ILIAS  release_7 Revision v7.30-3-g800a261c036
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 ()
 ilDidacticTemplateIconFactory constructor. More...
 
 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

 $definition
 
 $settings
 
 $icon_types = []
 
 $assignments = []
 
 $logger
 

Static Private Attributes

static $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 21 of file class.ilDidacticTemplateIconFactory.php.

Constructor & Destructor Documentation

◆ __construct()

ilDidacticTemplateIconFactory::__construct ( )

ilDidacticTemplateIconFactory constructor.

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

References $DIC, and initTemplates().

51  {
52  global $DIC;
53 
54  $this->logger = $DIC->logger()->otpl();
55  $this->definition = $DIC['objDefinition'];
56  $this->initTemplates();
57  }
global $DIC
Definition: goto.php:24
+ Here is the call graph for this function:

Member Function Documentation

◆ findAssignedTemplate()

ilDidacticTemplateIconFactory::findAssignedTemplate ( int  $ref_id)
protected
Parameters
int$ref_id
Returns
int

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

References $assignments.

Referenced by getIconPathForReference().

106  : int
107  {
108  foreach ($this->assignments as $tpl_id => $assignments) {
109  if (in_array($ref_id, $assignments)) {
110  return (int) $tpl_id;
111  }
112  }
113  return 0;
114  }
+ 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 122 of file class.ilDidacticTemplateIconFactory.php.

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

122  : string
123  {
124  // no support for referenced objects
125  if (!$this->definition->isContainer(ilObject::_lookupType($obj_id))) {
126  return '';
127  }
129  $ref_id = end($refs);
130  return $this->getIconPathForReference((int) $ref_id);
131  }
static _getAllReferences($a_id)
get all reference ids of object
static _lookupType($a_id, $a_reference=false)
lookup object type
+ Here is the call graph for this function:

◆ getIconPathForReference()

ilDidacticTemplateIconFactory::getIconPathForReference ( int  $ref_id)
Parameters
int$ref_id

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

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

Referenced by getIconPathForObject().

73  : string
74  {
77 
78  if (!$type || !$this->supportsCustomIcon($type)) {
79  return '';
80  }
81  $assigned_template = $this->findAssignedTemplate($ref_id);
82  if (!$assigned_template) {
83  return '';
84  }
85  $path = $this->getIconPathForTemplate($assigned_template);
86  return $path;
87  }
$type
static _lookupObjId($a_id)
static _lookupType($a_id, $a_reference=false)
lookup object type
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getIconPathForTemplate()

ilDidacticTemplateIconFactory::getIconPathForTemplate ( int  $template_id)
protected
Parameters
int$template_id
Returns
string

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

References settings().

Referenced by getIconPathForReference().

93  : string
94  {
95  foreach ($this->settings->getTemplates() as $template) {
96  if ($template->getId() == $template_id) {
97  return $template->getIconHandler()->getAbsolutePath();
98  }
99  }
100  }
settings()
Definition: settings.php:2
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getInstance()

static ilDidacticTemplateIconFactory::getInstance ( )
static
Returns
ilDidacticTemplateIconFactory

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

Referenced by ilObject\cloneMetaData().

63  {
64  if (!isset(self::$instance)) {
65  self::$instance = new self();
66  }
67  return self::$instance;
68  }
+ Here is the caller graph for this function:

◆ initTemplates()

ilDidacticTemplateIconFactory::initTemplates ( )
private

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

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

Referenced by __construct().

143  {
145  $this->icon_types = [];
146 
147  $templates = [];
148  foreach ($this->settings->getTemplates() as $tpl) {
149  if ($tpl->getIconIdentifier() != '') {
150  $templates[] = $tpl->getId();
151  foreach ($tpl->getAssignments() as $assignment) {
152  if (!in_array($assignment, $this->icon_types)) {
153  $this->icon_types[] = $assignment;
154  }
155  }
156  }
157  }
158  $this->assignments = ilDidacticTemplateObjSettings::getAssignmentsForTemplates($templates);
159  }
settings()
Definition: settings.php:2
static getInstance()
Get singelton instance.
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
Parameters
string$type
Returns
bool

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

Referenced by getIconPathForReference().

137  : bool
138  {
139  return in_array($type, $this->icon_types);
140  }
$type
+ Here is the caller graph for this function:

Field Documentation

◆ $assignments

ilDidacticTemplateIconFactory::$assignments = []
private

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

Referenced by findAssignedTemplate().

◆ $definition

ilDidacticTemplateIconFactory::$definition
private

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

◆ $icon_types

ilDidacticTemplateIconFactory::$icon_types = []
private

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

◆ $instance

ilDidacticTemplateIconFactory::$instance = null
staticprivate

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

◆ $logger

ilDidacticTemplateIconFactory::$logger
private

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

◆ $settings

ilDidacticTemplateIconFactory::$settings
private

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


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