<?php
/* SVN FILE: $Id: blogTag.php 281 2008-05-07 22:23:36Z bb_yujiro $ */
/**
 * ブログタグのタグクラウド表示
 *
 * PHP versions 5
 *
 *      Hitsuji : Social Network Service <http://rakuto.net/rktSNS/>
 *      Copyright (c) 2007 Yujiro Takahashi
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @filesource
 * @package         Hitsuji
 * @copyright       Copyright (c) 2007 Yujiro Takahashi
 * @link            http://rakuto.net/rktSNS/
 * @author          Yujiro Takahashi <yujiro@rakuto.net>
 * @version         $Revision: 281 $
 * @modifiedby      $LastChangedBy: bb_yujiro $
 * @lastmodified    $Date: 2008-05-08 07:23:36 +0900 (木, 08 5 2008) $
 * @license         http://opensource.org/licenses/mit-license.php The MIT License
 */

require_once LIB_DIR.'PEAR/HTML/TagCloud.php';

/**
 * ブログタグのタグクラウド表示
 *
 * @access public
 * @param integer   $ref_account
 * @return void
 **/
function hitsuji_blogTag($ref_account, $id_name='frm_blog_tag')
{
    $objdb = RKT_DB::getInstance();
    $sql = 'SELECT tag,count(tag) as num FROM '.DB_PREFIX.'blg_tag '.
           'WHERE ref_account = :ref_account GROUP BY tag';
    $stmt = $objdb->prepare($sql);
    $stmt->execute(array(':ref_account'=> $ref_account));
    $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
    if (empty($result)){
        return ;
    }
    
    $list_url = HTTP_ACTION.'member/blog/list/'.$ref_account.'/tag/';
    $baseFontSize  = 36;
    $fontSizeRange = 24;
    // Tag size range in ($baseFontSize - $fontSizeRange) to
    // ($baseFontSize + $fontSizeRange).
    $tags = new HTML_TagCloud($baseFontSize, $fontSizeRange);
    foreach ($result as $row){
        $tags->addElement($row['tag'], $list_url.urlencode($row['tag']).'/', $row['num']);
    }
    // html part only
    $taghtml = $tags->buildHTML();
?>
<?php e($taghtml); ?>
<script type="text/javascript">
YAHOO.util.Dom.setStyle("<?php e($id_name); ?>", "display", "block");
</script>
<?php
} // hitsuji_summary
?>
