Geeklogを全ての人の手に!


2012年5月19日(土) 06:42 JST

タグプラグイン-0.5.1

Geeklog -- プラグイン

昨日リリースしたタグプラグインで、バージョン0.3.2以前からアップグレードする際にエラーが発生していたバグを修正した。ご指摘いただいたひろろんさんに感謝。機能追加はなし。

タグ:タグプラグイン

トラックバック

このエントリのトラックバックURL: http://mystral-kk.net/trackback.php/20101228212120866

'タグプラグイン-0.5.1'について他のサイトでは次のように言及されています:

http://geeklog.fr/article.php/Tag-plugin-0.5.1
[...] Management System Home Forum Download Wiki Sitemap Store Tag plugin 0.5.1 ::Ben 30 décembre 2010 - 12:05 Views: 97 Mystral-kk propose une mise à jour du plugin tag. Une fois le plugin installé via l'installation automatique, [...] 続きを読む
トラックバック オン 2011年1月 3日(月) 06:26 JST

タグプラグイン-0.5.1 | 4 コメント | アカウント登録
サイト管理者はコメントに関する責任を負いません。
タグプラグイン-0.5.1
投稿者: ゲストユーザー 2011年1月 2日(日) 01:31 JST

Hey,

I have a feature request for the Tags Plugin.  I use it on a site that has a large number of tags which have been used a large number of times. The current tag cloud threshold sytem doesn't work for me since most tags are mentioned more than 10 times. I updated the function TAG_getLevel to use percentages based on the thresholds once a max value is reached. I was wondering if you could add in this code in the next release?

I added  to the config.php

$_TAG_CONF['tag_cloud_threshold_max_count'] = 20; // Uses thresholds until this number of tags is reached then a percentage system is used.

I updated the TAG_getLevel function:

function TAG_getLevel($count) {
 global $_TAG_CONF, $_TABLES;
 
 $count = intval($count);
 
 $total_tag_count = DB_getItem($_TABLES['tag_map'], 'COUNT(map_id) AS cnt', '');
 
 if ( $total_tag_count != 0 ) {
     if ($total_tag_count <= $_TAG_CONF['tag_cloud_threshold_max_count']) {
            // Old way uses thresholds based on set number of tags maybe add a switch here to use this as percentages really would not work until a few tags are in the system ?
            for ($i = 0; $i <= 9; $i ++) {
                if ($count <= $_TAG_CONF['tag_cloud_threshold'][$i]) {
                    return $i;
                }
            }
           
            return 9;
        } else {
            $percentage = intval(($count / $total_tag_count)*100);
            for ($i = 0; $i <= 9; $i ++) {
                if ($percentage <= $_TAG_CONF['tag_cloud_threshold'][$i]) {
                    return $i;
                }
            }
           
            return 9;
        }
 }
 
 return 0;
}

Thanks

Tom

タグプラグイン-0.5.1
投稿者: ゲストユーザー 2011年1月 2日(日) 02:09 JST

I just found a small bug in the Tag plugin version 0.5.1.

It deals with the function TAG_getTaggedItems. If a user doesn't have access to view the item, the function still tries to list it.  Notice the $num_row variable check when updating the template variables. Here is the fix:

function TAG_getTaggedItems($tag) {
 global $_CONF, $_TABLES, $_PLUGINS, $_TAG_CONF;
 
 $retval = '';
 
 $sql = "SELECT type, sid FROM {$_TABLES['tag_map']} "
   . "WHERE (tag_id = '" . addslashes(TAG_getTagId($tag)) . "')";
 $result = DB_query($sql);
 
 if (DB_error()) {
  return $retval;
 }
 
 $list = array();
 
 while (($A = DB_fetchArray($result)) !== FALSE) {
  $list[] = $A;
 }
 
 $T = new Template($_CONF['path'] . 'plugins/tag/templates');
 $T->set_file('item', 'tagged_item.thtml');
 
 foreach ($list as $L) {
  switch ($L['type']) {
   case 'article':
    $sql = "SELECT title, introtext, bodytext "
      . "FROM {$_TABLES['stories']} "
      . "WHERE (sid = '" . addslashes($L['sid']) . "') "
      . COM_getPermSQL('AND');
    $result = DB_query($sql);
    
    $num_rows = DB_numRows($result);
    if ($num_rows == 0) {
     continue;
    }

    $A = DB_fetchArray($result);
    $title = TAG_escape(stripslashes($A['title']));
    $body  = stripslashes($A['introtext']) . '<br>'
        . stripslashes($A['bodytext']);
    $all_tags = TAG_scanTag($body);
    $url = COM_buildURL($_CONF['site_url'] . '/article.php?story=' . $L['sid']);
    break;
   
   case 'staticpages':
    if (!in_array('staticpages', $_PLUGINS)) {
     continue;
    }
    
    $sql = "SELECT sp_title, sp_content "
      . "FROM {$_TABLES['staticpage']} "
      . "WHERE (sp_id = '" . addslashes($L['sid']) . "') "
      . COM_getPermSQL('AND');
    $result = DB_query($sql);
    
    $num_rows = DB_numRows($result);
    if ($num_rows == 0) {
     continue;
    }

    $A = DB_fetchArray($result);
    $title = TAG_escape(stripslashes($A['sp_title']));
    $content  = stripslashes($A['sp_content']);
    $all_tags = TAG_scanTag($content);
    $url = COM_buildURL($_CONF['site_url'] . '/staticpages/index.php?page=' . $L['sid']);
    break;
   
   default:
    continue;
    break;
  }
  
  if ($num_rows != 0) {
            $T->set_var('title', $title);
            $T->set_var('url', $url);
            $T->set_var('tag', TAG_escape($tag));
            $T->set_var('related', TAG_str('related'));
            $T->set_var('related_tags', TAG_formatRelatedTags($all_tags, $tag));
            $T->parse('output', 'item');
            $retval .= $T->finish($T->get_var('output'));
        }
 }
 
 return $retval;
}