本文整理匯總了PHP中MarkupToHTML函數的典型用法代碼示例。如果您正苦於以下問題:PHP MarkupToHTML函數的具體用法?PHP MarkupToHTML怎麽用?PHP MarkupToHTML使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了MarkupToHTML函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: HandleRecipeCheck
function HandleRecipeCheck($pagename, $auth = 'admin')
{
global $RecipeListUrl, $Version, $RecipeInfo, $RecipeCheckFmt, $PageStartFmt, $PageEndFmt;
$page = RetrieveAuthPage($pagename, $auth, true, READPAGE_CURRENT);
if (!$page) {
Abort('?admin access required');
}
$cvinfo = GetRecipeList($RecipeListUrl);
if (!$cvinfo) {
$msg = "Unable to retrieve cookbook data from {$RecipeListUrl}\n";
$allow_url_fopen = ini_get('allow_url_fopen');
if (!$allow_url_fopen) {
$msg .= "\n <br /><br />It appears that your PHP environment isn't allowing\n the recipelist to be downloaded from pmwiki.org \n (allow_url_fopen = {$allow_url_fopen}).";
}
Abort($msg);
}
$rinfo['PmWiki:Upgrades'] = $Version;
ScanRecipeInfo('cookbook', $cvinfo);
foreach ((array) $RecipeInfo as $r => $v) {
if (!@$v['Version']) {
continue;
}
$r = preg_replace('/^(?!PmWiki:)(Cookbook[.:])?/', 'Cookbook:', $r);
$rinfo[$r] = $v['Version'];
}
$markup = "!!Recipe status for {\$PageUrl}\n" . RecipeTable($rinfo, $cvinfo);
$html = MarkupToHTML($pagename, $markup);
SDV($RecipeCheckFmt, array(&$PageStartFmt, $html, &$PageEndFmt));
PrintFmt($pagename, $RecipeCheckFmt);
}
示例2: MarkupMarkup
function MarkupMarkup($pagename, $text, $opt = '') {
$MarkupMarkupOpt = array('class' => 'vert');
$opt = array_merge($MarkupMarkupOpt, ParseArgs($opt));
$html = MarkupToHTML($pagename, $text, array('escape' => 0));
if (@$opt['caption'])
$caption = str_replace("'", ''',
"<caption>{$opt['caption']}</caption>");
$class = preg_replace('/[^-\\s\\w]+/', ' ', @$opt['class']);
$sep = (strpos($class, 'horiz') !== false) ? '' : '</tr><tr>';
$pretext = str_replace(" ", " ", nl2br($text));
return Keep(@"<table class='markup $class' align='center'>$caption
<tr><td class='markup1' valign='top'><code>$pretext</code></td>$sep<td
class='markup2' valign='top'>$html</td></tr></table>");
}
示例3: HandleEdit
function HandleEdit($pagename, $auth = 'edit') {
global $IsPagePosted, $EditFields, $ChangeSummary, $EditFunctions,
$EnablePost, $FmtV, $Now, $EditRedirectFmt,
$PageEditForm, $HandleEditFmt, $PageStartFmt, $PageEditFmt, $PageEndFmt;
SDV($EditRedirectFmt, '$FullName');
if (@$_POST['cancel'])
{ Redirect(FmtPageName($EditRedirectFmt, $pagename)); return; }
Lock(2);
$IsPagePosted = false;
$page = RetrieveAuthPage($pagename, $auth, true);
if (!$page) Abort("?cannot edit $pagename");
PCache($pagename,$page);
$new = $page;
foreach((array)$EditFields as $k)
if (isset($_POST[$k])) $new[$k]=str_replace("\r",'',stripmagic($_POST[$k]));
$new['csum'] = $ChangeSummary;
if ($ChangeSummary) $new["csum:$Now"] = $ChangeSummary;
$EnablePost &= preg_grep('/^post/', array_keys(@$_POST));
foreach((array)$EditFunctions as $fn) $fn($pagename,$page,$new);
Lock(0);
if ($IsPagePosted && !@$_POST['postedit'])
{ Redirect(FmtPageName($EditRedirectFmt, $pagename)); return; }
$FmtV['$DiffClassMinor'] =
(@$_POST['diffclass']=='minor') ? "checked='checked'" : '';
$FmtV['$EditText'] =
str_replace('$','$',htmlspecialchars(@$new['text'],ENT_NOQUOTES));
$FmtV['$EditBaseTime'] = $Now;
if (@$PageEditForm) {
$form = ReadPage(FmtPageName($PageEditForm, $pagename), READPAGE_CURRENT);
$FmtV['$EditForm'] = MarkupToHTML($pagename, $form['text']);
}
SDV($PageEditFmt, "<div id='wikiedit'>
<h2 class='wikiaction'>$[Editing {\$FullName}]</h2>
<form method='post' rel='nofollow' action='\$PageUrl?action=edit'>
<input type='hidden' name='action' value='edit' />
<input type='hidden' name='n' value='\$FullName' />
<input type='hidden' name='basetime' value='\$EditBaseTime' />
\$EditMessageFmt
<textarea id='text' name='text' rows='25' cols='60'
onkeydown='if (event.keyCode==27) event.returnValue=false;'
>\$EditText</textarea><br />
<input type='submit' name='post' value=' $[Save] ' />");
SDV($HandleEditFmt, array(&$PageStartFmt, &$PageEditFmt, &$PageEndFmt));
PrintFmt($pagename, $HandleEditFmt);
}
示例4: HandleRss
function HandleRss($pagename)
{
global $RssMaxItems, $RssSourceSize, $RssDescSize, $RssChannelFmt, $RssChannelDesc, $RssTimeFmt, $RssChannelBuildDate, $RssItemsRDFList, $RssItemsRDFListFmt, $RssItems, $RssItemFmt, $HandleRssFmt, $FmtV;
$t = ReadTrail($pagename, $pagename);
$page = RetrieveAuthPage($pagename, 'read', false);
if (!$page) {
Abort("?cannot read {$pagename}");
}
$cbgmt = $page['time'];
$r = array();
for ($i = 0; $i < count($t) && count($r) < $RssMaxItems; $i++) {
if (!PageExists($t[$i]['pagename'])) {
continue;
}
$page = RetrieveAuthPage($t[$i]['pagename'], 'read', false);
Lock(0);
if (!$page) {
continue;
}
$text = MarkupToHTML($t[$i]['pagename'], substr($page['text'], 0, $RssSourceSize));
$text = entityencode(preg_replace("/<.*?>/s", "", $text));
preg_match("/^(.{0,{$RssDescSize}}\\s)/s", $text, $match);
$r[] = array('name' => $t[$i]['pagename'], 'time' => $page['time'], 'desc' => $match[1] . " ...", 'author' => $page['author']);
if ($page['time'] > $cbgmt) {
$cbgmt = $page['time'];
}
}
SDV($RssChannelBuildDate, entityencode(gmdate('D, d M Y H:i:s \\G\\M\\T', $cbgmt)));
SDV($RssChannelDesc, entityencode(FmtPageName('$Group.$Title', $pagename)));
foreach ($r as $page) {
$FmtV['$RssItemPubDate'] = gmstrftime($RssTimeFmt, $page['time']);
$FmtV['$RssItemDesc'] = $page['desc'];
$FmtV['$RssItemAuthor'] = $page['author'];
$RssItemsRDFList[] = entityencode(FmtPageName($RssItemsRDFListFmt, $page['name']));
$RssItems[] = entityencode(FmtPageName($RssItemFmt, $page['name']));
}
header("Content-type: text/xml");
PrintFmt($pagename, $HandleRssFmt);
exit;
}
示例5: PrintDiff
function PrintDiff($pagename)
{
global $DiffShow, $DiffStartFmt, $TimeFmt, $DiffDelFmt, $DiffAddFmt, $DiffEndDelAddFmt, $DiffEndFmt, $DiffRestoreFmt, $FmtV, $LinkFunctions;
$page = ReadPage($pagename);
if (!$page) {
return;
}
krsort($page);
reset($page);
$lf = $LinkFunctions;
$LinkFunctions['http:'] = 'LinkSuppress';
$LinkFunctions['https:'] = 'LinkSuppress';
foreach ($page as $k => $v) {
if (!preg_match("/^diff:(\\d+):(\\d+):?([^:]*)/", $k, $match)) {
continue;
}
$diffclass = $match[3];
if ($diffclass == 'minor' && $DiffShow['minor'] != 'y') {
continue;
}
$diffgmt = $match[1];
$FmtV['$DiffTime'] = strftime($TimeFmt, $diffgmt);
$diffauthor = @$page["author:{$diffgmt}"];
if (!$diffauthor) {
@($diffauthor = $page["host:{$diffgmt}"]);
}
if (!$diffauthor) {
$diffauthor = "unknown";
}
$FmtV['$DiffChangeSum'] = htmlspecialchars(@$page["csum:{$diffgmt}"]);
$FmtV['$DiffHost'] = @$page["host:{$diffgmt}"];
$FmtV['$DiffAuthor'] = $diffauthor;
$FmtV['$DiffId'] = $k;
echo FmtPageName($DiffStartFmt, $pagename);
$difflines = explode("\n", $v . "\n");
$in = array();
$out = array();
$dtype = '';
foreach ($difflines as $d) {
if ($d > '') {
if ($d[0] == '-' || $d[0] == '\\') {
continue;
}
if ($d[0] == '<') {
$out[] = substr($d, 2);
continue;
}
if ($d[0] == '>') {
$in[] = substr($d, 2);
continue;
}
}
if (preg_match("/^(\\d+)(,(\\d+))?([adc])(\\d+)(,(\\d+))?/", $dtype, $match)) {
if (@$match[7] > '') {
$lines = 'lines';
$count = $match[1] . '-' . ($match[1] + $match[7] - $match[5]);
} elseif ($match[3] > '') {
$lines = 'lines';
$count = $match[1] . '-' . $match[3];
} else {
$lines = 'line';
$count = $match[1];
}
if ($match[4] == 'a' || $match[4] == 'c') {
$txt = str_replace('line', $lines, $DiffDelFmt[$match[4]]);
$FmtV['$DiffLines'] = $count;
echo FmtPageName($txt, $pagename);
if ($DiffShow['source'] == 'y') {
echo "<div class='diffmarkup'>", str_replace("\n", "<br />", htmlspecialchars(join("\n", $in))), "</div>";
} else {
echo MarkupToHTML($pagename, preg_replace('/\\(:(.*?):\\)/', '[@$1@]', join("\n", $in)));
}
}
if ($match[4] == 'd' || $match[4] == 'c') {
$txt = str_replace('line', $lines, $DiffAddFmt[$match[4]]);
$FmtV['$DiffLines'] = $count;
echo FmtPageName($txt, $pagename);
if ($DiffShow['source'] == 'y') {
echo "<div class='diffmarkup'>", str_replace("\n", "<br />", htmlspecialchars(join("\n", $out))), "</div>";
} else {
echo MarkupToHTML($pagename, preg_replace('/(\\(:.*?:\\))/', '[@$1@]', join("\n", $out)));
}
}
echo FmtPageName($DiffEndDelAddFmt, $pagename);
}
$in = array();
$out = array();
$dtype = $d;
}
echo FmtPageName($DiffEndFmt, $pagename);
echo FmtPageName($DiffRestoreFmt, $pagename);
}
$LinkFunctions = $lf;
}
示例6: MarkupMarkup
function MarkupMarkup($pagename, $text, $opt = '')
{
$MarkupMarkupOpt = array('class' => 'vert');
$opt = array_merge($MarkupMarkupOpt, ParseArgs($opt));
$html = MarkupToHTML($pagename, $text, array('escape' => 0));
if (@$opt['caption']) {
$caption = str_replace("'", ''', "<caption>{$opt['caption']}</caption>");
}
$class = preg_replace('/[^-\\s\\w]+/', ' ', @$opt['class']);
if (strpos($class, 'horiz') !== false) {
$sep = '';
$pretext = wordwrap($text, 40);
} else {
$sep = '</tr><tr>';
$pretext = wordwrap($text, 75);
}
return Keep("<table class='markup {$class}' align='center'>{$caption}\n <tr><td class='markup1' valign='top'><pre>{$pretext}</pre></td>{$sep}<td \n class='markup2' valign='top'>{$html}</td></tr></table>");
}
示例7: FPLTemplate
//.........這裏部分代碼省略.........
array_splice($tparts, $i, 3);
}
SDVA($opt, array('class' => 'fpltemplate', 'wrap' => 'div'));
## get the list of pages
$matches = array_values(MakePageList($pagename, $opt, 0));
## extract page subset according to 'count=' parameter
if (@$opt['count']) {
list($r0, $r1) = CalcRange($opt['count'], count($matches));
if ($r1 < $r0) {
$matches = array_reverse(array_slice($matches, $r1 - 1, $r0 - $r1 + 1));
} else {
$matches = array_slice($matches, $r0 - 1, $r1 - $r0 + 1);
}
}
$savecursor = $Cursor;
$pagecount = 0;
$groupcount = 0;
$grouppagecount = 0;
$pseudovars = array('{$$PageCount}' => &$pagecount, '{$$GroupCount}' => &$groupcount, '{$$GroupPageCount}' => &$grouppagecount);
foreach (preg_grep('/^[\\w$]/', array_keys($opt)) as $k) {
if (!is_array($opt[$k])) {
$pseudovars["{\$\${$k}}"] = htmlspecialchars($opt[$k], ENT_NOQUOTES);
}
}
$vk = array_keys($pseudovars);
$vv = array_values($pseudovars);
$lgroup = '';
$out = '';
foreach ($matches as $i => $pn) {
$group = PageVar($pn, '$Group');
if ($group != $lgroup) {
$groupcount++;
$grouppagecount = 0;
$lgroup = $group;
}
$grouppagecount++;
$pagecount++;
$t = 0;
while ($t < count($tparts)) {
if ($tparts[$t] != 'template') {
$item = $tparts[$t];
$t++;
} else {
list($when, $control, $item) = array_slice($tparts, $t + 1, 3);
$t += 4;
if (!$control) {
if ($when == 'first' && $i != 0) {
continue;
}
if ($when == 'last' && $i != count($matches) - 1) {
continue;
}
} else {
if ($when == 'first' || !isset($last[$t])) {
$Cursor['<'] = $Cursor['<'] = (string) @$matches[$i - 1];
$Cursor['='] = $pn;
$Cursor['>'] = $Cursor['>'] = (string) @$matches[$i + 1];
$curr = str_replace($vk, $vv, $control);
$curr = preg_replace('/\\{(=|&[lg]t;)(\\$:?\\w+)\\}/e', "PageVar(\$pn, '\$2', '\$1')", $curr);
if ($when == 'first' && $i > 0 && $last[$t] == $curr) {
continue;
}
$last[$t] = $curr;
}
if ($when == 'last') {
$Cursor['<'] = $Cursor['<'] = $pn;
$Cursor['='] = (string) @$matches[$i + 1];
$Cursor['>'] = $Cursor['>'] = (string) @$matches[$i + 2];
$next = str_replace($vk, $vv, $control);
$next = preg_replace('/\\{(=|&[lg]t;)(\\$:?\\w+)\\}/e', "PageVar(\$pn, '\$2', '\$1')", $next);
if ($next == $last[$t] && $i != count($matches) - 1) {
continue;
}
$last[$t] = $next;
}
}
}
$Cursor['<'] = $Cursor['<'] = (string) @$matches[$i - 1];
$Cursor['='] = $pn;
$Cursor['>'] = $Cursor['>'] = (string) @$matches[$i + 1];
$item = str_replace($vk, $vv, $item);
$item = preg_replace('/\\{(=|&[lg]t;)(\\$:?\\w+)\\}/e', "PVSE(PageVar(\$pn, '\$2', '\$1'))", $item);
$out .= MarkupRestore($item);
}
}
$class = preg_replace('/[^-a-zA-Z0-9\\x80-\\xff]/', ' ', @$opt['class']);
if ($class) {
$class = " class='{$class}'";
}
$wrap = @$opt['wrap'];
if ($wrap != 'inline') {
$out = MarkupToHTML($pagename, $out, array('escape' => 0, 'redirect' => 1));
if ($wrap != 'none') {
$out = "<div{$class}>{$out}</div>";
}
}
$Cursor = $savecursor;
StopWatch("FPLTemplate end");
return $out;
}
示例8: FPLTemplate
function FPLTemplate($pagename, &$matches, $opt)
{
global $Cursor, $FPLFormatOpt, $FPLTemplatePageFmt;
SDV($FPLTemplatePageFmt, array('{$FullName}', '{$SiteGroup}.LocalTemplates', '{$SiteGroup}.PageListTemplates'));
$template = @$opt['template'];
if (!$template) {
$template = @$opt['fmt'];
}
list($tname, $qf) = explode('#', $template, 2);
if ($tname) {
$tname = array(MakePageName($pagename, $tname));
} else {
$tname = (array) $FPLTemplatePageFmt;
}
foreach ($tname as $t) {
$t = FmtPageName($t, $pagename);
if (!PageExists($t)) {
continue;
}
if ($qf) {
$t .= "#{$qf}";
}
$ttext = IncludeText($pagename, $t, true);
if (!$qf || strpos($ttext, "[[#{$qf}]]") !== false) {
break;
}
}
## remove any anchor markups to avoid duplications
$ttext = preg_replace('/\\[\\[#[A-Za-z][-.:\\w]*\\]\\]/', '', $ttext);
if (!@$opt['order'] && !@$opt['trail']) {
$opt['order'] = 'name';
}
$matches = array_values(MakePageList($pagename, $opt, 0));
if (@$opt['count']) {
array_splice($matches, $opt['count']);
}
$savecursor = $Cursor;
$pagecount = 0;
$groupcount = 0;
$grouppagecount = 0;
$vk = array('{$PageCount}', '{$GroupCount}', '{$GroupPageCount}');
$vv = array(&$pagecount, &$groupcount, &$grouppagecount);
$lgroup = '';
$out = '';
foreach ($matches as $i => $pn) {
$prev = (string) @$matches[$i - 1];
$next = (string) @$matches[$i + 1];
$Cursor['<'] = $Cursor['<'] = $prev;
$Cursor['='] = $pn;
$Cursor['>'] = $Cursor['>'] = $next;
$group = PageVar($pn, '$Group');
if ($group != $lgroup) {
$groupcount++;
$grouppagecount = 0;
}
$grouppagecount++;
$pagecount++;
$item = str_replace($vk, $vv, $ttext);
$item = preg_replace('/\\{(=|&[lg]t;)(\\$:?\\w+)\\}/e', "PageVar(\$pn, '\$2', '\$1')", $item);
$out .= $item;
$lgroup = $group;
}
$class = preg_replace('/[^-a-zA-Z0-9\\x80-\\xff]/', ' ', @$opt['class']);
$div = $class ? "<div class='{$class}'>" : '<div>';
return $div . MarkupToHTML($pagename, $out, array('escape' => 0)) . '</div>';
}
示例9: icalexportfct
function icalexportfct($pagename)
{
global $ICalCalendarTitle, $ICalCalendarGroup, $ICalTimeZone, $ICalFileName;
global $UploadDir, $UploadPrefixFmt, $UploadUrlFmt, $GroupPattern, $NamePattern, $FarmD, $IsPagePosted;
global $ScriptUrl;
// Script only executes if the wiki page is written
if (!$IsPagePosted) {
return;
}
// Script only executes if the currently saved page is in the $ICalCalendarGroup
if (!preg_match("/" . $ICalCalendarGroup . "[\\/.]" . $NamePattern . "/i", $pagename)) {
return;
}
$pagelist = ListPages();
$attachlist = array();
$locationi18n = FmtPageName("\$[Location]", $pagename);
$begini18n = FmtPageName("\$[Begin]", $pagename);
$endi18n = FmtPageName("\$[End]", $pagename);
$descriptioni18n = FmtPageName("\$[Description]", $pagename);
$out[] = "BEGIN:VCALENDAR\r\n";
$out[] = "VERSION:2.0\r\n";
$out[] = "X-WR-CALNAME:" . $ICalCalendarTitle . "\r\n";
foreach ($pagelist as $pagename) {
// we need only search events on wiki sides belonging to group $ICalCalendarGroup
if (!preg_match("/" . $ICalCalendarGroup . "." . $NamePattern . "/", $pagename)) {
continue;
}
// we read the page and ...
$rcpage = ReadPage($pagename);
// ... split the events apart on horizontal ruler
$calenderEvents = explode("----", $rcpage['text']);
$acalYear = date("Y", $rcpage['ctime']);
foreach ($calenderEvents as $eventNumber => $event) {
if (preg_match("/^(?:!!)(?!!)\\s?(.*)/m", $event, $eventTitle)) {
preg_match("/^(?:" . $endi18n . ":)\\s*([0-9]{1,2}:[0-9]{1,2}).*\$/m", $event, $eventEnd);
preg_match("/^(?:" . $begini18n . ":)\\s*([0-9]{1,2}:[0-9]{1,2}).*\$/m", $event, $eventBegin);
preg_match("/^(?:" . $locationi18n . ":)\\s*(.*)\$/m", $event, $eventLocation);
preg_match("/^(?:" . $descriptioni18n . ":)\\s*(.*)\$/ms", $event, $eventDescription);
$eventTitle = $eventTitle[1];
$eventBegin = $eventBegin[1];
$eventEnd = $eventEnd[1];
// uh, why I did the str_replace here?
$eventLocation = str_replace("\\", "", $eventLocation[1]);
$eventDescription = str_replace("\\", "", $eventDescription[1]);
$temp = explode(".", $pagename);
$out[] = "BEGIN:VEVENT\r\n";
if (preg_match("/^ACAL/", $temp[1])) {
$temp[1] = str_replace("ACAL", date("Y", $acalYear), $temp[1]);
$out[] = "RRULE:FREQ=YEARLY;INTERVAL=1\r\n";
}
if ($eventBegin && $eventEnd) {
$eventBegin = preg_replace('/^([0-9]:)/', '0$1', $eventBegin);
$eventBegin = preg_replace('/:([0-9])$/', ':0$1', $eventBegin);
$eventEnd = preg_replace('/^([0-9]:)/', '0$1', $eventEnd);
$eventEnd = preg_replace('/:([0-9])$/', ':0$1', $eventEnd);
$beginn = str_replace(":", "", $eventBegin);
$ende = str_replace(":", "", $eventEnd);
$out[] = "DTSTART;TZID=" . $ICalTimeZone . ":" . $temp[1] . "T" . $beginn . "00\r\n";
$out[] = "DTEND;TZID=" . $ICalTimeZone . ":" . $temp[1] . "T" . $ende . "00\r\n";
} else {
//we say it is a full day event and set the end to the next day
// TODO:1 check if date exists and wrap to next month if not
$nextDay = $temp[1] + 1;
$out[] = "DTSTART;VALUE=DATE:" . $temp[1] . "\r\n";
$out[] = "DTEND;VALUE=DATE:" . $nextDay . "\r\n";
}
if ($eventLocation) {
$out[] = "LOCATION:" . $eventLocation . "\r\n";
}
$title = MarkupToHTML($pagename, $eventTitle);
$title = chop(preg_replace("/<.*?>/s", "", $title));
$out[] = "SUMMARY:" . $title . "\r\n";
//Every event needs a clear ID in the iCal protokoll
$out[] = "UID:" . $pagename . "-" . $eventNumber . "-@" . $_SERVER['HTTP_HOST'] . "\r\n";
if ($eventDescription) {
$infos = MarkupToHTML($pagename, $eventDescription);
$infos = preg_replace("/<.*?>/s", "", $infos);
$infos = chop($infos);
$infos = preg_replace("/\n/s", "\\r\\n", $infos);
//Seperates the following URL by two lines
$infos = $infos . "\\r\\n\\r\\n";
} else {
$infos = "";
}
$out[] = "DESCRIPTION:" . $infos . $ScriptUrl . "/" . $pagename . "\r\n";
$out[] = "END:VEVENT\r\n";
}
}
}
$out[] = "END:VCALENDAR\r\n";
$pagetext = implode("", $out);
//debugging help: prints out the written iCal file on the wikipage
#return implode("<br>", $out);
// writes out the ics file
$filename = $UploadDir . "/" . $ICalCalendarGroup . "/" . $ICalFileName . ".ics";
$handle = fopen($filename, "w");
fwrite($handle, $pagetext);
fclose($handle);
chmod($filename, 0777);
return;
//.........這裏部分代碼省略.........
示例10: HandleFastCacheBrowse
function HandleFastCacheBrowse($pagename, $auth = 'read')
{
# handle display of a page
global $DefaultPageTextFmt, $PageNotFoundHeaderFmt, $HTTPHeaders, $EnableHTMLCache, $NoHTMLCache, $PageCacheFile, $LastModTime, $IsHTMLCached, $FmtV, $HandleBrowseFmt, $PageStartFmt, $PageEndFmt, $PageRedirectFmt;
## begin added
global $FastCachePage, $FastCacheDir, $FastCacheValid, $FastCacheSuffix;
if (!$FastCacheValid || !$FastCacheDir) {
HandleBrowse($pagename, $auth);
return;
}
SDV($FastCacheSuffix, '.html');
$fcfile = "{$FastCacheDir}/{$pagename}{$FastCacheSuffix}";
if (@filemtime($fcfile) > $LastModTime) {
if ($FastCachePage = file_get_contents($fcfile)) {
StopWatch("HandleFastCacheBrowse: using FastCached copy of {$pagename}");
echo $FastCachePage;
} else {
$FastCacheValid = FALSE;
StopWatch("HandleFastCacheBrowse: read error on {$fcfile}");
HandleBrowse($pagename, $auth);
}
return;
}
## end added
$page = RetrieveAuthPage($pagename, $auth, true, READPAGE_CURRENT);
if (!$page) {
Abort("?cannot read {$pagename}");
}
PCache($pagename, $page);
if (PageExists($pagename)) {
$text = @$page['text'];
} else {
$FastCacheValid = FALSE;
## added
SDV($DefaultPageTextFmt, '(:include $[{$SiteGroup}.PageNotFound]:)');
$text = FmtPageName($DefaultPageTextFmt, $pagename);
SDV($PageNotFoundHeaderFmt, 'HTTP/1.1 404 Not Found');
SDV($HTTPHeaders['status'], $PageNotFoundHeaderFmt);
}
$opt = array();
SDV($PageRedirectFmt, "<p><i>(\$[redirected from] <a rel='nofollow'\n href='{\$PageUrl}?action=edit'>{\$FullName}</a>)</i></p>\$HTMLVSpace\n");
if (@(!$_GET['from'])) {
$opt['redirect'] = 1;
$PageRedirectFmt = '';
} else {
$PageRedirectFmt = FmtPageName($PageRedirectFmt, $_GET['from']);
}
if (@$EnableHTMLCache && !$NoHTMLCache && $PageCacheFile && @filemtime($PageCacheFile) > $LastModTime) {
list($ctext) = unserialize(file_get_contents($PageCacheFile));
$FmtV['$PageText'] = "<!--cached-->{$ctext}";
$IsHTMLCached = 1;
StopWatch("HandleFastCacheBrowse: using HTMLCached copy");
## modified
} else {
$IsHTMLCached = 0;
$text = '(:groupheader:)' . @$text . '(:groupfooter:)';
$t1 = time();
$FmtV['$PageText'] = MarkupToHTML($pagename, $text, $opt);
if (@$EnableHTMLCache > 0 && !$NoHTMLCache && $PageCacheFile && time() - $t1 + 1 >= $EnableHTMLCache) {
$fp = @fopen("{$PageCacheFile},new", "x");
if ($fp) {
StopWatch("HandleFastCacheBrowse: HTMLCaching page");
## modified
fwrite($fp, serialize(array($FmtV['$PageText'])));
fclose($fp);
rename("{$PageCacheFile},new", $PageCacheFile);
}
}
}
SDV($HandleBrowseFmt, array(&$PageStartFmt, &$PageRedirectFmt, '$PageText', &$PageEndFmt));
## begin modified
if ($FastCacheValid) {
ob_start();
PrintFmt($pagename, $HandleBrowseFmt);
$FastCachePage = ob_get_contents();
ob_end_flush();
mkdirp(dirname($fcfile));
if ($FastCacheValid && ($fc = fopen("{$fcfile},new", 'x'))) {
StopWatch("HandleFastCacheBrowse: FastCaching {$pagename}");
fwrite($fc, $FastCachePage);
fclose($fc);
rename("{$fcfile},new", $fcfile);
} else {
StopWatch("HandleFastCacheBrowse: error writing cache to {$fcfile},new");
}
} else {
PrintFmt($pagename, $HandleBrowseFmt);
}
## end modified
}
示例11: convertPagesToXML
function convertPagesToXML ($pageinfo) {
$xml = "<!-- Frontmatter -->\n";
if ($pageinfo['preface'] != '') {
// extract title and author information
message("processing trail page ".$this->pagename, 'start');
while (preg_match('/(\(:(\w+)(\s+.+?)?:\).*?\(:end\2:\)\s*)/s', $pageinfo['preface'], $m)) {
$xml .= preg_replace('#^\s*<p>(.*)</p>\s*$#s', '$1', MarkupToHTML($this->pagename, trim($m[1])));
$pageinfo['preface'] = str_replace($m[1], '', $pageinfo['preface']);
}
while (preg_match('/(\(:\w+(\s+.+?)?:\))\s*/s', $pageinfo['preface'], $m)) {
$xml .= preg_replace('#^\s*<p>(.*)</p>\s*$#s', '$1', MarkupToHTML($this->pagename, trim($m[1])));
$pageinfo['preface'] = str_replace($m[1], '', $pageinfo['preface']);
}
message('', 'end');
}
unset($pageinfo['preface']);
foreach ($pageinfo as $pi) {
global $WikiDir;
$pagefile = $WikiDir->pagefile($pi['pagename']);
$cachefile = $this->outputDir($pi['pagename'])."/cache.xml";
$msg = "processing page ".htmlentities($pi['pagename']);
if (0) { // @@
message("$msg from cache", 'start');
$localxml = file_get_contents($cachefile);
}
else {
global $ProcessedPages;
$empty = file_exists($pagefile) ? '' : ' (page empty)';
message($msg.$empty, 'start');
$ProcessedPages[] = $pi['pagename'];
list($group) = explode('.', $pi['pagename']);
$page = ReadPage($pi['pagename']);
$text = trim($page['text']);
$text = preg_replace('/^!+.*?\\n/', '', $text); // remove title header from wiki page
$text = html_entity_decode($text);
$title = $pi['title'] ? $pi['title'] : $pi['pagename'];
$sectcmd = "(:section level=$pi[depth] title=\"$pi[title]\" label=".Keep($pi[pagename]).":)";
$text = "{$sectcmd}\n$text"; // ...then add a title with name of wiki page
$text = str_replace(chr(128), '¤', $text); // das "Windows" ¤-Zeichen liegt auf 128...
$localxml = MarkupToHTML($pi['pagename'], $text); // generate XML of current wiki page
if (file_exists($pagefile)) { // does wikipage exist?
recursive_mkdir(dirname($cachefile));
$f = fopen($cachefile, 'w');
fputs($f, $localxml);
fclose($f);
}
}
$xml .= $localxml;
message('', 'end');
}
// close all open section elements
$xml .= flush_section(0);
$xml = "<article page-width='210mm' page-height='297mm' margin='2cm'>$xml</article>";
return $xml;
}
示例12: FPLTemplate
function FPLTemplate($pagename, &$matches, $opt)
{
global $Cursor, $FPLFormatOpt, $FPLTemplatePageFmt;
SDV($FPLTemplatePageFmt, '{$SiteGroup}.PageListTemplates');
$template = @$opt['template'];
if (!$template) {
$template = @$opt['fmt'];
}
list($tname, $qf) = explode('#', $template, 2);
if ($tname) {
$tname = MakePageName($pagename, $tname);
} else {
$tname = FmtPageName($FPLTemplatePageFmt, $pagename);
}
if ($qf) {
$tname .= "#{$qf}";
}
$ttext = IncludeText($pagename, $tname, true);
$ttext = preg_replace('/\\[\\[#[A-Za-z][-.:\\w]*\\]\\]/', '', $ttext);
if (!$opt['order'] && !$opt['trail']) {
$opt['order'] = 'name';
}
$matches = array_values(MakePageList($pagename, $opt, 0));
if (@$opt['count']) {
array_splice($matches, $opt['count']);
}
$savecursor = $Cursor;
$pagecount = 0;
$groupcount = 0;
$grouppagecount = 0;
$vk = array('{$PageCount}', '{$GroupCount}', '{$GroupPageCount}');
$vv = array(&$pagecount, &$groupcount, &$grouppagecount);
$lgroup = '';
$out = '';
foreach ($matches as $i => $pn) {
$prev = (string) @$matches[$i - 1];
$next = (string) @$matches[$i + 1];
$Cursor['<'] = $Cursor['<'] = $prev;
$Cursor['='] = $pn;
$Cursor['>'] = $Cursor['>'] = $next;
$group = PageVar($pn, '$Group');
if ($group != $lgroup) {
$groupcount++;
$grouppagecount = 0;
}
$grouppagecount++;
$pagecount++;
$item = str_replace($vk, $vv, $ttext);
$item = preg_replace('/\\{(=|&[lg]t;)(\\$\\w+)\\}/e', "PageVar(\$pn, '\$2', '\$1')", $item);
$out .= $item;
$lgroup = $group;
}
return '<div>' . MarkupToHTML($pagename, $out, false) . '</div>';
}
示例13: HandlePDF
function HandlePDF($pagename)
{
global $WikiTitle;
// modify WikiTitle
$WikiTitle = str_replace(' ', '_', $WikiTitle);
$WikiTitle = html_entity_decode($WikiTitle);
// read wiki page !
//$page = ReadPage($pagename);
$page = RetrieveAuthPage($pagename, 'read', true, READPAGE_CURRENT);
//$date['modif'] = filemtime($_SERVER['DOCUMENT_ROOT'].'/wiki.d/'.$pagename);
// define variable
$xyz['author'] = 'by ' . $page['author'];
// pdf author
$xyz['name']['page'] = str_replace('.', '_', $pagename);
// page name
$xyz['name']['pdf'] = $WikiTitle . '_' . $xyz['name']['page'] . '.pdf';
// pdf name
$xyz['text'] = mv_breakpage($page['text']);
// to transform breakpage markup
$xyz['title'] = $WikiTitle . ' : page ' . $xyz['name']['page'];
// pdf title
$xyz['path'] = $_SERVER["DOCUMENT_ROOT"];
// return root path of your site web
$xyz['url'] = 'http://' . HOST . URI;
// pdf URL
// transform text to html !
$html = change_code(MarkupToHTML($pagename, $xyz['text']));
/*** for test ! ***
echo $xyz['text'];
echo "\n HTML : ".$html;
/** */
//out pass memory server
ini_set('memory_limit', '24M');
ini_set('max_execution_time', 0);
// declare a new object pdf
$pdf = new HTML2FPDF();
// Disactive elements HTML ... cause bad support !
$pdf->DisableTags('<span>');
$pdf->DisableTags('<dl>');
$pdf->DisableTags('<dt>');
$pdf->DisableTags('<dd>');
// generals informations
$pdf->SetCompression(1);
$pdf->SetAuthor($xyz['author']);
$pdf->SetTitle($xyz['title']);
// method implemented by me to return in footer pdf generated.
$pdf->PutHREF($xyz['url']);
// method implemented by html2pdf author !
$pdf->setBasePath($xyz['path']);
// to implement path of your site ; need it for include correctly the image on pdf !
$pdf->UseCSS(false);
// to recognize CSS ... run correctly ?
$pdf->UsePRE(false);
// to recognize element PRE in your code HTML ... but, really bad support !
// build the page PDF
$pdf->AddPage();
$pdf->WriteHTML($html);
$pdf->Output($xyz['name']['pdf'], I);
/**/
// retabli valeur serveur
ini_set('memory_limit', MEM);
ini_set('max_execution_time', MAX_TIME);
}
示例14: RenderSidePart
function RenderSidePart($pagename, $params)
{
$pagelist = preg_split('/\\s+/', $params, -1, PREG_SPLIT_NO_EMPTY);
$class_title = array_shift($pagelist);
$class = array_shift($pagelist);
$id = array_shift($pagelist);
list($text, $title) = RetrievePageMarkup($pagelist);
if (!isset($text)) {
return;
}
$orig_page_title = PageVar($pagename, '$Title');
print "<div class='{$class_title}'>{$title}</div><div class='{$class}' id='{$id}'>";
print MarkupToHTML($pagename, $text);
print "</div><!-- id='{$id}' -->";
PCache($pagename, array('title' => SetProperty($pagename, 'title', $orig_page_title)));
}
示例15: HandleRss
function HandleRss($pagename)
{
global $RssMaxItems, $RssSourceSize, $RssDescSize, $RssChannelFmt, $RssChannelDesc, $RssTimeFmt, $RssChannelBuildDate, $RssItemsRDFList, $RssItemsRDFListFmt, $RssItems, $RssItemFmt, $RssItemDesc, $RssItemPubDate, $GCount, $HandleRssFmt;
$t = ReadTrail($pagename, $pagename);
$page = RetrieveAuthPage($pagename, false);
$cbgmt = $page['time'];
$r = array();
for ($i = 0; $i < count($t) && count($r) < $RssMaxItems; $i++) {
if (!PageExists($t[$i]['pagename'])) {
continue;
}
$page = RetrieveAuthPage($t[$i]['pagename'], false);
$text = MarkupToHTML($t[$i]['pagename'], substr($page['text'], 0, $RssSourceSize));
$text = rssencode(preg_replace("/<.*?>/s", "", $text));
preg_match("/^(.{0,{$RssDescSize}}\\s)/s", $text, $match);
$r[] = array('name' => $t[$i]['pagename'], 'time' => $page['time'], 'desc' => $match[1] . " ...");
if ($page['time'] > $cbgmt) {
$cbgmt = $page['time'];
}
}
SDV($RssChannelBuildDate, rssencode(gmstrftime($RssTimeFmt, $cbgmt)));
SDV($RssChannelDesc, rssencode(FmtPageName('$Group.$Title', $pagename)));
foreach ($r as $page) {
$RssItemPubDate = gmstrftime($RssTimeFmt, $page['time']);
$RssItemDesc = $page['desc'];
$GCount = 0;
$RssItemsRDFList[] = rssencode(FmtPageName($RssItemsRDFListFmt, $page['name']));
$RssItems[] = rssencode(FmtPageName($RssItemFmt, $page['name']));
}
header("Content-type: text/xml");
PrintFmt($pagename, $HandleRssFmt);
exit;
}