Esempio n. 1
0
 /**
  * Constructs a new file browser table
  * @param string $action URL where the table form should point to
  * @param zibo\filebrowser\model\Filebrowser $fileBrowser
  * @param zibo\library\filesystem\File $path The path to display in the table
  * @param string $directoryAction URL to the action behind a directory
  * @param string $fileAction URL to the action behind a file
  */
 public function __construct($action, Filebrowser $fileBrowser, File $path = null, $directoryAction = null, $fileAction = null)
 {
     $this->fileBrowser = $fileBrowser;
     $paths = $fileBrowser->readDirectory($path);
     $directories = $fileBrowser->applyFilters($paths, array(new DirectoryFilter()));
     $files = $fileBrowser->applyFilters($paths, array(new DirectoryFilter(false)));
     unset($paths);
     parent::__construct($files, $directories, $action, self::NAME);
     $fileDecorator = new FileDecorator($fileBrowser);
     $fileDecorator->setDirectoryAction($directoryAction . ($path ? '/' . $path : ''));
     $fileDecorator->setFileAction($fileAction);
     $fileDecorator = new ZebraDecorator($fileDecorator);
     $this->addDecorator($fileDecorator);
     $translator = I18n::getInstance()->getTranslator();
     $breadcrumbs = $this->getBreadcrumbs();
     $breadcrumbs->setLabel($translator->translate(self::TRANSLATION_NAVIGATION));
     $breadcrumbs->addBreadcrumb($directoryAction, $translator->translate(self::TRANSLATION_NAVIGATION_HOME));
     $this->addBreadcrumbs($breadcrumbs, $directoryAction, $path);
 }
Esempio n. 2
0
 public static function urlencode_parts($path)
 {
     $ret = "";
     $parts = explode("/", $path);
     foreach ($parts as $part) {
         if ($ret != "") {
             $ret .= "/";
         }
         $ret .= "" . Filebrowser::double_encode_specialcharacters(urlencode($part));
     }
     return $ret;
 }
Esempio n. 3
0
 public function __construct()
 {
     parent::__construct();
     $this->session = Session::instance();
     require Kohana::find_file('vendor', 'classTextile');
     require Kohana::find_file('vendor', 'Markdown');
     $this->auth = Auth::instance();
     $this->access = Access::instance();
     $this->filebrowser = Filebrowser::instance();
     $this->filekind = FileKind::instance();
     Subfolio::set_filebrowser($this->filebrowser);
     Subfolio::set_auth($this->auth);
     Subfolio::set_template($this->template);
     Subfolio::set_filekind($this->filekind);
     $this->template->site_title = Kohana::config('filebrowser.site_name');
     $this->template->page_title = "";
 }
Esempio n. 4
0
 public function get_thumbnail_url()
 {
     $root = SubfolioTheme::get_site_root();
     if ($this->has_custom_thumbnail()) {
         return $root . "directory/" . format::urlencode_parts($this->parent) . "/-thumbnails-custom/" . Filebrowser::double_encode_specialcharacters($this->get_custom_thumbnail_file_name());
     } else {
         $thumbnail = "-thumbnails/" . $this->name;
         $url = $root . "directory/" . format::urlencode_parts($this->parent) . "/-thumbnails/" . Filebrowser::double_encode_specialcharacters(urlencode($this->name));
         if (!file_exists("-thumbnails")) {
             mkdir("-thumbnails", 0755, true);
         }
         $build_thumbnail = false;
         if (!$this->has_thumbnail()) {
             $build_thumbnail = true;
         }
         if ($build_thumbnail) {
             $max_size = Kohana::config('filebrowser.thumbnail_max_filesize');
             $stats = stat($this->name);
             if ($stats['size'] > $max_size * 1024 * 1024) {
                 return '';
             } else {
                 $thumbnail_width = SubfolioTheme::get_option('thumbnail_width', Kohana::config('filebrowser.thumbnail_width'));
                 $thumbnail_height = SubfolioTheme::get_option('thumbnail_height', Kohana::config('filebrowser.thumbnail_height'));
                 $info = @getimagesize($this->name);
                 if (isset($info[1])) {
                     if ($info[1] <= $thumbnail_height) {
                     } else {
                         $this->image = new Image($this->name);
                         if ($this->image) {
                             $this->image->resize($thumbnail_width, $thumbnail_height, Image::HEIGHT);
                             $this->image->save($thumbnail);
                         }
                     }
                 }
             }
         }
         if (file_exists($thumbnail)) {
             $thumbnail_stats = stat($thumbnail);
             return $url . "?rnd=" . $thumbnail_stats['ctime'];
         } else {
             return '';
         }
     }
 }
Esempio n. 5
0
<?php

