2 // PukiWiki - Yet another WikiWikiWeb clone
5 // 2003-2017 PukiWiki Development Team
6 // 2002 Kazunori Mizushima <kazunori@uc.netyou.jp>
7 // License: WHERE IS THE RECORD?
9 // Popular pages plugin: Show an access ranking of this wiki
10 // -- like recent plugin, using counter plugin's count --
14 * 通算および今日に別けて一覧を作ることができます。
19 * #popular(20,FrontPage|MenuBar)
20 * #popular(20,FrontPage|MenuBar,true)
23 * 1 - 表示する件数 default 10
24 * 2 - 表示させないページの正規表現 default なし
25 * 3 - 通算(true)か今日(false)の一覧かのフラグ default false
28 define('PLUGIN_POPULAR_DEFAULT', 10);
30 require_once(PLUGIN_DIR . 'counter.inc.php');
32 function plugin_popular_convert()
35 global $_popular_plugin_frame, $_popular_plugin_today_frame;
37 $max = PLUGIN_POPULAR_DEFAULT;
40 $array = func_get_args();
42 $today_param = $array[2];
43 switch (func_num_args()) {
44 case 3: if ($today_param && $today_param !== 'false') $today = get_date('Y/m/d');
45 case 2: $except = $array[1];
46 case 1: $max = (int)$array[0];
48 $counters = plugin_counter_get_popular_list($today, $except, $max);
51 if (! empty($counters)) {
52 $items = '<ul class="popular_list">' . "\n";
54 foreach ($counters as $page=>$count) {
55 $page = substr($page, 1);
57 $s_page = htmlsc($page);
58 if ($page === $vars['page']) {
59 // No need to link itself, notifies where you just read
60 $attrs = get_page_link_a_attrs($page);
61 $items .= ' <li><span class="' .
62 $attrs['class'] . '" data-mtime="' . $attrs['data_mtime'] .
63 '">' . $s_page . '<span class="counter">(' . $count .
64 ')</span></span></li>' . "\n";
66 $items .= ' <li>' . make_pagelink($page,
67 $s_page . '<span class="counter">(' . $count . ')</span>') .
71 $items .= '</ul>' . "\n";
74 return sprintf($today ? $_popular_plugin_today_frame : $_popular_plugin_frame, count($counters), $items);