cvs: pear /Services_Yahoo_JP/Yahoo/JP Auction.php MA.php News.php Search.php /Services_Yahoo_JP/Yahoo/JP/Auction AbstractAuction.php Response.php category.php exhibit.php goods.php /Services_Yahoo_JP/Yahoo/JP/MA AbstractMA.php Response.php parse.php /Services_Yahoo_JP/Yahoo/JP/News AbstractNews.php Response.php topics.php /Services_Yahoo_JP/Yahoo/JP/Search image.php video.php web.php
[email protected] ("Tetsuya Nakase")
| Newsgroups | php.pear.cvs |
|---|---|
| Message-ID | <cvstetsuya1209398371@cvsserver> |
tetsuya Mon Apr 28 15:59:31 2008 UTC
Added files:
/pear/Services_Yahoo_JP/Yahoo/JP/Auction AbstractAuction.php
Response.php category.php
exhibit.php goods.php
/pear/Services_Yahoo_JP/Yahoo/JP/MA AbstractMA.php Response.php
parse.php
/pear/Services_Yahoo_JP/Yahoo/JP/News AbstractNews.php Response.php
topics.php
/pear/Services_Yahoo_JP/Yahoo/JP/Search image.php video.php web.php
/pear/Services_Yahoo_JP/Yahoo/JP Auction.php MA.php News.php
Search.php
Log:
Initial commit
tetsuya-20080428155931.txt
(text/plain, 60.3 KB)
http://cvs.php.net/viewvc.cgi/pear/Services_Yahoo_JP/Yahoo/JP/Auction/AbstractAuction.php?view=markup&rev=1.1 Index: pear/Services_Yahoo_JP/Yahoo/JP/Auction/AbstractAuction.php +++ pear/Services_Yahoo_JP/Yahoo/JP/Auction/AbstractAuction.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * Abstract Auctio class * * PHP version 5 * * LICENSE: This source file is subject to the New BSD license that is * available through the world-wide-web at the following URI: * http://www.opensource.org/licenses/bsd-license.php. If you did not receive * a copy of the New BSD License and are unable to obtain it through the web, * please send a note to [email protected] so we can mail you a copy immediately. * * @category Services * @package Services_Yahoo_JP * @author Tetsuya Nakase <[email protected]> * @copyright 2008 Tetsuya Nakase * @license http://www.opensource.org/licenses/bsd-license.php BSD * @version CVS: $Id: AbstractAuction.php,v 1.1 2008/04/28 15:59:30 tetsuya Exp $ * @link http://phpize.net */ require_once 'Services/Yahoo/JP/Auction/Response.php'; require_once 'HTTP/Request.php'; /** * Abstract Auction class * * This abstract class serves as the base class for all different * types of categories that available through Services_Yahoo. * * @category Services * @package Services_Yahoo_JP * @author Tetsuya Nakase <[email protected]> * @copyright 2008 Tetsuya Nakase * @license http://www.opensource.org/licenses/bsd-license.php BSD * @version Release: 0.0.1 * @link http://phpize.net */ abstract class Services_Yahoo_JP_Auction_AbstractAuction { /** * parameter * * @access protected * @var array */ protected $parameters = array('appid' => 'PEAR_Services_Y_JP'); /** * Submits the Auction * * This method submits the auction and handles the response. It * returns an instance of Services_Yahoo_Result which may be used * to further make use of the result. * * @return object Services_Yahoo_Response Auction Tree result * @throws Services_Yahoo_Exception */ public function submit() { $url = $this->requestURL . '?'; foreach ($this->parameters as $key => $value) { if (is_array($value)) { foreach ($value as $value2) { $url .= $key . '=' . urlencode($value2) . '&'; } continue; } $url .= $key . '=' . urlencode($value) . '&'; } $request = new HTTP_Request($url); $result = $request->sendRequest(); if (PEAR::isError($result)) { throw new Services_Yahoo_Exception($result->getMessage()); } return new Services_Yahoo_JP_Auction_Response($request); } /** * Set Application ID for the Auction * * An Application ID is a string that uniquely identifies your * application. Think of it as like a User-Agent string. If you * have multiple applications, you should use a different ID for * each one. You can register your ID and make sure nobody is * already using your ID on Yahoo's Application ID registration * page. * * The ID defaults to "PEAR_Services_Y_JP", but you are free to * change it to whatever you want. Please note that the access * to the Yahoo API is not limited via the Application ID but via * the IP address of the host where the package is used. * * @param string $id Application * * @return void */ public function withAppID($id) { $this->parameters['appid'] = $id; } /** * Set the id to category for * * @param string $id to category for * * @return void */ public function setCategory($id) { $this->parameters['category'] = $id; } /** * Set the page to auction * * @param string $page to auction * * @return void */ public function setPage($page) { $this->parameters['page'] = $page; } /** * Set the store to auction * * @param string $store to auction * * @return void */ public function setStore($store) { $this->parameters['store'] = $store; } /** * Set the escrow to auction * * @return void */ public function setEscrow() { $this->parameters['escrow'] = 1; } /** * Set the easypayment to auction * * @return void */ public function setEasypayment() { $this->parameters['easypayment'] = 1; } /** * Set the new to auction * * @return void */ public function setNew() { $this->parameters['new'] = 1; } /** * Set the largeimg to auction * * @return void */ public function setLargeimg() { $this->parameters['largeimg'] = 1; } /** * Set the freeshipping to auction * * @return void */ public function setFreeshipping() { $this->parameters['freeshipping'] = 1; } /** * Set the wrappingicon to auction * * @return void */ public function setWrappingicon() { $this->parameters['wrappingicon'] = 1; } /** * Set the buynow to auction * * @return void */ public function setBuynow() { $this->parameters['buynow'] = 1; } /** * Set the thumbnail to auction * * @param string $thumbnail to auction * * @return void */ public function setThumbnail($thumbnail = 1) { $this->parameters['thumbnail'] = $thumbnail; } /** * Set the attn to auction * * @param string $attn to auction * * @return void */ public function setAttn($attn = 1) { $this->parameters['attn'] = $attn; } /** * Set the gift_icon to auction * * @param string $gift_icon to auction * * @return void */ public function setGiftIcon($gift_icon) { $this->parameters['gift_icon'] = $gift_icon; } /** * Set the sort to auction * * @param string $sort to auction * * @return void */ public function setSort($sort) { $this->parameters['sort'] = $sort; } /** * Set the order to auction * * @param string $order to auction * * @return void */ public function setOrder($order) { $this->parameters['order'] = $order; } /** * Set the sellerID to auction * * @param string $seller to auction * * @return void */ public function setSellerID($seller) { $this->parameters['sellerID'] = $seller; } /** * Returns an element from the parameters * * @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 ''; } } ?> http://cvs.php.net/viewvc.cgi/pear/Services_Yahoo_JP/Yahoo/JP/Auction/Response.php?view=markup&rev=1.1 Index: pear/Services_Yahoo_JP/Yahoo/JP/Auction/Response.php +++ pear/Services_Yahoo_JP/Yahoo/JP/Auction/Response.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * Services_Yahoo_JP Auction Response * * PHP version 5 * * LICENSE: This source file is subject to the New BSD license that is * available through the world-wide-web at the following URI: * http://www.opensource.org/licenses/bsd-license.php. If you did not receive * a copy of the New BSD License and are unable to obtain it through the web, * please send a note to [email protected] so we can mail you a copy immediately. * * @category Services * @package Services_Yahoo_JP * @author Tetsuya Nakase <[email protected]> * @copyright 2008 Tetsuya Nakase * @license http://www.opensource.org/licenses/bsd-license.php BSD * @version CVS: $Id: Response.php,v 1.1 2008/04/28 15:59:30 tetsuya Exp $ * @link http://phpize.net */ /** * Services_Yahoo Auction Response class * * This class provides methods for accessing the response of a Auction * request. * * @category Services * @package Services_Yahoo_JP * @extends Exception * @author Tetsuya Nakase <[email protected]> * @copyright 2008 Tetsuya Nakase * @license http://www.opensource.org/licenses/bsd-license.php BSD * @version Release: 0.0.1 * @link http://phpize.net */ class Services_Yahoo_JP_Auction_Response implements Iterator { /** * validate flag * * @access private * @var bool */ private $_isValidIterator = true; /** * counter * * @access private * @var intger */ private $_iteratorCounter = 0; /** * request object * * @access private * @var object */ private $_request; /** * result * * @access private * @var array */ private $_results = array(); /** * index key for loop * * @access private * @var string */ private $_indexkey; /** * Constructor * * @param object $request HTTP_Request Instance of * HTTP_Request that was used for the request * * @throws Services_Yahoo_Exception */ public function __construct(HTTP_Request $request) { $this->_request = $request; $this->_parseRequest(); if ($this->_isError() == true) { $exception = new Services_Yahoo_Exception("Auction query failed"); $exception->addErrors($this->_getMessages()); throw $exception; } } // {{{ response handling /** * Get number of result sets returned by the content analysis * * @return integer Number of result sets returned */ public function getTotalResultsReturned() { return count((array)$this->xml->{$this->_indexkey}); } /** * Get the HTTP_Request instance that was used for the query * * Access to the HTTP_Request instance is useful for introspecting * into the request details. (E.g. for getting the HTTP response * code.) * * @return object HTTP_Request Instance of HTTP_Request */ public function getRequest() { return $this->_request; } // }}} // {{{ Iterator implementation /** * get current result of response * * @return array current result of response */ public function current() { return (array)$this->xml->{$this->_indexkey}[$this->_iteratorCounter]; } /** * get next result of response * * @return array next result of response */ public function next() { $this->_iteratorCounter++; if (!isset($this->xml->{$this->_indexkey}[$this->_iteratorCounter])) { $this->_isValidIterator = false; } } /** * get counter for iterator * * @return string counter */ public function key() { return $this->_iteratorCounter; } /** * clear counter for iterator * * @return void */ public function rewind() { $this->_iteratorCounter = 0; } /** * get validate status * * @return bool validate status */ public function valid() { return $this->_isValidIterator; } // }}} // {{{ private methods /** * Parse XML from the response * * @throws Services_Yahoo_Exception * * @return void */ private function _parseRequest() { $this->xml = simplexml_load_string($this->_request->getResponseBody()); if ($this->xml === false) { throw new Services_Yahoo_Exception("The response contained no valid XML"); } } /** * Determine if an error was returned by the Yahoo API * * This method evaluates the HTTP response code. If it indicates * an error, the method returns true. * * @return boolean True on error, otherwise false. */ private function _isError() { return in_array($this->_request->getResponseCode(), array(400, 403, 404, 503)); } /** * Get all error messages if the response contained an error * * Returns all errors in an numerically indexed array that were * part of the response. * * @see _isError() * @return array */ private function _getMessages() { $returnValue = array(); foreach ($this->xml->Message as $message) { $returnValue[] = $message; } return $returnValue; } /** * Set Key for Response Loop Field * * @param string $key key for loop in result * * @return void */ public function setIndexKey($key) { return $this->_indexkey = $key; } /** * get Attribute * * @param string $name key in result * * @return string value of attribute */ public function returnAttribute($name) { if (isset($this->xml[$name])) { return $this->xml[$name]; } return null; } // }}} } http://cvs.php.net/viewvc.cgi/pear/Services_Yahoo_JP/Yahoo/JP/Auction/category.php?view=markup&rev=1.1 Index: pear/Services_Yahoo_JP/Yahoo/JP/Auction/category.php +++ pear/Services_Yahoo_JP/Yahoo/JP/Auction/category.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * Auction directory class * * PHP version 5 * * LICENSE: This source file is subject to the New BSD license that is * available through the world-wide-web at the following URI: * http://www.opensource.org/licenses/bsd-license.php. If you did not receive * a copy of the New BSD License and are unable to obtain it through the web, * please send a note to [email protected] so we can mail you a copy immediately. * * @category Services * @package Services_Yahoo_JP * @author Tetsuya Nakase <[email protected]> * @copyright 2008 Tetsuya Nakase * @license http://www.opensource.org/licenses/bsd-license.php BSD * @version CVS: $Id: category.php,v 1.1 2008/04/28 15:59:30 tetsuya Exp $ * @link http://phpize.net */ require_once 'AbstractAuction.php'; /** * Services_Yahoo_JP_Auction_category * * This class implements an interface to Yahoo! JAPAN's Cateogry Tree by using * the Yahoo API. * * @category Services * @package Services_Yahoo_JP * @author Tetsuya Nakase <[email protected]> * @copyright 2008 Tetsuya Nakase * @license http://www.opensource.org/licenses/bsd-license.php BSD * @version Release: 0.0.1 * @link http://phpize.net */ class Services_Yahoo_JP_Auction_Category extends Services_Yahoo_JP_Auction_AbstractAuction { /** * api url * * @access protected * @var string */ protected $requestURL = 'http://api.auctions.yahoo.co.jp/AuctionWebService/V1/CategoryTree'; /** * submit * This is override function in Services_Yahoo_JP_Auction_AbstractAuction. * * @return array A category list. */ public function submit() { $res = parent::submit(); $res->setIndexKey('childCategory'); return $res; } } ?> http://cvs.php.net/viewvc.cgi/pear/Services_Yahoo_JP/Yahoo/JP/Auction/exhibit.php?view=markup&rev=1.1 Index: pear/Services_Yahoo_JP/Yahoo/JP/Auction/exhibit.php +++ pear/Services_Yahoo_JP/Yahoo/JP/Auction/exhibit.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * Auction exhibit class * * PHP version 5 * * LICENSE: This source file is subject to the New BSD license that is * available through the world-wide-web at the following URI: * http://www.opensource.org/licenses/bsd-license.php. If you did not receive * a copy of the New BSD License and are unable to obtain it through the web, * please send a note to [email protected] so we can mail you a copy immediately. * * @category Services * @package Services_Yahoo_JP * @author Tetsuya Nakase <[email protected]> * @copyright 2008 Tetsuya Nakase * @license http://www.opensource.org/licenses/bsd-license.php BSD * @version CVS: $Id: exhibit.php,v 1.1 2008/04/28 15:59:30 tetsuya Exp $ * @link http://phpize.net */ require_once 'AbstractAuction.php'; /** * Services_Yahoo_JP_Auction_exhibit * * This class implements an interface to Yahoo! JAPAN's Cateogry Tree by using * the Yahoo API. * * @category Services * @package Services_Yahoo_JP * @author Tetsuya Nakase <[email protected]> * @copyright 2008 Tetsuya Nakase * @license http://www.opensource.org/licenses/bsd-license.php BSD * @version Release: 0.0.1 * @link http://phpize.net */ class Services_Yahoo_JP_Auction_Exhibit extends Services_Yahoo_JP_Auction_AbstractAuction { /** * api url * * @access protected * @var string */ protected $requestURL = 'http://api.auctions.yahoo.co.jp/AuctionWebService/V1/SellingList'; /** * submit * This is override function in Services_Yahoo_JP_Auction_AbstractAuction. * * @return array A exhibit list. */ public function submit() { $res = parent::submit(); $res->setIndexKey('item'); return $res; } } ?> http://cvs.php.net/viewvc.cgi/pear/Services_Yahoo_JP/Yahoo/JP/Auction/goods.php?view=markup&rev=1.1 Index: pear/Services_Yahoo_JP/Yahoo/JP/Auction/goods.php +++ pear/Services_Yahoo_JP/Yahoo/JP/Auction/goods.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * Auction goods class * * PHP version 5 * * LICENSE: This source file is subject to the New BSD license that is * available through the world-wide-web at the following URI: * http://www.opensource.org/licenses/bsd-license.php. If you did not receive * a copy of the New BSD License and are unable to obtain it through the web, * please send a note to [email protected] so we can mail you a copy immediately. * * @category Services * @package Services_Yahoo_JP * @author Tetsuya Nakase <[email protected]> * @copyright 2008 Tetsuya Nakase * @license http://www.opensource.org/licenses/bsd-license.php BSD * @version CVS: $Id: goods.php,v 1.1 2008/04/28 15:59:30 tetsuya Exp $ * @link http://phpize.net */ require_once 'AbstractAuction.php'; /** * Services_Yahoo_JP_Auction_goods * * This class implements an interface to Yahoo! JAPAN's Cateogry Tree by using * the Yahoo API. * * @category Services * @package Services_Yahoo_JP * @author Tetsuya Nakase <[email protected]> * @copyright 2008 Tetsuya Nakase * @license http://www.opensource.org/licenses/bsd-license.php BSD * @version Release: 0.0.1 * @link http://phpize.net */ class Services_Yahoo_JP_Auction_Goods extends Services_Yahoo_JP_Auction_AbstractAuction { /** * api url * * @access protected * @var string */ protected $requestURL = 'http://api.auctions.yahoo.co.jp/AuctionWebService/V1/CategoryLeaf'; /** * submit * This is override function in Services_Yahoo_JP_Auction_AbstractAuction. * * @return array A goods list. */ public function submit() { $res = parent::submit(); $res->setIndexKey('item'); return $res; } } ?> http://cvs.php.net/viewvc.cgi/pear/Services_Yahoo_JP/Yahoo/JP/MA/AbstractMA.php?view=markup&rev=1.1 Index: pear/Services_Yahoo_JP/Yahoo/JP/MA/AbstractMA.php +++ pear/Services_Yahoo_JP/Yahoo/JP/MA/AbstractMA.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * Abstract MA class * * PHP version 5 * * LICENSE: This source file is subject to the New BSD license that is * available through the world-wide-web at the following URI: * http://www.opensource.org/licenses/bsd-license.php. If you did not receive * a copy of the New BSD License and are unable to obtain it through the web, * please send a note to [email protected] so we can mail you a copy immediately. * * @category Services * @package Services_Yahoo_JP * @author Tetsuya Nakase <[email protected]> * @copyright 2008 Tetsuya Nakase * @license http://www.opensource.org/licenses/bsd-license.php BSD * @version CVS: $Id: AbstractMA.php,v 1.1 2008/04/28 15:59:30 tetsuya Exp $ * @link http://pear.php.net/package/Services_Yahoo */ require_once 'Services/Yahoo/JP/MA/Response.php'; require_once 'HTTP/Request.php'; /** * Abstract MA class * * This abstract class serves as the base class for all different * types of categories that available through Services_Yahoo. * * @category Services * @package Services_Yahoo_JP * @author Tetsuya Nakase <[email protected]> * @copyright 2008 Tetsuya Nakase * @license http://www.opensource.org/licenses/bsd-license.php BSD * @version Release: 0.0.1 * @link http://phpize.net */ abstract class Services_Yahoo_JP_MA_AbstractMA { /** * parameter * * @access protected * @var array */ protected $parameters = array('appid' => 'PEAR_Services_Y_JP'); /** * Submits the MA * * This method submits the MA and handles the response. It * returns an instance of Services_Yahoo_Result which may be used * to further make use of the result. * * @return object Services_Yahoo_Response MA result * @throws Services_Yahoo_Exception */ public function submit() { $url = $this->requestURL . '?'; foreach ($this->parameters as $key => $value) { if (is_array($value)) { foreach ($value as $value2) { $url .= $key . '=' . urlencode($value2) . '&'; } continue; } $url .= $key . '=' . urlencode($value) . '&'; } $request = new HTTP_Request($url); $result = $request->sendRequest(); if (PEAR::isError($result)) { throw new Services_Yahoo_Exception($result->getMessage()); } return new Services_Yahoo_JP_MA_Response($request); } /** * Set Application ID * * An Application ID is a string that uniquely identifies your * application. Think of it as like a User-Agent string. If you * have multiple applications, you should use a different ID for * each one. You can register your ID and make sure nobody is * already using your ID on Yahoo's Application ID registration * page. * * The ID defaults to "PEAR_Services_Y_JP", but you are free to * change it to whatever you want. Please note that the access * to the Yahoo API is not limited via the Application ID but via * the IP address of the host where the package is used. * * @param string $id Application ID * * @return void */ public function withAppID($id) { $this->parameters['appid'] = $id; } /** * Returns an element from the parameters * * @param string $name Name of the element * * @return string Value of the parameter */ protected function getParameter($name) { if (isset($this->parameters[$name])) { return $this->parameters[$name]; } return ''; } /** * Set the Sentence * * @param string $sentence for Morphological Analysis * * @return void */ public function setSentence($sentence) { $this->parameters['sentence'] = $sentence; } /** * Set the type of result * * @param string $results type 'ma' or 'uniq' * * @return void */ public function setResults($results) { /* ma is default */ $this->parameters['results'] = ( $results === 'uniq') ? 'uniq' : 'ma'; } /** * Set the response field * * @param string $response field * * @return void */ public function setResponse($response) { $this->parameters['response'] = $response; } /** * Set the ma response field * * @param string $maresponse type of response * * @return void */ public function setMAResponse($maresponse) { $this->parameters['ma_response'] = $maresponse; } /** * Set the uniq response field * * @param string $uniqresponse tyep of response * * @return void */ public function setUniqResponse($uniqresponse) { $this->parameters['uniq_response'] = $uniqresponse; } /** * Set the filter * * @param string $filter filter type * * @return void */ public function setFileter($filter) { $this->parameters['filter'] = $filter; } /** * Set the MA filter * * @param string $mafilter ma filter type * * @return void */ public function setMAFileter($mafilter) { $this->parameters['ma_filter'] = $mafilter; } /** * Set the UNIQ filter * * @param string $uniqfilter uniq filter type * * @return void */ public function setUniqFileter($uniqfilter) { $this->parameters['uniq_filter'] = $uniqfilter; } /** * Set the Uniq_by_baseform * * @param string $ubbf uniq filter * * @return void */ public function setUniqByBaseform($ubbf) { $this->parameters['uniq_by_baseform'] = $ubbf; } } ?> http://cvs.php.net/viewvc.cgi/pear/Services_Yahoo_JP/Yahoo/JP/MA/Response.php?view=markup&rev=1.1 Index: pear/Services_Yahoo_JP/Yahoo/JP/MA/Response.php +++ pear/Services_Yahoo_JP/Yahoo/JP/MA/Response.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * Services_Yahoo_JP MA Response * * PHP version 5 * * LICENSE: This source file is subject to the New BSD license that is * available through the world-wide-web at the following URI: * http://www.opensource.org/licenses/bsd-license.php. If you did not receive * a copy of the New BSD License and are unable to obtain it through the web, * please send a note to [email protected] so we can mail you a copy immediately. * * @category Services * @package Services_Yahoo_JP * @author Tetsuya Nakase <[email protected]> * @copyright 2008 Tetsuya Nakase * @license http://www.opensource.org/licenses/bsd-license.php BSD * @version CVS: $Id: Response.php,v 1.1 2008/04/28 15:59:30 tetsuya Exp $ * @link http://phpize.net */ /** * Services_Yahoo MA Response class * * This class provides methods for accessing the response of a MA * request. * * @category Services * @package Services_Yahoo_JP * @extends Exception * @author Tetsuya Nakase <[email protected]> * @copyright 2008 Tetsuya Nakase * @license http://www.opensource.org/licenses/bsd-license.php BSD * @version Release: 0.0.1 * @link http://phpize.net */ class Services_Yahoo_JP_MA_Response implements Iterator { /** * validate flag * * @access private * @var bool */ private $_isValidIterator = true; /** * counter * * @access private * @var intger */ private $_iteratorCounter = 0; /** * request object * * @access private * @var object */ private $_request; /** * result * * @access private * @var array */ private $_results = array(); /** * Constructor * * @param object $request HTTP_Request Instance of * HTTP_Request that was used for the request * * @throws Services_Yahoo_Exception */ public function __construct(HTTP_Request $request) { $this->_request = $request; $this->_parseRequest(); if ($this->_isError() == true) { $exception = new Services_Yahoo_Exception("MA query failed"); $exception->addErrors($this->_getMessages()); throw $exception; } } // {{{ response handling /** * Get number of result sets returned by the content analysis * * @return integer Number of result sets returned */ public function getTotalResultsReturned() { return count((array)$this->xml->{$this->_getResultType()}->word_list->word); } /** * Get the HTTP_Request instance that was used for the query * * Access to the HTTP_Request instance is useful for introspecting * into the request details. (E.g. for getting the HTTP response * code.) * * @return object HTTP_Request Instance of HTTP_Request */ public function getRequest() { return $this->_request; } // }}} // {{{ Iterator implementation /** * get current result of response * * @return array current result of response */ public function current() { return (array)$this->xml->{$this->_getResultType()}->word_list->word[$this->_iteratorCounter]; } /** * get next result of response * * @return array next result of response */ public function next() { $this->_iteratorCounter++; if (!isset($this->xml->{$this->_getResultType()}->word_list->word[$this->_iteratorCounter])) { $this->_isValidIterator = false; } } /** * get counter for iterator * * @return string counter */ public function key() { return $this->_iteratorCounter; } /** * clear counter for iterator * * @return void */ public function rewind() { $this->_iteratorCounter = 0; } /** * get validate status * * @return bool validate status */ public function valid() { return $this->_isValidIterator; } // }}} // {{{ private methods /** * Parse XML from the response * * @throws Services_Yahoo_Exception * * @return void */ private function _parseRequest() { $this->xml = simplexml_load_string($this->_request->getResponseBody()); if ($this->xml === false) { throw new Services_Yahoo_Exception("The response contained no valid XML"); } } /** * Determine if an error was returned by the Yahoo API * * This method evaluates the HTTP response code. If it indicates * an error, the method returns true. * * @return boolean True on error, otherwise false. */ private function _isError() { return in_array($this->_request->getResponseCode(), array(400, 403, 404, 503)); } /** * Get all error messages if the response contained an error * * Returns all errors in an numerically indexed array that were * part of the response. * * @see _isError() * @return array */ private function _getMessages() { $returnValue = array(); foreach ($this->xml->Message as $message) { $returnValue[] = $message; } return $returnValue; } /** * getAttribute * * @param string $name key in result * * @return string value of attribute */ public function returnAttribute($name) { if (isset($this->xml[$name])) { return $this->xml[$name]; } return null; } /** * getResultType * * @return string result type */ private function _getResultType() { if (isset($this->_request->_url->querystring['results'])) { return $this->_request->_url->querystring['results'] . '_result'; } else { return 'ma_result'; } } // }}} } http://cvs.php.net/viewvc.cgi/pear/Services_Yahoo_JP/Yahoo/JP/MA/parse.php?view=markup&rev=1.1 Index: pear/Services_Yahoo_JP/Yahoo/JP/MA/parse.php +++ pear/Services_Yahoo_JP/Yahoo/JP/MA/parse.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * MA parse class * * PHP version 5 * * LICENSE: This source file is subject to the New BSD license that is * available through the world-wide-web at the following URI: * http://www.opensource.org/licenses/bsd-license.php. If you did not receive * a copy of the New BSD License and are unable to obtain it through the web, * please send a note to [email protected] so we can mail you a copy immediately. * * @category Services * @package Services_Yahoo_JP * @author Nakase Tetsuya <[email protected]> * @copyright 2008 Nakase Tetsuya * @license http://www.opensource.org/licenses/bsd-license.php BSD * @version CVS: $Id: parse.php,v 1.1 2008/04/28 15:59:30 tetsuya Exp $ * @link http://phpize.net */ require_once 'AbstractMA.php'; /** * Services_Yahoo_JP_MA_parse * * This class implements an interface to Yahoo! JAPAN's Cateogry Tree by using * the Yahoo API. * * @category Services * @package Services_Yahoo_JP * @author Nakase Tetsuya <[email protected]> * @copyright 2008 Nakase Tetsuya * @license http://www.opensource.org/licenses/bsd-license.php BSD * @version Release: 0.0.1 * @link http://phpize.net */ class Services_Yahoo_JP_MA_Parse extends Services_Yahoo_JP_MA_AbstractMA { /** * api url * * @access protected * @var string */ protected $requestURL = 'http://api.jlp.yahoo.co.jp/MAService/V1/parse'; } ?> http://cvs.php.net/viewvc.cgi/pear/Services_Yahoo_JP/Yahoo/JP/News/AbstractNews.php?view=markup&rev=1.1 Index: pear/Services_Yahoo_JP/Yahoo/JP/News/AbstractNews.php +++ pear/Services_Yahoo_JP/Yahoo/JP/News/AbstractNews.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * Abstract News class * * PHP version 5 * * LICENSE: This source file is subject to the New BSD license that is * available through the world-wide-web at the following URI: * http://www.opensource.org/licenses/bsd-license.php. If you did not receive * a copy of the New BSD License and are unable to obtain it through the web, * please send a note to [email protected] so we can mail you a copy immediately. * * @category Services * @package Services_Yahoo_JP * @author Tetsuya Nakase <[email protected]> * @copyright 2008 Tetsuya Nakase * @license http://www.opensource.org/licenses/bsd-license.php BSD * @version CVS: $Id: AbstractNews.php,v 1.1 2008/04/28 15:59:30 tetsuya Exp $ * @link http://phpize.net */ require_once 'Services/Yahoo/JP/News/Response.php'; require_once 'HTTP/Request.php'; /** * Abstract News class * * This abstract class serves as the base class for all different * types of news that available through Services_Yahoo. * * @category Services * @package Services_Yahoo_JP * @author Tetsuya Nakase <[email protected]> * @copyright 2008 Tetsuya Nakase * @license http://www.opensource.org/licenses/bsd-license.php BSD * @version Release: 0.0.1 * @link http://phpize.net */ abstract class Services_Yahoo_JP_News_AbstractNews { /** * parameter * * @access protected * @var array */ protected $parameters = array('appid' => 'PEAR_Services_Y_JP'); /** * Submits the News * * This method submits the News and handles the response. It * returns an instance of Services_Yahoo_Result which may be used * to further make use of the result. * * @return object Services_Yahoo_Response News result * @throws Services_Yahoo_Exception */ public function submit() { $url = $this->requestURL . '?'; foreach ($this->parameters as $key => $value) { if (is_array($value)) { foreach ($value as $value2) { $url .= $key . '=' . urlencode($value2) . '&'; } continue; } $url .= $key . '=' . urlencode($value) . '&'; } $request = new HTTP_Request($url); $result = $request->sendRequest(); if (PEAR::isError($result)) { throw new Services_Yahoo_Exception($result->getMessage()); } return new Services_Yahoo_JP_News_Response($request); } /** * Set Application ID * * An Application ID is a string that uniquely identifies your * application. Think of it as like a User-Agent string. If you * have multiple applications, you should use a different ID for * each one. You can register your ID and make sure nobody is * already using your ID on Yahoo's Application ID registration * page. * * The ID defaults to "PEAR_Services_Y_JP", but you are free to * change it to whatever you want. Please note that the access * to the Yahoo API is not limited via the Application ID but via * the IP address of the host where the package is used. * * @param string $id Application ID * * @return void */ public function withAppID($id) { $this->parameters['appid'] = $id; } /** * Returns an element from the parameters * * @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 ''; } /** * Set the word * * @param string $word Search word in Topics * * @return void */ public function setWord($word) { $this->parameters['word'] = $word; } /** * Set the topicname * * @param string $topicname Search topics name * * @return void */ public function setTopicname($topicname) { $this->parameters['topicname'] = $topicname; } /** * Set the category * * @param string $category Search category * * @return void */ public function setCategory($category) { $this->parameters['category'] = $category; } /** * Set the topflg. It's only on the Yahoo!JAPAN's Top Page * * @return void */ public function setTopflg() { $this->parameters['topflg'] = 1; } /** * Set the midashiflg. It has a midashi. * * @return void */ public function setMidashiflg() { $this->parameters['midashiflg'] = 1; } /** * Set the relatedsite * * @param int $relatedsite It's a flag for showing related site * * @return void */ public function setRelatedsite($relatedsite = 1) { $this->parameters['relatedsite'] = $relatedsite; } /** * Set the sorder * * @param string $order An order to sort. * * @return void */ public function setOrder($order) { $this->parameters['order'] = $order; } /** * Set the sort * * @param string $sort An item to sort. * * @return void */ public function setSort($sort) { $this->parameters['sort'] = $sort; } /** * Set the num * * @param int $num Appoint the indication number. * * @return void */ public function setNum($num) { $this->parameters['num'] = $num; } } ?> http://cvs.php.net/viewvc.cgi/pear/Services_Yahoo_JP/Yahoo/JP/News/Response.php?view=markup&rev=1.1 Index: pear/Services_Yahoo_JP/Yahoo/JP/News/Response.php +++ pear/Services_Yahoo_JP/Yahoo/JP/News/Response.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * Services_Yahoo_JP News Response * * PHP version 5 * * LICENSE: This source file is subject to the New BSD license that is * available through the world-wide-web at the following URI: * http://www.opensource.org/licenses/bsd-license.php. If you did not receive * a copy of the New BSD License and are unable to obtain it through the web, * please send a note to [email protected] so we can mail you a copy immediately. * * @category Services * @package Services_Yahoo_JP * @author Tetsuya Nakase <[email protected]> * @copyright 2008 Tetsuya Nakase * @license http://www.opensource.org/licenses/bsd-license.php BSD * @version CVS: $Id: Response.php,v 1.1 2008/04/28 15:59:30 tetsuya Exp $ * @link http://phpize.net */ /** * Services_Yahoo News Response class * * This class provides methods for accessing the response of a category * request. * * @category Services * @package Services_Yahoo_JP * @extends Exception * @author Tetsuya Nakase <[email protected]> * @copyright 2008 Tetsuya Nakase * @license http://www.opensource.org/licenses/bsd-license.php BSD * @version Release: 0.0.1 * @link http://phpize.net */ class Services_Yahoo_JP_News_Response implements Iterator { /** * validate flag * * @access private * @var bool */ private $_isValidIterator = true; /** * counter * * @access private * @var intger */ private $_iteratorCounter = 0; /** * request object * * @access private * @var object */ private $_request; /** * result * * @access private * @var array */ private $_results = array(); /** * Constructor * * @param object $request HTTP_Request Instance of * HTTP_Request that was used for the request * * @throws Services_Yahoo_Exception */ public function __construct(HTTP_Request $request) { $this->_request = $request; $this->_parseRequest(); if ($this->_isError() == true) { $exception = new Services_Yahoo_Exception("News query failed"); $exception->addErrors($this->_getMessages()); throw $exception; } } // {{{ response handling /** * Get number of result sets returned by the content analysis * * @return integer Number of result sets returned */ public function getTotalResultsReturned() { return count((array)$this->xml->Result); } /** * Get the HTTP_Request instance that was used for the query * * Access to the HTTP_Request instance is useful for introspecting * into the request details. (E.g. for getting the HTTP response * code.) * * @return object HTTP_Request Instance of HTTP_Request */ public function getRequest() { return $this->_request; } // }}} // {{{ Iterator implementation /** * get current result of response * * @return array current result of response */ public function current() { return (array)$this->xml->Result[$this->_iteratorCounter]; } /** * get next result of response * * @return array next result of response */ public function next() { $this->_iteratorCounter++; if (!isset($this->xml->Result[$this->_iteratorCounter])) { $this->_isValidIterator = false; } } /** * get counter for iterator * * @return string counter */ public function key() { return $this->_iteratorCounter; } /** * clear counter for iterator * * @return void */ public function rewind() { $this->_iteratorCounter = 0; } /** * get validate status * * @return bool validate status */ public function valid() { return $this->_isValidIterator; } // }}} // {{{ private methods /** * Parse XML from the response * * @throws Services_Yahoo_Exception * * @return void */ private function _parseRequest() { $this->xml = simplexml_load_string($this->_request->getResponseBody()); if ($this->xml === false) { throw new Services_Yahoo_Exception("The response contained no valid XML"); } } /** * Determine if an error was returned by the Yahoo API * * This method evaluates the HTTP response code. If it indicates * an error, the method returns true. * * @return boolean True on error, otherwise false. */ private function _isError() { return in_array($this->_request->getResponseCode(), array(400, 403, 404, 503)); } /** * Get all error messages if the response contained an error * * Returns all errors in an numerically indexed array that were * part of the response. * * @see _isError() * @return array */ private function _getMessages() { $returnValue = array(); foreach ($this->xml->Message as $message) { $returnValue[] = $message; } return $returnValue; } /** * get Attribute * * @param string $name key in result * * @return string value of attribute */ public function returnAttribute($name) { if (isset($this->xml[$name])) { return $this->xml[$name]; } return null; } // }}} } http://cvs.php.net/viewvc.cgi/pear/Services_Yahoo_JP/Yahoo/JP/News/topics.php?view=markup&rev=1.1 Index: pear/Services_Yahoo_JP/Yahoo/JP/News/topics.php +++ pear/Services_Yahoo_JP/Yahoo/JP/News/topics.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ /** * News topics class * * PHP version 5 * * LICENSE: This source file is subject to the New BSD license that is * available through the world-wide-web at the following URI: * http://www.opensource.org/licenses/bsd-license.php. If you did not receive * a copy of the New BSD License and are unable to obtain it through the web, * please send a note to [email protected] so we can mail you a copy immediately. * * @category Services * @package Services_Yahoo_JP * @author Nakase Tetsuya <[email protected]> * @copyright 2008 Nakase Tetsuya * @license http://www.opensource.org/licenses/bsd-license.php BSD * @version CVS: $Id: topics.php,v 1.1 2008/04/28 15:59:30 tetsuya Exp $ * @link http://phpize.net */ require_once 'AbstractNews.php'; /** * Services_Yahoo_JP_News_topics * * This class implements an interface to Yahoo! JAPAN's Cateogry Tree by using * the Yahoo API. * * @category Services * @package Services_Yahoo_JP * @author Nakase Tetsuya <[email protected]> * @copyright 2008 Nakase Tetsuya * @license http://www.opensource.org/licenses/bsd-license.php BSD * @version Release: 0.0.1 * @link http://phpize.net */ class Services_Yahoo_JP_News_Topics extends Services_Yahoo_JP_News_AbstractNews { /** * api url * * @access protected * @var string */ protected $requestURL = 'http://api.news.yahoo.co.jp/NewsWebService/V1/Topics'; } ?> http://cvs.php.net/viewvc.cgi/pear/Services_Yahoo_JP/Yahoo/JP/Search/image.php?view=markup&rev=1.1 Index: pear/Services_Yahoo_JP/Yahoo/JP/Search/image.php +++ pear/Services_Yahoo_JP/Yahoo/JP/Search/image.php <?php /** * Image search class * * PHP version 5 * * LICENSE: This source file is subject to the New BSD license that is * available through the world-wide-web at the following URI: * http://www.opensource.org/licenses/bsd-license.php. If you did not receive * a copy of the New BSD License and are unable to obtain it through the web, * please send a note to [email protected] so we can mail you a copy immediately. * * @category Services * @package Services_Yahoo_JP * @author Tetsuya Nakase <[email protected]> * @copyright 2008 Tetsuya Nakase * @license http://www.opensource.org/licenses/bsd-license.php BSD * @version CVS: $Id: image.php,v 1.1 2008/04/28 15:59:31 tetsuya Exp $ * @link http://phpize.net */ require_once 'Services/Yahoo/Search/image.php'; /** * Image search class * * This class implements an interface to Yahoo's image search by using * the Yahoo API. * * @category Services * @package Services_Yahoo_JP * @author Tetsuya Nakase <[email protected]> * @copyright 2008 Tetsuya Nakase * @license http://www.opensource.org/licenses/bsd-license.php BSD * @version Release: 0.0.1 * @link http://phpize.net */ class Services_Yahoo_JP_Search_Image extends Services_Yahoo_Search_image { /** * api url * * @access protected * @var string */ protected $requestURL_JP = 'http://api.search.yahoo.co.jp/ImageSearchService/V1/imageSearch'; /** * Constructor to set a api url */ public function __construct() { $this->requestURL = $this->requestURL_JP; } } ?> http://cvs.php.net/viewvc.cgi/pear/Services_Yahoo_JP/Yahoo/JP/Search/video.php?view=markup&rev=1.1 Index: pear/Services_Yahoo_JP/Yahoo/JP/Search/video.php +++ pear/Services_Yahoo_JP/Yahoo/JP/Search/video.php <?php /** * Video search class * * PHP version 5 * * LICENSE: This source file is subject to the New BSD license that is * available through the world-wide-web at the following URI: * http://www.opensource.org/licenses/bsd-license.php. If you did not receive * a copy of the New BSD License and are unable to obtain it through the web, * please send a note to [email protected] so we can mail you a copy immediately. * * @category Services * @package Services_Yahoo_JP * @author Tetsuya Nakase <[email protected]> * @copyright 2008 Tetsuya Nakase * @license http://www.opensource.org/licenses/bsd-license.php BSD * @version CVS: $Id: video.php,v 1.1 2008/04/28 15:59:31 tetsuya Exp $ * @link http://phpize.net */ require_once 'Services/Yahoo/Search/video.php'; /** * Video search class * * This class implements an interface to Yahoo's video search by using * the Yahoo API. * * @category Services * @package Services_Yahoo_JP * @author Tetsuya Nakase <[email protected]> * @copyright 2008 Tetsuya Nakase * @license http://www.opensource.org/licenses/bsd-license.php BSD * @version Release: 0.0.1 * @link http://phpize.net */ class Services_Yahoo_JP_Search_Video extends Services_Yahoo_Search_video { /** * api url * * @access protected * @var string */ protected $requestURL_JP = 'http://api.search.yahoo.co.jp/VideoSearchService/V1/videoSearch'; /** * Constructor to set a api url */ public function __construct() { $this->requestURL = $this->requestURL_JP; } } ?> http://cvs.php.net/viewvc.cgi/pear/Services_Yahoo_JP/Yahoo/JP/Search/web.php?view=markup&rev=1.1 Index: pear/Services_Yahoo_JP/Yahoo/JP/Search/web.php +++ pear/Services_Yahoo_JP/Yahoo/JP/Search/web.php <?php /** * Web search class * * PHP version 5 * * LICENSE: This source file is subject to the New BSD license that is * available through the world-wide-web at the following URI: * http://www.opensource.org/licenses/bsd-license.php. If you did not receive * a copy of the New BSD License and are unable to obtain it through the web, * please send a note to [email protected] so we can mail you a copy immediately. * * @category Services * @package Services_Yahoo_JP * @author Tetsuya Nakase <[email protected]> * @copyright 2008 Tetsuya Nakase * @license http://www.opensource.org/licenses/bsd-license.php BSD * @version CVS: $Id: web.php,v 1.1 2008/04/28 15:59:31 tetsuya Exp $ * @link http://phpize.net */ require_once 'Services/Yahoo/Search/web.php'; /** * Web search class * * This class implements an interface to Yahoo's web search by using * the Yahoo API. * * @category Services * @package Services_Yahoo_JP * @author Tetsuya Nakase <[email protected]> * @copyright 2008 Tetsuya Nakase * @license http://www.opensource.org/licenses/bsd-license.php BSD * @version Release: 0.0.1 * @link http://phpize.net */ class Services_Yahoo_JP_Search_Web extends Services_Yahoo_Search_web { /** * api url * * @access protected * @var string */ protected $requestURL_JP = 'http://api.search.yahoo.co.jp/WebSearchService/V1/webSearch'; /** * Constructor to set a api url */ public function __construct() { $this->requestURL = $this->requestURL_JP; } } ?> http://cvs.php.net/viewvc.cgi/pear/Services_Yahoo_JP/Yahoo/JP/Auction.php?view=markup&rev=1.1 Index: pear/Services_Yahoo_JP/Yahoo/JP/Auction.php +++ pear/Services_Yahoo_JP/Yahoo/JP/Auction.php <?php /** * Auction dispatcher * * PHP version 5 * * LICENSE: This source file is subject to the New BSD license that is * available through the world-wide-web at the following URI: * http://www.opensource.org/licenses/bsd-license.php. If you did not receive * a copy of the New BSD License and are unable to obtain it through the web, * please send a note to [email protected] so we can mail you a copy immediately. * * @category Services * @package Services_Yahoo_JP * @author Tetsuya Nakase <[email protected]> * @copyright 2008 Tetsuya Nakase * @license http://www.opensource.org/licenses/bsd-license.php BSD * @version CVS: $Id: Auction.php,v 1.1 2008/04/28 15:59:31 tetsuya Exp $ * @link http://phpize.net */ require_once "Services/Yahoo/Exception.php"; /** * Auction dispatcher class * * This class provides a method to create a concrete instance of one * of the supported Auction types (category, exhibit, goods). * * @category Services * @package Services_Yahoo_JP * @author Tetsuya Nakase <[email protected]> * @copyright 2008 Tetsuya Nakase * @license http://www.opensource.org/licenses/bsd-license.php BSD * @version Release: 0.0.1 * @link http://phpize.net */ class Services_Yahoo_JP_Auction { /** * Attempts to return a concrete instance of a auction class * * @param string $type Can be one of category, goods or exhibit * * @return object Concrete instance of a auction class based on the paramter * @throws Services_Yahoo_Exception */ public function factory($type) { switch ($type) { case 'category': case 'goods' : case 'exhibit' : include_once 'Services/Yahoo/JP/Auction/' . $type . '.php'; $classname = 'Services_Yahoo_JP_Auction_' . ucfirst($type); return new $classname; default : throw new Services_Yahoo_Exception('Unknown Auction type ' . $type); break; } } } ?> http://cvs.php.net/viewvc.cgi/pear/Services_Yahoo_JP/Yahoo/JP/MA.php?view=markup&rev=1.1 Index: pear/Services_Yahoo_JP/Yahoo/JP/MA.php +++ pear/Services_Yahoo_JP/Yahoo/JP/MA.php <?php /** * MA dispatcher * * PHP version 5 * * LICENSE: This source file is subject to the New BSD license that is * available through the world-wide-web at the following URI: * http://www.opensource.org/licenses/bsd-license.php. If you did not receive * a copy of the New BSD License and are unable to obtain it through the web, * please send a note to [email protected] so we can mail you a copy immediately. * * @category Services * @package Services_Yahoo_JP * @author Tetsuya Nakase <[email protected]> * @copyright 2008 Tetsuya Nakase * @license http://www.opensource.org/licenses/bsd-license.php BSD * @version CVS: $Id: MA.php,v 1.1 2008/04/28 15:59:31 tetsuya Exp $ * @link http://phpize.net */ require_once "Services/Yahoo/Exception.php"; /** * MA dispatcher class * * This class provides a method to create a concrete instance of one * of the supported MA types (parse). * * Morphological Analysis * divide a Japanese sentence into a morpheme and * offer the function that can acquire a part of speech, * the grant of the phonetic symbol, statistics information. * * @category Services * @package Services_Yahoo_JP * @author Tetsuya Nakase <[email protected]> * @copyright 2008 Tetsuya Nakase * @license http://www.opensource.org/licenses/bsd-license.php BSD * @version Release: 0.0.1 * @link http://phpize.net */ class Services_Yahoo_JP_MA { /** * Attempts to return a concrete instance of a MA class * * @param string $type Can be one of parse. * * @return object Concrete instance of a MA class based on the paramter * @throws Services_Yahoo_Exception */ public function factory($type) { switch ($type) { case 'parse' : include_once 'Services/Yahoo/JP/MA/' . $type . '.php'; $classname = 'Services_Yahoo_JP_MA_' . ucfirst($type); return new $classname; default : throw new Services_Yahoo_Exception('Unknown MA type ' . $type); break; } } } ?> http://cvs.php.net/viewvc.cgi/pear/Services_Yahoo_JP/Yahoo/JP/News.php?view=markup&rev=1.1 Index: pear/Services_Yahoo_JP/Yahoo/JP/News.php +++ pear/Services_Yahoo_JP/Yahoo/JP/News.php <?php /** * News dispatcher * * PHP version 5 * * LICENSE: This source file is subject to the New BSD license that is * available through the world-wide-web at the following URI: * http://www.opensource.org/licenses/bsd-license.php. If you did not receive * a copy of the New BSD License and are unable to obtain it through the web, * please send a note to [email protected] so we can mail you a copy immediately. * * @category Services * @package Services_Yahoo_JP * @author Tetsuya Nakase <[email protected]> * @copyright 2008 Tetsuya Nakase * @license http://www.opensource.org/licenses/bsd-license.php BSD * @version CVS: $Id: News.php,v 1.1 2008/04/28 15:59:31 tetsuya Exp $ * @link http://phpize.net */ require_once "Services/Yahoo/Exception.php"; /** * News dispatcher class * * This class provides a method to create a concrete instance of one * of the supported News types (topics). * * @category Services * @package Services_Yahoo_JP * @author Tetsuya Nakase <[email protected]> * @copyright 2008 Tetsuya Nakase * @license http://www.opensource.org/licenses/bsd-license.php BSD * @version Release: 0.0.1 * @link http://phpize.net */ class Services_Yahoo_JP_News { /** * Attempts to return a concrete instance of a News class * * @param string $type Can be one of topics. * * @return object Concrete instance of a News class based on the paramter * @throws Services_Yahoo_Exception */ public function factory($type) { switch ($type) { case 'topics' : include_once 'Services/Yahoo/JP/News/' . $type . '.php'; $classname = 'Services_Yahoo_JP_News_' . ucfirst($type); return new $classname; default : throw new Services_Yahoo_Exception('Unknown news type ' . $type); break; } } } ?> http://cvs.php.net/viewvc.cgi/pear/Services_Yahoo_JP/Yahoo/JP/Search.php?view=markup&rev=1.1 Index: pear/Services_Yahoo_JP/Yahoo/JP/Search.php +++ pear/Services_Yahoo_JP/Yahoo/JP/Search.php <?php /** * Search dispatcher * * PHP version 5 * * LICENSE: This source file is subject to the New BSD license that is * available through the world-wide-web at the following URI: * http://www.opensource.org/licenses/bsd-license.php. If you did not receive * a copy of the New BSD License and are unable to obtain it through the web, * please send a note to [email protected] so we can mail you a copy immediately. * * @category Services * @package Services_Yahoo_JP * @author Tetsuya Nakase <[email protected]> * @copyright 2008 Tetsuya Nakase * @license http://www.opensource.org/licenses/bsd-license.php BSD * @version CVS: $Id: Search.php,v 1.1 2008/04/28 15:59:31 tetsuya Exp $ * @link http://phpize.net */ require_once 'Services/Yahoo/Search.php'; /** * Search dispatcher class * * This class provides a method to create a concrete instance of one * of the supported search types (Web, Images, Videos). * * @category Services * @package Services_Yahoo_JP * @author Tetsuya Nakase <[email protected]> * @copyright 2008 Tetsuya Nakase * @license http://www.opensource.org/licenses/bsd-license.php BSD * @version Release: 0.0.1 * @link http://phpize.net */ class Services_Yahoo_JP_Search extends Services_Yahoo_Search { /** * Attempts to return a concrete instance of a search class * * @param string $type Can be one of web, image or video * * @return object Concrete instance of a search class based on the paramter * @throws Services_Yahoo_Exception */ public function factory($type) { switch ($type) { case 'web' : case 'image' : case 'video' : include_once 'Services/Yahoo/JP/Search/' . $type . '.php'; $classname = 'Services_Yahoo_JP_Search_' . ucfirst($type); return new $classname; default : throw new Services_Yahoo_Exception('Unknown search type ' . $type); break; } } } ?>