protected static function factory($class)
 {
     if (!self::$instance) {
         self::$instance = new $class();
     }
     return self::$instance;
 }
function partial($partial, $variables = array())
{
    $backtrace = debug_backtrace();
    $view_directory = dirname($backtrace[0]['file']) . '/';
    $controller = basename($view_directory, '/');
    $app = basename(dirname($view_directory));
    if (!($partial_path = moojon_paths::get_partial_path($app, $controller, $partial))) {
        throw new moojon_exception("Unknown partial ({$partial})");
    }
    moojon_runner::partial($partial_path, $variables);
}
 public final function render()
 {
     if (!$this->controller) {
         $this->set_controller();
     }
     $return = moojon_runner::render(moojon_paths::get_view_path(self::get_app_name($this), self::get_controller_name($this->controller), $this->controller->get_view()), $this->controller, $this->uri);
     $layout = $this->get_layout();
     if ($layout !== false) {
         $return = str_replace('YIELD', $return, moojon_runner::render(moojon_paths::get_layout_path($layout), $this->controller), $this->uri);
     }
     return $return;
 }
 protected function run(moojon_exception $exception)
 {
     switch (UI) {
         case 'CGI':
             $app = moojon_runner::app_from_uri(moojon_config::get('exception_app') . '/' . moojon_config::get('exception_controller') . '/' . moojon_config::get('exception_action'));
             if (ENVIRONMENT != 'development' && moojon_config::get('exception_mail')) {
                 $mailer = new moojon_mailer();
                 $mailer->set_from(moojon_config::get('from_mail_email'), moojon_config::get('from_mail_name'));
                 $mailer->set_to(moojon_config::get('webmaster_mail_email'), moojon_config::get('webmaster_mail_name'));
                 $mailer->set_subject(moojon_config::get('exception_mail_subject'));
                 $mailer->set_html($exception);
                 $mailer->send();
             }
             echo $app->render();
             break;
         case 'CLI':
             echo $this->exception;
             break;
     }
 }
 private static function render_view($route)
 {
     return moojon_runner::render_app($route);
 }
Exemple #6
0
<?php

require_once MOOJON_DIRECTORY . '/classes/moojon.base.class.php';
require_once MOOJON_DIRECTORY . '/classes/moojon.singleton.class.php';
require_once MOOJON_DIRECTORY . '/classes/moojon.singleton.immutable.collection.class.php';
require_once MOOJON_DIRECTORY . '/classes/moojon.singleton.mutable.collection.class.php';
require_once MOOJON_DIRECTORY . '/classes/moojon.runner.class.php';
moojon_runner::fetch();