[PHP-DOC] cvs: livedocs / livedoc_funcs.php
bjori Mon Jun 25 15:21:25 2007 UTC Modified files: /livedocs livedoc_funcs.php Log: Let phpweb handle the printing of the notes http://cvs.php.net/viewvc.cgi/livedocs/livedoc_funcs.php?r1=1.32r2=1.33diff_format=u Index: livedocs/livedoc_funcs.php diff -u livedocs/livedoc_funcs.php:1.32 livedocs/livedoc_funcs.php:1.33 --- livedocs/livedoc_funcs.php:1.32 Tue Jun 19 23:22:52 2007 +++ livedocs/livedoc_funcs.php Mon Jun 25 15:21:25 2007 @@ -285,6 +285,11 @@ function format_user_notes($id) { + // Let phpweb handle the notes + if (defined(PHPNET)) { + return ; + } + $notes = sqlite_array_query($GLOBALS['NOTESDB'], SELECT id, xwhen, who, note from notes where sect='$id' order by xwhen desc); if (empty($notes)) return '';
[PHP-DOC] cvs: livedocs / livedoc_funcs.php
iliaa Wed Sep 14 18:02:39 2005 EDT Modified files: /livedocs livedoc_funcs.php Log: Place extension's function list at the top of the nav bar. # Credit and Thanks goes out to Sean http://cvs.php.net/diff.php/livedocs/livedoc_funcs.php?r1=1.30r2=1.31ty=u Index: livedocs/livedoc_funcs.php diff -u livedocs/livedoc_funcs.php:1.30 livedocs/livedoc_funcs.php:1.31 --- livedocs/livedoc_funcs.php:1.30 Thu Jul 14 15:05:38 2005 +++ livedocs/livedoc_funcs.php Wed Sep 14 18:02:38 2005 @@ -24,9 +24,6 @@ if (!defined('NAV_END')) { define('NAV_END', /table\n); } -if (!defined('NAV_CHILDREN_EMBEDED')) { - define('NAV_CHILDREN_EMBEDED', false); -} if (!function_exists('nav_item')) { function nav_item($data, $class ) { return trtd class='$class'$data/td/tr\n; @@ -39,7 +36,8 @@ function do_nav($idx, $fb_idx, $lang, $current_page, $nav, $children) { $children = array(); - $nav = NAV_START; + $nav_start = NAV_START; + $nav = ''; /* Get the fileinfo for the reference */ $current_page = sqlite_escape_string($current_page); @@ -61,36 +59,29 @@ if (($r = sqlite_single_query($idx, SELECT path FROM toc WHERE docbook_id = '$current_page' LIMIT 1))) { $path = explode(,, $r); foreach ($path as $item) { - $nav .= do_nav_line($item, $head_class, $current_page, $lang, $dummy); + $nav_start .= do_nav_line($item, $head_class, $current_page, $lang, $dummy); $last_item = $item; $head_class = 'header up'; } } else { - $nav .= do_nav_line(ROOT_NODE, 'up', $current_page, $lang, $dummy); + $nav_start .= do_nav_line(ROOT_NODE, 'up', $current_page, $lang, $dummy); } $after_child_class = ''; /* With $last_item we're going to show all brothers */ $r = (array) sqlite_single_query($idx, SELECT docbook_id FROM toc WHERE parent_docbook_id = '$last_item' ORDER BY id); foreach ($r as $val) { - $nav .= do_nav_line($val, 'down'.$after_child_class, $current_page, $lang, $dummy); - $after_child_class = ''; - /* Include the children here */ - if (NAV_CHILDREN_EMBEDED $current_page == $val) { - do_nav_children($idx, $val, $lang, $current_page, $nav, $children); + if ($current_page == $val) { + $nav_start .= do_nav_line($current_page, 'down active', $current_page, $lang, $dummy); + do_nav_children($idx, $val, $lang, $current_page, $nav_start, $children); } - - } - - /* And finally all children, but only if $current_page != $last_item -* because showing the same thing twice makes no sense */ - if ( !NAV_CHILDREN_EMBEDED $current_page != $last_item) { - do_nav_children($idx, $val, $lang, $current_page, $nav, $children); + $nav .= do_nav_line($val, 'down'.$after_child_class, $current_page, $lang, $dummy); + $after_child_class = ''; + } - - $nav .= NAV_END; + $nav = $nav_start . $nav . NAV_END; return $tr[0]; }
[PHP-DOC] cvs: livedocs / livedoc_funcs.php mkindex.php
iliaa Fri Jun 17 18:10:18 2005 EDT Modified files: /livedocs livedoc_funcs.php mkindex.php Log: Added some warnings on common errors. Fixed bug #33358 (Use TITLEABBREV in table of contents). http://cvs.php.net/diff.php/livedocs/livedoc_funcs.php?r1=1.26r2=1.27ty=u Index: livedocs/livedoc_funcs.php diff -u livedocs/livedoc_funcs.php:1.26 livedocs/livedoc_funcs.php:1.27 --- livedocs/livedoc_funcs.php:1.26 Thu Feb 10 07:23:32 2005 +++ livedocs/livedoc_funcs.php Fri Jun 17 18:10:16 2005 @@ -160,16 +160,20 @@ $nolink = FALSE; - $title = lookup_title($item); - $fulltitle = $title; - if (NAV_TRUNCATE isset($title{NAV_TRUNCATE}) ) { - $ftitle = title='$title'; - $title = substr($title, 0, NAV_TRUNCATE-3). '...'; + list($fulltitle, $title) = lookup_title($item, 1); + + if ($title) { /* got abbreviated title */ + $ftitle = title='$fulltitle'; + } else if (NAV_TRUNCATE isset($fulltitle{NAV_TRUNCATE})) { + $ftitle = title='$fulltitle'; + $title = substr($fulltitle, 0, NAV_TRUNCATE-3). '...'; } else { $ftitle = ; - if (!$title) { + if (!$fulltitle) { $title = $item . ' [?]'; $nolink = TRUE; + } else { + $title = $fulltitle; } } @@ -316,7 +320,7 @@ return $inner . /div; } -function lookup_title($nodeid) +function lookup_title($nodeid, $get_abbr=0) { static $ids = array(); @@ -335,18 +339,23 @@ } /* See if the title lookup is in the cache already */ - if (isset($ids[$nodeid])) { - return $ids[$nodeid]; + if (!isset($ids[$nodeid])) { + /* It's not, so we try to resolve it from the DB */ + $safeid = sqlite_escape_string($nodeid); + if (!($ids[$nodeid] = sqlite_array_query($GLOBALS['idx'], SELECT title, abbrtitle from idents where id='$safeid', SQLITE_NUM)) isset($GLOBALS['fb_idx'])) { + $ids[$nodeid] = sqlite_array_query($GLOBALS['fb_idx'], SELECT title, abbrtitle from idents where id='$safeid', SQLITE_NUM); + } } - /* It's not, so we try to resolve it from the DB */ - $safeid = sqlite_escape_string($nodeid); - if (($ids[$nodeid] = sqlite_single_query($GLOBALS['idx'], SELECT title from idents where id='$safeid'))) { - return $ids[$nodeid]; - } else if (isset($GLOBALS['fb_idx']) ($ids[$nodeid] = sqlite_single_query($GLOBALS['fb_idx'], SELECT title from idents where id='$safeid'))) { - return $ids[$nodeid]; + if (isset($ids[$nodeid][0])) { + if ($get_abbr) { + return $ids[$nodeid][0]; + } else { + return $ids[$nodeid][0][0]; + } } - return null; + + return $get_abbr ? array('','') : null; } /* transform an entity name of the form reference..functions.ID http://cvs.php.net/diff.php/livedocs/mkindex.php?r1=1.40r2=1.41ty=u Index: livedocs/mkindex.php diff -u livedocs/mkindex.php:1.40 livedocs/mkindex.php:1.41 --- livedocs/mkindex.php:1.40 Wed Jun 15 21:11:01 2005 +++ livedocs/mkindex.phpFri Jun 17 18:10:16 2005 @@ -19,23 +19,23 @@ // | construct an index | // +--+ // -// $Id: mkindex.php,v 1.40 2005/06/16 01:11:01 iliaa Exp $ +// $Id: mkindex.php,v 1.41 2005/06/17 22:10:16 iliaa Exp $ /* just to be on the safe side */ set_time_limit(0); set_magic_quotes_runtime(0); +if ($argc != 5 || !is_dir($argv[1]) || !is_dir($argv[1] . DIRECTORY_SEPARATOR . $argv[2])) { + echo Usage: mkindex.php /path/to/docs lang tmp-dir build-type\n; + exit(1); +} + $DOCS = $argv[1]; $LANG = $argv[2]; $TMPDIR = $argv[3]; $BUILDTYPE = $argv[4]; -if (!is_dir($DOCS) || !is_dir($DOCS . DIRECTORY_SEPARATOR . $LANG)) { - echo Usage: mkindex.php /path/to/docs lang tmp-dir build-type\n; - exit(1); -} - require 'mk_' . $BUILDTYPE . '.php'; function entity_replace($data) { @@ -54,12 +54,15 @@ return ''; } +$titles = array('TITLE'=1, 'REFNAME'=2, 'QANDAENTRY'=2, 'VARLISTENTRY'=2, 'TITLEABBREV' = 2); + class DocBookXMLFileParser { var $fileid = false; var $last_id = false; var $cdata = null; var $data = ''; var $title_depth = -1; + var $incomp = 0; function DocBookXMLFileParser($filename, $rel, $parser) { $this-fileid = $GLOBALS['fileid']; @@ -87,13 +90,11 @@ } function start_elem($parser, $name, $attrs) { - static $titles = array('TITLE'=1, 'REFNAME'=1, 'QANDAENTRY'=1, 'VARLISTENTRY'=1); -
[PHP-DOC] cvs: livedocs / livedoc_funcs.php
iliaa Fri Jun 17 22:03:20 2005 EDT Modified files: /livedocs livedoc_funcs.php Log: Fixed bug #30440 #33037 http://cvs.php.net/diff.php/livedocs/livedoc_funcs.php?r1=1.27r2=1.28ty=u Index: livedocs/livedoc_funcs.php diff -u livedocs/livedoc_funcs.php:1.27 livedocs/livedoc_funcs.php:1.28 --- livedocs/livedoc_funcs.php:1.27 Fri Jun 17 18:10:16 2005 +++ livedocs/livedoc_funcs.php Fri Jun 17 22:03:19 2005 @@ -278,8 +278,8 @@ $data = preg_replace('@(\\?xml.*\\?)@U', '\\1div', $data) . '/div'; } } else { - $data = preg_replace('/([a-zA-Z0-9._-]+);/sm', 'phpdoc_include ref=\\1/', $data); - } + $data = preg_replace('/([a-zA-Z0-9._-]{5,});/sm', 'phpdoc_include ref=\\1/', $data); + } $page = new DocBookToHTML($data);
Re: [PHP-DOC] cvs: livedocs / livedoc_funcs.php mkindex.php
Ilia Alshanetsky wrote: iliaa Fri Jun 17 18:10:18 2005 EDT Modified files: /livedocs livedoc_funcs.php mkindex.php Log: Added some warnings on common errors. Fixed bug #33358 (Use TITLEABBREV in table of contents). Ilia, It may not have been this one, but one of your patches, tonight, broke the way titles or entities are captured.. See http://livedocs.phpdoc.info/index.php?l=enq=manual Notice all of the Title [?] I checked other livedocs (including yours) -- it's not just me. S
[PHP-DOC] cvs: livedocs / livedoc_funcs.php
jacques Thu Feb 10 07:23:32 2005 EDT Modified files: /livedocs livedoc_funcs.php Log: Committing http://www.powertrip.co.za/livedocs/viewpatch.php?patch=6 http://cvs.php.net/diff.php/livedocs/livedoc_funcs.php?r1=1.25r2=1.26ty=u Index: livedocs/livedoc_funcs.php diff -u livedocs/livedoc_funcs.php:1.25 livedocs/livedoc_funcs.php:1.26 --- livedocs/livedoc_funcs.php:1.25 Wed Feb 9 17:48:14 2005 +++ livedocs/livedoc_funcs.php Thu Feb 10 07:23:32 2005 @@ -427,7 +427,7 @@ return ''; } -$GLOBALS['special'] = array('gt' = 1,'lt' = 1,'quot' = 1,'amp' = 1); +$GLOBALS['special'] = array('gt' = 1,'lt' = 1,'quot' = 1,'amp' = 1,'apos' = 1); function handle_include($node) {
Re: [PHP-DOC] cvs: livedocs / livedoc_funcs.php
+// turn urls into links +$the_note = preg_replace( + /((mailto|http|ftp|nntp|news):.+?)(gt;|\\s|\\)|\|\\.\\s||$)/, +a href=\\\1\\\1/a\\3, +$the_note +); + A slightly optimized version would be: $the_note = preg_replace( '/((?:mailto|http|ftp|nntp|news):.+?)(gt;|\s|\)||\.\s||$)/S', 'a href=\1\1/a\2', $the_note ); Nuno P.S.: BTW, thanks for reviewing some livedocs' patches.
Re: [PHP-DOC] cvs: livedocs / livedoc_funcs.php
Nuno Lopes wrote: A slightly optimized version would be: The one I submitted was copied directly from php-web, but I have no problem with the optimization, once tested. P.S.: BTW, thanks for reviewing some livedocs' patches. Yes, thanks. Ilia also said he'd take a look, later today. S
[PHP-DOC] cvs: livedocs / livedoc_funcs.php
iliaa Wed Feb 9 14:00:00 2005 EDT Modified files: /livedocs livedoc_funcs.php Log: Clean up CS Fixed bug #30319 http://cvs.php.net/diff.php/livedocs/livedoc_funcs.php?r1=1.18r2=1.19ty=u Index: livedocs/livedoc_funcs.php diff -u livedocs/livedoc_funcs.php:1.18 livedocs/livedoc_funcs.php:1.19 --- livedocs/livedoc_funcs.php:1.18 Wed Feb 9 13:22:55 2005 +++ livedocs/livedoc_funcs.php Wed Feb 9 13:59:59 2005 @@ -259,13 +259,13 @@ // turn urls into links $the_note = preg_replace( - /((mailto|http|ftp|nntp|news):.+?)(gt;|\\s|\\)|\|\\.\\s||$)/, -a href=\\\1\\\1/a\\3, -$the_note + /((mailto|http|ftp|nntp|news):.+?)(gt;|\\s|\\)|\|\\.\\s||$)/, + a href=\\\1\\\1/a\\3, + $the_note ); $inner .= 'div class=usernotediv class=noteheaderspan class=user'.$note['who']. - '/spanbr /span class=when'.$date.'/span/div'.$the_note.'/div'; + '(#'.$note['id'].')/spanbr /span class=when'.$date.'/span/div'.$the_note.'/div'; } return $inner . /div;
[PHP-DOC] cvs: livedocs / livedoc_funcs.php
iliaa Wed Feb 9 14:47:38 2005 EDT Modified files: /livedocs livedoc_funcs.php Log: Fixed bug #30455 http://cvs.php.net/diff.php/livedocs/livedoc_funcs.php?r1=1.19r2=1.20ty=u Index: livedocs/livedoc_funcs.php diff -u livedocs/livedoc_funcs.php:1.19 livedocs/livedoc_funcs.php:1.20 --- livedocs/livedoc_funcs.php:1.19 Wed Feb 9 13:59:59 2005 +++ livedocs/livedoc_funcs.php Wed Feb 9 14:47:38 2005 @@ -210,8 +210,9 @@ $file_revision .= $matches[0]; } - /* strip comments */ - $data = preg_replace('@!--\s+.*\s--@Usm', '', $data); + /* strip comments (Ilia: it seems pointless) + $data = preg_replace('@!--\s+.*\s--@Usm', '', $data); + */ /* Replace entities */ $data = str_replace($search, $replace, bind_entities($data));
[PHP-DOC] cvs: livedocs / livedoc_funcs.php
iliaa Wed Feb 9 15:03:44 2005 EDT Modified files: /livedocs livedoc_funcs.php Log: Fixed bug #30204 http://cvs.php.net/diff.php/livedocs/livedoc_funcs.php?r1=1.20r2=1.21ty=u Index: livedocs/livedoc_funcs.php diff -u livedocs/livedoc_funcs.php:1.20 livedocs/livedoc_funcs.php:1.21 --- livedocs/livedoc_funcs.php:1.20 Wed Feb 9 14:47:38 2005 +++ livedocs/livedoc_funcs.php Wed Feb 9 15:03:43 2005 @@ -11,13 +11,35 @@ include LIVEDOC_SOURCE . '/handlers.php'; include LIVEDOC_SOURCE . '/themes/' . THEME_NAME . '/html_format.php'; +/* if THEME_NAME/html_format.php doesn't redefine these */ +if (!defined('NAV_TRUNCATE')) { + define('NAV_TRUNCATE', 25); +} +if (!defined('NAV_SPACE')) { + define('NAV_SPACE', 'nbsp;'); +} +if (!defined('NAV_START')) { + define('NAV_START', 'table class=nav border=0 cellpadding=0 cellspacing=0 width=150'); +} +if (!defined('NAV_END')) { + define('NAV_END', /table\n); +} +if (!defined('NAV_CHILDREN_EMBEDED')) { + define('NAV_CHILDREN_EMBEDED', false); +} +if (!function_exists('nav_item')) { + function nav_item($data, $class ) { + return trtd class='$class'$data/td/tr\n; + } +} + /* * Helper functions for navigation */ function do_nav($idx, $fb_idx, $lang, $current_page, $nav, $children) { $children = array(); - $nav = table class='nav' border='0' cellpadding='0' cellspacing='0' width='150'; + $nav = NAV_START; /* Get the fileinfo for the reference */ $tr = sqlite_array_query($idx, SELECT title, filename, idents.fileid, files.dirid from idents left join files where id='$current_page' and idents.fileid=files.fileid, SQLITE_NUM); @@ -33,37 +55,53 @@ /* Get parent ID and child IDs */ /* - first we get the first three parts of the path */ $last_item = 'manual'; + $head_class = 'header home'; if (($r = sqlite_single_query($idx, SELECT path FROM toc WHERE docbook_id = '$current_page' LIMIT 1))) { $path = explode(,, $r); foreach ($path as $item) { - $nav .= do_nav_line($item, 'up', $current_page, $lang, $dummy); + $nav .= do_nav_line($item, $head_class, $current_page, $lang, $dummy); $last_item = $item; + $head_class = 'header up'; } } else { $nav .= do_nav_line('manual', 'up', $current_page, $lang, $dummy); } + $after_child_class = ''; /* With $last_item we're going to show all brothers */ $r = (array) sqlite_single_query($idx, SELECT docbook_id FROM toc WHERE parent_docbook_id = '$last_item' ORDER BY id); foreach ($r as $val) { - $nav .= do_nav_line($val, 'down', $current_page, $lang, $dummy); + $nav .= do_nav_line($val, 'down'.$after_child_class, $current_page, $lang, $dummy); + $after_child_class = ''; + + /* Include the children here */ + if (NAV_CHILDREN_EMBEDED $current_page == $val) { + do_nav_children($idx, $val, $lang, $current_page, $nav, $children); + } + } /* And finally all children, but only if $current_page != $last_item * because showing the same thing twice makes no sense */ - if ($current_page != $last_item $current_page != 'manual') { - $r = (array) sqlite_single_query($idx, SELECT docbook_id FROM toc WHERE parent_docbook_id = '$current_page' ORDER BY id); - foreach ($r as $val) { - $nav .= do_nav_line($val, 'downdown', $current_page, $lang, $title); - $children[$val] = $title; - } + if ( !NAV_CHILDREN_EMBEDED $current_page != $last_item) { + do_nav_children($idx, $val, $lang, $current_page, $nav, $children); } - $nav .= /table\n; + + $nav .= NAV_END; return $tr[0]; } +function do_nav_children($idx, $parent, $lang, $current_page, $nav, $children) { + if ($current_page != 'manual' ) { + $rsub = (array) sqlite_single_query($idx, SELECT docbook_id FROM toc WHERE parent_docbook_id = '$current_page' ORDER BY id); + foreach ($rsub as $valsub) { + $nav .= do_nav_line($valsub, 'downdown', $current_page, $lang, $title); + $children[$parent] = $title; + } + } +} function generate_url_for_id($lang, $ref) { @@ -124,9 +162,9 @@ $title = lookup_title($item); $fulltitle = $title; - if (isset($title{25})) { + if (NAV_TRUNCATE isset($title{NAV_TRUNCATE}) ) { $ftitle = title='$title'; - $title = substr($title, 0, 22). '...'; + $title = substr($title, 0,
[PHP-DOC] cvs: livedocs / livedoc_funcs.php style_mapping.php
iliaa Wed Feb 9 15:31:57 2005 EDT Modified files: /livedocs style_mapping.php livedoc_funcs.php Log: Don't handle user notes as if they were ALL php code. http://cvs.php.net/diff.php/livedocs/style_mapping.php?r1=1.23r2=1.24ty=u Index: livedocs/style_mapping.php diff -u livedocs/style_mapping.php:1.23 livedocs/style_mapping.php:1.24 --- livedocs/style_mapping.php:1.23 Wed Feb 9 13:56:00 2005 +++ livedocs/style_mapping.php Wed Feb 9 15:31:57 2005 @@ -18,7 +18,7 @@ // | Helper functions for formatting elements | // +--+ // -// $Id: style_mapping.php,v 1.23 2005/02/09 18:56:00 iliaa Exp $ +// $Id: style_mapping.php,v 1.24 2005/02/09 20:31:57 iliaa Exp $ // almost XPATH.. ;-) $map = array( @@ -301,19 +301,13 @@ return 'a class=phpfunc href=' . $link . '' . $matches[1] . '/a/span' . $matches[2]; } -function format_listing($node) +function highlight_php_code($str) { - $content = trim($node-content); - if (substr($content, 0, 5) == '?php') { - $node-attributes['role'] = 'php'; - } - if (!isset($node-attributes['role'])) { - $node-attributes['role'] = ''; + if (is_array($str)) { + $str = $str[0]; } - switch ($node-attributes['role']) { - case 'php': - $content = str_replace( + $tmp = str_replace( array( 'nbsp;', 'font color=',// for PHP 4 @@ -330,11 +324,31 @@ \nnbsp;, ' nbsp;' ), - highlight_string($content, true) - ); + highlight_string($str, true) + ); + + $tmp = preg_replace_callback('{([\w_]+)\s*/span(\s*span\s+class=keyword\s*\()}m', 'format_listing_hyperlink_function', $tmp); + return sprintf('div class=phpcode%s%s/div', LTR, $tmp); +} + +function format_listing($node) +{ + $content = trim($node-content); + if (substr($content, 0, 5) == '?php') { + $node-attributes['role'] = 'php'; + } + if (!isset($node-attributes['role'])) { + $node-attributes['role'] = ''; + } - $content = preg_replace_callback('{([\w_]+)\s*/span(\s*span\s+class=keyword\s*\()}m', 'format_listing_hyperlink_function', $content); + switch ($node-attributes['role']) { + case 'php': + $content = highlight_php_code($content); + break; + case 'note': + $content = preg_replace_callback('!(\(\?|\?php).+\?\)!msU', 'highlight_php_code', $content); break; + case 'asp': case 'shell': case 'html': http://cvs.php.net/diff.php/livedocs/livedoc_funcs.php?r1=1.21r2=1.22ty=u Index: livedocs/livedoc_funcs.php diff -u livedocs/livedoc_funcs.php:1.21 livedocs/livedoc_funcs.php:1.22 --- livedocs/livedoc_funcs.php:1.21 Wed Feb 9 15:03:43 2005 +++ livedocs/livedoc_funcs.php Wed Feb 9 15:31:57 2005 @@ -299,7 +299,7 @@ $node = new stdClass; $node-content = $note['note']; - $node-attributes['role'] = 'php'; + $node-attributes['role'] = 'note'; $the_note = format_listing($node); // turn urls into links
Re: [PHP-DOC] cvs: livedocs / livedoc_funcs.php
Curt mustn't have updated his patch, $children[$parent] needs to be changed to $children[$valsub] (on the indicated line below) otherwise the function list and other 'sub-TOCs' are broken. Matt Ilia Alshanetsky wrote: iliaa Wed Feb 9 15:03:44 2005 EDT Modified files: /livedocs livedoc_funcs.php Log: Fixed bug #30204 http://cvs.php.net/diff.php/livedocs/livedoc_funcs.php?r1=1.20r2=1.21ty=u Index: livedocs/livedoc_funcs.php diff -u livedocs/livedoc_funcs.php:1.20 livedocs/livedoc_funcs.php:1.21 --- livedocs/livedoc_funcs.php:1.20 Wed Feb 9 14:47:38 2005 +++ livedocs/livedoc_funcs.php Wed Feb 9 15:03:43 2005 @@ -11,13 +11,35 @@ include LIVEDOC_SOURCE . '/handlers.php'; include LIVEDOC_SOURCE . '/themes/' . THEME_NAME . '/html_format.php'; [snip] +function do_nav_children($idx, $parent, $lang, $current_page, $nav, $children) { + if ($current_page != 'manual' ) { + $rsub = (array) sqlite_single_query($idx, SELECT docbook_id FROM toc WHERE parent_docbook_id = '$current_page' ORDER BY id); + foreach ($rsub as $valsub) { + $nav .= do_nav_line($valsub, 'downdown', $current_page, $lang, $title); + $children[$parent] = $title; - + } + } +}
[PHP-DOC] cvs: livedocs / livedoc_funcs.php
iliaa Wed Feb 9 17:06:44 2005 EDT Modified files: /livedocs livedoc_funcs.php Log: Use correct array key. http://cvs.php.net/diff.php/livedocs/livedoc_funcs.php?r1=1.22r2=1.23ty=u Index: livedocs/livedoc_funcs.php diff -u livedocs/livedoc_funcs.php:1.22 livedocs/livedoc_funcs.php:1.23 --- livedocs/livedoc_funcs.php:1.22 Wed Feb 9 15:31:57 2005 +++ livedocs/livedoc_funcs.php Wed Feb 9 17:06:43 2005 @@ -98,7 +98,7 @@ $rsub = (array) sqlite_single_query($idx, SELECT docbook_id FROM toc WHERE parent_docbook_id = '$current_page' ORDER BY id); foreach ($rsub as $valsub) { $nav .= do_nav_line($valsub, 'downdown', $current_page, $lang, $title); - $children[$parent] = $title; + $children[$valsub] = $title; } } }
[PHP-DOC] cvs: livedocs / livedoc_funcs.php style_mapping.php
iliaa Wed Feb 9 17:37:51 2005 EDT Modified files: /livedocs livedoc_funcs.php style_mapping.php Log: Cleanup notes presentation. http://cvs.php.net/diff.php/livedocs/livedoc_funcs.php?r1=1.23r2=1.24ty=u Index: livedocs/livedoc_funcs.php diff -u livedocs/livedoc_funcs.php:1.23 livedocs/livedoc_funcs.php:1.24 --- livedocs/livedoc_funcs.php:1.23 Wed Feb 9 17:06:43 2005 +++ livedocs/livedoc_funcs.php Wed Feb 9 17:37:51 2005 @@ -310,7 +310,7 @@ ); $inner .= 'div class=usernotediv class=noteheaderspan class=user'.$note['who']. - '(#'.$note['id'].')/spanbr /span class=when'.$date.'/span/div'.$the_note.'/div'; + ' (#'.$note['id'].')/spanbr /span class=when'.$date.'/span/div'.$the_note.'/div'; } return $inner . /div; http://cvs.php.net/diff.php/livedocs/style_mapping.php?r1=1.24r2=1.25ty=u Index: livedocs/style_mapping.php diff -u livedocs/style_mapping.php:1.24 livedocs/style_mapping.php:1.25 --- livedocs/style_mapping.php:1.24 Wed Feb 9 15:31:57 2005 +++ livedocs/style_mapping.php Wed Feb 9 17:37:51 2005 @@ -18,7 +18,7 @@ // | Helper functions for formatting elements | // +--+ // -// $Id: style_mapping.php,v 1.24 2005/02/09 20:31:57 iliaa Exp $ +// $Id: style_mapping.php,v 1.25 2005/02/09 22:37:51 iliaa Exp $ // almost XPATH.. ;-) $map = array( @@ -347,6 +347,7 @@ break; case 'note': $content = preg_replace_callback('!(\(\?|\?php).+\?\)!msU', 'highlight_php_code', $content); + $node-attributes['role'] = 'php'; break; case 'asp':
[PHP-DOC] cvs: livedocs / livedoc_funcs.php
iliaa Wed Feb 9 17:48:14 2005 EDT Modified files: /livedocs livedoc_funcs.php Log: Added anchors to notes. http://cvs.php.net/diff.php/livedocs/livedoc_funcs.php?r1=1.24r2=1.25ty=u Index: livedocs/livedoc_funcs.php diff -u livedocs/livedoc_funcs.php:1.24 livedocs/livedoc_funcs.php:1.25 --- livedocs/livedoc_funcs.php:1.24 Wed Feb 9 17:37:51 2005 +++ livedocs/livedoc_funcs.php Wed Feb 9 17:48:14 2005 @@ -309,7 +309,7 @@ $the_note ); - $inner .= 'div class=usernotediv class=noteheaderspan class=user'.$note['who']. + $inner .= 'div class=usernotediv class=noteheadera name=' . $note['id'] . ' /span class=user'.$note['who']. ' (#'.$note['id'].')/spanbr /span class=when'.$date.'/span/div'.$the_note.'/div'; }
[PHP-DOC] cvs: livedocs / livedoc_funcs.php
gobaThu Sep 2 12:18:24 2004 EDT Modified files: /livedocs livedoc_funcs.php Log: *always* go into the refs sections (refgroups) when building a toc http://cvs.php.net/diff.php/livedocs/livedoc_funcs.php?r1=1.10r2=1.11ty=u Index: livedocs/livedoc_funcs.php diff -u livedocs/livedoc_funcs.php:1.10 livedocs/livedoc_funcs.php:1.11 --- livedocs/livedoc_funcs.php:1.10 Sat Aug 14 17:41:37 2004 +++ livedocs/livedoc_funcs.php Thu Sep 2 12:18:23 2004 @@ -359,7 +359,7 @@ $ret .= a href='.generate_url_for_id($lang, $row[1]).'.$title./a; } - if (($level 2 strncmp($row[1], 'ref', 3)) || $level 1) { + if (strncmp($row[1], 'refs.', 5) || ($level 2 strncmp($row[1], 'ref', 3)) || $level 1) { $ret .= do_contents($row[0], $level + 1); } $ret .= /li\n;
[PHP-DOC] cvs: livedocs / livedoc_funcs.php
gobaThu Sep 2 12:20:04 2004 EDT Modified files: /livedocs livedoc_funcs.php Log: ups, returns 0 on success http://cvs.php.net/diff.php/livedocs/livedoc_funcs.php?r1=1.11r2=1.12ty=u Index: livedocs/livedoc_funcs.php diff -u livedocs/livedoc_funcs.php:1.11 livedocs/livedoc_funcs.php:1.12 --- livedocs/livedoc_funcs.php:1.11 Thu Sep 2 12:18:23 2004 +++ livedocs/livedoc_funcs.php Thu Sep 2 12:20:04 2004 @@ -359,7 +359,7 @@ $ret .= a href='.generate_url_for_id($lang, $row[1]).'.$title./a; } - if (strncmp($row[1], 'refs.', 5) || ($level 2 strncmp($row[1], 'ref', 3)) || $level 1) { + if (strncmp($row[1], 'refs.', 5) == 0 || ($level 2 strncmp($row[1], 'ref', 3)) || $level 1) { $ret .= do_contents($row[0], $level + 1); } $ret .= /li\n;
[PHP-DOC] cvs: livedocs / livedoc_funcs.php
gobaThu Sep 2 13:54:06 2004 EDT Modified files: /livedocs livedoc_funcs.php Log: adding reg; - Sean spotted this http://cvs.php.net/diff.php/livedocs/livedoc_funcs.php?r1=1.12r2=1.13ty=u Index: livedocs/livedoc_funcs.php diff -u livedocs/livedoc_funcs.php:1.12 livedocs/livedoc_funcs.php:1.13 --- livedocs/livedoc_funcs.php:1.12 Thu Sep 2 12:20:04 2004 +++ livedocs/livedoc_funcs.php Thu Sep 2 13:54:05 2004 @@ -186,7 +186,7 @@ $replace = array(); $search = array('aelig;', 'copy;', 'eacute;', 'egrave;', 'agrave;', 'iuml;', 'ouml;', 'auml;', 'Auml;', - 'ocirc;', 'ecirc;', 'ucirc;', 'icirc;', 'acirc;', 'euml;', 'ccedil;', 'ugrave;'); + 'ocirc;', 'ecirc;', 'ucirc;', 'icirc;', 'acirc;', 'euml;', 'ccedil;', 'ugrave;', 'reg;'); foreach ($search as $item) { $replace[] = html_entity_decode($item); }
[PHP-DOC] cvs: livedocs / livedoc_funcs.php
gobaThu Sep 2 15:26:02 2004 EDT Modified files: /livedocs livedoc_funcs.php Log: do not go into listing functions on refgroup pages (yes, I am nesting two ifs, since I think it is readble this way) - feel free to optimize http://cvs.php.net/diff.php/livedocs/livedoc_funcs.php?r1=1.14r2=1.15ty=u Index: livedocs/livedoc_funcs.php diff -u livedocs/livedoc_funcs.php:1.14 livedocs/livedoc_funcs.php:1.15 --- livedocs/livedoc_funcs.php:1.14 Thu Sep 2 15:03:14 2004 +++ livedocs/livedoc_funcs.php Thu Sep 2 15:26:01 2004 @@ -346,7 +346,7 @@ function do_contents($id, $level) { - global $lang; + global $lang, $current_page; $parent_selector = (is_numeric($id)) ? $parent_selector = 'parent_id =' . $id : 'parent_docbook_id = ' . sqlite_escape_string($id) . ''; @@ -361,8 +361,12 @@ $ret .= a href='.generate_url_for_id($lang, $row[1]).'.$title./a; } - if (strncmp($row[1], 'refs.', 5) == 0 || ($level 2 strncmp($row[1], 'ref', 3)) || $level 1) { - $ret .= do_contents($row[0], $level + 1); + // Do not go into listing functions on refgroup pages + if (!(strncmp($current_page, 'refs.', 5) == 0 strncmp($row[1], 'function.', 3) != 0)) { + // Go very deep on refgroup pages + if (strncmp($row[1], 'refs.', 5) == 0 || ($level 2 strncmp($row[1], 'ref', 3)) || $level 1) { + $ret .= do_contents($row[0], $level + 1); + } } $ret .= /li\n; }
[PHP-DOC] cvs: livedocs / livedoc_funcs.php
gobaThu Sep 2 15:33:25 2004 EDT Modified files: /livedocs livedoc_funcs.php Log: wups, this is 9 chars, not 3 http://cvs.php.net/diff.php/livedocs/livedoc_funcs.php?r1=1.15r2=1.16ty=u Index: livedocs/livedoc_funcs.php diff -u livedocs/livedoc_funcs.php:1.15 livedocs/livedoc_funcs.php:1.16 --- livedocs/livedoc_funcs.php:1.15 Thu Sep 2 15:26:01 2004 +++ livedocs/livedoc_funcs.php Thu Sep 2 15:33:25 2004 @@ -362,7 +362,7 @@ } // Do not go into listing functions on refgroup pages - if (!(strncmp($current_page, 'refs.', 5) == 0 strncmp($row[1], 'function.', 3) != 0)) { + if (!(strncmp($current_page, 'refs.', 5) == 0 strncmp($row[1], 'function.', 9) != 0)) { // Go very deep on refgroup pages if (strncmp($row[1], 'refs.', 5) == 0 || ($level 2 strncmp($row[1], 'ref', 3)) || $level 1) { $ret .= do_contents($row[0], $level + 1);
[PHP-DOC] cvs: livedocs / livedoc_funcs.php
gobaThu Sep 2 16:36:59 2004 EDT Modified files: /livedocs livedoc_funcs.php Log: merge the ifs so it becomes a big list :) - plus fix the function list exlusion to work properly http://cvs.php.net/diff.php/livedocs/livedoc_funcs.php?r1=1.16r2=1.17ty=u Index: livedocs/livedoc_funcs.php diff -u livedocs/livedoc_funcs.php:1.16 livedocs/livedoc_funcs.php:1.17 --- livedocs/livedoc_funcs.php:1.16 Thu Sep 2 15:33:25 2004 +++ livedocs/livedoc_funcs.php Thu Sep 2 16:36:58 2004 @@ -361,12 +361,10 @@ $ret .= a href='.generate_url_for_id($lang, $row[1]).'.$title./a; } - // Do not go into listing functions on refgroup pages - if (!(strncmp($current_page, 'refs.', 5) == 0 strncmp($row[1], 'function.', 9) != 0)) { - // Go very deep on refgroup pages - if (strncmp($row[1], 'refs.', 5) == 0 || ($level 2 strncmp($row[1], 'ref', 3)) || $level 1) { - $ret .= do_contents($row[0], $level + 1); - } + // Do not go into listing functions on refgroup pages, but + // otherwise go very deep into refgroup pages + if (!(strncmp($current_page, 'refs.', 5) == 0 strncmp($row[1], 'ref.', 4) == 0) (strncmp($row[1], 'refs.', 5) == 0 || ($level 2 strncmp($row[1], 'ref', 3)) || $level 1)) { + $ret .= do_contents($row[0], $level + 1); } $ret .= /li\n; }
[PHP-DOC] cvs: livedocs / livedoc_funcs.php
iliaa Sat Aug 14 17:41:37 2004 EDT Modified files: /livedocs livedoc_funcs.php Log: Clean-up + http://livedocs.aborla.net/patch.php?id=include.entitiesdownload=linux http://cvs.php.net/diff.php/livedocs/livedoc_funcs.php?r1=1.9r2=1.10ty=u Index: livedocs/livedoc_funcs.php diff -u livedocs/livedoc_funcs.php:1.9 livedocs/livedoc_funcs.php:1.10 --- livedocs/livedoc_funcs.php:1.9 Fri Jul 30 11:16:29 2004 +++ livedocs/livedoc_funcs.php Sat Aug 14 17:41:37 2004 @@ -214,7 +214,7 @@ $data = preg_replace('@!--\s+.*\s--@Usm', '', $data); /* Replace entities */ - $data = bind_entities($data); + $data = str_replace($search, $replace, bind_entities($data)); /* catch any undefined entities */ if ($included) { @@ -229,14 +229,11 @@ $data = preg_replace('@(\\?xml.*\\?)@U', '\\1div', $data) . '/div'; } } else { - $data = preg_replace('/([a-zA-Z0-9-]+)\.([a-zA-Z0-9.-]+);/sm', 'phpdoc_include ref=\\1.\\2/', $data); + $data = preg_replace('/([a-zA-Z0-9._-]+);/sm', 'phpdoc_include ref=\\1/', $data); } - $data = str_replace($search, $replace, $data); - $page = new DocBookToHTML($data); - if ($return_rev) { return array($page, $lang_rev); } else { @@ -250,10 +247,7 @@ if (empty($notes)) return ''; - $inner = HTML -div class=usernotes - span class=titleUser Contributed Notes/span -HTML; + $inner = 'div class=usernotesspan class=titleUser Contributed Notes/span'; foreach ($notes as $note) { $date = date(d-M-Y h:i, $note['xwhen']); @@ -262,16 +256,9 @@ $node-content = $note['note']; $node-attributes['role'] = 'php'; $the_note = format_listing($node); - - $inner .= HTML -div class=usernote - div class=noteheader - span class=user$note[who]/spanbr / - span class=when$date/span - /div - $the_note -/div -HTML; + + $inner .= 'div class=usernotediv class=noteheaderspan class=user'.$note['who']. + '/spanbr /span class=when'.$date.'/span/div'.$the_note.'/div'; } return $inner . /div; @@ -384,12 +371,19 @@ return ''; } +$GLOBALS['special'] = array('gt' = 1,'lt' = 1,'quot' = 1,'amp' = 1); + function handle_include($node) { global $current_page; $ref = $node-attributes['ref']; - + + /* Special HTML entities */ + if (isset($GLOBALS['special'][$ref])) { + return '' . $ref . ';'; + } + $curr_lvl = sqlite_single_query($GLOBALS['idx'], SELECT lvl from toc where docbook_id='$current_page'); list($row) = sqlite_array_query($GLOBALS['idx'], SELECT idents.id, lvl from ents left join files on ents.value = files.filename left join idents on files.fileid = idents.fileid left join toc on ents.entid=toc.docbook_id where is_file=1 and ents.entid='$ref' limit 1); @@ -404,7 +398,6 @@ } if ($lvl $curr_lvl) { - $fake-content = null; $fake-attributes['linkend'] = $id; $fake-tagname = 'xref';
[PHP-DOC] cvs: livedocs / livedoc_funcs.php style_mapping.php
iliaa Fri Jul 30 11:16:29 2004 EDT Modified files: /livedocs livedoc_funcs.php style_mapping.php Log: Fixes and tune-ups by Nuno Lopes. http://cvs.php.net/diff.php/livedocs/livedoc_funcs.php?r1=1.8r2=1.9ty=u Index: livedocs/livedoc_funcs.php diff -u livedocs/livedoc_funcs.php:1.8 livedocs/livedoc_funcs.php:1.9 --- livedocs/livedoc_funcs.php:1.8 Wed May 26 11:57:28 2004 +++ livedocs/livedoc_funcs.php Fri Jul 30 11:16:29 2004 @@ -314,7 +314,7 @@ * and generate a link to its node using its title */ function make_function_link($ref) { - $parts = explode('.', $ref); + $parts = explode('.', strtolower($ref)); $stag = 'function'; $etag = 'function'; http://cvs.php.net/diff.php/livedocs/style_mapping.php?r1=1.18r2=1.19ty=u Index: livedocs/style_mapping.php diff -u livedocs/style_mapping.php:1.18 livedocs/style_mapping.php:1.19 --- livedocs/style_mapping.php:1.18 Wed May 26 11:40:04 2004 +++ livedocs/style_mapping.php Fri Jul 30 11:16:29 2004 @@ -18,7 +18,7 @@ // | Helper functions for formatting elements | // +--+ // -// $Id: style_mapping.php,v 1.18 2004/05/26 15:40:04 wez Exp $ +// $Id: style_mapping.php,v 1.19 2004/07/30 15:16:29 iliaa Exp $ // almost XPATH.. ;-) $map = array( @@ -296,7 +296,7 @@ $link = str_replace('_', '-', $matches[1]); $link = WEBBASE . (FORCE_DYNAMIC ? ?l=$langq=function.$link : $lang/function.$link.html); - return 'a class=phpfunc href=' . $link . '' . $matches[1] . '/a('; + return 'a class=phpfunc href=' . $link . '' . $matches[1] . '/a/span' . $matches[2]; } function format_listing($node) @@ -312,33 +312,27 @@ switch ($node-attributes['role']) { case 'asp': case 'php': -// Small hack because highlight_string has changed its behaviour in PHP 5 RC1 - if (version_compare(phpversion(), '5.0.0RC1') == -1){ - $content = preg_replace(array( - '@br /@', - '@font color=([^]+)@', - '@/font@', - ), - array( - br /\n, - 'span class=\\1', + $content = str_replace( + array( + 'nbsp;', + 'font color=',// for PHP 4 + 'span style=color: ', // for PHP 5.0.0RC1 + '/font', + \n , + ' ' + ), + array( + ' ', + 'span class=', + 'span class=', '/span', - ), - highlight_string($content, 1)); - } else { - $content = preg_replace(array( - '@br /@', - '@span style=color: ([^]+)@', - '@/span@', - ), - array( - br /\n, - 'span class=\\1', - '/span', - ), - highlight_string($content, 1)); - } - $content = preg_replace_callback('{([\w_]+)(\s*/span)(\s*span\s+class=keyword\s*\()}m', 'format_listing_hyperlink_function', $content); + \nnbsp;, + ' nbsp;' + ), + highlight_string($content, true) + ); + + $content = preg_replace_callback('{([\w_]+)\s*/span(\s*span\s+class=keyword\s*\()}m', 'format_listing_hyperlink_function', $content); break; case 'shell': case 'html':
Re: [PHP-DOC] cvs: livedocs / livedoc_funcs.php style_mapping.php xml_classes5.php
Ilia Alshanetsky wrote: - switch (count($parts)) { - case 4: - $id = 'function.' . $parts[3]; - $func_name = lookup_title($id); - break; - - case 5: - if ($parts[3] == 'class') { - $id = 'class.' . $parts[4]; - $func_name = str_replace('-', '_', $parts[4]); - $stag = xref linkend=\$id\; - $etag = xref; - break; - } - /* fall through */ - - default: - /* some weird node type we don't understand */ - $id = $ref; - $func_name = 'Unknown ??'; + if (isset($parts[4]) $parts[3] == 'class') { + $id = 'class.' . $parts[4]; + $func_name = str_replace('-', '_', $parts[4]); + $stag = xref linkend=\$id\; + $etag = xref; + } else if (isset($parts[3])) { + $id = 'function.' . $parts[3]; + $func_name = lookup_title($id); + } else { + /* some weird node type we don't understand */ + $id = $ref; + $func_name = 'Unknown ??'; } This is overtuned, here's the patch. Jakub VranaIndex: livedoc_funcs.php === RCS file: /repository/livedocs/livedoc_funcs.php,v retrieving revision 1.4 diff -u -r1.4 livedoc_funcs.php --- livedoc_funcs.php 25 May 2004 20:15:03 - 1.4 +++ livedoc_funcs.php 26 May 2004 08:09:52 - @@ -330,7 +330,7 @@ $func_name = str_replace('-', '_', $parts[4]); $stag = xref linkend=\$id\; $etag = xref; - } else if (isset($parts[3])) { + } else if (isset($parts[3]) !isset($parts[4])) { $id = 'function.' . $parts[3]; $func_name = lookup_title($id); } else {
[PHP-DOC] cvs: livedocs / livedoc_funcs.php
wez Wed May 26 05:25:52 2004 EDT Modified files: /livedocs livedoc_funcs.php Log: Fix overtuning. Patch by Jakub Vrana # ps: Jakub, please Cc: ilia directly if you spot another thing like this, # as he is not subscribed to phpdoc@ http://cvs.php.net/diff.php/livedocs/livedoc_funcs.php?r1=1.4r2=1.5ty=u Index: livedocs/livedoc_funcs.php diff -u livedocs/livedoc_funcs.php:1.4 livedocs/livedoc_funcs.php:1.5 --- livedocs/livedoc_funcs.php:1.4 Tue May 25 16:15:03 2004 +++ livedocs/livedoc_funcs.php Wed May 26 05:25:52 2004 @@ -330,7 +330,7 @@ $func_name = str_replace('-', '_', $parts[4]); $stag = xref linkend=\$id\; $etag = xref; - } else if (isset($parts[3])) { + } else if (isset($parts[3]) !isset($parts[4])) { $id = 'function.' . $parts[3]; $func_name = lookup_title($id); } else {
[PHP-DOC] cvs: livedocs / livedoc_funcs.php
iliaa Wed May 26 10:18:15 2004 EDT Modified files: /livedocs livedoc_funcs.php Log: Minor tuneup. http://cvs.php.net/diff.php/livedocs/livedoc_funcs.php?r1=1.5r2=1.6ty=u Index: livedocs/livedoc_funcs.php diff -u livedocs/livedoc_funcs.php:1.5 livedocs/livedoc_funcs.php:1.6 --- livedocs/livedoc_funcs.php:1.5 Wed May 26 05:25:52 2004 +++ livedocs/livedoc_funcs.php Wed May 26 10:18:15 2004 @@ -23,10 +23,9 @@ $tr = sqlite_array_query($fb_idx, SELECT title, filename, idents.fileid, files.dirid from idents left join files where id='$current_page' and idents.fileid=files.fileid, SQLITE_NUM); } if ($tr) { - list($tr) = $tr; - list($title, $filename, $fileid, $dirid) = $tr; + list($title, $filename, $fileid, $dirid) = $tr[0]; } else { - $tr = array('?', '', -1, -1); + $tr = array(array('?', '', -1, -1)); } /* Get parent ID and child IDs */ @@ -59,7 +58,7 @@ } $nav .= /table\n; - return $tr; + return $tr[0]; } @@ -204,7 +203,7 @@ $data = @file_get_contents($fallback_filename); if (!$data) { - $data = warningpermissions problem for $filename?/warning; + $data = warningpermissions problem for '$filename'?/warning; } } elseif ($lang != 'en' preg_match('/!-- EN-Revision: \d+\.(\d+)/', $data, $matches)) {
[PHP-DOC] cvs: livedocs / livedoc_funcs.php xml_classes5.php
iliaa Wed May 26 10:24:55 2004 EDT Modified files: /livedocs xml_classes5.php livedoc_funcs.php Log: Another slight optimization. http://cvs.php.net/diff.php/livedocs/xml_classes5.php?r1=1.4r2=1.5ty=u Index: livedocs/xml_classes5.php diff -u livedocs/xml_classes5.php:1.4 livedocs/xml_classes5.php:1.5 --- livedocs/xml_classes5.php:1.4 Tue May 25 16:15:03 2004 +++ livedocs/xml_classes5.php Wed May 26 10:24:55 2004 @@ -19,7 +19,7 @@ // | PHP 5 style | // +--+ // -// $Id: xml_classes5.php,v 1.4 2004/05/25 20:15:03 iliaa Exp $ +// $Id: xml_classes5.php,v 1.5 2004/05/26 14:24:55 iliaa Exp $ class Node { /* {{{ */ @@ -56,8 +56,8 @@ $n = $n-parent; } if ($match) { - if (is_callable($mapent[1])) { - return call_user_func($mapent[1], $this); + if (isset($GLOBALS['fl'][$mapent[1]])) { + return $mapent[1]($this); } else { $tagname = $mapent[1]; } http://cvs.php.net/diff.php/livedocs/livedoc_funcs.php?r1=1.6r2=1.7ty=u Index: livedocs/livedoc_funcs.php diff -u livedocs/livedoc_funcs.php:1.6 livedocs/livedoc_funcs.php:1.7 --- livedocs/livedoc_funcs.php:1.6 Wed May 26 10:18:15 2004 +++ livedocs/livedoc_funcs.php Wed May 26 10:24:55 2004 @@ -2,8 +2,10 @@ include LIVEDOC_SOURCE . '/common.php'; if (version_compare(phpversion(), 5, ge)) { include LIVEDOC_SOURCE . '/xml_classes5.php'; + $fl_gen = true; } else { include LIVEDOC_SOURCE . '/xml_classes.php'; + $fl_gen = false; } include LIVEDOC_SOURCE . '/style_mapping.php'; include LIVEDOC_SOURCE . '/handlers.php'; @@ -428,6 +430,11 @@ header('Location: ' . WEBBASE . 'search.php?q=' . urlencode($current_page) . 'l=' . $lang); exit; +} + +if ($fl_gen) { + $fl = get_defined_functions(); + $GLOBALS['fl'] = array_flip($fl['user']); } ?
[PHP-DOC] cvs: livedocs / livedoc_funcs.php
iliaa Wed May 26 11:57:29 2004 EDT Modified files: /livedocs livedoc_funcs.php Log: More tuneup. http://cvs.php.net/diff.php/livedocs/livedoc_funcs.php?r1=1.7r2=1.8ty=u Index: livedocs/livedoc_funcs.php diff -u livedocs/livedoc_funcs.php:1.7 livedocs/livedoc_funcs.php:1.8 --- livedocs/livedoc_funcs.php:1.7 Wed May 26 10:24:55 2004 +++ livedocs/livedoc_funcs.php Wed May 26 11:57:28 2004 @@ -155,26 +155,19 @@ function bind_entities($data) { global $idx; - - static $entity_cache = array(); - - $entities = array(); + $sanity = 0; while (($ent_count = preg_match_all('/([a-zA-Z0-9.-]+);/sm', $data, $matches)) $sanity++ 5) { - $q = sqlite_query($idx, SELECT entid, value from ents where is_file=0 and entid in (' . implode(',', $matches[1]) . ') GROUP BY entid); - if (!$q) { + $r = sqlite_array_query($idx, SELECT ''||entid||';', value from ents where is_file=0 and entid in (' . implode(',', $matches[1]) . ') GROUP BY entid, SQLITE_NUM); + if (empty($r)) { break; } $src = $dst = array(); - while ($r = sqlite_fetch_array($q, SQLITE_NUM)) { - $src[] = '' . $r[0] . ';'; - $dst[] = $r[1]; - } - - if (empty($src)) { - break; + foreach ($r as $row) { + $src[] = $row[0]; + $dst[] = $row[1]; } $data = str_replace($src, $dst, $data);
[PHP-DOC] cvs: livedocs / livedoc_funcs.php xml_classes5.php
wez Tue May 25 11:24:47 2004 EDT Modified files: /livedocs livedoc_funcs.php xml_classes5.php Log: A couple of tweaks http://cvs.php.net/diff.php/livedocs/livedoc_funcs.php?r1=1.1r2=1.2ty=u Index: livedocs/livedoc_funcs.php diff -u livedocs/livedoc_funcs.php:1.1 livedocs/livedoc_funcs.php:1.2 --- livedocs/livedoc_funcs.php:1.1 Tue May 25 07:33:48 2004 +++ livedocs/livedoc_funcs.php Tue May 25 11:24:46 2004 @@ -18,12 +18,15 @@ $nav = table class='nav' border='0' cellpadding='0' cellspacing='0' width='150'; /* Get the fileinfo for the reference */ - list($tr) = sqlite_array_query($idx, SELECT title, filename, idents.fileid, files.dirid from idents left join files where id='$current_page' and idents.fileid=files.fileid, SQLITE_NUM); + $tr = sqlite_array_query($idx, SELECT title, filename, idents.fileid, files.dirid from idents left join files where id='$current_page' and idents.fileid=files.fileid, SQLITE_NUM); if (!$tr) { - list($tr) = sqlite_array_query($fb_idx, SELECT title, filename, idents.fileid, files.dirid from idents left join files where id='$current_page' and idents.fileid=files.fileid, SQLITE_NUM); + $tr = sqlite_array_query($fb_idx, SELECT title, filename, idents.fileid, files.dirid from idents left join files where id='$current_page' and idents.fileid=files.fileid, SQLITE_NUM); } if ($tr) { + list($tr) = $tr; list($title, $filename, $fileid, $dirid) = $tr; + } else { + $tr = array('?', '', -1, -1); } /* Get parent ID and child IDs */ http://cvs.php.net/diff.php/livedocs/xml_classes5.php?r1=1.1r2=1.2ty=u Index: livedocs/xml_classes5.php diff -u livedocs/xml_classes5.php:1.1 livedocs/xml_classes5.php:1.2 --- livedocs/xml_classes5.php:1.1 Tue May 25 07:33:48 2004 +++ livedocs/xml_classes5.php Tue May 25 11:24:46 2004 @@ -19,7 +19,7 @@ // | PHP 5 style | // +--+ // -// $Id: xml_classes5.php,v 1.1 2004/05/25 11:33:48 wez Exp $ +// $Id: xml_classes5.php,v 1.2 2004/05/25 15:24:46 wez Exp $ class Node { /* {{{ */ @@ -136,7 +136,7 @@ $this-tagname = $tagname; $this-attributes = $attributes; - $GLOBALS['__node_count']++; + @$GLOBALS['__node_count']++; } function set_parent($parent)
[PHP-DOC] cvs: livedocs / livedoc_funcs.php pregenerate.php style_mapping.php xml_classes5.php
iliaa Tue May 25 15:07:13 2004 EDT Modified files: /livedocs livedoc_funcs.php pregenerate.php style_mapping.php xml_classes5.php Log: Various optimizations, these gives us about 15%-20% speed boost. http://cvs.php.net/diff.php/livedocs/livedoc_funcs.php?r1=1.2r2=1.3ty=u Index: livedocs/livedoc_funcs.php diff -u livedocs/livedoc_funcs.php:1.2 livedocs/livedoc_funcs.php:1.3 --- livedocs/livedoc_funcs.php:1.2 Tue May 25 11:24:46 2004 +++ livedocs/livedoc_funcs.php Tue May 25 15:07:13 2004 @@ -123,7 +123,7 @@ $title = lookup_title($item); $fulltitle = $title; - if (strlen($title) 25) { + if (isset($title{25})) { $ftitle = title='$title'; $title = substr($title, 0, 22). '...'; } else { @@ -161,33 +161,23 @@ $sanity = 0; while (($ent_count = preg_match_all('/([a-zA-Z0-9.-]+);/sm', $data, $matches)) $sanity++ 5) { - /* now collect their values */ - $entities_to_find = array_unique($matches[1]); - foreach ($entities_to_find as $ent) { - if (isset($entity_cache[$ent])) { - $entities['' . $ent . ';'] = $entity_cache[$ent]; - unset($entities_to_find[$ent]); - } + $q = sqlite_query($idx, SELECT entid, value from ents where is_file=0 and entid in (' . implode(',', $matches[1]) . ') GROUP BY entid); + if (!$q) { + break; } - - if (count($entities_to_find)) { - $ents = implode(',', $entities_to_find); - $q = sqlite_query($idx, SELECT entid, value from ents where is_file=0 and entid in (' . $ents . ')); - if ($q) { - while ($r = sqlite_fetch_array($q, SQLITE_NUM)) { - $entities['' . $r[0] . ';'] = $r[1]; - $entities_cache[$r[0]] = $r[1]; - } - } + $src = $dst = array(); + + while ($r = sqlite_fetch_array($q, SQLITE_NUM)) { + $src[] = '' . $r[0] . ';'; + $dst[] = $r[1]; } - if (!count($entities)) + if (empty($src)) { break; + } - /* substitute */ - $data = strtr($data, $entities); - - } while ($sanity++ 5); + $data = str_replace($src, $dst, $data); + } return $data; } @@ -210,10 +200,10 @@ $lang_rev = 0; $data = @file_get_contents($filename); - if (strlen($data) == 0 strlen($fallback_filename)) { + if (!$data $fallback_filename) { $data = @file_get_contents($fallback_filename); - if (strlen($data) == 0) { + if (!$data) { $data = warningpermissions problem for $filename?/warning; } http://cvs.php.net/diff.php/livedocs/pregenerate.php?r1=1.1r2=1.2ty=u Index: livedocs/pregenerate.php diff -u livedocs/pregenerate.php:1.1 livedocs/pregenerate.php:1.2 --- livedocs/pregenerate.php:1.1Tue May 25 07:33:48 2004 +++ livedocs/pregenerate.phpTue May 25 15:07:13 2004 @@ -6,6 +6,8 @@ * So, only run this with PHP 5 if you value your RAM! */ +//apd_set_pprof_trace(); + define('LIVEDOC_SOURCE', dirname(__FILE__)); include LIVEDOC_SOURCE . '/livedoc_funcs.php'; @@ -24,7 +26,7 @@ $nav_time = 0; $load_time = 0; -while ($page_row = sqlite_fetch_array($ids_and_pages)) { +while ($page_row = sqlite_fetch_array($ids_and_pages, SQLITE_NUM)) { if ($last_file_name == $page_row[1]) continue; @@ -107,6 +109,11 @@ if ($__node_count 0) { fwrite(STDERR, nodes: $__node_count\n); fflush(STDERR); } +/* XXX: dev limiter + if ($number_processed 10) { + break; + } +*/ } $elapsed = microtime(true) - $start_time; http://cvs.php.net/diff.php/livedocs/style_mapping.php?r1=1.15r2=1.16ty=u Index: livedocs/style_mapping.php diff -u livedocs/style_mapping.php:1.15 livedocs/style_mapping.php:1.16 --- livedocs/style_mapping.php:1.15 Sun May 23 04:58:01 2004 +++ livedocs/style_mapping.php Tue May 25 15:07:13 2004 @@ -18,7 +18,7 @@ // | Helper functions for formatting elements | // +--+ // -// $Id: style_mapping.php,v 1.15 2004/05/23 08:58:01 wez Exp $ +// $Id: style_mapping.php,v 1.16 2004/05/25 19:07:13 iliaa Exp $ // almost XPATH.. ;-) $map = array( @@ -159,7 +159,7 @@ $vers = ''; if (substr($current_page, 0, 9) == 'function.') { - $func_name =
[PHP-DOC] cvs: livedocs / livedoc_funcs.php style_mapping.php xml_classes5.php
iliaa Tue May 25 16:15:04 2004 EDT Modified files: /livedocs xml_classes5.php livedoc_funcs.php style_mapping.php Log: More tunning. http://cvs.php.net/diff.php/livedocs/xml_classes5.php?r1=1.3r2=1.4ty=u Index: livedocs/xml_classes5.php diff -u livedocs/xml_classes5.php:1.3 livedocs/xml_classes5.php:1.4 --- livedocs/xml_classes5.php:1.3 Tue May 25 15:07:13 2004 +++ livedocs/xml_classes5.php Tue May 25 16:15:03 2004 @@ -19,7 +19,7 @@ // | PHP 5 style | // +--+ // -// $Id: xml_classes5.php,v 1.3 2004/05/25 19:07:13 iliaa Exp $ +// $Id: xml_classes5.php,v 1.4 2004/05/25 20:15:03 iliaa Exp $ class Node { /* {{{ */ @@ -46,9 +46,10 @@ if ($mapent[0][0] == $this-tagname) { $n = $this-parent; $match = true; - $c = count($mapent[0]); - for ($i = 1; $i $c; $i++) { - if ($n-tagname != $mapent[0][$i]) { + foreach ($mapent[0] as $v) { + if ($v == $mapent[0][0]) continue; + + if ($n-tagname != $v) { $match = false; break; } @@ -65,7 +66,7 @@ } if (isset($this-attributes['id'])) { - $anchor = sprintf('a name=%s/a', $this-attributes['id']); + $anchor = 'a name='.$this-attributes['id'].'/a'; } else { $anchor = ''; } @@ -121,7 +122,7 @@ /* look for children that match */ foreach ($this-children as $child) { $x = $this-select_node($child, $id); - if (is_object($x)) { + if (!empty($x)) { return $x; } } @@ -143,8 +144,7 @@ function set_parent($parent) { $this-parent = $parent; - $this-index = count($parent-children); - $parent-children[$this-index] = $this; + $parent-children[] = $this; } function compress() @@ -213,7 +213,7 @@ function release() { foreach ($this-children as $child) { - if (is_object($child)) { + if (!empty($child)) { $child-release(); } $child = null; @@ -234,16 +234,13 @@ var $current = null; function __destruct() { - if (is_object($this-top)) { + if (!empty($this-top)) { $this-top-release(); } - if (is_object($this-current)) { + if (!empty($this-current)) { $this-current-release(); } - $this-top = null; - unset($this-top); - $this-current = null; - unset($this-current); + unset($this-top, $this-current); } function DocBookToHTML($xml, $id = null) @@ -275,7 +272,7 @@ if ($id !== null) { $newtop = $this-top-select_node($id); - if (is_object($newtop)) { + if (!empty($newtop)) { $this-top = $newtop; $this-top-parent = null; } @@ -287,7 +284,7 @@ { /* pre-parse the map */ - if (!is_object($this-top)) { + if (empty($this-top)) { return div class=\warning\XML document contained no data/div; } http://cvs.php.net/diff.php/livedocs/livedoc_funcs.php?r1=1.3r2=1.4ty=u Index: livedocs/livedoc_funcs.php diff -u livedocs/livedoc_funcs.php:1.3 livedocs/livedoc_funcs.php:1.4 --- livedocs/livedoc_funcs.php:1.3 Tue May 25 15:07:13 2004 +++ livedocs/livedoc_funcs.php Tue May 25 16:15:03 2004 @@ -32,7 +32,7 @@ /* Get parent ID and child IDs */ /* - first we get the first three parts of the path */ $last_item = 'manual'; - if (($r = sqlite_single_query($idx, SELECT path FROM toc WHERE docbook_id = '$current_page' LIMIT 1, SQLITE_NUM))) { + if (($r = sqlite_single_query($idx, SELECT path FROM toc WHERE docbook_id = '$current_page' LIMIT 1))) { $path = explode(,, $r); foreach ($path as $item) { $nav .= do_nav_line($item, 'up', $current_page,