Lines Matching defs:id

26  * For $param='id' $conf['start'] is returned if no id was found.
31 * @param string $param the $_REQUEST variable name, default 'id'
35 function getID($param = 'id', $clean = true)
42 $id = $INPUT->str($param);
44 //construct page id from request URI
45 if (empty($id) && $conf['userewrite'] == 2) {
52 if ($param != 'id') {
74 //remove script URL and Querystring to gain the id
76 $id = preg_replace('/\?.*/', '', $match[1]);
78 $id = urldecode($id);
80 $id = preg_replace('!^/+!', '', $id);
84 if (str_ends_with($id, ':') || ($conf['useslash'] && str_ends_with($id, '/'))) {
85 if (page_exists($id . $conf['start'])) {
87 $id .= $conf['start'];
88 } elseif (page_exists($id . noNS(cleanID($id)))) {
90 $id .= noNS(cleanID($id));
91 } elseif (page_exists($id)) {
93 $id = substr($id, 0, -1);
96 $id .= $conf['start'];
100 if (isset($urlParameters['id'])) {
101 unset($urlParameters['id']);
103 send_redirect(wl($id, $urlParameters, true, '&'));
106 if ($clean) $id = cleanID($id);
107 if ($id === '' && $param == 'id') $id = $conf['start'];
109 return $id;
122 * @return string cleaned id
141 $id = trim((string)$raw_id);
142 $id = PhpString::strtolower($id);
146 $id = strtr($id, ';/', '::');
148 $id = strtr($id, ';/', ':' . $sepchar);
151 if ($conf['deaccent'] == 2 || $ascii) $id = Clean::romanize($id);
152 if ($conf['deaccent'] || $ascii) $id = Clean::deaccent($id, -1);
155 $id = Clean::stripspecials($id, $sepchar, '\*');
157 if ($ascii) $id = Clean::strip($id);
160 $id = preg_replace($sepcharpat, $sepchar, $id);
161 $id = preg_replace('#:+#', ':', $id);
162 $id = trim($id, ':._-');
163 $id = preg_replace('#:[:\._\-]+#', ':', $id);
164 $id = preg_replace('#[:\._\-]+:#', ':', $id);
166 if (!$ascii) $cache[(string)$raw_id] = $id;
167 return($id);
175 * @param string $id
178 function getNS($id)
180 $pos = strrpos((string)$id, ':');
182 return substr((string)$id, 0, $pos);
192 * @param string $id
195 function noNS($id)
197 $pos = strrpos($id, ':');
199 return substr($id, $pos + 1);
201 return $id;
210 * @param string $id
213 function curNS($id)
215 return noNS(getNS($id));
223 * @param string $id
226 function noNSorNS($id)
230 $p = noNS($id);
232 $p = curNS($id);
279 * @param string $id page id
281 * @param bool $clean flag indicating that $id should be cleaned (see wikiFN as well)
285 function page_exists($id, $rev = '', $clean = true, $date_at = false)
287 $id = (explode('#', $id, 2))[0]; // #3608
290 $pagelog = new PageChangeLog($id);
295 return file_exists(wikiFN($id, $rev, $clean));
301 * @param string $id page id
303 * @param bool $clean flag indicating that $id should be cleaned (see mediaFN as well)
307 function media_exists($id, $rev = '', $clean = true, $date_at = false)
310 $changeLog = new MediaChangeLog($id);
316 return file_exists(mediaFN($id, $rev, $clean));
324 * @param $raw_id string id of wikipage
327 * when $id is guaranteed to have been cleaned already.
339 $id = $raw_id;
341 if ($clean) $id = cleanID($id);
342 $id = str_replace(':', '/', $id);
344 if (isset($cache[$id]) && isset($cache[$id][$rev])) {
345 return $cache[$id][$rev];
349 $fn = $conf['datadir'] . '/' . utf8_encodeFN($id) . '.txt';
351 $fn = $conf['olddir'] . '/' . utf8_encodeFN($id) . '.' . $rev . '.txt';
365 if (!isset($cache[$id])) {
366 $cache[$id] = [];
368 $cache[$id][$rev] = $fn;
377 * @param string $id page id
380 function wikiLockFN($id)
383 return $conf['lockdir'] . '/' . md5(cleanID($id)) . '.lock';
392 * @param string $id page id
396 function metaFN($id, $ext)
399 $id = cleanID($id);
400 $id = str_replace(':', '/', $id);
402 $fn = $conf['metadir'] . '/' . utf8_encodeFN($id) . $ext;
411 * @param string $id media id
415 function mediaMetaFN($id, $ext)
418 $id = cleanID($id);
419 $id = str_replace(':', '/', $id);
421 $fn = $conf['mediametadir'] . '/' . utf8_encodeFN($id) . $ext;
431 * @param string $id page id
434 function metaFiles($id)
436 $basename = metaFN($id, '');
438 // filter files like foo.bar.meta when $id == 'foo'
450 * @param string $id media id
456 function mediaFN($id, $rev = '', $clean = true)
459 if ($clean) $id = cleanID($id);
460 $id = str_replace(':', '/', $id);
462 $fn = $conf['mediadir'] . '/' . utf8_encodeFN($id);
464 $ext = mimetype($id);
465 $name = substr($id, 0, -1 * strlen($ext[0]) - 1);
475 * @param string $id The id of the local file
481 function localeFN($id, $ext = 'txt')
484 $file = DOKU_CONF . 'lang/' . $conf['lang'] . '/' . $id . '.' . $ext;
486 $file = DOKU_INC . 'inc/lang/' . $conf['lang'] . '/' . $id . '.' . $ext;
489 $file = DOKU_INC . 'inc/lang/en/' . $id . '.' . $ext;
505 * @param string $ns namespace which is context of id
506 * @param string $id relative id
507 * @param bool $clean flag indicating that id should be cleaned
510 function resolve_id($ns, $id, $clean = true)
516 if ($conf['useslash']) $id = str_replace('/', ':', $id);
518 // if the id starts with a dot we need to handle the
520 if ($id && $id[0] == '.') {
522 $id = preg_replace('/^((\.+:)*)(\.+)(?=[^:\.])/', '\1\3:', $id);
524 $id = $ns . ':' . $id;
528 $pathA = explode(':', $id);
542 $id = implode(':', $result);
543 } elseif ($ns !== false && strpos($id, ':') === false) {
545 $id = $ns . ':' . $id;
548 if ($clean) $id = cleanID($id);
549 return $id;
553 * Returns a full media id
555 * @param string $ns namespace which is context of id
556 * @param string &$media (reference) relative media id, updated to resolved id
571 * Returns a full page id
574 * @param string $ns namespace which is context of id
575 * @param string &$page (reference) relative page id, updated to resolved id
621 * @param string $id page id
624 function isHiddenPage($id)
626 $data = ['id' => $id, 'hidden' => false];
645 if (preg_match('/' . $conf['hidepages'] . '/ui', ':' . $data['id'])) {
655 * @param string $id page id
658 function isVisiblePage($id)
660 return !isHiddenPage($id);
664 * Format an id for output to a user
671 * @param string $id page id
674 function prettyprint_id($id)
676 if (!$id || $id === ':') {
679 if (str_ends_with($id, ':')) {
680 $id .= '*';
682 return hsc($id);
754 * @return false|string the full page id of the found page, false if any