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
00033 require_once("classes/class.ilSaxParser.php");
00034
00035 class ilStyleDefinition extends ilSaxParser
00036 {
00037
00045 function ilStyleDefinition($a_template_id = "")
00046 {
00047 global $ilias;
00048
00049 if ($a_template_id == "")
00050 {
00051 $a_template_id = $ilias->account->skin;
00052 }
00053
00054 if ($a_template_id == "default")
00055 {
00056 parent::ilSaxParser("./templates/".$a_template_id."/template.xml");
00057 }
00058 else
00059 {
00060 parent::ilSaxParser("./Customizing/global/skin/".$a_template_id."/template.xml");
00061 }
00062 }
00063
00064
00065
00066
00073 function getStyles()
00074 {
00075
00076 if (is_array($this->styles))
00077 {
00078 return $this->styles;
00079 }
00080 else
00081 {
00082 return array();
00083 }
00084 }
00085
00086 function getTemplateName()
00087 {
00088 return $this->template_name;
00089 }
00090
00091
00092 function getStyle($a_id)
00093 {
00094 return $this->styles[$a_id];
00095 }
00096
00097
00098 function getStyleName($a_id)
00099 {
00100 return $this->styles[$a_id]["name"];
00101 }
00102
00103
00104 function getImageDirectory($a_id)
00105 {
00106 return $this->styles[$a_id]["image_directory"];
00107 }
00108
00109 function getSoundDirectory($a_id)
00110 {
00111 return $this->styles[$a_id]["sound_directory"];
00112 }
00113
00114 function getAllTemplates()
00115 {
00116 global $ilias;
00117
00118 $skins = array();
00119
00120 $skins[] = array("id" => "default");
00121 if ($dp = @opendir("./Customizing/global/skin"))
00122 {
00123 while (($file = readdir($dp)) != false)
00124 {
00125
00126 if (is_dir("./Customizing/global/skin/".$file) && $file != "." && $file != ".." && $file != "CVS"
00127 && $file != ".svn")
00128 {
00129 if (is_file("./Customizing/global/skin/".$file."/template.xml"))
00130 {
00131 $skins[] = array(
00132 "id" => $file
00133 );
00134 }
00135 }
00136 }
00137 }
00138 else
00139 {
00140 return $skins;
00141 }
00142
00143 return $skins;
00144 }
00145
00146
00147
00154 function setHandlers($a_xml_parser)
00155 {
00156 xml_set_object($a_xml_parser,$this);
00157 xml_set_element_handler($a_xml_parser, 'handlerBeginTag', 'handlerEndTag');
00158 xml_set_character_data_handler($a_xml_parser, 'handlerCharacterData');
00159 }
00160
00169 function handlerBeginTag($a_xml_parser, $a_name, $a_attribs)
00170 {
00171 switch($a_name)
00172 {
00173 case "template" :
00174 $this->template_name = $a_attribs["name"];
00175 break;
00176
00177 case "style" :
00178 $this->styles[$a_attribs["id"]] =
00179 array( "id" => $a_attribs["id"],
00180 "name" => $a_attribs["name"],
00181 "css_file" => $a_attribs["id"].".css",
00182 "image_directory" => $a_attribs["image_directory"],
00183 "sound_directory" => $a_attribs["sound_directory"]
00184 );
00185 $browsers =
00186 explode(",", $a_attribs["browsers"]);
00187 foreach ($browsers as $val)
00188 {
00189 $this->styles[$a_attribs["id"]]["browsers"][] = trim($val);
00190 }
00191 break;
00192 }
00193 }
00194
00195
00204 static function styleExists($skin, $style)
00205 {
00206 if ($skin == "default")
00207 {
00208 if (is_file("./templates/".$skin."/template.xml") &&
00209 is_file("./templates/".$skin."/".$style.".css")
00210 )
00211 {
00212 return true;
00213 }
00214 }
00215 else
00216 {
00217 if (is_file("./Customizing/global/skin/".$skin."/template.xml") &&
00218 is_file("./Customizing/global/skin/".$skin."/".$style.".css")
00219 )
00220 {
00221 return true;
00222 }
00223 }
00224 return false;
00225 }
00226
00234 static function skinExists($skin)
00235 {
00236 if ($skin == "default")
00237 {
00238 if (is_file("./templates/".$skin."/template.xml"))
00239 {
00240 return true;
00241 }
00242 }
00243 else
00244 {
00245 if (is_file("./Customizing/global/skin/".$skin."/template.xml"))
00246 {
00247 return true;
00248 }
00249 }
00250 return false;
00251 }
00252
00260 function handlerCharacterData($a_xml_parser,$a_data)
00261 {
00262
00263 $a_data = preg_replace("/\n/","",$a_data);
00264 $a_data = preg_replace("/\t+/","",$a_data);
00265
00266 if(!empty($a_data))
00267 {
00268 switch($this->current_tag)
00269 {
00270 default:
00271 break;
00272 }
00273 }
00274 }
00275
00283 function handlerEndTag($a_xml_parser,$a_name)
00284 {
00285 }
00286 }
00287 ?>