php-5.1.0RC1を用いてPukiWikiを運用すると、newプラグインにおいて「New!」表示の対象であってもそのように表示されません。
php-5.0.5では「New!」表示が出ます。
&new{2005-11-02 12:03:50 (水)}; <- php-5.1.0b1のcomment pluginの入力結果 &new{2005-11-02 (水) 12:03:50}; <- php-5.1.0RC1のcomment pluginの入力結果
Index: new.inc.php =================================================================== RCS file: /cvsroot/pukiwiki/pukiwiki/plugin/new.inc.php,v retrieving revision 1.9 diff -u -r1.9 new.inc.php --- new.inc.php 16 Jun 2005 15:04:08 -0000 1.9 +++ new.inc.php 5 Nov 2005 14:34:15 -0000 @@ -34,8 +34,12 @@ // Show 'New!' message by the time of the $date string if (func_num_args() > 2) return '&new([nodate]){date};'; - $timestamp = strtotime($date); - if ($timestamp === -1) return '&new([nodate]){date}: Invalid date string;'; + $timestamp = strtotime(preg_replace('/\([^\x00-\x7F]+\)/','',$date)); + if(version_compare(phpversion(),'5.1')<0){ + if ($timestamp === -1) return '&new([nodate]){date}: Invalid date string;'; + }else{ + if ($timestamp === FALSE) return '&new([nodate]){date}: Invalid date string;'; + } $timestamp -= ZONETIME; $retval = in_array('nodate', $args) ? '' : htmlspecialchars($date);
- strtotime()が非ASCII文字を厳密に扱うようになった(?) - エラーの戻り値の変更によりエラーハンドリングができていないという2つの問題があったわけですね。とりあえず上記修正にて「New!」表示されるようになりました(RC4で確認)。 -- よっちい 2005-11-07 (月) 09:45:51
--- new.inc.php.orig Tue Nov 8 09:17:37 2005 +++ new.inc.php Tue Nov 8 09:19:47 2005 @@ -34,8 +34,12 @@ // Show 'New!' message by the time of the $date string if (func_num_args() > 2) return '&new([nodate]){date};'; - $timestamp = strtotime($date); - if ($timestamp === -1) return '&new([nodate]){date}: Invalid date string;'; + if(LANG == 'ja'){ + $timestamp = strtotime(preg_replace('/\([^\x00-\x7f]+\)/','',$date)); + } else { + $timestamp = strtotime($date); + } + if ($timestamp === -1 || $timestamp === FALSE) return '&new([nodate]){date}: Invalid date string;'; $timestamp -= ZONETIME; $retval = in_array('nodate', $args) ? '' : htmlspecialchars($date);してみました。 -- よっちい 2005-11-08 (火) 12:54:07
--- new.inc.php.orig Fri Jun 17 00:04:08 2005 +++ new.inc.php Fri Nov 3 16:41:26 2006 @@ -24,7 +24,7 @@ function plugin_new_inline() { - global $vars, $_plugin_new_elapses; + global $vars, $_plugin_new_elapses, $weeklabels; $retval = ''; $args = func_get_args(); @@ -34,8 +34,8 @@ // Show 'New!' message by the time of the $date string if (func_num_args() > 2) return '&new([nodate]){date};'; - $timestamp = strtotime($date); - if ($timestamp === -1) return '&new([nodate]){date}: Invalid date string;'; + $timestamp = strtotime(str_replace($weeklabels,'',$date)); + if ($timestamp === -1 || $timestamp === FALSE) return '&new([nodate]){date}: Invalid date string;'; $timestamp -= ZONETIME; $retval = in_array('nodate', $args) ? '' : htmlspecialchars($date);言語に依存しない書き方ができそうですが、カッコ()が残るのでこれでも動作しません。lngファイルをいじれば
--- ja.lng.php.orig Tue Apr 11 02:36:56 2006 +++ ja.lng.php Fri Nov 3 15:01:08 2006 @@ -52,7 +52,7 @@ $_msg_symbol = '記号'; $_msg_other = '日本語'; $_msg_help = 'テキスト整形のルールを表示する'; -$_msg_week = array('日','月','火','水','木','金','土'); +$_msg_week = array('日','月','火','水','木','金','土','(',')'); $_msg_content_back_to_top = '<div class="jumpmenu"><a href="#navigator">↑</a></div>'; $_msg_word = 'これらのキーワードがハイライトされています:';イケそうですが、ちょっとイマイチ感があります。 -- よっちい 2006-11-03 (金) 16:45:44
$_date = str_replace($weeklabels, '', $date); $_date = str_replace('()', '', $_date); $timestamp = strtotime($_date);
$date_format = 'Y年m月d日';のように設定して、&new{2008年03月21日 (金) 19:00:00}; として使っている場合はダメなんですよね・・・ -- 2008-03-21 (金) 19:06:21
if (preg_match('/^\D*(\d{4})\D+(\d{1,2})\D+(\d{1,2})\D+(\d{1,2}:\d{2}:\d{2})\D*$/', $date, $dm)) { $iso8601_date = $dm[1] . '-' . substr('0' . $dm[2], -2) . '-' . substr('0' . $dm[3], -2) . ' ' . $dm[4]; $timestamp = strtotime($iso8601_date); }