diff --git a/include/results.inc b/include/results.inc new file mode 100644 index 000000000..be518bdc7 --- /dev/null +++ b/include/results.inc @@ -0,0 +1,89 @@ +Showing results $disp_start_result to $disp_end_result of $results_count\n"; + echo '
{$types[$type]}{$display_title}
+{$summary}
+ + +EOB; + } + echo "
+EOB;
+ endif;
+ if($show_foot):
+ echo <<
diff --git a/results.php b/results.php
index ee8135395..46eb2c138 100644
--- a/results.php
+++ b/results.php
@@ -2,6 +2,7 @@
// $Id$
$_SERVER['BASE_PAGE'] = 'results.php';
include $_SERVER['DOCUMENT_ROOT'] . '/include/prepend.inc';
+include $_SERVER['DOCUMENT_ROOT'] . '/include/results.inc';
#include $_SERVER['DOCUMENT_ROOT'] . '/include/loadavg.inc';
function exit_with_pretty_error($title, $header, $msg) {
@@ -32,8 +33,8 @@ if ($MQ) {
if(strlen($l)>2) $l = substr($l,0,2); // Just take the first 2 chars. eg. pt_BR = pt
-$q = urlencode($q);
-$l = urlencode($l);
+$uq = urlencode($q);
+$ul = urlencode($l);
$s = (isset($_GET['start']) && is_numeric($_GET['start'])) ? (int)$_GET['start'] : 0;
$profile = (isset($_GET['p']) && is_string($_GET['p'])) ? $_GET['p'] : 'all';
@@ -42,7 +43,7 @@ $per_page = 10;
$valid_profiles = array('all', 'local', 'manual', 'news', 'bugs', 'pear', 'pecl', 'talks');
$scope = in_array($profile, $valid_profiles) ? $profile : 'all';
$srch_host = "www.php.net";
-$srch_rqst = "/ws.php?profile=$scope&q=$q&lang=$l&results=$per_page&start=$s&mirror=".trim(substr($MYSITE,7),'/');
+$srch_rqst = "/ws.php?profile=$scope&q=$uq&lang=$ul&results=$per_page&start=$s&mirror=".trim(substr($MYSITE,7),'/');
$url = "http://".$srch_host.$srch_rqst;
$data = fetch_contents($url);
@@ -66,85 +67,7 @@ if ($res['ResultSet']['totalResultsAvailable'] == 0) {
exit;
}
-$start_result = $s;
-$end_result = $s + $res['ResultSet']['totalResultsReturned'] -1;
+search_results($res, $q, $scope, $per_page, $s, $l);
-$results_count = ($res['ResultSet']['totalResultsAvailable'] < 100 ? $res['ResultSet']['totalResultsAvailable'] : 'more than 100');
-
-$disp_start_result = $start_result + 1;
-$disp_end_result = $end_result + 1;
-echo << {$types[$type]}{$display_title} {$summary}
-EOB;
-$pos = $res['ResultSet']['firstResultPosition'];
-
-$php_img_dir = 'http://static.php.net/www.php.net/images';
-$types = array(
- 'pear' => '
',
- 'pecl' => '
',
- 'pecl4win' => '
',
- 'peclbugs' => '
',
- 'pearbugs' => '
',
- 'talks' => '
',
- 'snaps' => '
',
- 'cvsweb' => '
',
- 'viewcvs' => '
',
- 'news' => '
',
- 'php' => '
',
- 'doc' => '
',
- 'bugs' => '
',
- 'gtk' => '
'
-);
-
-foreach($res['ResultSet']['Result'] as $i => $hit) {
- $cnt = $pos + $i;
-
- $d = date('j M Y', $hit['ModificationDate']);
- $cachelink = '';
- if (isset($hit['Cache'])) {
- $cachelink = " - Cached";
- }
-
- // rewrite mirrors urls (\w\w\d? or www, but not qa, doc, gtk and ~/user)
- $real_url = preg_replace('@^http://(?!doc|qa|gtk)\w{2,3}\.php\.net(?!/~)(.*)$@', '$1', $hit['Url']);
- $displayurl = preg_replace('@^http://(?:(?!doc|qa|php|gtk)\w{2,3}\.)?(.+[^/])/?$@', '$1', $hit['Url']);
- $type = substr($displayurl,0,strpos($displayurl,'.'));
- if($type=='pecl' && strstr($displayurl,"/bugs/")) $type = "peclbugs";
- if($type=='pear' && strstr($displayurl,"/bugs/")) $type = "pearbugs";
- if($type=='smarty') continue;
- $display_title = str_replace(array('PHP:', '&'), array('', '&'), $hit['Title']);
-
- // Fall back to the PHP logo for unknown hits
- if (!isset($types[$type])) {
- $type = "php";
- }
-
- // Fix > double escaping
- $summary = str_replace('&', '&', $hit['Summary']);
- echo <<
-';
site_footer();
?>