示例#1
0
if (isMobile()) {
    out('<h2 class="singleCol">(mobile version)</h2>');
}
// you may or may not want to put your images under CC-BY, and indicate
// that with a graphic badge in your readme box. I use a not-listed marker-file to achive that:
if (is_file($ROOT . $_SERVER['REQUEST_URI'] . 'CC-BY.marker')) {
    out('<div class="singleCol"><a href="http://creativecommons.org/licenses/by/3.0/de/" target="_blank">');
    out('<img src="/static/cc-by-88x31.png" width="88" height="31" align="right" style="margin:10px" title="Creative Commons CC-BY 3.0">');
    out('</a></div>');
}
$title = $d->title();
out("<h1 class='singleCol'>{$title}</h1>");
$readmeText = $d->readme();
if (!empty($readmeText)) {
    // only push out readme-box, if there is a readme
    outPush('<div id="readme" class="singleCol">');
    out($readmeText);
    out('<hr class="clear"/>');
    outPop('</div>');
    out();
}
$d->render();
// alternative, less automatic outputs:
//
// out("<h2 class='singleCol'>128px list</h2>");
// $d->render('list',128);
// out("<h2 class='singleCol'>128px grid</h2>");
// $d->render('grid',128)
?>

		<?php 
示例#2
0
function outPrint($v, $label = '')
{
    outPush(empty($label) ? '' : "{$label}:");
    $r = print_r($v, true);
    // strip_tags(var_dump($v));
    $r = explode("\n", trim($r));
    foreach ($r as $line) {
        out($line);
    }
    outPop();
}
示例#3
0
 /**
  * actually renders the file set
  */
 public function render($mode = 'auto', $size = 'auto')
 {
     $c =& $this->config;
     // shorthand
     out('');
     if ($mode === 'auto') {
         // do not count readme for decision (otherwise 2 pics and one readme would be only 66% ...)
         // ignorereadmeCompensate (otherwise 2 pics and one readme would be only 66% ...)
         $total = $this->totalFiles() - (empty($this->readme_content) ? 0 : 1);
         if ($total > 0 && $this->thumbCount / $total > $c->GRID_THRESHOLD) {
             $mode = 'grid';
         } else {
             $mode = 'list';
         }
     }
     if ($size === 'auto') {
         if ($mode === 'gallery') {
             $size = 1280;
         }
         if ($mode === 'grid') {
             $size = 128;
         } else {
             $size = 32;
         }
     }
     enforce(is_int($size));
     if ($mode === 'gallery') {
         foreach ($this->fileList as $file) {
             $o = (object) $file;
             // shorthand
             // only images matter
             if (!isset(self::$thumb_support[$o->ext])) {
                 continue;
             }
             $url = Cache::getThumb($c->origUrl . '/' . $o->filename, 'b', $size, $size, false, true, $c->thumbScale, $imgW, $imgH);
             out("<a href='{$url}' id='" . $file['thumbID'] . "'></a>");
         }
         return;
     }
     //for (potentially larger thumbs)
     enforce(in_array($size, array(32, 64, 128, 256)), 'non-available icon size');
     // OLD enforce( in_array($thumbSize, Cache::$PERMITTED_SIZES),'invalid thumb size' );
     $ulClass = array("dirList");
     $ulClass[] = "dirList-{$mode}";
     $ulClass[] = "dirList-{$size}";
     $ulClass[] = "dirList-{$mode}-{$size}";
     /* use singleCol rather than styling dirList list width 780px
      * since singeCol is already adjust-styled for Mobile... */
     if ($mode === 'list') {
         $ulClass[] = 'singleCol';
     }
     outPush("<ul class='" . implode(' ', $ulClass) . "'>", $c->indent);
     if (count($this->fileList) < 2) {
         //if empty aka only .. in there
         out("<li class='item item-empty'>This directory is empty.</li>");
     }
     // odd-even class
     $even = true;
     // iterate file-list
     foreach ($this->fileList as $file) {
         $o = (object) $file;
         // shorthand
         $liClass = array('item');
         if ($even) {
             $liClass[] = 'item-even';
         }
         $even = !$even;
         // links open in external tab
         $target = $o->type === 'link' ? " target='_blank'" : '';
         // single-column (folders and other no-downloaders)
         $hasDownload = $o->type === 'file';
         $singleCol = !$hasDownload;
         if ($singleCol) {
             $liClass[] = 'item-singleCol';
         }
         // computer right icon and path, default fallback.
         $iconBaseUrl = $c->ICONURL . $size . '/';
         $iconUrl = $iconBaseUrl . $o->icon;
         $iconPath = $this->ROOT . '/' . $c->ICONPATH . $size . '/';
         if (!is_file($iconPath . $o->icon)) {
             error_log("missing ICONPATH: " . $iconPath . $o->icon);
             $iconUrl = $iconBaseUrl . $c->ICON_DEFAULT;
         }
         //get prior .meta(data) file
         $meta = array();
         // assume empty array for now
         $metaFile = $this->ROOT . $c->origUrl . '/' . $o->filename . '.meta';
         if (is_file($metaFile)) {
             $metaString = file_get_contents($metaFile);
             $metaString = str_replace('\\\\r\\\\n', '<br>', $metaString);
             $meta = json_decode($metaString);
         }
         $title = $o->filename;
         if (isset($meta->caption)) {
             $title = json_clean($meta->caption);
         }
         // COULDO:
         // $download-Only stuff gets singleCol and download-Button...
         $iconOrThumb = isset(self::$thumb_support[$o->ext]) ? 'thumb' : 'icon';
         $liClass[] = $iconOrThumb;
         outPush("<li class='" . implode(' ', $liClass) . "'>");
         $thumbID = isset($o->thumbID) ? " data-thumbid='{$o->thumbID}'" : '';
         outPush("<a class='view'{$thumbID}{$target} href='{$o->link}' title='{$o->title}'>");
         if ($iconOrThumb === 'thumb') {
             $imgW = $imgH = 0;
             $url = Cache::getThumb($c->origUrl . '/' . $o->filename, 'b', $size, $size, false, true, $c->thumbScale, $imgW, $imgH);
             $marginTop = floor(($size - $imgH) / 2) . 'px';
             $marginLeft = floor(($size - $imgW) / 2) . 'px';
             out("<img src='{$url}' alt='{$title}' width='{$imgW}' height='{$imgH}' style='margin-top:{$marginTop};margin-left:{$marginLeft}'>");
         } else {
             out("<img src='{$iconUrl}' alt='' width='{$size}' height='{$size}'>");
         }
         if ($o->size !== null && $o->size !== '') {
             out("<span class='filesize'>" . self::humanSize($o->size) . "</span>");
         }
         out("<span class='filename'>{$title}</span>");
         outPop("</a>");
         if ($hasDownload) {
             out("<a class='download neverprint' title='Herunterladen' href='?download={$o->link}'><span>Download</span></a>");
         }
         outPop("</li>");
     }
     // foreach $file
     outPop("</ul>");
     if ($mode !== 'list') {
         out("<hr class='clear'/>");
     }
     out("<div style='text-align:center;font-size: x-small;color:#888'>powered by " . "<a href='http://github.com/fran-kee/dirList' target='_blank'>" . "dirList</a></div>");
 }