ILIAS  Release_3_10_x_branch Revision 61812
 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  switch($a_name)
177  {
178  case "template" :
179  $this->template_name = $a_attribs["name"];
180  break;
181 
182  case "style" :
183  $this->styles[$a_attribs["id"]] =
184  array( "id" => $a_attribs["id"],
185  "name" => $a_attribs["name"],
186  "css_file" => $a_attribs["id"].".css",
187  "image_directory" => $a_attribs["image_directory"],
188  "sound_directory" => $a_attribs["sound_directory"]
189  );
190  $browsers =
191  explode(",", $a_attribs["browsers"]);
192  foreach ($browsers as $val)
193  {
194  $this->styles[$a_attribs["id"]]["browsers"][] = trim($val);
195  }
196  break;
197  }
198  }
199 
200 
209  static function styleExists($skin, $style)
210  {
211  if ($skin == "default")
212  {
213  if (is_file("./templates/".$skin."/template.xml") &&
214  is_file("./templates/".$skin."/".$style.".css")
215  )
216  {
217  return true;
218  }
219  }
220  else
221  {
222  if (is_file("./Customizing/global/skin/".$skin."/template.xml") &&
223  is_file("./Customizing/global/skin/".$skin."/".$style.".css")
224  )
225  {
226  return true;
227  }
228  }
229  return false;
230  }
231 
239  static function skinExists($skin)
240  {
241  if ($skin == "default")
242  {
243  if (is_file("./templates/".$skin."/template.xml"))
244  {
245  return true;
246  }
247  }
248  else
249  {
250  if (is_file("./Customizing/global/skin/".$skin."/template.xml"))
251  {
252  return true;
253  }
254  }
255  return false;
256  }
257 
265  function handlerCharacterData($a_xml_parser,$a_data)
266  {
267  // DELETE WHITESPACES AND NEWLINES OF CHARACTER DATA
268  $a_data = preg_replace("/\n/","",$a_data);
269  $a_data = preg_replace("/\t+/","",$a_data);
270 
271  if(!empty($a_data))
272  {
273  switch($this->current_tag)
274  {
275  default:
276  break;
277  }
278  }
279  }
280 
288  function handlerEndTag($a_xml_parser,$a_name)
289  {
290  }
291 }
292 ?>