本文整理汇总了PHP中WikiPage::mtime方法的典型用法代码示例。如果您正苦于以下问题:PHP WikiPage::mtime方法的具体用法?PHP WikiPage::mtime怎么用?PHP WikiPage::mtime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WikiPage
的用法示例。
在下文中一共展示了WikiPage::mtime方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: do_sitemap
function do_sitemap($formatter, $options)
{
global $DBInfo;
# get page list
if ($formater->group) {
$group_pages = $DBInfo->getLikePages($formater->group);
foreach ($group_pages as $page) {
$all_pages[] = str_replace($formatter->group, '', $page);
}
} else {
$all_pages = $DBInfo->getPageLists();
}
usort($all_pages, 'strcasecmp');
$items = '';
// empty string
# process page list
$zone = '+00:00';
foreach ($all_pages as $page) {
$url = qualifiedUrl($formatter->link_url(_rawurlencode($page)));
$p = new WikiPage($page);
$t = $p->mtime();
$date = gmdate("Y-m-d\\TH:i:s", $t) . $zone;
// W3C datetime format
$item = "<url>\n";
$item .= " <loc>" . $url . "</loc>\n";
$item .= " <lastmod>" . $date . "</lastmod>\n";
$item .= "</url>\n";
$items .= $item;
}
# process output
$out = $items;
if ($options['oe'] and strtolower($options['oe']) != $DBInfo->charset) {
$charset = $options['oe'];
if (function_exists('iconv')) {
$new = iconv($DBInfo->charset, $charset, $items);
if (!$new) {
$charset = $DBInfo->charset;
}
if ($new) {
$out = $new;
}
}
} else {
$charset = $DBInfo->charset;
}
$head = <<<HEAD
<?xml version="1.0" encoding="{$charset}"?>
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9"
url="http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
HEAD;
$foot = <<<FOOT
</urlset>
FOOT;
# output
header("Content-Type: text/xml");
print $head . $out . $foot;
}
示例2: macro_BBS
//.........这里部分代码省略.........
# add some basic rule/repl for bts
$rule = "/-{4}(?:" . $boundary . ")?\nComment-Id:\\s*(\\d+)\n" . "From:\\s*([^\n]+)\nDate:\\s*([^\n]+)\n\n/im";
$repl = "----\n'''Comment-Id:''' [#c\\1][#c\\1 #\\1] by \\2 on [[DateTime(\\3)]] [reply \\1]\n\n";
$body = preg_replace($rule, $repl, $body);
$formatter->quote_style = 'bbs-comment';
$options['usemeta'] = 1;
#
$q_save = $formatter->self_query;
$query = '?no=' . $nid . '&p=' . $options['p'];
$formatter->self_query = $query;
$save = $formatter->preview;
$formatter->preview = 1;
$save_markup = $formatter->format;
ob_start();
if ($conf['default_markup']) {
$formatter->pi['#format'] = $conf['default_markup'];
}
$formatter->send_page($body, $options);
$body = ob_get_contents();
ob_end_clean();
$formatter->pi['#format'] = $save_markup;
$formatter->self_query = $q_save;
$msg .= "<div class='bbsArticle'>" . '<div class="head"><h2>' . _("No") . ' ' . $nid . ': ' . $metas['Subject'] . '</h2></div>' . '<div class="body">' . '<div class="extra"> @ ' . $metas['Date'] . ' (' . _mask_hostname($metas['IP'], 3) . ')</div>' . '<div class="user"><h3>' . $metas['Name'] . '</h3></div>' . '<div class="article">' . $body . "</div>\n</div>\n" . '<div class="foot"><div></div></div>' . "</div>\n";
$snid = $nid;
$btn['edit'] = $formatter->link_tag($bpage, "?action=bbs&mode=edit&no=" . $nid, '<span>' . _("Edit") . '</span>', 'class="button"');
$btn['delete'] = $formatter->link_tag($bpage, "?action=bbs&mode=delete&no=" . $nid, '<span>' . _("Delete") . '</span>', 'class="button"');
if ($narticle == 1 and $conf['use_comment']) {
$opts['action'] = 'bbs';
$opts['no'] = $nid;
$opts['p'] = $options['p'];
$opts['mode'] = 'comment';
$opts['nopreview'] = 1;
$p = new WikiPage($bname . ':' . $opts['no'], $options);
$opts['datestamp'] = $p->mtime();
$comment = $formatter->macro_repl('Comment', 'usemeta', $opts);
unset($opts['no']);
# XXX
}
$msg .= '<div class="bbsComment">' . $comment . '</div><div class="bbsArticleBtn">' . implode(" ", $btn) . '</div>';
unset($btn['delete']);
unset($btn['edit']);
$title = str_replace('"', '\\"', $metas['Subject']);
$js .= <<<JS
<script type="text/javascript">
/*<![CDATA[*/
document.title+=" [" + {$snid} + "] - " + "{$title}";
/*]]>*/
</script>
JS;
}
}
if (!empty($msg) and !$_GET['p']) {
return $msg;
}
if (1) {
# XXX
$nochk = _("Please check article numbers.");
$js .= <<<JS
<script type='text/javascript'>
/*<![CDATA[*/
function send_list(obj,mode) {
var tmp="";
var i, chk=false;
form=obj.parentNode.parentNode;
示例3: macro_PageList
function macro_PageList($formatter, $arg = "", $options = array())
{
global $DBInfo;
$offset = '';
if (!is_numeric($options['offset']) or $options['offset'] <= 0) {
unset($options['offet']);
} else {
$offset = $options['offset'];
}
preg_match("/([^,]*)(\\s*,\\s*)?(.*)?\$/", $arg, $match);
if ($match[1] == 'date') {
$options['date'] = 1;
$arg = '';
} else {
if ($match) {
$arg = $match[1];
$opts = array();
if ($match[3]) {
$opts = explode(",", $match[3]);
}
if (in_array('date', $opts)) {
$options['date'] = 1;
}
if (in_array('dir', $opts)) {
$options['dir'] = 1;
}
if (in_array('subdir', $opts)) {
$options['subdir'] = 1;
}
if (in_array('info', $opts)) {
$options['info'] = 1;
} else {
if ($arg and (in_array('metawiki', $opts) or in_array('m', $opts))) {
$options['metawiki'] = 1;
}
}
}
}
$upper = '';
if (!empty($options['subdir'])) {
if (($p = strrpos($formatter->page->name, '/')) !== false) {
$upper = substr($formatter->page->name, 0, $p);
}
$needle = _preg_search_escape($formatter->page->name);
$needle = '^' . $needle . '\\/';
} else {
if (!empty($options['rawre'])) {
$needle = $arg;
} else {
$needle = _preg_search_escape($arg);
}
}
$test = @preg_match("/{$needle}/", "", $match);
if ($test === false) {
# show error message
return "[[PageList(<font color='red'>Invalid \"{$arg}\"</font>)]]";
}
$ret = array();
$options['ret'] =& $ret;
$options['offset'] = $offset;
if (!empty($options['date'])) {
$tz_offset =& $formatter->tz_offset;
$all_pages = $DBInfo->getPageLists($options);
} else {
if (!empty($options['metawiki'])) {
$all_pages = $DBInfo->metadb->getLikePages($needle);
} else {
$all_pages = $DBInfo->getLikePages($needle);
}
}
$hits = array();
$out = '';
if (!empty($options['date']) and !is_numeric($k = key($all_pages)) and is_numeric($all_pages[$k])) {
if ($needle) {
while (list($pagename, $mtime) = @each($all_pages)) {
preg_match("/{$needle}/", $pagename, $matches);
if ($matches) {
$hits[$pagename] = $mtime;
}
}
} else {
$hits = $all_pages;
}
arsort($hits);
while (list($pagename, $mtime) = @each($hits)) {
$out .= '<li>' . $formatter->link_tag(_rawurlencode($pagename), "", _html_escape($pagename)) . ". . . . [" . gmdate("Y-m-d", $mtime + $tz_offset) . "]</li>\n";
}
$out = "<ol>\n" . $out . "</ol>\n";
} else {
foreach ($all_pages as $page) {
preg_match("/{$needle}/", $page, $matches);
if ($matches) {
$hits[] = $page;
}
}
sort($hits);
if (!empty($options['dir']) or !empty($options['subdir'])) {
$dirs = array();
$files = array();
if ($options['subdir']) {
//.........这里部分代码省略.........
示例4: ajax_RecentChanges
/**
* get updated info
*
*/
function ajax_RecentChanges($formatter, $options = array())
{
global $DBInfo;
// list style
if (!empty($options['type']) and $options['type'] == 'list') {
$options['call'] = 1;
$options['ajax'] = 1;
$opt = '';
if (isset($options['datefmt'])) {
$opt .= $options['datefmt'] . ',';
}
$opt .= 'list';
if (!empty($options['item'])) {
$opt .= ',item=' . $options['item'];
}
$out = macro_RecentChanges($formatter, $opt, $options);
echo $out;
return;
}
if (empty($options['value'])) {
echo '[]';
return;
}
$checknew = 0;
$checkchange = 0;
if (!empty($options['new'])) {
$checknew = 1;
}
if (!empty($options['change'])) {
$checkchange = 1;
}
require_once 'lib/JSON.php';
$json = new Services_JSON();
$rclist = $json->decode($options['value']);
if (!is_array($rclist)) {
echo '[]';
return;
}
// get bookmark parameter and call bookmark macro
if (!empty($options['time'])) {
if (is_numeric($options['time']) and $options['time'] > 0) {
$formatter->macro_repl('Bookmark', '', $options);
//$bookmark = $options['time'];
}
}
$u = $DBInfo->user;
# retrive user info
if ($u->id != 'Anonymous') {
$bookmark = !empty($u->info['bookmark']) ? $u->info['bookmark'] : '';
} else {
$bookmark = $u->bookmark;
}
if (!$bookmark) {
$bookmark = time();
}
$tz_offset = $formatter->tz_offset;
$info = array();
foreach ($rclist as $page_name) {
$p = new WikiPage($page_name);
if (!$p->exists()) {
$info[$page_name]['state'] = 'deleted';
continue;
// XXX
}
$ed_time = $p->mtime();
if ($ed_time <= $bookmark) {
break;
}
$info[$page_name]['state'] = 'updated';
$add = 0;
$del = 0;
if ($checknew or $checkchange) {
$v = $p->get_rev($bookmark);
if (empty($v)) {
$info[$page_name]['state'] = 'new';
$add += $p->lines();
}
}
if ($checkchange) {
if (empty($v)) {
// new
$infos = array();
} else {
$infos = $p->get_info('>' . $bookmark);
}
foreach ($infos as $inf) {
$tmp = explode(' ', trim($inf[1]));
if (isset($tmp[1])) {
$add += $tmp[0];
$del += $tmp[1];
}
}
$info[$page_name]['add'] = $add;
$info[$page_name]['del'] = $del;
}
}
//.........这里部分代码省略.........
示例5: do_sitemap
function do_sitemap($formatter, $options)
{
global $DBInfo, $Config;
$tc = new Cache_text('persist', array('depth' => 0));
$extra = '';
if (!empty($formater->group)) {
$extra = '.' . $formatter->group;
}
if (!empty($formatter->prefix)) {
$extra .= qualifiedUrl($formatter->prefix);
}
// all pages
$mtime = $DBInfo->mtime();
$lastmod = gmdate('D, d M Y H:i:s \\G\\M\\T', $mtime);
$etag = md5($mtime . $DBInfo->etag_seed . $extra);
$options['etag'] = $etag;
$options['mtime'] = $mtime;
// set the s-maxage for proxy
$date = gmdate('Y-m-d-H-i-s', $mtime);
$proxy_maxage = !empty($Config['proxy_maxage']) ? ', s-maxage=' . $Config['proxy_maxage'] : '';
// only xml format supported
$format = 'text/xml';
if (isset($options['format']) and in_array($options['format'], array('text/xml'))) {
$format = $options['format'];
}
$header[] = 'Content-Type: ' . $format;
$header[] = 'Cache-Control: public' . $proxy_maxage . ', max-age=0, must-revalidate';
$need = http_need_cond_request($mtime, $lastmod, $etag);
if (!$need) {
$header[] = 'HTTP/1.0 304 Not Modified';
} else {
$header[] = 'Content-Disposition: attachment; filename="sitemap-' . $date . '.xml"';
}
$formatter->send_header($header, $options);
if (!$need) {
@ob_end_clean();
return;
}
if (!$formatter->refresh && ($ret = $tc->fetch('sitemap' . $extra . '.mtime')) !== false) {
if (($ret = $tc->fetch('sitemap' . $extra, 0, array('print' => 1))) !== false) {
return;
}
}
// set sitemap public cache
$ext = $format == 'text/xml' ? 'xml' : 'txt';
$sc = new Cache_text('sitemap', array('dir' => $DBInfo->cache_public_dir, 'ext' => $ext, 'depth' => 0));
# get page list
set_time_limit(0);
if ($formater->group) {
$group_pages = $DBInfo->getLikePages($formater->group);
foreach ($group_pages as $page) {
$all_pages[] = str_replace($formatter->group, '', $page);
}
usort($all_pages, 'strcasecmp');
} else {
if (!empty($Config['sitemap_sortby'])) {
// call PageSort macro.
$opts = array();
$opts['sortby'] = $Config['sitemap_sortby'];
// date or size
$opts['.call'] = 1;
$ret = $formatter->macro_repl('PageSort', '', $opts);
$all_pages = array();
if (!empty($ret['count'])) {
$tc->fetch('pagedate.raw');
$rawfile = $tc->cache_path . '/' . $tc->getKey('pagedate.raw');
$fp = fopen($rawfile, 'r');
if (is_resource($fp)) {
while (($line = fgets($fp, 1024)) != false) {
$tmp = explode("\t", $line);
$all_pages[] = $tmp[0];
}
fclose($fp);
}
}
} else {
$args = array('all' => 1);
$all_pages = $DBInfo->getPageLists($args);
usort($all_pages, 'strcasecmp');
}
}
$count = sizeof($all_pages);
$map = '';
$zone = '+00:00';
$ttl = !empty($DBInfo->sitemap_ttl) ? $DBInfo->sitemap_ttl : 60 * 60 * 24 * 7;
if ($count > 50000) {
$map = <<<HEAD
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
HEAD;
$date = gmdate("Y-m-d\\TH:i:s", time()) . $zone;
// W3C datetime format
$total = intval($count / 50000) + ($count % 50000 > 0 ? 1 : 0);
for ($i = 0; $i < $total; $i++) {
$mapname = $sc->getKey(sprintf('sitemap' . $extra . '%03d', $i));
$map .= "<sitemap>\n<loc>\n" . qualifiedUrl($DBInfo->cache_public_url . '/' . $mapname) . '</loc>' . "\n";
$map .= '<lastmod>' . $date . "</lastmod>\n</sitemap>\n";
}
$map .= "</sitemapindex>\n";
//.........这里部分代码省略.........