cvs: php-gtk-web / manual-lookup.php search.php /include layout.php

[email protected] ("Steph Fox")
Newsgroups php.gtk.webmaster
Message-ID <cvssfox1144993118@cvsserver>
sfox		Fri Apr 14 05:38:38 2006 UTC

  Modified files:              
    /php-gtk-web/include	layout.php 
    /php-gtk-web	manual-lookup.php search.php 
  Log:
  Putting manual-lookup.php back in the role it was intended to have
  (copied manual2-lookup.php into it)
  manual2-lookup.php can be CVS removed as soon as this is known to work live
sfox-20060414053838.txt (text/plain, 10.4 KB)
http://cvs.php.net/viewcvs.cgi/php-gtk-web/include/layout.php?r1=1.48&r2=1.49&diff_format=u
Index: php-gtk-web/include/layout.php
diff -u php-gtk-web/include/layout.php:1.48 php-gtk-web/include/layout.php:1.49
--- php-gtk-web/include/layout.php:1.48	Fri Apr 14 04:49:35 2006
+++ php-gtk-web/include/layout.php	Fri Apr 14 05:38:38 2006
@@ -1,5 +1,5 @@
 <?php
-/* $Id: layout.php,v 1.48 2006/04/14 04:49:35 sfox Exp $ */
+/* $Id: layout.php,v 1.49 2006/04/14 05:38:38 sfox Exp $ */
 
 # spacer()
 # print a IMG tag for a sized spacer GIF
@@ -196,7 +196,8 @@
        <input class="small" type="text" name="pattern" value="<?php echo htmlentities($prevsearch); ?>" size="30" />
        <small>in the</small>
        <select name="show" class="small">
-        <option value="manual">manual</option>
+        <option value="manual1">PHP-GTK 1 manual</option>
+        <option value="manual">PHP-GTK 2 manual</option>
         <option value="whole-site">whole site</option>
         <option value="wiki">wiki</option>
         <option value="php-gtk-general-list">general mailing list</option>
http://cvs.php.net/viewcvs.cgi/php-gtk-web/manual-lookup.php?r1=1.3&r2=1.4&diff_format=u
Index: php-gtk-web/manual-lookup.php
diff -u php-gtk-web/manual-lookup.php:1.3 php-gtk-web/manual-lookup.php:1.4
--- php-gtk-web/manual-lookup.php:1.3	Mon Nov 21 01:12:01 2005
+++ php-gtk-web/manual-lookup.php	Fri Apr 14 05:38:38 2006
@@ -1,198 +1,44 @@
 <?php
-require_once 'prepend.php';
-require_once 'manual-lookup.inc';
+//we are in php-gtk-web/ and need php-gtk-web/include/ as include path
+set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/include/');
 
