ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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...
 

Protected Attributes

 $db
 

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

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

41  {
42  global $DIC;
43 
44  $this->db = $DIC->database();
45  if ($a_id > 0) {
46  if ($config) {
47  $this->setConfig($config);
48  }
49  $this->setId($a_id);
50  $this->read();
51  }
52  }
global $DIC
Definition: saml.php:7
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 213 of file class.ilSettingsTemplate.php.

Referenced by read().

214  {
215  $this->hidden_tab[$a_tab_id] = $a_tab_id;
216  }
+ Here is the caller graph for this function:

◆ create()

ilSettingsTemplate::create ( )

Create settings template.

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

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

306  {
307  $ilDB = $this->db;
308 
309  $this->setId($ilDB->nextId("adm_settings_template"));
310 
311  // write template
312  $ilDB->insert("adm_settings_template", array(
313  "id" => array("integer", $this->getId()),
314  "title" => array("text", $this->getTitle()),
315  "type" => array("text", $this->getType()),
316  // begin-patch lok
317  "description" => array("clob", $this->getDescription()),
318  'auto_generated' => array('integer',$this->getAutoGenerated())
319  // end-patch lok
320  ));
321 
322  // write settings
323  $this->insertSettings();
324 
325  // write hidden tabs
326  $this->insertHiddenTabs();
327  }
getDescription()
Get description.
insertHiddenTabs()
Insert hidden tabs.
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 399 of file class.ilSettingsTemplate.php.

References $db, and $ilDB.

400  {
401  $ilDB = $this->db;
402 
403  $ilDB->manipulate(
404  "DELETE FROM adm_settings_template WHERE "
405  . " id = " . $ilDB->quote($this->getId(), "integer")
406  );
407  $ilDB->manipulate(
408  "DELETE FROM adm_set_templ_value WHERE "
409  . " template_id = " . $ilDB->quote($this->getId(), "integer")
410  );
411  $ilDB->manipulate(
412  "DELETE FROM adm_set_templ_hide_tab WHERE "
413  . " template_id = " . $ilDB->quote($this->getId(), "integer")
414  );
415  }
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 422 of file class.ilSettingsTemplate.php.

References $a_type, $DIC, and $ilDB.

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

423  {
424  global $DIC;
425 
426  $ilDB = $DIC->database();
427 
428  // begin-patch lok
429  if ($a_include_auto_generated) {
430  $set = $ilDB->query("SELECT * FROM adm_settings_template " .
431  " WHERE type = " . $ilDB->quote($a_type, "text") .
432  " ORDER BY title");
433  } else {
434  $set = $ilDB->query("SELECT * FROM adm_settings_template " .
435  " WHERE type = " . $ilDB->quote($a_type, "text") .
436  'AND auto_generated = ' . $ilDB->quote(0, 'integer') . ' ' .
437  " ORDER BY title");
438  }
439  // end-patch lok
440 
441 
442  $settings_template = array();
443  while ($rec = $ilDB->fetchAssoc($set)) {
444  $settings_template[] = $rec;
445  }
446  return $settings_template;
447  }
global $DIC
Definition: saml.php:7
$a_type
Definition: workflow.php:92
global $ilDB
+ Here is the caller graph for this function:

◆ getAutoGenerated()

ilSettingsTemplate::getAutoGenerated ( )

Get auto generated status.

Returns
type

Definition at line 88 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 240 of file class.ilSettingsTemplate.php.

References $config.

Referenced by setSetting().

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

◆ getDescription()

ilSettingsTemplate::getDescription ( )

Get description.

Returns
string description

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

References $description.

Referenced by create(), and update().

150  {
151  return $this->description;
152  }
+ Here is the caller graph for this function:

◆ getHiddenTabs()

ilSettingsTemplate::getHiddenTabs ( )

Get hidden tabs.

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

References $hidden_tab.

Referenced by insertHiddenTabs().

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

◆ getId()

ilSettingsTemplate::getId ( )

Get id.

Returns
integer id

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

References $id.

Referenced by create(), and update().

70  {
71  return $this->id;
72  }
+ Here is the caller graph for this function:

◆ getSettings()

ilSettingsTemplate::getSettings ( )

Get settings.

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

References $setting.

Referenced by insertSettings().

203  {
204  return $this->setting;
205  }
+ Here is the caller graph for this function:

◆ getTitle()

ilSettingsTemplate::getTitle ( )

Get title.

Returns
string title

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

References $title.

