ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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...
 
 setAutoGenerated ($a_status)
 Set auto generated status. More...
 
 getAutoGenerated ()
 Get auto generated status. 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, $a_include_auto_generated=false)
 Get all settings templates of type. More...
 
static lookupTitle ($a_id)
 Lookup title. More...
 
static lookupDescription ($a_id)
 Lookup title. More...
 
static translate ($a_title_desc)
 

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()
 
 $auto_generated = false
 
 $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 35 of file class.ilSettingsTemplate.php.

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

36  {
37  if ($a_id > 0)
38  {
39  if ($config)
40  $this->setConfig($config);
41  $this->setId($a_id);
42  $this->read();
43  }
44  }
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 204 of file class.ilSettingsTemplate.php.

Referenced by read().

205  {
206  $this->hidden_tab[$a_tab_id] = $a_tab_id;
207  }
+ Here is the caller graph for this function:

◆ create()

ilSettingsTemplate::create ( )

Create settings template.

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

References $ilDB, array, getAutoGenerated(), getDescription(), getId(), getTitle(), getType(), insertHiddenTabs(), insertSettings(), and setId().

291  {
292  global $ilDB;
293 
294  $this->setId($ilDB->nextId("adm_settings_template"));
295 
296  // write template
297  $ilDB->insert("adm_settings_template", array(
298  "id" => array("integer", $this->getId()),
299  "title" => array("text", $this->getTitle()),
300  "type" => array("text", $this->getType()),
301  // begin-patch lok
302  "description" => array("clob", $this->getDescription()),
303  'auto_generated' => array('integer',$this->getAutoGenerated())
304  // end-patch lok
305  ));
306 
307  // write settings
308  $this->insertSettings();
309 
310  // write hidden tabs
311  $this->insertHiddenTabs();
312  }
getDescription()
Get description.
insertHiddenTabs()
Insert hidden tabs.
Create styles array
The data for the language used.
global $ilDB
getAutoGenerated()
Get auto generated status.
insertSettings()
Insert settings to db.
+ Here is the call graph for this function:

◆ delete()

ilSettingsTemplate::delete ( )

Delete settings template.

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

References $ilDB.

386  {
387  global $ilDB;
388 
389  $ilDB->manipulate("DELETE FROM adm_settings_template WHERE "
390  ." id = ".$ilDB->quote($this->getId(), "integer")
391  );
392  $ilDB->manipulate("DELETE FROM adm_set_templ_value WHERE "
393  ." template_id = ".$ilDB->quote($this->getId(), "integer")
394  );
395  $ilDB->manipulate("DELETE FROM adm_set_templ_hide_tab WHERE "
396  ." template_id = ".$ilDB->quote($this->getId(), "integer")
397  );
398  }
global $ilDB

◆ getAllSettingsTemplates()

static ilSettingsTemplate::getAllSettingsTemplates (   $a_type,
  $a_include_auto_generated = false 
)
static

Get all settings templates of type.

Parameters
string$a_typeobject type

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

References $a_type, $ilDB, and array.

Referenced by ilSettingsTemplateTableGUI\__construct(), ilObjSurveyGUI\addDidacticTemplateOptions(), ilObjTestGUI\addDidacticTemplateOptions(), ilLOEditorGUI\applySettingsTemplate(), and ilObjSurveyGUI\importSurveyObject().

406  {
407  global $ilDB;
408 
409  // begin-patch lok
410  if($a_include_auto_generated)
411  {
412  $set = $ilDB->query("SELECT * FROM adm_settings_template ".
413  " WHERE type = ".$ilDB->quote($a_type, "text").
414  " ORDER BY title");
415  }
416  else
417  {
418  $set = $ilDB->query("SELECT * FROM adm_settings_template ".
419  " WHERE type = ".$ilDB->quote($a_type, "text").
420  'AND auto_generated = '.$ilDB->quote(0,'integer').' '.
421  " ORDER BY title");
422  }
423  // end-patch lok
424 
425 
426  $settings_template = array();
427  while ($rec = $ilDB->fetchAssoc($set))
428  {
429  $settings_template[] = $rec;
430  }
431  return $settings_template;
432  }
$a_type
Definition: workflow.php:93
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ getAutoGenerated()

ilSettingsTemplate::getAutoGenerated ( )

Get auto generated status.

Returns
type

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

References $auto_generated.

Referenced by create(), and update().

+ 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 231 of file class.ilSettingsTemplate.php.

References $config.

Referenced by setSetting().

231  {
232  return $this->config;
233  }
+ Here is the caller graph for this function:

◆ getDescription()

ilSettingsTemplate::getDescription ( )

Get description.

Returns
string description

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

References $description.

Referenced by create(), and update().

142  {
143  return $this->description;
144  }
+ Here is the caller graph for this function:

◆ getHiddenTabs()

ilSettingsTemplate::getHiddenTabs ( )

Get hidden tabs.

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

References $hidden_tab.

