-<?
+<?php
/*
* PukiWiki ºÇ¿·¤Î?·ï¤òɽ¼¨¤¹¤ë¥×¥é¥°¥¤¥ó
*
* CopyRight 2002 Y.MASUI GPL2
* http://masui.net/pukiwiki/ masui@masui.net
- *
+ *
* Êѹ¹ÍúÎò:
* 2002.04.08: pat¤µ¤ó¡¢¤ß¤Î¤ë¤µ¤ó¤Î»ØŦ¤Ë¤è¤ê¡¢¥ê¥ó¥¯À褬ÆüËܸì¤Î¾ì¹ç¤Ë
* ²½¤±¤ë¤Î¤ò½¤Àµ
- *
+ *
* 2002.06.17: plugin_recent_init()¤òÀßÄê
+ * 2002.07.02: <ul>¤Ë¤è¤ë½ÐÎϤËÊѹ¹¤·¹½Â¤²½
+ *
+ * $Id: recent.inc.php,v 1.13 2004/09/04 14:26:52 henoheno Exp $
*/
-function plugin_recent_init()
-{
- $_plugin_recent_messages = array(
- '_recent_plugin_li'=>'¡¦',
- '_recent_plugin_frame '=>'<span align="center"><h5 class="side_label">ºÇ¿·¤Î%d·ï</h5></span><small>%s</small>');
- set_plugin_messages($_plugin_recent_messages);
-}
+// RecentChanges¤Î¥¥ã¥Ã¥·¥å
+define('PLUGIN_RECENT_CACHE', CACHE_DIR . 'recent.dat');
function plugin_recent_convert()
{
- global $_recent_plugin_li,$_recent_plugin_frame;
- global $WikiName,$BracketName,$script,$whatsnew;
-
+ global $script, $vars, $date_format;
+ global $_recent_plugin_frame;
+
+ if (! file_exists(PLUGIN_RECENT_CACHE)) return '';
+
$recent_lines = 10;
- if(func_num_args()>0) {
- $array = func_get_args();
- $recent_lines = $array[0];
+ if (func_num_args()) {
+ $args = func_get_args();
+ if (is_numeric($args[0]))
+ $recent_lines = $args[0];
}
-
- $lines = file(get_filename(encode($whatsnew)));
- $date = $items = "";
- $cnt = 0;
- foreach($lines as $line)
- {
- if($cnt > $recent_lines - 1) break;
- if(preg_match("/(($WikiName)|($BracketName))/",$line,$match))
- {
- $name = $match[1];
- if($match[2])
- {
- $title = $match[1];
- }
- else
- {
- $title = strip_bracket($match[1]);
- }
- if(preg_match("/([0-9]{4}-[0-9]{2}-[0-9]{2})/",$line,$match)) {
- if($date != $match[0]) {
- if($date != '') {
- $items .= "<br>";
- }
- $items .= "<b>".$match[0]."</b><br>";
- $date = $match[0];
- }
- }
- $items .= $_recent_plugin_li."<a href=\"".$script."?".rawurlencode($name)."\" title=\"$title ".get_pg_passage($name,false)."\">".$title."</a><BR>\n";
- $cnt++;
+
+ // ÀèƬ¤ÎN·ï(¹Ô)¤ò¼è¤ê½Ð¤¹
+ $lines = array_splice(file(PLUGIN_RECENT_CACHE), 0, $recent_lines);
+
+ $date = $items = '';
+ foreach ($lines as $line) {
+ list($time, $page) = explode("\t", rtrim($line));
+ $_date = get_date($date_format, $time);
+ if ($date != $_date) {
+ if ($date != '') $items .= '</ul>';
+ $date = $_date;
+ $items .= "<strong>$date</strong>\n" .
+ "<ul class=\"recent_list\">\n";
+ }
+ $s_page = htmlspecialchars($page);
+ $r_page = rawurlencode($page);
+ $pg_passage = get_pg_passage($page, FALSE);
+ if($page == $vars['page']) {
+ // No need to link itself, notifies where you just read
+ $items .= " <li><span title=\"$s_page $pg_passage\">$s_page</span></li>\n";
+ } else {
+ $items .= " <li><a href=\"$script?$r_page\" title=\"$s_page $pg_passage\">$s_page</a></li>\n";
}
}
- return sprintf($_recent_plugin_frame,$cnt,$items);
+ if (! empty($lines)) $items .= "</ul>\n";
+
+ return sprintf($_recent_plugin_frame, count($lines), $items);
}
?>