ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
ilDidacticTemplateSetting Class Reference
+ Collaboration diagram for ilDidacticTemplateSetting:

Public Member Functions

 __construct ($a_id=0)
 Constructor. More...
 
 getId ()
 Get id. More...
 
 enable ($a_status)
 Set enabled status. More...
 
 isEnabled ()
 Check if template is enabled. More...
 
 setTitle ($a_title)
 Set title. More...
 
 getTitle ()
 Get title. More...
 
 getDescription ()
 Get description. More...
 
 setDescription ($a_description)
 Set description. More...
 
 setInfo ($a_info)
 Set installation info text. More...
 
 getInfo ()
 Get installation info text. More...
 
 setType ($a_type)
 Set type. More...
 
 getType ()
 Get type. More...
 
 setAssignments (Array $a_ass)
 Set assignments. More...
 
 getAssignments ()
 Get object assignemnts. More...
 
 addAssignment ($a_obj_type)
 Add one assignment obj type. More...
 
 delete ()
 Delete settings. More...
 
 save ()
 Save settings. More...
 
 update ()
 Update settings ilDB $ilDB. More...
 
 toXml (ilXmlWriter $writer)
 Export. More...
 
 __clone ()
 Implemented clone method. More...
 

Data Fields

const TYPE_CREATION = 1
 

Protected Member Functions

 setId ($a_id)
 Set id. More...
 
 read ()
 read settings from db More...
 

Private Member Functions

 saveAssignments ()
 Save assignments in DB. More...
 
 saveAssignment ($a_obj_type)
 Add one object assignment ilDB $ilDB. More...
 
 deleteAssignments ()
 Delete assignments ilDB $ilDB. More...
 

Private Attributes

 $id = 0
 
 $enabled = false
 
 $title = ''
 
 $description = ''
 
 $info = ''
 
 $type = self::TYPE_CREATION
 
 $assignments = array()
 

Detailed Description

Definition at line 10 of file class.ilDidacticTemplateSetting.php.

Constructor & Destructor Documentation

◆ __construct()

ilDidacticTemplateSetting::__construct (   $a_id = 0)

Constructor.

Parameters
int$a_id

Definition at line 28 of file class.ilDidacticTemplateSetting.php.

References read(), and setId().

29  {
30  $this->setId($a_id);
31  $this->read();
32  }
+ Here is the call graph for this function:

Member Function Documentation

◆ __clone()

ilDidacticTemplateSetting::__clone ( )

Implemented clone method.

Definition at line 393 of file class.ilDidacticTemplateSetting.php.

References enable(), and setId().

394  {
395  $this->setId(0);
396  $this->enable(false);
397  }
enable($a_status)
Set enabled status.
+ Here is the call graph for this function:

◆ addAssignment()

ilDidacticTemplateSetting::addAssignment (   $a_obj_type)

Add one assignment obj type.

Parameters
string$a_obj_type

Definition at line 164 of file class.ilDidacticTemplateSetting.php.

Referenced by read().

165  {
166  $this->assignments[] = $a_obj_type;
167  }
+ Here is the caller graph for this function:

◆ delete()

ilDidacticTemplateSetting::delete ( )

Delete settings.

Definition at line 172 of file class.ilDidacticTemplateSetting.php.

References $query, ilDidacticTemplateActionFactory\getActionsByTemplateId(), and getId().

173  {
174  global $ilDB;
175 
176  // Delete settings
177  $query = 'DELETE FROM didactic_tpl_settings '.
178  'WHERE id = '.$ilDB->quote($this->getId(),'integer');
179  $ilDB->manipulate($query);
180 
181  // Delete obj assignments
182  $query = 'DELETE FROM didactic_tpl_sa '.
183  'WHERE id = '.$ilDB->quote($this->getId(),'integer');
184  $ilDB->manipulate($query);
185 
186  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateActionFactory.php';
188  {
189  $action->delete();
190  }
191 
192 
193  return true;
194  }
static getActionsByTemplateId($a_tpl_id)
Get actions of one template.
+ Here is the call graph for this function:

◆ deleteAssignments()

ilDidacticTemplateSetting::deleteAssignments ( )
private

Delete assignments ilDB $ilDB.

Returns
bool

Definition at line 258 of file class.ilDidacticTemplateSetting.php.

