ILIAS  release_8 Revision v8.24
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 20 of file class.ilDidacticTemplateIconFactory.php.

Constructor & Destructor Documentation

◆ __construct()

ilDidacticTemplateIconFactory::__construct ( )

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

32 {
33 global $DIC;
34
35 $this->definition = $DIC['objDefinition'];
36 $this->initTemplates();
37 }
global $DIC
Definition: feed.php:28

References $DIC, and initTemplates().

+ Here is the call graph for this function:

Member Function Documentation

◆ findAssignedTemplate()

ilDidacticTemplateIconFactory::findAssignedTemplate ( int  $ref_id)
protected

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

76 : int
77 {
78 foreach ($this->assignments as $tpl_id => $assignments) {
79 if (in_array($ref_id, $assignments, true)) {
80 return $tpl_id;
81 }
82 }
83
84 return 0;
85 }
$ref_id
Definition: ltiauth.php:67

References $assignments, and $ref_id.

Referenced by getIconPathForReference().

+ 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 93 of file class.ilDidacticTemplateIconFactory.php.

93 : string
94 {
95 // no support for referenced objects
96 if (!$this->definition->isContainer(ilObject::_lookupType($obj_id))) {
97 return '';
98 }
99 $refs = ilObject::_getAllReferences($obj_id);
100 $ref_id = end($refs);
101
102 return $this->getIconPathForReference((int) $ref_id);
103 }
static _lookupType(int $id, bool $reference=false)
static _getAllReferences(int $id)
get all reference ids for object ID

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

+ Here is the call graph for this function:

◆ getIconPathForReference()

ilDidacticTemplateIconFactory::getIconPathForReference ( int  $ref_id)

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

48 : string
49 {
52
53 if (!$type || !$this->supportsCustomIcon($type)) {
54 return '';
55 }
56 $assigned_template = $this->findAssignedTemplate($ref_id);
57 if (!$assigned_template) {
58 return '';
59 }
60
61 $path = $this->getIconPathForTemplate($assigned_template);
62 return $path;
63 }
static _lookupObjId(int $ref_id)
$path
Definition: ltiservices.php:32
$type

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

Referenced by getIconPathForObject().

+ 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 65 of file class.ilDidacticTemplateIconFactory.php.

65 : ?string
66 {
67 foreach ($this->settings->getTemplates() as $template) {
68 if ($template->getId() === $template_id) {
69 return $template->getIconHandler()->getAbsolutePath();
70 }
71 }
72
73 return null;
74 }

References ILIAS\Repository\settings().

Referenced by getIconPathForReference().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getInstance()

static ilDidacticTemplateIconFactory::getInstance ( )
static

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

40 {
41 if (!isset(self::$instance)) {
42 self::$instance = new self();
43 }
44
45 return self::$instance;
46 }
Icon factory for didactic template custom icons.
static ilDidacticTemplateIconFactory $instance

References $instance.

◆ initTemplates()

ilDidacticTemplateIconFactory::initTemplates ( )
private

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

110 : void
111 {
113 $this->icon_types = [];
114
115 $templates = [];
116 foreach ($this->settings->getTemplates() as $tpl) {
117 if ($tpl->getIconIdentifier() !== '') {
118 $templates[] = $tpl->getId();
119 foreach ($tpl->getAssignments() as $assignment) {
120 if (!in_array($assignment, $this->icon_types, true)) {
121 $this->icon_types[] = $assignment;
122 }
123 }
124 }
125 }
126 $this->assignments = ilDidacticTemplateObjSettings::getAssignmentsForTemplates($templates);
127 }
static getAssignmentsForTemplates(array $template_ids)
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41

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

Referenced by __construct().

+ 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 105 of file class.ilDidacticTemplateIconFactory.php.

105 : bool
106 {
107 return in_array($type, $this->icon_types, true);
108 }

References $type.

Referenced by getIconPathForReference().

+ Here is the caller graph for this function:

Field Documentation

◆ $assignments

array ilDidacticTemplateIconFactory::$assignments = []
private

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

Referenced by findAssignedTemplate().

◆ $definition

ilObjectDefinition ilDidacticTemplateIconFactory::$definition
private

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

◆ $icon_types

array ilDidacticTemplateIconFactory::$icon_types = []
private

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

◆ $instance

ilDidacticTemplateIconFactory ilDidacticTemplateIconFactory::$instance = null
staticprivate

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

Referenced by getInstance().

◆ $settings

ilDidacticTemplateSettings ilDidacticTemplateIconFactory::$settings
private

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


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