com web/php: Remove wrappers for the beta design, and the old code: include/layout.inc include/prepend.inc include/shared-manual.inc

From: Date: Thu, 21 Nov 2013 00:29:56 +0000
Subject: com web/php: Remove wrappers for the beta design, and the old code: include/layout.inc include/prepend.inc include/shared-manual.inc
Groups: php.webmaster 
Request: Send a blank email to php-webmaster+get-17103@lists.php.net to get a copy of this message
Commit: 7cf8424edf79524c78bab5980df960cfe45e1a60 Author: Hannes Magnusson <bjori@mongodb.com> Wed, 20 Nov 2013 16:29:56 -0800 Parents: ccf9c6399eaeecf7bfa1e2f5008dbff71eeb6a26 Branches: master Link: http://git.php.net/?p=web/php.git;a=commitdiff;h=7cf8424edf79524c78bab5980df960cfe45e1a60 Log: Remove wrappers for the beta design, and the old code Changed paths: M include/layout.inc M include/prepend.inc M include/shared-manual.inc

diff --git a/include/layout.inc b/include/layout.inc index 2561134..c12adad 100644 --- a/include/layout.inc +++ b/include/layout.inc @@ -63,312 +63,10 @@ function highlight_php($code, $return = FALSE) // Stats pages still need this function commonHeader($title) { site_header($title); } -function site_header($title = '', $config = array()) -{ - if (myphpnet_beta()) { - return site_header_beta($title, $config); - } - global $EXPL_LANG, $SIDEBAR_DATA, $RSIDEBAR_DATA, $PAGE_COLUMNS, $PGI; - - // Default to empty array if improper parameter passed - if (!is_array($config)) { $config = array(); } - - // String defaults - $lang_input = $canonical = $base = $meta = $layout_helper = ''; - - // Count number of columns for layout. The number identifies - // the layout precisely, as we have no page having a right - // sidebar and no left sidebar - $PAGE_COLUMNS = 1; - if (!empty($SIDEBAR_DATA)) { $PAGE_COLUMNS++; } - if (!empty($RSIDEBAR_DATA)) { $PAGE_COLUMNS++; } - - // Check which language we are presenting, default to english - $lang = "en"; - if (isset($config["lang"])) { - $lang = language_convert($config["lang"]); - } elseif (isset($PGI, $PGI['head'], $PGI['head'][1])) { - $lang = language_convert($PGI['head'][1]); - } - - // Print out lang and charset headers - if (!isset($config["charset"])) { $config["charset"] = "utf-8"; } - header("Content-type: text/html;charset={$config['charset']}"); - header("Content-language: {$lang}"); - if (isset($config["generate_modified"]) && $config["generate_modified"]) { - $timestamp = @filemtime($_SERVER["DOCUMENT_ROOT"] . "/" .$_SERVER["BASE_PAGE"]); - if ($timestamp) { - $tsstring = gmdate("D, d M Y H:i:s ", $timestamp) . "GMT"; - header("Last-Modified: " . $tsstring); - } - } - - - if (isset($config["extra_headers"]) && is_array($config["extra_headers"])) { - foreach($config["extra_headers"] as $key => $value) { - header(sprintf("%s: %s", $key, $value)); - } - } - - if (!empty($title)) { $title = ": $title"; } - - // This page should not be indexed by robots - if (in_array("noindex", $config)) { - $meta .= "\n <meta name=\"robots\" content=\"noindex\" />"; - } - - // Set onload handler if required - $onload = (isset($config['onload']) ? ' onload="' . $config['onload'] . '"' : ''); - - // Explicit language setting means that we should put that into the form - if (isset($EXPL_LANG)) { - $lang_input = "\n <input type=\"hidden\" name=\"lang\" value=\"$EXPL_LANG\" />"; - } - - // Link tags - $link = ""; - if (isset($config['link']) && is_array($config['link'])) { - foreach($config['link'] as $rel => $url) { - if (!is_array($url)) { - $link .= "\n <link rel=\"$rel\" href=\"$url\" />"; - } else { - $link .= "\n <link "; - foreach($url as $attr => $val) { - $link .= "$attr=\"$val\" "; - } - $link .= "/>"; - } - } - } - - // Base href setting for URL shortcuts to work - if (!empty($_SERVER['BASE_HREF'])) { - $base = "\n <base href=\"{$_SERVER['BASE_HREF']}\" />"; - $canonical = '<link rel="canonical" href="//php.net/' . $_SERVER['BASE_PAGE'] . '" />'; - } - - // Define layout helper in case we need it - if ($PAGE_COLUMNS > 2) { - $layout_helper = "<div id=\"layout_{$PAGE_COLUMNS}_helper\">"; - } - - // Choose name of mirror site specific CSS file - $mirror_specific_style = ($_SERVER['STATIC_ROOT'] ? 'phpnet' : 'mirror'); - - // Support for more header tags - $moreheadtags = ''; - if (isset($config['headtags'])) { - if (is_array($config['headtags'])) { - $moreheadtags = "\n " . join("\n ", $config['headtags']); - } else { - $moreheadtags = "\n " . ((string)$config['headtags']); - } - } - $classname = "default"; - if(isset($_SERVER['BASE_PAGE'])) { - $classname = dirname($_SERVER['BASE_PAGE']); - if(empty($classname)) { - $classname = "default"; - } - } - - // Right-to-left support - $rtl = ""; - /* Does not appear to work... commenting out. - switch ($lang) { - case "he": - case "ar": - $rtl = ' style="direction: rtl"'; - break; - } - */ - - // RTL Hack. Edit styles/rtl.css for rtl specific CSS. - $import_rtl = ''; - if (in_array($lang, array('ar', 'fa', 'he'))) { - $import_rtl = '@import url("' . $_SERVER['STATIC_ROOT'] . '/styles/rtl.css");'; - } - - $profile = ""; - if (isset($config['profile']) && !empty($config['profile'])) { - $profile = ' profile="'; - if (is_array($config['profile'])) { - $profile .= implode(" ", $config['profile']); - } else { - $profile .= $config['profile']; - } - $profile .= '"'; - } - - - print <<<END_HEADER -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{$lang}" lang="{$lang}"> -<head{$profile}> - <title>PHP{$title}</title> - <style type="text/css" media="all"> - @import url("{$_SERVER['STATIC_ROOT']}/styles/site.css"); - @import url("{$_SERVER['STATIC_ROOT']}/styles/{$mirror_specific_style}.css"); - $import_rtl - </style> - <!--[if IE]><![if gte IE 6]><![endif]--> - <style type="text/css" media="print"> - @import url("{$_SERVER['STATIC_ROOT']}/styles/print.css"); - </style> - <!--[if IE]><![endif]><![endif]--> - <meta http-equiv="Content-Type" content="text/html; charset={$config['charset']}"/> - <link rel="shortcut icon" href="{$_SERVER['STATIC_ROOT']}/favicon.ico" />{$link} - $canonical - <script type="text/javascript" src="{$_SERVER['STATIC_ROOT']}/userprefs.js"></script>{$base}{$meta} - <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> - {$moreheadtags} -</head> -<body{$onload}> - -<div id="headnav"> - <a href="/" rel="home"><img src="{$_SERVER['STATIC_ROOT']}/images/php.gif" - alt="PHP" width="120" height="67" id="phplogo" /></a> - <div id="headmenu"> - <a href="/downloads.php">downloads</a> | - <a href="/docs.php">documentation</a> | - <a href="/FAQ.php">faq</a> | - <a href="/support.php">getting help</a> | - <a href="/mailing-lists.php">mailing lists</a> | - <a href="/license">licenses</a> | - <a href="https://wiki.php.net/">wiki</a> | - <a href="https://bugs.php.net/">reporting bugs</a> | - <a href="/sites.php">php.net sites</a> | - <a href="/conferences/">conferences</a> | - <a href="/my.php">my php.net</a> - </div> -</div> - -<div id="headsearch"> - <form method="post" action="/search.php" id="topsearch"> - <p> - <span title="Keyboard shortcut: Alt+S (Win), Ctrl+S (Apple)"> - <span class="shortkey">s</span>earch for - </span> - <input type="text" name="pattern" value="" size="30" accesskey="s" title="Search"/> - <span>in the</span> - <select name="show"> - <option value="all" >all php.net sites</option> - <option value="local" >this mirror only</option> - <option value="quickref" selected="selected">function list</option> - <option value="manual" >online documentation</option> - <option value="bugdb" >bug database</option> - <option value="news_archive">Site News Archive</option> - <option value="changelogs">All Changelogs</option> - <option value="pear" >just pear.php.net</option> - <option value="pecl" >just pecl.php.net</option> - <option value="talks" >just talks.php.net</option> - <option value="maillist" >general mailing list</option> - <option value="devlist" >developer mailing list</option> - <option value="phpdoc" >documentation mailing list</option> - </select> - <input type="image" - src="{$_SERVER['STATIC_ROOT']}/images/small_submit_white.gif" - class="submit" alt="search" />{$lang_input} - </p> - </form> -</div> - -<div id="layout_{$PAGE_COLUMNS}">{$layout_helper} -END_HEADER; - - // Print out left column - if ($PAGE_COLUMNS > 1) { - echo "\n <div id=\"leftbar\">\n$SIDEBAR_DATA\n </div>"; - } - - // Print out right column - if ($PAGE_COLUMNS > 2) { - echo "\n <div id=\"rightbar\">\n$RSIDEBAR_DATA\n </div>"; - } - - // Any layout workarounds? - if (!empty($config["layout_workaround"])) { - echo $config["layout_workaround"]; - } - - // Start main page content - echo "\n <div id=\"content\" class=\"$classname\"{$rtl}>\n"; -} // Stats pages still need this function commonFooter() { site_footer(); } -function site_footer($config = array()) -{ - if (myphpnet_beta()) { - return site_footer_beta($config); - } - global $LAST_UPDATED, $PAGE_COLUMNS; - - $stats = (have_stats() ? "\n <a href=\"/stats/\">stats</a> |" : ""); - $rsslink = (isset($config["rss"]) ? - "<a href=\"{$config["rss"]}\">RSS</a> |" : - ""); - $atomlink = (isset($config["atom"]) ? - "<a href=\"{$config["atom"]}\">Atom</a> |" : - ""); - $viewsource = (isset($_SERVER['BASE_PAGE']) ? - "<a href=\"/source.php?url=/{$_SERVER['BASE_PAGE']}\">show source</a> |" : - ""); - $provider_url = mirror_provider_url(); - $provider_name = mirror_provider(); - $mirror_text = (is_official_mirror() ? - "<a href=\"/mirror.php\">This mirror</a> generously provided by:" : - "<a href=\"/mirror.php\">This unofficial mirror</a> is operated at:"); - $last_updated = strftime("%c %Z", $LAST_UPDATED); - $layout_helper = ($PAGE_COLUMNS > 2 ? "</div>" : ""); - - // Automate the Copyright year - $current_year = date('Y'); - - print <<<END_FOOTER - - </div> - <div class="cleaner">&nbsp;</div> -{$layout_helper}</div> - -<div id="footnav"> - $rsslink $atomlink $viewsource - <a href="/credits.php">credits</a> |$stats - <a href="/sitemap.php">sitemap</a> | - <a href="/contact.php">contact</a> | - <a href="/contact.php#ads">advertising</a> | - <a href="/mirrors.php">mirror sites</a> -</div> - -<div id="pagefooter"> - <div id="copyright"> - <a href="/copyright.php">Copyright &copy; 2001-{$current_year} The PHP Group</a><br /> - All rights reserved. - </div> - - <div id="thismirror"> - {$mirror_text} - <a href="{$provider_url}">{$provider_name}</a><br /> - Last updated: {$last_updated} - </div> -</div> - -<!--[if IE 6]> -<script type="text/javascript"> - var IE6UPDATE_OPTIONS = { - icons_path: "/ie6update/images/" - } -</script> -<script type="text/javascript" src="/ie6update/ie6update.js"></script> -<![endif]--> - -</body> -</html> -END_FOOTER; -} - // Resize the image using the output of make_image() // (considering possible HTML/XHTML image tag endings) function resize_image($img, $width = 1, $height = 1) @@ -827,7 +525,7 @@ EOT; // BETA -function site_header_beta($title = '', $config = array()) +function site_header($title = '', $config = array()) { global $SIDEBAR_DATA; global $MYSITE; @@ -867,7 +565,7 @@ function site_header_beta($title = '', $config = array()) require dirname(__FILE__) ."/header.inc"; } -function site_footer_beta($config = array()) +function site_footer($config = array()) { require dirname(__FILE__) . "/footer.inc"; } diff --git a/include/prepend.inc b/include/prepend.inc index b0625c1..3bbc425 100644 --- a/include/prepend.inc +++ b/include/prepend.inc @@ -100,12 +100,7 @@ function myphpnet_language($langcode = FALSE) elseif (isset($MYPHPNET[0]) && $MYPHPNET[0]) { return $MYPHPNET[0]; } - else { - if (myphpnet_beta()) { - return "en"; - } - return FALSE; - } + return false; } define("MYPHPNET_URL_NONE", FALSE); @@ -175,25 +170,6 @@ function myphpnet_save() } -function myphpnet_setbeta($bool = false) { - global $MYPHPNET; - - $bool = (bool) $bool; - - $MYPHPNET[4] = (bool) $bool; -} -function myphpnet_beta() { -/* - global $MYPHPNET; - global $MYSITE; - - if (isset($_GET["beta"])) { - return (bool)$_GET["beta"]; - } -*/ - return true; -} - // Default: Default search. // Lang: Not yet implemented (TODO: Compare google lang codes with ours. We did this for bing already, so maybe it's an easy fix) // TODO: Possible $default escaping issues diff --git a/include/shared-manual.inc b/include/shared-manual.inc index e7e22e2..1a78b01 100644 --- a/include/shared-manual.inc +++ b/include/shared-manual.inc @@ -20,167 +20,6 @@ include_once $_SERVER['DOCUMENT_ROOT'] . '/include/prepend.inc'; // Set variable defaults $PGI = array(); $SIDEBAR_DATA = ''; -// Set up variables important for this page -// including HTTP header information -function manual_setup($page_data) -{ - if (myphpnet_beta()) { - return manual_setup_beta($page_data); - } - global $PGI; - $PGI = array_merge($PGI, $page_data); // merge for BC reasons - - // Set base page for this manual page - $_SERVER['BASE_PAGE'] = 'manual/' . language_convert($PGI['head'][1]) . "/" . $PGI['this'][0]; - - // Set last modification time on the current manual page - if (($time = @filemtime($_SERVER['DOCUMENT_ROOT'] ."/". $_SERVER['BASE_PAGE'])) != false) { - $PGI['lastmod'] = gmdate("D, d M Y", $time); - } else { - $PGI['lastmod'] = "Unkown"; - } -} - -// Print out HTTP headers and the HTML header -// for this manual page, according to details -// already set up -// TODO: replace logo with logos/php-med-trans-light.gif on print -function manual_header() -{ - if (myphpnet_beta()) { - return manual_header_beta(); - } - global $PGI, $LAST_UPDATED, $MYSITE; - - // Get values out of the config array - $title = $PGI['this'][1]; - list($encoding, $lang) = $PGI['head']; - - header("Last-Modified: " . gmdate("D, d M Y H:i:s ", $LAST_UPDATED) . "GMT"); - //header("Cache-Control: public, max-age=600"); - header("Vary: Cookie"); - //header("Content-type: text/html;charset=$encoding"); - header("Content-type: text/html;charset=utf-8"); - header("Content-language: $lang"); - - // Set base href for this manual page - $_SERVER['BASE_HREF'] = $MYSITE . $_SERVER['BASE_PAGE']; - - // {{{ Build rev=canonical - $sections = get_manual_search_sections(); - // Kill the first entry (empty) - array_shift($sections); - - // We can at the very least kill the .php - $shorturl = substr($PGI['this'][0], 0, -4); - - foreach($sections as $section) { - // If we know this section - if (strpos($PGI['this'][0], $section) === 0) { - // We can make it even shorter - $shorturl = substr($PGI['this'][0], strlen($section), -4); - } - } - // }}} - - manual_sidebar(); - $link = array( - "contents" => $PGI["home"][0], - "index" => $PGI["up"][0], - "prev" => $PGI["prev"][0], - "next" => $PGI["next"][0], - "schema.dc" => "http://purl.org/dc/elements/1.1/", - "schema.rdfs" => "http://www.w3.org/2000/01/rdf-schema#", - array( - "rev" => "canonical", - "rel" => "self alternate shorter shorturl shortlink", - "href" => "http://php.net/" . $shorturl, - ), - array( - "rel" => "license", - "href" => "http://creativecommons.org/licenses/by/3.0/", - "about" => "#content", - ), - ); - if (isset($PGI["extra_header_links"])) { - $link[] = (array)$PGI["extra_header_links"]; - } - - site_header("$title - Manual", array( - "link" => $link, - "profile" => "http://purl.org/NET/erdf/profile", - "extra_headers" => array( - "Link" => "<http://php.net/" . $shorturl . ">; rel=shorturl", - ), - "headtags" => array( - '<meta http-equiv="Content-language" content="' . $lang . '" /> - <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"></script> -<script type="text/javascript"> -$(document).ready(function() { - var toggleImage = function(elem) { - if ($(elem).hasClass("shown")) { - $(elem).removeClass("shown").addClass("hidden"); - $("img", elem).attr("src", "/images/notes-add.gif"); - } - else { - $(elem).removeClass("hidden").addClass("shown"); - $("img", elem).attr("src", "/images/notes-reject.gif"); - } - }; - - $(".soft-deprecation-notice h1.title").each(function() { - $(this).prepend("<a class=\'toggler shown\' href=\'#\'><img src=\'/images/notes-reject.gif\' alt=\'minimize\' /></a> "); - }); - $(".refsect1 h3.title").each(function() { - url = "https://bugs.php.net/report.php?bug_type=Documentation+problem&amp;manpage=" + $(this).parent().parent().attr("id") + "%23" + $(this).parent().attr("id"); - $(this).parent().prepend("<div class=\'reportbug\'><a href=\'" + url + "\'>Report a bug</a></div>"); - $(this).prepend("<a class=\'toggler shown\' href=\'#\'><img src=\'/images/notes-reject.gif\' alt=\'reject note\' /></a> "); - }); - $("#usernotes .head").each(function() { - $(this).prepend("<a class=\'toggler shown\' href=\'#\'><img src=\'/images/notes-reject.gif\' alt=\'reject note\' /></a> "); - }); - $(".soft-deprecation-notice h1.title .toggler").click(function() { - $(this).parent().siblings().slideToggle("slow"); - toggleImage(this); - return false; - }); - $(".refsect1 h3.title .toggler").click(function() { - $(this).parent().siblings().slideToggle("slow"); - toggleImage(this); - return false; - }); - $("#usernotes .head .toggler").click(function() { - $(this).parent().next().slideToggle("slow"); - toggleImage(this); - return false; - }); -}); -</script> -<script type="text/javascript" src="/js/usernotes.js"></script> -', - - - ), - )); - manual_navbar(); -} - -// Print out manual page footer -function manual_footer() -{ - if (myphpnet_beta()) { - return manual_footer_beta(); - } - global $PGI; - - // Get vars for easy handling - list($filename, $title) = $PGI['this']; - - echo "<br /><br />"; - manual_notes(); - echo "<br />"; - site_footer(); -} // ============================================================================= // Manual page navigation parts @@ -311,80 +150,7 @@ function manual_navbar($location = "top") // ============================================================================= // Print out all user notes for this manual page -function manual_notes() -{ - if (myphpnet_beta()) { - return manual_notes_beta(); - } - // Get needed values - list($filename, $title) = $GLOBALS['PGI']['this']; - - // Drop file extension from the name - if (substr($filename, -4) == '.php') { - $filename = substr($filename, 0, -4); - } - - // Load user note for this page - $notes = manual_notes_load($filename); - uasort($notes, "manual_notes_sort"); - - // If there are few comments, provide the quick 'prevous'/'next' navigation - // above the comments - if(count($notes) > 2) { - manual_navbar("bottom"); - } - - // Link target to add a note to the current manual page, - // and it's extended form with a [+] image - $addnotelink = '/manual/add-note.php?sect=' . $filename . - '&amp;redirect=' . $_SERVER['BASE_HREF']; - $addnotesnippet = - make_link($addnotelink, make_image('notes-add.gif', 'add a note', FALSE, 'class="middle"')) . - ' <small>' . - make_link($addnotelink, 'add a note') . - '</small>'; - - $num_notes = count($notes); - - // note snippet - list($redir_filename) = $GLOBALS['PGI']['this']; - if (substr($redir_filename, -4) == '.php') { - $redir_filename = substr($redir_filename, 0, -4); - } - - echo <<<END_USERNOTE_HEADER - -<div id="usernotes"> - <div class="head"> - <span class="action">{$addnotesnippet}</span> - <small>User Contributed Notes</small> - <strong>{$title}</strong> - [<em>{$num_notes}</em> notes] - </div> -END_USERNOTE_HEADER; - - // If we have no notes, then inform the user - if (sizeof($notes) == 0) { - echo "\n <div class=\"note\">There are no user contributed notes for this page.</div>"; - } - - // If we have notes, print them out - else { - echo '<div id="allnotes">'; - - foreach($notes as $note) { - manual_note_display( - $note['xwhen'], $note['user'], $note['note'], $note['id'], $note['votes'] - ); - } - echo "</div>\n"; - echo "\n <div class=\"foot\">$addnotesnippet</div>\n"; - } - - // End of #usernotes - echo "</div>"; -} - -function manual_notes_beta() { +function manual_notes() { // Get needed values list($filename, $title) = $GLOBALS['PGI']['this']; @@ -563,7 +329,9 @@ USER_NOTE_TEXT; /* vim: set et ts=4 sw=4: */ -function manual_setup_beta($setup) { +// Set up variables important for this page +// including HTTP header information +function manual_setup($setup) { global $PGI, $MYSITE; $PGI = $setup; // Set base href for this manual page @@ -664,8 +432,8 @@ function manual_language_chooser($currentlang, $currentpage) { return $rt; } -function manual_header_beta(){} -function manual_footer_beta() { +function manual_header(){} +function manual_footer() { manual_notes(); echo "</section>";
« previous php.webmaster (#17103) next »