function plugin_recent_convert() { global $vars, $date_format, $link_compact, $page_title; // , $_recent_plugin_frame; static $exec_count = 1; global $cache; if (empty($vars['page'])) { return null; } $recent_lines = PLUGIN_RECENT_DEFAULT_LINES; $args = func_get_args(); if (!empty($args)) { if (isset($args[1]) || !is_numeric($args[0])) { return PLUGIN_RECENT_USAGE . '<br />'; } $recent_lines =& $args[0]; } if ($exec_count++ > PLUGIN_RECENT_EXEC_LIMIT) { return '<div class="alert alert-warning">#recent(): You called me too much.</div>' . "\n"; } $date = ''; $items = array(); $lines = Recent::get(); if ($lines !== null) { $count = count($lines) < $recent_lines ? count($lines) : $recent_lines; $i = 0; foreach ($lines as $page => $time) { $wiki = Factory::Wiki($page); if (!$wiki->isReadable()) { continue; } //if (! $wiki->isHidden()) continue; if ($i > $count) { break; } $s_page = Utility::htmlsc($page); $_date = get_date($date_format, $time); if (!IS_MOBILE) { if ($page === $vars['page']) { // No need to link to the page you just read, or notify where you just read $items[$_date][] = ' <li>' . $s_page . '</li>'; } else { $passage = !$link_compact ? ' ' . $wiki->passage(false, true) : ''; $items[$_date][] = ' <li><a href="' . $wiki->uri() . '" title="' . $s_page . $passage . '">' . $s_page . '</a></li>'; } } else { if ($date !== $_date) { // New day $date = $_date; $items[] = '<li data-role="list-divider">' . $date . '</li>'; } if ($page === $vars['page']) { // No need to link to the page you just read, or notify where you just read $items[] = ' <li data-theme="e">' . $s_page . '</li>'; } else { $passage = !$link_compact ? ' ' . '<span class="ui-li-count">' . $wiki->passage(false, false) . '</span>' : ''; $items[] = ' <li><a href="' . $wiki->uri() . '" data-transition="slide">' . $s_page . $passage . '</a></li>'; } } $i++; } unset($lines, $i); } $_recent_title = sprintf(T_('recent(%d)'), $count); if (!IS_MOBILE) { // End of the day $ret[] = '<div class="plugin-recent">'; $ret[] = '<h5>' . $_recent_title . '</h5>'; $ret[] = '<div class="hslice" id="webslice">'; $ret[] = '<span class="entry-title" style="display:none;">' . $page_title . '</span>'; $ret[] = '<div class="entry-content">'; $ret[] = '<ul class="list-unstyled">'; foreach ($items as $date => $entries) { $ret[] = '<li><strong>' . $date . '</strong><ul>'; foreach ($entries as $entry) { $ret[] = $entry; } $ret[] = '</ul></li>'; } $ret[] = '</ul>'; $ret[] = '</div>'; $ret[] = '</div>'; $ret[] = '</div>'; return join("\n", $ret); } else { return '<ul data-role="listview" data-dividertheme="b">' . "\n" . '<li data-theme="a">' . $_recent_title . '</li>' . "\n" . join("\n", $items) . '</ul>' . "\n"; } }
/** * Returns a list of recent changes since given timestamp. * timestamp(UTC)以降に更新されたページのリストを得る。 * @param string $timestamp 時刻 * @return array */ public function getRecentChanges($timestamp = 0) { $ret = array(); $recents = Recent::get(); if ($timestamp === 0) { return array_keys($recents); } foreach ($recents as $page => $time) { if ($time < $timestamp) { continue; } $ret[] = $page; } return $ret; }
function put_lastmodified() { //trigger_error('put_lastmodified() is deprecated. use FileUtility::get_recent(true).', E_USER_DEPRECATED ); Recent::get(true); }
function plugin_mixirss_action() { global $vars, $get, $post, $rss_max, $rss_description, $page_title, $whatsnew; global $modifier; global $exclude_plugin; global $memcache; $version = isset($vars['ver']) ? $vars['ver'] : ''; switch ($version) { case '': $version = '1.0'; break; // mixi Default // mixi Default case '1': $version = '1.0'; break; case '2': $version = '2.0'; break; case '0.91': /* FALLTHROUGH */ /* FALLTHROUGH */ case '1.0': /* FALLTHROUGH */ /* FALLTHROUGH */ case '2.0': break; default: die('Invalid RSS version!!'); } // Official Main routine ... $page_title_utf8 = mb_convert_encoding($page_title, 'UTF-8', SOURCE_ENCODING); $rss_description_utf8 = mb_convert_encoding(htmlspecialchars($rss_description), 'UTF-8', SOURCE_ENCODING); // Disable plugin $exclude_plugin[] = 'include'; $self = get_script_absuri(); change_uri('', 1); // Force absoluteURI. // Creating <item> $items = $rdf_li = ''; foreach (Recent::get() as $page => $time) { $wiki = Factory::Wiki($page); $r_page = rawurlencode($page); $url = $wiki->uri(); $title = mb_convert_encoding($page, 'UTF-8', SOURCE_ENCODING); switch ($version) { case '0.91': /* FALLTHROUGH */ /* FALLTHROUGH */ case '2.0': $date = get_date('D, d M Y H:i:s T', $time); $date = $version == '0.91' ? ' <description>' . $date . '</description>' : ' <pubDate>' . $date . '</pubDate>'; $items .= <<<EOD <item> <title>{$title}</title> <link>{$url}</link> {$date} </item> EOD; break; case '1.0': // Add <item> into <items> // $rdf_li .= ' <rdf:li rdf:resource="' . $url . '" />' . "\n"; $date = substr_replace(get_date('Y-m-d\\TH:i:sO', $time), ':', -2, 0); if (plugin_mixirss_isValidDate(substr($page, -10)) && check_readable($page, false, false)) { // for Calendar/MiniCalendar $get['page'] = $post['page'] = $vars['page'] = $page; $source = get_source($page); $rdf_hx = ''; $rdf_lx = ''; $itemhx = ''; $itemlx = ''; while (!empty($source)) { $line = array_shift($source); if (preg_match('/^(\\*{1,3})(.*)\\[#([A-Za-z][\\w-]+)\\](.*)$/m', $line, $matches)) { $anchortitle = strip_htmltag(RendererFactory::factory($matches[2])); $anchortitle = preg_replace("/[\r\n]/", ' ', $anchortitle); $anchortitle = '<![CDATA[' . mb_convert_encoding($anchortitle, 'UTF-8', SOURCE_ENCODING) . '(' . $title . ')' . ']]>'; $sharp = '#'; $rdf_hx .= ' <rdf:li rdf:resource="' . $url . $sharp . $matches[3] . '" />' . "\n"; $itemhx .= <<<EOD <item rdf:about="{$url}{$sharp}{$matches[3]}"> <title>{$anchortitle}</title> <link>{$url}{$sharp}{$matches[3]}</link> <dc:date>{$date}</dc:date> <dc:identifier>{$url}{$sharp}{$matches[3]}</dc:identifier> </item> EOD; } else { if (preg_match('/^(\\-{1,3})(.*)$/m', $line, $matches)) { $anchortitle = strip_htmltag(RendererFactory::factory($matches[2])); $anchortitle = preg_replace("/[\r\n]/", ' ', $anchortitle); $anchortitle = '<![CDATA[' . mb_convert_encoding($anchortitle, 'UTF-8', SOURCE_ENCODING) . '(' . $title . ')' . ']]>'; $sharp = '#'; $rdf_lx .= ' <rdf:li rdf:resource="' . $url . '" />' . "\n"; $itemlx .= <<<EOD <item rdf:about="{$url}"> <title>{$anchortitle}</title> <link>{$url}</link> <dc:date>{$date}</dc:date> <dc:identifier>{$url}</dc:identifier> </item> EOD; } } } if ($itemhx != '') { $rdf_li .= $rdf_hx; $items .= $itemhx; } else { if ($itemlx != '') { $rdf_li .= $rdf_lx; $items .= $itemlx; } else { // default $rdf_li .= ' <rdf:li rdf:resource="' . $url . '" />' . "\n"; $items .= <<<EOD <item rdf:about="{$url}"> <title>{$title}</title> <link>{$url}</link> {$description} <dc:date>{$date}</dc:date> <dc:identifier>{$url}</dc:identifier> </item> EOD; } } // upk 2006-03-22 // } else if (check_readable($page,false,false) && !ereg(MIXIRSS_IGNORE_REGEX, $page)) { } else { if ($wiki->isReadable()) { $get['page'] = $post['page'] = $vars['page'] = $page; //miko added $description = strip_htmltag($wiki->render()); $description = mb_strimwidth(preg_replace("/[\r\n]/", ' ', $description), 0, MIXIRSS_DESCRIPTION_LENGTH, '...'); $description = ' <description><![CDATA[' . mb_convert_encoding($description, 'UTF-8', SOURCE_ENCODING) . ']]></description>'; //miko added $rdf_li .= ' <rdf:li rdf:resource="' . $url . '" />' . "\n"; global $newtitle, $newbase; if (isset($newbase) && $newbase != '') { $anchortitle = $newtitle . ' (' . $title . ')'; $newtitle = $newbase = ''; } else { $anchortitle = $title; } $items .= <<<EOD <item rdf:about="{$url}"> <title>{$anchortitle}</title> <link>{$url}</link> {$description} <dc:date>{$date}</dc:date> <dc:identifier>{$url}</dc:identifier> </item> EOD; } } break; } } // Feeding start $html = '<?xml version="1.0" encoding="UTF-8"?>' . "\n"; $w_whatsnew = Factory::Wiki($whatsnew); $url_whatsnew = $w_whatsnew->uri(); switch ($version) { case '0.91': $html .= '<!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN"' . ' "http://my.netscape.com/publish/formats/rss-0.91.dtd">' . "\n"; /* FALLTHROUGH */ /* FALLTHROUGH */ case '2.0': $html .= <<<EOD <rss version="{$version}"> <channel> <title><![CDATA[{$page_title_utf8}]]></title> <link>{$url_whatsnew}</link> <description><![CDATA[{$rss_description_utf8}]]></description> <language>ja</language> {$items} </channel> </rss> EOD; break; case '1.0': $html .= <<<EOD <rdf:RDF xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="http://purl.org/rss/1.0/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xml:lang="ja"> <channel rdf:about="{$url_whatsnew}"> <title><![CDATA[{$page_title_utf8}]]></title> <link>{$url_whatsnew}</link> <description><![CDATA[{$rss_description_utf8}]]></description> <items> <rdf:Seq> {$rdf_li} </rdf:Seq> </items> </channel> {$items} </rdf:RDF> EOD; break; } $header = Header::getHeaders('application/xml', $w_whatsnew->time()); Header::writeResponse($header, 200, $html); exit; }