本文整理汇总了PHP中Formatter::macro_repl方法的典型用法代码示例。如果您正苦于以下问题:PHP Formatter::macro_repl方法的具体用法?PHP Formatter::macro_repl怎么用?PHP Formatter::macro_repl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Formatter
的用法示例。
在下文中一共展示了Formatter::macro_repl方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: do_atom
function do_atom($formatter, $options)
{
global $DBInfo;
global $_release;
define('ATOM_DEFAULT_DAYS', 7);
$days = $DBInfo->rc_days ? $DBInfo->rc_days : ATOM_DEFAULT_DAYS;
$options['quick'] = 1;
if ($options['c']) {
$options['items'] = $options['c'];
}
$lines = $DBInfo->editlog_raw_lines($days, $options);
$time_current = time();
# $secs_per_day= 60*60*24;
# $days_to_show= 30;
# $time_cutoff= $time_current - ($days_to_show * $secs_per_day);
$URL = qualifiedURL($formatter->prefix);
$img_url = qualifiedURL($DBInfo->logo_img);
$url = qualifiedUrl($formatter->link_url($DBInfo->frontpage));
$surl = qualifiedUrl($formatter->link_url($options['page'] . '?action=atom'));
$channel = <<<CHANNEL
<title>{$DBInfo->sitename}</title>
<link href="{$url}"></link>
<link rel="self" type="application/atom+xml" href="{$surl}" />
<subtitle>RecentChanges at {$DBInfo->sitename}</subtitle>
<generator version="{$_release}">MoniWiki Atom feeder</generator>
CHANNEL;
$items = "";
$ratchet_day = FALSE;
if (!$lines) {
$lines = array();
}
foreach ($lines as $line) {
$parts = explode("\t", $line);
$page_name = $DBInfo->keyToPagename($parts[0]);
$addr = $parts[1];
$ed_time = $parts[2];
$user = $parts[4];
$user_uri = '';
if ($DBInfo->hasPage($user)) {
$user_uri = $formatter->link_url(_rawurlencode($user), "", $user);
$user_uri = '<uri>' . $user_uri . '</uri>';
}
$log = _stripslashes($parts[5]);
$act = rtrim($parts[6]);
$url = qualifiedUrl($formatter->link_url(_rawurlencode($page_name)));
$diff_url = qualifiedUrl($formatter->link_url(_rawurlencode($page_name), '?action=diff'));
$extra = "<br /><a href='{$diff_url}'>" . _("show changes") . "</a>\n";
$content = '';
if (!$DBInfo->hasPage($page_name)) {
$status = 'deleted';
$content = "<content type='html'><a href='{$url}'>{$page_name}</a> is deleted</content>\n";
} else {
$status = 'updated';
if ($options['diffs']) {
$p = new WikiPage($page_name);
$f = new Formatter($p);
$options['raw'] = 1;
$options['nomsg'] = 1;
$html = $f->macro_repl('Diff', '', $options);
if (!$html) {
ob_start();
$f->send_page('', array('fixpath' => 1));
#$f->send_page('');
$html = ob_get_contents();
ob_end_clean();
$extra = '';
}
$content = " <content type='xhtml'><div xmlns='http://www.w3.org/1999/xhtml'>{$html}</content>\n";
} else {
if ($log) {
$html = str_replace('&', '&', $log);
$content = "<content type='text'>" . $html . "</content>\n";
} else {
$content = "<content type='text'>updated</content>\n";
}
}
}
$zone = '+00:00';
$date = gmdate("Y-m-d\\TH:i:s", $ed_time) . $zone;
if (!isset($updated)) {
$updated = $date;
}
#$datetag = gmdate("YmdHis",$ed_time);
$valid_page_name = str_replace('&', '&', $page_name);
$items .= "<entry>\n";
$items .= " <title>{$valid_page_name}</title>\n";
$items .= " <link href='{$url}'></link>\n";
$items .= ' ' . $content;
$items .= " <author><name>{$user}</name>{$user_uri}</author>\n";
$items .= " <updated>{$date}</updated>\n";
$items .= " <contributor><name>{$user}</name>{$user_uri}</contributor>\n";
$items .= "</entry>\n";
}
$updated = " <updated>{$updated}</updated>\n";
$new = "";
if ($options['oe'] and strtolower($options['oe']) != $DBInfo->charset) {
$charset = $options['oe'];
if (function_exists('iconv')) {
$out = $head . $channel . $items . $form;
//.........这里部分代码省略.........
示例2: do_rss_rc
//.........这里部分代码省略.........
$ratchet_day = FALSE;
if (!$lines) {
$lines = array();
}
foreach ($lines as $line) {
$parts = explode("\t", $line);
$page_name = $DBInfo->keyToPagename($parts[0]);
// hide log
if (!empty($members) && !in_array($options['id'], $members) && !empty($Config['ruleset']['hidelog'])) {
if (in_array($page_name, $Config['ruleset']['hidelog'])) {
continue;
}
}
$addr = $parts[1];
$ed_time = $parts[2];
$user = $parts[4];
$log = _stripslashes($parts[5]);
$act = rtrim($parts[6]);
# if ($ed_time < $time_cutoff)
# break;
$url = qualifiedUrl($formatter->link_url(_rawurlencode($page_name)));
$diff_url = qualifiedUrl($formatter->link_url(_rawurlencode($page_name), '?action=diff'));
$extra = "<br /><a href='{$diff_url}'>" . _("show changes") . "</a>\n";
if (!$DBInfo->hasPage($page_name)) {
$status = 'deleted';
$html = '<![CDATA[' . "<a href='{$url}'>" . $page_name . "</a> is deleted" . ']]>' . "\n";
} else {
$status = 'updated';
if (!empty($options['diffs'])) {
$p = new WikiPage($page_name);
$f = new Formatter($p);
$options['raw'] = 1;
$options['nomsg'] = 1;
$html = $f->macro_repl('Diff', '', $options);
if (!$html) {
ob_start();
$f->send_page('', array('fixpath' => 1));
#$f->send_page('');
$html = ob_get_contents();
ob_end_clean();
$extra = '';
}
$html = str_replace(']', ']', $html);
$html = "<![CDATA[" . $html . $extra . "]]>";
#$html=strtr($html.$extra,array('&'=>'&','<'=>'<'));
} else {
if (!empty($options['summary'])) {
$p = new WikiPage($page_name);
$f = new Formatter($p);
$f->section_edit = 0;
$f->sister_on = 0;
$f->perma_icon = '';
$options['nomsg'] = 1;
$b = $p->_get_raw_body();
$chunks = preg_split('/\\n#{4,}/', $b);
# summary breaker is ####
ob_start();
if ($chunks) {
$f->send_page($chunks[0], array('fixpath' => 1));
} else {
$f->send_page('', array('fixpath' => 1));
}
#$f->send_page('');
$html = ob_get_contents();
ob_end_clean();
$chunks = preg_split('/<!-- break -->/', $html);
示例3: do_atom
//.........这里部分代码省略.........
foreach ($lines as $line) {
$parts = explode("\t", $line);
$page_name = $DBInfo->keyToPagename($parts[0]);
// hide log
if (!empty($members) && !in_array($options['id'], $members) && !empty($Config['ruleset']['hidelog'])) {
if (in_array($page_name, $Config['ruleset']['hidelog'])) {
continue;
}
}
$addr = $parts[1];
$ed_time = $parts[2];
$user = $parts[4];
$user_uri = '';
if ($user != 'Anonymous' && $DBInfo->hasPage($user)) {
$user_uri = $formatter->link_url(_rawurlencode($user), "", $user);
$user_uri = '<uri>' . $user_uri . '</uri>';
}
$log = _stripslashes($parts[5]);
$act = rtrim($parts[6]);
$url = qualifiedUrl($formatter->link_url(_rawurlencode($page_name)));
$diff_url = qualifiedUrl($formatter->link_url(_rawurlencode($page_name), '?action=diff'));
$extra = "<br /><a href='{$diff_url}'>" . _("show changes") . "</a>\n";
$content = '';
if (!$DBInfo->hasPage($page_name)) {
$status = 'deleted';
$content = "<content type='html'><a href='{$url}'>{$page_name}</a> is deleted</content>\n";
} else {
$status = 'updated';
if ($options['diffs']) {
$p = new WikiPage($page_name);
$f = new Formatter($p);
$options['raw'] = 1;
$options['nomsg'] = 1;
$html = $f->macro_repl('Diff', '', $options);
if (!$html) {
ob_start();
$f->send_page('', array('fixpath' => 1));
#$f->send_page('');
$html = ob_get_contents();
ob_end_clean();
$extra = '';
}
$content = " <content type='xhtml'><div xmlns='http://www.w3.org/1999/xhtml'>{$html}</content>\n";
} else {
if ($log) {
$html = str_replace('&', '&', $log);
$content = "<content type='text'>" . $html . "</content>\n";
} else {
$content = "<content type='text'>updated</content>\n";
}
}
}
$zone = '+00:00';
$date = gmdate("Y-m-d\\TH:i:s", $ed_time) . $zone;
if (!isset($updated)) {
$updated = $date;
}
#$datetag = gmdate("YmdHis",$ed_time);
$valid_page_name = str_replace('&', '&', $page_name);
$items .= "<entry>\n";
$items .= " <title>{$valid_page_name}</title>\n";
$items .= " <link href='{$url}'></link>\n";
$items .= ' ' . $content;
$items .= " <author><name>{$user}</name>{$user_uri}</author>\n";
$items .= " <updated>{$date}</updated>\n";
$items .= " <contributor><name>{$user}</name>{$user_uri}</contributor>\n";