Lines Matching defs:file
18 * and calls the supplied function for each file and directory
44 while (($file = readdir($dh)) !== false) {
45 if (preg_match('/^[\._]/', $file)) continue; //skip hidden files and upper dirs
46 if (is_dir($base . '/' . $dir . '/' . $file)) {
47 $dirs[] = $dir . '/' . $file;
50 $files[] = $dir . '/' . $file;
51 $filepaths[] = $base . '/' . $dir . '/' . $file;
70 foreach ($files as $file) {
71 call_user_func_array($func, [&$data, $base, $file, 'f', $lvl, $opts]);
77 * function above. This function is called for every found file or
84 * string $file - current file or directory relative to $base
85 * string $type - Type either 'd' for directory or 'f' for file
94 * one deeper nested) also make sure to check the file type (for example
105 * @param string $file
112 function search_qsearch(&$data, $base, $file, $type, $lvl, $opts)
119 return search_universal($data, $base, $file, $type, $lvl, $opts);
131 * @param string $file
138 function search_index(&$data, $base, $file, $type, $lvl, $opts)
148 'depth' => preg_match('#^' . preg_quote($file, '#') . '(/|$)#', '/' . $ns) ? 0 : -1,
151 return search_universal($data, $base, $file, $type, $lvl, $opts);
161 * @param string $file
168 function search_namespaces(&$data, $base, $file, $type, $lvl, $opts)
171 return search_universal($data, $base, $file, $type, $lvl, $opts);
186 * @param string $file
193 function search_media(&$data, $base, $file, $type, $lvl, $opts)
199 $depth = substr_count($file, '/');
205 $info['id'] = pathID($file, true);
208 msg(hsc($info['id']) . ' is not a valid file name for DokuWiki - skipped', -1);
223 $info['file'] = PhpString::basename($file);
224 $info['size'] = filesize($base . '/' . $file);
225 $info['mtime'] = filemtime($base . '/' . $file);
226 $info['writable'] = is_writable($base . '/' . $file);
227 if (preg_match("/\.(jpe?g|gif|png)$/", $file)) {
229 $info['meta'] = new JpegMeta($base . '/' . $file);
254 * @param string $file
261 function search_mediafiles(&$data, $base, $file, $type, $lvl, $opts)
267 $depth = substr_count($file, '/');
272 $id = pathID($file, true);
275 msg(hsc($id) . ' is not a valid file name for DokuWiki - skipped', -1);
302 * @param string $file
309 function search_list(&$data, $base, $file, $type, $lvl, $opts)
314 if (str_ends_with($file, '.txt')) {
316 $id = pathID($file);
334 * @param string $file
341 function search_pagename(&$data, $base, $file, $type, $lvl, $opts)
346 if (!str_ends_with($file, '.txt')) return true;
350 if (strpos($file, (string) $opts['query']) !== false) {
352 $id = pathID($file);
373 * @param string $file
380 function search_allpages(&$data, $base, $file, $type, $lvl, $opts)
383 $parts = explode('/', ltrim($file, '/'));
398 if (!str_ends_with($file, '.txt')) return true;
401 $item['id'] = pathID($file);
406 $item['rev'] = filemtime($base . '/' . $file);
408 $item['size'] = filesize($base . '/' . $file);
480 * meta bool return file metadata (default: false)
492 * @param string $file - current file or directory relative to $base
493 * @param string $type - Type either 'd' for directory or 'f' for file
501 function search_universal(&$data, $base, $file, $type, $lvl, $opts)
507 $item['id'] = pathID($file, ($type == 'd' || !empty($opts['keeptxt'])));
510 msg(hsc($item['id']) . ' is not a valid file name for DokuWiki - skipped', -1);
521 $depth = substr_count($file, '/');
530 $match = empty($opts['recmatch']) || preg_match('/' . $opts['recmatch'] . '/', $file);
553 if (!empty($opts['dirmatch']) && !preg_match('/' . $opts['dirmatch'] . '/', $file)) return $return;
558 if (!empty($opts['pagesonly']) && !str_ends_with($file, '.txt')) return $return;
560 if (!empty($opts['filematch']) && !preg_match('/' . $opts['filematch'] . '/', $file)) return $return;
570 $item['file'] = PhpString::basename($file);
571 $item['size'] = filesize($base . '/' . $file);
572 $item['mtime'] = filemtime($base . '/' . $file);
574 $item['writable'] = is_writable($base . '/' . $file);
575 $item['executable'] = is_executable($base . '/' . $file);
579 if (!empty($opts['hash'])) $item['hash'] = md5(io_readFile($base . '/' . $file, false));