/** * 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; } } }
/** * List all files in a given Media namespace * * @see media_filelist() */ function _mod_media_filelist($ns, $auth = null, $jump = '', $fullscreenview = false, $sort = false) { 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}:*"); } if (!$fullscreenview) { 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; } else { if (!$fullscreenview) { media_uploadform($ns, $auth); } $dir = utf8_encodeFN(str_replace(':', '/', $ns)); $data = array(); search($data, $conf['mediadir'], 'search_media', array('showmsg' => true, 'depth' => 1), $dir, 1, $sort); if (!count($data)) { echo '<div class="nothing">' . $lang['nothingfound'] . '</div>' . NL; } else { if ($fullscreenview) { echo '<ul class="' . _media_get_list_type() . '">'; } foreach ($data as $item) { if (!$fullscreenview) { $this->_mod_media_printfile($item, $auth, $jump); } else { $this->_mod_media_printfile_thumbs($item, $auth, $jump); } } if ($fullscreenview) { echo '</ul>' . NL; } } } if (!$fullscreenview) { media_searchform($ns); } }
/** * 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); }