ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilStyleDefinition Class Reference

ilStyleDefinition acts as a wrapper of style related actions. More...

+ Collaboration diagram for ilStyleDefinition:

Public Member Functions

 __construct ($skin_id="", ilSystemStyleConfig $system_style_config=null)
 ilStyleDefinition constructor. More...
 
 getStyles ()
 
 getTemplateName ()
 
 getStyle ($a_id)
 
 getStyleName ($a_id)
 
 getImageDirectory ($style_id)
 
 getSoundDirectory ($style_id)
 
 getSkin ()
 
 setSkin ($skin)
 
 getSystemStylesConf ()
 
 setSystemStylesConf ($system_style_config)
 

Static Public Member Functions

static getCurrentSkin ()
 get the current skin More...
 
static getAllTemplates ()
 
static skinExists ($skin_id, ilSystemStyleConfig $system_style_config=null)
 Check whether a skin exists. More...
 
static getCurrentStyle ()
 get the current style or sub style More...
 
static getAllSkinStyles ()
 Get all skins/styles as array (convenient for tables) Attention: tempalte_name/template_id in this array is only used for legacy reasons an might be removed in future. More...
 
static setCurrentSkin ($a_skin)
 
static styleExists ($style_id)
 
static styleExistsForSkinId ($skin_id, $style_id)
 
static styleExistsForCurrentSkin ($style_id)
 
static setCurrentStyle ($a_style)
 
static getSkins ()
 
static setSkins ($skins)
 

Static Public Attributes

static $current_style = false
 
static $skins = []
 

Static Protected Member Functions

static getCachedAllStylesInformation ()
 
static setCachedAllStylesInformation ($cached_all_styles_information)
 

Protected Attributes

 $skin
 
 $system_style_config
 

Static Protected Attributes

static $cached_all_styles_information = null
 

Detailed Description

ilStyleDefinition acts as a wrapper of style related actions.

Use this class to get the systems current style. Currently some of the logic is not clearly separated from ilSystemStyleSettings. This is due to legacy reasons. In a future refactoring, this class might be completely merged with ilSystemStyleSettings.

The following terminology is used:

(system) style: A style that can be set as system style for the complete ILIAS installations. This includes, less css, fonts, icons and sounds as well as possible html tpl files to overide ILIAS templates. (stystem) sub style: A sub style can be assigned to exactly one system style to be displayed for a set of categories. skin: A skin can hold multiple style. A skin is defined by it's folder carrying the name of the skin and the template.xml in this exact folder, listing the skins styles and substyles. Mostly a skin caries exactly one style. Through the GUI in the administration it is not possible to define multiple style per skin. It is however possible to define multiple sub styles for one style stored in one skin. template: The template is the xml file of the skin storing the skin styles and sub styles information.

Skins, styles ans stub styles are always used globally (not client specific).

This class is currently also used as global $styleDefinition.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Timon Amstutz timon.nosp@m..ams.nosp@m.tutz@.nosp@m.ilub.nosp@m..unib.nosp@m.e.ch
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilStyleDefinition::__construct (   $skin_id = "",
ilSystemStyleConfig  $system_style_config = null 
)

ilStyleDefinition constructor.

Parameters
string$skin_id
ilSystemStyleConfig | null$system_style_config
Exceptions
ilSystemStyleException

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

References $system_style_config, getSystemStylesConf(), setSkin(), and setSystemStylesConf().

85  {
86  if ($skin_id == "") {
87  $skin_id = self::getCurrentSkin();
88  }
89 
90  if (!$system_style_config) {
92  } else {
93  $this->setSystemStylesConf($system_style_config);
94  }
95 
96  if ($skin_id != $this->getSystemStylesConf()->getDefaultSkinId()) {
97  $this->setSkin(ilSkinXML::parseFromXML($this->getSystemStylesConf()->getCustomizingSkinPath() . $skin_id . "/template.xml"));
98  } else {
99  $this->setSkin(ilSkinXML::parseFromXML($this->getSystemStylesConf()->getDefaultTemplatePath()));
100  }
101  }
setSystemStylesConf($system_style_config)
ilSystemStyleConfig wraps all 'constants' to ensure the testability of all classes using those 'const...
+ Here is the call graph for this function:

