ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
ilStyleDefinition Class Reference

parses the template.xml that defines all styles of the current template More...

+ Inheritance diagram for ilStyleDefinition:
+ Collaboration diagram for ilStyleDefinition:

Public Member Functions

 ilStyleDefinition ($a_template_id="")
 Constructor. More...
 
 getStyles ()
 get translation type (sys, db or 0)s More...
 
 getTemplateId ()
 
 getTemplateName ()
 
 getStyle ($a_id)
 
 getStyleName ($a_id)
 
 getImageDirectory ($a_master_style, $a_substyle="")
 
 getSoundDirectory ($a_id)
 
 getAllTemplates ()
 
 setHandlers ($a_xml_parser)
 set event handler More...
 
 handlerBeginTag ($a_xml_parser, $a_name, $a_attribs)
 start tag handler More...
 
 handlerCharacterData ($a_xml_parser, $a_data)
 end tag handler More...
 
 handlerEndTag ($a_xml_parser, $a_name)
 end tag handler More...
 
 writeSystemStyleCategoryAssignment ($a_skin_id, $a_style_id, $a_substyle, $a_ref_id)
 Write category assignment. More...
 
 deleteSystemStyleCategoryAssignment ($a_skin_id, $a_style_id, $a_substyle, $a_ref_id)
 Delete category style assignment. More...
 
- Public Member Functions inherited from ilSaxParser
 ilSaxParser ($a_xml_file='', $throwException=false)
 Constructor setup ILIAS global object public. More...
 
 setXMLContent ($a_xml_content)
 
 getXMLContent ()
 
 getInputType ()
 
 startParsing ()
 stores xml data in array More...
 
 createParser ()
 create parser More...
 
 setOptions ($a_xml_parser)
 set parser options More...
 
 setHandlers ($a_xml_parser)
 set event handler should be overwritten by inherited class private More...
 
 openXMLFile ()
 open xml file More...
 
 parse ($a_xml_parser, $a_fp=null)
 parse xml file More...
 
 freeParser ($a_xml_parser)
 free xml parser handle More...
 
 setThrowException ($throwException)
 set error handling More...
 
- Public Member Functions inherited from PEAR
 PEAR ($error_class=null)
 Constructor. More...
 
 _PEAR ()
 Destructor (the emulated type of...). More...
 
getStaticProperty ($class, $var)
 If you have a class that's mostly/entirely static, and you need static properties, you can use this method to simulate them. More...
 
 registerShutdownFunc ($func, $args=array())
 Use this function to register a shutdown method for static classes. More...
 
 isError ($data, $code=null)
 Tell whether a value is a PEAR error. More...
 
 setErrorHandling ($mode=null, $options=null)
 Sets how errors generated by this object should be handled. More...
 
 expectError ($code=' *')
 This method is used to tell which errors you expect to get. More...
 
 popExpect ()
 This method pops one element off the expected error codes stack. More...
 
 _checkDelExpect ($error_code)
 This method checks unsets an error code if available. More...
 
 delExpect ($error_code)
 This method deletes all occurences of the specified element from the expected error codes stack. More...
 
raiseError ($message=null, $code=null, $mode=null, $options=null, $userinfo=null, $error_class=null, $skipmsg=false)
 This method is a wrapper that returns an instance of the configured error class with this object's default error handling applied. More...
 
throwError ($message=null, $code=null, $userinfo=null)
 Simpler form of raiseError with fewer options. More...
 
 staticPushErrorHandling ($mode, $options=null)
 
 staticPopErrorHandling ()
 
 pushErrorHandling ($mode, $options=null)
 Push a new error handler on top of the error handler options stack. More...
 
 popErrorHandling ()
 Pop the last error handler used. More...
 
 loadExtension ($ext)
 OS independant PHP extension load. More...
 

Static Public Member Functions

static _getAllTemplates ()
 
static styleExists ($skin, $style)
 Check wheter a style exists. More...
 
