NP_WordCountJP
2007年1月10日
NP_WordCountJPなるプラグインを作成した。テンプレート変数として使用。
<%WordCountJP%> 記事の文字数を表示(本文と続きをあわせたもの)
<%WordCountJP(title)%> 記事のタイトルの文字数を表示
<%WordCountJP(body)%> 記事の本文の文字数を表示
<%WordCountJP(more)%> 記事の続きの部分の文字数を表示
<%WordCountJP%> 記事の文字数を表示(本文と続きをあわせたもの)
<%WordCountJP(title)%> 記事のタイトルの文字数を表示
<%WordCountJP(body)%> 記事の本文の文字数を表示
<%WordCountJP(more)%> 記事の続きの部分の文字数を表示
<?php class NP_WordCountJP extends NucleusPlugin { function getName() { return 'NP_WordCountJP'; } function getMinNucleusVersion() { return 220; } function getAuthor() { return 'Katsumi'; } function getVersion() { return '0.1'; } function getURL() {return 'http://hp.vector.co.jp/authors/VA016157/';} function getDescription() { return $this->getName().' plugin'; } function supportsFeature($what) { return (int)($what=='SqlTablePrefix'); } function doTemplateVar(&$item,$type='') { switch(strtolower($type)){ case 'title': return $this->showlen($item->title); case 'body': return $this->showlen($item->body); case 'more': return $this->showlen($item->more); default: return $this->showlen($item->body.$item->body); } } function showlen($text){ mb_language('ja'); mb_internal_encoding(_CHARSET); echo mb_strlen($text); } } ?>