cvs: pear /XML_Transformer/Transformer/Namespace DocBook.php

From: Date: Tue, 01 Oct 2002 06:40:32 +0000
Subject: cvs: pear /XML_Transformer/Transformer/Namespace DocBook.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-6789@lists.php.net to get a copy of this message
sebastian Tue Oct 1 02:40:32 2002 EDT Modified files: /pear/XML_Transformer/Transformer/Namespace DocBook.php Log: Add <book>. Index: pear/XML_Transformer/Transformer/Namespace/DocBook.php diff -u pear/XML_Transformer/Transformer/Namespace/DocBook.php:1.18 pear/XML_Transformer/Transformer/Namespace/DocBook.php:1.19 --- pear/XML_Transformer/Transformer/Namespace/DocBook.php:1.18 Mon Sep 30 06:46:41 2002 +++ pear/XML_Transformer/Transformer/Namespace/DocBook.php Tue Oct 1 02:40:32 2002 @@ -13,7 +13,7 @@ // | license@php.net so we can mail you a copy immediately. | // +----------------------------------------------------------------------+ // -// $Id: DocBook.php,v 1.18 2002/09/30 10:46:41 sebastian Exp $ +// $Id: DocBook.php,v 1.19 2002/10/01 06:40:32 sebastian Exp $ // require_once 'XML/Transformer/Namespace.php'; @@ -32,6 +32,8 @@ * * * <author> * +* * <book> +* * * <chapter> * * * <emphasis> @@ -144,7 +146,7 @@ * * @author Sebastian Bergmann <sb@sebastian-bergmann.de> * @author Kristian Köhntopp <kris@koehntopp.de> -* @version $Revision: 1.18 $ +* @version $Revision: 1.19 $ * @access public */ class XML_Transformer_Namespace_DocBook extends XML_Transformer_Namespace { @@ -315,23 +317,7 @@ * @access public */ function start_article($attributes) { - if (!$this->_secondPass) { - $id = $this->_startSection( - 'article', - isset($attributes['id']) ? $attributes['id'] : '' - ); - - return '<article>' . $id; - } else { - return sprintf( - '<html><head><title>%s: %s</title><body><h1 class="title">%s: %s</h1>', - - $this->_author, - $this->_title, - $this->_author, - $this->_title - ); - } + return $this->_startDocument('article', $attributes); } // }}} @@ -343,20 +329,7 @@ * @access public */ function end_article($cdata) { - if (!$this->_secondPass) { - $this->_endSection('article'); - - $this->_secondPass = true; - - $cdata = $cdata . '</article>'; - } else { - $cdata = $cdata . '</body></html>'; - } - - return array( - $cdata, - false - ); + return $this->_endDocument('article', $cdata); } // }}} @@ -382,6 +355,30 @@ } // }}} + // {{{ function start_book($attributes) + + /** + * @param array + * @return string + * @access public + */ + function start_book($attributes) { + return $this->_startDocument('book', $attributes); + } + + // }}} + // {{{ function end_book($cdata) + + /** + * @param string + * @return string + * @access public + */ + function end_book($cdata) { + return $this->_endDocument('book', $cdata); + } + + // }}} // {{{ function start_chapter($attributes) /** @@ -967,6 +964,71 @@ } // }}} + // {{{ function _startDocument($type, $attributes) + + /** + * @param string + * @param array + * @return string + * @access private + */ + function _startDocument($type, $attributes) { + if (!$this->_secondPass) { + $id = $this->_startSection( + $type, + isset($attributes['id']) ? $attributes['id'] : '' + ); + + return sprintf( + '<%s>%s', + + $type, + $id + ); + } else { + return sprintf( + '<html><head><title>%s: %s</title><body><h1 class="title">%s: %s</h1>', + + $this->_author, + $this->_title, + $this->_author, + $this->_title + ); + } + } + + // }}} + // {{{ function _endDocument($type, $cdata) + + /** + * @param string + * @param string + * @return string + * @access private + */ + function _endDocument($type, $cdata) { + if (!$this->_secondPass) { + $this->_endSection($type); + + $this->_secondPass = true; + + $cdata = sprintf( + '%s</%s>', + + $cdata, + $type + ); + } else { + $cdata = $cdata . '</body></html>'; + } + + return array( + $cdata, + false + ); + } + + // }}} // {{{ function _startSection($type, $id) /** @@ -980,6 +1042,7 @@ switch ($type) { case 'article': + case 'book': case 'chapter': case 'section': { $this->_currentSectionNumber = ''; @@ -1050,6 +1113,7 @@ switch ($type) { case 'article': + case 'book': case 'chapter': case 'section': { $this->_sections[$type]['open']--;

« previous php.pear.cvs (#6789) next »