manual-lookup.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. //we are in php-gtk-web/ and need php-gtk-web/include/ as include path
  3. set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/include/');
  4. require_once('prepend.php');
  5. $strResult = null;
  6. $strError = null;
  7. $strSearch = null;
  8. $strSelectedType = '';
  9. if (isset($_REQUEST['q']) && $_REQUEST['q'] != '') {
  10. require_once 'PhpGtkDoc/Search2.php';
  11. require_once 'PhpGtkDoc/Search2/Result/Html.php';
  12. $strIndexFile = dirname(__FILE__) . '/include/PhpGtkDoc/index.search';
  13. $strDocumentationDir = 'manual/en/';
  14. if (isset($_REQUEST['type']) && isset($arTypes[$_REQUEST['type']])) {
  15. $strSelectedType = $_REQUEST['type'];
  16. }
  17. $strSearch = preg_replace('/[^a-zA-Z0-9_ ]/', '', $_REQUEST['q']);
  18. try {
  19. $arResults = PhpGtkDoc_Search2::find($strSearch, $strIndexFile);
  20. $strResult = PhpGtkDoc_Search2_Result_Html::format($arResults, $strDocumentationDir, $strSelectedType);
  21. if ($strResult == '') {
  22. $strResult = '<p>Your search for "' . $strSearch . '" didn\'t return any results.</p>';
  23. }
  24. } catch (Exception $e) {
  25. $strError = $e->getMessage();
  26. }
  27. }
  28. commonHeader('Search results');
  29. if ($strError !== null) {
  30. echo '<h2>Error</h2>';
  31. echo $strError;
  32. }
  33. if ($strResult !== null) {
  34. echo '<h2>PHP-GTK 2 manual search results for "' . $strSearch . '"</h2>';
  35. echo $strResult;
  36. }
  37. commonFooter();
  38. ?>