ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilObjectPlugin.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("./Services/Object/classes/class.ilObject2.php");
5 require_once('./Services/Component/classes/class.ilPlugin.php');
6 
7 /*
8 * Object class for plugins. This one wraps around ilObject
9 *
10 * @author Alex Killing <alex.killing@gmx.de>
11 * @version $Id$
12 * @ingroup ServicesRepository
13 */
14 abstract class ilObjectPlugin extends ilObject2
15 {
16  private $object;
17 
18  protected $plugin;
19 
23  protected static $plugin_by_type = array();
24 
25 
29  public function __construct($a_ref_id = 0)
30  {
31  $this->initType();
32  parent::__construct($a_ref_id, true);
33  $this->plugin = $this->getPlugin();
34  }
35 
36 
43  public static function getRepoPluginObjectByType($type)
44  {
45  if (!self::$plugin_by_type[$type]) {
46  self::loadRepoPlugin($type);
47  }
48 
49  return self::$plugin_by_type[$type];
50  }
51 
52 
56  protected static function loadRepoPlugin($type_id)
57  {
60  "Repository",
61  "robj",
62  ilPlugin::lookupNameForId(IL_COMP_SERVICE, "Repository", "robj", $type_id)
63  );
64  if (!$plugin) {
67  "OrgUnit",
68  "orguext",
69  ilPlugin::lookupNameForId(IL_COMP_MODULE, "OrgUnit", "orguext", $type_id)
70  );
71  }
72  if (!$plugin) {
73  ilLoggerFactory::getLogger("obj")->log("Try to get repo plugin obj by type: $type_id. No such type exists for Repository and Org Unit pluginss.");
74  }
75  self::$plugin_by_type[$type_id] = $plugin;
76  }
77 
83  public static function lookupTxtById($plugin_id, $lang_var)
84  {
85  $pl = self::getRepoPluginObjectByType($plugin_id);
86  return $pl->txt($lang_var);
87  }
88 
94  protected function getPlugin()
95  {
96  if (!$this->plugin) {
97  $this->plugin =
100  "Repository",
101  "robj",
102  ilPlugin::lookupNameForId(IL_COMP_SERVICE, "Repository", "robj", $this->getType())
103  );
104  if (!is_object($this->plugin)) {
105  throw new ilPluginException("ilObjectPlugin: Could not instantiate plugin object for type " . $this->getType() . ".");
106  }
107  }
108  return $this->plugin;
109  }
110 
114  final protected function txt($a_var)
115  {
116  return $this->getPlugin()->txt($a_var);
117  }
118 
123  public function getParentTypes()
124  {
125  return $this->plugin->getParentTypes();
126  }
127 }
static getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get plugin object.
static loadRepoPlugin($type_id)
getParentTypes()
returns a list of all repository object types which can be a parent of this type. ...
static lookupTxtById($plugin_id, $lang_var)
txt($a_var)
Wrapper for txt function.
__construct($a_ref_id=0)
Constructor.
static lookupNameForId($a_ctype, $a_cname, $a_slot_id, $a_plugin_id)
Lookup name for id.
const IL_COMP_MODULE
static getRepoPluginObjectByType($type)
Return either a repoObject plugin or a orgunit extension plugin or null if the type is not a plugin...
Create styles array
The data for the language used.
getPlugin()
Get plugin object.
Class ilObject2 This is an intermediate progress of ilObject class.
static getLogger($a_component_id)
Get component logger.
const IL_COMP_SERVICE