ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilDidacticTemplateSettings.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateSetting.php';
5
13{
14 private static $instance = null;
15 private static $instances = null;
16
17
18 private $templates = array();
19 private $obj_type = '';
20
25 private function __construct($a_obj_type = '')
26 {
27 $this->obj_type = $a_obj_type;
28 $this->read();
29 }
30
35 public static function getInstance()
36 {
37 if (self::$instance) {
38 return self::$instance;
39 }
40 return self::$instance = new ilDidacticTemplateSettings();
41 }
42
48 public static function getInstanceByObjectType($a_obj_type)
49 {
50 if (self::$instances[$a_obj_type]) {
51 return self::$instances[$a_obj_type];
52 }
53 return self::$instances[$a_obj_type] = new ilDidacticTemplateSettings($a_obj_type);
54 }
55
60 public function getTemplates()
61 {
62 return (array) $this->templates;
63 }
64
69 public function getObjectType()
70 {
71 return $this->obj_type;
72 }
73
77 public function readInactive()
78 {
79 global $ilDB;
80
81 $query = 'SELECT dtpl.id FROM didactic_tpl_settings dtpl ';
82
83 if ($this->getObjectType()) {
84 $query .= 'JOIN didactic_tpl_sa tplsa ON dtpl.id = tplsa.id ';
85 }
86 $query .= 'WHERE enabled = ' . $ilDB->quote(0, 'integer') . ' ';
87
88 if ($this->getObjectType()) {
89 $query .= 'AND obj_type = ' . $ilDB->quote($this->getObjectType(), 'text');
90 }
91
92 $res = $ilDB->query($query);
93 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
94 $this->templates[$row->id] = new ilDidacticTemplateSetting($row->id);
95 }
96 return true;
97 }
98
104 protected function read()
105 {
106 global $ilDB;
107
108 $query = 'SELECT dtpl.id FROM didactic_tpl_settings dtpl ';
109
110 if ($this->getObjectType()) {
111 $query .= 'JOIN didactic_tpl_sa tplsa ON dtpl.id = tplsa.id ';
112 }
113 $query .= 'WHERE enabled = ' . $ilDB->quote(1, 'integer') . ' ';
114
115 if ($this->getObjectType()) {
116 $query .= 'AND obj_type = ' . $ilDB->quote($this->getObjectType(), 'text');
117 }
118
119 $res = $ilDB->query($query);
120 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
121 $this->templates[$row->id] = new ilDidacticTemplateSetting($row->id);
122 }
123 return true;
124 }
125}
An exception for terminatinating execution or to throw for unit testing.
read()
Read active didactic templates @global ilDB $ilDB.
static getInstanceByObjectType($a_obj_type)
Get instance by obj type.
static getInstance()
Get singelton instance.
$query
foreach($_POST as $key=> $value) $res
global $ilDB