The start of a User-module
[AOOS.git] / AOOSModule.php
blobf0b57d28ecda7066822b564cdb5028043704b9eb
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;
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)
61 return $string;
64 /**
65 * Returns the current core
66 * @return AOOSCore
68 public function core()
70 return $this->_core;