Not loaded class files can be in lib/ too
[AOOS.git] / AOOSModule.php
blobc200bb8a9132a23b9d0de2e886cc6321148256e0
1 <?php
3 /**
4 * AOOSModule
6 * Base module for all modules
8 * @author Sebastian Skejø
9 */
12 class AOOSModule
14 private $_core = null;
15 private $_toModel = null;
17 /**
18 * Default constructor. Redefined constructors must take $core as first argument and call $this->_init($core)
19 * @param AOOSCore $core A reference to the core object
20 * @param bool $toModel If this is set to 'true' module must implement the public function: AOOSModel toModel();
22 public function __construct(&$core, $toModel = false)
24 $this->_init($core, $toModel);
27 /**
28 * Must be called when redefining constructor. Takes core object as first argument.
29 * @param AOOSCore $core A reference to the core object
31 private function _init($core, $toModel)
33 if (!$core instanceof AOOSCore || !isset($core))
35 return false;
38 if (!is_bool($toModel))
40 return false;
43 $this->_core = $core;
45 $this->core()->log(__class__." instantiated");
46 // $this->_toModel = $_toModel;
49 /**
50 * Translates a given string to language selected in settings
51 * @param string $stringID The unique ID of the string to translate
53 public function tr($stringID)
55 $string = $stringID;
56 try
58 $string = $this->core()->getTranslatedString($stringID);
60 catch (AOOSException $e)
63 return $string;
66 /**
67 * Returns the current core
68 * @return AOOSCore
70 public function core()
72 return $this->_core;