static skinExists ($skin)
 Check wheter a skin exists. More...
 
static getCurrentSkin ()
 get the current skin More...
 
static getCurrentStyle ()
 get the current style More...
 
static getCurrentMasterStyle ()
 get the current style More...
 
static setCurrentSkin ($a_skin)
 set a new current skin More...
 
static setCurrentStyle ($a_style)
 set a new current style More...
 
static getAllSkinStyles ()
 Get all skins/styles. More...
 
static getSystemStyleCategoryAssignments ($a_skin_id, $a_style_id)
 Get all system style category assignments. More...
 

Static Public Attributes

static $current_skin
 
static $current_style
 
static $current_master_style
 

Additional Inherited Members

- Data Fields inherited from ilSaxParser
 $input_type = null
 
 $xml_content = ''
 
 $ilias
 
 $lng
 
 $xml_file
 
 $throwException = false
 
- Data Fields inherited from PEAR
 $_debug = false
 
 $_default_error_mode = null
 
 $_default_error_options = null
 
 $_default_error_handler = ''
 
 $_error_class = 'PEAR_Error'
 
 $_expected_errors = array()
 
- Protected Member Functions inherited from ilSaxParser
 handleError ($message, $code)
 use given error handler to handle error message or internal ilias error message handle More...
 

Detailed Description

parses the template.xml that defines all styles of the current template

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 14 of file class.ilStyleDefinition.php.

Member Function Documentation

◆ _getAllTemplates()

static ilStyleDefinition::_getAllTemplates ( )
static

Definition at line 122 of file class.ilStyleDefinition.php.

References $file.

Referenced by ilUserImportParser\ilUserImportParser().

123  {
124  $skins = array();
125 
126  $skins[] = array("id" => "default");
127  if ($dp = @opendir("./Customizing/global/skin"))
128  {
129  while (($file = readdir($dp)) != false)
130  {
131  //is the file a directory?
132  if (is_dir("./Customizing/global/skin/".$file) && $file != "." && $file != ".." && $file != "CVS"
133  && $file != ".svn")
134  {
135  if (is_file("./Customizing/global/skin/".$file."/template.xml"))
136  {
137  $skins[] = array(
138  "id" => $file
139  );
140  }
141  }
142  } // while
143  }
144  else
145  {
146  return $skins;
147  }
148 
149  return $skins;
150 
151  }
print $file
+ Here is the caller graph for this function:

◆ deleteSystemStyleCategoryAssignment()

ilStyleDefinition::deleteSystemStyleCategoryAssignment (   $a_skin_id,
  $a_style_id,
  $a_substyle,
  $a_ref_id 
)

Delete category style assignment.

Parameters

Definition at line 547 of file class.ilStyleDefinition.php.

Referenced by ilObjStyleSettingsGUI\deleteSysStyleCatAssignmentsObject().

549  {
550  global $ilDB;
551 
552  $ilDB->manipulate("DELETE FROM syst_style_cat WHERE ".
553  " skin_id = ".$ilDB->quote($a_skin_id, "text").
554  " AND style_id = ".$ilDB->quote($a_style_id, "text").
555  " AND substyle = ".$ilDB->quote($a_substyle, "text").
556  " AND category_ref_id = ".$ilDB->quote($a_ref_id, "integer"));
557  }
+ Here is the caller graph for this function:

◆ getAllSkinStyles()

static ilStyleDefinition::getAllSkinStyles ( )
static

Get all skins/styles.

Parameters

Definition at line 460 of file class.ilStyleDefinition.php.

References ilObjUser\_getNumberOfUsersForStyle(), and ilStyleDefinition().

Referenced by ilObjStyleSettingsGUI\assignStylesToCatsObject(), ilObjStyleSettingsGUI\editSystemStylesObject(), ilSystemStylesTableGUI\getStyles(), and ilObjStyleSettingsGUI\saveStyleSettingsObject().

