ILIAS  trunk Revision v11.0_alpha-1866-gfa368f7776e
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilDidacticTemplateIconFactory Class Reference

Icon factory for didactic template custom icons. More...

+ Collaboration diagram for ilDidacticTemplateIconFactory:

Public Member Functions

 __construct ()
 
 getIconPathForReference (int $ref_id)
 
 getIconPathForObject (int $obj_id)
 Get icon path for object Not applicable to non container objects, use getIconPathForReference instead. More...
 

Static Public Member Functions

static getInstance ()
 

Protected Member Functions

 getIconPathForTemplate (int $template_id)
 
 findAssignedTemplate (int $ref_id)
 
 supportsCustomIcon (string $type)
 

Private Member Functions

 initTemplates ()
 

Private Attributes

ilObjectDefinition $definition
 
ilDidacticTemplateSettings $settings
 
array $icon_types = []
 
array $assignments = []
 

Static Private Attributes

static ilDidacticTemplateIconFactory $instance = null
 

Detailed Description

Icon factory for didactic template custom icons.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 34 of file class.ilDidacticTemplateIconFactory.php.

Constructor & Destructor Documentation

◆ __construct()

ilDidacticTemplateIconFactory::__construct ( )

Definition at line 45 of file class.ilDidacticTemplateIconFactory.php.

References $DIC, and initTemplates().

46  {
47  global $DIC;
48 
49  $this->definition = $DIC['objDefinition'];
50  $this->initTemplates();
51  }
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Member Function Documentation

◆ findAssignedTemplate()

ilDidacticTemplateIconFactory::findAssignedTemplate ( int  $ref_id)
protected

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

Referenced by getIconPathForReference().

90  : int
91  {
92  foreach ($this->assignments as $tpl_id => $assignments) {
93  if (in_array($ref_id, $assignments, true)) {
94  return $tpl_id;
95  }
96  }
97 
98  return 0;
99  }
$ref_id
Definition: ltiauth.php:65
+ Here is the caller graph for this function:

◆ getIconPathForObject()

ilDidacticTemplateIconFactory::getIconPathForObject ( int  $obj_id)

Get icon path for object Not applicable to non container objects, use getIconPathForReference instead.

Parameters
int$obj_id
Returns
string

Definition at line 107 of file class.ilDidacticTemplateIconFactory.php.

References $ref_id, ilObject\_getAllReferences(), ilObject\_lookupType(), and getIconPathForReference().

107  : string
108  {
109  // no support for referenced objects
110  if (!$this->definition->isContainer(ilObject::_lookupType($obj_id))) {
111  return '';
112  }
113  $refs = ilObject::_getAllReferences($obj_id);
114  $ref_id = end($refs);
115 
116  return $this->getIconPathForReference((int) $ref_id);
117  }
static _getAllReferences(int $id)
get all reference ids for object ID
$ref_id
Definition: ltiauth.php:65
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:

◆ getIconPathForReference()

ilDidacticTemplateIconFactory::getIconPathForReference ( int  $ref_id)

Definition at line 62 of file class.ilDidacticTemplateIconFactory.php.

References $path, ilObject\_lookupObjId(), ilObject\_lookupType(), findAssignedTemplate(), getIconPathForTemplate(), and supportsCustomIcon().

Referenced by getIconPathForObject().

62  : string
63  {
65  $type = ilObject::_lookupType($obj_id);
66 
67  if (!$type || !$this->supportsCustomIcon($type)) {
68  return '';
69  }
70  $assigned_template = $this->findAssignedTemplate($ref_id);
71  if (!$assigned_template) {
72  return '';
73  }
74 
75  $path = $this->getIconPathForTemplate($assigned_template);
76  return $path;
77  }
$path
Definition: ltiservices.php:29
static _lookupObjId(int $ref_id)
$ref_id
Definition: ltiauth.php:65
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getIconPathForTemplate()

ilDidacticTemplateIconFactory::getIconPathForTemplate ( int  $template_id)
protected

Definition at line 79 of file class.ilDidacticTemplateIconFactory.php.

References null, and ILIAS\Repository\settings().

Referenced by getIconPathForReference().

79  : ?string
80  {
81  foreach ($this->settings->getTemplates() as $template) {
82  if ($template->getId() === $template_id) {
83  return $template->getIconHandler()->getAbsolutePath();
84  }
85  }
86 
87  return null;
88  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getInstance()

static ilDidacticTemplateIconFactory::getInstance ( )
static

Definition at line 53 of file class.ilDidacticTemplateIconFactory.php.

Referenced by ilObject\cloneMetaData().

54  {
55  if (!isset(self::$instance)) {
56  self::$instance = new self();
57  }
58 
59  return self::$instance;
60  }
Icon factory for didactic template custom icons.
+ Here is the caller graph for this function:

◆ initTemplates()

ilDidacticTemplateIconFactory::initTemplates ( )
private

Definition at line 124 of file class.ilDidacticTemplateIconFactory.php.

References ilDidacticTemplateObjSettings\getAssignmentsForTemplates(), ilDidacticTemplateSettings\getInstance(), and ILIAS\Repository\settings().

Referenced by __construct().

124  : void
125  {
127  $this->icon_types = [];
128 
129  $templates = [];
130  foreach ($this->settings->getTemplates() as $tpl) {
131  if ($tpl->getIconIdentifier() !== '') {
132  $templates[] = $tpl->getId();
133  foreach ($tpl->getAssignments() as $assignment) {
134  if (!in_array($assignment, $this->icon_types, true)) {
135  $this->icon_types[] = $assignment;
136  }
137  }
138  }
139  }
140  $this->assignments = ilDidacticTemplateObjSettings::getAssignmentsForTemplates($templates);
141  }
static getAssignmentsForTemplates(array $template_ids)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ supportsCustomIcon()

ilDidacticTemplateIconFactory::supportsCustomIcon ( string  $type)
protected

Definition at line 119 of file class.ilDidacticTemplateIconFactory.php.

Referenced by getIconPathForReference().

119  : bool
120  {
121  return in_array($type, $this->icon_types, true);
122  }
+ Here is the caller graph for this function:

Field Documentation

◆ $assignments

array ilDidacticTemplateIconFactory::$assignments = []
private

Definition at line 43 of file class.ilDidacticTemplateIconFactory.php.

◆ $definition

ilObjectDefinition ilDidacticTemplateIconFactory::$definition
private

Definition at line 38 of file class.ilDidacticTemplateIconFactory.php.

◆ $icon_types

array ilDidacticTemplateIconFactory::$icon_types = []
private

Definition at line 41 of file class.ilDidacticTemplateIconFactory.php.

◆ $instance

ilDidacticTemplateIconFactory ilDidacticTemplateIconFactory::$instance = null
staticprivate

Definition at line 36 of file class.ilDidacticTemplateIconFactory.php.

◆ $settings

ilDidacticTemplateSettings ilDidacticTemplateIconFactory::$settings
private

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


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