Esempio n. 1
0
 static function ls($path)
 {
     $ipath = implode("/", $path);
     $r = new ResultSet();
     $dImages = new Dir(self::ROOT);
     $dir = $dImages->getDir($ipath);
     $dirs = $dir->ls(null, DIR::LS_DIR);
     $r->f("#dirs")->count(count($dirs))->f("#parent > whyperlink")->href(array_merge(array_slice($path, 0, -1), array(null)));
     foreach ($dirs as $k => $d) {
         $l = substr($d, strlen($dImages));
         $r->f("#cd > whyperlink", $k)->href(explode('/', $l))->f("#ddel", $k)->additional_id($d->getName())->f("#cd wtext", $k)->text($d->getName());
     }
     $fc = 0;
     foreach ($dir->ls() as $k => $f) {
         $df = new MimeDecorator(new StatDecorator($f));
         //if(strpos($df->getMime(),"image") === false) continue;
         try {
             $df = new ImageDecorator($df);
         } catch (DecoratorException $e) {
             continue;
         }
         $stat = $df->stat();
         @$r->f("#fname", $k)->text($df->getName())->f("#fdel", $k)->additional_id($df->getName())->f("#stat", $k)->text($df->getWidth() . "×" . $df->getHeight() . " " . date("Y/m/d H:i", $stat['mtime']) . " " . sizeToString($stat['size']))->f("#preview", $k)->file($df)->f("#choose > whyperlink", $k)->href($df->getURL());
         $fc++;
     }
     $r->f("#files")->count($fc);
     return $r;
 }
Esempio n. 2
0
    /**
     * Method description
     *
     * More detailed method description
     * @param    void
     * @return   void
     */
    function preRender()
    {
        $this->checkAndSetData();
        if (!$this->file instanceof iFile && isset($this->src) && isset($this->subst_src)) {
            $this->setSrc(sprintf($this->getSubstSrc(), $this->getSrc()));
        }
        if (empty($this->alt)) {
            $this->setAlt(basename($this->getSrc()));
        }
        if (empty($this->src)) {
            $this->setVisible(0);
            parent::preRender();
            return;
        }
        if (($this->getMaxWidth() || $this->getMaxHeight()) && !is_null($this->file)) {
            $iDeco = new ImageDecorator($this->file);
            $a = recalcSize($iDeco->getWidth(), $iDeco->getHeight(), $this->getMaxWidth(), $this->getMaxHeight());
            $this->setWidth($a['0']);
            $this->setHeight($a['1']);
        }
        if ($this->getWithPreview()) {
            $js = <<<EOD
\$(document).ready(function(){
\t\$('#{$this->getId()}').css('cursor','pointer').click(function(){
\t\tvar iot = \$("#{$this->getId()}").offset().top;
\t\t\$('<div id="{$this->getId()}_preview" class="image_preview"><img src="{$this->getSrc()}" /></div>').appendTo('body');
\t\tvar i_w = \$('#{$this->getId()}_preview > img').width();
\t\tvar i_h = \$('#{$this->getId()}_preview > img').height();
\t\tvar p = p1 = p2= 1;
\t\tif(i_w > 800) p1 = 800 / i_w;
\t\tif(i_h > 600) p2 = 600 / i_h;
\t\tp = Math.min(p1,p2);
\t\ti_w = i_w*p;i_h = i_h*p;
\t\tvar o_l = \$("#{$this->getId()}").offset().left;
\t\tif(o_l < 20) o_l = 20;
\t\tif(o_l + i_w > \$(window).width())
\t\t\to_l = \$(window).width()-i_w-40;
\t\t\$('#{$this->getId()}_preview').width(i_w).height(i_h).css('left',o_l).css('top',iot);
\t\t\$('#{$this->getId()}_preview > img').width(i_w).height(i_h).click(function() {
\t\t\t\$("#{$this->getId()}_preview").remove();
\t\t});
\t});
});
EOD;
            $this->javascript->addBeforeWidget($js);
        }
        parent::preRender();
    }