ILIAS  release_8 Revision v8.24
ilDidacticTemplateSettings Class Reference
+ Collaboration diagram for ilDidacticTemplateSettings:

Public Member Functions

 getTemplates ()
 
 getObjectType ()
 
 readInactive ()
 Read disabled templates. More...
 

Static Public Member Functions

static getInstance ()
 
static getInstanceByObjectType (string $a_obj_type)
 
static lookupAssignedObjectTypes ()
 

Protected Member Functions

 read ()
 Read active didactic templates. More...
 

Private Member Functions

 __construct (string $a_obj_type='')
 

Private Attributes

array $templates = []
 
string $obj_type = ''
 
ilDBInterface $db
 

Static Private Attributes

static ilDidacticTemplateSettings $instance = null
 
static array $instances = []
 

Detailed Description

Definition at line 11 of file class.ilDidacticTemplateSettings.php.

Constructor & Destructor Documentation

◆ __construct()

ilDidacticTemplateSettings::__construct ( string  $a_obj_type = '')
private

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

23 {
24 global $DIC;
25
26 $this->obj_type = $a_obj_type;
27 $this->db = $DIC->database();
28 $this->read();
29 }
read()
Read active didactic templates.
global $DIC
Definition: feed.php:28

References $DIC, and read().

+ Here is the call graph for this function:

Member Function Documentation

◆ getInstance()

static ilDidacticTemplateSettings::getInstance ( )
static

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

32 {
33 if (self::$instance) {
34 return self::$instance;
35 }
36
37 return self::$instance = new ilDidacticTemplateSettings();
38 }
static ilDidacticTemplateSettings $instance

References $instance.

Referenced by ilDidacticTemplateIconFactory\initTemplates(), and ilDidacticTemplateSettingsTableGUI\parse().

+ Here is the caller graph for this function:

◆ getInstanceByObjectType()

static ilDidacticTemplateSettings::getInstanceByObjectType ( string  $a_obj_type)
static

Definition at line 40 of file class.ilDidacticTemplateSettings.php.

41 {
42 return self::$instances[$a_obj_type] ?? (self::$instances[$a_obj_type] = new ilDidacticTemplateSettings($a_obj_type));
43 }

Referenced by ilDidacticTemplateGUI\appendToolbarSwitch(), ilSessionDataSet\applyDidacticTemplate(), and ilObjectGUI\initDidacticTemplate().

+ Here is the caller graph for this function:

◆ getObjectType()

ilDidacticTemplateSettings::getObjectType ( )

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

73 : string
74 {
75 return $this->obj_type;
76 }

References $obj_type.

Referenced by read(), and readInactive().

+ Here is the caller graph for this function:

◆ getTemplates()

ilDidacticTemplateSettings::getTemplates ( )
Returns
ilDidacticTemplateSetting[]

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

68 : array
69 {
70 return $this->templates;
71 }

References $templates.

◆ lookupAssignedObjectTypes()

static ilDidacticTemplateSettings::lookupAssignedObjectTypes ( )
static
Returns
string[]
Exceptions
ilDatabaseException

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

49 : array
50 {
51 global $DIC;
52
53 $db = $DIC->database();
54 $query = 'select distinct (obj_type) from didactic_tpl_sa ' .
55 'group by obj_type';
56 $res = $db->query($query);
57 $types = [];
58 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
59 $types[] = $row->obj_type;
60 }
61
62 return $types;
63 }
query(string $query)
Run a (read-only) Query on the database.
$res
Definition: ltiservices.php:69
$query

References $db, $DIC, $query, $res, ilDBConstants\FETCHMODE_OBJECT, and ilDBInterface\query().

Referenced by ilDidacticTemplateSettingsTableFilter\init().

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

◆ read()

ilDidacticTemplateSettings::read ( )
protected

Read active didactic templates.

Returns
bool

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

106 : bool
107 {
108 $query = 'SELECT dtpl.id FROM didactic_tpl_settings dtpl ';
109 if ($this->getObjectType()) {
110 $query .= 'JOIN didactic_tpl_sa tplsa ON dtpl.id = tplsa.id ';
111 }
112 $query .= 'WHERE enabled = ' . $this->db->quote(1, 'integer') . ' ';
113
114 if ($this->getObjectType()) {
115 $query .= 'AND obj_type = ' . $this->db->quote($this->getObjectType(), 'text');
116 }
117
118 $res = $this->db->query($query);
119 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
120 $this->templates[$row->id] = new ilDidacticTemplateSetting((int) $row->id);
121 }
122
123 return true;
124 }

References $query, $res, ilDBConstants\FETCHMODE_OBJECT, and getObjectType().

Referenced by __construct().

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

◆ readInactive()

ilDidacticTemplateSettings::readInactive ( )

Read disabled templates.

Definition at line 81 of file class.ilDidacticTemplateSettings.php.

81 : bool
82 {
83 $query = 'SELECT dtpl.id FROM didactic_tpl_settings dtpl ';
84
85 if ($this->getObjectType()) {
86 $query .= 'JOIN didactic_tpl_sa tplsa ON dtpl.id = tplsa.id ';
87 }
88 $query .= 'WHERE enabled = ' . $this->db->quote(0, 'integer') . ' ';
89
90 if ($this->getObjectType()) {
91 $query .= 'AND obj_type = ' . $this->db->quote($this->getObjectType(), 'text');
92 }
93
94 $res = $this->db->query($query);
95 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
96 $this->templates[$row->id] = new ilDidacticTemplateSetting((int) $row->id);
97 }
98
99 return true;
100 }

References $query, $res, ilDBConstants\FETCHMODE_OBJECT, and getObjectType().

+ Here is the call graph for this function:

Field Documentation

◆ $db

ilDBInterface ilDidacticTemplateSettings::$db
private

Definition at line 20 of file class.ilDidacticTemplateSettings.php.

Referenced by lookupAssignedObjectTypes().

◆ $instance

ilDidacticTemplateSettings ilDidacticTemplateSettings::$instance = null
staticprivate

Definition at line 13 of file class.ilDidacticTemplateSettings.php.

Referenced by getInstance().

◆ $instances

array ilDidacticTemplateSettings::$instances = []
staticprivate

Definition at line 14 of file class.ilDidacticTemplateSettings.php.

◆ $obj_type

string ilDidacticTemplateSettings::$obj_type = ''
private

Definition at line 18 of file class.ilDidacticTemplateSettings.php.

Referenced by getObjectType().

◆ $templates

array ilDidacticTemplateSettings::$templates = []
private

Definition at line 17 of file class.ilDidacticTemplateSettings.php.

Referenced by getTemplates().


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