ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 $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 }
49
50
55 public function getTemplateId()
56 {
57 return $this->tpl_id;
58 }
59
64 public function getNewTemplateId()
65 {
66 return $this->new_tpl_id;
67 }
68
74 public function start()
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 }
93}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
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.
$query
foreach($_POST as $key=> $value) $res
global $ilDB
$DIC
Definition: xapitoken.php:46