461  {
462  global $styleDefinition;
463 
464  $all_styles = array();
465 
466  $templates = $styleDefinition->getAllTemplates();
467 
468  foreach ($templates as $template)
469  {
470  // get styles definition for template
471  $styleDef = new ilStyleDefinition($template["id"]);
472  $styleDef->startParsing();
473  $styles = $styleDef->getStyles();
474 
475  foreach ($styles as $style)
476  {
477  $num_users = ilObjUser::_getNumberOfUsersForStyle($template["id"], $style["id"]);
478 
479  // default selection list
480  $all_styles[$template["id"].":".$style["id"]] =
481  array (
482  "title" => $styleDef->getTemplateName()." / ".$style["name"],
483  "id" => $template["id"].":".$style["id"],
484  "template_id" => $template["id"],
485  "style_id" => $style["id"],
486  "template_name" => $styleDef->getTemplateName(),
487  "substyle" => $style["substyle"],
488  "style_name" => $style["name"],
489  "users" => $num_users
490  );
491  }
492  }
493 
494  return $all_styles;
495  }
_getNumberOfUsersForStyle($a_skin, $a_style)
skins and styles
ilStyleDefinition($a_template_id="")
Constructor.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAllTemplates()

ilStyleDefinition::getAllTemplates ( )

Definition at line 153 of file class.ilStyleDefinition.php.

154  {
155  return self::_getAllTemplates();
156  }

◆ getCurrentMasterStyle()

static ilStyleDefinition::getCurrentMasterStyle ( )
static

get the current style

use always this function instead of getting the account's style the current style may be changed on the fly by setCurrentStyle()

Returns
string style id

Definition at line 407 of file class.ilStyleDefinition.php.

References ilSaxParser\$ilias.

Referenced by ilUtil\getImagePath().

408  {
409  global $ilias;
410 
411  if (isset(self::$current_master_style))
412  {
413  return self::$current_master_style;
414  }
415 
416  $cs = $ilias->account->prefs['style'];
417 
418  self::$current_master_style = $cs;
419 
420  return $cs;
421  }
+ Here is the caller graph for this function:

◆ getCurrentSkin()

static ilStyleDefinition::getCurrentSkin ( )
static

get the current skin

use always this function instead of getting the account's skin the current skin may be changed on the fly by setCurrentSkin()

Returns
string skin id

Definition at line 330 of file class.ilStyleDefinition.php.

References ilSaxParser\$ilias.

Referenced by ilUtil\getImagePath(), ilUtil\getJSLocation(), ilUtil\getNewContentStyleSheetLocation(), ilUtil\getStyleSheetLocation(), ilTestPDFGenerator\getTemplatePath(), and ilTemplate\getTemplatePath().

331  {
332  global $ilias;
333 
334  return isset(self::$current_skin) ? self::$current_skin :
335  $ilias->account->skin;
336  }
+ Here is the caller graph for this function:

◆ getCurrentStyle()

static ilStyleDefinition::getCurrentStyle ( )
static

get the current style

use always this function instead of getting the account's style the current style may be changed on the fly by setCurrentStyle()

Returns
string style id

Definition at line 346 of file class.ilStyleDefinition.php.

References $_GET, ilSaxParser\$ilias, and $path.

Referenced by ilUtil\getImagePath(), and ilUtil\getStyleSheetLocation().

