philip Thu May 10 07:31:56 2007 UTC
Modified files: /livedocs mkindex.php style_mapping.php Log: Implement format_acronym() for acronym tags (for phpdoc) This also closes bug #36448 http://cvs.php.net/viewvc.cgi/livedocs/mkindex.php?r1=1.48&r2=1.49&diff_format=u Index: livedocs/mkindex.php diff -u livedocs/mkindex.php:1.48 livedocs/mkindex.php:1.49 --- livedocs/mkindex.php:1.48 Wed Apr 18 07:26:45 2007 +++ livedocs/mkindex.php Thu May 10 07:31:56 2007 @@ -19,7 +19,7 @@ // | construct an index | // +----------------------------------------------------------------------+ // -// $Id: mkindex.php,v 1.48 2007/04/18 07:26:45 bjori Exp $ +// $Id: mkindex.php,v 1.49 2007/05/10 07:31:56 philip Exp $ /* just to be on the safe side */ @@ -621,6 +621,47 @@ sqlite_exec($idc, $tbl_data); sqlite_close($idc); +/* Build the acronym tags table + TODO: config path setting (plugins) to allow non phpdoc use +*/ +if ($BUILDTYPE === 'phpdoc' && extension_loaded('simplexml')) { + + echo 'Log: Acronym tags creation has been initialized: ', date('r'), "\n"; + + $path = $DOCS . '/entities/acronyms.xml'; + if (is_readable($path)) { + + $xml = simplexml_load_string(file_get_contents($path)); + + if ($xml) { + + $tbl_acronyms = " + CREATE TABLE acronyms ( + acronym TEXT PRIMARY KEY, + descr TEXT + );"; + + sqlite_exec($idx, $tbl_acronyms); + sqlite_exec($idx, 'BEGIN TRANSACTION'); + + $qry = ''; + foreach ($xml->variablelist->varlistentry as $c) { + $term = sqlite_escape_string(trim($c->term)); + $desc = sqlite_escape_string(trim($c->listitem->simpara)); + $qry .= "INSERT INTO acronyms VALUES ('$term', '$desc');"; + } + + sqlite_exec($idx, $qry); + sqlite_exec($idx, 'COMMIT'); + + } else { + echo "Error: Unable to parse the acronym tags\n"; + } + } else { + echo "Error: The acronyms tag file ($path) is not readable\n"; + } +} + exit; ?> http://cvs.php.net/viewvc.cgi/livedocs/style_mapping.php?r1=1.32&r2=1.33&diff_format=u Index: livedocs/style_mapping.php diff -u livedocs/style_mapping.php:1.32 livedocs/style_mapping.php:1.33 --- livedocs/style_mapping.php:1.32 Wed Jul 6 16:17:31 2005 +++ livedocs/style_mapping.php Thu May 10 07:31:56 2007 @@ -18,11 +18,11 @@ // | Helper functions for formatting elements | // +----------------------------------------------------------------------+ // -// $Id: style_mapping.php,v 1.32 2005/07/06 16:17:31 iliaa Exp $ +// $Id: style_mapping.php,v 1.33 2007/05/10 07:31:56 philip Exp $ // almost XPATH.. ;-) $map = array( - 'acronym' => 'acronym', + 'acronym' => 'format_acronym', 'appendix/title' => 'h1', 'author' => 'format_name', 'authorgroup' => 'format_authorgroup', @@ -108,6 +108,20 @@ 'xref' => 'format_link', ); +function format_acronym($node) +{ + global $idx; + + $name = $node->content; + $q = sqlite_single_query($idx, " SELECT descr + FROM acronyms + WHERE acronym = '" . sqlite_escape_string($name) . "'" + ); + if (!$q) { + $q = $name; + } + return '<acronym title="'. $q .'">'. $name . '</acronym>'; +} function format_authorgroup($node) {