ILIAS  release_4-4 Revision
ilSettingsTemplate Class Reference

Settings template application class. More...

+ Collaboration diagram for ilSettingsTemplate:

Public Member Functions

 __construct ($a_id=0, $config=null)
 Constructor. More...
 
 setId ($a_val)
 Set id. More...
 
 getId ()
 Get id. More...
 
 setTitle ($a_val)
 Set title. More...
 
 getTitle ()
 Get title. More...
 
 setType ($a_val)
 Set type. More...
 
 getType ()
 Get type. More...
 
 setDescription ($a_val)
 Set description. More...
 
 getDescription ()
 Get description. More...
 
 setSetting ($a_setting, $a_value, $a_hide=false)
 Set setting. More...
 
 removeSetting ($a_setting)
 Remove setting. More...
 
 removeAllSettings ()
 Remove all settings. More...
 
 getSettings ()
 Get settings. More...
 
 addHiddenTab ($a_tab_id)
 Add hidden tab. More...
 
 removeAllHiddenTabs ()
 Remove all hidden tabs. More...
 
 getHiddenTabs ()
 Get hidden tabs. More...
 
 getConfig ()
 Returns the template config associated with this template or NULL if none is given. More...
 
 setConfig (ilSettingsTemplateConfig $config)
 Sets the template config for this template. More...
 
 read ()
 Read. More...
 
 create ()
 Create settings template. More...
 
 update ()
 Update settings template. More...
 
 insertHiddenTabs ()
 Insert hidden tabs. More...
 
 delete ()
 Delete settings template. More...
 

Static Public Member Functions

static getAllSettingsTemplates ($a_type)
 Get all settings templates of type. More...
 
static lookupTitle ($a_id)
 Lookup title. More...
 

Static Protected Member Functions

static lookupProperty ($a_id, $a_prop)
 Lookup property. More...
 

Private Member Functions

 insertSettings ()
 Insert settings to db. More...
 

Private Attributes

 $id
 
 $type
 
 $title
 
 $description
 
 $setting = array()
 
 $hidden_tab = array()
 
 $config
 

Detailed Description

Settings template application class.

Author
Alex Killing <alex.killing>
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilSettingsTemplate::__construct (   $a_id = 0,
  $config = null 
)

Constructor.

Parameters

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

References $config, read(), setConfig(), and setId().

32  {
33  if ($a_id > 0)
34  {
35  if ($config)
36  $this->setConfig($config);
37  $this->setId($a_id);
38  $this->read();
39  }
40  }
setConfig(ilSettingsTemplateConfig $config)
Sets the template config for this template.
+ Here is the call graph for this function:

Member Function Documentation

◆ addHiddenTab()

ilSettingsTemplate::addHiddenTab (   $a_tab_id)

Add hidden tab.

Parameters
stringtab id
Returns

Definition at line 180 of file class.ilSettingsTemplate.php.

Referenced by read().

181  {
182  $this->hidden_tab[$a_tab_id] = $a_tab_id;
183  }
+ Here is the caller graph for this function:

◆ create()

ilSettingsTemplate::create ( )

Create settings template.

Definition at line 263 of file class.ilSettingsTemplate.php.

References getDescription(), getId(), getTitle(), getType(), insertHiddenTabs(), insertSettings(), and setId().

264  {
265  global $ilDB;
266 
267  $this->setId($ilDB->nextId("adm_settings_template"));
268 
269  // write template
270  $ilDB->insert("adm_settings_template", array(
271  "id" => array("integer", $this->getId()),
272  "title" => array("text", $this->getTitle()),
273  "type" => array("text", $this->getType()),
274  "description" => array("clob", $this->getDescription())
275  ));
276 
277  // write settings
278  $this->insertSettings();
279 
280  // write hidden tabs
281  $this->insertHiddenTabs();
282  }
getDescription()
Get description.
insertHiddenTabs()
Insert hidden tabs.
insertSettings()
Insert settings to db.
+ Here is the call graph for this function:

◆ delete()

ilSettingsTemplate::delete ( )

Delete settings template.

Definition at line 353 of file class.ilSettingsTemplate.php.

