[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/inc/ -> pageutils.php (summary)

Utilities for handling pagenames

Author: Andreas Gohr
License: GPL 2 (http://www.gnu.org/licenses/gpl.html)
File Size: 771 lines (21 kb)
Included or required: 1 time
Referenced: 0 times
Includes or requires: 0 files

Defines 27 functions

  getID()
  cleanID()
  getNS()
  noNS()
  curNS()
  noNSorNS()
  sectionID()
  page_exists()
  media_exists()
  wikiFN()
  wikiLockFN()
  metaFN()
  mediaMetaFN()
  metaFiles()
  mediaFN()
  localeFN()
  resolve_id()
  resolve_mediaid()
  resolve_pageid()
  getCacheName()
  isHiddenPage()
  _isHiddenPage()
  isVisiblePage()
  prettyprint_id()
  utf8_encodeFN()
  utf8_decodeFN()
  page_findnearest()

Functions
Functions that are not part of a class:

getID($param = 'id', $clean = true)   X-Ref
Fetch the an ID from request

Uses either standard $_REQUEST variable or extracts it from
the full request URI when userewrite is set to 2

For $param='id' $conf['start'] is returned if no id was found.
If the second parameter is true (default) the ID is cleaned.

return: string
author: Andreas Gohr <andi@splitbrain.org>
param: string $param  the $_REQUEST variable name, default 'id'
param: bool   $clean  if true, ID is cleaned

cleanID($raw_id, $ascii = false)   X-Ref
Remove unwanted chars from ID

Cleans a given ID to only use allowed characters. Accented characters are
converted to unaccented ones

return: string cleaned id
author: Andreas Gohr <andi@splitbrain.org>
param: string  $raw_id    The pageid to clean
param: boolean $ascii     Force ASCII

getNS($id)   X-Ref
Return namespacepart of a wiki ID

return: string|false the namespace part or false if the given ID has no namespace (root)
author: Andreas Gohr <andi@splitbrain.org>
param: string $id

noNS($id)   X-Ref
Returns the ID without the namespace

return: string
author: Andreas Gohr <andi@splitbrain.org>
param: string $id

curNS($id)   X-Ref
Returns the current namespace

return: string
author: Nathan Fritz <fritzn@crown.edu>
param: string $id

noNSorNS($id)   X-Ref
Returns the ID without the namespace or current namespace for 'start' pages

return: string
author: Nathan Fritz <fritzn@crown.edu>
param: string $id

sectionID($title, &$check)   X-Ref
Creates a XHTML valid linkid from a given headline title

return: string the title
author: Andreas Gohr <andi@splitbrain.org>
param: string  $title   The headline title
param: array|bool   $check   Existing IDs

page_exists($id, $rev = '', $clean = true, $date_at = false)   X-Ref
Wiki page existence check

parameters as for wikiFN

return: bool exists?
author: Chris Smith <chris@jalakai.co.uk>
param: string $id page id
param: string|int $rev empty or revision timestamp
param: bool $clean flag indicating that $id should be cleaned (see wikiFN as well)
param: bool $date_at

media_exists($id, $rev = '', $clean = true, $date_at = false)   X-Ref
Media existence check

return: bool exists?
param: string $id page id
param: string|int $rev empty or revision timestamp
param: bool $clean flag indicating that $id should be cleaned (see mediaFN as well)
param: bool $date_at

wikiFN($raw_id, $rev = '', $clean = true)   X-Ref
returns the full path to the datafile specified by ID and optional revision

The filename is URL encoded to protect Unicode chars

return: string full path
author: Andreas Gohr <andi@splitbrain.org>
param: $raw_id  string   id of wikipage
param: $rev     int|string   page revision, empty string for current
param: $clean   bool     flag indicating that $raw_id should be cleaned.  Only set to false

wikiLockFN($id)   X-Ref
Returns the full path to the file for locking the page while editing.

return: string full path
author: Ben Coburn <btcoburn@silicodon.net>
param: string $id page id

metaFN($id, $ext)   X-Ref
returns the full path to the meta file specified by ID and extension

return: string full path
author: Steven Danz <steven-danz@kc.rr.com>
param: string $id   page id
param: string $ext  file extension

mediaMetaFN($id, $ext)   X-Ref
returns the full path to the media's meta file specified by ID and extension

return: string
author: Kate Arzamastseva <pshns@ukr.net>
param: string $id   media id
param: string $ext  extension of media

metaFiles($id)   X-Ref
returns an array of full paths to all metafiles of a given ID

return: array
author: Esther Brunner <esther@kaffeehaus.ch>
author: Michael Hamann <michael@content-space.de>
param: string $id page id

mediaFN($id, $rev = '', $clean = true)   X-Ref
returns the full path to the mediafile specified by ID

The filename is URL encoded to protect Unicode chars

return: string full path
author: Andreas Gohr <andi@splitbrain.org>
author: Kate Arzamastseva <pshns@ukr.net>
param: string     $id  media id
param: string|int $rev empty string or revision timestamp
param: bool $clean

localeFN($id, $ext = 'txt')   X-Ref
Returns the full filepath to a localized file if local
version isn't found the english one is returned

return: string full filepath to localized file
author: Andreas Gohr <andi@splitbrain.org>
param: string $id  The id of the local file
param: string $ext The file extension (usually txt)

resolve_id($ns, $id, $clean = true)   X-Ref
Resolve relative paths in IDs

Do not call directly use resolve_mediaid or resolve_pageid
instead

Partyly based on a cleanPath function found at
http://php.net/manual/en/function.realpath.php#57016

return: string
param: string $ns     namespace which is context of id
param: string $id     relative id
param: bool   $clean  flag indicating that id should be cleaned

resolve_mediaid($ns, &$media, &$exists, $rev = '', $date_at = false)   X-Ref
Returns a full media id

param: string $ns namespace which is context of id
param: string &$media (reference) relative media id, updated to resolved id
param: bool &$exists (reference) updated with existance of media
param: int|string $rev
param: bool $date_at

resolve_pageid($ns, &$page, &$exists, $rev = '', $date_at = false)   X-Ref
Returns a full page id

param: string $ns namespace which is context of id
param: string &$page (reference) relative page id, updated to resolved id
param: bool &$exists (reference) updated with existance of media
param: string $rev
param: bool $date_at

getCacheName($data, $ext = '')   X-Ref
Returns the name of a cachefile from given data

The needed directory is created by this function!

return: string       The filename of the cachefile
author: Andreas Gohr <andi@splitbrain.org>
param: string $data  This data is used to create a unique md5 name
param: string $ext   This is appended to the filename if given

isHiddenPage($id)   X-Ref
Checks a pageid against $conf['hidepages']

return: bool
author: Andreas Gohr <gohr@cosmocode.de>
param: string $id page id

_isHiddenPage(&$data)   X-Ref
callback checks if page is hidden

param: array $data event data    - see isHiddenPage()

isVisiblePage($id)   X-Ref
Reverse of isHiddenPage

return: bool
author: Andreas Gohr <gohr@cosmocode.de>
param: string $id page id

prettyprint_id($id)   X-Ref
Format an id for output to a user

Namespaces are denoted by a trailing “:*”. The root namespace is
“*”. Output is escaped.

return: string
author: Adrian Lang <lang@cosmocode.de>
param: string $id page id

utf8_encodeFN($file, $safe = true)   X-Ref
Encode a UTF-8 filename to use on any filesystem

Uses the 'fnencode' option to determine encoding

When the second parameter is true the string will
be encoded only if non ASCII characters are detected -
This makes it safe to run it multiple times on the
same string (default is true)

return: string
author: Andreas Gohr <andi@splitbrain.org>
param: string $file file name
param: bool   $safe if true, only encoded when non ASCII characters detected
see: urlencode

utf8_decodeFN($file)   X-Ref
Decode a filename back to UTF-8

Uses the 'fnencode' option to determine encoding

return: string
author: Andreas Gohr <andi@splitbrain.org>
param: string $file file name
see: urldecode

page_findnearest($page, $useacl = true)   X-Ref
Find a page in the current namespace (determined from $ID) or any
higher namespace that can be accessed by the current user,
this condition can be overriden by an optional parameter.

Used for sidebars, but can be used other stuff as well

return: false|string the full page id of the found page, false if any
param: string $page the pagename you're looking for
param: bool $useacl only return pages readable by the current user, false to ignore ACLs