ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 ()
 
 getTemplateVersion ()
 
 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 125 of file class.ilStyleDefinition.php.

126 {
127 $skins = array();
128
129 $skins[] = array("id" => "default");
130 if ($dp = @opendir("./Customizing/global/skin"))
131 {
132 while (($file = readdir($dp)) != false)
133 {
134 //is the file a directory?
135 if (is_dir("./Customizing/global/skin/".$file) && $file != "." && $file != ".." && $file != "CVS"
136 && $file != ".svn")
137 {
138 if (is_file("./Customizing/global/skin/".$file."/template.xml"))
139 {
140 $skins[] = array(
141 "id" => $file
142 );
143 }
144 }
145 } // while
146 }
147 else
148 {
149 return $skins;
150 }
151
152 return $skins;
153
154 }
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 592 of file class.ilStyleDefinition.php.

594 {
595 global $ilDB;
596
597 $ilDB->manipulate("DELETE FROM syst_style_cat WHERE ".
598 " skin_id = ".$ilDB->quote($a_skin_id, "text").
599 " AND style_id = ".$ilDB->quote($a_style_id, "text").
600 " AND substyle = ".$ilDB->quote($a_substyle, "text").
601 " AND category_ref_id = ".$ilDB->quote($a_ref_id, "integer"));
602 }
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 505 of file class.ilStyleDefinition.php.

506 {
507 global $styleDefinition;
508
509 $all_styles = array();
510
511 $templates = $styleDefinition->getAllTemplates();
512
513 foreach ($templates as $template)
514 {
515 // get styles definition for template
516 $styleDef = new ilStyleDefinition($template["id"]);
517 $styleDef->startParsing();
518 $styles = $styleDef->getStyles();
519
520 foreach ($styles as $style)
521 {
522 $num_users = ilObjUser::_getNumberOfUsersForStyle($template["id"], $style["id"]);
523
524 // default selection list
525 $all_styles[$template["id"].":".$style["id"]] =
526 array (
527 "title" => $styleDef->getTemplateName()." / ".$style["name"],
528 "id" => $template["id"].":".$style["id"],
529 "template_id" => $template["id"],
530 "style_id" => $style["id"],
531 "template_name" => $styleDef->getTemplateName(),
532 "substyle" => $style["substyle"],
533 "style_name" => $style["name"],
534 "users" => $num_users
535 );
536 }
537 }
538
539 return $all_styles;
540 }
_getNumberOfUsersForStyle($a_skin, $a_style)
skins and styles
ilStyleDefinition($a_template_id="")
Constructor.
$style
Definition: example_012.php:70

References $style, 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 156 of file class.ilStyleDefinition.php.

157 {
158 return self::_getAllTemplates();
159 }

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

429 {
430 global $ilias;
431
432 if (isset(self::$current_master_style))
433 {
435 }
436
437 $cs = $ilias->account->prefs['style'];
438
439 self::$current_master_style = $cs;
440
441 return $cs;
442 }

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

363 {
364 global $ilias, $tree, $styleDefinition, $tree;
365
366 if (isset(self::$current_style))
367 {
369 }
370
371 if(!is_object($ilias))
372 {
373 return null;
374 }
375
376 $cs = $ilias->account->prefs['style'];
377
378 if (is_object($styleDefinition))
379 {
380 // are there any substyles?
381 $styles = $styleDefinition->getStyles();
382 if (is_array($styles[$cs]["substyle"]))
383 {
384 // read assignments, if given
385 $assignmnts = self::getSystemStyleCategoryAssignments(self::getCurrentSkin(), $cs);
386 if (count($assignmnts) > 0)
387 {
388 $ref_ass = array();
389 foreach ($assignmnts as $a)
390 {
391 $ref_ass[$a["ref_id"]] = $a["substyle"];
392 }
393
394 // check whether any ref id assigns a new style
395 if (is_object($tree) && $_GET["ref_id"] > 0 &&
396 $tree->isInTree($_GET["ref_id"]))
397 {
398 $path = $tree->getPathId((int) $_GET["ref_id"]);
399 for ($i = count($path) - 1; $i >= 0; $i--)
400 {
401 if (isset($ref_ass[$path[$i]]))
402 {
403 self::$current_style = $ref_ass[$path[$i]];
405 }
406 }
407 }
408 }
409 }
410 }
411
412 if ($_GET["ref_id"] != "")
413 {
414 self::$current_style = $cs;
415 }
416
417 return $cs;
418 }
$_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 111 of file class.ilStyleDefinition.php.

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

