From aa0fa694e10be584f0cea8f6ab0cfb585100588d Mon Sep 17 00:00:00 2001 From: James Cox Date: Tue, 28 Feb 2006 01:06:32 +0000 Subject: [PATCH] land better version of the search system and enable.. basically it just looks better, has paging, is realistic about results, should respect mirrors.. etc --- include/layout.inc | 1 + results.php | 80 +++++++++++++++++++++++++++------------------- search.php | 4 +-- style.css | 41 ++++++++++++++++++++++++ styles/site.css | 41 ++++++++++++++++++++++++ 5 files changed, 132 insertions(+), 35 deletions(-) diff --git a/include/layout.inc b/include/layout.inc index d62ba8f19..9d2921a7d 100644 --- a/include/layout.inc +++ b/include/layout.inc @@ -119,6 +119,7 @@ function site_header($title = '', $config = array()) @import url("{$_SERVER['STATIC_ROOT']}/styles/site.css"); @import url("{$_SERVER['STATIC_ROOT']}/styles/{$mirror_specific_style}.css"); + $base$meta diff --git a/results.php b/results.php index cb3df4734..f73209e2b 100644 --- a/results.php +++ b/results.php @@ -1,18 +1,33 @@ Internal error, please try later'; exit; @@ -24,31 +39,14 @@ if ($res['ResultSet']['totalResultsAvailable'] == 0) { exit; } -echo << -ul#search-results { - list-style-type: none; -} -ul#search-results li { - margin-top: 1em; -} -ul#search-results p { - margin: 0; -} -ul#search-results p.summary, -ul#search-results p.meta { - font-size: 0.8em; - margin-left: 2em; -} -ul#search-results p.meta { - color: #008000; -} -ul#search-results p.meta a { - color: #8284cc; -} +$start_result = ($s == 0 ? 1 : $s); +$end_result = $s + $res['ResultSet']['totalResultsReturned']; - -

Showing {$res['ResultSet']['totalResultsReturned']} of {$res['ResultSet']['totalResultsAvailable']} results

+$results_count = ($res['ResultSet']['totalResultsAvailable'] < 100 ? $res['ResultSet']['totalResultsAvailable'] : 'more than 100'); + + +echo <<Showing results $start_result to $end_result of $results_count
    EOB; $pos = $res['ResultSet']['firstResultPosition']; @@ -66,11 +64,17 @@ foreach($res['ResultSet']['Result'] as $i => $hit) { $size = " - {$hit['Cache']['Size']} bytes"; } } + + if(empty($_GET['p']) || $_GET['p'] == 'local') { + $real_url = preg_replace('!^http://[\w]+\.php\.net/(.*)$!', $MYSITE . '\\1', $hit['Url']); + } else { + $real_url = $hit['Url']; + } $displayurl = preg_replace('!^http://(.+[^/])(/?)$!', '\\1', $hit['Url']); - + $display_title = str_replace('PHP:', '', $hit['Title']); echo << -

    $cnt. {$hit['Title']}

    +

    {$display_title}

    {$hit['Summary']}

    {$displayurl} - {$d}{$size}{$cachelink}

    @@ -80,4 +84,16 @@ echo << EOB; +$start = 0; +echo ''; +echo '

    Results Page:

      '; +for($z=1; $z < 11; $z++) { + if($start > $res['ResultSet']['totalResultsAvailable']) { + break; + } + printf('
    • %d
    • ', $q, $start, $z); + $start += $per_page; +} +echo '
    '; +site_footer(); ?> diff --git a/search.php b/search.php index 3fc48dc85..d5543d78f 100644 --- a/search.php +++ b/search.php @@ -77,9 +77,7 @@ if (!empty($_FORM['pattern'])) { // Covers "wholesite", "manual" and any malicios targets default: - mirror_redirect( - "http://www.google.com/search?q={$ucp}+site:www.php.net&l=$LANG" - ); + mirror_redirect($MYSITE . "results.php?q={$ucp}&l=$LANG"); } } diff --git a/style.css b/style.css index 673955ea8..484031fd8 100644 --- a/style.css +++ b/style.css @@ -328,3 +328,44 @@ ul#manualtoc li a { ul#manualtoc li a:hover { text-decoration: underline; } + +/* for search system... */ +ul#search-results { + list-style-type: none; +} +ul#search-results li { + margin-top: 1em; + list-style-type: none; +} +ul#search-results p { + margin: 0; +} +ul#search-results p.result { + font-weight: 700; +} +ul#search-results p.summary, +ul#search-results p.meta { + font-size: 0.8em; + margin-left: 2em; +} +ul#search-results p.meta { + color: #008000; +} +ul#search-results p.meta a { + color: #8284cc; +} +div#results_nav { + margin:auto; + width: 200px; + text-align: center; +} + +ul#results_nav_list { + text-align: center; + padding: 0px; +} +ul#results_nav_list li { + display: inline; + margin-right: 0.4em; + list-style-type: none; +} diff --git a/styles/site.css b/styles/site.css index d4d376d43..632adc198 100644 --- a/styles/site.css +++ b/styles/site.css @@ -487,3 +487,44 @@ div.manualnavbar form { div.manualnavbar .lastupdated { font-size: 75%; } + +/* for searching system... */ +ul#search-results { + list-style-type: none; +} +ul#search-results li { + margin-top: 1em; + list-style-type: none; +} +ul#search-results p { + margin: 0; +} +ul#search-results p.result { + font-weight: 700; +} +ul#search-results p.summary, +ul#search-results p.meta { + font-size: 0.8em; + margin-left: 2em; +} +ul#search-results p.meta { + color: #008000; +} +ul#search-results p.meta a { + color: #8284cc; +} +div#results_nav { + margin:auto; + width: 200px; + text-align: center; +} + +ul#results_nav_list { + text-align: center; + padding: 0px; +} +ul#results_nav_list li { + display: inline; + margin-right: 0.4em; + list-style-type: none; +}