347  {
348  global $ilias, $tree, $styleDefinition, $tree;
349 
350  if (isset(self::$current_style))
351  {
352  return self::$current_style;
353  }
354 
355  $cs = $ilias->account->prefs['style'];
356 
357  if (is_object($styleDefinition))
358  {
359  // are there any substyles?
360  $styles = $styleDefinition->getStyles();
361  if (is_array($styles[$cs]["substyle"]))
362  {
363  // read assignments, if given
364  $assignmnts = self::getSystemStyleCategoryAssignments(self::getCurrentSkin(), $cs);
365  if (count($assignmnts) > 0)
366  {
367  $ref_ass = array();
368  foreach ($assignmnts as $a)
369  {
370  $ref_ass[$a["ref_id"]] = $a["substyle"];
371  }
372 
373  // check whether any ref id assigns a new style
374  if (is_object($tree) && $_GET["ref_id"] > 0 &&
375  $tree->isInTree($_GET["ref_id"]))
376  {
377  $path = $tree->getPathId((int) $_GET["ref_id"]);
378  for ($i = count($path) - 1; $i >= 0; $i--)
379  {
380  if (isset($ref_ass[$path[$i]]))
381  {
382  self::$current_style = $ref_ass[$path[$i]];
383  return self::$current_style;
384  }
385  }
386  }
387  }
388  }
389  }
390 
391  if ($_GET["ref_id"] != "")
392  {
393  self::$current_style = $cs;
394  }
395 
396  return $cs;
397  }
$_GET["client_id"]
$path
Definition: index.php:22
+ Here is the caller graph for this function:

◆ getImageDirectory()

ilStyleDefinition::getImageDirectory (   $a_master_style,
  $a_substyle = "" 
)

Definition at line 108 of file class.ilStyleDefinition.php.

109  {
110  if ($a_substyle != $a_master_style && $a_substyle != "")
111  {
112  return $this->styles[$a_master_style]["substyle"][$a_substyle]["image_directory"];
113  }
114  return $this->styles[$a_master_style]["image_directory"];
115  }

◆ getSoundDirectory()

ilStyleDefinition::getSoundDirectory (   $a_id)

Definition at line 117 of file class.ilStyleDefinition.php.

118  {
119  return $this->styles[$a_id]["sound_directory"];
120  }

◆ getStyle()

ilStyleDefinition::getStyle (   $a_id)

Definition at line 96 of file class.ilStyleDefinition.php.

97  {
98  return $this->styles[$a_id];
99  }

◆ getStyleName()

ilStyleDefinition::getStyleName (   $a_id)

Definition at line 102 of file class.ilStyleDefinition.php.

103  {
104  return $this->styles[$a_id]["name"];
105  }

◆ getStyles()

ilStyleDefinition::getStyles ( )

get translation type (sys, db or 0)s

Parameters
stringobject type public

Definition at line 71 of file class.ilStyleDefinition.php.

72  {
73 //echo ":".count($this->styles).":";
74  if (is_array($this->styles))
75  {
76  return $this->styles;
77  }
78  else
79  {
80  return array();
81  }
82  }

◆ getSystemStyleCategoryAssignments()

static ilStyleDefinition::getSystemStyleCategoryAssignments (   $a_skin_id,
  $a_style_id 
)
static

Get all system style category assignments.

Parameters
string$a_skin_idskin id
string$a_style_idstyle id
Returns
array ref ids

Definition at line 504 of file class.ilStyleDefinition.php.

Referenced by ilSystemStylesTableGUI\fillRow(), and ilSysStyleCatAssignmentTableGUI\getStyleCatAssignments().

505  {
506  global $ilDB;
507 
508  $assignmnts = array();
509  $set = $ilDB->query("SELECT substyle, category_ref_id FROM syst_style_cat ".
510  " WHERE skin_id = ".$ilDB->quote($a_skin_id, "text").
511  " AND style_id = ".$ilDB->quote($a_style_id, "text")
512  );
513  while ($rec = $ilDB->fetchAssoc($set))
514  {
515  $assignmnts[] = array("substyle" => $rec["substyle"],
516  "ref_id" => $rec["category_ref_id"]);
517  }
518  return $assignmnts;
519  }
+ Here is the caller graph for this function:

◆ getTemplateId()

ilStyleDefinition::getTemplateId ( )

Definition at line 84 of file class.ilStyleDefinition.php.

85  {
86  return $this->template_id;
87  }

◆ getTemplateName()

ilStyleDefinition::getTemplateName ( )

Definition at line 90 of file class.ilStyleDefinition.php.