◆ getSoundDirectory()

ilStyleDefinition::getSoundDirectory (   $a_id)

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

121 {
122 return $this->styles[$a_id]["sound_directory"];
123 }

◆ getStyle()

ilStyleDefinition::getStyle (   $a_id)

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

101 {
102 return $this->styles[$a_id];
103 }

◆ getStyleName()

ilStyleDefinition::getStyleName (   $a_id)

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

107 {
108 return $this->styles[$a_id]["name"];
109 }

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

550 {
551 global $ilDB;
552
553 $assignmnts = array();
554 $set = $ilDB->query("SELECT substyle, category_ref_id FROM syst_style_cat ".
555 " WHERE skin_id = ".$ilDB->quote($a_skin_id, "text").
556 " AND style_id = ".$ilDB->quote($a_style_id, "text")
557 );
558 while ($rec = $ilDB->fetchAssoc($set))
559 {
560 $assignmnts[] = array("substyle" => $rec["substyle"],
561 "ref_id" => $rec["category_ref_id"]);
562 }
563 return $assignmnts;
564 }

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 }
$template_id
Definition: example_062.php:89

References $template_id.

◆ getTemplateName()

ilStyleDefinition::getTemplateName ( )

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

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

◆ getTemplateVersion()

ilStyleDefinition::getTemplateVersion ( )

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

96 {
97 return $this->template_version;
98 }

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

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

◆ handlerCharacterData()

ilStyleDefinition::handlerCharacterData (   $a_xml_parser,
  $a_data 
)

end tag handler

Parameters
ressouceinternal xml_parser_handler
stringdata @access private

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

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

◆ handlerEndTag()

ilStyleDefinition::handlerEndTag (   $a_xml_parser,
  $a_name 
)

end tag handler

Parameters
ressouceinternal xml_parser_handler
stringelement tag name @access private

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

322 {
323 }

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

475 {
476 global $styleDefinition;
477
478 if (is_object($styleDefinition)
479 and $styleDefinition->getTemplateId() != $a_skin)
480 {
481 $styleDefinition = new ilStyleDefinition($a_skin);
482 $styleDefinition->startParsing();
483 }
484
485 self::$current_skin = $a_skin;
486 }

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

495 {
496 self::$current_style = $a_style;
497 }

◆ setHandlers()

ilStyleDefinition::setHandlers (   $a_xml_parser)

set event handler

Parameters
ressouceinternal xml_parser_handler @access private

Reimplemented from ilSaxParser.

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

171 {
172 xml_set_object($a_xml_parser,$this);
173 xml_set_element_handler($a_xml_parser, 'handlerBeginTag', 'handlerEndTag');
174 xml_set_character_data_handler($a_xml_parser, 'handlerCharacterData');
175 }

◆ skinExists()

static ilStyleDefinition::skinExists (   $skin)
static

Check wheter a skin exists.

Parameters
string$skinskin id
Returns
boolean

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

273 {
274 if ($skin == "default")
275 {
276 if (is_file("./templates/".$skin."/template.xml"))
277 {
278 return true;
279 }
280 }
281 else
282 {
283 if (is_file("./Customizing/global/skin/".$skin."/template.xml"))
284 {
285 return true;
286 }
287 }
288 return false;
289 }

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

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

References $style.

◆ writeSystemStyleCategoryAssignment()

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

Write category assignment.

Parameters

return

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

574 {
575 global $ilDB;
576
577 $ilDB->manipulate("INSERT INTO syst_style_cat ".
578 "(skin_id, style_id, substyle, category_ref_id) VALUES (".
579 $ilDB->quote($a_skin_id, "text").",".
580 $ilDB->quote($a_style_id, "text").",".
581 $ilDB->quote($a_substyle, "text").",".
582 $ilDB->quote($a_ref_id, "integer").
583 ")");
584 }

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: