/**
     * @param FieldList $fields
     */
    public function updateCMSFields(FieldList $fields)
    {
        $fields->addFieldToTab('Root.YouTube', new TextField('YouTubeFeed_AppID', 'Application ID'));
        $fields->addFieldToTab('Root.YouTube', new TextField('YouTubeFeed_AppSecret', 'Application Secret'));
        if ($this->owner->YouTubeFeed_AppID && $this->owner->YouTubeFeed_AppSecret) {
            $service = new YouTubeFeed();
            if ($service->getIsAuthenticated()) {
                //  We have a valid access token
                $fields->addFieldToTab('Root.YouTube', new LiteralField('YouTubeTabHeading', "<h2>YouTube has an active connection.</h2>"));
                $fields->addFieldToTab('Root.YouTube', new CheckboxField('YouTubeFeed_AutoUpdate', 'Automatically fetch YouTube video information'));
                if ($this->owner->YouTubeFeed_AutoUpdate) {
                    $fields->addFieldToTab('Root.YouTube', new NumericField('YouTubeFeed_UpdateInterval', 'Update interval'));
                    $fields->addFieldToTab('Root.YouTube', $updateIntervalUnitsField = new DropdownField('YouTubeFeed_UpdateIntervalUnit', '&nbsp;', singleton('SiteConfig')->dbObject('YouTubeFeed_UpdateIntervalUnit')->enumValues()));
                    $updateIntervalUnitsField->setRightTitle('This time period defines the minimum length of time between each request to YouTube to check for new or updated videos.');
                }
            } else {
                // YouTube isn't connected -- provide auth link
                $serviceURL = $service->getAuthURL();
                $fields->addFieldToTab('Root.YouTube', new LiteralField('area', '<a href="' . $serviceURL . '" name="action_AuthenticateYouTube" value="Authenticate YouTube Application" class="action ss-ui-button ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" id="Form_EditForm_action_AuthenticateYouTube" role="button" aria-disabled="false"><span class="ui-button-text">
		Authenticate YouTube Application
	</span></a>'));
            }
        }
    }
 /**
  * Force the auto update when called through CLI
  */
 public function process()
 {
     $service = new YouTubeFeed();
     $service->doAutoUpdate(true);
 }
 /**
  * Perform the auto update
  */
 public function onAfterInit()
 {
     $service = new YouTubeFeed();
     $service->doAutoUpdate();
 }
コード例 #4
0
 public function start_aggregation()
 {
     $this->log('<<<<<<<<<<<<<<<<<<<<<<<<<< start aggregation..');
     // increasing maximum execution time to 3 min for this part, it can take more time
     // than the default 30 secs for the images to be downloaded and processed by PHP/WP..
     // set_time_limit(180);
     $feed_enabled = false;
     // fetch from Facebook..
     $options = get_option('facebook_page');
     if (isset($options[$this->prefix . 'enabled'])) {
         $feed_enabled = true;
         $fb = new FacebookFeed();
         $result = $fb->getFeed($options);
         if ($this->feed_error($result)) {
             return $result['message'];
         } else {
             $this->save_feed_items($result, $this->sections[$this->prefix . 'facebook']);
         }
     }
     // fetch from Twitter..
     $options = get_option('twitter_page');
     if (isset($options[$this->prefix . 'enabled'])) {
         $feed_enabled = true;
         $tw = new TwitterFeed();
         $result = $tw->getFeed($options);
         if ($this->feed_error($result)) {
             return $result['message'];
         } else {
             $this->save_feed_items($result, $this->sections[$this->prefix . 'twitter']);
         }
     }
     // fetch from Instagram..
     $options = get_option('instagram_page');
     if (isset($options[$this->prefix . 'enabled'])) {
         $feed_enabled = true;
         $in = new InstagramFeed();
         $result = $in->getFeed($options);
         if ($this->feed_error($result)) {
             return $result['message'];
         } else {
             $this->save_feed_items($result, $this->sections[$this->prefix . 'instagram']);
         }
     }
     // fetch from YouTube..
     $options = get_option('youtube_page');
     if (isset($options[$this->prefix . 'enabled'])) {
         $feed_enabled = true;
         $yt = new YouTubeFeed();
         $result = $yt->getFeed($options);
         if ($this->feed_error($result)) {
             return $result['message'];
         } else {
             $this->save_feed_items($result, $this->sections[$this->prefix . 'youtube']);
         }
     }
     // fetch from Vimeo..
     $options = get_option('vimeo_page');
     if (isset($options[$this->prefix . 'enabled'])) {
         $feed_enabled = true;
         $vim = new VimeoFeed();
         $result = $vim->getFeed($options);
         if ($this->feed_error($result)) {
             return $result['message'];
         } else {
             $this->save_feed_items($result, $this->sections[$this->prefix . 'vimeo']);
         }
     }
     // fetch from RSS Feed..
     $options = get_option('rss_page');
     if (isset($options[$this->prefix . 'enabled'])) {
         $feed_enabled = true;
         $rss = new RssFeed();
         $result = $rss->getFeed($options);
         if ($this->feed_error($result)) {
             return $result['message'];
         } else {
             $this->save_feed_items($result, $this->sections[$this->prefix . 'rss']);
         }
     }
     $this->log('>>>>>>>>>>>>>>>>>>>>>>>>>> aggregation complete..!');
     if (!$feed_enabled) {
         return 'No social feeds are enabled. <a href="edit.php?post_type=' . $this->post_type . '&page=' . $this->settings_slug . '">Enable some feeds.</a>';
     }
 }