91  {
92  return $this->template_name;
93  }

◆ handlerBeginTag()

ilStyleDefinition::handlerBeginTag (   $a_xml_parser,
  $a_name,
  $a_attribs 
)

start tag handler

Parameters
ressouceinternal xml_parser_handler
stringelement tag name
arrayelement attributes private

Definition at line 182 of file class.ilStyleDefinition.php.

183  {
184  if (!isset($a_attribs["sound_directory"]))
185  {
186  $a_attribs["sound_directory"] = "";
187  }
188 
189  if (!isset($a_attribs["browsers"]))
190  {
191  $a_attribs["browsers"] = "";
192  }
193 
194  switch($a_name)
195  {
196  case "template" :
197  $this->template_name = $a_attribs["name"];
198  break;
199 
200  case "style" :
201  $this->last_style_id = $a_attribs["id"];
202  $this->styles[$a_attribs["id"]] =
203  array( "id" => $a_attribs["id"],
204  "name" => $a_attribs["name"],
205  "css_file" => $a_attribs["id"].".css",
206  "image_directory" => $a_attribs["image_directory"],
207  "sound_directory" => $a_attribs["sound_directory"]
208  );
209  $browsers =
210  explode(",", $a_attribs["browsers"]);
211  foreach ($browsers as $val)
212  {
213  $this->styles[$a_attribs["id"]]["browsers"][] = trim($val);
214  }
215  break;
216 
217  case "substyle":
218  $this->styles[$this->last_style_id]["substyle"][$a_attribs["id"]] =
219  array( "id" => $a_attribs["id"],
220  "name" => $a_attribs["name"],
221  "css_file" => $a_attribs["id"].".css",
222  "image_directory" => $a_attribs["image_directory"],
223  "sound_directory" => $a_attribs["sound_directory"]
224  );
225  break;
226  }
227  }

◆ handlerCharacterData()

ilStyleDefinition::handlerCharacterData (   $a_xml_parser,
  $a_data 
)

end tag handler

Parameters
ressouceinternal xml_parser_handler
stringdata private

Definition at line 294 of file class.ilStyleDefinition.php.

295  {
296  // DELETE WHITESPACES AND NEWLINES OF CHARACTER DATA
297  $a_data = preg_replace("/\n/","",$a_data);
298  $a_data = preg_replace("/\t+/","",$a_data);
299 
300  if(!empty($a_data))
301  {
302  switch($this->current_tag)
303  {
304  default:
305  break;
306  }
307  }
308  }

◆ handlerEndTag()

ilStyleDefinition::handlerEndTag (   $a_xml_parser,
  $a_name 
)

end tag handler

Parameters
ressouceinternal xml_parser_handler
stringelement tag name private

Definition at line 317 of file class.ilStyleDefinition.php.

318  {
319  }

◆ ilStyleDefinition()

ilStyleDefinition::ilStyleDefinition (   $a_template_id = "")

Constructor.

parse

public

Definition at line 39 of file class.ilStyleDefinition.php.

References ilSaxParser\$ilias.

Referenced by getAllSkinStyles(), and setCurrentSkin().

40  {
41  global $ilias;
42 
43  if ($a_template_id == "")
44  {
45  // use function to get the current skin
46  $a_template_id = self::getCurrentSkin();
47  }
48 
49  // remember the template id
50  $this->template_id = $a_template_id;
51 
52  if ($a_template_id == "default")
53  {
54  parent::ilSaxParser("./templates/".$a_template_id."/template.xml");
55  }
56  else
57  {
58  parent::ilSaxParser("./Customizing/global/skin/".$a_template_id."/template.xml");
59  }
60  }
+ Here is the caller graph for this function:

◆ setCurrentSkin()

static ilStyleDefinition::setCurrentSkin (   $a_skin)
static

set a new current skin

Parameters
stringskin id

Definition at line 429 of file class.ilStyleDefinition.php.

References ilStyleDefinition().

