Lots of changes.
[AOOS.git] / AOOSModule.php
blob474481c64fb33c41f620f935004ceb12d7dbd2f0
1 <?php
3 /**
4 * AOOSModule
6 * Base module for all modules
8 * @author Sebastian Skejø
9 */
12 class AOOSModule
14 protected $_core = null;
15 protected $_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;
44 // $this->_toModel = $_toModel;
47 /**
48 * Translates a given string to language selected in settings
49 * @param string $stringID The unique ID of the string to translate
51 public function tr($stringID)
53 $string = $stringID;
54 try
56 $string = $this->_core->getTranslatedString($stringID);
58 catch (AOOSException $e)
60 print $e;
62 return $string;