Services_Digg
[ class tree: Services_Digg ] [ index: Services_Digg ] [ all elements ]

Source for file php.php

Documentation is available at php.php

  1. <?php
  2.  
  3. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  4.  
  5. /**
  6.  * API for Digg's web services
  7.  *
  8.  * PHP version 5.1.0+
  9.  *
  10.  * LICENSE: This source file is subject to version 3.0 of the PHP license
  11.  * that is available through the world-wide-web at the following URI:
  12.  * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
  13.  * the PHP License and are unable to obtain it through the web, please
  14.  * send a note to license@php.net so we can mail you a copy immediately.
  15.  *
  16.  * @category    Services
  17.  * @package     Services_Digg
  18.  * @author      Joe Stump <joe@joestump.net>
  19.  * @copyright   1997-2007 The PHP Group
  20.  * @license     http://www.php.net/license/3_0.txt  PHP License 3.0
  21.  * @version     CVS: $Id:$
  22.  * @link        http://pear.php.net/package/Services_Digg
  23.  */
  24.  
  25. require_once 'Services/Digg/Response/Common.php';
  26.  
  27. /**
  28.  * Services_Digg_Response_php
  29.  *  
  30.  * Parses the PHP response type from the Digg API. Digg's API responds with
  31.  * PHP, JSON and XML currently.
  32.  *  
  33.  * @category    Services
  34.  * @package     Services_Digg
  35.  * @author      Joe Stump <joe@joestump.net>
  36.  */
  37. {
  38.     /**
  39.      * Parse PHP respnse
  40.      *
  41.      * @access      public
  42.      * @return      mixed       DiggAPIError on failure
  43.      */
  44.     public function parse()
  45.     {
  46.         $result @unserialize($this->response);
  47.         if (!is_object($result)) {
  48.             throw new Services_Digg_Response_Exception('Could not parse result: ' $this->response);
  49.         }
  50.  
  51.         if ($result instanceof DiggAPIError{
  52.             throw new Services_Digg_Response_Exception($result->message$result->code);
  53.         }
  54.  
  55.         return $result;
  56.     }
  57. }
  58.  
  59. if (!class_exists('DiggAPIStory'false)) {
  60.     require_once 'Services/Digg/Story.php';
  61.  
  62.     /**
  63.      * DiggAPIStory
  64.      *
  65.      * @author      Joe Stump <joe@joestump.net>
  66.      * @see         Services_Digg_Story
  67.      */
  68.     class DiggAPIStory extends Services_Digg_Story
  69.     {
  70.         public function __call($functionarray $args)
  71.         {
  72.             $params = array();
  73.             if (isset($args[0]&& is_array($args[0]&& count($args[0])) {
  74.                 $params $args[0];
  75.             }
  76.  
  77.             return parent::__call($functionarray($this->id$params));
  78.         }
  79.  
  80.         /**
  81.          * Get comment activity for a story
  82.          * 
  83.          * @access      public
  84.          * @param       array       $params     Digg API arguments
  85.          * @throws      PEAR_Exception
  86.          */
  87.         public function getCommentActivity(array $params = array()) 
  88.         {
  89.             return parent::getCommentActivity($this->id$params);
  90.         }
  91.  
  92.         /**
  93.          * Get digg activity for a story
  94.          * 
  95.          * @access      public
  96.          * @param       array       $params     Digg API arguments
  97.          * @throws      PEAR_Exception
  98.          */
  99.         public function getDiggActivity(array $params = array()) 
  100.         {
  101.             return parent::getCommentActivity($this->id$params);
  102.         }
  103.     }
  104. }
  105.  
  106. if (!class_exists('DiggAPIGalleryPhoto'false)) {
  107.     require_once 'Services/Digg/GalleryPhoto.php';
  108.  
  109.     /**
  110.      * DiggAPIStory
  111.      *
  112.      * @author      Joe Stump <joe@joestump.net>
  113.      * @see         Services_Digg_GalleryPhoto
  114.      */
  115.     {
  116.         /**
  117.          * Make a second service call
  118.          *
  119.          * @param       string      $function 
  120.          * @param       array       $args 
  121.          */
  122.         public function __call($functionarray $args)
  123.         {
  124.             $params = array();
  125.             if (isset($args[0]&& is_array($args[0]&& count($args[0])) {
  126.                 $params $args[0];
  127.             }
  128.  
  129.             return parent::__call($functionarray($this->id$params));
  130.         }
  131.     }
  132. }
  133.  
  134.  
  135. if (!class_exists('DiggAPIError'false)) {
  136.     /**
  137.      * DiggAPIError
  138.      *
  139.      * @category    Services
  140.      * @package     Services_Digg
  141.      * @author      Joe Stump <joe@joestump.net>
  142.      * @throws      PEAR_Exception
  143.      */
  144.     class DiggAPIError 
  145.     {
  146.         /**
  147.          * Error message
  148.          *
  149.          * @access      public
  150.          * @var         string      $message    Error message
  151.          */
  152.         public $message = '';
  153.  
  154.         /**
  155.          * Error code
  156.          *
  157.          * @access      public
  158.          * @var         int         $code       Error code
  159.          */
  160.         public $code = 0;
  161.  
  162.         /**
  163.          * Get error message
  164.          *
  165.          * @access      public
  166.          * @return      string      Error message
  167.          */
  168.         public function getMessage()
  169.         {
  170.             return $this->message;
  171.         }
  172.  
  173.         /**
  174.          * Get error code
  175.          *
  176.          * @access      public
  177.          * @return      int         Error code
  178.          */
  179.         public function getCode()
  180.         {
  181.             return $this->code;
  182.         }
  183.     }
  184. }
  185.  
  186. if (!class_exists('DiggAPIUser'false)) {
  187.     require_once 'Services/Digg/User.php';
  188.  
  189.     /**
  190.      * DiggAPIUser
  191.      *
  192.      * @category    Services
  193.      * @package     Services_Digg
  194.      * @author      Joe Stump <joe@joestump.net>
  195.      * @see         Services_Digg_User
  196.      */
  197.     class DiggAPIUser extends Services_Digg_User
  198.     {
  199.         /**
  200.          * __call
  201.          * 
  202.          * @access      public
  203.          * @param       string      $function 
  204.          * @param       array       $args 
  205.          * @return      mixed 
  206.          */
  207.         public function __call($functionarray $args
  208.         {
  209.             $params = array();
  210.             if (isset($args[0]&& is_array($args[0]&& count($args[0])) {
  211.                 $params $args[0];
  212.             }
  213.  
  214.             return parent::__call($functionarray($this->name$params));
  215.         }
  216.  
  217.         /**
  218.          * Get a user's comment activity
  219.          *
  220.          * @access      public
  221.          * @param       array       $params 
  222.          * @throws      PEAR_Exception
  223.          */
  224.         public function getCommentActivity(array $params = array()) 
  225.         {
  226.             return parent::getCommentActivity($this->name$params);
  227.         }
  228.  
  229.         /**
  230.          * Get a user's digg activity
  231.          *
  232.          * @access      public
  233.          * @param       array       $params 
  234.          * @throws      PEAR_Exception
  235.          */
  236.         public function getDiggsActivity(array $params = array()) 
  237.         {
  238.             return parent::getDiggsActivity($this->name$params);
  239.         }
  240.  
  241.         /**
  242.          * Is the user friends with a person
  243.          *
  244.          * @access      public
  245.          * @param       string      $friend         Username to check for
  246.          * @return      boolean 
  247.          */
  248.         public function isFriend($friend)
  249.         {
  250.             return parent::isFan($this->name$friend);
  251.         }
  252.  
  253.         /**
  254.          * Is the person a fan of this user
  255.          *
  256.          * @access      public
  257.          * @param       string      $fan            Username to check for
  258.          * @return      boolean 
  259.          */
  260.         public function isFan($fan)
  261.         {
  262.             return parent::isFan($this->name$fan);
  263.         }
  264.  
  265.         /**
  266.          * Get a user's friends' submissions
  267.          *
  268.          * @access      public
  269.          * @param       array       $params 
  270.          * @throws      Services_Digg_Exception
  271.          */
  272.         public function getFriendsSubmissions(array $params = array())
  273.         {
  274.             $endPoint '/user/' $this->name . '/friends/submissions';
  275.             return $this->sendRequest($endPoint$params);
  276.         }
  277.  
  278.         /**
  279.          * Get a user's friends' dugg stories
  280.          *
  281.          * @access      public
  282.          * @param       array       $params 
  283.          * @throws      Services_Digg_Exception
  284.          */
  285.         public function getFriendsDugg(array $params = array())
  286.         {
  287.             $endPoint '/user/' $this->name . '/friends/dugg';
  288.             return $this->sendRequest($endPoint$params);
  289.         }
  290.     
  291.         /**
  292.          * Get a user's friends' commented stories
  293.          *
  294.          * @access      public
  295.          * @param       array       $params 
  296.          * @throws      Services_Digg_Exception
  297.          */
  298.         public function getFriendsCommented(array $params = array())
  299.         {
  300.             $endPoint '/user/' $this->name . '/friends/commented';
  301.             return $this->sendRequest($endPoint$params);
  302.         }
  303.  
  304.         /**
  305.          * Get a user's friends' popular stories that they dugg
  306.          *
  307.          * @access      public
  308.          * @param       array       $params 
  309.          * @throws      Services_Digg_Exception
  310.          */
  311.         public function getFriendsPopular(array $params = array())
  312.         {
  313.             $endPoint '/user/' $this->name . '/friends/popular';
  314.             return $this->sendRequest($endPoint$params);
  315.         }
  316.     
  317.         /**
  318.          * Get a user's friends' upcoming stories that they dugg
  319.          *
  320.          * @access      public
  321.          * @param       array       $params 
  322.          * @throws      Services_Digg_Exception
  323.          */
  324.         public function getFriendsUpcoming(array $params = array())
  325.         {
  326.             $endPoint '/user/' $this->name . '/friends/upcoming';
  327.             return $this->sendRequest($endPoint$params);
  328.         }
  329.     }
  330. }
  331.  
  332. if (!class_exists('DiggAPIComment'false)) {
  333.     require_once 'Services/Digg/Comment.php';
  334.  
  335.     /**
  336.      * DiggAPIComment
  337.      *
  338.      * @category    Services
  339.      * @package     Services_Digg
  340.      * @author      Joe Stump <joe@joestump.net>
  341.      * @see         Services_Digg_Comment
  342.      */
  343.     class DiggAPIComment extends Services_Digg_Comment
  344.     {
  345.         /**
  346.          * Get a comment's replies
  347.          *
  348.          * This function returns replies to the current comment. It only makes
  349.          * the second API call if the reply count is greater than zero.
  350.          *
  351.          * @access      public
  352.          * @param       array       $params     Digg API arguments
  353.          * @return      object      Instance of DiggAPIEvents
  354.          */
  355.         public function replies(array $params = array())
  356.         {
  357.             if ($this->replies > 0{
  358.                 $endPoint '/story/' $this->story '/comment/' $this->id .
  359.                             '/replies';
  360.                 return $this->sendRequest($endPoint$params);
  361.             }
  362.  
  363.             $ret = new DiggAPIEvents();
  364.             $ret->timestamp = time();
  365.             $ret->total = $ret->offset = $ret->count = 0;
  366.             return $ret;
  367.         }
  368.  
  369.         /**
  370.          * __toString
  371.          *
  372.          * @access      public
  373.          * @return      string      Comment's content
  374.          */
  375.         public function __toString(
  376.         {
  377.             return $this->content;
  378.         }
  379.     }
  380. }
  381.  
  382. if (!class_exists('DiggAPIActivityPeriod'false)) {
  383.     /**
  384.      * DiggAPIActivityPeriod
  385.      *
  386.      * @category    Services
  387.      * @package     Services_Digg
  388.      * @author      Joe Stump <joe@joestump.net>
  389.      */
  390.     class DiggAPIActivityPeriod
  391.     {
  392.  
  393.     }
  394. }
  395.  
  396. if (!class_exists('DiggAPIActivity'false)) {
  397.     /**
  398.      * DiggAPIActivity
  399.      *
  400.      * @category    Services
  401.      * @package     Services_Digg
  402.      * @author      Joe Stump <joe@joestump.net>
  403.      */
  404.     class DiggAPIActivity
  405.     {
  406.         /**
  407.          * Rewind $activity array
  408.          *
  409.          * @access      public
  410.          * @return      void 
  411.          */
  412.         public function rewind(
  413.         {
  414.             if (is_array($this->activity&& count($this->activity)) {
  415.                 reset($this->activity);
  416.             }
  417.  
  418.             return false;
  419.         }
  420.  
  421.         /**
  422.          * Return current element of $activity
  423.          *
  424.          * @access      public
  425.          * @return      mixed 
  426.          */
  427.         public function current()
  428.         {
  429.             if (is_array($this->activity&& count($this->activity)) {
  430.                 return current($this->activity);
  431.             }
  432.  
  433.             return false;
  434.         }
  435.  
  436.         /**
  437.          * Return a key from $activity array
  438.          *
  439.          * @access      public
  440.          * @return      mixed 
  441.          */
  442.         public function key()
  443.         {
  444.             if (is_array($this->activity&& count($this->activity)) {
  445.                 return key($this->activity);
  446.             }
  447.  
  448.             return false;
  449.         }
  450.  
  451.         /**
  452.          * Advance the internal pointer of $activity array
  453.          *
  454.          * @access      public
  455.          * @return      mixed 
  456.          */
  457.         public function next()
  458.         {
  459.             if (is_array($this->activity&& count($this->activity)) {
  460.                 return next($this->activity);
  461.             }
  462.  
  463.             return false;
  464.         }
  465.  
  466.         /**
  467.          * Is the next iteration valid?
  468.          *
  469.          * @access      public
  470.          * @return      boolean 
  471.          */
  472.         public function valid()
  473.         {
  474.             return ($this->current(!== false);
  475.         }
  476.     }
  477. }
  478.  
  479. if (!class_exists('DiggAPIContainer'false)) {
  480.     /**
  481.      * DiggAPIContainer
  482.      *
  483.      * @category    Services
  484.      * @package     Services_Digg
  485.      * @author      Joe Stump <joe@joestump.net>
  486.      */
  487.     class DiggAPIContainer
  488.     {
  489.  
  490.     }
  491. }
  492.  
  493. if (!class_exists('DiggAPIDigg'false)) {
  494.     /**
  495.      * DiggAPIDigg
  496.      *
  497.      * @category    Services
  498.      * @package     Services_Digg
  499.      * @author      Joe Stump <joe@joestump.net>
  500.      */
  501.     class DiggAPIDigg 
  502.     {
  503.  
  504.     }
  505. }
  506.  
  507. if (!class_exists('DiggAPIErrors'false)) {
  508.     /**
  509.      * DiggAPIError
  510.      *
  511.      * @category    Services
  512.      * @package     Services_Digg
  513.      * @author      Joe Stump <joe@joestump.net>
  514.      */
  515.     class DiggAPIErrors
  516.     {
  517.         /**
  518.          * Rewind $errors array
  519.          *
  520.          * @access      public
  521.          * @return      void 
  522.          */
  523.         public function rewind(
  524.         {
  525.             if (is_array($this->errors&& count($this->errors)) {
  526.                 reset($this->errors);
  527.             }
  528.  
  529.             return false;
  530.         }
  531.  
  532.         /**
  533.          * Return current element of $errors
  534.          *
  535.          * @access      public
  536.          * @return      mixed 
  537.          */
  538.         public function current()
  539.         {
  540.             if (is_array($this->errors&& count($this->errors)) {
  541.                 return current($this->errors);
  542.             }
  543.  
  544.             return false;
  545.         }
  546.  
  547.         /**
  548.          * Return a key from $errors array
  549.          *
  550.          * @access      public
  551.          * @return      mixed 
  552.          */
  553.         public function key()
  554.         {
  555.             if (is_array($this->errors&& count($this->errors)) {
  556.                 return key($this->errors);
  557.             }
  558.  
  559.             return false;
  560.         }
  561.  
  562.         /**
  563.          * Advance the internal pointer of $errors array
  564.          *
  565.          * @access      public
  566.          * @return      mixed 
  567.          */
  568.         public function next()
  569.         {
  570.             if (is_array($this->errors&& count($this->errors)) {
  571.                 return next($this->errors);
  572.             }
  573.  
  574.             return false;
  575.         }
  576.  
  577.         /**
  578.          * Is the next iteration valid?
  579.          *
  580.          * @access      public
  581.          * @return      boolean 
  582.          */
  583.         public function valid()
  584.         {
  585.             return ($this->current(!== false);
  586.         }
  587.     }
  588.  
  589. if (!class_exists('DiggAPIEvents'false)) {
  590.     /**
  591.      * DiggAPIEvents
  592.      *
  593.      * @category    Services
  594.      * @package     Services_Digg
  595.      * @author      Joe Stump <joe@joestump.net>
  596.      */
  597.     class DiggAPIEvents implements Iterator
  598.     {
  599.         /**
  600.          * Which array to iterate
  601.          *
  602.          * The DiggAPIEvents class is returned for both comments and diggs.
  603.          * In order for PHP5 object iteration to happen we need to figure out
  604.          * which events are returned (diggs v. comments) and iterate through
  605.          * that array.
  606.          *
  607.          * @access      private
  608.          * @var         string      $iterate 
  609.          */
  610.         private $iterator = null;
  611.  
  612.         /**
  613.          * __wakeup
  614.          *
  615.          * When this is unserialized we check to see if the events listed
  616.          * are diggs or comments and then set $iterator appropriately.
  617.          *
  618.          * @access      public
  619.          * @return      void 
  620.          * @see         DiggAPIEvents::$iterator
  621.          */
  622.         public function __wakeup(
  623.         {
  624.             if (isset($this->diggs&& 
  625.                 is_array($this->diggs)) {
  626.                 $this->iterator 'diggs';
  627.             elseif (isset($this->comments&&
  628.                       is_array($this->comments)) {
  629.                 $this->iterator 'comments';
  630.             }
  631.         }
  632.  
  633.         /**
  634.          * Rewind $stories array
  635.          *
  636.          * @access      public
  637.          * @return      void 
  638.          */
  639.         public function rewind(
  640.         {
  641.             if (!is_null($this->iterator)) {
  642.                 reset($this->{$this->iterator});
  643.             }
  644.  
  645.             return false;
  646.         }
  647.  
  648.         /**
  649.          * Return current element of $stories
  650.          *
  651.          * @access      public
  652.          * @return      mixed 
  653.          */
  654.         public function current()
  655.         {
  656.             if (!is_null($this->iterator)) {
  657.                 return current($this->{$this->iterator});
  658.             }
  659.  
  660.             return false;
  661.         }
  662.  
  663.         /**
  664.          * Return a key from $stories array
  665.          *
  666.          * @access      public
  667.          * @return      mixed 
  668.          */
  669.         public function key()
  670.         {
  671.             if (!is_null($this->iterator)) {
  672.                 return key($this->{$this->iterator});
  673.             }
  674.  
  675.             return false;
  676.         }
  677.  
  678.         /**
  679.          * Advance the internal pointer of $stories array
  680.          *
  681.          * @access      public
  682.          * @return      mixed 
  683.          */
  684.         public function next()
  685.         {
  686.             if (!is_null($this->iterator)) {
  687.                 return next($this->{$this->iterator});
  688.             }
  689.  
  690.             return false;
  691.         }
  692.  
  693.         /**
  694.          * Is the next iteration valid?
  695.          *
  696.          * @access      public
  697.          * @return      boolean 
  698.          */
  699.         public function valid()
  700.         {
  701.             return ($this->current(!== false);
  702.         }
  703.     }
  704. }   
  705.  
  706. if (!class_exists('DiggAPIStories'false)) {
  707.     /**
  708.      * DiggAPIStories
  709.      *
  710.      * The stories return object uses PHP5 object iteration so that you can
  711.      * quickly iterate through responses.
  712.      *
  713.      * <code>
  714.      * <?php
  715.      * 
  716.      * require_once 'Services/Digg.php';
  717.      * $api = Services_Digg::factory('Stories');
  718.      * $stories = $api->getAll(array('count' => 10));
  719.      * foreach ($stories as $story) {
  720.      *     echo $story->title . '<br />' . "\n";
  721.      * }
  722.      * 
  723.      * ?>
  724.      * </code>
  725.      *
  726.      * @category    Services
  727.      * @package     Services_Digg
  728.      * @author      Joe Stump <joe@joestump.net>
  729.      * @link        http://www.php.net/manual/en/language.oop5.iterations.php
  730.      */
  731.     class DiggAPIStories implements Iterator
  732.     {
  733.         /**
  734.          * Rewind $stories array
  735.          *
  736.          * @access      public
  737.          * @return      void 
  738.          */
  739.         public function rewind(
  740.         {
  741.             if (isset($this->stories&& is_array($this->stories&& 
  742.                 count($this->stories)) {
  743.                 reset($this->stories);
  744.             }
  745.  
  746.             return false;
  747.         }
  748.  
  749.         /**
  750.          * Return current element of $stories
  751.          *
  752.          * @access      public
  753.          * @return      mixed 
  754.          */
  755.         public function current()
  756.         {
  757.             if (isset($this->stories&& is_array($this->stories&& 
  758.                 count($this->stories)) {
  759.                 return current($this->stories);
  760.             }
  761.  
  762.             return false;
  763.         }
  764.  
  765.         /**
  766.          * Return a key from $stories array
  767.          *
  768.          * @access      public
  769.          * @return      mixed 
  770.          */
  771.         public function key()
  772.         {
  773.             if (isset($this->stories&& is_array($this->stories&& 
  774.                 count($this->stories)) {
  775.                 return key($this->stories);
  776.             }
  777.  
  778.             return false;
  779.         }
  780.  
  781.         /**
  782.          * Advance the internal pointer of $stories array
  783.          *
  784.          * @access      public
  785.          * @return      mixed 
  786.          */
  787.         public function next()
  788.         {
  789.             if (isset($this->stories&& is_array($this->stories&& 
  790.                 count($this->stories)) {
  791.                 return next($this->stories);
  792.             }
  793.  
  794.             return false;
  795.         }
  796.  
  797.         /**
  798.          * Is the next iteration valid?
  799.          *
  800.          * @access      public
  801.          * @return      boolean 
  802.          */
  803.         public function valid()
  804.         {
  805.             return ($this->current(!== false);
  806.         }
  807.     }
  808. }
  809.  
  810. if (!class_exists('DiggAPIGallery'false)) {
  811.     /**
  812.      * DiggAPIGallery
  813.      *
  814.      * The stories return object uses PHP5 object iteration so that you can
  815.      * quickly iterate through responses.
  816.      *
  817.      * <code>
  818.      * <?php
  819.      * 
  820.      * require_once 'Services/Digg.php';
  821.      * $api = Services_Digg::factory('GalleryPhotos');
  822.      * $photos = $api->getAll(array('count' => 10));
  823.      * foreach ($photos as $photo) {
  824.      *     echo $photo->title . '<br />' . "\n";
  825.      * }
  826.      * 
  827.      * ?>
  828.      * </code>
  829.      *
  830.      * @category    Services
  831.      * @package     Services_Digg
  832.      * @author      Joe Stump <joe@joestump.net>
  833.      * @link        http://www.php.net/manual/en/language.oop5.iterations.php
  834.      */
  835.     class DiggAPIGallery implements Iterator
  836.     {
  837.         /**
  838.          * Rewind $photos array
  839.          *
  840.          * @access      public
  841.          * @return      void 
  842.          */
  843.         public function rewind(
  844.         {
  845.             if (isset($this->photos&& is_array($this->photos&& 
  846.                 count($this->photos)) {
  847.                 reset($this->photos);
  848.             }
  849.  
  850.             return false;
  851.         }
  852.  
  853.         /**
  854.          * Return current element of $photos
  855.          *
  856.          * @access      public
  857.          * @return      mixed 
  858.          */
  859.         public function current()
  860.         {
  861.             if (isset($this->photos&& is_array($this->photos&& 
  862.                 count($this->photos)) {
  863.                 return current($this->photos);
  864.             }
  865.  
  866.             return false;
  867.         }
  868.  
  869.         /**
  870.          * Return a key from $photos array
  871.          *
  872.          * @access      public
  873.          * @return      mixed 
  874.          */
  875.         public function key()
  876.         {
  877.             if (isset($this->photos&& is_array($this->photos&& 
  878.                 count($this->photos)) {
  879.                 return key($this->photos);
  880.             }
  881.  
  882.             return false;
  883.         }
  884.  
  885.         /**
  886.          * Advance the internal pointer of $photos array
  887.          *
  888.          * @access      public
  889.          * @return      mixed 
  890.          */
  891.         public function next()
  892.         {
  893.             if (isset($this->photos&& is_array($this->photos&& 
  894.                 count($this->photos)) {
  895.                 return next($this->photos);
  896.             }
  897.  
  898.             return false;
  899.         }
  900.  
  901.         /**
  902.          * Is the next iteration valid?
  903.          *
  904.          * @access      public
  905.          * @return      boolean 
  906.          */
  907.         public function valid()
  908.         {
  909.             return ($this->current(!== false);
  910.         }
  911.     }
  912. }
  913.  
  914.  
  915. if (!class_exists('DiggAPITopic'false)) {
  916.     /**
  917.      * DiggAPITopic
  918.      *
  919.      * @category    Services
  920.      * @package     Services_Digg
  921.      * @author      Joe Stump <joe@joestump.net>
  922.      */
  923.     class DiggAPITopic
  924.     {
  925.  
  926.     }
  927. }
  928.  
  929. if (!class_exists('DiggAPIThumbnail'false)) {
  930.     /**
  931.      * DiggAPIThumbnail
  932.      *
  933.      * @category    Services
  934.      * @package     Services_Digg
  935.      * @author      Joe Stump <joe@joestump.net>
  936.      */
  937.     class DiggAPIThumbnail 
  938.     {
  939.  
  940.     }
  941. }
  942.  
  943. if (!class_exists('DiggAPITopics'false)) {
  944.     /**
  945.      * DiggAPITopics
  946.      *
  947.      * @category    Services
  948.      * @package     Services_Digg
  949.      * @author      Joe Stump <joe@joestump.net>
  950.      */
  951.     class DiggAPITopics implements Iterator 
  952.     {
  953.         /**
  954.          * Rewind $topics array
  955.          *
  956.          * @access      public
  957.          * @return      void 
  958.          */
  959.         public function rewind(
  960.         {
  961.             if (is_array($this->topics&& count($this->topics)) {
  962.                 reset($this->topics);
  963.             }
  964.  
  965.             return false;
  966.         }
  967.  
  968.         /**
  969.          * Return current element of $topics
  970.          *
  971.          * @access      public
  972.          * @return      mixed 
  973.          */
  974.         public function current()
  975.         {
  976.             if (is_array($this->topics&& count($this->topics)) {
  977.                 return current($this->topics);
  978.             }
  979.  
  980.             return false;
  981.         }
  982.  
  983.         /**
  984.          * Return a key from $topics array
  985.          *
  986.          * @access      public
  987.          * @return      mixed 
  988.          */
  989.         public function key()
  990.         {
  991.             if (is_array($this->topics&& count($this->topics)) {
  992.                 return key($this->topics);
  993.             }
  994.  
  995.             return false;
  996.         }
  997.  
  998.         /**
  999.          * Advance the internal pointer of $topics array
  1000.          *
  1001.          * @access      public
  1002.          * @return      mixed 
  1003.          */
  1004.         public function next()
  1005.         {
  1006.             if (is_array($this->topics&& count($this->topics)) {
  1007.                 return next($this->topics);
  1008.             }
  1009.  
  1010.             return false;
  1011.         }
  1012.  
  1013.         /**
  1014.          * Is the next iteration valid?
  1015.          *
  1016.          * @access      public
  1017.          * @return      boolean 
  1018.          */
  1019.         public function valid()
  1020.         {
  1021.             return ($this->current(!== false);
  1022.         }
  1023.     }
  1024. }
  1025.  
  1026. if (!class_exists('DiggAPILink'false)) {
  1027.     /**
  1028.      * DiggAPILink
  1029.      * 
  1030.      * @category    Services
  1031.      * @package     Services_Digg
  1032.      * @author      Joe Stump <joe@joestump.net>
  1033.      */
  1034.     class DiggAPILink 
  1035.     {
  1036.  
  1037.     }
  1038. }
  1039.  
  1040. if (!class_exists('DiggAPIShortURLs'false)) {
  1041.     /**
  1042.      * DiggAPIShortURLs
  1043.      * 
  1044.      * @category    Services
  1045.      * @package     Services_Digg
  1046.      * @author      Kurt Wilms kurt@digg.com
  1047.      */
  1048.     class DiggAPIShortURLs implements IteratorAggregate
  1049.     {
  1050.         /**
  1051.          * Return the URl's for iteration
  1052.          *
  1053.          * @return object Instance of ArrayObject
  1054.          */
  1055.         public function getIterator()
  1056.         {
  1057.             return new ArrayObject($this->shorturls);
  1058.         }
  1059.     }
  1060. }
  1061.  
  1062. if (!class_exists('DiggAPIShortURL'false)) {
  1063.     /**
  1064.      * DiggAPIShortURL
  1065.      * 
  1066.      * @category    Services
  1067.      * @package     Services_Digg
  1068.      * @author      Kurt Wilms kurt@digg.com
  1069.      */
  1070.     class DiggAPIShortURL 
  1071.     {
  1072.  
  1073.     }
  1074. }
  1075.  
  1076. if (!class_exists('DiggAPIUsers'false)) {
  1077.     /**
  1078.      * DiggAPIUsers
  1079.      *
  1080.      * @category    Services
  1081.      * @package     Services_Digg
  1082.      * @author      Joe Stump <joe@joestump.net>
  1083.      */
  1084.     class DiggAPIUsers implements Iterator
  1085.     {
  1086.         /**
  1087.          * Rewind $users array
  1088.          *
  1089.          * @access      public
  1090.          * @return      void 
  1091.          */
  1092.         public function rewind(
  1093.         {
  1094.             if (isset($this->users&& is_array($this->users&& count($this->users)) {
  1095.                 reset($this->users);
  1096.             }
  1097.  
  1098.             return false;
  1099.         }
  1100.  
  1101.         /**
  1102.          * Return current element of $users
  1103.          *
  1104.          * @access      public
  1105.          * @return      mixed 
  1106.          */
  1107.         public function current()
  1108.         {
  1109.             if (isset($this->users&& is_array($this->users&& count($this->users)) {
  1110.                 return current($this->users);
  1111.             }
  1112.  
  1113.             return false;
  1114.         }
  1115.  
  1116.         /**
  1117.          * Return a key from $users array
  1118.          *
  1119.          * @access      public
  1120.          * @return      mixed 
  1121.          */
  1122.         public function key()
  1123.         {
  1124.             if (is_array($this->users&& count($this->users)) {
  1125.                 return key($this->users);
  1126.             }
  1127.  
  1128.             return false;
  1129.         }
  1130.  
  1131.         /**
  1132.          * Advance the internal pointer of $users array
  1133.          *
  1134.          * @access      public
  1135.          * @return      mixed 
  1136.          */
  1137.         public function next()
  1138.         {
  1139.             if (is_array($this->users&& count($this->users)) {
  1140.                 return next($this->users);
  1141.             }
  1142.  
  1143.             return false;
  1144.         }
  1145.  
  1146.         /**
  1147.          * Is the next iteration valid?
  1148.          *
  1149.          * @access      public
  1150.          * @return      boolean 
  1151.          */
  1152.         public function valid()
  1153.         {
  1154.             return ($this->current(!== false);
  1155.         }
  1156.     }
  1157. }
  1158.  
  1159. ?>

Documentation generated on Fri, 10 Jul 2009 01:30:05 +0000 by phpDocumentor 1.4.2. PEAR Logo Copyright © PHP Group 2004.