示例#1
0
文件: app.php 项目: TheShockTop/dirp
 /**
  * run
  * the main() to this whole darned thing.
  *
  * @param array $configuration
  */
 public static function run(array $configuration)
 {
     define('DS', DIRECTORY_SEPARATOR);
     define('ROOT', __DIR__);
     // having short_open_tag enabled is a dirp
     // requirement.
     if (!ini_get('short_open_tag')) {
         throw new \Exception("The 'short_open_tag' setting MUST be enabled in your php.ini to use dirp, sorry!");
     }
     // setup the autoloader and the exception handler:
     set_exception_handler(array('\\dirp\\app', 'exception_handler'));
     static::_autoloader_init();
     static::$_cfg = new helper\params($configuration);
     static::$_http_request = http\request::factory($_GET, $_POST, $_SERVER);
     static::$_http_response = new http\response();
     // prepare addons:
     if ($addons = static::cfg()->addons) {
         addon\manager::load_addons((array) $addons);
     }
     // the master view is the frame/template around
     // the main content area. addons have access to
     // it directly through the \dirp\addon\base::master
     // method.
     static::$_master = view::factory('master/template', array('title' => 'dirp framework', 'body' => '', 'icon' => 'folder_heart.png', 'panels' => addon\event::fire('renderpanels', array('panels' => array()))->panels, 'css' => array(), 'js' => array(), 'head' => array()));
     addon\base::set_master_view(static::$_master);
     // dispatch the request and figure out what to do with
     // the controller's response:
     // TO-DO: HEY THE WAY CONTROLLER RETURNS ARE HANDLED IS KINDA FLAKY.
     if ($ret = router::dispatch(static::get_request(), static::get_response())) {
         if (is_string($ret)) {
             if (static::get_request()->is_ajax()) {
                 static::get_response()->header('content-type', 'text/plain');
                 static::get_response()->write($ret);
                 static::get_response()->send();
             } else {
                 static::get_master()->body = $ret;
             }
         }
     }
     static::get_response()->write(static::get_master()->render());
     addon\event::fire('shutdown', array());
     static::get_response()->send();
 }
示例#2
0
文件: file.php 项目: TheShockTop/dirp
 /**
  * _init
  * called by the \dirp\app autoloader automatically,
  * prepares icons and such.
  */
 public static function _init()
 {
     // the iconslist events allows addons to register
     // their own custom icons.
     static::$_icons = addon\event::fire('iconslist', array('exe' => 'binary.png', 'doc' => 'doc.png', 'zip' => 'archive.png', 'rar' => 'archive.png', 'tar' => 'archive.png', '7z' => 'archive.png', 'fla' => 'fla.png', 'swf' => 'fla.png', 'html' => 'html.png', 'md' => 'md.png', 'psd' => 'psd.png', 'ruby' => 'ruby.png', 'sig' => 'sig.png', 'svg' => 'vec.png', 'ai' => 'vec.png', 'eps' => 'vec.png', 'wmv' => 'vid.png', 'mpg' => 'vid.png', 'mp4' => 'vid.png', 'jpg' => 'img.png', 'png' => 'img.png', 'gif' => 'img.png', 'pdf' => 'pdf.png', 'txt' => 'txt.png', 'misc' => 'unknown.png', 'folder' => 'folder.png', 'php' => 'php.png', 'mp3' => 'music.png', 'wma' => 'music.png', 'v0' => 'music.png', 'flac' => 'music.png'))->get_params();
 }