示例#1
0
文件: cache.php 项目: flyysr/emlog
 /**
  * 文章标签缓存
  */
 private function mc_logtags()
 {
     $tag_model = new Tag_Model();
     $newlog = $this->readCache("newlog");
     $log_cache_tags = array();
     foreach ($newlog as $each) {
         $gid = $each['gid'];
         $tag_ids = $tag_model->getTagIdsFromBlogId($gid);
         $tag_names = $tag_model->getNamesFromIds($tag_ids);
         $tags = array();
         foreach ($tag_names as $key => $value) {
             $tag = array();
             $tag['tagurl'] = rawurlencode($value);
             $tag['tagname'] = htmlspecialchars($value);
             $tag['tid'] = intval($key);
             $tags[] = $tag;
         }
         $log_cache_tags[$gid] = $tags;
     }
     $cacheData = serialize($log_cache_tags);
     $this->cacheWrite($cacheData, 'logtags');
 }
示例#2
0
文件: module.php 项目: flyysr/emlog
function blog_tag($blogid)
{
    global $CACHE;
    $tag_model = new Tag_Model();
    $log_cache_tags = $CACHE->readCache('logtags');
    if (!empty($log_cache_tags[$blogid])) {
        $tag = '标签:';
        foreach ($log_cache_tags[$blogid] as $value) {
            $tag .= "\t<a href=\"" . Url::tag($value['tagurl']) . "\">" . $value['tagname'] . '</a>';
        }
        echo $tag;
    } else {
        $tag_ids = $tag_model->getTagIdsFromBlogId($blogid);
        $tag_names = $tag_model->getNamesFromIds($tag_ids);
        if (!empty($tag_names)) {
            $tag = '标签:';
            foreach ($tag_names as $key => $value) {
                $tag .= "\t<a href=\"" . Url::tag(rawurlencode($value)) . "\">" . htmlspecialchars($value) . '</a>';
            }
            echo $tag;
        }
    }
}