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

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

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

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

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

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

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

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

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

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

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

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

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

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

parameters as for wikiFN

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

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

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

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

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

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

author: Steven Danz <steven-danz@kc.rr.com>
return: string full path
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

author: Kate Arzamastseva <pshns@ukr.net>
return: string
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

author: Esther Brunner <esther@kaffeehaus.ch>
author: Michael Hamann <michael@content-space.de>
return: array
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

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

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

author: <bart at mediawave dot nl>
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,&$page,&$exists,$rev='',$date_at=false)   X-Ref
Returns a full media id

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

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

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

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

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

author: Andreas Gohr <gohr@cosmocode.de>
return: bool
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

author: Andreas Gohr <gohr@cosmocode.de>
return: bool
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.

author: Adrian Lang <lang@cosmocode.de>
return: string
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)

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

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