本文整理汇总了PHP中pageTemplate函数的典型用法代码示例。如果您正苦于以下问题:PHP pageTemplate函数的具体用法?PHP pageTemplate怎么用?PHP pageTemplate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pageTemplate函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _prepare_template
/**
* Loads the template for a new blog post and does some text replacements
*
* @author Gina Haeussge <osd@foosel.net>
*
* @param $id
* @param $title
* @return bool|mixed|string
*/
function _prepare_template($id, $title)
{
$tpl = pageTemplate($id);
if (!$tpl) {
$tpl = io_readFile(DOKU_PLUGIN . 'blogtng/tpl/newentry.txt');
}
$replace = array('@TITLE@' => $title);
$tpl = str_replace(array_keys($replace), array_values($replace), $tpl);
return $tpl;
}
示例2: rawPage
/**
* Return a raw wiki page
* @param string $id wiki page id
* @param string $rev revision number of the page
* @return page text.
*/
function rawPage($id, $rev = '')
{
$id = $this->resolvePageId($id);
if (auth_quickaclcheck($id) < AUTH_READ) {
throw new RemoteAccessDeniedException('You are not allowed to read this file', 111);
}
$text = rawWiki($id, $rev);
if (!$text) {
return pageTemplate($id);
} else {
return $text;
}
}
示例3: handle_act_preprocess
/**
* Checks if 'newentry' was given as action, if so we
* do handle the event our self and no further checking takes place
*/
function handle_act_preprocess(&$event, $param)
{
//if ($event->data != 'newentry') return; // nothing to do for us
global $ACT;
global $ID;
echo "param={$param}";
return;
// we can handle it -> prevent others
$event->stopPropagation();
$event->preventDefault();
$ns = $_REQUEST['ns'];
$title = str_replace(':', '', $_REQUEST['title']);
$id = ($ns ? $ns . ':' : '') . cleanID($title);
// check if we are allowed to create this file
if (auth_quickaclcheck($id) >= AUTH_CREATE) {
$back = $ID;
$ID = $id;
$file = wikiFN($ID);
//check if locked by anyone - if not lock for my self
if (checklock($ID)) {
$ACT = 'locked';
} else {
lock($ID);
}
// prepare the new thread file with default stuff
if (!@file_exists($file)) {
global $TEXT;
global $INFO;
global $conf;
$TEXT = pageTemplate($ns . ':' . $title);
if (!$TEXT) {
$TEXT = "====== {$title} ======\n\n\n\n" . "~~DISCUSSION~~\n";
}
$ACT = 'preview';
} else {
$ACT = 'edit';
}
} else {
$ACT = 'show';
}
}
示例4: _handle_newEntry
/**
* Creates a new entry page
*/
function _handle_newEntry()
{
global $ID, $INFO;
$ns = cleanID($_REQUEST['ns']);
$title = str_replace(':', '', $_REQUEST['title']);
$ID = $this->_newEntryID($ns, $title);
$INFO = pageinfo();
// check if we are allowed to create this file
if ($INFO['perm'] >= AUTH_CREATE) {
//check if locked by anyone - if not lock for my self
if ($INFO['locked']) {
return 'locked';
} else {
lock($ID);
}
// prepare the new thread file with default stuff
if (!@file_exists($INFO['filepath'])) {
global $TEXT;
$TEXT = pageTemplate(array(($ns ? $ns . ':' : '') . $title));
if (!$TEXT) {
$data = array('id' => $ID, 'ns' => $ns, 'title' => $title);
$TEXT = $this->_pageTemplate($data);
}
return 'preview';
} else {
return 'edit';
}
} else {
return 'show';
}
}
示例5: rawPage
/**
* Return a raw wiki page
*/
function rawPage($id, $rev = '')
{
$id = cleanID($id);
if (auth_quickaclcheck($id) < AUTH_READ) {
return new IXR_Error(1, 'You are not allowed to read this page');
}
$text = rawWiki($id, $rev);
if (!$text) {
return pageTemplate($id);
} else {
return $text;
}
}
示例6: getActionTargetpages
/**
* Load template(s) for targetpage as given via action field
*
* @param string $tpl template name as given in form
* @return string parsed templatename
*/
protected function getActionTargetpages($tpl)
{
global $USERINFO;
global $conf;
global $ID;
$runas = $this->getConf('runas');
if ($tpl == '_') {
// use namespace template
if (!isset($this->targetpages[$this->pagename])) {
$this->targetpages[$this->pagename] = pageTemplate(array($this->pagename));
}
} elseif ($tpl !== '!') {
$tpl = $this->replace($tpl);
resolve_pageid(getNS($ID), $tpl, $ignored);
$backup = array();
if ($runas) {
// Hack user credentials.
$backup = array($_SERVER['REMOTE_USER'], $USERINFO['grps']);
$_SERVER['REMOTE_USER'] = $runas;
$USERINFO['grps'] = array();
}
$template_pages = array();
//search checks acl (as runas)
$opts = array('depth' => 0, 'listfiles' => true, 'showhidden' => true);
search($template_pages, $conf['datadir'], 'search_universal', $opts, str_replace(':', '/', getNS($tpl)));
foreach ($template_pages as $template_page) {
$templatepageid = cleanID($template_page['id']);
// try to replace $tpl path with $this->pagename path in the founded $templatepageid
// - a single-page template will only match on itself and will be replaced,
// other newtargets are pages in same namespace, so aren't changed
// - a namespace as template will match at the namespaces-part of the path of pages in this namespace
// so these newtargets are changed
// if there exist a single-page and a namespace with name $tpl, both are selected
$newTargetpageid = preg_replace('/^' . preg_quote_cb(cleanID($tpl)) . '($|:)/', $this->pagename . '$1', $templatepageid);
if ($newTargetpageid === $templatepageid) {
// only a single-page template or page in the namespace template
// which matches the $tpl path are changed
continue;
}
if (!isset($this->targetpages[$newTargetpageid])) {
$this->addParsedTargetpage($newTargetpageid, $templatepageid);
}
}
if ($runas) {
/* Restore user credentials. */
list($_SERVER['REMOTE_USER'], $USERINFO['grps']) = $backup;
}
}
return $tpl;
}
示例7: act_edit
/**
* Handle 'edit', 'preview', 'recover'
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function act_edit($act)
{
global $ID;
global $INFO;
global $TEXT;
global $RANGE;
global $PRE;
global $SUF;
global $REV;
global $SUM;
global $lang;
global $DATE;
if (!isset($TEXT)) {
if ($INFO['exists']) {
if ($RANGE) {
list($PRE, $TEXT, $SUF) = rawWikiSlices($RANGE, $ID, $REV);
} else {
$TEXT = rawWiki($ID, $REV);
}
} else {
$TEXT = pageTemplate($ID);
}
}
//set summary default
if (!$SUM) {
if ($REV) {
$SUM = $lang['restored'];
} elseif (!$INFO['exists']) {
$SUM = $lang['created'];
}
}
// Use the date of the newest revision, not of the revision we edit
// This is used for conflict detection
if (!$DATE) {
$DATE = $INFO['meta']['date']['modified'];
}
//check if locked by anyone - if not lock for my self
$lockedby = checklock($ID);
if ($lockedby) {
return 'locked';
}
lock($ID);
return $act;
}
示例8: _preprocess
/**
* function _preprocess
* @author Myron Turner <turnermm02@shaw.ca>
*/
function _preprocess()
{
global $ID;
global $REV;
global $DATE;
global $RANGE;
global $PRE;
global $SUF;
global $INFO;
global $SUM;
global $lang;
global $conf;
global $ckgedit_lang;
//set summary default
if (!$SUM) {
if ($REV) {
$SUM = $lang['restored'];
} elseif (!$INFO['exists']) {
$SUM = $lang['created'];
}
}
if ($INFO['exists']) {
if ($RANGE) {
list($PRE, $text, $SUF) = rawWikiSlices($RANGE, $ID, $REV);
} else {
$text = rawWiki($ID, $REV);
}
} else {
//try to load a pagetemplate
$text = pageTemplate($ID);
//Check for text from template event handler
if (!$text && $this->page_from_template) {
$text = $this->page_from_template;
}
}
$text = preg_replace_callback('/(~~NOCACHE~~|~~NOTOC~~|\\{\\{rss>http:\\/\\/.*?\\}\\})/ms', create_function('$matches', '$matches[0] = str_replace("{{rss>http://", "{ { rss>Feed:", $matches[0]);
$matches[0] = str_replace("~", "~ ", $matches[0]);
return $matches[0];'), $text);
if ($this->getConf('smiley_hack')) {
$new_addr = $_SERVER['SERVER_NAME'] . DOKU_BASE;
$text = preg_replace("#(?<=http://)(.*?)(?=lib/plugins/ckgedit/ckeditor/plugins/smiley/images)#s", $new_addr, $text);
}
$text = preg_replace_callback('/\\[\\[\\w+>.*?\\]\\]/ms', create_function('$matches', 'return str_replace("/", "__IWIKI_FSLASH__" ,$matches[0]);'), $text);
global $useComplexTables;
if ($this->getConf('complex_tables') || strrpos($text, '~~COMPLEX_TABLES~~') !== false) {
$useComplexTables = true;
} else {
$useComplexTables = false;
}
if (strpos($text, '%%') !== false) {
$text = preg_replace_callback("/<(nowiki|code|file)>(.*?)<\\/(nowiki|code|file)/ms", function ($matches) {
$matches[0] = str_replace('%%', 'DBLPERCENT', $matches[0]);
return $matches[0];
}, $text);
$text = preg_replace_callback("/(?<!nowiki>)%%(.*?)%%/ms", function ($matches) {
return '<nowiki>' . $matches[1] . '</nowiki>';
}, $text);
$text = str_replace('DBLPERCENT', '%%', $text);
}
$pos = strpos($text, '<');
if ($pos !== false) {
$text = preg_replace_callback('/(<nowiki>)(.*?)(<\\/nowiki>)/ms', create_function('$matches', '$needles = array("[","]", "/", ".", "*", "_","\'","<",">","%", "{", "}", "\\\\","(");
$replacements = array("[","]","/", ".", "*", "_", "'", "<",">","%", "{","}", "\","(");
$matches[2] = str_replace($needles, $replacements, $matches[2]);
return $matches[1] . $matches[2] . $matches[3];'), $text);
$text = preg_replace_callback('/<(code|file)(.*?)(>)(.*?)(<\\/\\1>)/ms', create_function('$matches', ' //file_put_contents("geshi.txt", print_r($matches,true));
if(preg_match("/(^\\s*geshi:\\s*(\\w+)(\\s+\\w+\\.\\w+)*\\s*)$/m",$matches[0],$gmatch)){
$gmatch[0] = preg_replace("/\\s*geshi:\\s+/","",$gmatch[0]);
$matches[1] .= " " . trim($gmatch[0]);
//file_put_contents("gmatch.txt", print_r($gmatch,true));
$c=1;
$matches[4] = str_replace($gmatch[1],"",$matches[4],$c);
}
if(preg_match("/\\w+/",$matches[2])) {
$matches[4] = str_replace("CHEVRONescC", ">>",$matches[4]);
$matches[4] = str_replace("CHEVRONescO", "<<",$matches[4]);
$matches[4] = preg_replace("/<(?!\\s)/ms", "__GESHI_OPEN__", $matches[4]);
}
else {
if( preg_match("/MULTI/",$matches[0])) {
$open = "< ";
$close = " >";
}
else {
$open = "<";
$close = ">";
}
$matches[4] = preg_replace("/<(?!\\s)/ms", $open, $matches[4]);
$matches[4] = preg_replace("/(?<!\\s)>/ms", $close, $matches[4]);
}
$matches[4] = str_replace("\\"", "__GESHI_QUOT__", $matches[4]);
return "<" . $matches[1] . $matches[2] . $matches[3] . $matches[4] . $matches[5];'), $text);
/* \n_ckgedit_NPBBR_\n: the final \n prevents this from iterfering with next in line markups
-- in particular tables which require a new line and margin left
this may leave an empty paragraph in the xhtml, which is removed below
*/
//.........这里部分代码省略.........
示例9: run
function run($data, $thanks, $argv)
{
global $ID;
global $conf;
global $USERINFO;
list($tpl, $pagename, $sep) = $argv;
if (is_null($sep)) {
$sep = $conf['sepchar'];
}
$runas = $this->getConf('runas');
$patterns = array();
$values = array();
$templates = array();
// run through fields
foreach ($data as $opt) {
$label = $opt->getParam('label');
$value = $opt->getParam('value');
// prepare replacements
if (!is_null($label)) {
$patterns[$label] = '/(@@|##)' . preg_quote($label, '/') . '(?:\\|([^|]*?))' . (is_null($value) ? '' : '?') . '\\1/si';
$values[$label] = is_null($value) ? '$2' : $value;
$patterns[$label . '|'] = '/(@@|##)' . preg_quote($label, '/') . '(?:\\|(.*?))(?:\\|(.*?))\\1/si';
$values[$label . '|'] = is_null($value) ? '$2' : '$3';
}
// handle pagenames
$pname = $opt->getParam('pagename');
if (!is_null($pname)) {
$pagename .= $sep . $pname;
}
if (!is_null($opt->getParam('page_tpl')) && !is_null($opt->getParam('page_tgt'))) {
$page_tpl = $this->replace($patterns, $values, $opt->getParam('page_tpl'));
if (auth_aclcheck($page_tpl, $runas ? $runas : $_SERVER['REMOTE_USER'], $USERINFO['grps']) >= AUTH_READ) {
$templates[$opt->getParam('page_tgt')] = rawWiki($page_tpl);
}
}
}
$pagename = $this->replace($patterns, $values, $pagename);
// check pagename
$pagename = cleanID($pagename);
if ($pagename === '') {
throw new Exception($this->getLang('e_pagename'));
}
$_templates = array();
foreach ($templates as $k => $v) {
$_templates[cleanID("{$pagename}:{$k}")] = $v;
}
$templates = $_templates;
// get templates
if ($tpl == '_') {
// use namespace template
if (!isset($templates[$pagename])) {
$templates[$pagename] = pageTemplate(array($pagename));
}
} elseif ($tpl !== '!') {
// Namespace link
require_once DOKU_INC . 'inc/search.php';
if ($runas) {
// Hack user credentials.
global $USERINFO;
$backup = array($_SERVER['REMOTE_USER'], $USERINFO['grps']);
$_SERVER['REMOTE_USER'] = $runas;
$USERINFO['grps'] = array();
}
$t_pages = array();
search($t_pages, $conf['datadir'], 'search_universal', array('depth' => 0, 'listfiles' => true), str_replace(':', '/', getNS($tpl)));
foreach ($t_pages as $t_page) {
$t_name = cleanID($t_page['id']);
$p_name = preg_replace('/^' . preg_quote_cb(cleanID($tpl)) . '($|:)/', $pagename . '$1', $t_name);
if ($p_name === $t_name) {
// When using a single-page template, ignore other pages
// in the same namespace.
continue;
}
if (!isset($templates[$p_name])) {
// load page data and do default pattern replacements like
// namespace templates do
$data = array('id' => $p_name, 'tpl' => rawWiki($t_name), 'doreplace' => true);
parsePageTemplate($data);
$templates[$p_name] = $data['tpl'];
}
}
if ($runas) {
/* Restore user credentials. */
global $USERINFO;
list($_SERVER['REMOTE_USER'], $USERINFO['grps']) = $backup;
}
}
if (empty($templates)) {
throw new Exception(sprintf($this->getLang('e_template'), $tpl));
}
// check all target pagenames
foreach (array_keys($templates) as $pname) {
// prevent overriding already existing pages
if (page_exists($pname)) {
throw new Exception(sprintf($this->getLang('e_pageexists'), html_wikilink($pname)));
}
// check auth
if ($runas) {
$auth = auth_aclcheck($pname, $runas, array());
} else {
//.........这里部分代码省略.........
示例10: act_edit
/**
* Handle 'edit', 'preview', 'recover'
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function act_edit($act)
{
global $ID;
global $INFO;
global $TEXT;
global $RANGE;
global $PRE;
global $SUF;
global $REV;
global $SUM;
global $lang;
global $DATE;
if (!isset($TEXT)) {
if ($INFO['exists']) {
if ($RANGE) {
list($PRE, $TEXT, $SUF) = rawWikiSlices($RANGE, $ID, $REV);
} else {
$TEXT = rawWiki($ID, $REV);
}
} else {
$TEXT = pageTemplate($ID);
}
}
//set summary default
if (!$SUM) {
if ($REV) {
$SUM = sprintf($lang['restored'], dformat($REV));
} elseif (!$INFO['exists']) {
$SUM = $lang['created'];
}
}
// Use the date of the newest revision, not of the revision we edit
// This is used for conflict detection
if (!$DATE) {
$DATE = @filemtime(wikiFN($ID));
}
//check if locked by anyone - if not lock for my self
//do not lock when the user can't edit anyway
if ($INFO['writable']) {
$lockedby = checklock($ID);
if ($lockedby) {
return 'locked';
}
lock($ID);
}
return $act;
}
示例11: _preprocess
/**
* function _preprocess
* @author Myron Turner <turnermm02@shaw.ca>
*/
function _preprocess()
{
global $ID;
global $REV;
global $DATE;
global $RANGE;
global $PRE;
global $SUF;
global $INFO;
global $SUM;
global $lang;
global $conf;
global $fckg_lang;
//set summary default
if (!$SUM) {
if ($REV) {
$SUM = $lang['restored'];
} elseif (!$INFO['exists']) {
$SUM = $lang['created'];
}
}
if ($INFO['exists']) {
if ($RANGE) {
list($PRE, $text, $SUF) = rawWikiSlices($RANGE, $ID, $REV);
} else {
$text = rawWiki($ID, $REV);
}
} else {
//try to load a pagetemplate
$text = pageTemplate($ID);
//Check for text from template event handler
if (!$text && $this->page_from_template) {
$text = $this->page_from_template;
}
}
if ($this->getConf('smiley_hack')) {
$new_addr = $_SERVER['SERVER_NAME'] . DOKU_BASE;
$text = preg_replace("#(?<=http://)(.*?)(?=lib/plugins/fckg/fckeditor/editor/images/smiley/msn)#s", $new_addr, $text);
}
$text = preg_replace_callback('/\\[\\[\\w+>.*?\\]\\]/ms', create_function('$matches', 'return str_replace("/", "__IWIKI_FSLASH__" ,$matches[0]);'), $text);
global $useComplexTables;
if ($this->getConf('complex_tables') || strrpos($text, '~~COMPLEX_TABLES~~') !== false) {
$useComplexTables = true;
} else {
$useComplexTables = false;
}
if (strpos($text, '%%') !== false) {
$text = preg_replace_callback('/(<nowiki>)*(\\s*)%%\\s*([^%]+)\\s*%%(<\\/nowiki>)*(\\s*)/ms', create_function('$matches', 'if(preg_match("/<nowiki>/",$matches[1])) {
$matches[1] .= "%%";
}
else $matches[1] = "<nowiki>";
if(preg_match("/<\\/nowiki>/",$matches[4])) {
$matches[4] = "%%</nowiki>";
}
else $matches[4] = "</nowiki>";
return $matches[1] . $matches[2] . $matches[3] . $matches[4] . $matches[5];'), $text);
}
/* convert html tags to entities in indented code blocks*/
$text = preg_replace_callback('/(\\n )((?![\\*\\-]).*?)(\\n)(?!\\s)/ms', create_function('$matches', '$matches[0] = preg_replace("/(\\[\\[\\w+)>/ms","$1__IWIKI__",$matches[0]);
$matches[0] = preg_replace("/<(?!\\s)/ms", "<", $matches[0]);
$matches[0] = preg_replace("/(?<!\\s)>/ms", ">", $matches[0]);
$matches[0] = preg_replace("/__IWIKI__/ms", ">", $matches[0]);
return $matches[0]; '), $text);
$pos = strpos($text, '<');
if ($pos !== false) {
$text = preg_replace_callback('/(<nowiki>)(.*?)(<\\/nowiki>)/ms', create_function('$matches', '$needles = array("[","]", "/", ".", "*", "_","\'","<",">","%", "{", "}", "\\\\");
$replacements = array("[","]","/", ".", "*", "_", "'", "<",">","%", "{","}", "\");
$matches[2] = str_replace($needles, $replacements, $matches[2]);
return $matches[1] . $matches[2] . $matches[3];'), $text);
$text = preg_replace_callback('/<(code|file)(.*?)(>)(.*?)(<\\/\\1>)/ms', create_function('$matches', 'if(preg_match("/\\w+/",$matches[2])) {
$matches[4] = str_replace("CHEVRONescC", ">>",$matches[4]);
$matches[4] = str_replace("CHEVRONescO", "<<",$matches[4]);
$matches[4] = preg_replace("/<(?!\\s)/ms", "__GESHI_OPEN__", $matches[4]);
}
else {
if( preg_match("/MULTI/",$matches[0])) {
$open = "< ";
$close = " >";
}
else {
$open = "<";
$close = ">";
}
$matches[4] = preg_replace("/<(?!\\s)/ms", $open, $matches[4]);
$matches[4] = preg_replace("/(?<!\\s)>/ms", $close, $matches[4]);
}
$matches[4] = str_replace("\\"", "__GESHI_QUOT__", $matches[4]);
return "<" . $matches[1] . $matches[2] . $matches[3] . $matches[4] . $matches[5];'), $text);
/* \n_fckg_NPBBR_\n: the final \n prevents this from iterfering with next in line markups
-- in particular tables which require a new line and margin left
this may leave an empty paragraph in the xhtml, which is removed below
*/
$text = preg_replace('/<\\/(code|file)>(\\s*)(?=[^\\w])(\\s*)/m', "</\$1>\n_fckg_NPBBR_\n\$2", $text);
$text = preg_replace_callback('/(\\|\\s*)(<code>|<file>)(.*?)(<\\/code>|<\\/file>)\\n_fckg_NPBBR_(?=.*?\\|)/ms', create_function('$matches', '$matches[2] = preg_replace("/<code>/ms", "TPRE_CODE", $matches[2]);
$matches[2] = preg_replace("/<file>/ms", "TPRE_FILE", $matches[2]);
$matches[4] = "TPRE_CLOSE";
//.........这里部分代码省略.........
示例12: getTemplates
/**
* @param $fields
* @param $tpl
* @param $runas
* @return string template
*/
function getTemplates($fields, $tpl, $runas)
{
global $USERINFO;
global $conf;
if ($tpl == '_') {
// use namespace template
if (!isset($this->templates[$this->pagename])) {
$this->templates[$this->pagename] = pageTemplate(array($this->pagename));
}
} elseif ($tpl !== '!') {
$tpl = $this->replaceDefault($tpl);
// Namespace link
if ($runas) {
// Hack user credentials.
$backup = array($_SERVER['REMOTE_USER'], $USERINFO['grps']);
$_SERVER['REMOTE_USER'] = $runas;
$USERINFO['grps'] = array();
}
$t_pages = array();
search($t_pages, $conf['datadir'], 'search_universal', array('depth' => 0, 'listfiles' => true, 'showhidden' => true), str_replace(':', '/', getNS($tpl)));
foreach ($t_pages as $t_page) {
$t_name = cleanID($t_page['id']);
$p_name = preg_replace('/^' . preg_quote_cb(cleanID($tpl)) . '($|:)/', $this->pagename . '$1', $t_name);
if ($p_name === $t_name) {
// When using a single-page template, ignore other pages
// in the same namespace.
continue;
}
if (!isset($this->templates[$p_name])) {
// load page data and do default pattern replacements like
// namespace templates do
$data = array('id' => $p_name, 'tpl' => rawWiki($t_name), 'doreplace' => true);
parsePageTemplate($data);
$this->templates[$p_name] = $this->replace(array('__lang__' => $this->patterns['__lang__'], '__trans__' => $this->patterns['__trans__']), array('__lang__' => $this->values['__lang__'], '__trans__' => $this->values['__trans__']), $data['tpl'], false);
}
}
if ($runas) {
/* Restore user credentials. */
list($_SERVER['REMOTE_USER'], $USERINFO['grps']) = $backup;
}
}
return $tpl;
}