ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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 @access 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 @access 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 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.

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

References $file.

Referenced by getAllTemplates(), and ilUserImportParser\ilUserImportParser().

+ 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

return

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

566 {
567 global $ilDB;
568
569 $ilDB->manipulate("DELETE FROM syst_style_cat WHERE ".
570 " skin_id = ".$ilDB->quote($a_skin_id, "text").
571 " AND style_id = ".$ilDB->quote($a_style_id, "text").
572 " AND substyle = ".$ilDB->quote($a_substyle, "text").
573 " AND category_ref_id = ".$ilDB->quote($a_ref_id, "integer"));
574 }
global $ilDB

References $ilDB.

Referenced by ilObjStyleSettingsGUI\deleteSysStyleCatAssignmentsObject().

+ Here is the caller graph for this function:

◆ getAllSkinStyles()

static ilStyleDefinition::getAllSkinStyles ( )
static

Get all skins/styles.

Parameters

return

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

478 {
479 global $styleDefinition;
480
481 $all_styles = array();
482
483 $templates = $styleDefinition->getAllTemplates();
484
485 foreach ($templates as $template)
486 {
487 // get styles definition for template
488 $styleDef = new ilStyleDefinition($template["id"]);
489 $styleDef->startParsing();
490 $styles = $styleDef->getStyles();
491
492 foreach ($styles as $style)
493 {
494 $num_users = ilObjUser::_getNumberOfUsersForStyle($template["id"], $style["id"]);
495
496 // default selection list
497 $all_styles[$template["id"].":".$style["id"]] =
498 array (
499 "title" => $styleDef->getTemplateName()." / ".$style["name"],
500 "id" => $template["id"].":".$style["id"],
501 "template_id" => $template["id"],
502 "style_id" => $style["id"],
503 "template_name" => $styleDef->getTemplateName(),
504 "substyle" => $style["substyle"],
505 "style_name" => $style["name"],
506 "users" => $num_users
507 );
508 }
509 }
510
511 return $all_styles;
512 }
_getNumberOfUsersForStyle($a_skin, $a_style)
skins and styles
ilStyleDefinition($a_template_id="")
Constructor.

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

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

+ 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 }

References _getAllTemplates().

+ Here is the call graph for this function:

◆ 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 424 of file class.ilStyleDefinition.php.

425 {
426 global $ilias;
427
428 if (isset(self::$current_master_style))
429 {
431 }
432
433 $cs = $ilias->account->prefs['style'];
434
435 self::$current_master_style = $cs;
436
437 return $cs;
438 }

References $current_master_style, and ilSaxParser\$ilias.

Referenced by ilUtil\getImagePath().

+ 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|null style id

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

359 {
360 global $ilias, $tree, $styleDefinition, $tree;
361
362 if (isset(self::$current_style))
363 {
365 }
366
367 if(!is_object($ilias))
368 {
369 return null;
370 }
371
372 $cs = $ilias->account->prefs['style'];
373
374 if (is_object($styleDefinition))
375 {
376 // are there any substyles?
377 $styles = $styleDefinition->getStyles();
378 if (is_array($styles[$cs]["substyle"]))
379 {
380 // read assignments, if given
381 $assignmnts = self::getSystemStyleCategoryAssignments(self::getCurrentSkin(), $cs);
382 if (count($assignmnts) > 0)
383 {
384 $ref_ass = array();
385 foreach ($assignmnts as $a)
386 {
387 $ref_ass[$a["ref_id"]] = $a["substyle"];
388 }
389
390 // check whether any ref id assigns a new style
391 if (is_object($tree) && $_GET["ref_id"] > 0 &&
392 $tree->isInTree($_GET["ref_id"]))
393 {
394 $path = $tree->getPathId((int) $_GET["ref_id"]);
395 for ($i = count($path) - 1; $i >= 0; $i--)
396 {
397 if (isset($ref_ass[$path[$i]]))
398 {
399 self::$current_style = $ref_ass[$path[$i]];
401 }
402 }
403 }
404 }
405 }
406 }
407
408 if ($_GET["ref_id"] != "")
409 {
410 self::$current_style = $cs;
411 }
412
413 return $cs;
414 }
$_GET["client_id"]
static getSystemStyleCategoryAssignments($a_skin_id, $a_style_id)
Get all system style category assignments.
$path
Definition: index.php:22

References $_GET, $current_style, ilSaxParser\$ilias, $path, and getSystemStyleCategoryAssignments().

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

+ Here is the call graph for this function:
+ 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 @access 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 521 of file class.ilStyleDefinition.php.

522 {
523 global $ilDB;
524
525 $assignmnts = array();
526 $set = $ilDB->query("SELECT substyle, category_ref_id FROM syst_style_cat ".
527 " WHERE skin_id = ".$ilDB->quote($a_skin_id, "text").
528 " AND style_id = ".$ilDB->quote($a_style_id, "text")
529 );
530 while ($rec = $ilDB->fetchAssoc($set))
531 {
532 $assignmnts[] = array("substyle" => $rec["substyle"],
533 "ref_id" => $rec["category_ref_id"]);
534 }
535 return $assignmnts;
536 }

References $ilDB.

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

+ 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 @access 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 @access 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 @access private

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

318 {
319 }

◆ ilStyleDefinition()

ilStyleDefinition::ilStyleDefinition (   $a_template_id = "")

Constructor.

parse

@access public

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

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 }

References ilSaxParser\$ilias.

Referenced by getAllSkinStyles(), and setCurrentSkin().

+ 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 446 of file class.ilStyleDefinition.php.

447 {
448 global $styleDefinition;
449
450 if (is_object($styleDefinition)
451 and $styleDefinition->getTemplateId() != $a_skin)
452 {
453 $styleDefinition = new ilStyleDefinition($a_skin);
454 $styleDefinition->startParsing();
455 }
456
457 self::$current_skin = $a_skin;
458 }

References ilStyleDefinition().

+ 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 466 of file class.ilStyleDefinition.php.

467 {
468 self::$current_style = $a_style;
469 }

◆ setHandlers()

ilStyleDefinition::setHandlers (   $a_xml_parser)

set event handler

Parameters
ressouceinternal xml_parser_handler @access private

Reimplemented from ilSaxParser.

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.

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 }

Referenced by ilObjUser\read().

+ 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

return

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

546 {
547 global $ilDB;
548
549 $ilDB->manipulate("INSERT INTO syst_style_cat ".
550 "(skin_id, style_id, substyle, category_ref_id) VALUES (".
551 $ilDB->quote($a_skin_id, "text").",".
552 $ilDB->quote($a_style_id, "text").",".
553 $ilDB->quote($a_substyle, "text").",".
554 $ilDB->quote($a_ref_id, "integer").
555 ")");
556 }

References $ilDB.

Referenced by ilObjStyleSettingsGUI\saveStyleCatAssignmentObject().

+ 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.

Referenced by getCurrentMasterStyle().

◆ $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.

Referenced by getCurrentStyle().


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