Ejemplo n.º 1
0
 /**
  * Returns the hot tags in order of hotness in a given forum or all hot tags
  *
  * @since 1.0
  * @return integer|object The tag data when successfully executed or an IXR_Error object on failure
  * @param array $args Arguments passed by the XML-RPC call
  * @param string $args[0] The username for authentication
  * @param string $args[1] The password for authentication
  * @param integer $args[2] The number of tags to return (optional)
  * @param integer|string $args[3] The forum id or slug (optional)
  *
  * XML-RPC request to get the 20 hottest tags in the forum with slug "hawtness"
  * <methodCall>
  *     <methodName>bb.getTopicTags</methodName>
  *     <params>
  *         <param><value><string>joeblow</string></value></param>
  *         <param><value><string>123password</string></value></param>
  *         <param><value><int>20</int></value></param>
  *         <param><value><string>hawtness</string></value></param>
  *     </params>
  * </methodCall>
  */
 function bb_getHotTopicTags($args)
 {
     do_action('bb_xmlrpc_call', 'bb.getHotTopicTags');
     // Escape args
     $this->escape($args);
     // Get the login credentials
     $username = $args[0];
     $password = (string) $args[1];
     // Check the user is valid
     if ($this->auth_readonly) {
         $user = $this->authenticate($username, $password);
     }
     do_action('bb_xmlrpc_call_authenticated', 'bb.getHotTopicTags');
     // If an error was raised by authentication or by an action then return it
     if ($this->error) {
         return $this->error;
     }
     // Must be a number
     $per_page = isset($args[2]) ? (int) $args[2] : false;
     // Can be numeric id or slug
     $forum_id = isset($args[3]) ? $args[3] : false;
     if ($forum_id) {
         // Check for bad data
         if (!is_string($forum_id) && !is_integer($forum_id)) {
             $this->error = new IXR_Error(400, __('The forum id is invalid.'));
             return $this->error;
         }
         // Check the requested forum exists
         if (!($forum = bb_get_forum($forum_id))) {
             $this->error = new IXR_Error(404, __('No forum found.'));
             return $this->error;
         }
         global $bbdb;
         $topic_ids = $bbdb->get_col($bbdb->prepare("SELECT topic_id FROM `" . $bbdb->topics . "` WHERE `topic_status` = 0 AND `topic_open` = 1 AND `tag_count` > 0 AND `forum_id` = %s;", $forum_id));
         if (!count($topic_ids)) {
             $this->error = new IXR_Error(400, __('No topics found.'));
             return $this->error;
         }
         global $nxt_taxonomy_object;
         $tags = $nxt_taxonomy_object->get_object_terms($topic_ids, 'bb_topic_tag', array('fields' => 'all_with_object_id', 'orderby' => 'count', 'order' => 'DESC'));
         if (!$tags || is_nxt_error($tags)) {
             $this->error = new IXR_Error(500, __('Could not retrieve hot topic tags.'));
             return $this->error;
         }
         if (!count($tags)) {
             $this->error = new IXR_Error(500, __('No hot topic tags found.'));
             return $this->error;
         }
         global $bb_log;
         $bb_log->debug($tags);
         for ($i = 0; isset($tags[$i]); $i++) {
             _bb_make_tag_compat($tags[$i]);
         }
         $bb_log->debug($tags);
         // Only include "safe" data in the array
         $_tags = array();
         foreach ($tags as $tag) {
             $_tag = $this->prepare_topic_tag($tag);
             if (!in_array($_tag, $_tags)) {
                 $_tags[] = $_tag;
             }
         }
         if ($per_page) {
             $_tags = array_slice($_tags, 0, $per_page);
         }
     } else {
         if (!($tags = bb_get_top_tags(array('get' => 'all', 'number' => $per_page)))) {
             $this->error = new IXR_Error(500, __('No hot topic tags found.'));
             return $this->error;
         }
         // Only include "safe" data in the array
         $_tags = array();
         foreach ($tags as $tag) {
             $_tags[] = $this->prepare_topic_tag($tag);
         }
     }
     do_action('bb_xmlrpc_call', 'bb.getHotTopicTags');
     return $_tags;
 }
function bb_tag_heat_map($args = '')
{
    $defaults = array('smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'limit' => 40, 'format' => 'flat');
    $args = wp_parse_args($args, $defaults);
    if (1 < ($fn = func_num_args())) {
        // For back compat
        $args['smallest'] = func_get_arg(0);
        $args['largest'] = func_get_arg(1);
        $args['unit'] = 2 < $fn ? func_get_arg(2) : $unit;
        $args['limit'] = 3 < $fn ? func_get_arg(3) : $limit;
    }
    extract($args, EXTR_SKIP);
    $tags = bb_get_top_tags(array('number' => $limit));
    if (empty($tags)) {
        return;
    }
    $r = bb_get_tag_heat_map($tags, $args);
    echo apply_filters('tag_heat_map', $r, $args);
}
Ejemplo n.º 3
0
 function get_top_tags($recent = true, $limit = 40)
 {
     bb_log_deprecated('function', __FUNCTION__, 'bb_get_top_tags');
     return bb_get_top_tags(array('number' => $limit));
 }
Ejemplo n.º 4
0
			</div>
		</div>
		
		<div class="sidebar">
			<ul>
				<li id="page-info">
					<h2><?php 
_e('Page Information', 'guangzhou');
?>
</h2>
					<p><?php 
_e('This is a collection of <strong>tags</strong> that are currently popular on the forums.', 'guangzhou');
?>
</p>
					<?php 
$tags = bb_get_top_tags();
?>
					
					<p><?php 
printf(__('There are <strong>%d tags</strong> in total.', 'guangzhou'), count($tags));
?>
</p>
				</li>
				<li>
					<?php 
do_action('gz_place_sidebar');
?>
				</li>
			</ul>
		</div>
		<?php