public static function preSetup() { // Using T editor driver to avoid script termination on non-existing xml files // (so that whatever the order in which the extractlng and the install_i18n scripts ar run, it's ok) T::setConfig(array_merge(T::$config, array('driver' => 'editor'))); return true; }
public static function bootstrap() { $paths[] = APP_ROOT . 'app/_shared/'; $paths[] = APP_ROOT . 'app/' . APP_NAME . '/'; $paths[] = APP_ROOT . 'app/'; set_include_path(get_include_path() . ':' . implode(':', $paths)); if (defined('E_DEPRECATED')) { ini_set('error_reporting', E_ALL & ~E_STRICT & ~E_NOTICE & ~E_DEPRECATED); } else { ini_set('error_reporting', E_ALL & ~E_STRICT & ~E_NOTICE); } switch (MODE) { case 'development': ini_set('display_errors', 1); $caching = false; break; case 'test': ini_set('display_errors', 1); $caching = false; break; case 'production': ini_set('display_errors', 0); $caching = true; break; } T::setConfig(array('path' => APP_ROOT . 'app/' . APP_NAME . '/lang/', 'encoding' => 'utf8', 'saveresult' => false, 'driver' => 'reader', 'autoexpire' => MODE == 'development')); if (!defined('DEFAULT_LANG')) { define('DEFAULT_LANG', 'en'); } M::addPath('lang', dirname(__FILE__) . '/lang/'); $lang = $_REQUEST['lang'] ? $_REQUEST['lang'] : DEFAULT_LANG; T::setLang($lang); M::addPath('templates', APP_ROOT . 'app/_shared/templates/'); M::addPath('templates', APP_ROOT . 'app/' . APP_NAME . '/templates/'); M::addPath('modules', 'modules'); M::addPath('plugins', realpath(dirname(__FILE__))); M::addPath('plugins', APP_ROOT . 'app/'); $opt =& PEAR::getStaticProperty('Module', 'global'); $opt['caching'] = $caching; $opt['cacheDir'] = APP_ROOT . 'app/' . APP_NAME . '/cache/'; $opt['cacheTime'] = 7200; $dispatchopt =& PEAR::getStaticProperty('Dispatcher', 'global'); $dispatchopt['all']['loginmodule'] = 'user'; $dispatchopt['all']['loginaction'] = 'login'; $dispatchopt['all']['modulepath'] = array('modules'); require APP_ROOT . 'app/setup.php'; $setup = new M_setup(); spl_autoload_register('M::m_autoload_db_dataobject'); Mreg::set('setup', $setup); }
break; case 'test': ini_set('error_reporting', E_ALL ^ E_NOTICE); ini_set('display_errors', 1); $caching = false; break; case 'production': ini_set('error_reporting', E_ALL ^ E_NOTICE); ini_set('display_errors', 0); $caching = true; break; } /** * Translation initialization (TODO move this out of the startup file, maybe setup) */ T::setConfig(array('path' => APP_ROOT . 'app/' . APP_NAME . '/lang/', 'encoding' => 'utf-8', 'saveresult' => false, 'cacheDir' => APP_ROOT . 'app/' . APP_NAME . '/cache/')); // TODO define a default lang, not french hardcoded $opt =& PEAR::getStaticProperty('Module', 'global'); $opt['template_dir'] = array(APP_ROOT . 'app/' . APP_NAME . '/templates/'); $opt['caching'] = $caching; $opt['cacheDir'] = APP_ROOT . 'app/' . APP_NAME . '/cache/' . $host . '/'; $opt['cacheTime'] = 7200; $dispatchopt =& PEAR::getStaticProperty('Dispatcher', 'global'); $dispatchopt['all']['loginmodule'] = 'user'; $dispatchopt['all']['loginaction'] = 'login'; $dispatchopt['all']['modulepath'] = array('modules'); /** * TODO config & setup : maybe we should rename them to pre-cache & post-cache config ? **/ include APP_ROOT . 'app/config.php'; include APP_ROOT . 'app/' . APP_NAME . '/config.php';