References $query, and getId().

Referenced by update().

259  {
260  global $ilDB;
261 
262  $query = 'DELETE FROM didactic_tpl_sa '.
263  'WHERE id = '.$ilDB->quote($this->getId(),'integer');
264  $ilDB->manipulate($query);
265  return true;
266  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ enable()

ilDidacticTemplateSetting::enable (   $a_status)

Set enabled status.

Parameters
bool$a_status

Definition at line 56 of file class.ilDidacticTemplateSetting.php.

Referenced by __clone(), and read().

57  {
58  $this->enabled = $a_status;
59  }
+ Here is the caller graph for this function:

◆ getAssignments()

ilDidacticTemplateSetting::getAssignments ( )

Get object assignemnts.

Returns
array

Definition at line 155 of file class.ilDidacticTemplateSetting.php.

References $assignments.

Referenced by ilDidacticTemplateSettingsGUI\initEditTemplate(), saveAssignments(), and toXml().

156  {
157  return (array) $this->assignments;
158  }
+ Here is the caller graph for this function:

◆ getDescription()

ilDidacticTemplateSetting::getDescription ( )

Get description.

Returns
string

Definition at line 92 of file class.ilDidacticTemplateSetting.php.

References $description.

Referenced by ilDidacticTemplateSettingsGUI\initEditTemplate(), save(), toXml(), and update().

+ Here is the caller graph for this function:

◆ getId()

ilDidacticTemplateSetting::getId ( )

Get id.

Returns
int

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

References $id.

Referenced by delete(), deleteAssignments(), ilDidacticTemplateImport\parseActions(), read(), save(), saveAssignment(), toXml(), and update().

+ Here is the caller graph for this function:

◆ getInfo()

ilDidacticTemplateSetting::getInfo ( )

Get installation info text.

Returns
string

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

References $info.

Referenced by ilDidacticTemplateSettingsGUI\initEditTemplate(), save(), toXml(), and update().

+ Here is the caller graph for this function:

◆ getTitle()

ilDidacticTemplateSetting::getTitle ( )

Get title.

Returns
string

Definition at line 83 of file class.ilDidacticTemplateSetting.php.

References $title.

Referenced by ilDidacticTemplateSettingsGUI\initEditTemplate(), save(), toXml(), and update().

+ Here is the caller graph for this function:

◆ getType()

ilDidacticTemplateSetting::getType ( )

Get type.

Returns
int

Definition at line 137 of file class.ilDidacticTemplateSetting.php.

References $type.

Referenced by save(), toXml(), and update().

+ Here is the caller graph for this function:

◆ isEnabled()

ilDidacticTemplateSetting::isEnabled ( )

Check if template is enabled.

Returns
bool

Definition at line 65 of file class.ilDidacticTemplateSetting.php.

References $enabled.

Referenced by save(), and update().

+ Here is the caller graph for this function:

◆ read()

ilDidacticTemplateSetting::read ( )
protected

read settings from db

Returns
bool

Read settings

Read assigned objects

Definition at line 295 of file class.ilDidacticTemplateSetting.php.

References $query, $res, $row, addAssignment(), DB_FETCHMODE_OBJECT, enable(), getId(), setDescription(), setInfo(), setTitle(), and setType().

Referenced by __construct().

296  {
297  global $ilDB;
298 
299  if(!$this->getId())
300  {
301  return false;
302  }
303 
307  $query = 'SELECT * FROM didactic_tpl_settings dtpl '.
308  'WHERE id = '.$ilDB->quote($this->getId(),'integer');
309  $res = $ilDB->query($query);
310  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
311  {
312  $this->setType($row->type);
313  $this->enable($row->enabled);
314  $this->setTitle($row->title);
315  $this->setDescription($row->description);
316  $this->setInfo($row->info);
317 
318  }
319 
323  $query = 'SELECT * FROM didactic_tpl_sa '.
324  'WHERE id = '.$ilDB->quote($this->getId(),'integer');
325  $res = $ilDB->query($query);
326  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
327  {
328  $this->addAssignment($row->obj_type);
329  }
330  return true;
331  }
setInfo($a_info)
Set installation info text.
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
addAssignment($a_obj_type)
Add one assignment obj type.
enable($a_status)
Set enabled status.
setDescription($a_description)
Set description.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilDidacticTemplateSetting::save ( )

Save settings.

Definition at line 199 of file class.ilDidacticTemplateSetting.php.

References $query, getDescription(), getId(), getInfo(), getTitle(), getType(), isEnabled(), saveAssignments(), and setId().

200  {
201  global $ilDB;
202 
203  $this->setId($ilDB->nextId('didactic_tpl_settings'));
204 
205  $query = 'INSERT INTO didactic_tpl_settings (id,enabled,title,description,info,type) '.
206  'VALUES( '.
207  $ilDB->quote($this->getId(),'integer').', '.
208  $ilDB->quote($this->isEnabled(),'integer').', '.
209  $ilDB->quote($this->getTitle(),'text').', '.
210  $ilDB->quote($this->getDescription(),'text').', '.
211  $ilDB->quote($this->getInfo(),'text').', '.
212  $ilDB->quote($this->getType(),'integer').
213  ')';
214 
215  $ilDB->manipulate($query);
216 
217  $this->saveAssignments();
218 
219 
220  return true;
221  }
isEnabled()
Check if template is enabled.
getInfo()
Get installation info text.
+ Here is the call graph for this function:

◆ saveAssignment()

ilDidacticTemplateSetting::saveAssignment (   $a_obj_type)
private

Add one object assignment ilDB $ilDB.

Parameters
string$a_obj_type

Definition at line 241 of file class.ilDidacticTemplateSetting.php.

References $query, and getId().

Referenced by saveAssignments().

242  {
243  global $ilDB;
244 
245  $query = 'INSERT INTO didactic_tpl_sa (id,obj_type) '.
246  'VALUES( '.
247  $ilDB->quote($this->getId(),'integer').', '.
248  $ilDB->quote($a_obj_type,'text').
249  ')';
250  $ilDB->manipulate($query);
251  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveAssignments()

ilDidacticTemplateSetting::saveAssignments ( )
private

Save assignments in DB.

Returns
bool

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

References getAssignments(), and saveAssignment().

Referenced by save(), and update().

228  {
229  foreach($this->getAssignments() as $ass)
230  {
231  $this->saveAssignment($ass);
232  }
233  return true;
234  }
saveAssignment($a_obj_type)
Add one object assignment ilDB $ilDB.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAssignments()

ilDidacticTemplateSetting::setAssignments ( Array  $a_ass)

Set assignments.

Parameters
array$a_ass

Definition at line 146 of file class.ilDidacticTemplateSetting.php.

147  {
148  $this->assignments = (array) $a_ass;
149  }

◆ setDescription()

ilDidacticTemplateSetting::setDescription (   $a_description)

Set description.

Parameters
string$a_description

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

Referenced by read().

102  {
103  $this->description = $a_description;
104  }
+ Here is the caller graph for this function:

◆ setId()

ilDidacticTemplateSetting::setId (   $a_id)
protected

Set id.

Parameters
int$a_id

Definition at line 38 of file class.ilDidacticTemplateSetting.php.

Referenced by __clone(), __construct(), and save().

39  {
40  $this->id = $a_id;
41  }
+ Here is the caller graph for this function:

◆ setInfo()

ilDidacticTemplateSetting::setInfo (   $a_info)

Set installation info text.

Parameters
string$a_info

Definition at line 110 of file class.ilDidacticTemplateSetting.php.

Referenced by read().

111  {
112  $this->info = $a_info;
113  }
+ Here is the caller graph for this function:

◆ setTitle()

ilDidacticTemplateSetting::setTitle (   $a_title)

Set title.

Parameters
string$a_title

Definition at line 74 of file class.ilDidacticTemplateSetting.php.

Referenced by read().

75  {
76  $this->title = $a_title;
77  }
+ Here is the caller graph for this function:

◆ setType()

ilDidacticTemplateSetting::setType (   $a_type)

Set type.

Parameters
int$a_type

Definition at line 128 of file class.ilDidacticTemplateSetting.php.

Referenced by read().

129  {
130  $this->type = $a_type;
131  }
+ Here is the caller graph for this function:

◆ toXml()

ilDidacticTemplateSetting::toXml ( ilXmlWriter  $writer)

Export.

Parameters
ilXmlWriter$writer
Returns
ilXmlWriter

Definition at line 338 of file class.ilDidacticTemplateSetting.php.

References $info, $type, ilDidacticTemplateActionFactory\getActionsByTemplateId(), getAssignments(), getDescription(), getId(), getInfo(), getTitle(), getType(), ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

339  {
340  switch($this->getType())
341  {
342  case self::TYPE_CREATION:
343  $type = 'creation';
344  break;
345  }
346 
347  $writer->xmlStartTag('didacticTemplate',array('type' => $type));
348  $writer->xmlElement('title',array(),$this->getTitle());
349  $writer->xmlElement('description', array(), $this->getDescription());
350 
351  // info text with p-tags
352  if(strlen($this->getInfo()))
353  {
354  $writer->xmlStartTag('info');
355 
356  $info_lines = (array) explode("\n",$this->getInfo());
357  foreach($info_lines as $info)
358  {
359  $trimmed_info = trim($info);
360  if(strlen($trimmed_info))
361  {
362  $writer->xmlElement('p', array(), $trimmed_info);
363  }
364  }
365 
366  $writer->xmlEndTag('info');
367  }
368 
369  // Assignments
370  $writer->xmlStartTag('assignments');
371  foreach($this->getAssignments() as $assignment)
372  {
373  $writer->xmlElement('assignment', array(), $assignment);
374  }
375  $writer->xmlEndTag('assignments');
376 
377 
378  $writer->xmlStartTag('actions');
379  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateActionFactory.php';
381  {
382  $action->toXml($writer);
383  }
384  $writer->xmlEndTag('actions');
385  $writer->xmlEndTag('didacticTemplate');
386 
387  return $writer;
388  }
xmlStartTag($tag, $attrs=NULL, $empty=FALSE, $encode=TRUE, $escape=TRUE)
Writes a starttag.
xmlElement($tag, $attrs=NULL, $data=Null, $encode=TRUE, $escape=TRUE)
Writes a basic element (no children, just textual content)
xmlEndTag($tag)
Writes an endtag.
getInfo()
Get installation info text.
static getActionsByTemplateId($a_tpl_id)
Get actions of one template.
+ Here is the call graph for this function:

◆ update()

ilDidacticTemplateSetting::update ( )

Update settings ilDB $ilDB.

Definition at line 272 of file class.ilDidacticTemplateSetting.php.

References $query, deleteAssignments(), getDescription(), getId(), getInfo(), getTitle(), getType(), isEnabled(), and saveAssignments().

273  {
274  global $ilDB;
275 
276  $query = 'UPDATE didactic_tpl_settings '.
277  'SET '.
278  'enabled = '.$ilDB->quote($this->isEnabled(),'integer').', '.
279  'title = '.$ilDB->quote($this->getTitle(),'text').', '.
280  'description = '.$ilDB->quote($this->getDescription(),'text').', '.
281  'info = '.$ilDB->quote($this->getInfo(),'text').', '.
282  'type = '.$ilDB->quote($this->getType(),'integer').' '.
283  'WHERE id = '.$ilDB->quote($this->getId(),'integer');
284  $ilDB->manipulate($query);
285  $this->deleteAssignments();
286  $this->saveAssignments();
287 
288  return true;
289  }
isEnabled()
Check if template is enabled.
deleteAssignments()
Delete assignments ilDB $ilDB.
getInfo()
Get installation info text.
+ Here is the call graph for this function:

Field Documentation

◆ $assignments

ilDidacticTemplateSetting::$assignments = array()
private

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

Referenced by getAssignments().

◆ $description

ilDidacticTemplateSetting::$description = ''
private

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

Referenced by getDescription().

◆ $enabled

ilDidacticTemplateSetting::$enabled = false
private

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

Referenced by isEnabled().

◆ $id

ilDidacticTemplateSetting::$id = 0
private

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

Referenced by getId().

◆ $info

ilDidacticTemplateSetting::$info = ''
private

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

Referenced by getInfo(), and toXml().

◆ $title

ilDidacticTemplateSetting::$title = ''
private

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

Referenced by getTitle().

◆ $type

ilDidacticTemplateSetting::$type = self::TYPE_CREATION
private

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

Referenced by getType(), and toXml().

◆ TYPE_CREATION

const ilDidacticTemplateSetting::TYPE_CREATION = 1

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