ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 @global 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 @global ilDB $ilDB. More...
 
 deleteAssignments ()
 Delete assignments @global 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.

29 {
30 $this->setId($a_id);
31 $this->read();
32 }

References read(), and setId().

+ Here is the call graph for this function:

Member Function Documentation

◆ __clone()

ilDidacticTemplateSetting::__clone ( )

Implemented clone method.

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

396 {
397 $this->setId(0);
398 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateCopier.php';
400 $this->enable(false);
401 }
enable($a_status)
Set enabled status.

References ilDidacticTemplateCopier\appendCopyInfo(), enable(), getTitle(), setId(), and setTitle().

+ 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.

165 {
166 $this->assignments[] = $a_obj_type;
167 }

Referenced by read().

+ Here is the caller graph for this function:

◆ delete()

ilDidacticTemplateSetting::delete ( )

Delete settings.

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

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 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php';
194
195 return true;
196 }
static getActionsByTemplateId($a_tpl_id)
Get actions of one template.
static deleteByTemplateId($a_tpl_id)
Delete by template id @global ilDB $ilDB.
global $ilDB

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

+ Here is the call graph for this function:

◆ deleteAssignments()

ilDidacticTemplateSetting::deleteAssignments ( )
private

Delete assignments @global ilDB $ilDB.

Returns
bool

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

261 {
262 global $ilDB;
263
264 $query = 'DELETE FROM didactic_tpl_sa '.
265 'WHERE id = '.$ilDB->quote($this->getId(),'integer');
266 $ilDB->manipulate($query);
267 return true;
268 }

References $ilDB, $query, and getId().

Referenced by update().

+ 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.

57 {
58 $this->enabled = $a_status;
59 }

Referenced by __clone(), and read().

+ 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().

+ 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 __clone(), 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 297 of file class.ilDidacticTemplateSetting.php.

298 {
299 global $ilDB;
300
301 if(!$this->getId())
302 {
303 return false;
304 }
305
309 $query = 'SELECT * FROM didactic_tpl_settings dtpl '.
310 'WHERE id = '.$ilDB->quote($this->getId(),'integer');
311 $res = $ilDB->query($query);
312 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
313 {
314 $this->setType($row->type);
315 $this->enable($row->enabled);
316 $this->setTitle($row->title);
317 $this->setDescription($row->description);
318 $this->setInfo($row->info);
319
320 }
321
325 $query = 'SELECT * FROM didactic_tpl_sa '.
326 'WHERE id = '.$ilDB->quote($this->getId(),'integer');
327 $res = $ilDB->query($query);
328 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
329 {
330 $this->addAssignment($row->obj_type);
331 }
332 return true;
333 }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
setDescription($a_description)
Set description.
addAssignment($a_obj_type)
Add one assignment obj type.
setInfo($a_info)
Set installation info text.

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

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilDidacticTemplateSetting::save ( )

Save settings.

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

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

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

+ Here is the call graph for this function:

◆ saveAssignment()

ilDidacticTemplateSetting::saveAssignment (   $a_obj_type)
private

Add one object assignment @global ilDB $ilDB.

Parameters
string$a_obj_type

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

244 {
245 global $ilDB;
246
247 $query = 'INSERT INTO didactic_tpl_sa (id,obj_type) '.
248 'VALUES( '.
249 $ilDB->quote($this->getId(),'integer').', '.
250 $ilDB->quote($a_obj_type,'text').
251 ')';
252 $ilDB->manipulate($query);
253 }

References $ilDB, $query, and getId().

Referenced by saveAssignments().

+ 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 229 of file class.ilDidacticTemplateSetting.php.

230 {
231 foreach($this->getAssignments() as $ass)
232 {
233 $this->saveAssignment($ass);
234 }
235 return true;
236 }
saveAssignment($a_obj_type)
Add one object assignment @global ilDB $ilDB.

References getAssignments(), and saveAssignment().

Referenced by save(), and update().

+ 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.

102 {
103 $this->description = $a_description;
104 }

Referenced by read().

+ 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.

39 {
40 $this->id = $a_id;
41 }

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

+ 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.

111 {
112 $this->info = $a_info;
113 }

Referenced by read().

+ 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.

75 {
76 $this->title = $a_title;
77 }

Referenced by __clone(), and read().

+ 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.

129 {
130 $this->type = $a_type;
131 }

Referenced by read().

+ Here is the caller graph for this function:

◆ toXml()

ilDidacticTemplateSetting::toXml ( ilXmlWriter  $writer)

Export.

Parameters
ilXmlWriter$writer
Returns
ilXmlWriter

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

341 {
342 switch($this->getType())
343 {
345 $type = 'creation';
346 break;
347 }
348
349 $writer->xmlStartTag('didacticTemplate',array('type' => $type));
350 $writer->xmlElement('title',array(),$this->getTitle());
351 $writer->xmlElement('description', array(), $this->getDescription());
352
353 // info text with p-tags
354 if(strlen($this->getInfo()))
355 {
356 $writer->xmlStartTag('info');
357
358 $info_lines = (array) explode("\n",$this->getInfo());
359 foreach($info_lines as $info)
360 {
361 $trimmed_info = trim($info);
362 if(strlen($trimmed_info))
363 {
364 $writer->xmlElement('p', array(), $trimmed_info);
365 }
366 }
367
368 $writer->xmlEndTag('info');
369 }
370
371 // Assignments
372 $writer->xmlStartTag('assignments');
373 foreach($this->getAssignments() as $assignment)
374 {
375 $writer->xmlElement('assignment', array(), $assignment);
376 }
377 $writer->xmlEndTag('assignments');
378
379
380 $writer->xmlStartTag('actions');
381 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateActionFactory.php';
383 {
384 $action->toXml($writer);
385 }
386 $writer->xmlEndTag('actions');
387 $writer->xmlEndTag('didacticTemplate');
388
389 return $writer;
390 }
xmlEndTag($tag)
Writes an endtag.
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)

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

+ Here is the call graph for this function:

◆ update()

ilDidacticTemplateSetting::update ( )

Update settings @global ilDB $ilDB.

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

275 {
276 global $ilDB;
277
278 $query = 'UPDATE didactic_tpl_settings '.
279 'SET '.
280 'enabled = '.$ilDB->quote($this->isEnabled(),'integer').', '.
281 'title = '.$ilDB->quote($this->getTitle(),'text').', '.
282 'description = '.$ilDB->quote($this->getDescription(),'text').', '.
283 'info = '.$ilDB->quote($this->getInfo(),'text').', '.
284 'type = '.$ilDB->quote($this->getType(),'integer').' '.
285 'WHERE id = '.$ilDB->quote($this->getId(),'integer');
286 $ilDB->manipulate($query);
287 $this->deleteAssignments();
288 $this->saveAssignments();
289
290 return true;
291 }
deleteAssignments()
Delete assignments @global ilDB $ilDB.

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

+ 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: