Esempio n. 1
0
function fbf_facebook_messages($options)
{
    // CHECK OPTIONS
    add_filter('wp_feed_cache_transient_lifetime', create_function('$a', 'return 60;'));
    // To reduce cache time
    if ($options['pageID'] == '') {
        return __('Facebook pageID not configured', 'fbf');
    }
    if (!is_numeric($options['num']) or $options['num'] <= 0) {
        return __('Number of status not valid', 'fbf');
    }
    $link_target = $options['link_target_blank'] ? ' target="_blank" ' : '';
    // Checking Link target - Open new windo/tab or in same window
    $avatar_size = $options['avatar_size'] ? $options['avatar_size'] : 'small';
    // avatar_size
    // Fetching feed using wordpress // Credits http://digwp.com/2011/09/feed-display-multiple-columns/
    include_once ABSPATH . WPINC . '/feed.php';
    $optionID = $options['pageID'];
    // Getting Facebook Page ID
    $rss_array = explode(',', $optionID);
    $feed_link_array = "";
    foreach ($rss_array as $feed_link_id) {
        // Creating string of RSS links seperated by commas
        $feed_link_array .= ',http://www.facebook.com/feeds/page.php?id=' . $feed_link_id . '&format=rss20';
    }
    if ($feed_link_array[0] == ",") {
        $feed_link_array = substr($feed_link_array, 1, strlen($feed_link_array));
    }
    $feed_links = explode(",", $feed_link_array);
    // Array of RSS Feed links
    if (function_exists('fetch_feed')) {
        $feed = fetch_feed($feed_links);
        if (is_wp_error($feed)) {
            $error_string = $feed->get_error_message();
            $err_msg = '<div id="message" class="error">';
            $err_msg .= '<strong>Unable to fetch the feed</strong><br><span>Error :</span><ul>';
            foreach ($error_string as $err) {
                if ($err == "file_get_contents could not read the file") {
                    $error_detail = "SimplePie could not read the feed";
                } else {
                    $error_detail = $err;
                }
                $err_msg .= '<li>' . $error_detail . '</li>';
            }
            $err_msg .= '</ul>
				    </div>';
            echo $err_msg;
            // Prints the error message
        }
        if (!is_wp_error($feed)) {
            $feed->init();
            $feed->set_output_encoding('UTF-8');
            // set encoding
            $feed->handle_content_type();
            // ensure encoding
            $feed->enable_cache(false);
            // no cache
            $limit = $feed->get_item_quantity($options['num']);
            // get  feed items
            $items = $feed->get_items(0, $limit);
            // set array
        }
    }
    if ($limit == 0) {
        echo '<p><strong>RSS Feed currently unavailable.</strong></p>';
    } else {
        $returnMarkup = '';
        $returnMarkup .= '<!--- page ID ' . $optionID . ' -->';
        $returnMarkup .= '<div class="fbf_facebook_page_widget_container">	
<ul class="fbf_facebook_page_widget">';
        $blocks = array_slice($items, 0, $options['num']);
        foreach ($blocks as $block) {
            $returnMarkup .= '<li>';
            # Shows avatar of Facebook page
            $returnMarkup .= '<div class="content_header">';
            if ($options['show_avatar'] != '') {
                $returnMarkup .= "<div class=\"facebook_page-avatar\"><img src=\"http://graph.facebook.com/" . $options['pageID'] . "/picture?type=" . $avatar_size . "\"  alt=" . $block->author . " /></div>";
            }
            if ($options['feed_title'] == "true") {
                $feedtitle = "<h4><a href=" . $block->get_permalink() . " class='facebook_page-link' " . $link_target . ">" . substr($block->get_title(), 0, 200) . "</a></h4>";
                // Title of the update
            } elseif ($options['feed_title'] == "") {
                $feedtitle = null;
            }
            $returnMarkup .= html_entity_decode($feedtitle, ENT_COMPAT, 'UTF-8');
            if ($options['update'] != '') {
                $time = strtotime($block->get_date("j F Y, H:i:s"));
                $tval = timesince($time);
                $h_time = abs(time() - $time) < 86400 ? sprintf(__('%s ago', 'rstw'), human_time_diff($time)) : date(__('Y/m/d'), $time);
                $returnMarkup .= '' . sprintf(__('%s', 'rstw'), ' <span class="facebook_page-timestamp"><abbr title="' . $block->get_date("j F Y, H:i:s") . '">' . timesince($time) . '</abbr></span>');
            }
            //  Show Timestamp - if option enabled
            # Shows fb like button on bottom, below the feed description
            if ($options['like_button'] != '' && $options['like_button'] != false) {
                if ($options['like_button_position'] == "bottom") {
                    $returnMarkup .= $like_button;
                }
            }
            $returnMarkup .= '</div>';
            # Like button
            $like_button = '<iframe src="http://www.facebook.com/plugins/like.php?href=' . $block->get_permalink() . '&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=30" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100%; height:30px;" allowTransparency="true"></iframe>';
            if ($options['show_description'] != '') {
                $desc_feed = str_replace('href="http://www.facebook.com', 'href="', $block->get_description());
                // Emptying all links
                $desc = html_entity_decode(str_replace('href="', 'href="http://www.facebook.com', $desc_feed), ENT_COMPAT, 'UTF-8');
                // adding facebook link - to avoid facebook redirector l.php's broken link error
                $returnMarkup .= "<div class=\"fbf_desc\">" . $desc . "</div>";
                // Full content
            }
            # Shows fb like button on top, below the feed title
            if ($options['like_button'] != '' && $options['like_button'] != false) {
                if ($options['like_button_position'] == "top") {
                    $returnMarkup .= '<div class="like_btn">' . $like_button . '</div>';
                }
            }
            $returnMarkup .= '</li>';
        }
        // For Loop Ends here
        $returnMarkup .= '</ul>
		</div>';
    }
    return $returnMarkup;
}
Esempio n. 2
0
function SB_comment($param)
{
    $comments = Typecho_Widget::widget('Widget_Comments_Recent', 'ignoreAuthor=true&pageSize=' . (empty($param["max"]) ? "5" : $param["max"]));
    if (!$comments->have()) {
        return '';
    }
    $text = '<aside class="widget widget_minty_recentcomments clearfix"><h3 class="widget-title"><span>近期评论</span></h3><ul id="minty_recentcomments">';
    while ($comments->next()) {
        $url = !empty($comments->url) ? $comments->url : "#";
        $text .= "<li><a href=\"" . $url . "\" target=\"_blank\" rel=\"external nofollow\" class=\"avatar\"><img alt=\"\" src=\"" . getAvatar(32, $comments->mail) . "\" class=\"avatar\" height=\"32\" width=\"32\" /></a><div class=\"bd\"><a href=\"" . $url . "\" rel=\"external nofollow\" class=\"url\">" . $comments->author . "</a><a href=\"" . $comments->permalink . "\" class=\"desc\" title=\"发表在 " . timesince($comments->created) . "\">" . Typecho_Common::subStr(strip_tags($comments->text), 0, 25, '...') . "</a></div></li>";
    }
    return $text . '</ul></aside>';
}
 $graph[$i] .= '<div class="optionsHeader" rel="twitter_' . $id . '"><span>' . $tweets . ' ' . JText::_('JM_TWEETS_AND_RETWEETS') . '</span><div id="toggler_twitter_' . $id . '" class="optionsHeader_r" onclick="toggleSlider(\'twitter_' . $id . '\', \'toggler_twitter_' . $id . '\')"></div></div>';
 $graph[$i] .= '<div class="optionsContent" id="twitter_' . $id . '">';
 if ($tweets) {
     foreach ($twitter['twitter']['statuses'] as $status) {
         $graph[$i] .= '<div class="tweet">';
         $graph[$i] .= '<div class="twitterStatus">';
         if ($status['is_retweet']) {
             $graph[$i] .= '<img style="position:relative;top:3px;" src="' . JURI::root() . 'administrator/components/com_joomailermailchimpintegration/assets/images/retweet.png" /> ';
         }
         $graph[$i] .= twitterit($status['status'], $status['screen_name']);
         $graph[$i] .= '</div>';
         $graph[$i] .= '<span class="twitterInfo">';
         $graph[$i] .= '<a href="http://twitter.com/' . $status['screen_name'] . '" target="_blank" style="text-decoration:none!important;">';
         $graph[$i] .= $status['screen_name'] . '</a> | ';
         //	$graph[$i] .= $status['datetime'];
         $graph[$i] .= timesince(strtotime($status['datetime']), substr($status['datetime'], 0, -3));
         $graph[$i] .= '<span style="float:right;">';
         $graph[$i] .= '<a href="http://twitter.com/home?status=' . urlencode($status['status']) . '" target="_blank">' . JText::_('JM_RETWEET') . '</a>';
         $graph[$i] .= ' | ';
         $graph[$i] .= '<a href="http://twitter.com/home?status=@' . $status['screen_name'] . '+" target="_blank">' . JText::_('JM_REPLY') . '</a>';
         $graph[$i] .= '<span style="clear:both;"</span>';
         $graph[$i] .= '</span>';
         $graph[$i] .= '</span>';
         $graph[$i] .= '</div>';
     }
 }
 $graph[$i] .= '</div>';
 $graph[$i] .= '</div>';
 // geo stats
 $countries = $row['geo'];
 $graph[$i] .= '<div class="countrystats">';
Esempio n. 4
0
function threadedComments($comments, $singleCommentOptions)
{
    global $smilies_from, $smilies_to;
    ?>
<li class="comment depth-<?php 
    echo $comments->levels + 1;
    if ($comments->authorId == $comments->ownerId) {
        echo " bypostauthor";
    }
    ?>
" id="<?php 
    $comments->theId();
    ?>
">
	<div id="div-<?php 
    $comments->theId();
    ?>
" class="comment-body">
		<div class="comment-author vcard"><?php 
    if ($comments->levels == 0) {
        ?>
			<img alt="" src="<?php 
        echo getAvatar(50, $comments->mail);
        ?>
" class="avatar" height="50" width="50" /><?php 
    } else {
        ?>
      <img alt="" src="<?php 
        echo getAvatar(30, $comments->mail);
        ?>
" class="avatar" height="30" width="30" /><?php 
    }
    ?>
      <cite class="fn"><?php 
    echo empty($comments->url) ? htmlspecialchars($comments->author) : "<a href=\"" . $comments->url . "\" rel=\"external nofollow\" class=\"url\" target=\"_blank\">" . htmlspecialchars($comments->author) . "</a>";
    ?>
</cite>
      <time><?php 
    echo timesince($comments->created);
    ?>
</time>
    </div>
    <div class="comment-content"><?php 
    $output = "";
    // HTML loop taken from texturize function, could possible be consolidated
    $textarr = preg_split("/(<.*>)/U", Typecho_Common::stripTags($comments->text, "<br><a href=\"\">"), -1, PREG_SPLIT_DELIM_CAPTURE);
    $stop = count($textarr);
    for ($i = 0; $i < $stop; $i++) {
        $content = $textarr[$i];
        if (strlen($content) > 0 && '<' != $content[0]) {
            $content = str_replace($smilies_from, $smilies_to, $content);
        }
        $output .= $content;
    }
    echo $output;
    ?>
</div>
    <footer class="comment-footer">
    	<?php 
    $comments->reply("回复");
    ?>
    	<a href="#" class="com-at" data-name="@<?php 
    echo htmlspecialchars($comments->author);
    ?>
" data-id="#<?php 
    $comments->theId();
    ?>
">@TA</a>
    </footer>
  </div>
  <?php 
    if ($comments->children) {
        ?>
<ol class="children"><?php 
        $comments->threadedComments($singleCommentOptions);
        ?>
</ol><?php 
    }
    ?>
</li><?php 
}