Added .htaccess, config.php, lang.php.
[AOOS.git] / AOOSModule.php
blob9c34104af34ff74ac169930d6a0a9d40049bac04
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;
65 /**
66 * Returns the current core
67 * @return AOOSCore
69 public function core()
71 return $this->_core;