Member Function Documentation

◆ getAllSkinStyles()

static ilStyleDefinition::getAllSkinStyles ( )
static

Get all skins/styles as array (convenient for tables) Attention: tempalte_name/template_id in this array is only used for legacy reasons an might be removed in future.

Returns
array|null
Exceptions
ilSystemStyleException

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

References $DIC, $skin, $skins, $style, and ilObjUser\_getNumberOfUsersForStyle().

Referenced by ilSystemStyleOverviewGUI\addSubStyleForms(), ilSystemStyleOverviewGUI\checkStyleSettings(), ilSystemStyleOverviewGUI\cloneSystemStyleForm(), ilSystemStyleOverviewGUI\edit(), ilSystemStylesTableGUI\getStyles(), and ilSystemStyleOverviewGUI\saveStyleSettings().

349  {
350  global $DIC;
351 
352  if (!self::getCachedAllStylesInformation()) {
353  $all_styles = [];
354 
355  $skins = $DIC->systemStyle()->getSkins();
356 
357  foreach ($skins as $skin) {
358  foreach ($skin->getStyles() as $style) {
359  $num_users = ilObjUser::_getNumberOfUsersForStyle($skin->getId(), $style->getId());
360 
361  $parent_name = "";
362  if ($style->getSubstyleOf()) {
363  $parent_name = $skin->getStyle($style->getSubstyleOf())->getName();
364  }
365 
366  // default selection list
367  $all_styles[$skin->getId() . ":" . $style->getId()] = [
368  "title" => $skin->getName() . " / " . $style->getName(),
369  "id" => $skin->getId() . ":" . $style->getId(),
370  "skin_id" => $skin->getId(),
371  "skin_name" => $skin->getName(),
372  "template_id" => $skin->getId(),
373  "template_name" => $skin->getName(),
374  "style_id" => $style->getId(),
375  "style_name" => $style->getName(),
376  "substyle_of" => $style->getSubstyleOf(),
377  "substyle_of_name" => $parent_name,
378  "users" => $num_users
379  ];
380  }
381  }
382  self::setCachedAllStylesInformation($all_styles);
383  }
384 
385  return self::getCachedAllStylesInformation();
386  }
$style
Definition: example_012.php:70
static _getNumberOfUsersForStyle($a_skin, $a_style)
skins and styles
global $DIC
Definition: saml.php:7
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAllTemplates()

static ilStyleDefinition::getAllTemplates ( )
static
Deprecated:
due to bad naming.
Returns
ilSkinXML[]
Exceptions
ilSystemStyleException

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

246  {
247  return self::getAllSkins();
248  }

◆ getCachedAllStylesInformation()

static ilStyleDefinition::getCachedAllStylesInformation ( )
staticprotected
Returns
array|null

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

492  {
493  return self::$cached_all_styles_information;
494  }

◆ 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|null skin id

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

References $DIC, and ilUtil\sendFailure().

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

112  {
113  global $DIC;
114 
115  if (!$DIC) {
116  return null;
117  }
118  if ($DIC->isDependencyAvailable("systemStyle") && is_object($DIC->systemStyle()->getSkin())) {
119  return $DIC->systemStyle()->getSkin()->getId();
120  } else {
121  $system_style_conf = new ilSystemStyleConfig();
122 
123  if ($DIC->isDependencyAvailable("user") && is_object($DIC->user()) && property_exists($DIC->user(), "skin")) {
124  $skin_id = $DIC->user()->skin;
125  if (!self::skinExists($skin_id)) {
126  ilUtil::sendFailure($DIC->language()->txt("set_skin_does_not_exist") . " " . $skin_id);
127  $skin_id = $system_style_conf->getDefaultSkinId();
128  }
129  return $skin_id;
130  } else {
131  return null;
132  }
133  }
134  }
global $DIC
Definition: saml.php:7
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
ilSystemStyleConfig wraps all 'constants' to ensure the testability of all classes using those 'const...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCurrentStyle()

