ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilDidacticTemplateCopier.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
11{
12 private $tpl_id = 0;
13 private $new_tpl_id = 0;
14
19 public function __construct($a_tpl_id)
20 {
21 $this->tpl_id = $a_tpl_id;
22 }
23
28 public static function appendCopyInfo($a_orig_title)
29 {
30 global $ilDB;
31
32 $query = 'SELECT title FROM didactic_tpl_settings ' .
33 'WHERE title = ' . $ilDB->quote($a_orig_title, 'text');
34 $res = $ilDB->query($query);
35 $num = 0;
36 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
37 ++$num;
38 }
39 if (!$num) {
40 return $a_orig_title;
41 }
42 if ($num == 1) {
43 return $a_orig_title . ' ' . $GLOBALS['lng']->txt('copy_of_suffix');
44 }
45 return $a_orig_title . ' ' . sprintf($GLOBALS['lng']->txt('copy_n_of_suffix'), $num);
46 }
47
48
53 public function getTemplateId()
54 {
55 return $this->tpl_id;
56 }
57
62 public function getNewTemplateId()
63 {
64 return $this->new_tpl_id;
65 }
66
72 public function start()
73 {
75 $copy = clone $orig;
76 $copy->save();
77 $this->new_tpl_id = $copy->getId();
78
79 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateActionFactory.php';
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 }
91}
sprintf('%.4f', $callTime)
An exception for terminatinating execution or to throw for unit testing.
static getActionsByTemplateId($a_tpl_id)
Get actions of one template.
Copy a didactic template and all subitems.
$action
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
$query
foreach($_POST as $key=> $value) $res
global $ilDB