/** * get slides from posts */ public function getSlidesFromStream($publishedOnly = false) { $slideTemplates = $this->getSlidesFromGallery($publishedOnly); $slideTemplates = RevSliderFunctions::assocToArray($slideTemplates); if (count($slideTemplates) == 0) { return array(); } $arrPosts = array(); $max_allowed = 999999; $sourceType = $this->getParam("source_type", "gallery"); $additions = array('fb_type' => 'album'); switch ($sourceType) { case "facebook": $facebook = new RevSliderFacebook($this->getParam('facebook-transient', '1200')); if ($this->getParam('facebook-type-source', 'timeline') == "album") { $arrPosts = $facebook->get_photo_set_photos($this->getParam('facebook-album'), $this->getParam('facebook-count', 10), $this->getParam('facebook-app-id'), $this->getParam('facebook-app-secret')); } else { $user_id = $facebook->get_user_from_url($this->getParam('facebook-page-url')); $arrPosts = $facebook->get_photo_feed($user_id, $this->getParam('facebook-app-id'), $this->getParam('facebook-app-secret'), $this->getParam('facebook-count', 10)); $additions['fb_type'] = $this->getParam('facebook-type-source', 'timeline'); $additions['fb_user_id'] = $user_id; } if (!empty($arrPosts)) { foreach ($arrPosts as $k => $p) { if (!isset($p->status_type)) { continue; } if (in_array($p->status_type, array("wall_post"))) { unset($arrPosts[$k]); } } } $max_posts = $this->getParam('facebook-count', '25', self::FORCE_NUMERIC); $max_allowed = 25; break; case "twitter": $twitter = new RevSliderTwitter($this->getParam('twitter-consumer-key'), $this->getParam('twitter-consumer-secret'), $this->getParam('twitter-access-token'), $this->getParam('twitter-access-secret'), $this->getParam('twitter-transient', '1200')); $arrPosts = $twitter->get_public_photos($this->getParam('twitter-user-id'), $this->getParam('twitter-include-retweets'), $this->getParam('twitter-exclude-replies'), $this->getParam('twitter-count'), $this->getParam('twitter-image-only')); $max_posts = $this->getParam('twitter-count', '500', self::FORCE_NUMERIC); $max_allowed = 500; $additions['twitter_user'] = $this->getParam('twitter-user-id'); break; case "instagram": $instagram = new RevSliderInstagram($this->getParam('instagram-access-token'), $this->getParam('instagram-transient', '1200')); $search_user_id = $this->getParam('instagram-user-id'); $arrPosts = $instagram->get_public_photos($search_user_id, $this->getParam('instagram-count')); $max_posts = $this->getParam('instagram-count', '33', self::FORCE_NUMERIC); $max_allowed = 33; break; case "flickr": $flickr = new RevSliderFlickr($this->getParam('flickr-api-key'), $this->getParam('flickr-transient', '1200')); switch ($this->getParam('flickr-type')) { case 'publicphotos': $user_id = $flickr->get_user_from_url($this->getParam('flickr-user-url')); $arrPosts = $flickr->get_public_photos($user_id, $this->getParam('flickr-count')); break; case 'gallery': $gallery_id = $flickr->get_gallery_from_url($this->getParam('flickr-gallery-url')); $arrPosts = $flickr->get_gallery_photos($gallery_id, $this->getParam('flickr-count')); break; case 'group': $group_id = $flickr->get_group_from_url($this->getParam('flickr-group-url')); $arrPosts = $flickr->get_group_photos($group_id, $this->getParam('flickr-count')); break; case 'photosets': $arrPosts = $flickr->get_photo_set_photos($this->getParam('flickr-photoset'), $this->getParam('flickr-count')); break; } $max_posts = $this->getParam('flickr-count', '99', self::FORCE_NUMERIC); break; case 'youtube': $channel_id = $this->getParam('youtube-channel-id'); $youtube = new RevSliderYoutube($this->getParam('youtube-api'), $channel_id, $this->getParam('youtube-transient', '1200')); if ($this->getParam('youtube-type-source') == "playlist") { $arrPosts = $youtube->show_playlist_videos($this->getParam('youtube-playlist'), $this->getParam('youtube-count')); } else { $arrPosts = $youtube->show_channel_videos($this->getParam('youtube-count')); } $additions['yt_type'] = $this->getParam('youtube-type-source', 'channel'); $max_posts = $this->getParam('youtube-count', '25', self::FORCE_NUMERIC); $max_allowed = 50; break; case 'vimeo': $vimeo = new RevSliderVimeo($this->getParam('vimeo-transient', '1200')); $vimeo_type = $this->getParam('vimeo-type-source'); switch ($vimeo_type) { case 'user': $arrPosts = $vimeo->get_vimeo_videos($vimeo_type, $this->getParam('vimeo-username')); break; case 'channel': $arrPosts = $vimeo->get_vimeo_videos($vimeo_type, $this->getParam('vimeo-channelname')); break; case 'group': $arrPosts = $vimeo->get_vimeo_videos($vimeo_type, $this->getParam('vimeo-groupname')); break; case 'album': $arrPosts = $vimeo->get_vimeo_videos($vimeo_type, $this->getParam('vimeo-albumid')); break; default: break; } $additions['vim_type'] = $this->getParam('vimeo-type-source', 'user'); $max_posts = $this->getParam('vimeo-count', '25', self::FORCE_NUMERIC); $max_allowed = 60; break; default: RevSliderFunctions::throwError("getSlidesFromStream error: This source type must be from stream."); break; } if ($max_posts < 0) { $max_posts *= -1; } $arrPosts = apply_filters('revslider_pre_mod_stream_data', $arrPosts, $sourceType, $this->id); while (count($arrPosts) > $max_posts || count($arrPosts) > $max_allowed) { array_pop($arrPosts); } $arrPosts = apply_filters('revslider_post_mod_stream_data', $arrPosts, $sourceType, $this->id); $arrSlides = array(); $templateKey = 0; $numTemplates = count($slideTemplates); if (empty($arrPosts)) { RevSliderFunctions::throwError(__('Failed to load Stream', REVSLIDER_TEXTDOMAIN)); } foreach ($arrPosts as $postData) { $slideTemplate = $slideTemplates[$templateKey]; //advance the templates $templateKey++; if ($templateKey == $numTemplates) { $templateKey = 0; } $slide = new RevSlide(); $slide->initByStreamData($postData, $slideTemplate, $this->id, $sourceType, $additions); $arrSlides[] = $slide; } $this->arrSlides = $arrSlides; return $arrSlides; }