- 追加された行はこの色です。
- 削除された行はこの色です。
*[PATCH] popular プラグインで昨日の**件を表示したい [#v92a6f27]
-ページ: BugTrack
-投稿者: [[kak]]
-優先順位: 普通
-状態: 提案
-カテゴリー: 本体バグ
-投稿日: 2004-07-03 (土) 09:41:00
-投稿日: 2004-07-02 (金) 13:13:14
-バージョン: 1.4.3
**メッセージ [#neadf39f]
popular プラグインで通算と、今日の**件は表示できますが、昨日の**件もせっかくなので表示したいです。
ある程度はできたのですが(下)、昨日の日付を func.php の get_date 関数で得る方法がよくわかりません。.count ファイルが昨日のまま、まだ更新されていない時に必要なのです。よろしくお願いします。
--- popular.inc.php 2004-07-02 12:51:13.718625600 +0900
+++ popular.inc.php 2004-07-02 12:42:56.032988800 +0900
@@ -17,28 +17,31 @@
* #popular
* #popular(20)
* #popular(20,FrontPage|MenuBar)
- * #popular(20,FrontPage|MenuBar,true)
+ * #popular(20,FrontPage|MenuBar,today)
+ * #popular(20,FrontPage|MenuBar,yesterday)
*
* [引数]
* 1 - 表示する件数 default 10
* 2 - 表示させないページの正規表現 default なし
- * 3 - 通算(true)か今日(false)の一覧かのフラグ default false
+ * 3 - 今日(today)か昨日(yesterday)の一覧かのフラグ default、その他 通算
*/
function plugin_popular_convert()
{
- global $_popular_plugin_frame, $_popular_plugin_today_frame;
+ global $_popular_plugin_frame, $_popular_plugin_today_frame,$_popular_plugin_yesterday_frame;
global $script,$whatsnew,$non_list;
$max = 10;
$except = '';
-
+ $flag = FALSE;
+
$array = func_get_args();
$today = FALSE;
-
+
switch (func_num_args()) {
case 3:
- if ($array[2])
+ $flag = $array[2];
+ if ($flag == "today" or $flag == "yesterday")
$today = get_date('Y/m/d');
case 2:
$except = $array[1];
@@ -62,13 +65,18 @@
$today_count = rtrim($array[2]);
$yesterday_count = rtrim($array[3]);
- if ($today) {
+ if ($flag == "today") {
if ($today == $date) {
// $pageが数値に見える(たとえばencode('BBS')=424253)とき、
// array_splice()によってキー値が変更されてしまうのを防ぐ
$counters["_$page"] = $today_count;
}
}
+ else if($flag === "yesterday") {
+ if ($today == $date) {
+ $counters["_$page"] = $yesterday_count;
+ }
+ }
else {
$counters["_$page"] = $count;
}
@@ -89,7 +97,13 @@
}
$items .= '</ul>';
}
- return sprintf($today ? $_popular_plugin_today_frame : $_popular_plugin_frame,count($counters),$items);
+ if($flag == "today")
+ $frame = $_popular_plugin_today_frame;
+ else if($flag == "yesterday")
+ $frame = $_popular_plugin_yesterday_frame;
+ else
+ $frame = $_popular_plugin_frame;
+ return sprintf($frame,count($counters),$items);
}
?>
\ No newline at end of file
en.lng, ja.lng への $_popular_plugin_yesterday_frame; の追加も必要です。
***回答 [#ze0a646b]
-[[kak]] &new{2004-07-03 (SAT) 01:01:54};
~自己レスです。
$yesterday = get_date('Y/m/d',strtotime('yesterday',UTIME));
でできました。
できたのが &ref(popular.inc.php.diff); です。
こういうのは dev サイトに書くべきだったのかな?
----
-はい。ニーズと「どこを改善すべきか」、という部分が明確ですから、採用不採用とは関係なくBugTrack向きでしょう。それに、少なくとも私は[[pukiwiki:質問箱]]はあまり見ていません XD ということで、[[pukiwiki:続・質問箱/243]] から[[BugTrack/623]]に移動しましょう。 -- [[henoheno]] &new{2004-07-03 (土) 09:43:55};
#comment