Пример #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
 /**
  * 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));
 }
Пример #3
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;