+++ /dev/null
-<?php\r
-/**\r
- * Data structures used in parsing XML DocBook-based tutorials\r
- *\r
- * Conversion of DocBook-based tutorials is performed using special\r
- * {@link Converter} class methods. By default, these methods simply retrieve\r
- * simple rules for replacement of tags and slight re-ordering from the\r
- * options.ini file present for every template.\r
- *\r
- * In future versions, there may be utilization of xslt or other more powerful\r
- * protocols. However, for most situations, the power of these classes will\r
- * be more than sufficient to handle very complex documentation.\r
- *\r
- * Note that an entire tutorial is contained in a single parserXMLDocBookTag,\r
- * matching the document model for DocBook. The top-level tag, <refentry>,\r
- * contains every other tag and all text.\r
- * \r
- * phpDocumentor :: automatic documentation generator\r
- * \r
- * PHP versions 4 and 5\r
- *\r
- * Copyright (c) 2002-2006 Gregory Beaver\r
- * \r
- * LICENSE:\r
- * \r
- * This library is free software; you can redistribute it\r
- * and/or modify it under the terms of the GNU Lesser General\r
- * Public License as published by the Free Software Foundation;\r
- * either version 2.1 of the License, or (at your option) any\r
- * later version.\r
- * \r
- * This library is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r
- * Lesser General Public License for more details.\r
- * \r
- * You should have received a copy of the GNU Lesser General Public\r
- * License along with this library; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
- *\r
- * @package phpDocumentor\r
- * @subpackage Tutorial\r
- * @author Gregory Beaver <cellog@php.net>\r
- * @copyright 2002-2006 Gregory Beaver\r
- * @license http://www.opensource.org/licenses/lgpl-license.php LGPL\r
- * @version CVS: $Id: PackagePageElements.inc,v 1.4 2006/05/22 01:07:28 cellog Exp $\r
- * @tutorial tutorials.pkg\r
- * @link http://www.phpdoc.org\r
- * @link http://pear.php.net/PhpDocumentor\r
- * @since 1.2.0\r
- */\r
-/**\r
- * Represents <![CDATA[ ]]> sections.\r
- *\r
- * These sections are interpreted as plain text\r
- * @package phpDocumentor\r
- * @subpackage Tutorial\r
- */\r
-class parserCData extends parserStringWithInlineTags\r
-{\r
- /**\r
- * @uses Converter::getCData() convert contents to text\r
- * @param Converter\r
- */\r
- function Convert(&$c, $postprocess = true)\r
- {\r
- $val = $this->value;\r
- if ($postprocess)\r
- foreach($this->value as $key => $value)\r
- {\r
- if (is_string($value)) $this->value[$key] = $c->getCData($value);\r
- }\r
- $this->cache = false;\r
- $x = parent::Convert($c, false);\r
- $this->value = $val;\r
- return $x;\r
- }\r
-}\r
-/**\r
- * a standard XML DocBook Tag\r
- *\r
- * This class is designed to represent all DocBook tags. It is intelligent\r
- * enough to understand the <title> tag, and also the <refname> tag for\r
- * as title for <refentry>\r
- * @since 1.2\r
- * @package phpDocumentor\r
- * @subpackage Tutorial\r
- */\r
-class parserXMLDocBookTag extends parserStringWithInlineTags\r
-{\r
- /**\r
- * Attributes from the XML tag\r
- *\r
- * Format: array(attrname => attrvalue, attrname => attrvalue,...)\r
- * @var array\r
- */\r
- var $attributes = array();\r
- /**\r
- * Name of the tag\r
- * @var string\r
- */\r
- var $name;\r
- /**#@+ @access private */\r
- /** @var parserCData */\r
- var $_cdata;\r
- /** @var parserTag */\r
- var $_title;\r
- /** @var parserIdLineTag */\r
- var $_id;\r
- /**\r
- * Set to <refpurpose> in <refsynopsisdiv>\r
- * @var parserTag\r
- */\r
- var $_description;\r
- /**#@-*/\r
- /**\r
- * @param string tag name\r
- */\r
- function parserXMLDocBookTag($name)\r
- {\r
- $this->name = $name;\r
- }\r
- \r
- /**\r
- * @param Converter\r
- * @param boolean\r
- * @uses Converter::TranslateTag() Calls this to enclose the contents of the\r
- * DocBook tag based on the values in template options.ini file\r
- */\r
- function Convert(&$c, $postprocess = true)\r
- {\r
- $value = parent::Convert($c, $postprocess);\r
- $simvalue = parent::Convert($c, false);\r
- foreach($this->attributes as $a => $v)\r
- {\r
- $this->attributes[$a] = (is_string($v) ? $v : $v->Convert($c, $postprocess));\r
- }\r
- if (isset($this->_title))\r
- {\r
- list($this->attributes,$value) = $c->ConvertTitle($this->name, $this->attributes, $this->_title->Convert($c, $postprocess), $value);\r
- }\r
- return $c->TranslateTag($this->name,$this->attributes,$value,$simvalue);\r
- }\r
- \r
- /**\r
- * Begin a new CData section\r
- * @see addCData()\r
- */\r
- function startCData()\r
- {\r
- $this->_cdata = new parserCData;\r
- }\r
- \r
- /**\r
- * Adds {@link $_cdata} to {@link $value}\r
- */\r
- function endCData()\r
- {\r
- $this->value[] = $this->_cdata;\r
- unset($this->_cdata);\r
- }\r
- \r
- /**\r
- * Retrieve either the table of contents index, or the location that\r
- * the TOC will go\r
- * @see setTOC()\r
- * @param false|integer either an index of the {@}toc} tag in $this->value\r
- * or false, if the next index value of $this->value\r
- * is needed\r
- */\r
- function getTOC($state = false)\r
- {\r
- if ($state !== false) return $this->value[$state];\r
- return count($this->value);\r
- }\r
- \r
- /**\r
- * @param integer index of the TOC in $this->value\r
- * @param parserTocInlineTag\r
- */\r
- function setTOC($state, $val)\r
- {\r
- $this->value[$state] = $val;\r
- }\r
- \r
- /**\r
- * add a word to CData\r
- * @param string\r
- */\r
- function addCData($word)\r
- {\r
- $this->_cdata->add($word);\r
- }\r
- \r
- /**\r
- * Add an xml tag attribute name="value" pair\r
- *\r
- * if the attribute is id, value must be a {@link parserIdInlineTag}\r
- * @param string attribute name\r
- * @param string|parserIdInlineTag value of attribute\r
- */\r
- function addAttribute($name,$value)\r
- {\r
- $this->attributes[$name] = $value;\r
- if ($name == 'id')\r
- {\r
- // fix 1153593\r
- if (is_string($value))\r
- {\r
- addWarning(PDERROR_ID_MUST_BE_INLINE,$this->name,$value,$this->name,$value);\r
- } else {\r
- $this->setId($value);\r
- }\r
- }\r
- }\r
- \r
- /**\r
- * Set the title of a DocBook tag section.\r
- *\r
- * For most DocBook tags, the title is represented with a <title></title>\r
- * tag pair. The <refentry> top-level tag is a little different. Instead\r
- * of using <title></title>, phpDocumentor uses the contents of the\r
- * <refname> tag in the <refnamediv> tag\r
- * @param parserXMLDocBookTag the title element\r
- */\r
- function setTitle($title)\r
- {\r
- $this->_title = $title;\r
- }\r
- \r
- /**\r
- * If the id attribute is present, this method will set its id\r
- * @param parserIdInlineTag\r
- */\r
- function setId($id)\r
- {\r
- $this->_id = $id;\r
- }\r
- \r
- /**\r
- * Return converter-specific formatting of ID.\r
- *\r
- * Passes $c to {@link parserIdInlineTag::Convert()}\r
- * @param Converter\r
- * @return string\r
- */\r
- function getId(&$c)\r
- {\r
- if ($this->_id) return trim($this->_id->Convert($c));\r
- }\r
- \r
- /**\r
- * Determine whether the docbook element has a title\r
- * @return boolean\r
- */\r
- function hasTitle()\r
- {\r
- return isset($this->_title);\r
- }\r
- \r
- /**\r
- * Retrieve Converter-specific formatting of the title of this element\r
- * @return string\r
- * @param Converter\r
- */\r
- function getTitle(&$c)\r
- {\r
- if ($this->name == 'refentry')\r
- {\r
- foreach($this->value as $tag)\r
- {\r
- if (is_object($tag) && $tag->name == 'refnamediv')\r
- {\r
- return $tag->getTitle($c);\r
- }\r
- }\r
- }\r
- if ($this->name == 'refnamediv')\r
- {\r
- foreach($this->value as $tag)\r
- {\r
- if (is_object($tag) && is_a($tag, 'parserXMLDocBookTag') && $tag->name == 'refname')\r
- {\r
- $t = new parserStringWithInlineTags;\r
- foreach($tag->value as $val) $t->add($val);\r
- $this->_title = $t;\r
- }\r
- if (is_object($tag) && is_a($tag, 'parserXMLDocBookTag') && $tag->name == 'refpurpose')\r
- {\r
- $t = new parserStringWithInlineTags;\r
- foreach($tag->value as $val) $t->add($val);\r
- $this->_description = $t;\r
- }\r
- }\r
- }\r
- if (isset($this->_title))\r
- return $this->_title->Convert($c);\r
- if (is_object($this->value[0]) && is_a($tag, 'parserXMLDocBookTag')) {\r
- return $this->value[0]->getTitle($c);\r
- }\r
- if (isset($this->value[1])) {\r
- if (is_object($this->value[1]) && is_a($tag, 'parserXMLDocBookTag')) {\r
- return $this->value[1]->getTitle($c);\r
- }\r
- }\r
- return '';\r
- }\r
- \r
- /**\r
- * Retrieve the contents of a subsection\r
- *\r
- * This method uses the $_id members of nested docbook tags to retrieve\r
- * the section defined by $subsection\r
- * @param Converter\r
- * @param string converter-specific subsection\r
- */\r
- function getSubsection(&$c,$subsection)\r
- {\r
- if (!is_object($this->_id)) {\r
- return false;\r
- }\r
- $search = phpDocumentor_clone($this->_id);\r
- if (is_string($this->_id)) return false;\r
- if (phpDocumentor_get_class($search) != 'parseridinlinetag') return false;\r
- $search->id = $subsection;\r
- foreach($this->value as $el)\r
- {\r
- if (phpDocumentor_get_class($el) == 'parserxmldocbooktag')\r
- {\r
- if ($el->getId($c) == $search->Convert($c))\r
- {\r
- return $el;\r
- } elseif ($a = $el->getSubsection($c,$subsection))\r
- {\r
- return $a;\r
- }\r
- }\r
- }\r
- return false;\r
- }\r
- \r
- /**\r
- * Add contents to this tag.\r
- *\r
- * There are four kinds of data in a DocBook tutorial:\r
- * 1. <b>tags</b> - normal tags like <refentry>\r
- * 2. <b>entities</b> - normal entities like ”\r
- * 3. <b><![CDATA[</b> - character data that should not be interpreted,\r
- * like <programlisting> contents\r
- * 4. <b>text</b> - normal non-markup text\r
- *\r
- * All four kinds of data are added here\r
- * @param parserEntity|parserCData|parserXMLDocBookTag|string nested tag,\r
- * entity, or text\r
- */\r
- function add($el)\r
- {\r
- if (is_string($el)) return parent::add($el);\r
- if (phpDocumentor_get_class($el) == 'parserxmldocbooktag')\r
- {\r
- if ($el->name == 'title')\r
- {\r
- $this->setTitle($el);\r
- } else return parent::add($el);\r
- } else return parent::add($el);\r
- }\r
-}\r
-\r
-/**\r
- * a standard entity like ”\r
- *\r
- * This class is designed to represent all DocBook entities.\r
- * @since 1.2\r
- * @package phpDocumentor\r
- * @subpackage Tutorial\r
- */\r
-class parserEntity\r
-{\r
- /**\r
- * @param string entity name\r
- */\r
- function parserEntity($name)\r
- {\r
- $this->value = $name;\r
- }\r
- \r
- /**\r
- * @uses Converter::TranslateEntity() convert contents to text\r
- * @param Converter\r
- * @return string\r
- */\r
- function Convert(&$c, $postprocess = true)\r
- {\r
- if ($postprocess)\r
- return $c->TranslateEntity($this->value);\r
- else\r
- {\r
- $trans_tbl = get_html_translation_table (HTML_ENTITIES);\r
- $trans_tbl = array_flip ($trans_tbl);\r
- $ret = strtr ('&'.$this->value.';', $trans_tbl);\r
- return $ret;\r
- }\r
- }\r
-}\r
-?>
\ No newline at end of file