cvs: phpweb / my.php /error index.php /include prepend.inc
| From: | Gabor Hojtsy | Date: | Tue, 29 Jul 2003 11:35:24 +0000 |
| Subject: | cvs: phpweb / my.php /error index.php /include prepend.inc | ||
| Groups: | php.mirrors | ||
| Request: | Send a blank email to php-mirrors+get-19623@lists.php.net to get a copy of this message | ||
goba Tue Jul 29 07:35:24 2003 EDT
Modified files:
/phpweb my.php
/phpweb/include prepend.inc
/phpweb/error index.php
Log:
Change default URL shortcut search fallback type to be
the function list search (so users won't get redirected to
google). Also provide the option to force the site to redirect
to do a documentation seach (on google currently) in case
a user is used to this
Index: phpweb/my.php
diff -u phpweb/my.php:1.16 phpweb/my.php:1.17
--- phpweb/my.php:1.16 Sat May 24 15:50:36 2003
+++ phpweb/my.php Tue Jul 29 07:35:23 2003
@@ -1,5 +1,5 @@
<?php
-/* $Id: my.php,v 1.16 2003/05/24 19:50:36 goba Exp $ */
+/* $Id: my.php,v 1.17 2003/07/29 11:35:23 goba Exp $ */
include_once "prepend.inc";
@@ -14,7 +14,6 @@
// Set the language preference
myphpnet_language($_POST['my_lang']);
- myphpnet_save();
// Add this as first option, selected
$options[] = '<option value="' . $_POST['my_lang'] . '"
selected>' .
@@ -47,12 +46,20 @@
}
// Assemble form from collected data
-$langpref = "<form action=\"/my.php\" method=\"POST\">\n<select
name=\"my_lang\">\n" .
- join("", $options) . "</select>\n<input
type=\"submit\" value=\"Set\">\n</form>";
+$langpref = "<select name=\"my_lang\">\n" .
+ join("", $options) . "</select>\n";
+
+// Check URL shortcut fallback setting
+if (isset($_POST['urlsearch'])) {
+ myphpnet_urlsearch($_POST['urlsearch']);
+}
+
+myphpnet_save();
commonHeader("My PHP.net");
?>
+<form action="/my.php" method="POST">
<h1>My PHP.net</h1>
<p>
@@ -78,7 +85,8 @@
most of the time.
</p>
-<table border="0" cellpadding="3" cellspacing="2">
+<div class="indent">
+<table border="0" cellpadding="3" cellspacing="2"
class="standard">
<?php
// Data for the language settings table
@@ -101,12 +109,13 @@
// Write a row for all settings
foreach ($langinfo as $lin => $lid) {
- echo " <tr>\n <td bgcolor=\"#dddddd\">" . $lin .
"</td>\n";
- echo " <td bgcolor=\"#eeeeee\">" . $lid . "</td>\n
</tr>\n";
+ echo " <tr>\n <td class=\"sub\">" . $lin .
"</td>\n";
+ echo " <td>" . $lid . "</td>\n </tr>\n";
}
?>
</table>
+</div>
<p>
These settings are only overriden in case you have passed a language
@@ -134,7 +143,7 @@
page.
</p>
-<blockquote>
+<div class="indent">
<?php
if (i2c_valid_country()) {
echo "We detected that you are from <b>" . $COUNTRIES[$COUNTRY] .
"</b>";
@@ -142,6 +151,38 @@
echo "We were unable to detect your country";
}
?>
-</blockquote>
+</div>
+
+<h2>URL search fallback</h2>
+
+<p>
+When you try to access a PHP.net page via an URL shortcut, and
+the site is unable to find that particular page, it falls back
+to a documentation search, or a function list lookup, depending on
+your choice. The default is a function list lookup, as most of
+the URL shortcut users try to access function documentation pages.
+<em>Note that documentation searches are currently [temporarily]
+done through Google.</em>
+</p>
+
+<div class="indent">
+Your setting: <input type="radio" name="urlsearch"
value="quickref"
+<?php
+$type = myphpnet_urlsearch();
+if ($type === MYPHPNET_URL_NONE || $type === MYPHPNET_URL_FUNC) {
+ echo ' checked="checked"';
+}
+echo ' /> Function list search <input type="radio" name="urlsearch"
value="manual"';
+if ($type === MYPHPNET_URL_MANUAL) {
+ echo ' checked="checked"';
+}
+?>
+ /> PHP Documentation search
+</div>
+
+<div align="center">
+<input type="submit" value="Set All Preferences">
+</div>
+</form>
<?php commonFooter(); ?>
Index: phpweb/include/prepend.inc
diff -u phpweb/include/prepend.inc:1.27 phpweb/include/prepend.inc:1.28
--- phpweb/include/prepend.inc:1.27 Tue May 27 12:40:05 2003
+++ phpweb/include/prepend.inc Tue Jul 29 07:35:24 2003
@@ -1,6 +1,6 @@
<?php // -*- C++ -*-
-// $Id: prepend.inc,v 1.27 2003/05/27 16:40:05 goba Exp $
+// $Id: prepend.inc,v 1.28 2003/07/29 11:35:24 goba Exp $
// Start measuring time spent on page
$page_creation_start = getmicrotime();
@@ -105,7 +105,7 @@
// If we have a cookie, set the values in the array
if (isset($_COOKIE['MYPHPNET'])) {
- $MYPHPNET[0] = $_COOKIE['MYPHPNET'];
+ $MYPHPNET = explode(",", $_COOKIE['MYPHPNET']);
}
}
@@ -123,6 +123,26 @@
return $MYPHPNET[0];
}
else { return FALSE; }
+}
+
+define("MYPHPNET_URL_NONE", FALSE);
+define("MYPHPNET_URL_FUNC", 'quickref');
+define("MYPHPNET_URL_MANUAL", 'manual');
+
+// Set URL search fallback preference
+function myphpnet_urlsearch($type = FALSE)
+{
+ global $MYPHPNET;
+
+ // Set type if specified and if correct
+ if ($type && in_array($type, array(MYPHPNET_URL_FUNC, MYPHPNET_URL_MANUAL))) {
+ $MYPHPNET[1] = $type;
+ }
+
+ // Return code or FALSE
+ elseif (isset($MYPHPNET[1])) {
+ return $MYPHPNET[1];
+ } else { return MYPHPNET_URL_NONE; }
}
// Save user settings in cookie
Index: phpweb/error/index.php
diff -u phpweb/error/index.php:1.128 phpweb/error/index.php:1.129
--- phpweb/error/index.php:1.128 Mon Jul 28 04:36:52 2003
+++ phpweb/error/index.php Tue Jul 29 07:35:24 2003
@@ -1,6 +1,6 @@
<?php
-// $Id: index.php,v 1.128 2003/07/28 08:36:52 goba Exp $
+// $Id: index.php,v 1.129 2003/07/29 11:35:24 goba Exp $
/*
@@ -227,8 +227,9 @@
// ============================================================================
// If no match was found till this point, the last action is to start a
// search with the URI the user typed in
+$fallback = (myphpnet_urlsearch() === MYPHPNET_URL_MANUAL ? "manual" :
"quickref");
mirror_redirect(
- '/search.php?show=manual&lang=' . urlencode($LANG) .
+ '/search.php?show=' . $fallback . '&lang=' . urlencode($LANG) .
'&pattern=' . urlencode(substr($_SERVER['REQUEST_URI'], 1))
);