ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilDidacticTemplateUtils.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4
12{
13 public static function switchTemplate($a_ref_id, $a_new_tpl_id)
14 {
15 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php';
17 $a_ref_id
18 );
19
20 ilLoggerFactory::getLogger('dtpl')->debug('Current template id: '. $current_tpl_id);
21
22 // Revert current template
23 if($current_tpl_id)
24 {
25 ilLoggerFactory::getLogger('dtpl')->debug('Reverting template with id: ' . $current_tpl_id);
26
27 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateActionFactory.php';
28 foreach(ilDidacticTemplateActionFactory::getActionsByTemplateId($current_tpl_id) as $action)
29 {
30 $action->setRefId($a_ref_id);
31 $action->revert();
32 }
33 }
34
35 include_once './Services/Object/classes/class.ilObjectFactory.php';
36 $factory = new ilObjectFactory();
37 $obj = $factory->getInstanceByRefId($a_ref_id, false);
38 if($obj instanceof ilObject)
39 {
40 $obj->applyDidacticTemplate($a_new_tpl_id);
41 }
42 return true;
43 }
44}
45?>
An exception for terminatinating execution or to throw for unit testing.
static getActionsByTemplateId($a_tpl_id)
Get actions of one template.
static lookupTemplateId($a_ref_id)
Lookup template id @global ilDB $ilDB.
Utilities for didactic templates.
static switchTemplate($a_ref_id, $a_new_tpl_id)
static getLogger($a_component_id)
Get component logger.
Class ilObjectFactory.
Class ilObject Basic functions for all objects.