Beispiel #1
0
 /**
  *
  * @param  string                       $object
  * @param  int                          $offset_start
  * @param  int                          $quantity
  * @return Bridge_Api_ElementCollection
  */
 public function list_elements($object, $offset_start = 0, $quantity = 10)
 {
     switch ($object) {
         case self::ELEMENT_TYPE_VIDEO:
             $video_feed = $this->get_user_object_list_feed($object, $offset_start, $quantity);
             $element_collection = new Bridge_Api_ElementCollection();
             $element_collection->set_items_per_page($video_feed->getItemsPerPage()->getText());
             $total = $video_feed->getTotalResults()->getText();
             $current_page = floor((int) $video_feed->getStartIndex()->getText() / (int) $video_feed->getItemsPerPage()->getText()) + 1;
             $total_page = ceil((int) $total / (int) $video_feed->getItemsPerPage()->getText());
             $element_collection->set_total_items($total);
             $element_collection->set_current_page($current_page);
             $element_collection->set_total_page($total_page);
             foreach ($video_feed as $entry) {
                 $element_collection->add_element(new Bridge_Api_Youtube_Element($entry, $object));
             }
             return $element_collection;
             break;
         default:
             throw new Bridge_Exception_ElementUnknown('Unknown element ' . $object);
             break;
     }
 }
 /**
  *
  * @param  string                       $id
  * @return Bridge_Api_ElementCollection
  */
 protected function list_containers_content($object, $id, array $fields = [], $iteration = 0)
 {
     $url = sprintf("/%s/%s/videos", $object, $id);
     $result = $this->_api->call($url, ['fields' => $fields], $this->oauth_token);
     $element_collection = new Bridge_Api_ElementCollection();
     $element_collection->set_items_per_page($result["limit"]);
     $total = sizeof($result["list"]);
     $current_page = $result["page"];
     $total_page = null;
     $element_collection->set_total_items($total);
     $element_collection->set_current_page($current_page);
     $element_collection->set_total_page($total_page);
     $i = 0;
     foreach ($result["list"] as $entry) {
         $i++;
         $element_collection->add_element(new Bridge_Api_Dailymotion_Element($entry, $object));
         if ($i == $iteration) {
             break;
         }
     }
     return $element_collection;
 }
Beispiel #3
0
 /**
  *
  * @param  string                       $type
  * @param  int                          $offset_start
  * @param  int                          $quantity
  * @return Bridge_Api_ElementCollection
  */
 public function list_elements($type, $offset_start = 0, $quantity = 10)
 {
     switch ($type) {
         case self::ELEMENT_TYPE_PHOTO:
             $params = [];
             //info to display during search
             $extras = ['description', 'license', 'date_upload', 'date_taken', 'owner_name', 'last_update', 'tags', 'views', 'url_sq', 'url_t'];
             $params['user_id'] = $this->get_user_id();
             $params['extras'] = implode(",", $extras);
             if ($quantity) {
                 $params['per_page'] = $quantity;
             }
             $params['page'] = $quantity != 0 ? floor($offset_start / $quantity) + 1 : 1;
             $response = $this->_api->executeMethod('flickr.photos.search', $params);
             $photos = new Bridge_Api_ElementCollection();
             if (!$response->isOk()) {
                 throw new Bridge_Exception_ApiConnectorRequestFailed('Unable to retrieve element list ' . $type);
             }
             $xml = $response->getXml();
             $photos->set_current_page((int) $xml->photos['page'])->set_items_per_page((int) $xml->photos['perpage'])->set_total_items((int) $xml->photos['total'])->set_total_page((int) $xml->photos['pages']);
             foreach ($xml->photos->children() as $child) {
                 $photos->add_element(new Bridge_Api_Flickr_Element($child, $params['user_id'], $type));
             }
             return $photos;
             break;
         default:
             throw new Bridge_Exception_ElementUnknown('Unknown element ' . $type);
             break;
     }
 }