Referenced by create(), and update().

110  {
111  return $this->title;
112  }
+ Here is the caller graph for this function:

◆ getType()

ilSettingsTemplate::getType ( )

Get type.

Returns
string type

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

References $type.

Referenced by create(), and update().

130  {
131  return $this->type;
132  }
+ Here is the caller graph for this function:

◆ insertHiddenTabs()

ilSettingsTemplate::insertHiddenTabs ( )

Insert hidden tabs.

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

References $db, $ilDB, and getHiddenTabs().

Referenced by create(), and update().

384  {
385  $ilDB = $this->db;
386 
387  foreach ($this->getHiddenTabs() as $tab_id) {
388  $ilDB->manipulate("INSERT INTO adm_set_templ_hide_tab " .
389  "(template_id, tab_id) VALUES (" .
390  $ilDB->quote($this->getId(), "integer") . "," .
391  $ilDB->quote($tab_id, "text") .
392  ")");
393  }
394  }
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 365 of file class.ilSettingsTemplate.php.

References $db, $ilDB, $s, and getSettings().

Referenced by create(), and update().

366  {
367  $ilDB = $this->db;
368 
369  foreach ($this->getSettings() as $s => $set) {
370  $ilDB->manipulate("INSERT INTO adm_set_templ_value " .
371  "(template_id, setting, value, hide) VALUES (" .
372  $ilDB->quote($this->getId(), "integer") . "," .
373  $ilDB->quote($s, "text") . "," .
374  $ilDB->quote($set["value"], "text") . "," .
375  $ilDB->quote($set["hide"], "integer") .
376  ")");
377  }
378  }
$s
Definition: pwgen.php:45
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 486 of file class.ilSettingsTemplate.php.

487  {
488  return self::lookupProperty($a_id, 'description');
489  }

◆ lookupProperty()

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

Lookup property.

Parameters
idlevel id
Returns
mixed property value

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

References $DIC, and $ilDB.

456  {
457  global $DIC;
458 
459  $ilDB = $DIC->database();
460 
461  $set = $ilDB->query(
462  "SELECT $a_prop FROM adm_settings_template WHERE " .
463  " id = " . $ilDB->quote($a_id, "integer")
464  );
465  $rec = $ilDB->fetchAssoc($set);
466  return $rec[$a_prop];
467  }
global $DIC
Definition: saml.php:7
global $ilDB

◆ lookupTitle()

static ilSettingsTemplate::lookupTitle (   $a_id)
static

Lookup title.

Parameters

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

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

477  {
478  return self::lookupProperty($a_id, 'title');
479  }
+ Here is the caller graph for this function:

◆ read()

ilSettingsTemplate::read ( )

Read.

Parameters

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

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

Referenced by __construct().

263  {
264  $ilDB = $this->db;
265 
266  // read template
267  $set = $ilDB->query(
268  "SELECT * FROM adm_settings_template WHERE " .
269  " id = " . $ilDB->quote($this->getId(), "integer")
270  );
271  $rec = $ilDB->fetchAssoc($set);
272  $this->setTitle($rec["title"]);
273  $this->setType($rec["type"]);
274  $this->setDescription($rec["description"]);
275  // begin-patch lok
276  $this->setAutoGenerated($rec['auto_generated']);
277  // end-patch lok
278 
279  // read template setttings
280  $set = $ilDB->query(
281  "SELECT * FROM adm_set_templ_value WHERE " .
282  " template_id = " . $ilDB->quote($this->getId(), "integer")
283  );
284  while ($rec = $ilDB->fetchAssoc($set)) {
285  $this->setSetting(
286  $rec["setting"],
287  $rec["value"],
288  $rec["hide"]
289  );
290  }
291 
292  // read hidden tabs
293  $set = $ilDB->query(
294  "SELECT * FROM adm_set_templ_hide_tab WHERE " .
295  " template_id = " . $ilDB->quote($this->getId(), "integer")
296  );
297  while ($rec = $ilDB->fetchAssoc($set)) {
298  $this->addHiddenTab($rec["tab_id"]);
299  }
300  }
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 221 of file class.ilSettingsTemplate.php.

222  {
223  $this->hidden_tab = array();
224  }

◆ removeAllSettings()

ilSettingsTemplate::removeAllSettings ( )

Remove all settings.

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

195  {
196  $this->setting = array();
197  }

◆ removeSetting()

ilSettingsTemplate::removeSetting (   $a_setting)

