cvs: pear /Services_Yahoo/Yahoo/Search AbstractSearch.php web.php

From: Date: Fri, 30 Sep 2005 18:14:36 +0000
Subject: cvs: pear /Services_Yahoo/Yahoo/Search AbstractSearch.php web.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-35183@lists.php.net to get a copy of this message
mj Fri Sep 30 14:14:36 2005 EDT Modified files: /pear/Services_Yahoo/Yahoo/Search AbstractSearch.php web.php Log: * Simplified the whole concept of supporting multiple parameters. http://cvs.php.net/diff.php/pear/Services_Yahoo/Yahoo/Search/AbstractSearch.php?r1=1.4&r2=1.5&ty=u Index: pear/Services_Yahoo/Yahoo/Search/AbstractSearch.php diff -u pear/Services_Yahoo/Yahoo/Search/AbstractSearch.php:1.4 pear/Services_Yahoo/Yahoo/Search/AbstractSearch.php:1.5 --- pear/Services_Yahoo/Yahoo/Search/AbstractSearch.php:1.4 Fri Sep 30 14:03:27 2005 +++ pear/Services_Yahoo/Yahoo/Search/AbstractSearch.php Fri Sep 30 14:14:35 2005 @@ -17,7 +17,7 @@ * @author Martin Jansen <mj@php.net> * @copyright 2005 Martin Jansen * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: AbstractSearch.php,v 1.4 2005/09/30 18:03:27 mj Exp $ + * @version CVS: $Id: AbstractSearch.php,v 1.5 2005/09/30 18:14:35 mj Exp $ * @link http://pear.php.net/package/Services_Yahoo */ @@ -35,7 +35,7 @@ * @author Martin Jansen <mj@php.net> * @copyright 2005 Martin Jansen * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: AbstractSearch.php,v 1.4 2005/09/30 18:03:27 mj Exp $ + * @version CVS: $Id: AbstractSearch.php,v 1.5 2005/09/30 18:14:35 mj Exp $ * @link http://pear.php.net/package/Services_Yahoo */ abstract class Services_Yahoo_Search_AbstractSearch { @@ -193,23 +193,19 @@ { $this->parameters['adult_ok'] = 1; } - + /** - * Removes elements identified by the $needle from the array $haystack + * Returns an element from the parameters * - * @static * @access protected - * @param array $haystack Array to remove the elements from - * @param mixed $needle Value of the elements to remove from the array - * @return array Array with elements removed - */ - protected static function removeArrayElement($haystack, $needle) { - $searches = array_keys($haystack, $needle); - $offset = 0; - foreach ($searches as $position) { - array_splice($haystack, $position - $offset++, 1); + * @param string $name Name of the element + * @return string Value of the parameter idenfied by $name + */ + protected function getParameter($name) { + if (isset($this->parameters[$name])) { + return $this->parameters[$name]; } - return $haystack; + return ""; } } http://cvs.php.net/diff.php/pear/Services_Yahoo/Yahoo/Search/web.php?r1=1.4&r2=1.5&ty=u Index: pear/Services_Yahoo/Yahoo/Search/web.php diff -u pear/Services_Yahoo/Yahoo/Search/web.php:1.4 pear/Services_Yahoo/Yahoo/Search/web.php:1.5 --- pear/Services_Yahoo/Yahoo/Search/web.php:1.4 Fri Sep 30 14:03:27 2005 +++ pear/Services_Yahoo/Yahoo/Search/web.php Fri Sep 30 14:14:35 2005 @@ -17,7 +17,7 @@ * @author Martin Jansen <mj@php.net> * @copyright 2005 Martin Jansen * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: web.php,v 1.4 2005/09/30 18:03:27 mj Exp $ + * @version CVS: $Id: web.php,v 1.5 2005/09/30 18:14:35 mj Exp $ * @link http://pear.php.net/package/Services_Yahoo */ @@ -34,7 +34,7 @@ * @author Martin Jansen <mj@php.net> * @copyright 2005 Martin Jansen * @license http://www.php.net/license/3_0.txt PHP License 3.0 - * @version CVS: $Id: web.php,v 1.4 2005/09/30 18:03:27 mj Exp $ + * @version CVS: $Id: web.php,v 1.5 2005/09/30 18:14:35 mj Exp $ * @link http://pear.php.net/package/Services_Yahoo * @link http://developer.yahoo.net/web/V1/webSearch.html */ @@ -78,30 +78,52 @@ } /** - * Adds a domain to restrict the search to + * Returns the domains to restrict the search to * * @access public - * @param string Domain to add to the list of domains to restrict the search to + * @return array Array of domains */ - public function addSites($site) { - if (!isset($this->parameters['site']) || !is_array($this->parameters['site'])) { - $this->parameters['sites'] = array($site); - } else { - $this->parameters['sites'][] = $site; - } + public function getSites() { + return $this->getParameter("site"); } /** - * Removes a domain from the list of domains to restrict the search to + * Sets the subscriptions to premium contents that should also be searched * * @access public - * @param string Domain to remove from the list + * @param array Array of subscription codes + */ + public function setSubscriptions($subscriptions) { + $this->parameters['subscription'] = $sites; + } + + /** + * Returns the subscriptions to premium contents that should also be searched + * + * @access public + * @return array Array of subscription codes */ - public function removeSite($site) { - if (!isset($this->parameters['site'])) { - return; - } + public function getSubscriptions() { + return $this->getParameter("subscription"); + } - $this->parameters['site'] = self::removeArrayElement($this->parameters['site'], $site); + /** + * Sets the Creative Commons licenses that the contents must be licensed under + * + * @access public + * @param array Array of license codes + */ + public function setLicenses($licenses) { + $this->parameters['license'] = $licenses; + } + + /** + * Returns the Creative Commons licenses that the contents must be licensed under + * + * @access public + * @return array Array of license codes + */ + public function getLicenses() { + return $this->getParameter("license"); } }

« previous php.pear.cvs (#35183) next »