最近の投稿を画像サムネイル付きにしてみたかったんで、AiDaNews2っちゅうextentionを試してみました。

しかーし、 たまぁに、タイトルや、本文の抜粋が出来ずに空白になることがあるみたいでんな。下の絵では「AiDaNewsを試してみる」の記事本文の抜粋が表示されてませんやろ。
そんなんになりますねん。

最初は、よーわかりまへんでしたけど、よーくよくコードを眺めてましたら、ありましたが・・・大穴が
AiDaNews2の抜粋時のコードは、
mod_aidanews2_17_2.0.8/helper.php
- function shorten($txt, $cut, $type, $end){
- if ($cut > 0) {
- if ($type){
- $cut += 5;
- if (function_exists('mb_substr')) {
- $txt = mb_substr($txt, 0, $cut, 'UTF-8');
- $txt = mb_substr($txt, 0, mb_strrpos($txt," "), 'UTF-8');
- }else{
- $txt = substr($txt, 0, $cut);
- $txt = substr($txt, 0, strrpos($txt," "));
- }
- $txt .= $end;
- }else{
- $array = explode(" ", $txt);
- if (count($array)<= $cut) {
- //Do nothing
- }else{
- array_splice($array, $cut);
- $txt = implode(" ", $array) . $end;
- }
- }
- }
- $txt = str_replace('"', '"', $txt);
- return $txt;
- }
-
とかなってて、一見キチンとマルチバイト処理が行われているように思ってましたが・・・
よーくみると、189と192行目が、かなり怪しく、要するに半角スペースが無いと・・・ありゃりゃでんな。
まあ、とりあえずは抜粋を切りたいところで半角スペースを入れるっちゅうことで対処ができるけど・・・
気に入らないんで該当部分を以下の様に変えちまうことに・・・。さらに半角スペースで切られるのが嫌っちゅうお方は190と195行目をコメントアウトするとよろし。
mod_aidanews2_17_2.0.8/helper.php Edit
- function shorten($txt, $cut, $type, $end){
- if ($cut > 0) {
- if ($type){
- $cut += 5;
- if (function_exists('mb_substr')) {
- $txt = mb_substr($txt, 0, $cut, 'UTF-8');
- if ($space_pos = mb_strrpos($txt," ")){
- $txt = mb_substr($txt, 0, $space_pos, 'UTF-8');
- }
- }else{
- $txt = substr($txt, 0, $cut);
- if ($space_pos = strrpos($txt," ")){
- $txt = substr($txt, 0, $space_pos);
- }
- }
-
- $txt .= $end;
- }else{
- $array = explode(" ", $txt);
- if (count($array)<= $cut) {
- //Do nothing
- }else{
- array_splice($array, $cut);
- $txt = implode(" ", $array) . $end;
- }
- }
- }
- $txt = str_replace('"', '"', $txt);
- return $txt;
- }
-
おそるおそる、本家のフォーラムに報告をば、してみます。