include '../../../../includes/erudio.ini.php';
include_once ADMIN_DIR . 'lib/media/Media.php';
include_once ADMIN_DIR . 'lib/Upload/class.upload.php';
$fb = new Filebrowser();
$m = $fb->setInterface();
class Filebrowser
{
    private $media;
    public function setInterface()
    {
        $tpl = new Creatur_Smarty();
        $tpl->assign('media', $this->_getMedia());
        $tpl->display('mediaView.tpl');
    }
    private function _getMedia()
    {
        return Media::loadImages('', '', IMAGES);
    }
    public function setImg()
    {
        $msg = $this->imgUpload();
        $url = "index2.php?com=eventos&do=view&eid=" . $this->_event_id;
        Creatur::cosRedirect($url, $msg);
    }
    /**
     * @desc sube una imagen jpg al servidor
     * @param void
     * @return void
     */
Esempio n. 6
0
 public function get_link($name, $directory = false)
 {
     $root = SubfolioTheme::get_site_root();
     if ($directory) {
         $root .= "directory/";
     }
     if ($this->folder == "") {
         $link = $root . urlencode($name);
         $link = str_replace('%2F', '/', $link);
         $link = Filebrowser::double_encode_specialcharacters($link);
     } else {
         $link = $root . urlencode($this->folder) . "/" . urlencode($name);
         // unencode '/'
         $link = str_replace('%2F', '/', $link);
         $link = Filebrowser::double_encode_specialcharacters($link);
     }
     return $link;
 }
Esempio n. 7
0
<?php

define('APP_PATH', dirname(__FILE__));
define('DS', DIRECTORY_SEPARATOR);
include 'includes' . DS . 'creatur.ini.php';
require APP_PATH . DS . 'lib' . DS . 'DB.php';
include_once APP_PATH . DS . 'lib' . DS . 'media' . DS . 'Media.php';
include_once APP_PATH . DS . 'lib' . DS . 'Upload' . DS . 'class.upload.php';
$fb = new Filebrowser();
$m = $fb->getTask();
class Filebrowser
{
    public function getTask()
    {
        $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
        switch ($action) {
            case 'upload':
                $this->setImg();
                break;
            case 'drop':
                $img = isset($_REQUEST['img']) ? $_REQUEST['img'] : null;
                $this->unsetImg($img);
                break;
            default:
                $this->setInterface();
        }
    }
    public function setInterface()
    {
        $tpl = new Creatur_Smarty();
        $tpl->assign('path_img', IMG_WEB_PATH);
Esempio n. 8
0
    function html_link($action, $dir = '', $file = '', $caption)
    {
        PrintF('<a href="%1$s" title="%2$s">%2$s</a>', HTMLSpecialChars($this->build_link($action, $dir, $file)), $caption);
    }
    function delete_folder($directory)
    {
        foreach ((array) $this->get_subfolder($directory) as $folder) {
            $this->delete_folder($folder);
        }
        foreach ((array) $this->get_files($directory) as $file) {
            Unlink($file);
        }
        RmDir($directory);
    }
}
$filebrowser = new Filebrowser();
if ($filebrowser->action == 'browse') {
    ?>
<!DOCTYPE HTML><html><head><title>Browse: <?php 
    echo BaseName($filebrowser->directory);
    ?>
/</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body><h1>Filebrowser</h1><h2><?php 
    echo HTMLSpecialChars($filebrowser->directory);
    ?>
</h2><p><big>&uarr; <?php 
    $filebrowser->html_link('browse', DirName($filebrowser->directory), '', 'Go one directory upwards.');
    ?>
</big></p><?php 
    if ($arr_folder = $filebrowser->get_subfolder($filebrowser->directory)) {
        ?>
<h2>Sub folder</h2><ul><?php 
Esempio n. 9
0
 public function next_link_or_span($name, $directory_name, $link_id, $class)
 {
     $ff = Subfolio::$filebrowser->get_path();
     if ($ff != '') {
         if (Subfolio::$filebrowser->is_file()) {
             $file = Subfolio::$filebrowser->get_file();
             $items = Subfolio::$filebrowser->get_parent_file_folder_list(null, false);
             $items = Subfolio::$filebrowser->sort($items);
             $items = Subfolio::$filebrowser->prev_next_sort($items);
             $next = Subfolio::$filebrowser->get_next($items, $file->name);
             if ($next != "") {
                 $link = Filebrowser::double_encode_specialcharacters(urlencode($next->name));
                 $link = str_replace('%2F', '/', $link);
                 return "<a id='{$link_id}' href='{$link}'>{$name}</a>";
             } else {
                 return "<span id='{$link_id}' class='" . $class . "'>" . $name . "</span>";
             }
         } else {
             $folder = basename(Subfolio::$filebrowser->get_folder());
             $items = Subfolio::$filebrowser->get_parent_file_folder_list(null, true);
             $items = Subfolio::$filebrowser->sort($items);
             $items = Subfolio::$filebrowser->prev_next_sort($items);
             $next = Subfolio::$filebrowser->get_next($items, $folder);
             if ($next != "") {
                 $link = Filebrowser::double_encode_specialcharacters(urlencode($next->name));
                 $link = str_replace('%2F', '/', $link);
                 return "<a id='{$link_id}' href='{$link}'>{$directory_name}</a>";
             } else {
                 return "<span id='{$link_id}' class='" . $class . "'>" . $directory_name . "</span>";
             }
         }
     }
 }