示例#1
0
 public static function ajaxForceUpdateSocialStream()
 {
     self::$logger->log("ajaxForceUpdateSocialStream.", __LINE__);
     $timestamp = time();
     $msg_limit = get_option('fbss_setting_msg_limit', 20);
     update_option('fbss_setting_last_data_update', $timestamp);
     $social_stream = new FBSS_SocialStream();
     $social_stream->store($msg_limit, array(), true);
     $stream_update_timestamp = FBSS_TemplateStringUtils::getLocalTimestamp($timestamp);
     $stream_update_date_format = __('Y-m-d h:i:s a', 'wp-fb-social-stream');
     $stream_update_date = date($stream_update_date_format, $stream_update_timestamp);
     echo $stream_update_date;
     wp_die();
     // as described in codex: this is required to terminate immediately
 }
示例#2
0
            ?>
						<div class="fb-message-video-name"><?php 
            echo esc_html($view_data['video_name']);
            ?>
</div>
						<?php 
        }
        ?>
						
						<?php 
        if (isset($view_data['video_description'])) {
            ?>
						<div class="fb-message-video-desc">
							<?php 
            $view_data['video_description'] = esc_html($view_data['video_description']);
            echo FBSS_TemplateStringUtils::createMessageHTML($view_data['video_description']);
            ?>
						</div>
					</div>
					<div class="clearer"></div>
					<?php 
        }
        ?>
				</div>
				<?php 
    }
    ?>
			</div>
			<!-- /.fb-message-video -->
			<?php 
}
示例#3
0
 private function getStreamInfoHTML()
 {
     $this->logger->log("getStreamInfoHTML.", __LINE__);
     $timestamp = get_option('fbss_setting_last_data_update');
     $stream_update_timestamp = FBSS_TemplateStringUtils::getLocalTimestamp($timestamp);
     /* translators: date format, see http://php.net/date */
     $stream_update_date_format = __('Y-m-d h:i:s a', 'wp-fb-social-stream');
     $stream_update_date = date($stream_update_date_format, $stream_update_timestamp);
     $view_data = array('stream_update_date' => $stream_update_date);
     $html = $this->view->render('admin/stream-info', $view_data);
     return $html;
 }
示例#4
0
 public function get($limit = 20, $posts_filter = array())
 {
     $page_name = $this->page_name;
     $this->logger->log("Get '{$limit}' social stream posts from page " . "'{$page_name}'.", __LINE__);
     $extensions = $this->extensions;
     $messages = $this->db->getByType('message', $limit, $posts_filter);
     $social_stream_data = array();
     $social_stream_msg_html = array();
     $i = 1;
     $view_data = array('page_name' => $page_name, 'extensions' => $extensions, 'msg_limit' => $limit);
     foreach ($messages as $msg) {
         $msg_id = $msg->id;
         $msg_obj_id = $msg->object_id;
         $msg_data_json = $msg->data;
         $msg_data_obj = json_decode($msg_data_json);
         $view_data['i'] = $i;
         $view_data['obj_id'] = $msg_obj_id;
         if ($i == $limit) {
             $view_data['is_last_msg'] = true;
         } else {
             $view_data['is_last_msg'] = false;
         }
         $this->logger->log("Processing message '{$i}' with id '{$msg_id}' and " . "object_id '{$msg_obj_id}'.", __LINE__);
         #$this->logger->log("Message: ".print_r($messages, true), __LINE__);
         $msg_type = $msg_data_obj->type;
         $view_data['type'] = $msg_type;
         $view_data['status_type'] = $msg_data_obj->status_type;
         $view_data['fb_share_link'] = $this->getShareLinkFromJSON($msg_obj_id, $msg_data_obj, $msg_type);
         if (property_exists($msg_data_obj, 'message')) {
             $view_data['msg_text'] = $msg_data_obj->message;
         } else {
             $view_data['msg_text'] = '';
         }
         $msg_date_timestamp = strtotime($msg_data_obj->created_time);
         $msg_date_timestamp_local = FBSS_TemplateStringUtils::getLocalTimestamp($msg_date_timestamp);
         $view_data['msg_date_iso_8601'] = date('Y-m-d', $msg_date_timestamp_local);
         $msg_date_month = date('F', $msg_date_timestamp_local);
         $msg_date_month_translated = __($msg_date_month);
         /* translators: date format, see http://php.net/date */
         $date_format = __('jS \\of %\\s Y h:i A', 'wp-fb-social-stream');
         $view_data['msg_date_string'] = sprintf(date($date_format, $msg_date_timestamp_local), $msg_date_month_translated);
         # read likes and comments
         $view_data['fb_num_likes'] = 0;
         $view_data['fb_num_comments'] = 0;
         if (property_exists($msg_data_obj, 'likes')) {
             $view_data['fb_num_likes'] = $msg_data_obj->likes->summary->total_count;
         }
         if (property_exists($msg_data_obj, 'comments')) {
             $view_data['fb_num_comments'] = $msg_data_obj->comments->summary->total_count;
         }
         if ($msg_type == 'photo') {
             if (property_exists($msg_data_obj, 'object_id')) {
                 $img_id = $msg_data_obj->object_id;
                 $image = $this->db->get($img_id, 'image');
                 $this->logger->log("Processing image with id '{$img_id}'.", __LINE__);
                 #$this->logger->log("Image: ".print_r($image, true), __LINE__);
                 if ($image && property_exists($image, 'data')) {
                     $img_data_obj = json_decode($image->data);
                     $img_src = htmlspecialchars($img_data_obj->source);
                     $img_src_thumb = htmlspecialchars($img_data_obj->picture);
                     $img_widht = $img_data_obj->width;
                     $img_height = $img_data_obj->height;
                     $msg_data_obj->fbss_picture_src = $img_src;
                     $msg_data_obj->fbss_picture_width = $img_widht;
                     $msg_data_obj->fbss_picture_height = $img_height;
                     $view_data['img_src'] = $img_src;
                 }
             }
         } else {
             if ($msg_type == 'link') {
                 if (property_exists($msg_data_obj, 'link')) {
                     $view_data['link_src'] = $msg_data_obj->link;
                 }
                 if (property_exists($msg_data_obj, 'picture')) {
                     $view_data['link_img_src'] = $msg_data_obj->picture;
                 }
                 if (property_exists($msg_data_obj, 'name')) {
                     $view_data['link_name'] = $msg_data_obj->name;
                 }
                 if (property_exists($msg_data_obj, 'caption')) {
                     $view_data['link_caption'] = $msg_data_obj->caption;
                 }
                 if (property_exists($msg_data_obj, 'description')) {
                     $view_data['link_description'] = $msg_data_obj->description;
                     if (strlen($view_data['link_description']) > 120) {
                         $view_data['link_description'] = substr($view_data['link_description'], 0, 120) . "...";
                     }
                 }
             } else {
                 if ($msg_type == 'event') {
                     if (property_exists($msg_data_obj, 'link')) {
                         $view_data['event_src'] = $msg_data_obj->link;
                     }
                     if (property_exists($msg_data_obj, 'picture')) {
                         $view_data['event_img_src'] = $msg_data_obj->picture;
                     }
                     if (property_exists($msg_data_obj, 'name')) {
                         $view_data['event_name'] = $msg_data_obj->name;
                     }
                     if (property_exists($msg_data_obj, 'description')) {
                         $view_data['event_description'] = $msg_data_obj->description;
                         if (strlen($view_data['event_description']) > 120) {
                             $view_data['event_description'] = substr($view_data['event_description'], 0, 120) . "...";
                         }
                     }
                     if (property_exists($msg_data_obj, 'object_id')) {
                         $event_id = $msg_data_obj->object_id;
                         $event = $this->db->get($event_id, 'event');
                         $this->logger->log("Processing event with id '{$event_id}'.", __LINE__);
                         if ($event && property_exists($event, 'data')) {
                             $event_data_obj = json_decode($event->data);
                             $event_start_timestamp = strtotime($event_data_obj->start_time);
                             $event_start_timestamp_local = FBSS_TemplateStringUtils::getLocalTimestamp($event_start_timestamp);
                             $event_start_month = date('F', $event_start_timestamp_local);
                             $event_start_month_translated = __($event_start_month);
                             $view_data['event_start_date_string'] = sprintf(date($date_format, $event_start_timestamp_local), $event_start_month_translated);
                         }
                     }
                 } else {
                     if ($msg_type == 'video') {
                         $view_data['video_src'] = $msg_data_obj->source;
                         $view_data['video_img_src'] = $msg_data_obj->picture;
                         if (property_exists($msg_data_obj, 'name')) {
                             $view_data['video_name'] = $msg_data_obj->name;
                         }
                         if (property_exists($msg_data_obj, 'description')) {
                             $view_data['video_description'] = $msg_data_obj->description;
                         }
                     }
                 }
             }
         }
         $msg_html = $this->view->render('message', $view_data);
         array_push($social_stream_msg_html, $msg_html);
         array_push($social_stream_data, $msg_data_obj);
         $i++;
     }
     $html = $this->view->render('wrapper', array('social_stream_html' => join('', $social_stream_msg_html), 'extensions' => $extensions));
     if (get_option('fbss_setting_output_type', 'html') == 'json') {
         $json_view = new FBSS_View();
         // new object: use default view dir
         $json = $json_view->render('stream_json_wrapper', array('json' => json_encode($social_stream_data)));
         return array('html' => $json, 'num_messages' => count($messages));
     }
     return array('html' => $html, 'num_messages' => count($messages));
 }