Пример #1
0
 /**
  * Load .ini file and parse contents.
  *
  * @return void
  */
 public function load()
 {
     $ini = APP_DIR . 'config/' . ENVIRONMENT . '.ini';
     if (!file_exists($ini)) {
         Clockwork::throwError('Could not load config (' . $ini . ')');
     }
     $this->data = parse_ini_file($ini, true);
     $this->setValues();
 }
Пример #2
0
 /**
  * Constructor
  *
  */
 public function __construct()
 {
     if (!Clockwork::getInstance()->isModuleLoaded('Cache')) {
         Clockwork::throwError('Login module depends on Cache module, which is not loaded', Clockwork::ERROR_FATAL, 1);
     }
     if (!Clockwork::getInstance()->isModuleLoaded('Hash')) {
         Clockwork::throwError('Login module depends on Hash module, which is not loaded', Clockwork::ERROR_FATAL, 1);
     }
 }
Пример #3
0
 /**
  * Find objects by column
  *
  * @param string $method
  * @param array  $args
  *
  * @throws Clockwork Warning when requirements are not met
  *
  * @return array
  */
 public function __call($method, $args)
 {
     if (preg_match('/^(by)/', $method)) {
         $this->by(array(lcfirst(end(preg_split('/^(by)/', $method))) . ' = ' . $args[0][0]));
     } else {
         $trace = debug_backtrace();
         Clockwork::throwError('Call to undefined method ' . ucfirst($this->caller) . '::' . $method . '() in <b>' . $trace[0]['file'] . '</b> on line <b>' . $trace[0]['line'] . '</b><br />', Clockwork::ERROR_WARNING, 1);
     }
 }
Пример #4
0
 /**
  * Load
  *
  * @param string $type
  *
  * @return boolean
  */
 private function load($type)
 {
     $data = Config::getData($type);
     foreach ($data as $values) {
         foreach ($values as $key => $value) {
             if ($value == 1) {
                 if ($type == 'plugin') {
                     $key = $key . '/' . $key;
                 }
                 $file = constant(strtoupper($type) . '_DIR') . $key . '.php';
                 if (!file_exists($file)) {
                     $file = APP_DIR . $type . '/' . $key . '.php';
                     if (strpos($key, '/') !== false && !file_exists($file)) {
                         $file = PLUGIN_DIR . str_replace('/', '/' . $type . '/', $key) . '.php';
                     }
                 }
                 if (file_exists($file)) {
                     include_once $file;
                     if ($type == 'module') {
                         $this->loadedModules[] = $key;
                     }
                     if ($type == 'library') {
                         $this->loadedLibraries[] = $key;
                     }
                 } else {
                     Clockwork::throwError('Could not load ' . $type . ' (' . $key . ')');
                 }
             }
         }
     }
 }
Пример #5
0
 /**
  * Setup Twig template engine
  *
  * @return void
  */
 public function setupTwig()
 {
     Twig_Autoloader::register(true);
     if (!is_dir($this->basedir . 'template/')) {
         Clockwork::throwError('Template directory (' . $this->basedir . 'template/) does not exists');
     }
     $paths = [$this->basedir . 'template/', APP_DIR . 'template/'];
     $plugins = Clockwork::getInstance()->loadedPlugins;
     foreach ($plugins as $plugin) {
         if (is_dir($plugin->dir() . 'template/')) {
             $paths[] = $plugin->dir() . 'template/';
         }
     }
     $loader = new Twig_Loader_Filesystem($paths);
     $this->twig = new Twig_Environment($loader, array('cache' => Config::getSetting('twig_cache') ? appdir('template/cache/') : false));
     $functions = get_defined_functions();
     foreach ($functions['user'] as $function) {
         if (strpos(strtolower($function), 'twig') === false) {
             $this->twig->addFunction(new Twig_SimpleFunction($function, $function));
         }
     }
     $this->twig->addFunction(new Twig_SimpleFunction('PluginLoader', [Clockwork::getInstance(), 'pluginLoader']));
 }