Exemplo n.º 1
0
 /**
  * Ensures that getRecentPosts() provides expected behavior
  *
  * @return void
  */
 public function testGetRecentPosts()
 {
     $posts = $this->_delicious->getRecentPosts('zfSite', 10);
     $this->assertType('Zend_Service_Delicious_PostList', $posts);
     $this->assertTrue(count($posts) <= 10);
     foreach ($posts as $post) {
         $this->assertContains('zfSite', $post->getTags());
     }
 }
Exemplo n.º 2
0
 public function fetch()
 {
     if ($this->_disabled) {
         return array();
     }
     $frontendOptions = array('lifetime' => $this->_config->cacheLifetime, 'automatic_serialization' => true);
     $backendOptions = array('cache_dir' => $this->_config->cacheDir);
     $cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
     if (!($this->_items = $cache->load('delicious'))) {
         $delicious = new Zend_Service_Delicious($this->_config->username, $this->_config->password);
         $results = $delicious->getRecentPosts(null, $this->_config->limit);
         $this->_items = array();
         foreach ($results as $entry) {
             $this->_items[] = new Polycast_Stalker_Item_Delicious($entry->getTitle(), $entry->getUrl(), $entry->getTags(), new DateTime($entry->getDate()->toString()), $entry->getNotes(), $this->_config->items);
         }
         $cache->save($this->_items, 'delicious');
         uasort($this->_items, array('Polycast_Stalker', 'sortItems'));
         $this->_items = array_slice($this->_items, 0, $this->_config->limit, true);
     }
     return count($this->_items);
 }
Exemplo n.º 3
0
 /**
  * Gets posts by tags if necessary for a username and password
  *
  * @param string $username (del feed)
  * @param string $password	
  * @param string $tags tags to look for (array or comma separated string)
  * @param int $count
  * @return array $links array of links
  * @author Dan Chadwick
  */
 public function get_links_by_tag($username, $password, $tags = null, $count = 10)
 {
     if (!is_array($tags)) {
         $findtags = array();
         if (strpos($tags, ',') !== false) {
             foreach (split(',', $tags) as $value) {
                 $findtags[] = $tags;
             }
         } else {
             $findtags[] = $tags;
         }
     }
     $links = array();
     $delicious = new Zend_Service_Delicious($username, $password);
     $posts = $delicious->getRecentPosts($findtags, $count);
     // Print posts having "php" and "zend" tags
     foreach ($posts as $post) {
         $links[] = array('title' => $post->getTitle(), 'url' => $post->getUrl());
     }
     return $links;
 }