Remove setting.

Parameters
stringsetting

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

187  {
188  unset($this->setting[$a_setting]);
189  }

◆ setAutoGenerated()

ilSettingsTemplate::setAutoGenerated (   $a_status)

Set auto generated status.

Parameters
type$a_status

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

Referenced by read().

80  {
81  $this->auto_generated = $a_status;
82  }
+ 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 250 of file class.ilSettingsTemplate.php.

References $config.

Referenced by __construct().

251  {
252  $this->config = $config;
253  }
+ Here is the caller graph for this function:

◆ setDescription()

ilSettingsTemplate::setDescription (   $a_val)

Set description.

Parameters
string$a_valdescription

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

Referenced by read().

140  {
141  $this->description = $a_val;
142  }
+ Here is the caller graph for this function:

◆ setId()

ilSettingsTemplate::setId (   $a_val)

Set id.

Parameters
integerid

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

Referenced by __construct(), and create().

60  {
61  $this->id = $a_val;
62  }
+ 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 161 of file class.ilSettingsTemplate.php.

References ilSettingsTemplateConfig\CHECKBOX, and getConfig().

Referenced by read().

162  {
163  if ($this->getConfig()) {
164  $settings = $this->getConfig()->getSettings();
165 
166  if ($settings[$a_setting]['type'] == ilSettingsTemplateConfig::CHECKBOX) {
167  if (is_array($a_value)) {
168  $a_value = serialize($a_value);
169  } else {
170  $a_value = unserialize($a_value);
171  }
172  }
173  }
174 
175  $this->setting[$a_setting] = array(
176  "value" => $a_value,
177  "hide" => $a_hide
178  );
179  }
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 99 of file class.ilSettingsTemplate.php.

Referenced by read().

100  {
101  $this->title = $a_val;
102  }
+ Here is the caller graph for this function:

◆ setType()

ilSettingsTemplate::setType (   $a_val)

Set type.

Parameters
string$a_valtype

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

Referenced by read().

120  {
121  $this->type = $a_val;
122  }
+ Here is the caller graph for this function:

◆ translate()

static ilSettingsTemplate::translate (   $a_title_desc)
static

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

References $GLOBALS.

Referenced by ilSettingsTemplateTableGUI\fillRow().

493  {
494  if (substr($a_title_desc, 0, 3) == 'il_') {
495  return $GLOBALS['lng']->txt($a_title_desc);
496  }
497  return $a_title_desc;
498  }
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
+ Here is the caller graph for this function:

◆ update()

ilSettingsTemplate::update ( )

Update settings template.

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

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

333  {
334  $ilDB = $this->db;
335 
336  // update template
337  $ilDB->update("adm_settings_template", array(
338  "title" => array("text", $this->getTitle()),
339  "type" => array("text", $this->getType()),
340  // begin-patch lok
341  "description" => array("clob", $this->getDescription()),
342  'auto_generated' => array('integer',$this->getAutoGenerated())
343  ), array(
344  "id" => array("integer", $this->getId()),
345  ));
346 
347  // delete settings and hidden tabs
348  $ilDB->manipulate(
349  "DELETE FROM adm_set_templ_value WHERE "
350  . " template_id = " . $ilDB->quote($this->getId(), "integer")
351  );
352  $ilDB->manipulate(
353  "DELETE FROM adm_set_templ_hide_tab WHERE "
354  . " template_id = " . $ilDB->quote($this->getId(), "integer")
355  );
356 
357  // insert settings and hidden tabs
358  $this->insertSettings();
359  $this->insertHiddenTabs();
360  }
getDescription()
Get description.
insertHiddenTabs()
Insert hidden tabs.
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 26 of file class.ilSettingsTemplate.php.

Referenced by getAutoGenerated().

◆ $config

ilSettingsTemplate::$config
private

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

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

◆ $db

ilSettingsTemplate::$db
protected

◆ $description

ilSettingsTemplate::$description
private

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

Referenced by getDescription().

◆ $hidden_tab

ilSettingsTemplate::$hidden_tab = array()
private

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

Referenced by getHiddenTabs().

◆ $id

ilSettingsTemplate::$id
private

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

Referenced by getId().

◆ $setting

ilSettingsTemplate::$setting = array()
private

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

Referenced by getSettings().

◆ $title

ilSettingsTemplate::$title
private

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

Referenced by getTitle().

◆ $type

ilSettingsTemplate::$type
private

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

Referenced by getType().


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