Referenced by insertHiddenTabs().

221  {
222  return $this->hidden_tab;
223  }
+ Here is the caller graph for this function:

◆ getId()

ilSettingsTemplate::getId ( )

Get id.

Returns
integer id

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

References $id.

Referenced by create(), and update().

62  {
63  return $this->id;
64  }
+ Here is the caller graph for this function:

◆ getSettings()

ilSettingsTemplate::getSettings ( )

Get settings.

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

References $setting.

Referenced by insertSettings().

194  {
195  return $this->setting;
196  }
+ Here is the caller graph for this function:

◆ getTitle()

ilSettingsTemplate::getTitle ( )

Get title.

Returns
string title

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

References $title.

Referenced by create(), and update().

102  {
103  return $this->title;
104  }
+ Here is the caller graph for this function:

◆ getType()

ilSettingsTemplate::getType ( )

Get type.

Returns
string type

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

References $type.

Referenced by create(), and update().

122  {
123  return $this->type;
124  }
+ Here is the caller graph for this function:

◆ insertHiddenTabs()

ilSettingsTemplate::insertHiddenTabs ( )

Insert hidden tabs.

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

References $ilDB, and getHiddenTabs().

Referenced by create(), and update().

369  {
370  global $ilDB;
371 
372  foreach ($this->getHiddenTabs() as $tab_id)
373  {
374  $ilDB->manipulate("INSERT INTO adm_set_templ_hide_tab ".
375  "(template_id, tab_id) VALUES (".
376  $ilDB->quote($this->getId(), "integer").",".
377  $ilDB->quote($tab_id, "text").
378  ")");
379  }
380  }
getHiddenTabs()
Get hidden tabs.
global $ilDB
+ 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 349 of file class.ilSettingsTemplate.php.

References $ilDB, and getSettings().

Referenced by create(), and update().

350  {
351  global $ilDB;
352 
353  foreach ($this->getSettings() as $s => $set)
354  {
355  $ilDB->manipulate("INSERT INTO adm_set_templ_value ".
356  "(template_id, setting, value, hide) VALUES (".
357  $ilDB->quote($this->getId(), "integer").",".
358  $ilDB->quote($s, "text").",".
359  $ilDB->quote($set["value"], "text").",".
360  $ilDB->quote($set["hide"], "integer").
361  ")");
362  }
363  }
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lookupDescription()

static ilSettingsTemplate::lookupDescription (   $a_id)
static

Lookup title.

Parameters

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

469  {
470  return self::lookupProperty($a_id, 'description');
471  }

◆ lookupProperty()

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

Lookup property.

Parameters
idlevel id
Returns
mixed property value

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

References $ilDB.

441  {
442  global $ilDB;
443 
444  $set = $ilDB->query("SELECT $a_prop FROM adm_settings_template WHERE ".
445  " id = ".$ilDB->quote($a_id, "integer")
446  );
447  $rec = $ilDB->fetchAssoc($set);
448  return $rec[$a_prop];
449  }
global $ilDB

◆ lookupTitle()

static ilSettingsTemplate::lookupTitle (   $a_id)
static

Lookup title.

Parameters

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

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

459  {
460  return self::lookupProperty($a_id, 'title');
461  }
+ Here is the caller graph for this function:

◆ read()

ilSettingsTemplate::read ( )

Read.

Parameters

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

References $ilDB, addHiddenTab(), setAutoGenerated(), setDescription(), setSetting(), setTitle(), and setType().

Referenced by __construct().

252  {
253  global $ilDB;
254 
255  // read template
256  $set = $ilDB->query("SELECT * FROM adm_settings_template WHERE ".
257  " id = ".$ilDB->quote($this->getId(), "integer")
258  );
259  $rec = $ilDB->fetchAssoc($set);
260  $this->setTitle($rec["title"]);
261  $this->setType($rec["type"]);
262  $this->setDescription($rec["description"]);
263  // begin-patch lok
264  $this->setAutoGenerated($rec['auto_generated']);
265  // end-patch lok
266 
267  // read template setttings
268  $set = $ilDB->query("SELECT * FROM adm_set_templ_value WHERE ".
269  " template_id = ".$ilDB->quote($this->getId(), "integer")
270  );
271  while ($rec = $ilDB->fetchAssoc($set))
272  {
273  $this->setSetting($rec["setting"],
274  $rec["value"], $rec["hide"]);
275  }
276 
277  // read hidden tabs
278  $set = $ilDB->query("SELECT * FROM adm_set_templ_hide_tab WHERE ".
279  " template_id = ".$ilDB->quote($this->getId(), "integer")
280  );
281  while ($rec = $ilDB->fetchAssoc($set))
282  {
283  $this->addHiddenTab($rec["tab_id"]);
284  }
285  }
setDescription($a_val)
Set description.
setTitle($a_val)
Set title.
setAutoGenerated($a_status)
Set auto generated status.
addHiddenTab($a_tab_id)
Add hidden tab.
setSetting($a_setting, $a_value, $a_hide=false)
Set setting.
global $ilDB
+ 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 212 of file class.ilSettingsTemplate.php.

