?>
				    </div> <?php 
        });
        $columns['social_column_summary'] = array('title' => 'Summary', 'callback' => function (&$message) {
            ?>
 <div class="twitter_message_summary"> <a href="#"><?php 
            echo $message['twitter_message']->get_summary();
            ?>
</a>
						    </div> <?php 
        });
        $columns['social_column_action'] = array('title' => 'Action', 'callback' => function (&$message) {
            if (module_social::can_i('view', 'Twitter Comments', 'Social', 'social')) {
                ?>
				        <a href="<?php 
                echo module_social_twitter::link_open_twitter_message($message['social_twitter_id'], $message['social_twitter_message_id']);
                ?>
" class="socialtwitter_message_open social_modal btn btn-default btn-xs" data-modal-title="<?php 
                echo _l('Tweet');
                ?>
"><?php 
                _e('Open');
                ?>
</a>

			        <?php 
            }
            ?>
			        <?php 
            if (module_social::can_i('edit', 'Twitter Comments', 'Social', 'social')) {
                ?>
Exemple #2
0
    public function output_block($level)
    {
        if (!$this->get('social_twitter_message_id') || $level < -3) {
            return;
        }
        $twitter_data = @json_decode($this->get('data'), true);
        // any previous messages?
        if ($level <= 0) {
            if ($this->get('reply_to_id')) {
                // this tweet is a reply to a previous tweet!
                ?>
				<div class="twitter_previous_messages">
					<?php 
                $reply_message = new ucm_twitter_message($this->twitter_account, $this->get('reply_to_id'));
                $reply_message->output_block($level - 1);
                ?>
				</div>
				<?php 
            } else {
                if ($this->get('type') == _TWITTER_MESSAGE_TYPE_DIRECT) {
                    // find previous message(s)
                    $from = preg_replace('#[^0-9]#', '', $this->get('twitter_from_id'));
                    $to = preg_replace('#[^0-9]#', '', $this->get('twitter_to_id'));
                    if ($from && $to) {
                        $sql = "SELECT * FROM `" . _DB_PREFIX . "social_twitter_message` WHERE `type` = " . _TWITTER_MESSAGE_TYPE_DIRECT . " AND message_time <= " . (int) $this->get('message_time') . " AND social_twitter_message_id != " . (int) $this->social_twitter_message_id . " AND ( (`twitter_from_id` = {$from} AND `twitter_to_id` = {$to}) OR (`twitter_from_id` = {$to} AND `twitter_to_id` = {$from}) ) ORDER BY `message_time` DESC LIMIT 1";
                        $previous = qa1($sql);
                        if ($previous && $previous['social_twitter_message_id']) {
                            ?>
						<div class="twitter_previous_messages twitter_direct">
							<?php 
                            $reply_message = new ucm_twitter_message($this->twitter_account, $previous['social_twitter_message_id']);
                            $reply_message->output_block($level - 1);
                            ?>
						</div>
						<?php 
                        }
                    }
                }
            }
        }
        $message_from = isset($twitter_data['user']) ? $twitter_data['user'] : (isset($twitter_data['sender']) ? $twitter_data['sender'] : false);
        if ($this->get('summary')) {
            if ($message_from && $this->get('type') != _TWITTER_MESSAGE_TYPE_DIRECT) {
                $message_from['tweet_id'] = isset($twitter_data['id_str']) ? $twitter_data['id_str'] : false;
            }
            //echo '<pre>'; print_r($twitter_data); echo '</pre>';
            ?>
			<div class="twitter_comment <?php 
            echo $level != 0 ? ' twitter_comment_clickable' : 'twitter_comment_current';
            ?>
" data-id="<?php 
            echo $this->social_twitter_message_id;
            ?>
" data-link="<?php 
            echo module_social_twitter::link_open_twitter_message($this->get('social_twitter_id'), $this->social_twitter_message_id);
            ?>
" data-title="<?php 
            echo _l('Tweet');
            ?>
">
				<div class="twitter_comment_picture">
					<?php 
            if (isset($twitter_data['user']['id_str'])) {
                $pic = array('screen_name' => isset($twitter_data['user']['screen_name']) ? $twitter_data['user']['screen_name'] : '', 'image' => isset($twitter_data['user']['profile_image_url_https']) ? $twitter_data['user']['profile_image_url_https'] : '');
            } else {
                if (isset($twitter_data['sender']['id_str'])) {
                    $pic = array('screen_name' => isset($twitter_data['sender']['screen_name']) ? $twitter_data['sender']['screen_name'] : '', 'image' => isset($twitter_data['sender']['profile_image_url_https']) ? $twitter_data['sender']['profile_image_url_https'] : '');
                } else {
                    $pic = false;
                }
            }
            if ($pic) {
                ?>
						<img src="<?php 
                echo $pic['image'];
                ?>
">
						<?php 
            }
            ?>
				</div>
				<div class="twitter_comment_header">
					<?php 
            _e('From:');
            echo ' ';
            echo $message_from ? ucm_twitter::format_person($message_from) : 'N/A';
            ?>
					<span><?php 
            $time = strtotime($this->get('message_time'));
            echo $time ? ' @ ' . print_date($time, true) : '';
            if ($this->get('user_id')) {
                echo ' (sent by ' . module_user::link_open($this->get('user_id'), true) . ')';
            }
            ?>
					</span>
				</div>
				<div class="twitter_comment_body">
					<?php 
            if (isset($twitter_data['entities']['media']) && is_array($twitter_data['entities']['media'])) {
                foreach ($twitter_data['entities']['media'] as $media) {
                    if ($media['type'] == 'photo') {
                        ?>
								<div class="twitter_picture">
									<?php 
                        if (isset($media['url']) && $media['url']) {
                            ?>
 <a
										href="<?php 
                            echo htmlspecialchars($media['url']);
                            ?>
"
										target="_blank"> <?php 
                        }
                        ?>
										<img src="<?php 
                        echo htmlspecialchars($media['media_url_https']);
                        ?>
">
										<?php 
                        if (isset($media['url']) && $media['url']) {
                            ?>
 </a> <?php 
                        }
                        ?>
								</div>
							<?php 
                    }
                }
            }
            ?>
					<div>
						<?php 
            echo forum_text($this->get('summary'));
            ?>
					</div>
					<div class="twitter_comment_stats">
						<?php 
            $data = @json_decode($this->get('data'), true);
            //print_r($data);
            if ($data && (isset($data['retweet_count']) && $data['retweet_count'] > 0 || isset($data['favorite_count']) && $data['favorite_count'] > 0)) {
                if (isset($data['retweet_count']) && $data['retweet_count'] > 0) {
                    echo _l('Retweets: %s', $data['retweet_count']);
                }
                echo ' ';
                if (isset($data['favorite_count']) && $data['favorite_count'] > 0) {
                    echo _l('Favorites: %s', $data['favorite_count']);
                }
            }
            ?>
					</div>
				</div>
				<div class="twitter_comment_actions">
					<?php 
            if ($this->can_reply) {
                ?>
						<a href="#" class="twitter_reply_button"><?php 
                _e('Reply');
                ?>
</a>
					<?php 
            }
            ?>
				</div>
			</div>
		<?php 
        }
        ?>
		<?php 
        if ($level == 0) {
            ?>
			<div class="twitter_comment_replies">
			<?php 
            //if(strpos($twitter_data['message'],'picture')){
            //echo '<pre>'; print_r($twitter_data); echo '</pre>';
            //}
            if ($this->can_reply) {
                $this->reply_box($level, $message_from);
            }
            ?>
			</div>
		<?php 
        }
        if ($level >= 0) {
            // any follow up messages?
            if ($this->get('type') == _TWITTER_MESSAGE_TYPE_DIRECT) {
                $from = preg_replace('#[^0-9]#', '', $this->get('twitter_from_id'));
                $to = preg_replace('#[^0-9]#', '', $this->get('twitter_to_id'));
                if ($from && $to) {
                    $sql = "SELECT * FROM `" . _DB_PREFIX . "social_twitter_message` WHERE `type` = " . _TWITTER_MESSAGE_TYPE_DIRECT . " AND message_time >= " . (int) $this->get('message_time') . " AND social_twitter_message_id != " . (int) $this->social_twitter_message_id . " AND ( (`twitter_from_id` = {$from} AND `twitter_to_id` = {$to}) OR (`twitter_from_id` = {$to} AND `twitter_to_id` = {$from}) ) ORDER BY `message_time` ASC LIMIT 1";
                    $next = qa1($sql);
                    if ($next && $next['social_twitter_message_id']) {
                        ?>
						<div class="twitter_next_messages twitter_direct">
							<?php 
                        $reply_message = new ucm_twitter_message($this->twitter_account, $next['social_twitter_message_id']);
                        $reply_message->output_block($level + 1);
                        ?>
						</div>
						<?php 
                    }
                }
            } else {
                $next = get_multiple('social_twitter_message', array('social_twitter_id' => $this->twitter_account->get('social_twitter_id'), 'reply_to_id' => $this->social_twitter_message_id), 'social_twitter_message_id');
                if ($next) {
                    foreach ($next as $n) {
                        // this tweet is a reply to a previous tweet!
                        if ($n['social_twitter_message_id']) {
                            ?>
							<div class="twitter_next_messages">
								<?php 
                            $reply_message = new ucm_twitter_message($this->twitter_account, $n['social_twitter_message_id']);
                            $reply_message->output_block($level + 1);
                            ?>
							</div>
							<?php 
                        }
                    }
                }
            }
        }
    }
        ?>
">
				<td class="row_action">
					<img src="<?php 
        echo _BASE_HREF;
        ?>
includes/plugin_social_twitter/images/twitter-logo.png"
					     class="twitter_icon">
					<?php 
        echo htmlspecialchars($twitter_account->get('account_name'));
        ?>
					<br/>
				</td>
				<td>
					<a href="<?php 
        echo module_social_twitter::link_open_twitter_message($account['social_twitter_id'], false);
        ?>
" class="socialtwitter_message_open social_modal btn btn-success btn-sm" data-modal-title="<?php 
        echo _l('Compose Tweet');
        ?>
"><?php 
        _e('Compose Tweet');
        ?>
</a>
				</td>
			</tr>
		<?php 
    }
}
?>
  </tbody>