static ilStyleDefinition::getCurrentStyle ( )
static

get the current style or sub style

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

Returns
bool|null
Exceptions
ilSystemStyleException

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

References $_GET, $DIC, $i, $path, $system_style_config, $target_arr, ilSystemStyleSettings\getSystemStyleCategoryAssignments(), and ilUtil\sendFailure().

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

284  {
285  global $DIC;
286 
287  if (self::$current_style) {
288  return self::$current_style;
289  }
290 
291  if (!$DIC || !$DIC->isDependencyAvailable("user")) {
292  return null;
293  }
294 
295  self::setCurrentStyle($DIC->user()->prefs['style']);
296 
297  if ($DIC->isDependencyAvailable("systemStyle") && self::styleExistsForCurrentSkin(self::$current_style)) {
298  if ($DIC->systemStyle()->getSkin()->hasStyleSubstyles(self::$current_style)) {
299  // read assignments, if given
300  $assignments = ilSystemStyleSettings::getSystemStyleCategoryAssignments(self::getCurrentSkin(), self::$current_style);
301  if (count($assignments) > 0) {
302  $ref_ass = [];
303  foreach ($assignments as $a) {
304  if ($DIC->systemStyle()->getSkin()->hasStyle($a["substyle"])) {
305  $ref_ass[$a["ref_id"]] = $a["substyle"];
306  }
307  }
308 
309  $ref_id = false;
310  if ($_GET["ref_id"]) {
311  $ref_id = $_GET["ref_id"];
312  } elseif ($_GET["target"]) {
313  $target_arr = explode("_", $_GET["target"]);
314  $ref_id = $target_arr[1];
315  }
316 
317  // check whether any ref id assigns a new style
318  if ($DIC->isDependencyAvailable("repositoryTree") && $ref_id && $DIC->repositoryTree()->isInTree($ref_id)) {
319  $path = $DIC->repositoryTree()->getPathId($ref_id);
320  for ($i = count($path) - 1; $i >= 0; $i--) {
321  if (isset($ref_ass[$path[$i]])) {
322  self::$current_style = $ref_ass[$path[$i]];
323  return self::$current_style;
324  }
325  }
326  }
327  }
328  }
329  }
330 
331  if (!self::styleExistsForCurrentSkin(self::$current_style)) {
332  ilUtil::sendFailure($DIC->language()->txt("set_style_does_not_exist") . " " . self::$current_style);
334  self::setCurrentSkin($system_style_config->getDefaultSkinId());
335  self::setCurrentStyle($system_style_config->getDefaultStyleId());
336  }
337 
338  return self::$current_style;
339  }
$target_arr
Definition: goto.php:47
$path
Definition: aliased.php:25
static getSystemStyleCategoryAssignments($a_skin_id, $a_style_id)
Get all system sub styles category assignments.
global $DIC
Definition: saml.php:7
$_GET["client_id"]
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
ilSystemStyleConfig wraps all 'constants' to ensure the testability of all classes using those 'const...
$i
Definition: disco.tpl.php:19
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getImageDirectory()

ilStyleDefinition::getImageDirectory (   $style_id)
Parameters
$style_id
Returns
string
Exceptions
ilSystemStyleException

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

References getSkin(), getStyle(), ilSystemStyleException\NO_STYLE_ID, and ilSystemStyleException\NOT_EXISTING_STYLE.

180  {
181  if (!$style_id) {
183  }
184  if (!$this->getSkin()->getStyle($style_id)) {
186  }
187  return $this->getSkin()->getStyle($style_id)->getImageDirectory();
188  }
Class for advanced editing exception handling in ILIAS.
+ Here is the call graph for this function:

