2 // PukiWiki - Yet another WikiWikiWeb clone
3 // $Id: popular.inc.php,v 1.14 2005/04/09 03:18:06 henoheno Exp $
5 // Popular pages plugin: Show an access ranking of this wiki
6 // -- like recent plugin, using counter plugin's count --
9 * (C) 2003-2005 PukiWiki Developers Team
10 * (C) 2002 Kazunori Mizushima <kazunori@uc.netyou.jp>
12 * ÄÌ»»¤ª¤è¤Óº£Æü¤ËÊ̤±¤Æ°ìÍ÷¤òºî¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£
17 * #popular(20,FrontPage|MenuBar)
18 * #popular(20,FrontPage|MenuBar,true)
21 * 1 - ɽ¼¨¤¹¤ë·ï¿ô default 10
22 * 2 - ɽ¼¨¤µ¤»¤Ê¤¤¥Ú¡¼¥¸¤ÎÀµµ¬É½¸½ default ¤Ê¤·
23 * 3 - ÄÌ»»(true)¤«º£Æü(false)¤Î°ìÍ÷¤«¤Î¥Õ¥é¥° default false
26 define('PLUGIN_POPULAR_DEFAULT', 10);
28 function plugin_popular_convert()
30 global $vars, $whatsnew, $non_list;
31 global $_popular_plugin_frame, $_popular_plugin_today_frame;
33 $max = PLUGIN_POPULAR_DEFAULT;
36 $array = func_get_args();
38 switch (func_num_args()) {
39 case 3: if ($array[2]) $today = get_date('Y/m/d');
40 case 2: $except = $array[1];
41 case 1: $max = $array[0];
44 $non_list_pattern = '/' . $non_list . '/';
46 foreach (get_existpages(COUNTER_DIR, '.count') as $file=>$page) {
47 if (($except != '' && ereg($except, $page)) ||
48 $page == $whatsnew || preg_match($non_list_pattern, $page) ||
52 $array = file(COUNTER_DIR . $file);
53 $count = rtrim($array[0]);
54 $date = rtrim($array[1]);
55 $today_count = rtrim($array[2]);
58 // $page¤¬¿ôÃͤ˸«¤¨¤ë(¤¿¤È¤¨¤Ðencode('BBS')=424253)¤È¤¡¢
59 // array_splice()¤Ë¤è¤Ã¤Æ¥¡¼Ãͤ¬Êѹ¹¤µ¤ì¤Æ¤·¤Þ¤¦¤Î¤òËɤ°
60 // ¤¿¤á¡¢¥¡¼¤Ë '_' ¤òÏ¢·ë¤¹¤ë
61 if ($today == $date) $counters['_' . $page] = $today_count;
63 $counters['_' . $page] = $count;
67 asort($counters, SORT_NUMERIC);
68 $counters = array_splice(array_reverse($counters, TRUE), 0, $max);
71 if (! empty($counters)) {
72 $items = '<ul class="popular_list">' . "\n";
74 foreach ($counters as $page=>$count) {
75 $page = substr($page, 1);
77 $s_page = htmlspecialchars($page);
78 if ($page == $vars['page']) {
79 // No need to link itself, notifies where you just read
80 $pg_passage = get_pg_passage($page,FALSE);
81 $items .= ' <li><span title="' . $s_page . ' ' . $pg_passage . '">' .
82 $s_page . '<span class="counter">(' . $count .
83 ')</span></span></li>' . "\n";
85 $items .= ' <li>' . make_pagelink($page,
86 $s_page . '<span class="counter">(' . $count . ')</span>') .
90 $items .= '</ul>' . "\n";
93 return sprintf($today ? $_popular_plugin_today_frame : $_popular_plugin_frame, count($counters), $items);