예제 #1
0
 /**
  * 	event_indexlist
  * 
  * @param \dirp\addon\event $index
  */
 public function event_indexlist(\dirp\addon\event $index)
 {
     if (isset($index->files['config.php'])) {
         $config = (require $index->files['config.php']->path . DS . $index->files['config.php']->name);
         if (is_array($config)) {
             $config = new \dirp\helper\params($config);
             // fire off an event with this data, and give
             // addons a chance to override other behavior:
             event::fire('dirconfig', array('config' => $config, 'indexlist' => $index));
             // passworded directory:
             if ($config->password) {
                 // TO-DO: finish this
                 $session = \dirp\session::factory('dirtools');
                 if (!$session->get('pwd-' . $index->relative)) {
                     $index->body = $this->view('password')->render(array('relative' => $index->relative, 'path' => $index->path));
                 }
             }
         }
     }
 }
예제 #2
0
 /**
  * load_addons
  * attempts to load addons, by name.
  *
  * @param array $names;
  */
 public static function load_addons(array $names)
 {
     foreach ($names as $addon) {
         $addon_instance = static::_addon_loader($addon);
         // addons must always implement an 'about' method,
         // and return an array of info.
         if (method_exists($addon_instance, 'about')) {
             if (!($about = call_user_func(array($addon_instance, 'about')))) {
                 continue;
             }
             static::$_addons[$addon] = array('instance' => $addon_instance, 'about' => $about);
             // prepares event listeners for this event:
             if (isset($about['listen'])) {
                 event::register_listener($addon_instance, $about['listen']);
             }
             // register routes for this addon with the router:
             if (isset($about['routes'])) {
                 router::register_handler($addon_instance, $about['routes']);
             }
         }
     }
 }
예제 #3
0
파일: index.php 프로젝트: TheShockTop/dirp
 /**
  * index
  *
  * @param \dirp\http\request $req
  * @param \dirp\http\response $res
  */
 public function index(\dirp\http\request $req, \dirp\http\response $res)
 {
     $path = file::safe_path($req->get('dir', '/'));
     $files = file::from_directory($path);
     $relative = file::to_relative_path($path);
     // most likely tried to list a file. a file is
     // not a directory, silly.
     if ($files === false) {
         $res->redirect($req->get_base_uri());
     }
     $ev = event::fire('indexlist', array('files' => $files, 'body' => null, 'relative' => $relative, 'path' => $path));
     // prepare the breadcrumb:
     $root = $req->get_base_uri() . '?dir=';
     $parts = explode('/', $relative);
     $crumbs = array();
     foreach ($parts as $i => $crumb) {
         $crumbs[$crumb] = $root . '/' . rawurlencode(implode('/', array_slice($parts, 0, $i + 1)));
     }
     $this->master()->title = 'viewing: /' . $relative;
     $this->master()->css[] = \dirp\app::asset('css/index/index.css');
     $this->master()->body = $this->view('list')->render(array('files' => $ev->files, 'relative' => $relative, 'crumbs' => $crumbs, 'root' => $req->get_base_uri() . '/', 'filesroot' => \dirp\app::cfg()->files_uri, 'body_override' => $ev->body, 'files_count' => 0));
 }
예제 #4
0
				<?php 
echo $thing;
?>
			<? endforeach ?>
		<? endif ?>

		<title>dirp : <?php 
echo $title;
?>
</title>
	</head>
	<body>
		<div id="outer-wrapper">
		<div id="main-wrapper">
			<div id="navigation">
				<? foreach(\dirp\addon\event::fire('rendernav', array('links' => array()))->links as $link => $path): ?>
					<a class="button" href="<?php 
echo $path;
?>
"><?php 
echo $link;
?>
</a>
				<? endforeach ?>
			</div>
			<div id="header">
				<h1> <img alt="icon" src="<?php 
echo \dirp\app::asset('img/' . $icon);
?>
"> <?php 
echo $title;