ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables 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 20 of file class.ilDidacticTemplateIconFactory.php.

Constructor & Destructor Documentation

◆ __construct()

ilDidacticTemplateIconFactory::__construct ( )

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

References $DIC, and initTemplates().

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

Referenced by getIconPathForReference().

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

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

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 _getAllReferences(int $id)
get all reference ids for object ID
$ref_id
Definition: ltiauth.php:67
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:

◆ getIconPathForReference()

ilDidacticTemplateIconFactory::getIconPathForReference ( int  $ref_id)

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

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

Referenced by getIconPathForObject().

48  : string
49  {
51  $type = ilObject::_lookupType($obj_id);
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  }
$type
$path
Definition: ltiservices.php:32
static _lookupObjId(int $ref_id)
$ref_id
Definition: ltiauth.php:67
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 65 of file class.ilDidacticTemplateIconFactory.php.

References ILIAS\Repository\settings().

Referenced by getIconPathForReference().

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

Referenced by ilObject\cloneMetaData().

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.
+ Here is the caller graph for this function:

◆ initTemplates()

ilDidacticTemplateIconFactory::initTemplates ( )
private

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

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

Referenced by __construct().

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

Referenced by getIconPathForReference().

105  : bool
106  {
107  return in_array($type, $this->icon_types, true);
108  }
$type
+ Here is the caller graph for this function:

Field Documentation

◆ $assignments

array ilDidacticTemplateIconFactory::$assignments = []
private

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

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

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