◆ getSkin()

ilStyleDefinition::getSkin ( )
Returns
ilSkinXML

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

References $skin.

Referenced by getImageDirectory(), getSoundDirectory(), getStyle(), getStyleName(), getStyles(), and getTemplateName().

476  {
477  return $this->skin;
478  }
+ Here is the caller graph for this function:

◆ getSkins()

static ilStyleDefinition::getSkins ( )
static
Returns
ilSkinXML[]
Exceptions
ilSystemStyleException

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

Referenced by ilUtil\getStyleSheetLocation().

460  {
461  return self::getAllSkins();
462  }
+ Here is the caller graph for this function:

◆ getSoundDirectory()

ilStyleDefinition::getSoundDirectory (   $style_id)
Parameters
$style_id
Returns
string
Exceptions
ilSystemStyleException

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

References $skin, $skins, $system_style_config, and getSkin().

196  {
197  return $this->getSkin()->getStyle($style_id)->getSoundDirectory();
198  }
+ Here is the call graph for this function:

◆ getStyle()

ilStyleDefinition::getStyle (   $a_id)
Parameters
$a_id
Returns
ilSkinStyleXML
Exceptions
ilSystemStyleException

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

References getSkin().

Referenced by getImageDirectory().

160  {
161  return $this->getSkin()->getStyle($a_id);
162  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getStyleName()

ilStyleDefinition::getStyleName (   $a_id)
Parameters
$a_id
Returns
string
Exceptions
ilSystemStyleException

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

References getSkin().

170  {
171  return $this->getSkin()->getStyle($a_id)->getName();
172  }
+ Here is the call graph for this function:

◆ getStyles()

ilStyleDefinition::getStyles ( )
Returns
ilSkinStyleXML[]

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

References getSkin().

140  {
141  return $this->getSkin()->getStyles();
142  }
+ Here is the call graph for this function:

◆ getSystemStylesConf()

ilStyleDefinition::getSystemStylesConf ( )
Returns
ilSystemStyleConfig

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

References $system_style_config.

Referenced by __construct().

508  {
510  }
+ Here is the caller graph for this function:

◆ getTemplateName()

ilStyleDefinition::getTemplateName ( )
Returns
string

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

References getSkin().

149  {
150  return $this->getSkin()->getName();
151  }
+ Here is the call graph for this function:

◆ setCachedAllStylesInformation()

static ilStyleDefinition::setCachedAllStylesInformation (   $cached_all_styles_information)
staticprotected
Parameters
array | null$cached_all_styles_information

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

References $cached_all_styles_information.

500  {
501  self::$cached_all_styles_information = $cached_all_styles_information;
502  }

◆ setCurrentSkin()

static ilStyleDefinition::setCurrentSkin (   $a_skin)
static
Parameters
$a_skin
Exceptions
ilSystemStyleException

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

References $DIC.

394  {
395  global $DIC;
396 
397  if ($DIC->isDependencyAvailable("systemStyle") && $DIC->systemStyle()->getSkin()->getName() != $a_skin) {
398  $styleDefinition = new ilStyleDefinition($a_skin);
399  if (!self::styleExistsForCurrentSkin(self::$current_style)) {
400  $styleDefinition->setCurrentStyle($DIC->systemStyle()->getSkin()->getDefaultStyle()->getId());
401  }
402  }
403  }
global $DIC
Definition: saml.php:7
ilStyleDefinition acts as a wrapper of style related actions.

◆ setCurrentStyle()

static ilStyleDefinition::setCurrentStyle (   $a_style)
static
Parameters
$a_style

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

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

◆ setSkin()

ilStyleDefinition::setSkin (   $skin)
Parameters
ilSkinXML$skin

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

References $skin.

Referenced by __construct().

484  {
485  $this->skin = $skin;
486  }
+ Here is the caller graph for this function:

◆ setSkins()

static ilStyleDefinition::setSkins (   $skins)
static
Parameters
ilSkinXML[]$skins

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

References $skins.

468  {
469  self::$skins = $skins;
470  }

◆ setSystemStylesConf()

ilStyleDefinition::setSystemStylesConf (   $system_style_config)
Parameters
$system_style_config

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

References $system_style_config.

Referenced by __construct().

516  {
517  $this->system_style_config = $system_style_config;
518  }
+ Here is the caller graph for this function:

◆ skinExists()

static ilStyleDefinition::skinExists (   $skin_id,
ilSystemStyleConfig  $system_style_config = null 
)
static

Check whether a skin exists.

Not using array_key_exists($skin_id,self::getAllSkins()); for performance reasons

Parameters
string$skin_id
ilSystemStyleConfig | null$system_style_config
Returns
bool

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

References $system_style_config.

Referenced by ilSystemStyleSkinContainer\copy(), ilSystemStyleSettings\getCurrentDefaultSkin(), ilSystemStyleSkinContainer\import(), ilObjUser\read(), and ilSystemStyleOverviewGUI\saveNewSystemStyle().

257  {
258  if (!$system_style_config) {
259  $system_style_config = new ilSystemStyleConfig();
260  }
261 
262  if ($skin_id == $system_style_config->getDefaultSkinId()) {
263  if (is_file($system_style_config->getDefaultTemplatePath())) {
264  return true;
265  }
266  } else {
267  if (is_file($system_style_config->getCustomizingSkinPath() . $skin_id . "/template.xml")) {
268  return true;
269  }
270  }
271  return false;
272  }
ilSystemStyleConfig wraps all 'constants' to ensure the testability of all classes using those 'const...
+ Here is the caller graph for this function:

◆ styleExists()

static ilStyleDefinition::styleExists (   $style_id)
static
Parameters
$style_id
Returns
bool
Exceptions
ilSystemStyleException

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

References $skin.

Referenced by ilSystemStylesTableGUI\getStyles(), and ilSystemStyleOverviewGUI\moveUserStyles().

412  {
413  foreach (self::getSkins() as $skin) {
414  if ($skin->hasStyle($style_id)) {
415  return true;
416  }
417  }
418  return false;
419  }
+ Here is the caller graph for this function:

◆ styleExistsForCurrentSkin()

static ilStyleDefinition::styleExistsForCurrentSkin (   $style_id)
static
Parameters
$style_id
Returns
bool

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

References $DIC.

441  {
442  global $DIC;
443 
444  return $DIC->systemStyle()->getSkin()->hasStyle($style_id);
445  }
global $DIC
Definition: saml.php:7

◆ styleExistsForSkinId()

static ilStyleDefinition::styleExistsForSkinId (   $skin_id,
  $style_id 
)
static
Parameters
$skin_id
$style_id
Returns
bool
Exceptions
ilSystemStyleException

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

References $skin, and ilSystemStyleSkinContainer\generateFromId().

Referenced by ilSystemStyleSettings\getCurrentDefaultStyle(), and ilObjUser\read().

428  {
429  if (!self::skinExists($skin_id)) {
430  return false;
431  }
432  $skin = ilSystemStyleSkinContainer::generateFromId($skin_id)->getSkin();
433  return $skin->hasStyle($style_id);
434  }
static generateFromId($skin_id, ilSystemStyleMessageStack $message_stack=null, ilSystemStyleConfig $system_styles_conf=null)
Generate the container class by parsing the corresponding XML.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $cached_all_styles_information

ilStyleDefinition::$cached_all_styles_information = null
staticprotected

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

Referenced by setCachedAllStylesInformation().

◆ $current_style

ilStyleDefinition::$current_style = false
static

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

◆ $skin

ilStyleDefinition::$skin
protected

◆ $skins

ilStyleDefinition::$skins = []
static

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

Referenced by getAllSkinStyles(), getSoundDirectory(), and setSkins().

◆ $system_style_config

ilStyleDefinition::$system_style_config
protected

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