Exemple #1
0
 public function index()
 {
     $path = isset($_GET['path']) ? $_GET['path'] : '';
     $this->filebrowser->set_path($path);
     if ($this->filebrowser->exists()) {
         $this->access->load_access($this->filebrowser->get_folder());
         if ($this->access->is_restricted()) {
             // if user is not logged in redirect to login screen
             if (!$this->auth->logged_in()) {
                 $this->session->set('return_path', $path);
                 $this->session->keep_flash();
                 url::redirect("/login");
                 exit;
             }
         }
         if ($this->access->check_access($this->auth->get_user())) {
             $is_folder = false;
             $single = $this->filebrowser->is_file();
             $folder = $this->filebrowser->get_folder();
             if (!$single) {
                 $fkind = $this->filekind->get_kind_by_file($folder);
                 $kind = isset($fkind['kind']) ? $fkind['kind'] : '';
                 if ($kind == "site") {
                     $single = true;
                     $is_folder = true;
                 } else {
                     if ($kind == "slide") {
                         $slide_files = $this->filebrowser->get_file_list();
                         $slide_files = $this->filebrowser->sort($slide_files);
                         if (sizeof($slide_files) > 0) {
                             $url = Subfolio::$filebrowser->get_link($slide_files[0]->name);
                             url::redirect($url);
                             exit;
                         }
                     }
                 }
             }
             $replace_dash_space = view::get_option('replace_dash_space', true);
             $replace_underscore_space = view::get_option('replace_underscore_space', true);
             $display_file_extensions = view::get_option('display_file_extensions', true);
             if ($single) {
                 $file = $this->filebrowser->get_file();
                 if ($is_folder) {
                 } else {
                     $fkind = $this->filekind->get_kind_by_file($file->name);
                     $kind = isset($fkind['kind']) ? $fkind['kind'] : '';
                 }
                 if (View::view_exists('pages/filekinds/' . $kind)) {
                     $content = View::factory('pages/filekinds/' . $kind);
                     $content->file = $file;
                     if (isset($folder)) {
                         $content->folder = $folder;
                     }
                 } else {
                     $content = View::factory('pages/filekinds/default');
                     $content->file = $file;
                 }
                 if ($folder != '.') {
                     $title_path = $folder . "/" . $file->name;
                 } else {
                     $title_path = $file->name;
                 }
                 $this->template->page_title = FileFolder::make_title_display($title_path, $replace_dash_space, $replace_underscore_space, $display_file_extensions);
                 $this->template->content = $content;
             } else {
                 $folder = $this->filebrowser->get_folder();
                 $content = View::factory('pages/listing');
                 $this->template->content = $content;
                 if ($folder != "") {
                     $this->template->page_title = $folder;
                     $this->template->page_title = FileFolder::make_title_display($folder, $replace_dash_space, $replace_underscore_space, $display_file_extensions);
                 }
             }
         } else {
             $content = View::factory('pages/denied');
             $this->template->content = $content;
         }
     } else {
         $content = View::factory('pages/notfound');
         $this->template->content = $content;
     }
 }
Exemple #2
0
 public function related()
 {
     $related = array();
     $listing_mode = Kohana::config('filebrowser.listing_mode');
     $listing_mode = view::get_option('listing_mode', $listing_mode);
     $list = Subfolio::$filebrowser->get_file_list("cut", null, true);
     $restricted = false;
     foreach ($list as $item) {
         $link = Subfolio::$filebrowser->get_item_property($item->name, 'url');
         if ($link == "") {
             $link = Subfolio::$filebrowser->get_item_property($item->name, 'directory');
             $parent = Subfolio::$filebrowser->get_folder();
             $folder_name = $link;
             if (substr($folder_name, 0, 1) == "/") {
                 $pos = strrpos($link, "/");
                 $parent = substr($link, 1, strlen($link) - ($pos - 1));
                 $folder_name = substr($link, $pos + 1, strlen($link) - ($pos - 1));
             }
             $folder = new FileFolder($folder_name, $parent, 'folder', '', NULL);
             if ($folder->contains_access_file()) {
                 $restricted = true;
                 if ($folder->have_access($this->auth->get_user())) {
                     $have_access = true;
                 } else {
                     $have_access = false;
                 }
             } else {
                 if ($folder->have_access($this->auth->get_user())) {
                     $restricted = false;
                     $have_access = true;
                 } else {
                     $have_access = false;
                     $restricted = true;
                 }
             }
         }
         $name = Subfolio::$filebrowser->get_item_property($item->name, 'name');
         $file_kind = Subfolio::$filekind->get_kind_by_file($item->name);
         $icon_file = "";
         $icon_file = Subfolio::$filekind->get_icon_by_file($file_kind);
         $icon_set = view::get_option('icon_set_list', "list");
         $icon_set_grid = view::get_option('icon_set_grid', "grid");
         $icon = view::get_view_url() . "/images/icons/" . $icon_set . "/" . $icon_file . ".png";
         $icon_grid = view::get_view_url() . "/images/icons/" . $icon_set_grid . "/" . $icon_file . ".png";
         $rel = array();
         $rel['link'] = $link;
         $rel['filename'] = $name;
         $rel['icon'] = $icon;
         $rel['icon_grid'] = $icon_grid;
         if ($restricted) {
             $rel['restricted'] = true;
             $rel['have_access'] = $have_access;
         } else {
             $rel['restricted'] = false;
         }
         $related[] = $rel;
     }
     return $related;
 }