wez Fri May 7 09:32:58 2004 EDT
Modified files: /livedocs livedoc.php Log: Bind entities in node descriptions for the generated function list shown on ref.XXX pages. Patch by Nuno http://cvs.php.net/diff.php/livedocs/livedoc.php?r1=1.102&r2=1.103&ty=u Index: livedocs/livedoc.php diff -u livedocs/livedoc.php:1.102 livedocs/livedoc.php:1.103 --- livedocs/livedoc.php:1.102 Wed May 5 04:49:43 2004 +++ livedocs/livedoc.php Fri May 7 09:32:58 2004 @@ -18,7 +18,7 @@ // | Generate an HTML version of a phpdoc/docbook page on the fly | // +----------------------------------------------------------------------+ // -// $Id: livedoc.php,v 1.102 2004/05/05 08:49:43 wez Exp $ +// $Id: livedoc.php,v 1.103 2004/05/07 13:32:58 wez Exp $ define('LIVEDOC_SOURCE', dirname(__FILE__)); include LIVEDOC_SOURCE . '/common.php'; @@ -322,6 +322,41 @@ } } +/***************************************************************************** + * Search & Replace entities + */ +function bind_entities($data) { + + global $idx; + $entities = array(); + $sanity = 0; + + do { + $ent_count = preg_match_all('/&([a-zA-Z0-9.-]+);/sm', $data, $matches); + if ($ent_count == 0) { + break; + } + + /* now collect their values */ + $entities_to_find = array_unique($matches[1]); + $ents = implode("','", $entities_to_find); + $q = sqlite_query($idx, "SELECT entid, value from ents where entid in ('" . $ents . "')"); + if (!$q) { + break; + } + + while ($r = sqlite_fetch_array($q, SQLITE_NUM)) { + $entities['&' . $r[0] . ';'] = $r[1]; + } + + /* substitute */ + $data = strtr($data, $entities); + + } while ($sanity++ < 5); + + return $data; +} + /***************************************************************************** * Helper functions for transformation @@ -337,7 +372,6 @@ $replace[] = html_entity_decode($item); } - $sanity = 0; $lang_rev = 0; $data = @file_get_contents($filename); @@ -360,30 +394,8 @@ /* strip comments */ $data = preg_replace('@<!--\s+.*\s-->@Usm', '', $data); - /* list the entities that are required */ - $entities = array(); - do { - $ent_count = preg_match_all('/&([a-zA-Z0-9.-]+);/sm', $data, $matches); - if ($ent_count == 0) { - break; - } - - /* now collect their values */ - $entities_to_find = array_unique($matches[1]); - $ents = implode("','", $entities_to_find); - $q = sqlite_query($idx, "SELECT entid, value from ents where entid in ('" . $ents . "')"); - if (!$q) { - break; - } - - while ($r = sqlite_fetch_array($q, SQLITE_NUM)) { - $entities['&' . $r[0] . ';'] = $r[1]; - } - - /* substitute */ - $data = strtr($data, $entities); - - } while ($sanity++ < 5); + /* Replace entities */ + $data = bind_entities($data); /* catch any undefined entities */ if ($included) { @@ -514,7 +526,7 @@ if($parts[3] == 'class') { $title = ' - ' . lookup_title($id) . ' class'; } else { - $title = ' - ' . sqlite_single_query($GLOBALS['idx'], "SELECT descr from toc where docbook_id='$id'"); + $title = ' - ' . bind_entities(sqlite_single_query($GLOBALS['idx'], "SELECT descr from toc where docbook_id='$id'")); } return "<div class=\"function_link\"><$stag>$func_name</$etag>$title</div>";