Esempio n. 1
0
function getTagCloud ( $where = null, $min_size = 80, $max_size = 160, $max_entry = null, $offset = null, $params=array() )
{
	$wh = "";
	$ret = "";
	$tags = array();
	$max_qty = 0;
	$min_qty = 0;

	$db = & $this->d3dConf->db;

	$max_entry = !empty($max_entry) ? (int)$max_entry : 30 ;
	$offset = !empty($offset) ?(int)$offset : 0;
	//$odr = !empty($order) ? $order : "tag_name ASC";
	$odr = !empty($params['order']) ? $params['order'] : "tag_name ASC";
	$ofst_key = !empty($params['ofst_key']) ? $params['ofst_key'] : "tofst";

	if($where){
		$wh = " WHERE ". $where;
	}
	
	$sql = "SELECT tag_name AS tag, COUNT(tag_id) AS quantity
	  FROM ". $db->prefix($this->mydirname ."_tag") .$wh. "
	  GROUP BY tag_name
	  ORDER BY ".$odr;

	//$count = $db->getRowsNum( $db->query($sql) );
	$result = $db->query($sql);
	// here we loop through the results and put them into a simple array
	while ($row = $db->fetchRow($result)) {
	    $tags[$row['0']] = $row[1];
	}
	$count  = count($tags);

	if( $max_entry==0 ) {
		$tagnavi = "";
	} else {
		if( $count>$max_entry ){
	            if( !empty($_SERVER['QUERY_STRING'])) {
	                if( preg_match("/^".$ofst_key."=[0-9]+/", $_SERVER['QUERY_STRING']) ) {
	                    $url = "";
	                } else {
	                    $url = preg_replace("/^(.*)\&".$ofst_key."=[0-9]+/", "$1", $_SERVER['QUERY_STRING']);
	                }
	            } else {
	                $url = "";
	            }
		    include_once dirname(__FILE__).'/d3diaryPagenavi.class.php';
	            $nav = new d3diaryPageNav($count, $max_entry, $offset, $ofst_key, $url);
	            $tagnavi = $nav->renderNav();
	        } else {
	            $tagnavi = "";
		}
	}

	// get the largest and smallest array values
	if($tags){
		$max_qty = max(array_values($tags));
		$min_qty = min(array_values($tags));
	}

	// find the range of values
	$spread = $max_qty - $min_qty;
	if (0 == $spread) { // we don't want to divide by zero
	    $spread = 1;
	}

	// determine the font-size increment
	$step = ($max_size - $min_size)/($spread);

	// loop through our tag array
	$arr_keys = array_keys($tags);
	$arr_values = array_values($tags);
	$last_idx = ($count < $max_entry) ? $count : $max_entry ;
	for ( $i=0; $i < $last_idx; $i++ ) {
		$idx = $i+$offset;
		$size = $min_size + (($arr_values[$idx] - $min_qty) * $step);
		$ret[$i]['tag'] = $this->myts->makeTboxData4Show($arr_keys[$idx]);
		$ret[$i]['tag_urlenc'] = rawurlencode($arr_keys[$idx]);
		$ret[$i]['size'] = $size;
	}

	return array( $ret, $tagnavi ) ;
}
Esempio n. 2
0
 }
 // query limit
 $whr_offset = " LIMIT " . $offset2 . "," . $max_entry2;
 // using d3diaryPageNav
 if ($num_rows > $max_entry) {
     if (!empty($_SERVER['QUERY_STRING'])) {
         if (preg_match("/^pofst=[0-9]+/", $_SERVER['QUERY_STRING'])) {
             $url = "";
         } else {
             $url = preg_replace("/^(.*)\\&pofst=[0-9]+/", "\$1", $_SERVER['QUERY_STRING']);
         }
     } else {
         $url = "";
     }
     include_once dirname(dirname(__FILE__)) . '/class/d3diaryPagenavi.class.php';
     $nav = new d3diaryPageNav($num_rows, $max_entry, $offset, "pofst", $url);
     $yd_pagenavi = $nav->getNav();
 } else {
     $yd_pagenavi = "";
 }
 // *********** SQL for actual entry
 // get entries on selected offset
 $sql = "SELECT d.diary, d.create_time, d.cid, d.title, d.bid, d.openarea AS openarea, d.dohtml, \n\t\t\td.view, d.vgids AS vgids, d.vpids AS vpids, u.uid, u.uname, u.name, u.user_avatar, \n\t\t\tc.cid, c.cname, c.openarea AS openarea_cat, c.showoption , c.vgids AS vgids_cat, c.vpids AS vpids_cat \n\t\t\tFROM " . $xoopsDB->prefix($mydirname . '_diary') . " d \n\t\t\tINNER JOIN " . $xoopsDB->prefix('users') . " u USING(uid) \n\t\t\tLEFT JOIN " . $xoopsDB->prefix($mydirname . '_category') . " c ON ((c.uid=d.uid or c.uid='0') and d.cid=c.cid) \n\t\t\tLEFT JOIN " . $xoopsDB->prefix($mydirname . '_config') . " cfg ON d.uid=cfg.uid " . $sql_tag . $where_ser_bids . " ORDER BY " . $odr;
 $result = $xoopsDB->query($sql);
 // flag for using d3comment
 if (!empty($mod_config['comment_dirname']) && intval($mod_config['comment_forum_id']) > 0) {
     $yd_param['use_d3comment'] = true;
 } else {
     $yd_param['use_d3comment'] = false;
 }
 $charmax = (int) $mod_config['preview_charmax'];