cvs: phpweb / style.css userprefs.js /include layout.inc shared-manual.inc

From: Date: Sat, 14 Jun 2003 18:28:56 +0000
Subject: cvs: phpweb / style.css userprefs.js /include layout.inc shared-manual.inc
Groups: php.mirrors 
Request: Send a blank email to php-mirrors+get-18714@lists.php.net to get a copy of this message
goba Sat Jun 14 14:28:56 2003 EDT Modified files: /phpweb style.css userprefs.js /phpweb/include layout.inc shared-manual.inc Log: Use divs to present the TOC items on manual pages on the left side of the window Add images according to php.net rules to these two styles (toca, toci) depending on what mirror they are used on Also rewrite the TOC generator code a bit, so it identifies items properly when their title and titleabbrev differ [was a bug on many pages] Also wrap too long function names, so we have the same amount of content and nav area on pages with long function names in the TOC [eg. xml functions] The new div based approach means that we have *much* less HTML to output, and the layout of the menu is better than before, as the box images are aligned to the text. Tested with Mozilla and Konqueror. Apart from pages with long function names in the TOC, this should look very similar to the display of the TOC before Index: phpweb/style.css diff -u phpweb/style.css:1.42 phpweb/style.css:1.43 --- phpweb/style.css:1.42 Thu Jun 5 14:46:22 2003 +++ phpweb/style.css Sat Jun 14 14:28:56 2003 @@ -28,6 +28,26 @@ padding: 2px; } +/* Inactive and active TOC elements in the left + sidebar of the manual pages - this is further + enhanced with an image in /userprefs.js */ +div.toci, div.toca { + padding: 0 0 0 11px; + margin: 1px 0 0 3px; + background-repeat: no-repeat; + background-position: center left; +} +div.toca a { + font-weight: bold; +} +div.toca a, div.toci a { + text-decoration: none; + font-size: 75%; +} +div.toca a:hover, div.toci a:hover { + text-decoration: underline; +} + body, ul, td, th { font-family: verdana,arial,helvetica,sans-serif; font-size: 85%; @@ -169,10 +189,10 @@ font-size: smaller; } -table#cal a, .sidetoc a { +table#cal a { text-decoration: none; } -table#cal a:hover, .sidetoc a:hover { +table#cal a:hover { text-decoration: underline; } Index: phpweb/userprefs.js diff -u phpweb/userprefs.js:1.4 phpweb/userprefs.js:1.5 --- phpweb/userprefs.js:1.4 Sat Jun 7 03:55:46 2003 +++ phpweb/userprefs.js Sat Jun 14 14:28:56 2003 @@ -70,3 +70,32 @@ } } } + +// Make images appear by the side of TOC items on the manual pages +// This is not a user based function, but a mirror based one. Only +// php.net has images on a different server. But for performance +// reasons, the code is implemented to run on the client side. +function tocImages() +{ + // If DOM is supported, get the <div>s + if (document.getElementsByTagName) { + + divs = document.getElementsByTagName("div"); + + // Check if we are on the master site or not + staticContent = (location.hostname == "www.php.net" || + location.hostname == "php.net") ? + "http://static.php.net/www.php.net/" : "/"; + + // Change the style of every div tag which is in + // the "toci" or "toca" class, modifying the class + // according to the hostname + for (var i = 0; i < divs.length; i++) { + if (divs[i].className == "toci") { + divs[i].style.backgroundImage = "url(" + staticContent + "images/box-0.gif)"; + } else if(divs[i].className == "toca") { + divs[i].style.backgroundImage = "url(" + staticContent + "images/box-1.gif)"; + } + } + } +} \ No newline at end of file Index: phpweb/include/layout.inc diff -u phpweb/include/layout.inc:1.167 phpweb/include/layout.inc:1.168 --- phpweb/include/layout.inc:1.167 Sat Jun 7 22:17:10 2003 +++ phpweb/include/layout.inc Sat Jun 14 14:28:56 2003 @@ -1,5 +1,5 @@ <?php -/* $Id: layout.inc,v 1.167 2003/06/08 02:17:10 philip Exp $ */ +/* $Id: layout.inc,v 1.168 2003/06/14 18:28:56 goba Exp $ */ // Set the static content root differently on php.net $_SERVER['STATIC_ROOT'] = ($MYSITE == 'http://www.php.net/') ? @@ -188,7 +188,7 @@ $SEARCH_BASE, $ONLOAD, $BASE_FOR_MANPAGE; // If no onload event is specified, restore the last search - if (empty($ONLOAD)) { $ONLOAD = "searchHistory();"; } + if (empty($ONLOAD)) { $ONLOAD = "searchHistory(); tocImages();"; } ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> Index: phpweb/include/shared-manual.inc diff -u phpweb/include/shared-manual.inc:1.195 phpweb/include/shared-manual.inc:1.196 --- phpweb/include/shared-manual.inc:1.195 Sat Jun 7 16:01:07 2003 +++ phpweb/include/shared-manual.inc Sat Jun 14 14:28:56 2003 @@ -22,9 +22,10 @@ $tstamp = gmdate("D, d M Y",getlastmod()); } -// Put all the border table of contents data to $SIDEBAR_DATA -function makeBorderTOC($this) { - global $NEXT, $PREV, $UP, $HOME, $TOC, $PHP_SELF, $DOCUMENT_ROOT, $SIDEBAR_DATA; +// Append all the table of contents data to $SIDEBAR_DATA +function makeBorderTOC($id) +{ + global $UP, $HOME, $TOC, $SIDEBAR_DATA; $SIDEBAR_DATA .= '<!--UdmComment-->' . "\n" . '<table border="0" cellpadding="0" cellspacing="5" width="100%">'; @@ -41,28 +42,33 @@ '</td></tr>'; } - $SIDEBAR_DATA.= '<tr valign="top"><td><small class="sidetoc">'; + $SIDEBAR_DATA.= '<tr valign="top"><td>'; - for ($i = 0; $i < count($TOC); $i++) { - list($url, $title) = $TOC[$i]; - if (!$url || !$title) { - continue; - } - if ($UP[0] == 'funcref.php') { - $title = eregi_replace(" functions\$", "", $title); - } - $img = 'box-0.gif'; - if ($title == $this) { - $img = 'box-1.gif'; - $title = "<b>$title</b>"; + // Print out one link for all TOC items on this page + foreach($TOC as $tocitem) { + + // Get URL and title component + list($url, $title) = $tocitem; + + // Get the proper classname to use for this <div> + $divclass = ($url == $id) ? "toca" : "toci"; + + // There are some very long function names, which + // make the TOC be too wide, so wrap them + // eg: xml_set_processing_instruction_handler + if (strlen($title) > 30 && preg_match("!^[a-z0-9_]+$!", $title)) { + $title = str_replace("_", " ", $title); + $title = wordwrap($title, 30, "<br>"); + $title = str_replace(array(" ", "<br>"), array("_", "<br />_"), $title); } - $SIDEBAR_DATA .= '&nbsp;' . - make_link($url, make_image($img, "&middot;") . $title ) . - "<br />\n"; + + // Print out the TOC item using a div + $SIDEBAR_DATA .= "\n<div class=\"$divclass\">" . + make_link($url, $title) . "</div>"; } - $SIDEBAR_DATA .= '</small></td></tr>'; - $SIDEBAR_DATA .= '</table><!--/UdmComment-->'; + // End navigation table + $SIDEBAR_DATA .= "</td></tr></table><!--/UdmComment-->\n"; } // Print out manual navigation bar @@ -305,7 +311,7 @@ if ($PRINT_PAGE) { manualPrintHeader($title); } else { - makeBorderTOC($title); + makeBorderTOC($id); commonHeader ($title. " - Manual"); navigationBar($title, $id, "top"); }

« previous php.mirrors (#18714) next »