svn: /pear2/sandbox/SimpleChannelFrontend/trunk/ src/SimpleChannelFrontend/Main.php src/SimpleChannelFrontend/Search.php www/templates/Search.tpl.php
| From: | Brett Bieber | Date: | Sun, 28 Mar 2010 14:17:59 +0000 |
| Subject: | svn: /pear2/sandbox/SimpleChannelFrontend/trunk/ src/SimpleChannelFrontend/Main.php src/SimpleChannelFrontend/Search.php www/templates/Search.tpl.php | ||
| Groups: | php.pear.cvs php.pear.core | ||
| Request: | Send a blank email to pear-core+get-9339@lists.php.net to get a copy of this message | ||
saltybeagle Sun, 28 Mar 2010 14:17:59 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=296972
Log:
Add searching by package name
Changed paths:
U pear2/sandbox/SimpleChannelFrontend/trunk/src/SimpleChannelFrontend/Main.php
A pear2/sandbox/SimpleChannelFrontend/trunk/src/SimpleChannelFrontend/Search.php
A pear2/sandbox/SimpleChannelFrontend/trunk/www/templates/Search.tpl.php
Modified: pear2/sandbox/SimpleChannelFrontend/trunk/src/SimpleChannelFrontend/Main.php
===================================================================
--- pear2/sandbox/SimpleChannelFrontend/trunk/src/SimpleChannelFrontend/Main.php 2010-03-28 14:14:14
UTC (rev 296971)
+++ pear2/sandbox/SimpleChannelFrontend/trunk/src/SimpleChannelFrontend/Main.php 2010-03-28 14:17:59
UTC (rev 296972)
@@ -43,7 +43,8 @@
'package' =>
'pear2\SimpleChannelFrontend\Package',
'release' =>
'pear2\SimpleChannelFrontend\PackageRelease',
'categories' =>
'pear2\SimpleChannelFrontend\Categories',
- 'support' =>
'pear2\SimpleChannelFrontend\Support');
+ 'support' =>
'pear2\SimpleChannelFrontend\Support',
+ 'search' =>
'pear2\SimpleChannelFrontend\Search');
public static $url = '';
Added: pear2/sandbox/SimpleChannelFrontend/trunk/src/SimpleChannelFrontend/Search.php
===================================================================
--- pear2/sandbox/SimpleChannelFrontend/trunk/src/SimpleChannelFrontend/Search.php
(rev 0)
+++ pear2/sandbox/SimpleChannelFrontend/trunk/src/SimpleChannelFrontend/Search.php 2010-03-28
14:17:59 UTC (rev 296972)
@@ -0,0 +1,26 @@
+<?php
+namespace pear2\SimpleChannelFrontend;
+use pear2\Pyrus\Channel;
+
+class Search extends \FilterIterator
+{
+ public $query;
+
+ protected $frontend;
+
+ function __construct($options = array())
+ {
+
+ if (isset($options['q'])) {
+ $this->query = $options['q'];
+ }
+
+ parent::__construct(new \pear2\Pyrus\Channel\RemotePackages(Main::$channel));
+ }
+
+ function accept()
+ {
+ return (bool)stristr($this->current()->name, $this->query);
+ }
+
+}
\ No newline at end of file
Added: pear2/sandbox/SimpleChannelFrontend/trunk/www/templates/Search.tpl.php
===================================================================
--- pear2/sandbox/SimpleChannelFrontend/trunk/www/templates/Search.tpl.php
(rev 0)
+++ pear2/sandbox/SimpleChannelFrontend/trunk/www/templates/Search.tpl.php 2010-03-28 14:17:59 UTC
(rev 296972)
@@ -0,0 +1,20 @@
+<?php
+// Set the title for the main template
+$parent->context->page_title = 'Packages |
'.pear2\SimpleChannelFrontend\Main::$channel->name;
+?>
+<div class="packagelist grid_8">
+ <h1>Package Search</h1>
+ <form method="get">
+ <input type="hidden" name="view" value="search" />
+ <label>Search:</label><input type="text" name="q"
value="<?php echo htmlentities($context->getRaw('query'), ENT_QUOTES);
?>" />
+ <input type="submit" value="Go" />
+ </form>
+ <h2>Results for <?php echo $context->query; ?></h2>
+ <ul>
+ <?php
+ foreach ($context as $package) {
+ echo '<li><a
href="'.pear2\SimpleChannelFrontend\Main::getURL().$package->name.'">'.$package->name.'</a></li>';
+ }
+ ?>
+ </ul>
+</div>
\ No newline at end of file