ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilStyleDefinition.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 
33 require_once("./classes/class.ilSaxParser.php");
34 
36 {
37 
45  function ilStyleDefinition($a_template_id = "")
46  {
47  global $ilias;
48 
49  if ($a_template_id == "")
50  {
51  $a_template_id = $ilias->account->skin;
52  }
53 
54  if ($a_template_id == "default")
55  {
56  parent::ilSaxParser("./templates/".$a_template_id."/template.xml");
57  }
58  else
59  {
60  parent::ilSaxParser("./Customizing/global/skin/".$a_template_id."/template.xml");
61  }
62  }
63 
64 
65  // PUBLIC METHODS
66 
73  function getStyles()
74  {
75 //echo ":".count($this->styles).":";
76  if (is_array($this->styles))
77  {
78  return $this->styles;
79  }
80  else
81  {
82  return array();
83  }
84  }
85 
86  function getTemplateName()
87  {
88  return $this->template_name;
89  }
90 
91 
92  function getStyle($a_id)
93  {
94  return $this->styles[$a_id];
95  }
96 
97 
98  function getStyleName($a_id)
99  {
100  return $this->styles[$a_id]["name"];
101  }
102 
103 
104  function getImageDirectory($a_id)
105  {
106  return $this->styles[$a_id]["image_directory"];
107  }
108 
109  function getSoundDirectory($a_id)
110  {
111  return $this->styles[$a_id]["sound_directory"];
112  }
113 
114  public static function _getAllTemplates()
115  {
116  $skins = array();
117 
118  $skins[] = array("id" => "default");
119  if ($dp = @opendir("./Customizing/global/skin"))
120  {
121  while (($file = readdir($dp)) != false)
122  {
123  //is the file a directory?
124  if (is_dir("./Customizing/global/skin/".$file) && $file != "." && $file != ".." && $file != "CVS"
125  && $file != ".svn")
126  {
127  if (is_file("./Customizing/global/skin/".$file."/template.xml"))
128  {
129  $skins[] = array(
130  "id" => $file
131  );
132  }
133  }
134  } // while
135  }
136  else
137  {
138  return $skins;
139  }
140 
141  return $skins;
142 
143  }
144 
145  function getAllTemplates()
146  {
147  return self::_getAllTemplates();
148  }
149 
150 
151  // PRIVATE METHODS
152 
159  function setHandlers($a_xml_parser)
160  {
161  xml_set_object($a_xml_parser,$this);
162  xml_set_element_handler($a_xml_parser, 'handlerBeginTag', 'handlerEndTag');
163  xml_set_character_data_handler($a_xml_parser, 'handlerCharacterData');
164  }
165 
174  function handlerBeginTag($a_xml_parser, $a_name, $a_attribs)
175  {
176  if (!isset($a_attribs["sound_directory"]))
177  {
178  $a_attribs["sound_directory"] = "";
179  }
180 
181  if (!isset($a_attribs["browsers"]))
182  {
183  $a_attribs["browsers"] = "";
184  }
185 
186  switch($a_name)
187  {
188  case "template" :
189  $this->template_name = $a_attribs["name"];
190  break;
191 
192  case "style" :
193  $this->styles[$a_attribs["id"]] =
194  array( "id" => $a_attribs["id"],
195  "name" => $a_attribs["name"],
196  "css_file" => $a_attribs["id"].".css",
197  "image_directory" => $a_attribs["image_directory"],
198  "sound_directory" => $a_attribs["sound_directory"]
199  );
200  $browsers =
201  explode(",", $a_attribs["browsers"]);
202  foreach ($browsers as $val)
203  {
204  $this->styles[$a_attribs["id"]]["browsers"][] = trim($val);
205  }
206  break;
207  }
208  }
209 
210 
219  static function styleExists($skin, $style)
220  {
221  if ($skin == "default")
222  {
223  if (is_file("./templates/".$skin."/template.xml") &&
224  is_file("./templates/".$skin."/".$style.".css")
225  )
226  {
227  return true;
228  }
229  }
230  else
231  {
232  if (is_file("./Customizing/global/skin/".$skin."/template.xml") &&
233  is_file("./Customizing/global/skin/".$skin."/".$style.".css")
234  )
235  {
236  return true;
237  }
238  }
239  return false;
240  }
241 
249  static function skinExists($skin)
250  {
251  if ($skin == "default")
252  {
253  if (is_file("./templates/".$skin."/template.xml"))
254  {
255  return true;
256  }
257  }
258  else
259  {
260  if (is_file("./Customizing/global/skin/".$skin."/template.xml"))
261  {
262  return true;
263  }
264  }
265  return false;
266  }
267 
275  function handlerCharacterData($a_xml_parser,$a_data)
276  {
277  // DELETE WHITESPACES AND NEWLINES OF CHARACTER DATA
278  $a_data = preg_replace("/\n/","",$a_data);
279  $a_data = preg_replace("/\t+/","",$a_data);
280 
281  if(!empty($a_data))
282  {
283  switch($this->current_tag)
284  {
285  default:
286  break;
287  }
288  }
289  }
290 
298  function handlerEndTag($a_xml_parser,$a_name)
299  {
300  }
301 }
302 ?>