cvs: phpweb / results.php
| From: | Felipe Pena | Date: | Sun, 23 Mar 2008 16:28:33 +0000 |
| Subject: | cvs: phpweb / results.php | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-1393@lists.php.net to get a copy of this message | ||
felipe Sun Mar 23 16:28:33 2008 UTC
Modified files:
/phpweb results.php
Log:
- Fixed bug #44510 (Search yields a relative path that doesn't exist on all servers)
- Improved regexp
- Moved array out of the loop
http://cvs.php.net/viewvc.cgi/phpweb/results.php?r1=1.40&r2=1.41&diff_format=u
Index: phpweb/results.php
diff -u phpweb/results.php:1.40 phpweb/results.php:1.41
--- phpweb/results.php:1.40 Sat Mar 22 10:53:55 2008
+++ phpweb/results.php Sun Mar 23 16:28:33 2008
@@ -1,5 +1,5 @@
<?php
-// $Id: results.php,v 1.40 2008/03/22 10:53:55 bjori Exp $
+// $Id: results.php,v 1.41 2008/03/23 16:28:33 felipe Exp $
$_SERVER['BASE_PAGE'] = 'results.php';
include $_SERVER['DOCUMENT_ROOT'] . '/include/prepend.inc';
#include $_SERVER['DOCUMENT_ROOT'] . '/include/loadavg.inc';
@@ -96,6 +96,25 @@
<ul id="search-results">
EOB;
$pos = $res['ResultSet']['firstResultPosition'];
+
+$php_img_dir = 'http://static.php.net/www.php.net/images';
+$types = array(
+ 'pear' => '<img src="'. $php_img_dir
.'/pear_item.gif" height="19" width="17" style="float:left;
margin-left:-30px;"/>',
+ 'pecl' => '<img src="'. $php_img_dir
.'/pecl_item.gif" height="19" width="17" style="float:left;
margin-left:-30px;"/>',
+ 'pecl4win' => '<img src="'. $php_img_dir
.'/pecl_item_win.gif" height="22" width="21" style="float:left;
margin-left:-31px;"/>',
+ 'peclbugs' => '<img src="'. $php_img_dir
.'/pecl_item_bug.gif" height="19" width="17" style="float:left;
margin-left:-30px;"/>',
+ 'pearbugs' => '<img src="'. $php_img_dir
.'/pear_item_bug.gif" height="19" width="17" style="float:left;
margin-left:-30px;"/>',
+ 'talks' => '<img src="'. $php_img_dir
.'/ele-icon.gif" height="20" width="32" style="float:left;
margin-left:-40px;"/>',
+ 'snaps' => '<img src="'. $php_img_dir
.'/logos/php_xpstyle_ico.png" height="32" width="32"
style="float:left; margin-left:-40px;"/>',
+ 'cvsweb' => '<img src="'. $php_img_dir
.'/logos/php_script_ico.png" height="32" width="32"
style="float:left; margin-left:-40px;"/>',
+ 'viewcvs' => '<img src="'. $php_img_dir
.'/logos/php_script_ico.png" height="32" width="32"
style="float:left; margin-left:-40px;"/>',
+ 'news' => '<img src="'. $php_img_dir
.'/logos/php-icon-white.gif" height="32" width="32"
style="float:left; margin-left:-40px;"/>',
+ 'php' => '<img src="'. $php_img_dir
.'/logos/php-icon-white.gif" height="32" width="32"
style="float:left; margin-left:-40px;"/>',
+ 'doc' => '<img src="'. $php_img_dir
.'/logos/php-icon-white.gif" height="32" width="32"
style="float:left; margin-left:-40px;"/>',
+ 'bugs' => '<img src="'. $php_img_dir .'/php_bug.gif"
height="32" width="32" style="float:left;
margin-left:-40px;"/>',
+ 'gtk' => '<img src="http://bjori.php.is/images/logos/php-gtk-white.gif"
height="26" width="32" style="float:left;
margin-left:-40px;"/>'
+);
+
foreach($res['ResultSet']['Result'] as $i => $hit) {
$cnt = $pos + $i;
@@ -111,29 +130,15 @@
}
}
- // rewrite mirrors urls (\w\w\d? or www, but not qa, doc and gtk)
- $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']);
+ // 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']);
- $types = array('pear'=>'<img src="http://static.php.net/www.php.net/images/pear_item.gif"
height="19" width="17" style="float:left;
margin-left:-30px;"/>',
- 'pecl'=>'<img src="http://static.php.net/www.php.net/images/pecl_item.gif"
height="19" width="17" style="float:left;
margin-left:-30px;"/>',
- 'pecl4win'=>'<img src="http://static.php.net/www.php.net/images/pecl_item_win.gif"
height="22" width="21" style="float:left;
margin-left:-31px;"/>',
- 'peclbugs'=>'<img src="http://static.php.net/www.php.net/images/pecl_item_bug.gif"
height="19" width="17" style="float:left;
margin-left:-30px;"/>',
- 'pearbugs'=>'<img src="http://static.php.net/www.php.net/images/pear_item_bug.gif"
height="19" width="17" style="float:left;
margin-left:-30px;"/>',
- 'talks'=>'<img src="http://static.php.net/www.php.net/images/ele-icon.gif"
height="20" width="32" style="float:left;
margin-left:-40px;"/>',
- 'snaps'=>'<img src="http://static.php.net/www.php.net/images/logos/php_xpstyle_ico.png"
height="32" width="32" style="float:left;
margin-left:-40px;"/>',
- 'cvsweb'=>'<img src="http://static.php.net/www.php.net/images/logos/php_script_ico.png"
height="32" width="32" style="float:left;
margin-left:-40px;"/>',
- 'viewcvs'=>'<img src="http://static.php.net/www.php.net/images/logos/php_script_ico.png"
height="32" width="32" style="float:left;
margin-left:-40px;"/>',
- 'news'=>'<img src="http://static.php.net/www.php.net/images/logos/php-icon-white.gif"
height="32" width="32" style="float:left;
margin-left:-40px;"/>',
- 'php'=>'<img src="http://static.php.net/www.php.net/images/logos/php-icon-white.gif"
height="32" width="32" style="float:left;
margin-left:-40px;"/>',
- 'gtk'=>'<img src="http://bjori.php.is/images/logos/php-gtk-white.gif"
height="26" width="32" style="float:left;
margin-left:-40px;"/>',
- 'doc'=>'<img src="http://static.php.net/www.php.net/images/logos/php-icon-white.gif"
height="32" width="32" style="float:left;
margin-left:-40px;"/>',
- 'bugs'=>'<img src="http://static.php.net/www.php.net/images/php_bug.gif"
height="32" width="32" style="float:left;
margin-left:-40px;"/>'
- );
+
// Fix &gt; double escaping
$summary = str_replace('&', '&', $hit['Summary']);
echo <<<EOB