References array.

213  {
214  $this->hidden_tab = array();
215  }
Create styles array
The data for the language used.

◆ removeAllSettings()

ilSettingsTemplate::removeAllSettings ( )

Remove all settings.

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

References array.

186  {
187  $this->setting = array();
188  }
Create styles array
The data for the language used.

◆ removeSetting()

ilSettingsTemplate::removeSetting (   $a_setting)

Remove setting.

Parameters
stringsetting

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

178  {
179  unset($this->setting[$a_setting]);
180  }

◆ setAutoGenerated()

ilSettingsTemplate::setAutoGenerated (   $a_status)

Set auto generated status.

Parameters
type$a_status

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

Referenced by read().

72  {
73  $this->auto_generated = $a_status;
74  }
+ Here is the caller graph for this function:

◆ setConfig()

ilSettingsTemplate::setConfig ( ilSettingsTemplateConfig  $config)

Sets the template config for this template.

Parameters
ilSettingsTemplateConfig$config

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

References $config.

Referenced by __construct().

240  {
241  $this->config = $config;
242  }
+ Here is the caller graph for this function:

◆ setDescription()

ilSettingsTemplate::setDescription (   $a_val)

Set description.

Parameters
string$a_valdescription

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

Referenced by read().

132  {
133  $this->description = $a_val;
134  }
+ Here is the caller graph for this function:

◆ setId()

ilSettingsTemplate::setId (   $a_val)

Set id.

Parameters
integerid

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

Referenced by __construct(), and create().

52  {
53  $this->id = $a_val;
54  }
+ 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 153 of file class.ilSettingsTemplate.php.

References array, ilSettingsTemplateConfig\CHECKBOX, and getConfig().

Referenced by read().

154  {
155  if ($this->getConfig()) {
156  $settings = $this->getConfig()->getSettings();
157 
158  if ($settings[$a_setting]['type'] == ilSettingsTemplateConfig::CHECKBOX) {
159  if (is_array($a_value))
160  $a_value = serialize($a_value);
161  else
162  $a_value = unserialize($a_value);
163  }
164  }
165 
166  $this->setting[$a_setting] = array(
167  "value" => $a_value,
168  "hide" => $a_hide
169  );
170  }
Create styles array
The data for the language used.
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 91 of file class.ilSettingsTemplate.php.

Referenced by read().

92  {
93  $this->title = $a_val;
94  }
+ Here is the caller graph for this function:

◆ setType()

ilSettingsTemplate::setType (   $a_val)

Set type.

Parameters
string$a_valtype

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

Referenced by read().

112  {
113  $this->type = $a_val;
114  }
+ Here is the caller graph for this function:

◆ translate()

static ilSettingsTemplate::translate (   $a_title_desc)
static

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

References $GLOBALS.

Referenced by ilSettingsTemplateTableGUI\fillRow().

475  {
476  if(substr($a_title_desc, 0, 3) == 'il_')
477  {
478  return $GLOBALS['lng']->txt($a_title_desc);
479  }
480  return $a_title_desc;
481  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
+ Here is the caller graph for this function:

◆ update()

ilSettingsTemplate::update ( )

Update settings template.

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

References $ilDB, array, getAutoGenerated(), getDescription(), getId(), getTitle(), getType(), insertHiddenTabs(), and insertSettings().

318  {
319  global $ilDB;
320 
321  // update template
322  $ilDB->update("adm_settings_template", array(
323  "title" => array("text", $this->getTitle()),
324  "type" => array("text", $this->getType()),
325  // begin-patch lok
326  "description" => array("clob", $this->getDescription()),
327  'auto_generated' => array('integer',$this->getAutoGenerated())
328  ), array(
329  "id" => array("integer", $this->getId()),
330  ));
331 
332  // delete settings and hidden tabs
333  $ilDB->manipulate("DELETE FROM adm_set_templ_value WHERE "
334  ." template_id = ".$ilDB->quote($this->getId(), "integer")
335  );
336  $ilDB->manipulate("DELETE FROM adm_set_templ_hide_tab WHERE "
337  ." template_id = ".$ilDB->quote($this->getId(), "integer")
338  );
339 
340  // insert settings and hidden tabs
341  $this->insertSettings();
342  $this->insertHiddenTabs();
343 
344  }
getDescription()
Get description.
insertHiddenTabs()
Insert hidden tabs.
Create styles array
The data for the language used.
global $ilDB
getAutoGenerated()
Get auto generated status.
insertSettings()
Insert settings to db.
+ Here is the call graph for this function:

Field Documentation

◆ $auto_generated

ilSettingsTemplate::$auto_generated = false
private

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

Referenced by getAutoGenerated().

◆ $config

ilSettingsTemplate::$config
private

Definition at line 28 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: