Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00034 require_once("classes/class.ilSaxParser.php");
00035
00036 class ilStyleDefinition extends ilSaxParser
00037 {
00038
00046 function ilStyleDefinition($a_template_id = "")
00047 {
00048 global $ilias;
00049
00050 if ($a_template_id == "")
00051 {
00052 $a_template_id = $ilias->account->skin;
00053 }
00054
00055 parent::ilSaxParser("./templates/".$a_template_id."/template.xml");
00056 }
00057
00058
00059
00060
00067 function getStyles()
00068 {
00069
00070 if (is_array($this->styles))
00071 {
00072 return $this->styles;
00073 }
00074 else
00075 {
00076 return array();
00077 }
00078 }
00079
00080 function getTemplateName()
00081 {
00082 return $this->template_name;
00083 }
00084
00085
00086 function getStyle($a_id)
00087 {
00088 return $this->styles[$a_id];
00089 }
00090
00091
00092 function getStyleName($a_id)
00093 {
00094 return $this->styles[$a_id]["name"];
00095 }
00096
00097
00098 function getImageDirectory($a_id)
00099 {
00100 return $this->styles[$a_id]["image_directory"];
00101 }
00102
00103 function getAllTemplates()
00104 {
00105 global $ilias;
00106
00107 $skins = array();
00108
00109 if ($dp = @opendir($ilias->tplPath))
00110 {
00111 while (($file = readdir($dp)) != false)
00112 {
00113
00114 if (is_dir($ilias->tplPath.$file) && $file != "." && $file != ".." && $file != "CVS")
00115 {
00116 if (is_file($ilias->tplPath.$file."/template.xml"))
00117 {
00118 $skins[] = array(
00119 "id" => $file
00120 );
00121 }
00122 }
00123 }
00124 }
00125 else
00126 {
00127 return false;
00128 }
00129 return $skins;
00130 }
00131
00132
00133
00140 function setHandlers($a_xml_parser)
00141 {
00142 xml_set_object($a_xml_parser,$this);
00143 xml_set_element_handler($a_xml_parser, 'handlerBeginTag', 'handlerEndTag');
00144 xml_set_character_data_handler($a_xml_parser, 'handlerCharacterData');
00145 }
00146
00155 function handlerBeginTag($a_xml_parser, $a_name, $a_attribs)
00156 {
00157 switch($a_name)
00158 {
00159 case "template" :
00160 $this->template_name = $a_attribs["name"];
00161 break;
00162
00163 case "style" :
00164 $this->styles[$a_attribs["id"]] =
00165 array( "id" => $a_attribs["id"],
00166 "name" => $a_attribs["name"],
00167 "css_file" => $a_attribs["id"].".css",
00168 "image_directory" => $a_attribs["image_directory"]
00169 );
00170 $browsers =
00171 explode(",", $a_attribs["browsers"]);
00172 foreach ($browsers as $val)
00173 {
00174 $this->styles[$a_attribs["id"]]["browsers"][] = trim($val);
00175 }
00176 break;
00177 }
00178 }
00179
00187 function handlerCharacterData($a_xml_parser,$a_data)
00188 {
00189
00190 $a_data = preg_replace("/\n/","",$a_data);
00191 $a_data = preg_replace("/\t+/","",$a_data);
00192
00193 if(!empty($a_data))
00194 {
00195 switch($this->current_tag)
00196 {
00197 default:
00198 break;
00199 }
00200 }
00201 }
00202
00210 function handlerEndTag($a_xml_parser,$a_name)
00211 {
00212 }
00213 }
00214 ?>