ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator 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 25 of file class.ilDidacticTemplateCopier.php.

Constructor & Destructor Documentation

◆ __construct()

ilDidacticTemplateCopier::__construct ( int  $a_tpl_id)

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

31  {
32  $this->tpl_id = $a_tpl_id;
33  }

Member Function Documentation

◆ appendCopyInfo()

static ilDidacticTemplateCopier::appendCopyInfo ( string  $a_orig_title)
static

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

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

Referenced by ilDidacticTemplateSetting\__clone().

35  : string
36  {
37  global $DIC;
38 
39  $db = $DIC->database();
40  $lng = $DIC->language();
41 
42  $query = 'SELECT title FROM didactic_tpl_settings ' .
43  'WHERE title = ' . $db->quote($a_orig_title, 'text');
44  $res = $db->query($query);
45  $num = 0;
46  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
47  ++$num;
48  }
49  if (!$num) {
50  return $a_orig_title;
51  }
52  if ($num === 1) {
53  return $a_orig_title . ' ' . $lng->txt('copy_of_suffix');
54  }
55  return $a_orig_title . ' ' . sprintf($lng->txt('copy_n_of_suffix'), $num);
56  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:22
global $lng
Definition: privfeed.php:31
+ Here is the caller graph for this function:

◆ getNewTemplateId()

ilDidacticTemplateCopier::getNewTemplateId ( )

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

References $new_tpl_id.

Referenced by start().

63  : int
64  {
65  return $this->new_tpl_id;
66  }
+ Here is the caller graph for this function:

◆ getTemplateId()

ilDidacticTemplateCopier::getTemplateId ( )

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

References $tpl_id.

Referenced by start().

58  : int
59  {
60  return $this->tpl_id;
61  }
+ Here is the caller graph for this function:

◆ start()

ilDidacticTemplateCopier::start ( )

Start copy process.

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

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

Referenced by ilDidacticTemplateSettingsGUI\copyTemplate().

71  : void
72  {
73  $orig = new ilDidacticTemplateSetting($this->getTemplateId());
74  $copy = clone $orig;
75  $copy->save();
76  $this->new_tpl_id = $copy->getId();
77 
78  // copy icon
79  $copy->getIconHandler()->copy($orig);
81  $action->setTemplateId($this->getNewTemplateId());
82  $new = clone $action;
83  $new->save();
84  }
85 
86  $trans = $orig->getTranslationObject();
87  $copy_trans = $trans->copy($this->new_tpl_id);
88  $copy_trans->addLanguage($trans->getDefaultLanguage(), $copy->getTitle(), $copy->getDescription(), true, true);
89  $copy_trans->save();
90  }
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 28 of file class.ilDidacticTemplateCopier.php.

Referenced by getNewTemplateId().

◆ $tpl_id

int ilDidacticTemplateCopier::$tpl_id = 0
private

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

Referenced by getTemplateId().


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