Пример #1
0
/**
 * List all files in a given Media namespace
 */
function media_filelist($ns, $auth = null, $jump = '')
{
    global $conf;
    global $lang;
    $ns = cleanID($ns);
    // check auth our self if not given (needed for ajax calls)
    if (is_null($auth)) {
        $auth = auth_quickaclcheck("{$ns}:*");
    }
    echo '<h1 id="media__ns">:' . hsc($ns) . '</h1>' . NL;
    if ($auth < AUTH_READ) {
        // FIXME: print permission warning here instead?
        echo '<div class="nothing">' . $lang['nothingfound'] . '</div>' . NL;
        return;
    }
    media_uploadform($ns, $auth);
    $dir = utf8_encodeFN(str_replace(':', '/', $ns));
    $data = array();
    search($data, $conf['mediadir'], 'search_media', array('showmsg' => true), $dir);
    if (!count($data)) {
        echo '<div class="nothing">' . $lang['nothingfound'] . '</div>' . NL;
        return;
    }
    foreach ($data as $item) {
        media_printfile($item, $auth, $jump);
    }
}
Пример #2
0
/**
 * List all files found by the search request
 *
 * @author Tobias Sarnowski <*****@*****.**>
 * @author Andreas Gohr <*****@*****.**>
 * @author Kate Arzamastseva <*****@*****.**>
 * @triggers MEDIA_SEARCH
 */
function media_searchlist($query, $ns, $auth = null, $fullscreen = false, $sort = 'natural')
{
    global $conf;
    global $lang;
    $ns = cleanID($ns);
    if ($query) {
        $evdata = array('ns' => $ns, 'data' => array(), 'query' => $query);
        $evt = new Doku_Event('MEDIA_SEARCH', $evdata);
        if ($evt->advise_before()) {
            $dir = utf8_encodeFN(str_replace(':', '/', $evdata['ns']));
            $pattern = '/' . preg_quote($evdata['query'], '/') . '/i';
            search($evdata['data'], $conf['mediadir'], 'search_media', array('showmsg' => false, 'pattern' => $pattern), $dir, 1, $sort);
        }
        $evt->advise_after();
        unset($evt);
    }
    if (!$fullscreen) {
        echo '<h1 id="media__ns">' . sprintf($lang['searchmedia_in'], hsc($ns) . ':*') . '</h1>' . NL;
        media_searchform($ns, $query);
    }
    if (!count($evdata['data'])) {
        echo '<div class="nothing">' . $lang['nothingfound'] . '</div>' . NL;
    } else {
        if ($fullscreen) {
            echo '<ul class="' . _media_get_list_type() . '">';
        }
        foreach ($evdata['data'] as $item) {
            if (!$fullscreen) {
                media_printfile($item, $item['perm'], '', true);
            } else {
                media_printfile_thumbs($item, $item['perm'], false, true);
            }
        }
        if ($fullscreen) {
            echo '</ul>' . NL;
        }
    }
}
 /**
  * Outputs a list of files for mediamanager
  * 
  * @see media_filelist() in inc/media.php
  */
 function _listMedia($ns, $auth, $jumpto)
 {
     global $conf;
     global $lang;
     print '<h1 id="media__ns">:' . hsc($ns) . '</h1>' . NL;
     if ($auth < AUTH_READ) {
         print '<div class="nothing">' . $lang['nothingfound'] . '</div>' . NL;
     } else {
         media_uploadform($ns, $auth);
         $dir = utf8_encodeFN(str_replace(':', '/', $ns));
         $data = array();
         search($data, $conf['mediadir'], 'search_media', array('showmsg' => true, 'depth' => 1), $dir);
         if (empty($data)) {
             print '<div class="nothing">' . $lang['nothingfound'] . '</div>' . NL;
         } else {
             foreach ($data as $item) {
                 $filename = $this->_getOriginalFileName($item['id']);
                 if ($filename !== false) {
                     $item['file'] = utf8_encodeFN($filename);
                 }
                 media_printfile($item, $auth, $jumpto);
             }
         }
     }
     media_searchform($ns);
 }