cvs: php-gtk-doc /search manual-lookup.php /search/include manual-lookup.inc
| From: | Steph Fox | Date: | Fri, 31 Jan 2003 16:07:49 +0000 |
| Subject: | cvs: php-gtk-doc /search manual-lookup.php /search/include manual-lookup.inc | ||
| Groups: | php.gtk.doc | ||
| Request: | Send a blank email to php-gtk-doc+get-601@lists.php.net to get a copy of this message | ||
sfox Fri Jan 31 11:07:49 2003 EDT
Modified files:
/php-gtk-doc/search manual-lookup.php
/php-gtk-doc/search/include manual-lookup.inc
Log:
Manual search now finds any function containing the search pattern - just don't use it to
look for 'set' just yet :)
Index: php-gtk-doc/search/manual-lookup.php diff -u php-gtk-doc/search/manual-lookup.php:1.1 php-gtk-doc/search/manual-lookup.php:1.2 --- php-gtk-doc/search/manual-lookup.php:1.1 Mon Jan 27 14:15:58 2003 +++ php-gtk-doc/search/manual-lookup.php Fri Jan 31 11:07:49 2003 @@ -1,77 +1,79 @@ -<? -require_once 'include/manual-lookup.inc'; -require 'include/prepend.php'; - -function make404() { - commonHeader("404 Not Found"); - $no_path = str_replace("/manual-lookup.php?function=", "", $_SERVER[REQUEST_URI]); - $no_path = ereg_replace('&[x]=[0-9]&[y]=[0-9]', '', $no_path); - echo "<br> <H1>Not Found</H1><br>"; - echo " 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) { - commonHeader('multiple choice'); - $request = $_GET['function']; - echo "<br><br>"; - echo "<h1>Which "$request" did you want?</h1>\n"; - echo "<br>"; - for($i = 0; $i < sizeof($file); $i++) { - $path[$i] = str_replace("/manual/", "", $file[$i]); - $bits[$i][] = explode(".", $path[$i]); - foreach($bits[$i] as $piece) { - for($x = 0; $x < sizeof($piece); $x++) {} - } - - $GTK = strtoupper($piece[0]); - $classlink = strtolower($file[$i]); - - if(sizeof($piece) == 5 && $piece[2] == "method") - echo "<P> $piece[3]() as in the <B><a href = 'http://$_SERVER[HTTP_HOST]$classlink'>$piece[1] $piece[2]</a></B>?</P>"; - elseif(sizeof($piece) == 5 && $piece[2] == "property") { - $prop = strtolower(substr($piece[1], 3, strlen($piece[1]))); - if(strstr($prop, "event")) $prop = "event"; - echo "<P> \$$prop->$piece[3] as in the <B><a href = 'http://$_SERVER[HTTP_HOST]$classlink'>$piece[1] $piece[2]</a></B>?</P>"; - } - elseif(sizeof($piece) == 5) - echo "<P> "$piece[3]" as in the <B><a href = 'http://$_SERVER[HTTP_HOST]$classlink'>$piece[1] $piece[2]</a></B>?</P>"; - elseif(sizeof($piece) == 4 && $piece[1] == "enum") - echo "<P> [$piece[2]Value] as in the <B><a href = 'http://$_SERVER[HTTP_HOST]$classlink'>$piece[2] $piece[1]s</a></B>?</P>"; - elseif(sizeof($piece) == 4 && $piece[2] == "constructor") - echo "<P> $piece[1]() as in the <B><a href = 'http://$_SERVER[HTTP_HOST]$classlink'>$piece[1] $piece[2]</a></B>?</P>"; - elseif(sizeof($piece) == 4) - echo "<P> $piece[2]() as in the $GTK static function <B><a href = 'http://$_SERVER[HTTP_HOST]$classlink'>$piece[0]::$piece[2]</a></B>?</P>"; - elseif(sizeof($piece) == 3) - echo "<P> $piece[1] as in the <B><a href = 'http://$_SERVER[HTTP_HOST]$classlink'>$piece[1] class</a></B>?</P>"; - } - echo "<br><a href=$_SERVER[HTTP_REFERER]>Back</a>"; - commonFooter(); -} - -$function = strtolower($_GET['function']); - -$file = find_manual_page($function); - -if(is_array($file)) { - if(sizeof($file) < 2) { - $file[0] = strtolower($file[0]); - header("Location: http://$_SERVER[HTTP_HOST]$file[0]"); - exit; - } - multi_choice($file); - exit; -} - -elseif($file && !is_array($file)) { - $file = strtolower($file); - header("Location: http://$_SERVER[HTTP_HOST]$file"); - exit; -} - -else { - make404(); - exit; -} - -?> +<? +require_once 'include/manual-lookup.inc'; +require 'include/prepend.php'; + +function make404() { + commonHeader("404 Not Found"); + $no_path = str_replace("/manual-lookup.php?function=", "", $_SERVER[REQUEST_URI]); + $no_path = ereg_replace('&[x]=[0-9]&[y]=[0-9]', '', $no_path); + echo "<br> <H1>Not Found</H1><br>"; + echo " 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) { + commonHeader('multiple choice'); + $request = $_GET['function']; + echo "<br><br>"; + echo "<h1>Which "$request" did you want?</h1>\n"; + echo "<br>"; + for($i = 0; $i < sizeof($file); $i++) { + $path[$i] = str_replace("/manual/", "", $file[$i]); + $bits[$i][] = explode(".", $path[$i]); + foreach($bits[$i] as $piece) { + for($x = 0; $x < sizeof($piece); $x++) {} + } + + $GTK = strtoupper($piece[0]); + $classlink = strtolower($file[$i]); + + if(sizeof($piece) == 5 && $piece[2] == "method") + echo "<P> $piece[3]() as in the <B><a href = 'http://$_SERVER[HTTP_HOST]$classlink'>$piece[1] $piece[2]</a></B>?</P>"; + elseif(sizeof($piece) == 5 && $piece[2] == "property") { + $prop = strtolower(substr($piece[1], 3, strlen($piece[1]))); + if(strstr($prop, "event")) $prop = "event"; + echo "<P> \$$prop->$piece[3] as in the <B><a href = 'http://$_SERVER[HTTP_HOST]$classlink'>$piece[1] $piece[2]</a></B>?</P>"; + } + elseif(sizeof($piece) == 5) + echo "<P> "$piece[3]" as in the <B><a href = 'http://$_SERVER[HTTP_HOST]$classlink'>$piece[1] $piece[2]</a></B>?</P>"; + elseif(sizeof($piece) == 4 && $piece[1] == "enum") + echo "<P> [$piece[2]Value] as in the <B><a href = 'http://$_SERVER[HTTP_HOST]$classlink'>$piece[2] $piece[1]s</a></B>?</P>"; + elseif(sizeof($piece) == 4 && $piece[2] == "constructor") + echo "<P> $piece[1]() as in the <B><a href = 'http://$_SERVER[HTTP_HOST]$classlink'>$piece[1] $piece[2]</a></B>?</P>"; + elseif(sizeof($piece) == 4) + echo "<P> $piece[2]() as in the <B><a href = 'http://$_SERVER[HTTP_HOST]$classlink'>$GTK function</a></B>?</P>"; + elseif(sizeof($piece) == 3 && $piece[2] == "constructor") + echo "<P> $piece[1] as in the <B><a href = 'http://$_SERVER[HTTP_HOST]$classlink.php'>$piece[1] $piece[2]</a></B>?</P>"; + elseif(sizeof($piece) == 3) + echo "<P> $piece[1] as in the <B><a href = 'http://$_SERVER[HTTP_HOST]$classlink'>$piece[1] class</a></B>?</P>"; + } + echo "<br><a href=$_SERVER[HTTP_REFERER]>Back</a>"; + commonFooter(); +} + +$function = strtolower($_GET['function']); + +$file = find_manual_page($function); + +if(is_array($file)) { + if(sizeof($file) < 2) { + $file[0] = strtolower($file[0]); + header("Location: http://$_SERVER[HTTP_HOST]$file[0]"); + exit; + } + multi_choice($file); + exit; +} + +elseif($file && !is_array($file)) { + $file = strtolower($file); + header("Location: http://$_SERVER[HTTP_HOST]$file"); + exit; +} + +else { + make404(); + exit; +} + +?> Index: php-gtk-doc/search/include/manual-lookup.inc diff -u php-gtk-doc/search/include/manual-lookup.inc:1.1 php-gtk-doc/search/include/manual-lookup.inc:1.2 --- php-gtk-doc/search/include/manual-lookup.inc:1.1 Mon Jan 27 14:07:38 2003 +++ php-gtk-doc/search/include/manual-lookup.inc Fri Jan 31 11:07:49 2003 @@ -1,13 +1,16 @@ <?php -function tryprefix($func, $prefix) { - -/* set up the tools for the job - this array tests class and enum names */ +/* set up the tools for the job - this array tests class and enum names +in order to capitalize them correctly, throughout the search routines */ $classes = array('GtkAccelGroup.', 'GtkAccelLabel.', 'GtkAdjustment.', 'GtkAlignment.', 'GtkArrow.', 'GtkAspectFrame.', 'GtkBin.', 'GtkBox.', 'GtkBoxChild.', 'GtkButton.', 'GtkButtonBox.', 'GtkCalendar.', 'GtkCheckButton.', 'GtkCheckMenuItem.', 'GtkCList.', 'GtkCListRow.', 'GtkColorSelection.', 'GtkColorSelectionDialog.', 'GtkCombo.', 'GtkContainer.', 'GtkCTree.', 'GtkCTreeNode.', 'GtkCurve.', 'GtkData.', 'GtkDialog.', 'GtkDrawingArea.', 'GtkEditable.', 'GtkEntry.', 'GtkEventBox.', 'GtkFileSelection.', 'GtkFixed.', 'GtkFixedChild.', 'GtkFontSelection.', 'GtkFontSelectionDialog.', 'GtkFrame.', 'GtkGammaCurve.', 'GtkHandleBox.', 'GtkHBox.', 'GtkHButtonBox.', 'GtkHPaned.', 'GtkHRuler.', 'GtkHScale.', 'GtkHScrollbar.', 'GtkHSeparator.', 'GtkImage.', 'GtkInputDialog.', 'GtkInvisible.', 'GtkItem.', 'GtkItemFactory.', 'GtkLabel.', 'GtkLayout.', 'GtkList.', 'GtkListItem.', 'GtkMenu.', 'GtkMenuBar.', 'GtkMenuItem.', 'GtkMenuShell.', 'GtkMisc.', 'GtkNotebook.', 'GtkObject.', 'GtkOptionMenu.', 'GtkPacker.', 'GtkPaned.', 'GtkPixmap.', 'GtkPlug.', 'GtkPreview.', 'GtkProgress.', 'GtkProgressbar.', 'GtkRadioButton.', 'GtkRadioMenuItem.', 'GtkRange.', 'GtkRuler.', 'GtkScale.', 'GtkScrollbar.', 'GtkScrolledWindow.', 'GtkSelectionData.', 'GtkSeparator.', 'GtkSocket.', 'GtkSpinButton.', 'GtkStatusBar.', 'GtkStyle.', 'GtkTable.', 'GtkTableChild.', 'GtkTearoffMenuItem.', 'GtkText.', 'GtkTipsQuery.', 'GtkToggleButton.', 'GtkToolBar.', 'GtkToolTips.', 'GtkTree.', 'GtkTreeItem.', 'GtkVBox.', 'GtkVButtonBox.', 'GtkViewport.', 'GtkVPaned.', 'GtkVRuler.', 'GtkVScale.', 'GtkVScrollbar.', 'GtkVSeparator.', 'GtkWidget.', 'GtkWindow.', 'GdkAtom.', 'GdkBitmap.', 'GdkColor.', 'GdkColormap.', 'GdkCursor.', 'GdkDragContext.', 'GdkEvent.', 'GdkEventAny.', 'GdkEventExpose.', 'GdkFont.', 'GdkGC.', 'GdkPixmap.', 'GdkVisual.', 'GdkWindow.', 'GdkCapStyle.', 'GdkCursorType.', 'GdkDragAction.', 'GdkEventMask.', 'GdkEventType.', 'GdkFill.', 'GdkFontType.', 'GdkFunction.', 'GdkInputCondition.', 'GdkJoinStyle.', 'GdkLineStyle.', 'GdkModifierType.', 'GdkRgbDither.', 'GdkSubwindowMode.', 'GdkVisualType.', 'GtkAccelFlags.', 'GtkAnchorType.', 'GtkArrowType.', 'GtkAttachOptions.', 'GtkButtonAction.', 'GtkButtonBoxStyle.', 'GtkCalendarDisplayOptions.', 'GtkCellType.', 'GtkCornerStyle.', 'GtkCTreeExpanderStyle.', 'GtkCTreeExpansionType.', 'GtkCTreeLineStyle.', 'GtkCurveType.', 'GtkDestDefaults.', 'GtkDirectionType.', 'GtkFontFilterType.', 'GtkFontType.', 'GtkJustification.', 'GtkObjectFlags.', 'GtkOrientation.', 'GtkPackerOptions.', 'GtkPackType.', 'GtkPolicyType.', 'GtkPositionType.', 'GtkPreviewType.', 'GtkProgressBarOrientation.', 'GtkProgressBarStyle.', 'GtkReliefStyle.', 'GtkResizeMode.', 'GtkScrollType.', 'GtkSelectionMode.', 'GtkShadowType.', 'GtkSideType.', 'GtkSortType.', 'GtkSpinButtonUpdatePolicy.', 'GtkSpinType.', 'GtkStateType.', 'GtkSubmenuPlacement.', 'GtkToolbarChildType.', 'GtkToolbarSpaceStyle.', 'GtkToolbarStyle.', 'GtkTreeViewMode.', 'GtkUpdateType.', 'GtkVisibility.', 'GtkWidgetFlags.', 'GtkWindowPosition.', 'GtkWindowType.'); +function tryprefix($func, $prefix) { +global $classes; + $types = array('method.', 'signal.', 'property.'); $first = substr($prefix, 0, 3); $hit = array(); +$part = array(); /* just so's we don't have to guess wildly at capitalisation in classes/enums */ for($i = 0; $i < sizeof($classes); $i++) { @@ -34,73 +37,89 @@ else if (file_exists("$_SERVER[DOCUMENT_ROOT]$try")) $hit[] = $try; } -/* full queries can only have this return, so send it straight home to Daddy */ return $hit; } +} -/* undeclared class/constructor or enum */ - $try = "/manual/${prefix}${first}${func}.php"; - $constructor = "/manual/${prefix}${first}${func}.constructor.php"; - if (file_exists("$_SERVER[DOCUMENT_ROOT]$constructor")) { - for($i = 0; $i < sizeof($classes); $i++) { - if(stristr($classes[$i], "${first}${func}.")) $pos = $i; - } - $realname = $classes[$pos]; - $try = "/manual/${prefix}${realname}php"; - $constructor = "/manual/${prefix}${realname}constructor.php"; - $hit = array($try, $constructor); - } - else { - if (file_exists("$_SERVER[DOCUMENT_ROOT]$try")) { - for($i = 0; $i < sizeof($classes); $i++) { - if(stristr($classes[$i], "${first}${func}.")) { - $pos = $i; - $realname = $classes[$pos]; - $try = "/manual/${prefix}${realname}php"; +function wildcard($func, $hit) { +global $classes; + $dir = opendir("$_SERVER[DOCUMENT_ROOT]/manual"); + while(($item = readdir($dir))!== false) { + $part = explode('.', $item); + $gtk = $part[0]; + $class = substr($part[1], 0, 3); + $enum = substr($part[2], 0, 3); + $method = substr($part[3], 0, 3); + if($gtk == $class || $gtk == $enum) { + if(strstr($part[1], $func) || strstr($part[2], $func)) { + if($part[2] !== "method" && $part[2] !== "property" + && $part[2] !== "signal") { + $try = "/manual/$item"; + if(file_exists("$_SERVER[DOCUMENT_ROOT]$try") && + !in_array($try, $hit)) { + if(strstr($part[1], $func)) $uc = $part[1]; + else $uc = $part[2]; + for($i = 0; $i < sizeof($classes); $i++) { + if(stristr($classes[$i], "$uc.")) $pos = $i; + } + $realname = $classes[$pos]; + if ($uc == $part[1]) + $try = "/manual/$part[0].$realname$part[2]"; + else + $try = "/manual/$part[0].$part[1].$realname$part[3]"; + $hit[] = $try; + } } } - $hit[] = $try; } - } -/* undeclared static function */ - $try = "/manual/${prefix}method.${func}.php"; - if(file_exists("$_SERVER[DOCUMENT_ROOT]$try")) $hit[] = $try; - -/* class methods, signals and properties with no clues attached */ - foreach($classes as $class) { - $lowclass = strtolower($class); - foreach($types as $type) { - if($first == substr($lowclass, 0, 3)) { - $try = "/manual/${prefix}${lowclass}${type}${func}.php"; - $uc = "/manual/${prefix}${class}${type}${func}.php"; - if(file_exists("$_SERVER[DOCUMENT_ROOT]$try")) - $hit[] = $uc; + if($part[1] == "method") { + if(strstr($part[2], $func)) { + $try = "/manual/$item"; + if(file_exists("$_SERVER[DOCUMENT_ROOT]$try") && !in_array($try, $hit)) $hit[] = $try; + } + } + + if($gtk == $class && strstr($part[3], $func)) { + $try = "/manual/$item"; + if(file_exists("$_SERVER[DOCUMENT_ROOT]$try") && !in_array($try, $hit)) { + for($i = 0; $i < sizeof($classes); $i++) { + if(stristr($classes[$i], "$part[1].")) $pos = $i; + } + $realname = $classes[$pos]; + $try = "/manual/$part[0].$realname$part[2].$part[3].$part[4]"; + $hit[] = $try; } } } + closedir($dir); return $hit; } function find_manual_page($function) { -/* names of xml-generated sections */ -$sections = array("gdk.enum.", "gdk.", "gtk.enum.", "gtk."); +$hit = array(); -/* if there's no :: in there we could be looking for anything */ - if(!strstr($function, "::")) { - foreach($sections as $section) { - $try = tryprefix($function, $section); - if($try) $result = array_merge($try, $result); - } - if($result) return $result; - } - else { /* fast track, single return :) */ + if(strstr($function, "::")) { list($funcpre, $funcpost) = split("::", $function); $try = tryprefix($funcpost, "$funcpre.method."); if($try) return $try; } + elseif(strtolower(substr($function, 0, 3)) == "gtk" || + strtolower(substr($function, 0, 3 == "gdk"))) { + $prefix = strtolower(substr($function, 0, 3)); + $try = tryprefix($function, "$prefix."); + if($try) return $try; + } + else { +/* if there's no :: or gtk in there we could be looking for anything */ + $try = wildcard($function, $hit); + if($try) $result = array_merge($try, $result); + } + if($result) { + return $result; + } return ""; }
Index: php-gtk-doc/search/manual-lookup.php diff -u php-gtk-doc/search/manual-lookup.php:1.1 php-gtk-doc/search/manual-lookup.php:1.2 --- php-gtk-doc/search/manual-lookup.php:1.1 Mon Jan 27 14:15:58 2003 +++ php-gtk-doc/search/manual-lookup.php Fri Jan 31 11:07:49 2003 @@ -1,77 +1,79 @@ -<? -require_once 'include/manual-lookup.inc'; -require 'include/prepend.php'; - -function make404() { - commonHeader("404 Not Found"); - $no_path = str_replace("/manual-lookup.php?function=", "", $_SERVER[REQUEST_URI]); - $no_path = ereg_replace('&[x]=[0-9]&[y]=[0-9]', '', $no_path); - echo "<br> <H1>Not Found</H1><br>"; - echo " 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) { - commonHeader('multiple choice'); - $request = $_GET['function']; - echo "<br><br>"; - echo "<h1>Which "$request" did you want?</h1>\n"; - echo "<br>"; - for($i = 0; $i < sizeof($file); $i++) { - $path[$i] = str_replace("/manual/", "", $file[$i]); - $bits[$i][] = explode(".", $path[$i]); - foreach($bits[$i] as $piece) { - for($x = 0; $x < sizeof($piece); $x++) {} - } - - $GTK = strtoupper($piece[0]); - $classlink = strtolower($file[$i]); - - if(sizeof($piece) == 5 && $piece[2] == "method") - echo "<P> $piece[3]() as in the <B><a href = 'http://$_SERVER[HTTP_HOST]$classlink'>$piece[1] $piece[2]</a></B>?</P>"; - elseif(sizeof($piece) == 5 && $piece[2] == "property") { - $prop = strtolower(substr($piece[1], 3, strlen($piece[1]))); - if(strstr($prop, "event")) $prop = "event"; - echo "<P> \$$prop->$piece[3] as in the <B><a href = 'http://$_SERVER[HTTP_HOST]$classlink'>$piece[1] $piece[2]</a></B>?</P>"; - } - elseif(sizeof($piece) == 5) - echo "<P> "$piece[3]" as in the <B><a href = 'http://$_SERVER[HTTP_HOST]$classlink'>$piece[1] $piece[2]</a></B>?</P>"; - elseif(sizeof($piece) == 4 && $piece[1] == "enum") - echo "<P> [$piece[2]Value] as in the <B><a href = 'http://$_SERVER[HTTP_HOST]$classlink'>$piece[2] $piece[1]s</a></B>?</P>"; - elseif(sizeof($piece) == 4 && $piece[2] == "constructor") - echo "<P> $piece[1]() as in the <B><a href = 'http://$_SERVER[HTTP_HOST]$classlink'>$piece[1] $piece[2]</a></B>?</P>"; - elseif(sizeof($piece) == 4) - echo "<P> $piece[2]() as in the $GTK static function <B><a href = 'http://$_SERVER[HTTP_HOST]$classlink'>$piece[0]::$piece[2]</a></B>?</P>"; - elseif(sizeof($piece) == 3) - echo "<P> $piece[1] as in the <B><a href = 'http://$_SERVER[HTTP_HOST]$classlink'>$piece[1] class</a></B>?</P>"; - } - echo "<br><a href=$_SERVER[HTTP_REFERER]>Back</a>"; - commonFooter(); -} - -$function = strtolower($_GET['function']); - -$file = find_manual_page($function); - -if(is_array($file)) { - if(sizeof($file) < 2) { - $file[0] = strtolower($file[0]); - header("Location: http://$_SERVER[HTTP_HOST]$file[0]"); - exit; - } - multi_choice($file); - exit; -} - -elseif($file && !is_array($file)) { - $file = strtolower($file); - header("Location: http://$_SERVER[HTTP_HOST]$file"); - exit; -} - -else { - make404(); - exit; -} - -?> +<? +require_once 'include/manual-lookup.inc'; +require 'include/prepend.php'; + +function make404() { + commonHeader("404 Not Found"); + $no_path = str_replace("/manual-lookup.php?function=", "", $_SERVER[REQUEST_URI]); + $no_path = ereg_replace('&[x]=[0-9]&[y]=[0-9]', '', $no_path); + echo "<br> <H1>Not Found</H1><br>"; + echo " 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) { + commonHeader('multiple choice'); + $request = $_GET['function']; + echo "<br><br>"; + echo "<h1>Which "$request" did you want?</h1>\n"; + echo "<br>"; + for($i = 0; $i < sizeof($file); $i++) { + $path[$i] = str_replace("/manual/", "", $file[$i]); + $bits[$i][] = explode(".", $path[$i]); + foreach($bits[$i] as $piece) { + for($x = 0; $x < sizeof($piece); $x++) {} + } + + $GTK = strtoupper($piece[0]); + $classlink = strtolower($file[$i]); + + if(sizeof($piece) == 5 && $piece[2] == "method") + echo "<P> $piece[3]() as in the <B><a href = 'http://$_SERVER[HTTP_HOST]$classlink'>$piece[1] $piece[2]</a></B>?</P>"; + elseif(sizeof($piece) == 5 && $piece[2] == "property") { + $prop = strtolower(substr($piece[1], 3, strlen($piece[1]))); + if(strstr($prop, "event")) $prop = "event"; + echo "<P> \$$prop->$piece[3] as in the <B><a href = 'http://$_SERVER[HTTP_HOST]$classlink'>$piece[1] $piece[2]</a></B>?</P>"; + } + elseif(sizeof($piece) == 5) + echo "<P> "$piece[3]" as in the <B><a href = 'http://$_SERVER[HTTP_HOST]$classlink'>$piece[1] $piece[2]</a></B>?</P>"; + elseif(sizeof($piece) == 4 && $piece[1] == "enum") + echo "<P> [$piece[2]Value] as in the <B><a href = 'http://$_SERVER[HTTP_HOST]$classlink'>$piece[2] $piece[1]s</a></B>?</P>"; + elseif(sizeof($piece) == 4 && $piece[2] == "constructor") + echo "<P> $piece[1]() as in the <B><a href = 'http://$_SERVER[HTTP_HOST]$classlink'>$piece[1] $piece[2]</a></B>?</P>"; + elseif(sizeof($piece) == 4) + echo "<P> $piece[2]() as in the <B><a href = 'http://$_SERVER[HTTP_HOST]$classlink'>$GTK function</a></B>?</P>"; + elseif(sizeof($piece) == 3 && $piece[2] == "constructor") + echo "<P> $piece[1] as in the <B><a href = 'http://$_SERVER[HTTP_HOST]$classlink.php'>$piece[1] $piece[2]</a></B>?</P>"; + elseif(sizeof($piece) == 3) + echo "<P> $piece[1] as in the <B><a href = 'http://$_SERVER[HTTP_HOST]$classlink'>$piece[1] class</a></B>?</P>"; + } + echo "<br><a href=$_SERVER[HTTP_REFERER]>Back</a>"; + commonFooter(); +} + +$function = strtolower($_GET['function']); + +$file = find_manual_page($function); + +if(is_array($file)) { + if(sizeof($file) < 2) { + $file[0] = strtolower($file[0]); + header("Location: http://$_SERVER[HTTP_HOST]$file[0]"); + exit; + } + multi_choice($file); + exit; +} + +elseif($file && !is_array($file)) { + $file = strtolower($file); + header("Location: http://$_SERVER[HTTP_HOST]$file"); + exit; +} + +else { + make404(); + exit; +} + +?> Index: php-gtk-doc/search/include/manual-lookup.inc diff -u php-gtk-doc/search/include/manual-lookup.inc:1.1 php-gtk-doc/search/include/manual-lookup.inc:1.2 --- php-gtk-doc/search/include/manual-lookup.inc:1.1 Mon Jan 27 14:07:38 2003 +++ php-gtk-doc/search/include/manual-lookup.inc Fri Jan 31 11:07:49 2003 @@ -1,13 +1,16 @@ <?php -function tryprefix($func, $prefix) { - -/* set up the tools for the job - this array tests class and enum names */ +/* set up the tools for the job - this array tests class and enum names +in order to capitalize them correctly, throughout the search routines */ $classes = array('GtkAccelGroup.', 'GtkAccelLabel.', 'GtkAdjustment.', 'GtkAlignment.', 'GtkArrow.', 'GtkAspectFrame.', 'GtkBin.', 'GtkBox.', 'GtkBoxChild.', 'GtkButton.', 'GtkButtonBox.', 'GtkCalendar.', 'GtkCheckButton.', 'GtkCheckMenuItem.', 'GtkCList.', 'GtkCListRow.', 'GtkColorSelection.', 'GtkColorSelectionDialog.', 'GtkCombo.', 'GtkContainer.', 'GtkCTree.', 'GtkCTreeNode.', 'GtkCurve.', 'GtkData.', 'GtkDialog.', 'GtkDrawingArea.', 'GtkEditable.', 'GtkEntry.', 'GtkEventBox.', 'GtkFileSelection.', 'GtkFixed.', 'GtkFixedChild.', 'GtkFontSelection.', 'GtkFontSelectionDialog.', 'GtkFrame.', 'GtkGammaCurve.', 'GtkHandleBox.', 'GtkHBox.', 'GtkHButtonBox.', 'GtkHPaned.', 'GtkHRuler.', 'GtkHScale.', 'GtkHScrollbar.', 'GtkHSeparator.', 'GtkImage.', 'GtkInputDialog.', 'GtkInvisible.', 'GtkItem.', 'GtkItemFactory.', 'GtkLabel.', 'GtkLayout.', 'GtkList.', 'GtkListItem.', 'GtkMenu.', 'GtkMenuBar.', 'GtkMenuItem.', 'GtkMenuShell.', 'GtkMisc.', 'GtkNotebook.', 'GtkObject.', 'GtkOptionMenu.', 'GtkPacker.', 'GtkPaned.', 'GtkPixmap.', 'GtkPlug.', 'GtkPreview.', 'GtkProgress.', 'GtkProgressbar.', 'GtkRadioButton.', 'GtkRadioMenuItem.', 'GtkRange.', 'GtkRuler.', 'GtkScale.', 'GtkScrollbar.', 'GtkScrolledWindow.', 'GtkSelectionData.', 'GtkSeparator.', 'GtkSocket.', 'GtkSpinButton.', 'GtkStatusBar.', 'GtkStyle.', 'GtkTable.', 'GtkTableChild.', 'GtkTearoffMenuItem.', 'GtkText.', 'GtkTipsQuery.', 'GtkToggleButton.', 'GtkToolBar.', 'GtkToolTips.', 'GtkTree.', 'GtkTreeItem.', 'GtkVBox.', 'GtkVButtonBox.', 'GtkViewport.', 'GtkVPaned.', 'GtkVRuler.', 'GtkVScale.', 'GtkVScrollbar.', 'GtkVSeparator.', 'GtkWidget.', 'GtkWindow.', 'GdkAtom.', 'GdkBitmap.', 'GdkColor.', 'GdkColormap.', 'GdkCursor.', 'GdkDragContext.', 'GdkEvent.', 'GdkEventAny.', 'GdkEventExpose.', 'GdkFont.', 'GdkGC.', 'GdkPixmap.', 'GdkVisual.', 'GdkWindow.', 'GdkCapStyle.', 'GdkCursorType.', 'GdkDragAction.', 'GdkEventMask.', 'GdkEventType.', 'GdkFill.', 'GdkFontType.', 'GdkFunction.', 'GdkInputCondition.', 'GdkJoinStyle.', 'GdkLineStyle.', 'GdkModifierType.', 'GdkRgbDither.', 'GdkSubwindowMode.', 'GdkVisualType.', 'GtkAccelFlags.', 'GtkAnchorType.', 'GtkArrowType.', 'GtkAttachOptions.', 'GtkButtonAction.', 'GtkButtonBoxStyle.', 'GtkCalendarDisplayOptions.', 'GtkCellType.', 'GtkCornerStyle.', 'GtkCTreeExpanderStyle.', 'GtkCTreeExpansionType.', 'GtkCTreeLineStyle.', 'GtkCurveType.', 'GtkDestDefaults.', 'GtkDirectionType.', 'GtkFontFilterType.', 'GtkFontType.', 'GtkJustification.', 'GtkObjectFlags.', 'GtkOrientation.', 'GtkPackerOptions.', 'GtkPackType.', 'GtkPolicyType.', 'GtkPositionType.', 'GtkPreviewType.', 'GtkProgressBarOrientation.', 'GtkProgressBarStyle.', 'GtkReliefStyle.', 'GtkResizeMode.', 'GtkScrollType.', 'GtkSelectionMode.', 'GtkShadowType.', 'GtkSideType.', 'GtkSortType.', 'GtkSpinButtonUpdatePolicy.', 'GtkSpinType.', 'GtkStateType.', 'GtkSubmenuPlacement.', 'GtkToolbarChildType.', 'GtkToolbarSpaceStyle.', 'GtkToolbarStyle.', 'GtkTreeViewMode.', 'GtkUpdateType.', 'GtkVisibility.', 'GtkWidgetFlags.', 'GtkWindowPosition.', 'GtkWindowType.'); +function tryprefix($func, $prefix) { +global $classes; + $types = array('method.', 'signal.', 'property.'); $first = substr($prefix, 0, 3); $hit = array(); +$part = array(); /* just so's we don't have to guess wildly at capitalisation in classes/enums */ for($i = 0; $i < sizeof($classes); $i++) { @@ -34,73 +37,89 @@ else if (file_exists("$_SERVER[DOCUMENT_ROOT]$try")) $hit[] = $try; } -/* full queries can only have this return, so send it straight home to Daddy */ return $hit; } +} -/* undeclared class/constructor or enum */ - $try = "/manual/${prefix}${first}${func}.php"; - $constructor = "/manual/${prefix}${first}${func}.constructor.php"; - if (file_exists("$_SERVER[DOCUMENT_ROOT]$constructor")) { - for($i = 0; $i < sizeof($classes); $i++) { - if(stristr($classes[$i], "${first}${func}.")) $pos = $i; - } - $realname = $classes[$pos]; - $try = "/manual/${prefix}${realname}php"; - $constructor = "/manual/${prefix}${realname}constructor.php"; - $hit = array($try, $constructor); - } - else { - if (file_exists("$_SERVER[DOCUMENT_ROOT]$try")) { - for($i = 0; $i < sizeof($classes); $i++) { - if(stristr($classes[$i], "${first}${func}.")) { - $pos = $i; - $realname = $classes[$pos]; - $try = "/manual/${prefix}${realname}php"; +function wildcard($func, $hit) { +global $classes; + $dir = opendir("$_SERVER[DOCUMENT_ROOT]/manual"); + while(($item = readdir($dir))!== false) { + $part = explode('.', $item); + $gtk = $part[0]; + $class = substr($part[1], 0, 3); + $enum = substr($part[2], 0, 3); + $method = substr($part[3], 0, 3); + if($gtk == $class || $gtk == $enum) { + if(strstr($part[1], $func) || strstr($part[2], $func)) { + if($part[2] !== "method" && $part[2] !== "property" + && $part[2] !== "signal") { + $try = "/manual/$item"; + if(file_exists("$_SERVER[DOCUMENT_ROOT]$try") && + !in_array($try, $hit)) { + if(strstr($part[1], $func)) $uc = $part[1]; + else $uc = $part[2]; + for($i = 0; $i < sizeof($classes); $i++) { + if(stristr($classes[$i], "$uc.")) $pos = $i; + } + $realname = $classes[$pos]; + if ($uc == $part[1]) + $try = "/manual/$part[0].$realname$part[2]"; + else + $try = "/manual/$part[0].$part[1].$realname$part[3]"; + $hit[] = $try; + } } } - $hit[] = $try; } - } -/* undeclared static function */ - $try = "/manual/${prefix}method.${func}.php"; - if(file_exists("$_SERVER[DOCUMENT_ROOT]$try")) $hit[] = $try; - -/* class methods, signals and properties with no clues attached */ - foreach($classes as $class) { - $lowclass = strtolower($class); - foreach($types as $type) { - if($first == substr($lowclass, 0, 3)) { - $try = "/manual/${prefix}${lowclass}${type}${func}.php"; - $uc = "/manual/${prefix}${class}${type}${func}.php"; - if(file_exists("$_SERVER[DOCUMENT_ROOT]$try")) - $hit[] = $uc; + if($part[1] == "method") { + if(strstr($part[2], $func)) { + $try = "/manual/$item"; + if(file_exists("$_SERVER[DOCUMENT_ROOT]$try") && !in_array($try, $hit)) $hit[] = $try; + } + } + + if($gtk == $class && strstr($part[3], $func)) { + $try = "/manual/$item"; + if(file_exists("$_SERVER[DOCUMENT_ROOT]$try") && !in_array($try, $hit)) { + for($i = 0; $i < sizeof($classes); $i++) { + if(stristr($classes[$i], "$part[1].")) $pos = $i; + } + $realname = $classes[$pos]; + $try = "/manual/$part[0].$realname$part[2].$part[3].$part[4]"; + $hit[] = $try; } } } + closedir($dir); return $hit; } function find_manual_page($function) { -/* names of xml-generated sections */ -$sections = array("gdk.enum.", "gdk.", "gtk.enum.", "gtk."); +$hit = array(); -/* if there's no :: in there we could be looking for anything */ - if(!strstr($function, "::")) { - foreach($sections as $section) { - $try = tryprefix($function, $section); - if($try) $result = array_merge($try, $result); - } - if($result) return $result; - } - else { /* fast track, single return :) */ + if(strstr($function, "::")) { list($funcpre, $funcpost) = split("::", $function); $try = tryprefix($funcpost, "$funcpre.method."); if($try) return $try; } + elseif(strtolower(substr($function, 0, 3)) == "gtk" || + strtolower(substr($function, 0, 3 == "gdk"))) { + $prefix = strtolower(substr($function, 0, 3)); + $try = tryprefix($function, "$prefix."); + if($try) return $try; + } + else { +/* if there's no :: or gtk in there we could be looking for anything */ + $try = wildcard($function, $hit); + if($try) $result = array_merge($try, $result); + } + if($result) { + return $result; + } return ""; }