cvs: phd /formats xhtml.php /include PhDHelper.class.php /include/langs en.xml /themes/php phpdotnet.php

From: Date: Mon, 01 Oct 2007 13:48:53 +0000
Subject: cvs: phd /formats xhtml.php /include PhDHelper.class.php /include/langs en.xml /themes/php phpdotnet.php
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-115@lists.php.net to get a copy of this message
bjori Mon Oct 1 13:48:53 2007 UTC Added files: /phd/include/langs en.xml Modified files: /phd/formats xhtml.php /phd/include PhDHelper.class.php /phd/themes/php phpdotnet.php Log: Add autogenerated text support for; TOC, warning, note, caution & tip http://cvs.php.net/viewvc.cgi/phd/formats/xhtml.php?r1=1.32&r2=1.33&diff_format=u Index: phd/formats/xhtml.php diff -u phd/formats/xhtml.php:1.32 phd/formats/xhtml.php:1.33 --- phd/formats/xhtml.php:1.32 Sun Sep 30 18:38:47 2007 +++ phd/formats/xhtml.php Mon Oct 1 13:48:52 2007 @@ -1,5 +1,5 @@ <?php -/* $Id: xhtml.php,v 1.32 2007/09/30 18:38:47 bjori Exp $ */ +/* $Id: xhtml.php,v 1.33 2007/10/01 13:48:52 bjori Exp $ */ class XHTMLPhDFormat extends PhDFormat { protected $elementmap = array( /* {{{ */ @@ -39,7 +39,7 @@ ), 'calloutlist' => 'format_calloutlist', 'callout' => 'format_callout', - 'caution' => 'div', + 'caution' => 'format_admonition', 'citerefentry' => 'span', 'classname' => array( /* DEFAULT */ 'span', @@ -190,7 +190,7 @@ 'tfoot' => 'format_th', 'thead' => 'format_th', 'tgroup' => 'format_tgroup', - 'tip' => 'div', + 'tip' => 'format_admonition', 'title' => array( /* DEFAULT */ 'h1', 'example' => 'format_bold_paragraph', @@ -223,7 +223,7 @@ 'fieldsynopsis' => 'format_varname', ), 'void' => 'format_void', - 'warning' => 'div', + 'warning' => 'format_admonition', 'year' => 'span', 'quote' => 'format_quote', 'qandaset' => 'div', @@ -603,9 +603,15 @@ } return "</tt></b>"; } - public function format_note($open, $name, $attrs) { + public function format_admonition($open, $name, $attrs, $props) { if ($open) { - return '<blockquote><p>'; + return '<div class="'. $name. '">' .$this->admonition_title($name, $props["lang"]); + } + return "</div>"; + } + public function format_note($open, $name, $attrs, $props) { + if ($open) { + return '<blockquote><p>'.$this->admonition_title("note", $props["lang"]). ': '; } return "</p></blockquote>"; } @@ -724,6 +730,9 @@ return "</td>"; } + public function admonition_title($title, $lang) { + return sprintf('<b class="%s">%s</b>', strtolower($title), $this->autogen($title, $lang)); + } } /* http://cvs.php.net/viewvc.cgi/phd/include/PhDHelper.class.php?r1=1.4&r2=1.5&diff_format=u Index: phd/include/PhDHelper.class.php diff -u phd/include/PhDHelper.class.php:1.4 phd/include/PhDHelper.class.php:1.5 --- phd/include/PhDHelper.class.php:1.4 Fri Aug 10 20:18:21 2007 +++ phd/include/PhDHelper.class.php Mon Oct 1 13:48:53 2007 @@ -1,10 +1,11 @@ <?php -/* $Id: PhDHelper.class.php,v 1.4 2007/08/10 20:18:21 bjori Exp $ */ +/* $Id: PhDHelper.class.php,v 1.5 2007/10/01 13:48:53 bjori Exp $ */ class PhDHelper { private $IDs = array(); /* abstract */ protected $elementmap = array(); /* abstract */ protected $textmap = array(); + private static $autogen = array(); public function __construct(array $IDs) { $this->IDs = $IDs; @@ -29,6 +30,33 @@ final public function getTextMap() { return $this->textmap; } + final public function autogen($text, $lang) { + if (isset(PhDHelper::$autogen[$lang])) { + return PhDHelper::$autogen[$lang][$text]; + } + + $filename = dirname(__FILE__) ."/langs/$lang.xml"; + $r = new XMLReader; + if (!$r->open($filename)) { + throw new Exception("Could not open $filename"); + } + $autogen = array(); + while ($r->read()) { + if ($r->nodeType != XMLReader::ELEMENT) { + continue; + } + if ($r->name == "term") { + $r->read(); + $k = $r->value; + $autogen[$k] = ""; + } else if ($r->name == "simpara") { + $r->read(); + $autogen[$k] = $r->value; + } + } + PhDHelper::$autogen[$lang] = $autogen; + return PhDHelper::$autogen[$lang][$text]; + } } /* http://cvs.php.net/viewvc.cgi/phd/themes/php/phpdotnet.php?r1=1.21&r2=1.22&diff_format=u Index: phd/themes/php/phpdotnet.php diff -u phd/themes/php/phpdotnet.php:1.21 phd/themes/php/phpdotnet.php:1.22 --- phd/themes/php/phpdotnet.php:1.21 Sun Sep 30 21:32:51 2007 +++ phd/themes/php/phpdotnet.php Mon Oct 1 13:48:53 2007 @@ -1,5 +1,5 @@ <?php -/* $Id: phpdotnet.php,v 1.21 2007/09/30 21:32:51 bjori Exp $ */ +/* $Id: phpdotnet.php,v 1.22 2007/10/01 13:48:53 bjori Exp $ */ class phpdotnet extends PhDHelper { protected $elementmap = array( @@ -231,7 +231,7 @@ } return false; } - public function format_container_chunk($open, $name, $attrs) { + public function format_container_chunk($open, $name, $attrs, $props) { $this->CURRENT_ID = $id = $attrs[PhDReader::XMLNS_XML]["id"]; if ($open) { if ($name != "reference") { @@ -239,7 +239,7 @@ if (!count($chunks)) { return "<div>"; } - $content = '<ul class="chunklist chunklist_'.$name.'">'; + $content = '<h2>'.$this->autogen("toc", $props["lang"]). '</h2><ul class="chunklist chunklist_'.$name.'">'; foreach($chunks as $chunkid => $junk) { $content .= sprintf('<li><a href="%s%s.%s">%s</a></li>', $this->chunked ? "" : "#", $chunkid, $this->ext, PhDHelper::getDescription($chunkid, true)); } @@ -253,7 +253,7 @@ if ($name == "reference") { $chunks = PhDHelper::getChildren($id); if (count($chunks) > 1) { - $content = '<ul class="chunklist chunklist_reference">'; + $content = '<h2>'.$this->autogen("toc", $props["lang"]). '</h2><ul class="chunklist chunklist_reference">'; foreach($chunks as $chunkid => $junk) { $content .= sprintf('<li><a href="%s%s.%s">%s</a> — %s</li>', $this->chunked ? "" : "#", $chunkid, $this->ext, PhDHelper::getDescription($chunkid, false), PhDHelper::getDescription($chunkid, true)); } http://cvs.php.net/viewvc.cgi/phd/include/langs/en.xml?view=markup&rev=1.1 Index: phd/include/langs/en.xml +++ phd/include/langs/en.xml <?xml version="1.0" encoding="UTF-8" ?> <section xml:id="autogen" xml:lang="en"> <title>Autogenerated text</title> <variablelist> <varlistentry> <term>toc</term> <listitem> <simpara>Table of Contents</simpara> </listitem> </varlistentry> <varlistentry> <term>warning</term> <listitem> <simpara>Warning</simpara> </listitem> </varlistentry> <varlistentry> <term>note</term> <listitem> <simpara>Note</simpara> </listitem> </varlistentry> <varlistentry> <term>caution</term> <listitem> <simpara>Caution</simpara> </listitem> </varlistentry> <varlistentry> <term>tip</term> <listitem> <simpara>Tip</simpara> </listitem> </varlistentry> </variablelist> </section>

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