[ 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: 778 lines (22 kb)
Included or required: 1 time
Referenced: 0 times
Includes or requires: 0 files

Defines 26 functions

  getID()
  cleanID()
  getNS()
  noNS()
  curNS()
  noNSorNS()
  sectionID()
  page_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
param: string $param  the $_REQUEST variable name, default 'id'
param: bool   $clean  if true, ID is cleaned
author: Andreas Gohr <andi@splitbrain.org>

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
param: string  $raw_id    The pageid to clean
param: boolean $ascii     Force ASCII
author: Andreas Gohr <andi@splitbrain.org>

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

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

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

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

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

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

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

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

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

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

parameters as for wikiFN

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 wikiFN as well)
param: bool $date_at
author: Chris Smith <chris@jalakai.co.uk>

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

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

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

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

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

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

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

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

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

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

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
param: string $id  The id of the local file
param: string $ext The file extension (usually txt)
author: Andreas Gohr <andi@splitbrain.org>

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
author: <bart at mediawave dot nl>

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

param: string $ns namespace which is context of id
param: string &$page (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
author: Andreas Gohr <andi@splitbrain.org>

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

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

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

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

_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
param: string $id page id
author: Andreas Gohr <gohr@cosmocode.de>

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
param: string $id page id
author: Adrian Lang <lang@cosmocode.de>

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

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

Uses the 'fnencode' option to determine encoding

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