Exemplo n.º 1
0
 function h2o_instance($template, $options = array())
 {
     global $settings;
     $template_paths = array(dirname(__FILE__) . '/templates/', PROJECT_PATH . '/application/templates/', PROJECT_PATH . '/application/', PROJECT_PATH . '/public/');
     if (isset($settings['APPLICATIONS'])) {
         foreach ($settings['APPLICATIONS'] as $key) {
             array_push($template_paths, PROJECT_PATH . '/application/' . $key . '/templates/');
         }
     }
     try {
         $h2o = new h2o($template, array('searchpath' => $template_paths, 'cache' => false));
         return $h2o;
     } catch (Exception $e) {
         ExceptionsManager::TemplateNotFoundException("Could not find the correct Template: " . $template, $template_paths);
     }
 }
Exemplo n.º 2
0
 function resolveURL()
 {
     if (isset($settings['urls']['APPEND_SLASH']) && $settings['urls']['APPEND_SLASH'] == true && !self::endswith($this->url, "/")) {
         $url = $this->url . "/";
         Application::redirect_301($url);
     }
     $count = 0;
     $config_size = count($this->urls_conf);
     foreach ($this->urls_conf as $pattern => $callback) {
         $count += 1;
         $this->attempted_patterns[] = $pattern;
         if (preg_match($this->patternize($pattern), substr($this->url, 1), $matches) != false) {
             return self::dispatch($callback, $matches);
         }
         // match
         if ($count == $config_size) {
             if (DEBUG) {
                 ExceptionsManager::UrlNotFoundException("Could not find a Valid Url Pattern", $this->attempted_patterns);
             } else {
                 Application::raise404();
             }
         }
     }
 }
Exemplo n.º 3
0
 function loadModel($model, $args = "")
 {
     if ($this->has_model($model)) {
         require APPLICATION_PATH . $this->request->app . '/models/' . $model . '.php';
     } else {
         ExceptionsManager::ModelNotFoundException("Could not find the correct the model <b>" . $model . "</b> on " . APPLICATION_PATH . $this->request->app . '/models/' . $model . '.php');
     }
     if ($args == "") {
         return $this->{$model} = new $model();
     } else {
         return $this->{$model} = new $model($args);
     }
 }