ILIAS  release_8 Revision v8.22
All Data Structures Namespaces Files Functions Variables Modules Pages
ilDidacticTemplateCopier Class Reference

Copy a didactic template and all subitems. More...

+ Collaboration diagram for ilDidacticTemplateCopier:

Public Member Functions

 __construct (int $a_tpl_id)
 
 getTemplateId ()
 
 getNewTemplateId ()
 
 start ()
 Start copy process. More...
 

Static Public Member Functions

static appendCopyInfo (string $a_orig_title)
 

Private Attributes

int $tpl_id = 0
 
int $new_tpl_id = 0
 

Detailed Description

Copy a didactic template and all subitems.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

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

Constructor & Destructor Documentation

◆ __construct()

ilDidacticTemplateCopier::__construct ( int  $a_tpl_id)

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

17  {
18  $this->tpl_id = $a_tpl_id;
19  }

Member Function Documentation

◆ appendCopyInfo()

static ilDidacticTemplateCopier::appendCopyInfo ( string  $a_orig_title)
static

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

References $DIC, $lng, $query, $res, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilDidacticTemplateSetting\__clone().

21  : string
22  {
23  global $DIC;
24 
25  $db = $DIC->database();
26  $lng = $DIC->language();
27 
28  $query = 'SELECT title FROM didactic_tpl_settings ' .
29  'WHERE title = ' . $db->quote($a_orig_title, 'text');
30  $res = $db->query($query);
31  $num = 0;
32  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
33  ++$num;
34  }
35  if (!$num) {
36  return $a_orig_title;
37  }
38  if ($num === 1) {
39  return $a_orig_title . ' ' . $lng->txt('copy_of_suffix');
40  }
41  return $a_orig_title . ' ' . sprintf($lng->txt('copy_n_of_suffix'), $num);
42  }
$res
Definition: ltiservices.php:69
$lng
global $DIC
Definition: feed.php:28
$query
+ Here is the caller graph for this function:

◆ getNewTemplateId()

ilDidacticTemplateCopier::getNewTemplateId ( )

Definition at line 49 of file class.ilDidacticTemplateCopier.php.

References $new_tpl_id.

Referenced by start().

49  : int
50  {
51  return $this->new_tpl_id;
52  }
+ Here is the caller graph for this function:

◆ getTemplateId()

ilDidacticTemplateCopier::getTemplateId ( )

Definition at line 44 of file class.ilDidacticTemplateCopier.php.

References $tpl_id.

Referenced by start().

44  : int
45  {
46  return $this->tpl_id;
47  }
+ Here is the caller graph for this function:

◆ start()

ilDidacticTemplateCopier::start ( )

Start copy process.

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

References ilDidacticTemplateActionFactory\getActionsByTemplateId(), getNewTemplateId(), and getTemplateId().

Referenced by ilDidacticTemplateSettingsGUI\copyTemplate().

57  : void
58  {
59  $orig = new ilDidacticTemplateSetting($this->getTemplateId());
60  $copy = clone $orig;
61  $copy->save();
62  $this->new_tpl_id = $copy->getId();
63 
64  // copy icon
65  $copy->getIconHandler()->copy($orig);
67  $action->setTemplateId($this->getNewTemplateId());
68  $new = clone $action;
69  $new->save();
70  }
71 
72  $trans = $orig->getTranslationObject();
73  $copy_trans = $trans->copy($this->new_tpl_id);
74  $copy_trans->addLanguage($trans->getDefaultLanguage(), $copy->getTitle(), $copy->getDescription(), true, true);
75  $copy_trans->save();
76  }
static getActionsByTemplateId(int $a_tpl_id)
Get actions of one template.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $new_tpl_id

int ilDidacticTemplateCopier::$new_tpl_id = 0
private

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

Referenced by getNewTemplateId().

◆ $tpl_id

int ilDidacticTemplateCopier::$tpl_id = 0
private

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

Referenced by getTemplateId().


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