cvs: phpweb / manual-lookup.php /include manual-lookup.inc
| From: | Jim Winstead | Date: | Fri, 12 Jan 2001 20:48:29 +0000 |
| Subject: | cvs: phpweb / manual-lookup.php /include manual-lookup.inc | ||
| Groups: | php.mirrors | ||
| Request: | Send a blank email to php-mirrors+get-3370@lists.php.net to get a copy of this message | ||
jimw Fri Jan 12 12:48:29 2001 EDT
Added files:
/phpweb/include manual-lookup.inc
Modified files:
/phpweb manual-lookup.php
Log:
split manual-lookup functions into include file (error page will use it soon)
Index: phpweb/manual-lookup.php
diff -u phpweb/manual-lookup.php:1.6 phpweb/manual-lookup.php:1.7
--- phpweb/manual-lookup.php:1.6 Thu Nov 30 00:20:33 2000
+++ phpweb/manual-lookup.php Fri Jan 12 12:48:29 2001
@@ -1,82 +1,18 @@
<?php // -*- C++ -*-
require("shared.inc");
+require("manual-lookup.inc");
-$try_files = array();
-
$function = strtolower($function);
-
-function tryprefix($func, $prefix) {
- global $try_files, $MIRRORS, $MYSITE;
-
- // Get the country code, to find native
- // language manual entries first
- $cc = $MIRRORS[$MYSITE][0];
- $int_manual_try = array();
- $en_manual_try = array();
-
- $func = ereg_replace("_","-",$func);
- $func = ereg_replace('\(.*\)',"-",$func);
-
- $int_manual_try[] = "/manual/${cc}/${prefix}${func}.php";
- $en_manual_try[] = "/manual/${prefix}${func}.php";
-
- $nosp = ereg_replace(" ", "", $func);
- if ($nosp != $func) {
- $int_manual_try[] = "/manual/${cc}/${prefix}${nosp}.php";
- $en_manual_try[] = "/manual/${prefix}${nosp}.php";
- }
- $dasp = ereg_replace(" ", "-", $func);
- if ($dasp != $func) {
- $int_manual_try[] = "/manual/${cc}/${prefix}${dasp}.php";
- $en_manual_try[] = "/manual/${prefix}${dasp}.php";
- }
- $noul = ereg_replace("-", "", $func);
- if ($noul != $func) {
- $int_manual_try[] = "/manual/${cc}/${prefix}${noul}.php";
- $en_manual_try[] = "/manual/${prefix}${noul}.php";
- }
- $try_files = array_merge($try_files, $int_manual_try, $en_manual_try);
-}
+if (!isset($lang)) $lang = $MIRRORS[$MYSITE][6];
-tryprefix($function, "function.");
-tryprefix($function, "class.");
-tryprefix($function, "ref.");
-tryprefix($function, "feature-");
-tryprefix($function, "construct.");
-tryprefix($function, "control-structures.");
+$file = get_manual_page($lang, $function);
+if (!$file) $file = get_manual_page("en",$function);
-reset($try_files);
-while (list($dummy, $file) = each($try_files)) {
- if (file_exists($DOCUMENT_ROOT.$file)) {
- Header("Location: $file");
- exit;
- }
+if ($file) {
+ header("Location: $file");
+ exit;
}
-
-Header("Location:
search.php?pattern=".urlencode($function)."&show=nosource");
+
+header("Location:
search.php?pattern=".urlencode($function)."&show=nosource");
exit;
-
-
-CommonHeader("Quick Manual Reference");
-
-?>
-<h3>Oops!</h3>
-The function <B><?php echo $function;?></B> doesn't seem to exist.
-
-<h3>Why not?</h3>
-<UL>
-<LI>there is no manual page for that function ... yet
-<LI>you may have mis-spelt the function name
-<LI>you may have entered an alias to a function name, and that alias doesn't have
it's own manual page<BR>
-e.g. <B>mysql_num_rows</B> is the "real" function name, not
<B>mysql_numrows</B><BR>
-<LI>you entered a bunch of stuff I don't recognize<BR>
-e.g. you should enter <B>mysql_result</B>, not
<B>mysql_result($q1,0,"foobar");</B>
-</UL>
-<BR>
-
-If all else fails, just click <A HREF="/manual/">here</A> to go to the table
of contents for the online documentation,
-or click <A HREF="/quickref.php">here</A> for an alphabetical list of all PHP
functions.
-<P>
-
-<?php commonFooter(); ?>
Index: phpweb/include/manual-lookup.inc
+++ phpweb/include/manual-lookup.inc
<?php // -*- C++ -*-
function tryprefix($cc, $func, $prefix) {
global $DOCUMENT_ROOT;
// Get the country code, to find native
// language manual entries first
$try = array();
$func = ereg_replace("_","-",$func);
$func = ereg_replace('\(.*\)',"-",$func);
$try = "/manual/${cc}/${prefix}${func}.php";
if (file_exists("$DOCUMENT_ROOT$try")) return $try;
$nosp = ereg_replace(" ", "", $func);
if ($nosp != $func) {
$try = "/manual/${cc}/${prefix}${nosp}.php";
if (file_exists("$DOCUMENT_ROOT$try")) return $try;
}
$dasp = ereg_replace(" ", "-", $func);
if ($dasp != $func) {
$try = "/manual/${cc}/${prefix}${dasp}.php";
if (file_exists("$DOCUMENT_ROOT$try")) return $try;
}
$noul = ereg_replace("-", "", $func);
if ($noul != $func) {
$try = "/manual/${cc}/${prefix}${noul}.php";
if (file_exists("$DOCUMENT_ROOT$try")) return $try;
}
return "";
}
function find_manual_page($lang, $function) {
$sections = array("function.", "class.", "ref.",
"feature-", "construct.", "control-structures.");
while (list($t,$section) = each($sections)) {
$try = tryprefix($function, $section);
if ($try) return $try;
}
return "";
}