ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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.

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:69
global $lng
Definition: privfeed.php:31
global $DIC
Definition: shib_login.php:26

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

Referenced by ilDidacticTemplateSetting\__clone().

+ Here is the caller graph for this function:

◆ getNewTemplateId()

ilDidacticTemplateCopier::getNewTemplateId ( )

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

63 : int
64 {
65 return $this->new_tpl_id;
66 }

References $new_tpl_id.

Referenced by start().

+ Here is the caller graph for this function:

◆ getTemplateId()

ilDidacticTemplateCopier::getTemplateId ( )

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

58 : int
59 {
60 return $this->tpl_id;
61 }

References $tpl_id.

Referenced by start().

+ Here is the caller graph for this function:

◆ start()

ilDidacticTemplateCopier::start ( )

Start copy process.

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

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.

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

+ Here is the call 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: