cvs: phpweb / results.php

From: Date: Mon, 27 Feb 2006 20:46:06 +0000
Subject: cvs: phpweb / results.php
Groups: php.mirrors 
Request: Send a blank email to php-mirrors+get-30708@lists.php.net to get a copy of this message
goba Mon Feb 27 20:46:06 2006 UTC Modified files: /phpweb results.php Log: much better look, still an all-in-one file, so one can easily tweak http://cvs.php.net/viewcvs.cgi/phpweb/results.php?r1=1.2&r2=1.3&diff_format=u Index: phpweb/results.php diff -u phpweb/results.php:1.2 phpweb/results.php:1.3 --- phpweb/results.php:1.2 Sun Feb 26 21:44:05 2006 +++ phpweb/results.php Mon Feb 27 20:46:06 2006 @@ -1,5 +1,5 @@ <?php -// $Id: results.php,v 1.2 2006/02/26 21:44:05 goba Exp $ +// $Id: results.php,v 1.3 2006/02/27 20:46:06 goba Exp $ $_SERVER['BASE_PAGE'] = 'results.php'; #include $_SERVER['DOCUMENT_ROOT'] . '/include/prepend.inc'; #include $_SERVER['DOCUMENT_ROOT'] . '/include/loadavg.inc'; @@ -12,32 +12,72 @@ $data = file_get_contents("http://www.php.net/~rasmus/ws.php?q=$q&results=10&start=$s"); $res = unserialize($data); -$pos = $res['ResultSet']['firstResultPosition']; +// HTTP status line is passed on, signifies and error +if (is_string($res)) { + echo '<h2>Internal error, please try later</h2>'; + exit; +} -// No results +// No results for query if ($res['ResultSet']['totalResultsAvailable'] == 0) { echo '<h2>No pages matched your query</h2>'; + exit; } -// Got results -else { - echo <<<EOB -<h2>Showing {$res['ResultSet']['totalResultsReturned']} of {$res['ResultSet']['totalResultsAvailable']}</h2> +echo <<<EOB +<style type="text/css"> +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; +} + +</style> +<h2>Showing {$res['ResultSet']['totalResultsReturned']} of {$res['ResultSet']['totalResultsAvailable']} results</h2> <ul id="search-results"> EOB; - foreach($res['ResultSet']['Result'] as $i => $hit) { - $cnt = $pos + $i; - $d = date('r', $hit['ModificationDate']); - echo <<<EOB +$pos = $res['ResultSet']['firstResultPosition']; +foreach($res['ResultSet']['Result'] as $i => $hit) { + $cnt = $pos + $i; + + $d = date('j M Y', $hit['ModificationDate']); + $cachelink = $size = ''; + if ($hit['Cache']['Size']) { + $cachelink = " - <a href=\"{$hit['Cache']['Url']}\">Cached</a>"; + if ($hit['Cache']['Size'] > 1024) { + $size = ' - ' . sprintf("%d", $hit['Cache']['Size']/1024) . 'k'; + } + else { + $size = " - {$hit['Cache']['Size']} bytes"; + } + } + $displayurl = preg_replace('!^http://(.+[^/])(/?)$!', '\\1', $hit['Url']); + + echo <<<EOB <li> <p class="result">$cnt. <a href="{$hit['Url']}">{$hit['Title']}</a></p> <p class="summary">{$hit['Summary']}</p> - <p class="meta">Modified $d <a href="{$hit['Cache']['Url']}">Cache ({$hit['Cache']['Size']} bytes)</a></p> + <p class="meta">{$displayurl} - {$d}{$size}{$cachelink}</p> </li> EOB; - } - echo <<<EOB +} +echo <<<EOB </ul> EOB; -} + ?>

« previous php.mirrors (#30708) next »