[ 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.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

parameters as for wikiFN

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
author: Chris Smith <chris@jalakai.co.uk>
return: bool exists?

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

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
return: bool exists?

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

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
author: Andreas Gohr <andi@splitbrain.org>
return: string full path

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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!

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

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

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

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

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

isVisiblePage($id)   X-Ref
Reverse of isHiddenPage

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

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.

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

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)

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

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

Uses the 'fnencode' option to determine encoding

param: string $file file name
author: Andreas Gohr <andi@splitbrain.org>
return: string
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

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