ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilDidacticTemplateCopier Class Reference

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

+ Collaboration diagram for ilDidacticTemplateCopier:

Public Member Functions

 __construct ($a_tpl_id)
 Constructor. More...
 
 getTemplateId ()
 Get template id. More...
 
 getNewTemplateId ()
 Get new template id. More...
 
 start ()
 Start copy. More...
 

Static Public Member Functions

static appendCopyInfo ($a_orig_title)
 

Private Attributes

 $tpl_id = 0
 
 $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 10 of file class.ilDidacticTemplateCopier.php.

Constructor & Destructor Documentation

◆ __construct()

ilDidacticTemplateCopier::__construct (   $a_tpl_id)

Constructor.

Parameters
int$a_tpl_id

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

20  {
21  $this->tpl_id = $a_tpl_id;
22  }

Member Function Documentation

◆ appendCopyInfo()

static ilDidacticTemplateCopier::appendCopyInfo (   $a_orig_title)
static
Parameters
type$a_orig_title

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

References $DIC, $GLOBALS, $ilDB, $query, $res, $row, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilDidacticTemplateSetting\__clone().

29  {
30  global $DIC;
31 
32  $ilDB = $DIC['ilDB'];
33 
34  $query = 'SELECT title FROM didactic_tpl_settings ' .
35  'WHERE title = ' . $ilDB->quote($a_orig_title, 'text');
36  $res = $ilDB->query($query);
37  $num = 0;
38  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
39  ++$num;
40  }
41  if (!$num) {
42  return $a_orig_title;
43  }
44  if ($num == 1) {
45  return $a_orig_title . ' ' . $GLOBALS['DIC']['lng']->txt('copy_of_suffix');
46  }
47  return $a_orig_title . ' ' . sprintf($GLOBALS['DIC']['lng']->txt('copy_n_of_suffix'), $num);
48  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
global $ilDB
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
+ Here is the caller graph for this function:

◆ getNewTemplateId()

ilDidacticTemplateCopier::getNewTemplateId ( )

Get new template id.

Returns
int

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

References $new_tpl_id.

Referenced by start().

+ Here is the caller graph for this function:

◆ getTemplateId()

ilDidacticTemplateCopier::getTemplateId ( )

Get template id.

Returns
int

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

References $tpl_id.

Referenced by start().

+ Here is the caller graph for this function:

◆ start()

ilDidacticTemplateCopier::start ( )

Start copy.

Returns
int new template id

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

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

75  {
76  $orig = new ilDidacticTemplateSetting($this->getTemplateId());
77  $copy = clone $orig;
78  $copy->save();
79  $this->new_tpl_id = $copy->getId();
80 
81  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateActionFactory.php';
83  $action->setTemplateId($this->getNewTemplateId());
84  $new = clone $action;
85  $new->save();
86  }
87 
88  $trans = $orig->getTranslationObject();
89  $copy_trans = $trans->copy($this->new_tpl_id);
90  $copy_trans->addLanguage($trans->getDefaultLanguage(), $copy->getTitle(), $copy->getDescription(), true, true);
91  $copy_trans->save();
92  }
$action
static getActionsByTemplateId($a_tpl_id)
Get actions of one template.
+ Here is the call graph for this function:

Field Documentation

◆ $new_tpl_id

ilDidacticTemplateCopier::$new_tpl_id = 0
private

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

Referenced by getNewTemplateId().

◆ $tpl_id

ilDidacticTemplateCopier::$tpl_id = 0
private

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

Referenced by getTemplateId().


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