430  {
431  global $styleDefinition;
432 
433  if (is_object($styleDefinition)
434  and $styleDefinition->getTemplateId() != $a_skin)
435  {
436  $styleDefinition = new ilStyleDefinition($a_skin);
437  $styleDefinition->startParsing();
438  }
439 
440  self::$current_skin = $a_skin;
441  }
ilStyleDefinition($a_template_id="")
Constructor.
+ Here is the call graph for this function:

◆ setCurrentStyle()

static ilStyleDefinition::setCurrentStyle (   $a_style)
static

set a new current style

Parameters
stringstyle id

Definition at line 449 of file class.ilStyleDefinition.php.

450  {
451  self::$current_style = $a_style;
452  }

◆ setHandlers()

ilStyleDefinition::setHandlers (   $a_xml_parser)

set event handler

Parameters
ressouceinternal xml_parser_handler private

Definition at line 167 of file class.ilStyleDefinition.php.

168  {
169  xml_set_object($a_xml_parser,$this);
170  xml_set_element_handler($a_xml_parser, 'handlerBeginTag', 'handlerEndTag');
171  xml_set_character_data_handler($a_xml_parser, 'handlerCharacterData');
172  }

◆ skinExists()

static ilStyleDefinition::skinExists (   $skin)
static

Check wheter a skin exists.

Parameters
string$skinskin id
Returns
boolean

Definition at line 268 of file class.ilStyleDefinition.php.

Referenced by ilObjUser\read().

269  {
270  if ($skin == "default")
271  {
272  if (is_file("./templates/".$skin."/template.xml"))
273  {
274  return true;
275  }
276  }
277  else
278  {
279  if (is_file("./Customizing/global/skin/".$skin."/template.xml"))
280  {
281  return true;
282  }
283  }
284  return false;
285  }
+ Here is the caller graph for this function:

◆ styleExists()

static ilStyleDefinition::styleExists (   $skin,
  $style 
)
static

Check wheter a style exists.

Parameters
string$skinskin id
string$stylestyle id
Returns
boolean

Definition at line 238 of file class.ilStyleDefinition.php.

239  {
240  if ($skin == "default")
241  {
242  if (is_file("./templates/".$skin."/template.xml") &&
243  is_file("./templates/".$skin."/".$style.".css")
244  )
245  {
246  return true;
247  }
248  }
249  else
250  {
251  if (is_file("./Customizing/global/skin/".$skin."/template.xml") &&
252  is_file("./Customizing/global/skin/".$skin."/".$style.".css")
253  )
254  {
255  return true;
256  }
257  }
258  return false;
259  }

◆ writeSystemStyleCategoryAssignment()

ilStyleDefinition::writeSystemStyleCategoryAssignment (   $a_skin_id,
  $a_style_id,
  $a_substyle,
  $a_ref_id 
)

Write category assignment.

Parameters

Definition at line 527 of file class.ilStyleDefinition.php.

Referenced by ilObjStyleSettingsGUI\saveStyleCatAssignmentObject().

529  {
530  global $ilDB;
531 
532  $ilDB->manipulate("INSERT INTO syst_style_cat ".
533  "(skin_id, style_id, substyle, category_ref_id) VALUES (".
534  $ilDB->quote($a_skin_id, "text").",".
535  $ilDB->quote($a_style_id, "text").",".
536  $ilDB->quote($a_substyle, "text").",".
537  $ilDB->quote($a_ref_id, "integer").
538  ")");
539  }
+ Here is the caller graph for this function:

Field Documentation

◆ $current_master_style

ilStyleDefinition::$current_master_style
static

Definition at line 29 of file class.ilStyleDefinition.php.

◆ $current_skin

ilStyleDefinition::$current_skin
static

Definition at line 20 of file class.ilStyleDefinition.php.

◆ $current_style

ilStyleDefinition::$current_style
static

Definition at line 27 of file class.ilStyleDefinition.php.


The documentation for this class was generated from the following file: