cvs: phd(PHD_0_4) /include PhDHelper.class.php

From: Date: Sun, 19 Oct 2008 13:06:48 +0000
Subject: cvs: phd(PHD_0_4) /include PhDHelper.class.php
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-2254@lists.php.net to get a copy of this message
bjori Sun Oct 19 13:06:48 2008 UTC Modified files: (Branch: PHD_0_4) /phd/include PhDHelper.class.php Log: -MFH: Add new PhDHelper::getSelf() method -MFH: Comments and CS http://cvs.php.net/viewvc.cgi/phd/include/PhDHelper.class.php?r1=1.9.2.1&r2=1.9.2.1.2.1&diff_format=u Index: phd/include/PhDHelper.class.php diff -u phd/include/PhDHelper.class.php:1.9.2.1 phd/include/PhDHelper.class.php:1.9.2.1.2.1 --- phd/include/PhDHelper.class.php:1.9.2.1 Sat Aug 23 13:51:14 2008 +++ phd/include/PhDHelper.class.php Sun Oct 19 13:06:48 2008 @@ -1,51 +1,158 @@ <?php -/* $Id: PhDHelper.class.php,v 1.9.2.1 2008/08/23 13:51:14 bjori Exp $ */ +/* $Id: PhDHelper.class.php,v 1.9.2.1.2.1 2008/10/19 13:06:48 bjori Exp $ */ + +/** +* Base class for PhDTheme +*/ +class PhDHelper +{ + /** + * Array of all ids as key and their "attributes" (not xml-atts) + * as array. + * Created by mktoc.php + * + * @var array + */ + private $IDs = array(); + + /** + * Array of &lt;refname&gt; tag contents as key, + * and the ID of the section they appear in as value. + * Created by mktoc.php + * + * @var array + */ + private $refs = array(); -class PhDHelper { - private $IDs = array(); - private $refs = array(); private $classes = array(); private $vars = array(); + /* abstract */ protected $elementmap = array(); /* abstract */ protected $textmap = array(); private static $autogen = array(); + /** + * Creates the helper object. + * + * @param array $a Array with ID array as first value, ref array as second. + * + * @see $IDs + * @see $refs + */ public function __construct(array $a) { $this->IDs = $a[0]; $this->refs = $a[1]; $this->classes = $a[2]; $this->vars = $a[3]; } - final public function getFilename($id) { + + /** + * When the tag associated with that $id is to be chunked, + * the filename (without extension) is returned. + * + * @param string $id ID of an element + * + * @return mixed Filename without extension (string) or false if the element + * is not to be chunked + * + * @see $IDs + */ + final public function getFilename($id) + { return isset($this->IDs[$id]) ? $this->IDs[$id]["filename"] : false; } + final public function getDescription($id, $long = false) { return $long ? ($this->IDs[$id]["ldesc"] ? $this->IDs[$id]["ldesc"] : $this->IDs[$id]["sdesc"]) : ($this->IDs[$id]["sdesc"] ? $this->IDs[$id]["sdesc"] : $this->IDs[$id]["ldesc"]); } - final public function getChildren($id) { + + /** + * Returns an array of direct children tags with IDs. + * + * @param string $id ID of an element + * + * @return array Array of children IDs (empty array when no kids) + * + * @see $IDs + */ + final public function getChildren($id) + { return $this->IDs[$id]["children"]; } - final public function getParent($id) { + + /** + * Returns the toc entry of the given ID. + * + * @param string $id ID of an element + * + * @return array toc entry array + * + * @see $IDs + */ + final public function getSelf($id) + { + return $this->IDs[$id]; + } + + /** + * Returns ID of the first parental block tag with an ID. + * + * @param string $id ID of an element + * + * @return string ID of the parent tag + * + * @see $IDs + */ + final public function getParent($id) + { return $this->IDs[$id]["parent"]; } - public function getRefnameLink($ref) { + + /** + * Returns the id of the reference page for a given function/method/class. + * + * @param string $ref Name of referenced object (e.g. "$class", "$class-$method") + * + * @return mixed ID (string) of reference page or null if not found. + * + * @see $refs + */ + public function getRefnameLink($ref) + { return isset($this->refs[$ref]) ? $this->refs[$ref] : null; } + public function getClassnameLink($class) { return isset($this->classes[$class]) ? $this->classes[$class] : null; } public function getVarnameLink($var) { return isset($this->vars[$var]) ? $this->vars[$var] : null; } + final public function getElementMap() { return $this->elementmap; } final public function getTextMap() { return $this->textmap; } - final public function autogen($text, $lang) { + + /** + * Reads $phddir/include/langs/$lang.xml and returns the translation + * for the given $text. + * + * @note + * This function is used only internally, it has nothing to do with the + * manual content. Used e.g. for autogenerated table of contents titles. + * + * @param string $text Text to translate ("warning", "toc", "by") + * @param string $lang Two-letter ISO code of language (de, en, ..) + * + * @return string Translated text + */ + final public function autogen($text, $lang) + { if (isset(PhDHelper::$autogen[$lang])) { return PhDHelper::$autogen[$lang][$text]; }

« previous php.doc.cvs (#2254) next »