354  {
355  global $ilDB;
356 
357  $ilDB->manipulate("DELETE FROM adm_settings_template WHERE "
358  ." id = ".$ilDB->quote($this->getId(), "integer")
359  );
360  $ilDB->manipulate("DELETE FROM adm_set_templ_value WHERE "
361  ." template_id = ".$ilDB->quote($this->getId(), "integer")
362  );
363  $ilDB->manipulate("DELETE FROM adm_set_templ_hide_tab WHERE "
364  ." template_id = ".$ilDB->quote($this->getId(), "integer")
365  );
366  }

◆ getAllSettingsTemplates()

static ilSettingsTemplate::getAllSettingsTemplates (   $a_type)
static

Get all settings templates of type.

Parameters
string$a_typeobject type

Definition at line 373 of file class.ilSettingsTemplate.php.

Referenced by ilSettingsTemplateTableGUI\__construct(), ilObjSurveyGUI\addDidacticTemplateOptions(), ilObjTestGUI\addDidacticTemplateOptions(), and ilObjSurveyGUI\importFileObject().

374  {
375  global $ilDB;
376 
377  $set = $ilDB->query("SELECT * FROM adm_settings_template ".
378  " WHERE type = ".$ilDB->quote($a_type, "text").
379  " ORDER BY title");
380 
381  $settings_template = array();
382  while ($rec = $ilDB->fetchAssoc($set))
383  {
384  $settings_template[] = $rec;
385  }
386 
387  return $settings_template;
388  }
+ Here is the caller graph for this function:

◆ getConfig()

ilSettingsTemplate::getConfig ( )

Returns the template config associated with this template or NULL if none is given.

Returns
ilSettingsTemplateConfig

Definition at line 207 of file class.ilSettingsTemplate.php.

References $config.

Referenced by setSetting().

207  {
208  return $this->config;
209  }
+ Here is the caller graph for this function:

◆ getDescription()

ilSettingsTemplate::getDescription ( )

Get description.

Returns
string description

Definition at line 117 of file class.ilSettingsTemplate.php.

References $description.

Referenced by create(), and update().

118  {
119  return $this->description;
120  }
+ Here is the caller graph for this function:

◆ getHiddenTabs()

ilSettingsTemplate::getHiddenTabs ( )

Get hidden tabs.

Definition at line 196 of file class.ilSettingsTemplate.php.

References $hidden_tab.

Referenced by insertHiddenTabs().

197  {
198  return $this->hidden_tab;
199  }
+ Here is the caller graph for this function:

◆ getId()

ilSettingsTemplate::getId ( )

Get id.

Returns
integer id

Definition at line 57 of file class.ilSettingsTemplate.php.

References $id.

Referenced by create(), and update().

58  {
59  return $this->id;
60  }
+ Here is the caller graph for this function:

◆ getSettings()

ilSettingsTemplate::getSettings ( )

Get settings.

Definition at line 169 of file class.ilSettingsTemplate.php.

References $setting.

Referenced by insertSettings().

170  {
171  return $this->setting;
172  }
+ Here is the caller graph for this function:

◆ getTitle()

ilSettingsTemplate::getTitle ( )

Get title.

Returns
string title

Definition at line 77 of file class.ilSettingsTemplate.php.

References $title.

Referenced by create(), and update().

78  {
79  return $this->title;
80  }
+ Here is the caller graph for this function:

◆ getType()

ilSettingsTemplate::getType ( )

Get type.

Returns
string type

Definition at line 97 of file class.ilSettingsTemplate.php.

References $type.

Referenced by create(), and update().

98  {
99  return $this->type;
100  }
+ Here is the caller graph for this function:

◆ insertHiddenTabs()

ilSettingsTemplate::insertHiddenTabs ( )

Insert hidden tabs.

Definition at line 336 of file class.ilSettingsTemplate.php.

References getHiddenTabs().

Referenced by create(), and update().

337  {
338  global $ilDB;
339 
340  foreach ($this->getHiddenTabs() as $tab_id)
341  {
342  $ilDB->manipulate("INSERT INTO adm_set_templ_hide_tab ".
343  "(template_id, tab_id) VALUES (".
344  $ilDB->quote($this->getId(), "integer").",".
345  $ilDB->quote($tab_id, "text").
346  ")");
347  }
348  }
getHiddenTabs()
Get hidden tabs.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ insertSettings()

ilSettingsTemplate::insertSettings ( )
private

Insert settings to db.

Definition at line 317 of file class.ilSettingsTemplate.php.

References getSettings().