-$pattern = $_POST['pattern'];
-$function = $_GET['function'];
-
-if (!$function && $pattern) $function = $pattern;
-$function = strtolower($function);
-
-/* it gets messy trying to pass $lang around - so get it from the referral dir */
-if(strstr(dirname($_SERVER[HTTP_REFERER]), "manual/")) {
-	$lang = substr(dirname($_SERVER[HTTP_REFERER]), -2);
-	}
-else {
-	$lang="en";
-	}
-/* there's always one, eh? */
-if($lang == "BR") $lang = "pt_BR";
-
-function make404($lang) {
-	commonHeader("404 Not Found");
-	$no_path = str_replace("/php-gtk-web/manual-lookup.php?lang=$lang&function=", "", htmlspecialchars($_SERVER[REQUEST_URI]));
-	$no_path = ereg_replace('&[x]=[0-9]&[y]=[0-9]', '', $no_path);
-	echo "<br>&nbsp;<H1>Not Found</H1><br>";
-	if(strlen($no_path) < 3)
-	echo "&nbsp;<B>" . $no_path . "</B> is too short to be used as a search string.  <a href=$_SERVER[HTTP_REFERER]>Go back and try something longer</a><br><br><br><br><br><br><br>";
-	else echo "&nbsp;The function <B>" . $no_path . "</B> could not be found.  <a href=$_SERVER[HTTP_REFERER]>Try again</a><br><br><br><br><br><br><br>";
-	commonFooter();
-}
-
-function multi_choice($file, $lang) {
-	global $full_match;
-	$request = $_GET['function'];
-	$switch = (int)0;
-
-	if($full_match > 1) {
-		commonHeader('multiple choice');
-		echo "<br><br>";
-		echo "<h1>Which &quot;$request&quot; did you want?</h1>\n";
-		echo "<br>";
-	}
-	elseif($full_match < 1) {
-		commonHeader('multiple choice');
-		echo "<br><br>";
-		echo "<h1>There is no exact match for &quot;$request&quot;.<br>Here is a list of the nearest matches:</h1>\n";
-		echo "<br>";
-		$switch = 1;
-	}
-	for($i = 0; $i < sizeof($file); $i++) {
-		$path[$i] = str_replace("/manual/", "", $file[$i]);
-		$bits[$i][] = explode(".", $path[$i]);
-
-		foreach($bits[$i] as $piece) {
-		$GTK = substr(strtoupper($piece[0]), strlen($lang) + 1);
-		$classlink = strtolower($file[$i]);
-		if(strpos($classlink, "pt_br")) 
-			$classlink = str_replace("pt_br", "pt_BR", $classlink);
-
-		if(sizeof($piece) == 5 && $piece[2] == "method") {
-		similar_text(strtolower($request), strtolower($piece[3]), $percent);
-		if($percent == 100 && $full_match == 1) {
-			header("Location: http://$_SERVER[HTTP_HOST]$classlink");
-			exit;
-/* We should have a nice clean separate function for $full_match == 1) */
-			}
-		elseif(($percent == 100 && $full_match > 1) || ($percent > 50 && $full_match == 0)) {
-			echo "<P>&nbsp;$piece[3]() as in the <B><a href = 'http://$_SERVER[HTTP_HOST]$classlink'>$piece[1] $piece[2]</a></B>";
-			if($switch == 0) echo "?";
-			echo "</P>";
-			}
-		}
-		elseif(sizeof($piece) == 5 && $piece[2] == "property") {
-		$prop = strtolower(substr($piece[1], 3, strlen($piece[1])));
-		if(strstr($prop, "event")) $prop = "event";
-		similar_text(strtolower($request), strtolower($piece[3]), $percent);
-		if($percent == 100 && $full_match == 1) {
-			header("Location: http://$_SERVER[HTTP_HOST]$classlink");
-			exit;
-		}
-		elseif(($percent == 100 && $full_match > 1) || ($percent > 50 && $full_match == 0)) {
-			echo "<P>&nbsp;\$$prop-&gt;$piece[3] as in the <B><a href = 'http://$_SERVER[HTTP_HOST]$classlink'>$piece[1] $piece[2]</a></B>";
-			if($switch == 0) echo "?";
-			echo "</P>";
-			}
-		}
-		elseif(sizeof($piece) == 5) {
-		similar_text(strtolower($request), strtolower($piece[3]), $percent);
-		if($percent == 100 && $full_match == 1) {
-			header("Location: http://$_SERVER[HTTP_HOST]$classlink");
-			exit;
-			}
-		elseif(($percent == 100 && $full_match > 1) || ($percent > 50 && $full_match == 0)) {
-			echo "<P>&nbsp;&quot;$piece[3]&quot; as in the <B><a href = 'http://$_SERVER[HTTP_HOST]$classlink'>$piece[1] $piece[2]</a></B>";
-			$i++;
-			}
-		}
-		elseif(sizeof($piece) == 4 && $piece[1] == "enum") {
-		similar_text(strtolower($request), strtolower($piece[2]), $percent);
-		if($percent == 100 && $full_match == 1) {
-			header("Location: http://$_SERVER[HTTP_HOST]$classlink");
-			exit;
-			}
-		elseif(($percent == 100 && $full_match > 1) || ($percent > 50 && $full_match !== 1)) {
-			echo "<P>&nbsp;[$piece[2]Value] as in the <B><a href = 'http://$_SERVER[HTTP_HOST]$classlink'>$piece[2] $piece[1]s</a></B>";
-			if($switch == 0) echo "?";
-			echo "</P>";
-			}
-		}
-		elseif(sizeof($piece) == 4 && $piece[2] == "constructor") {
-		similar_text(strtolower($request), strtolower($piece[1]), $percent);
-		if($percent == 100 && $full_match == 1) {
-			header("Location: http://$_SERVER[HTTP_HOST]$classlink");
-			exit;
-			}
-		elseif(($percent == 100 && $full_match > 1) || ($percent > 50 && $full_match !== 1)) {
-			echo "<P>&nbsp;$piece[1]() as in the <B><a href = 'http://$_SERVER[HTTP_HOST]$classlink'>$piece[1] $piece[2]</a></B>";
-			if($switch == 0) echo "?";
-			echo "</P>";
-			}
-		}
-		elseif(sizeof($piece) == 4) {
-		similar_text(strtolower($request), strtolower($piece[2]), $percent);
-		if($percent == 100 && $full_match == 1) {
-			header("Location: http://$_SERVER[HTTP_HOST]$classlink");
-			exit;
-			}
-		elseif(($percent == 100 && $full_match > 1) || ($percent > 50 && $full_match !== 1)) {
-			echo "<P>&nbsp;$piece[2]() as in the <B><a href = 'http://$_SERVER[HTTP_HOST]$classlink'>$GTK function</a></B>";
-			if($switch == 0) echo "?";
-			echo "</P>";
-			}
-		}
-		elseif(sizeof($piece) == 3 && $piece[2] == "constructor") {
-		similar_text(strtolower($request), strtolower($piece[1]), $percent);
-		if($percent == 100 && $full_match == 1) {
-			header("Location: http://$_SERVER[HTTP_HOST]$classlink");
-			exit;
-			}
-		elseif(($percent == 100 && $full_match > 1) || ($percent > 50 && $full_match !== 1)) {
-			echo "<P>&nbsp;$piece[1]() as in the <B><a href = 'http://$_SERVER[HTTP_HOST]$classlink.php'>$piece[1] $piece[2]</a></B>";
-			if($switch == 0) echo "?";
-			echo "</P>";
-			}
-		}
-		elseif(sizeof($piece) == 3) {
-		similar_text(strtolower($request), strtolower($piece[1]), $percent);
-		if($percent == 100 && $full_match == 1) {
-			header("Location: http://$_SERVER[HTTP_HOST]$classlink");
-			exit;
-			}
-		elseif(($percent == 100 && $full_match > 1) || ($percent > 50 && $full_match !== 1)) {
-			echo "<P>&nbsp;$piece[1] as in the <B><a href = 'http://$_SERVER[HTTP_HOST]$classlink'>$piece[1] class</a></B>";
-			if($switch == 0) echo "?";
-			echo "</P>";
-			}
-		}
-	}
-	}
-	echo "<br><a href=$_SERVER[HTTP_REFERER]>Back</a>";
-	commonFooter();
+$strResult = null;
+$strError  = null;
+$strSearch = null;
+$strSelectedType = '';
+
+if (isset($_REQUEST['q']) && $_REQUEST['q'] != '') {
+    require_once 'PhpGtkDoc/Search2.php';
+    require_once 'PhpGtkDoc/Search2/Result/Html.php';
+
+    $strIndexFile = dirname(__FILE__) . '/include/PhpGtkDoc/index.search';
+    $strDocumentationDir = 'manual/en/';
+
+    if (isset($_REQUEST['type']) && isset($arTypes[$_REQUEST['type']])) {
+        $strSelectedType = $_REQUEST['type'];
+    }
+
+    $strSearch = preg_replace('/[^a-zA-Z0-9_ ]/', '', $_REQUEST['q']);
+    try {
+        $arResults = PhpGtkDoc_Search2::find($strSearch, $strIndexFile);
+        $strResult = PhpGtkDoc_Search2_Result_Html::format($arResults, $strDocumentationDir, $strSelectedType);
+
+        if ($strResult == '') {
+            $strResult = '<p>Your search for "' . $strSearch . '" didn\'t return any results.</p>';
+        }
+    } catch (Exception $e) {
+        $strError = $e->getMessage();
+    }
+}
+
+commonHeader('Search results');
+if ($strError !== null) {
+    echo '<h2>Error</h2>';
+    echo $strError;
+}
+if ($strResult !== null) {
+    echo '<h2>PHP-GTK 2 manual search results for "' . $strSearch . '"</h2>';
+    echo $strResult;
 }
-
-$function = strtolower($_GET['function']);
-
-if(strlen($function) < 3) {
-	make404($lang);
-	exit;
-}
-
-$file = find_manual_page($lang, $function);
-
-if(is_array($file)) {
-	if(sizeof($file) < 2) {
-		$file = strtolower($file[0]);
-		if(strpos($file, "pt_br")) 
-			$file = str_replace("pt_br", "pt_BR", $file);
-		header("Location: http://$_SERVER[HTTP_HOST]$file");
-		exit;
-	}
-	multi_choice($file, $lang);
-	exit;
-}
-
-elseif($file  && !is_array($file)) {
-	$file = strtolower($file);
-	if(strpos($file, "pt_br")) 
-		$file = str_replace("pt_br", "pt_BR", $file);
-	header("Location: http://$_SERVER[HTTP_HOST]$file");
-	exit;
-}
-
-else {
-	make404($lang);
-	exit;
-}
-
+commonFooter();
 ?>
http://cvs.php.net/viewcvs.cgi/php-gtk-web/search.php?r1=1.12&r2=1.13&diff_format=u
Index: php-gtk-web/search.php
diff -u php-gtk-web/search.php:1.12 php-gtk-web/search.php:1.13
--- php-gtk-web/search.php:1.12	Tue Apr 11 09:33:20 2006
+++ php-gtk-web/search.php	Fri Apr 14 05:38:38 2006
@@ -7,8 +7,8 @@
 	}
 $show = $_POST['show'];
 
-if(isset($pattern) && ($pattern) && isset($show) && ($show == "manual2")) {
-    $location = "/manual2-lookup.php";
+if(isset($pattern) && ($pattern) && isset($show) && ($show == "manual")) {
+    $location = "/manual-lookup.php";
     $query = "q=".urlencode($pattern);
     Header("Location: ".$location."?".$query);
     exit;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.