本文整理汇总了PHP中resolve_pageid函数的典型用法代码示例。如果您正苦于以下问题:PHP resolve_pageid函数的具体用法?PHP resolve_pageid怎么用?PHP resolve_pageid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了resolve_pageid函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* Handle the match
*/
function handle($match, $state, $pos, &$handler)
{
global $ID;
$match = substr($match, 9, -11);
// strip markup
list($flags, $match) = explode('>', $match, 2);
$flags = explode('&', substr($flags, 1));
$items = explode('*', $match);
$pages = array();
$c = count($items);
for ($i = 0; $i < $c; $i++) {
if (!preg_match('/\\[\\[(.+?)\\]\\]/', $items[$i], $match)) {
continue;
}
list($id, $title, $description) = explode('|', $match[1], 3);
list($id, $section) = explode('#', $id, 2);
if (!$id) {
$id = $ID;
}
resolve_pageid(getNS($ID), $id, $exists);
// page has an image title
if ($title && preg_match('/\\{\\{(.+?)\\}\\}/', $title, $match)) {
list($image, $title) = explode('|', $match[1], 2);
list($ext, $mime) = mimetype($image);
if (!substr($mime, 0, 5) == 'image') {
$image = '';
}
$pages[] = array('id' => $id, 'section' => cleanID($section), 'title' => trim($title), 'image' => trim($image), 'description' => trim($description), 'exists' => $exists);
// text title (if any)
} else {
$pages[] = array('id' => $id, 'section' => cleanID($section), 'title' => trim($title), 'description' => trim($description), 'exists' => $exists);
}
}
return array($flags, $pages);
}
示例2: getMainPageId
private function getMainPageId($ns)
{
$idMainPage = $ns['id'] . ':';
resolve_pageid('', $idMainPage, $exist);
//get the id of the main page of the ns
return $exist ? $idMainPage : null;
}
示例3: tpl_processStartPage
/**
* Table of content-function that will
* create a hierarchical TOC for the site (by namespace)
* and highlight the current page
* The startpage if it exists, will always
* be shown first in the menu
*/
function tpl_processStartPage($ns, $context)
{
// Check if a start page exists and add it first
global $conf;
$pageExists = false;
$startPageName = $conf['start'];
if ($ns == "") {
$startPageID = $startPageName;
} else {
$startPageID = $ns . ":" . $startPageName;
}
$startPagePath = $startPageID;
resolve_pageid($ns, $startPagePath, $pageExists);
if ($pageExists) {
// Check if page is visible
$perm = auth_quickaclcheck($startPageID);
if ($perm > 0) {
// Determine Page Title from first heading
$firstHeading = p_get_first_heading($startPageID);
if ($conf['useheading'] && !empty($firstHeading)) {
$linkName = $firstHeading;
} else {
$linkName = $startPageName;
}
// echo "<b>" . $conf['useheading'] ."</b>";
tpl_pageLinkCreate($startPageID, '<i class="icon-home"></i>' . $linkName, "tpl_processStartPage:{$context}");
}
}
}
示例4: internallink
function internallink($id, $name = NULL, $search = NULL, $returnonly = false)
{
global $ID;
// default name is based on $id as given
$default = $this->_simpleTitle($id);
// now first resolve and clean up the $id
resolve_pageid(getNS($ID), $id, $exists);
$name = $this->_getLinkTitle($name, $default, $isImage, $id);
if (!$isImage) {
if ($exists) {
$class = 'wikilink1';
} else {
$class = 'wikilink2';
}
} else {
$class = 'media';
}
//keep hash anchor
list($id, $hash) = split('#', $id, 2);
//prepare for formating
$link['class'] = $class;
$link['url'] = str_replace(':', '-', $id) . $this->ext;
$link['name'] = $name;
$link['title'] = str_replace(':', '-', $id) . $this->ext;
//keep hash
if ($hash) {
$link['url'] .= '#' . $hash;
}
$this->doc .= $this->_formatLink($link);
}
示例5: normalize
function normalize($value, $hint)
{
global $ID;
// fragment reference special case
if (!empty($hint) && substr($hint, -1) == '#') {
$value = $hint . $value;
resolve_pageid(getNS($hint), $value, $exists);
return $value;
}
$base = $hint ?: getNS($ID);
// check for local link, and prefix full page id
// (local links don't get resolved by resolve_pageid)
if (preg_match('/^#.+/', $value)) {
$value = $ID . $value;
}
// resolve page id with respect to selected base
resolve_pageid($base, $value, $exists);
// if the value is empty after resolving, it is a reference to the
// root starting page. (We can not put the emtpy string into the
// database as a normalized reference -- this will create problems)
if ($value == '') {
global $conf;
$value = $conf['start'];
}
return $value;
}
示例6: handleAjax
/**
* Autocompletion support for pages
*
* @return array
*/
public function handleAjax()
{
global $INPUT;
// check minimum length
$lookup = trim($INPUT->str('search'));
if (utf8_strlen($lookup) < $this->config['autocomplete']['mininput']) {
return array();
}
// results wanted?
$max = $this->config['autocomplete']['maxresult'];
if ($max <= 0) {
return array();
}
// lookup with namespace and postfix applied
$namespace = $this->config['autocomplete']['namespace'];
if ($namespace) {
// namespace may be relative, resolve in current context
$namespace .= ':foo';
// resolve expects pageID
resolve_pageid($INPUT->str('ns'), $namespace, $exists);
$namespace = getNS($namespace);
}
$postfix = $this->config['autocomplete']['postfix'];
if ($namespace) {
$lookup .= ' @' . $namespace;
}
$data = ft_pageLookup($lookup, true, $this->config['usetitles']);
if (!count($data)) {
return array();
}
// this basically duplicates what we do in ajax_qsearch()
$result = array();
$counter = 0;
foreach ($data as $id => $title) {
if ($this->config['usetitles']) {
$name = $title . ' (' . $id . ')';
} else {
$ns = getNS($id);
if ($ns) {
$name = noNS($id) . ' (' . $ns . ')';
} else {
$name = $id;
}
}
// check suffix
if ($postfix && substr($id, -1 * strlen($postfix)) != $postfix) {
continue;
// page does not end in postfix, don't suggest it
}
$result[] = array('label' => $name, 'value' => $id);
$counter++;
if ($counter > $max) {
break;
}
}
return $result;
}
示例7: test_resolve_pageid_empty_homepage
/**
* Empty page on homepage should resolve to start page
*/
function test_resolve_pageid_empty_homepage()
{
global $ID;
$ID = '';
global $conf;
$conf['start'] = 'someverystrangestartname';
$ns = '';
$page = '';
$exist = true;
resolve_pageid($ns, $page, $exist);
$this->assertEquals($page, $conf['start']);
}
示例8: handle
/**
* Handler to prepare matched data for the rendering process
*
* @param string $match The text matched by the patterns
* @param int $state The lexer state for the match
* @param int $pos The character position of the matched text
* @param Doku_Handler $handler The Doku_Handler object
* @return bool|array Return an array with all data you want to use in render, false don't add an instruction
*/
public function handle($match, $state, $pos, Doku_Handler $handler)
{
global $ID;
$ns = substr($match, 8, strpos($match, '|') - 8);
$id = $ns . ':start';
resolve_pageid(getNS($ID), $id, $exists);
$ns = getNS($id);
$title = substr($match, strpos($match, '|') + 1, -2);
$link = '?do=export_pdfns&book_ns=' . $ns . '&book_title=' . $title;
$title = substr($title, 0, strpos($title, '&'));
return array('link' => $link, 'title' => sprintf($this->getLang('export_ns'), $ns, $title), $state, $pos);
}
示例9: run
/**
* Handle the user input [required]
*
* @param helper_plugin_bureaucracy_field[] $fields the list of fields in the form
* @param string $thanks the thank you message as defined in the form
* or default one. Might be modified by the action
* before returned
* @param array $argv additional arguments passed to the action
* @return bool|string false on error, $thanks on success
*/
public function run($fields, $thanks, $argv)
{
global $ID;
// prepare replacements
$this->prepareNamespacetemplateReplacements();
$this->prepareDateTimereplacements();
$this->prepareLanguagePlaceholder();
$this->prepareNoincludeReplacement();
$this->prepareFieldReplacements($fields);
//handle arguments
$page_to_modify = array_shift($argv);
if ($page_to_modify === '_self') {
# shortcut to modify the same page as the submitter
$page_to_modify = $ID;
} else {
//resolve against page which contains the form
resolve_pageid(getNS($ID), $page_to_modify, $ignored);
}
$template_section_id = cleanID(array_shift($argv));
if (!page_exists($page_to_modify)) {
msg(sprintf($this->getLang('e_pagenotexists'), html_wikilink($page_to_modify)), -1);
return false;
}
// check auth
//
// This is an important point. In order to be able to modify a page via this method ALL you need is READ access to the page
// This is good for admins to be able to only allow people to modify a page via a certain method. If you want to protect the page
// from people to WRITE via this method, deny access to the form page.
$auth = $this->aclcheck($page_to_modify);
// runas
if ($auth < AUTH_READ) {
msg($this->getLang('e_denied'), -1);
return false;
}
// fetch template
$template = rawWiki($page_to_modify);
if (empty($template)) {
msg(sprintf($this->getLang('e_template'), $page_to_modify), -1);
return false;
}
// do the replacements
$template = $this->updatePage($template, $template_section_id);
if (!$template) {
msg(sprintf($this->getLang('e_failedtoparse'), $page_to_modify), -1);
return false;
}
// save page
saveWikiText($page_to_modify, $template, sprintf($this->getLang('summary'), $ID));
//thanks message with redirect
$link = wl($page_to_modify);
return sprintf($this->getLang('pleasewait'), "<script type='text/javascript' charset='utf-8'>location.replace('{$link}')</script>", html_wikilink($page_to_modify));
}
示例10: render
function render($format, &$renderer, $data)
{
if ($format != 'xhtml') {
return;
}
global $ID;
$svg_wiki_page = trim(substr($data[1], 6, -2));
//name of wiki page containing SVG image
resolve_pageid(getNS($ID), $svg_wiki_page, $exists);
//resolve relative IDs
//detect image size for stupid browsers (like firefox) - ugly (fails if svg does not contain information about it's size)
$svg_dimensions = '';
preg_match('/width="[0-9]+" height="[0-9]+"/', $data[1] . rawWiki($svg_wiki_page), $_);
if (isset($_[0])) {
$svg_dimensions = $_[0];
}
// Check alignment
$ralign = (bool) preg_match('/^\\{\\{ /', $data[1]);
$lalign = (bool) preg_match('/ \\}\\}$/', $data[1]);
switch (true) {
case $lalign & $ralign:
$align = 'center';
break;
case $ralign:
$align = 'right';
break;
case $lalign:
$align = 'left';
break;
default:
$align = '';
}
if ($data[0] === '<svg') {
$svgenc = $this->svg_base64_encode($data[1]);
$renderer->doc .= $this->svg_format_embed($svgenc, 'inline-svg@' . $ID, $svg_dimensions);
return true;
}
if ($data[0] === '{{sv' || $data[0] === '{{ s') {
$svglink = exportlink($svg_wiki_page, 'svg');
$renderer->doc .= $this->svg_format_embed($svglink, 'image:' . htmlspecialchars($svg_wiki_page), $svg_dimensions, $align);
$renderer->doc .= '<br /><small>' . html_wikilink($svg_wiki_page, 'svg@' . $svg_wiki_page) . '</small>';
return true;
}
if ($data[0] === '{{SV' || $data[0] === '{{ S') {
$svgenc = $this->svg_base64_encode(rawWiki($svg_wiki_page));
$renderer->doc .= $this->svg_format_embed($svgenc, 'image:' . htmlspecialchars($svg_wiki_page), $svg_dimensions, $align);
$renderer->doc .= '<br /><small>' . html_wikilink($svg_wiki_page, 'SVG@' . $svg_wiki_page) . '</small>';
return true;
}
}
示例11: getNamespaceFromID
/**
* Returns an utf8 encoded Namespace for a Page and input Namespace
* @param $NS
* @param $PAGE
*/
function getNamespaceFromID($NS, &$PAGE)
{
global $conf;
// Check current page - if its an NS add the startpage
$clean = true;
resolve_pageid(getNS($NS), $NS, $clean);
if (!page_exists($NS) && array_pop(explode(':', $NS)) != strtolower($conf['start'])) {
// Compare to lowercase since clean lowers it.
$NS .= ':' . $conf['start'];
resolve_pageid(getNS($NS), $NS, $clean);
}
$PAGE = noNS($NS);
$NS = getNS($NS);
return utf8_encodeFN(str_replace(':', '/', $NS));
}
示例12: handle
/**
* Handler to prepare matched data for the rendering process
*/
function handle($match, $state, $pos, &$handler)
{
global $ID;
if ($match == '~~BACKLINKS~~') {
//check for deprecated syntax
$match = $ID;
} else {
$match = substr($match, 12, -2);
//strip {{backlinks> from start and }} from end
$match = $match == '.' ? $ID : $match;
if (strstr($match, ".:")) {
resolve_pageid(getNS($ID), $match, $exists);
}
}
return array($match);
}
示例13: _normalize_internallink
/**
* Normalizes an internal link.
*/
function _normalize_internallink($instruction)
{
global $ID;
// split off query string
$parts = explode('?', $instruction[0], 2);
$id = $parts[0];
list($id, $hash) = explode('#', $id, 2);
// normalize selflink
if ($id === '') {
$id = $ID;
}
// actually resolve the page
resolve_pageid(getNS($ID), $id, $exists);
// render the link
return $this->_linkSyntax($instruction, $id . '#' . $hash);
}
示例14: handle
/**
* Handler to prepare matched data for the rendering process.
* @see DokuWiki_Syntax_Plugin::handle()
*/
function handle($match, $state, $pos, &$handler)
{
// Take the id of the source
// It can be a rendering of a sidebar
global $INFO;
global $ID;
$id = $ID;
// If it's a sidebar, get the original id.
if ($INFO != null) {
$id = $INFO['id'];
}
$match = substr($match, 12, -2);
//strip {{backlinks> from start and }} from end
$match = $match == '.' ? $id : $match;
if (strstr($match, ".:")) {
resolve_pageid(getNS($id), $match, $exists);
}
return array($match);
}
示例15: dw_internal_links
function dw_internal_links($page)
{
global $conf;
$instructions = p_get_instructions(file_get_contents($page['file']));
$links = array();
$cns = getNS($page['id']);
$exists = false;
foreach ($instructions as $ins) {
if ($ins[0] == 'internallink' || $conf['camelcase'] && $ins[0] == 'camelcaselink') {
$mid = $ins[1][0];
resolve_pageid($cns, $mid, $exists);
if (!$exists) {
list($mid) = explode('#', $mid);
//record pages without hashs
$links[] = $mid;
}
}
}
return $links;
}