Referenced by create(), and update().

318  {
319  global $ilDB;
320 
321  foreach ($this->getSettings() as $s => $set)
322  {
323  $ilDB->manipulate("INSERT INTO adm_set_templ_value ".
324  "(template_id, setting, value, hide) VALUES (".
325  $ilDB->quote($this->getId(), "integer").",".
326  $ilDB->quote($s, "text").",".
327  $ilDB->quote($set["value"], "text").",".
328  $ilDB->quote($set["hide"], "integer").
329  ")");
330  }
331  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lookupProperty()

static ilSettingsTemplate::lookupProperty (   $a_id,
  $a_prop 
)
staticprotected

Lookup property.

Parameters
idlevel id
Returns
mixed property value

Definition at line 396 of file class.ilSettingsTemplate.php.

Referenced by lookupTitle().

397  {
398  global $ilDB;
399 
400  $set = $ilDB->query("SELECT $a_prop FROM adm_settings_template WHERE ".
401  " id = ".$ilDB->quote($a_id, "integer")
402  );
403  $rec = $ilDB->fetchAssoc($set);
404  return $rec[$a_prop];
405  }
+ Here is the caller graph for this function:

◆ lookupTitle()

static ilSettingsTemplate::lookupTitle (   $a_id)
static

Lookup title.

Parameters

Definition at line 413 of file class.ilSettingsTemplate.php.

References lookupProperty().

Referenced by ilSettingsTemplateGUI\confirmSettingsTemplateDeletion(), and ilObjSurveyGUI\propertiesObject().

414  {
415  return ilSettingsTemplate::lookupProperty($a_id, "title");
416  }
static lookupProperty($a_id, $a_prop)
Lookup property.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read()

ilSettingsTemplate::read ( )

Read.

Parameters

Definition at line 227 of file class.ilSettingsTemplate.php.

References addHiddenTab(), setDescription(), setSetting(), setTitle(), and setType().

Referenced by __construct().

228  {
229  global $ilDB;
230 
231  // read template
232  $set = $ilDB->query("SELECT * FROM adm_settings_template WHERE ".
233  " id = ".$ilDB->quote($this->getId(), "integer")
234  );
235  $rec = $ilDB->fetchAssoc($set);
236  $this->setTitle($rec["title"]);
237  $this->setType($rec["type"]);
238  $this->setDescription($rec["description"]);
239 
240  // read template setttings
241  $set = $ilDB->query("SELECT * FROM adm_set_templ_value WHERE ".
242  " template_id = ".$ilDB->quote($this->getId(), "integer")
243  );
244  while ($rec = $ilDB->fetchAssoc($set))
245  {
246  $this->setSetting($rec["setting"],
247  $rec["value"], $rec["hide"]);
248  }
249 
250  // read hidden tabs
251  $set = $ilDB->query("SELECT * FROM adm_set_templ_hide_tab WHERE ".
252  " template_id = ".$ilDB->quote($this->getId(), "integer")
253  );
254  while ($rec = $ilDB->fetchAssoc($set))
255  {
256  $this->addHiddenTab($rec["tab_id"]);
257  }
258  }
setDescription($a_val)
Set description.
setTitle($a_val)
Set title.
addHiddenTab($a_tab_id)
Add hidden tab.
setSetting($a_setting, $a_value, $a_hide=false)
Set setting.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeAllHiddenTabs()

ilSettingsTemplate::removeAllHiddenTabs ( )

Remove all hidden tabs.

Definition at line 188 of file class.ilSettingsTemplate.php.

189  {
190  $this->hidden_tab = array();
191  }

◆ removeAllSettings()

ilSettingsTemplate::removeAllSettings ( )

Remove all settings.

Definition at line 161 of file class.ilSettingsTemplate.php.

162  {
163  $this->setting = array();
164  }

◆ removeSetting()

ilSettingsTemplate::removeSetting (   $a_setting)

Remove setting.

Parameters
stringsetting

Definition at line 153 of file class.ilSettingsTemplate.php.

154  {
155  unset($this->setting[$a_setting]);
156  }

◆ setConfig()

ilSettingsTemplate::setConfig ( ilSettingsTemplateConfig  $config)

Sets the template config for this template.

Parameters
ilSettingsTemplateConfig$config

Definition at line 216 of file class.ilSettingsTemplate.php.

References $config.

Referenced by __construct().

216  {
217  $this->config = $config;
218  }
+ Here is the caller graph for this function:

◆ setDescription()

ilSettingsTemplate::setDescription (   $a_val)

Set description.

Parameters
string$a_valdescription

Definition at line 107 of file class.ilSettingsTemplate.php.

Referenced by read().

108  {
109  $this->description = $a_val;
110  }
+ Here is the caller graph for this function:

◆ setId()

ilSettingsTemplate::setId (   $a_val)

Set id.

Parameters
integerid

Definition at line 47 of file class.ilSettingsTemplate.php.

Referenced by __construct(), and create().

48  {
49  $this->id = $a_val;
50  }
+ Here is the caller graph for this function:

◆ setSetting()

ilSettingsTemplate::setSetting (   $a_setting,
  $a_value,
  $a_hide = false 
)

Set setting.

Parameters
stringsetting
mixedvalue
booleanhide the setting?

Definition at line 129 of file class.ilSettingsTemplate.php.

References ilSettingsTemplateConfig\CHECKBOX, and getConfig().

Referenced by read().

130  {
131  if ($this->getConfig()) {
132  $settings = $this->getConfig()->getSettings();
133 
134  if ($settings[$a_setting]['type'] == ilSettingsTemplateConfig::CHECKBOX) {
135  if (is_array($a_value))
136  $a_value = serialize($a_value);
137  else
138  $a_value = unserialize($a_value);
139  }
140  }
141 
142  $this->setting[$a_setting] = array(
143  "value" => $a_value,
144  "hide" => $a_hide
145  );
146  }
getConfig()
Returns the template config associated with this template or NULL if none is given.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setTitle()

ilSettingsTemplate::setTitle (   $a_val)

Set title.

Parameters
stringtitle

Definition at line 67 of file class.ilSettingsTemplate.php.

Referenced by read().

68  {
69  $this->title = $a_val;
70  }
+ Here is the caller graph for this function:

◆ setType()

ilSettingsTemplate::setType (   $a_val)

Set type.

Parameters
string$a_valtype

Definition at line 87 of file class.ilSettingsTemplate.php.

Referenced by read().

88  {
89  $this->type = $a_val;
90  }
+ Here is the caller graph for this function:

◆ update()

ilSettingsTemplate::update ( )

Update settings template.

Definition at line 287 of file class.ilSettingsTemplate.php.

References getDescription(), getId(), getTitle(), getType(), insertHiddenTabs(), and insertSettings().

288  {
289  global $ilDB;
290 
291  // update template
292  $ilDB->update("adm_settings_template", array(
293  "title" => array("text", $this->getTitle()),
294  "type" => array("text", $this->getType()),
295  "description" => array("clob", $this->getDescription())
296  ), array(
297  "id" => array("integer", $this->getId()),
298  ));
299 
300  // delete settings and hidden tabs
301  $ilDB->manipulate("DELETE FROM adm_set_templ_value WHERE "
302  ." template_id = ".$ilDB->quote($this->getId(), "integer")
303  );
304  $ilDB->manipulate("DELETE FROM adm_set_templ_hide_tab WHERE "
305  ." template_id = ".$ilDB->quote($this->getId(), "integer")
306  );
307 
308  // insert settings and hidden tabs
309  $this->insertSettings();
310  $this->insertHiddenTabs();
311 
312  }
getDescription()
Get description.
insertHiddenTabs()
Insert hidden tabs.
insertSettings()
Insert settings to db.
+ Here is the call graph for this function:

Field Documentation

◆ $config

ilSettingsTemplate::$config
private

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

Referenced by __construct(), getConfig(), and setConfig().

◆ $description

ilSettingsTemplate::$description
private

Definition at line 16 of file class.ilSettingsTemplate.php.

Referenced by getDescription().

◆ $hidden_tab

ilSettingsTemplate::$hidden_tab = array()
private

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

Referenced by getHiddenTabs().

◆ $id

ilSettingsTemplate::$id
private

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

Referenced by getId().

◆ $setting

ilSettingsTemplate::$setting = array()
private

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

Referenced by getSettings().

◆ $title

ilSettingsTemplate::$title
private

Definition at line 15 of file class.ilSettingsTemplate.php.

Referenced by getTitle().

◆ $type

ilSettingsTemplate::$type
private

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

Referenced by getType().


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