本文整理汇总了PHP中page_exists函数的典型用法代码示例。如果您正苦于以下问题:PHP page_exists函数的具体用法?PHP page_exists怎么用?PHP page_exists使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了page_exists函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: page_clear_background_img
/**
* clear the page's current background image
*
* @param array $args arguments
* key 'page' is the page (i.e. page.rev)
* @return array response
*/
function page_clear_background_img($args)
{
if (!isset($args['page'])) {
return response('Required argument "page" missing', 400);
}
if (!page_exists($args['page'])) {
return response('Page ' . quot($args['page']) . ' does not exist', 400);
}
load_modules('glue');
$obj = load_object(array('name' => $args['page'] . '.page'));
if ($obj['#error']) {
// page object does not exist, hence no background image to clear
return response(true);
} else {
$obj = $obj['#data'];
}
if (!empty($obj['page-background-file'])) {
// delete file
delete_upload(array('pagename' => array_shift(expl('.', $args['page'])), 'file' => $obj['page-background-file'], 'max_cnt' => 1));
// and remove attributes
return object_remove_attr(array('name' => $obj['name'], 'attr' => array('page-background-file', 'page-background-mime')));
} else {
return response(true);
}
}
开发者ID:danielfogarty,项目名称:damp,代码行数:32,代码来源:module_page.inc.php
示例2: saveData
/**
* Saves data for a given page (creates a new revision)
*
* If this call succeeds you can assume your data has either been saved or it was
* not necessary to save it because the data already existed in the wanted form or
* the given schemas are no longer assigned to that page.
*
* Important: You have to check write permissions for the given page before calling
* this function yourself!
*
* this duplicates a bit of code from entry.php - we could also fake post data and let
* entry handle it, but that would be rather unclean and might be problematic when multiple
* calls are done within the same request.
*
* @todo should this try to lock the page?
*
*
* @param string $page
* @param array $data ('schema' => ( 'fieldlabel' => 'value', ...))
* @param string $summary
* @throws StructException
*/
public function saveData($page, $data, $summary = '')
{
$page = cleanID($page);
$summary = trim($summary);
if (!$summary) {
$summary = $this->getLang('summary');
}
if (!page_exists($page)) {
throw new StructException("Page does not exist. You can not attach struct data");
}
// validate and see if anything changes
$valid = AccessDataValidator::validateDataForPage($data, $page, $errors);
if ($valid === false) {
throw new StructException("Validation failed:\n%s", join("\n", $errors));
}
if (!$valid) {
return;
}
// empty array when no changes were detected
$newrevision = self::createPageRevision($page, $summary);
// save the provided data
$assignments = new Assignments();
foreach ($valid as $v) {
$v->saveData($newrevision);
// make sure this schema is assigned
$assignments->assignPageSchema($page, $v->getAccessTable()->getSchema()->getTable());
}
}
开发者ID:cosmocode,项目名称:dokuwiki-plugin-struct,代码行数:50,代码来源:helper.php
示例3: handle_output
/**
* Appends the instruction to render our syntax output component to each page
* after the first found headline or the very begining if no headline was found
*
* @param Doku_Event $event
* @param $param
*/
public function handle_output(Doku_Event $event, $param)
{
global $ID;
if ($this->lastread != $ID) {
return;
}
// avoid nested calls
$this->lastread = '';
if (!page_exists($ID)) {
return;
}
$ins = -1;
$pos = 0;
foreach ($event->data->calls as $num => $call) {
// try to find the first header
if ($call[0] == 'header') {
$pos = $call[2];
$ins = $num;
break;
}
// abort when after we looked at the first 150 bytes
if ($call[3] > 150) {
break;
}
}
// insert our own call after the found position
array_splice($event->data->calls, $ins + 1, 0, array(array('plugin', array('struct_output', array('pos' => $pos), DOKU_LEXER_SPECIAL, ''), $pos)));
}
开发者ID:cosmocode,项目名称:dokuwiki-plugin-struct,代码行数:35,代码来源:output.php
示例4: controller_revisions
function controller_revisions($args)
{
page_canonical($args[0][0]);
$page = $args[0][0];
if (!page_exists($page)) {
hotglue_error(404);
}
// get all revisions of page and determine the current revision's index
load_modules('glue');
$a = expl('.', $page);
$revs = revisions_info(array('pagename' => $a[0], 'sort' => 'time'));
$revs = $revs['#data'];
$cur_rev = false;
for ($i = 0; $i < count($revs); $i++) {
if ($revs[$i]['revision'] == $a[1]) {
$cur_rev = $i;
break;
}
}
if ($cur_rev === false) {
// we didn't find the current revision
hotglue_error(500);
}
default_html(true);
html_add_css(base_url() . 'modules/revisions_browser/revisions_browser.css');
if (USE_MIN_FILES) {
html_add_js(base_url() . 'modules/revisions_browser/revisions_browser.min.js');
} else {
html_add_js(base_url() . 'modules/revisions_browser/revisions_browser.js');
}
html_add_js_var('$.glue.page', $page);
$bdy =& body();
elem_attr($bdy, 'id', 'revisions');
render_page(array('page' => $page, 'edit' => false));
body_append('<div id="revisions_browser_ctrl">');
body_append('<div id="revisions_browser_prev">');
if ($cur_rev + 1 < count($revs)) {
body_append('<a href="' . base_url() . '?' . htmlspecialchars(urlencode($revs[$cur_rev + 1]['page']), ENT_COMPAT, 'UTF-8') . '/revisions">prev</a>');
}
body_append('</div><div id="revisions_browser_cur">');
if (substr($revs[$cur_rev]['revision'], 0, 5) == 'auto-') {
body_append(date('d M y H:i', $revs[$cur_rev]['time']));
} else {
body_append(htmlspecialchars($revs[$cur_rev]['revision'], ENT_NOQUOTES, 'UTF-8'));
}
body_append('<br>');
if ($a[1] == 'head') {
body_append('<a href="' . base_url() . '?' . htmlspecialchars(urlencode($page), ENT_COMPAT, 'UTF-8') . '/edit">back to editing mode</a>');
} else {
body_append('<a id="revisions_browser_revert_btn" href="#">revert</a>');
}
body_append('</div><div id="revisions_browser_next">');
if (0 < $cur_rev) {
body_append('<a href="' . base_url() . '?' . htmlspecialchars(urlencode($revs[$cur_rev - 1]['page']), ENT_COMPAT, 'UTF-8') . '/revisions">next</a>');
}
body_append('</div>');
body_append('</div>');
echo html_finalize();
}
开发者ID:danielfogarty,项目名称:damp,代码行数:59,代码来源:module_revisions_browser.inc.php
示例5: 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));
}
开发者ID:nadabenlahbib,项目名称:dokuwiki-pagemod,代码行数:62,代码来源:pagemod.php
示例6: onInitLangLoad
public function onInitLangLoad(Doku_Event $event, $param = null)
{
$id = getID();
if (page_exists($id)) {
return;
}
$page = $this->getActivity($id);
if ($page instanceof \SimpleXMLElement && $page->attributes()->redirect == 'true' && !empty($page->attributes()->new_id)) {
header("HTTP/1.1 301 Moved Permanently");
header("Location: " . wl($page->attributes()->new_id));
die;
}
// else just notify spiders page does not exist 404, instead of 200
header("HTTP/1.1 404 Not Found");
}
开发者ID:yurii-github,项目名称:dokuwiki-plugin-yktools,代码行数:15,代码来源:redirect.php
示例7: 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));
}
开发者ID:omusico,项目名称:isle-web-framework,代码行数:20,代码来源:functions.php
示例8: render
/**
* Create output
*
* @param string $format Renderer mode (supported modes: xhtml)
* @param Doku_Renderer $renderer The renderer
* @param array $data The data from the handler() function
* @return bool If rendering was successful.
*/
function render($format, Doku_Renderer $renderer, $data)
{
if ($format == 'metadata') {
return false;
}
if ($data[0] != DOKU_LEXER_SPECIAL) {
return false;
}
$hlp = plugin_load('helper', 'rating');
$list = $hlp->best($data[1]['lang'], $data[1]['startdate'], 20);
if ($data[1]['tag'] == 'ol') {
$renderer->listo_open();
} else {
$renderer->listu_open();
}
$num_items = 0;
foreach ($list as $item) {
if (auth_aclcheck($item['page'], '', null) < AUTH_READ) {
continue;
}
if (!page_exists($item['page'])) {
continue;
}
$num_items = $num_items + 1;
$renderer->listitem_open(1);
if (strpos($item['page'], ':') === false) {
$item['page'] = ':' . $item['page'];
}
$renderer->internallink($item['page']);
if ($data[1]['score'] === 'true') {
$renderer->cdata(' (' . $item['val'] . ')');
}
$renderer->listitem_close();
if ($num_items >= 10) {
break;
}
}
if ($data[1]['tag'] == 'ol') {
$renderer->listo_close();
} else {
$renderer->listu_close();
}
return true;
}
开发者ID:cosmocode,项目名称:dokuwiki-plugin-rating,代码行数:52,代码来源:syntax.php
示例9: tpl_navigation
/**
* Prints the navigation
*
* @author Michael Klier <[email protected]>
*/
function tpl_navigation()
{
global $ID;
global $conf;
$navpage = tpl_getConf('navigation_page');
print '<div class="navigation">' . DOKU_LF;
if (!page_exists($navpage)) {
if (@file_exists(DOKU_TPLINC . 'lang/' . $conf['lang'] . '/nonavigation.txt')) {
$out = p_render('xhtml', p_get_instructions(io_readFile(DOKU_TPLINC . 'lang/' . $conf['lang'] . '/nonavigation.txt')), $info);
} else {
$out = p_render('xhtml', p_get_instructions(io_readFile(DOKU_TPLINC . 'lang/en/nonavigation.txt')), $info);
}
$link = '<a href="' . wl($navpage) . '" class="wikilink2">' . $navpage . '</a>' . DOKU_LF;
print str_replace('LINK', $link, $out);
} else {
print p_wiki_xhtml($navpage);
}
print '</div>';
}
开发者ID:adri,项目名称:Dokuwiki-OS-X-Template,代码行数:24,代码来源:tpl_functions.php
示例10: alterLoginPageBefore
/**
* Alters login page via HTML_LOGINFORM_OUTPUT event
* @param $event
* @param $param
*/
public function alterLoginPageBefore($event, $param)
{
print '<div class="login container">' . NL;
$helpId = $this->getConf(self::CONF_HELP_PAGE);
global $conf;
if (!empty($conf['lang'])) {
$lang = $conf['lang'];
if (!empty($conf['plugin']['translation']['translations']) && preg_match("/{$lang}/", $conf['plugin']['translation']['translations'])) {
$helpId = ':' . $lang . $helpId;
}
}
if (page_exists($helpId)) {
print '<div class="login help">' . p_wiki_xhtml($helpId) . '</div>' . NL;
}
if (!empty($this->getConf(self::CONF_RENAME_LOCAL))) {
/** @var Doku_Form $form */
$form = $event->data;
$form->_content[0]['_legend'] = $this->getLang('login_local');
}
}
开发者ID:tomaskadlec,项目名称:dokuwiki-plugin-authhelp,代码行数:25,代码来源:action.php
示例11: handle
function handle()
{
if (!isset($_REQUEST['data_go']) || !checkSecurityToken()) {
return;
}
$sqlite = $this->dthlp->_getDB();
if (!$sqlite) {
return false;
}
$res = $sqlite->query("SELECT pid, page FROM pages");
$rows = $sqlite->res2arr($res);
$count = 0;
foreach ($rows as $row) {
if (!page_exists($row['page'])) {
$sqlite->query('DELETE FROM data WHERE pid = ?', $row['pid']);
$sqlite->query('DELETE FROM pages WHERE pid = ?', $row['pid']);
$count++;
}
}
msg(sprintf($this->getLang('pages_del'), $count), 1);
}
开发者ID:stretchyboy,项目名称:dokuwiki-plugin-data,代码行数:21,代码来源:clean.php
示例12: driver_getRecommendation
function driver_getRecommendation($lastJump)
{
$currentPage = $lastJump['page'];
if (isset($lastJump['section'])) {
$currentPage = $lastJump['page'] . '#' . sectionId($lastJump['section']) . '=' . $lastJump['section'];
}
$output = '';
$output .= '<div id=driver_recommendation class=driver_rbox>';
//$output .= '<table class=driver_rbox_table>';
//$output .= '<tr><td class=driver_rbox_table_title_column>Try these...</td></tr>';
//$output .= '<tr><td class=driver_rbox_table_column >';
if (!page_exists($currentPage)) {
$output .= '<div align="center" style="font-style:italic"> nowhere yet...</div>';
$output .= '</div>';
return $output;
}
error_log("currentPage: " . print_r($currentPage, true));
$recommend = driverdb_getMostNextSteps($currentPage);
error_log("recommend: " . print_r($recommend, true));
foreach ($recommend as $page => $count) {
unset($trailPage);
// is it section?
$pageParts = explode("#", $page);
if (sizeof($pageParts) > 1) {
//its section, then parse title
$sectionParts = explode("=", $pageParts[1]);
$trailPage['section'] = $sectionParts[1];
}
$trailPage['id'] = $pageParts[0];
$trailPage['name'] = trimPageTitle(get_first_heading($pageParts[0]), 40);
$output .= printTrailPage($trailPage, '_parent', '', '', 'trail_page_recommend', $count);
}
//$output .= '</td></tr>';
//$output .='</table>';
$output .= '</div>';
return $output;
}
开发者ID:nunoflores,项目名称:driver,代码行数:37,代码来源:recommend.php
示例13: checkPage
/**
* Check if the given page can be moved to the given destination
*
* @param $src
* @param $dst
* @return bool
*/
public function checkPage($src, $dst)
{
// Check we have rights to move this document
if (!page_exists($src)) {
msg(sprintf($this->getLang('notexist'), $src), -1);
return false;
}
if (auth_quickaclcheck($src) < AUTH_EDIT) {
msg(sprintf($this->getLang('norights'), $src), -1);
return false;
}
// Check file is not locked
// checklock checks if the page lock hasn't expired and the page hasn't been locked by another user
// the file exists check checks if the page is reported unlocked if a lock exists which means that
// the page is locked by the current user
if (checklock($src) !== false || @file_exists(wikiLockFN($src))) {
msg(sprintf($this->getLang('filelocked'), $src), -1);
return false;
}
// Has the document name and/or namespace changed?
if ($src == $dst) {
msg(sprintf($this->getLang('notchanged'), $src), -1);
return false;
}
// Check the page does not already exist
if (page_exists($dst)) {
msg(sprintf($this->getLang('exists'), $src, $dst), -1);
return false;
}
// Check if the current user can create the new page
if (auth_quickaclcheck($dst) < AUTH_CREATE) {
msg(sprintf($this->getLang('notargetperms'), $dst), -1);
return false;
}
return true;
}
开发者ID:kochichi,项目名称:dokuwiki-plugin-move,代码行数:43,代码来源:op.php
示例14: handle_ajax_call
/**
* Handles the AJAX calls
*
* @author Michael Klier <[email protected]>
*/
function handle_ajax_call(&$event, $param)
{
global $lang;
if ($event->data == 'snippet_preview' or $event->data == 'snippet_insert') {
$event->preventDefault();
$event->stopPropagation();
$id = cleanID($_REQUEST['id']);
if (page_exists($id)) {
if ($event->data == 'snippet_preview') {
if (auth_quickaclcheck($id) >= AUTH_READ) {
print p_wiki_xhtml($id);
} else {
print p_locale_xhtml('denied');
}
} elseif ($event->data == 'snippet_insert') {
if (auth_quickaclcheck($id) >= AUTH_READ) {
print "\n\n";
// always start on a new line (just to be safe)
print trim(preg_replace('/<snippet>.*?<\\/snippet>/s', '', io_readFile(wikiFN($id))));
}
}
}
}
}
开发者ID:houshuang,项目名称:folders2web,代码行数:29,代码来源:action.php
示例15: enhanced_idx_addPage
/**
* Adds/updates the search index for the given page
*
* Locking is handled internally.
*
* @param string $page name of the page to index
* @param boolean $verbose print status messages
* @param boolean $force force reindexing even when the index is up to date
* @return boolean the function completed successfully
* @author Tom N Harris <[email protected]>
*/
function enhanced_idx_addPage($page, $verbose = false, $force = false)
{
$idxtag = metaFN($page, '.indexed');
// check if page was deleted but is still in the index
if (!page_exists($page)) {
if (!@file_exists($idxtag)) {
if ($verbose) {
print "Indexer: {$page} does not exist, ignoring" . DOKU_LF;
}
return false;
}
$Indexer = enhanced_idx_get_indexer();
$result = $Indexer->deletePage($page);
if ($result === "locked") {
if ($verbose) {
print "Indexer: locked" . DOKU_LF;
}
return false;
}
@unlink($idxtag);
return $result;
}
// check if indexing needed
if (!$force && @file_exists($idxtag)) {
if (trim(io_readFile($idxtag)) == idx_get_version()) {
$last = @filemtime($idxtag);
if ($last > @filemtime(wikiFN($page))) {
if ($verbose) {
print "Indexer: index for {$page} up to date" . DOKU_LF;
}
return false;
}
}
}
$indexenabled = p_get_metadata($page, 'internal index', METADATA_RENDER_UNLIMITED);
if ($indexenabled === false) {
$result = false;
if (@file_exists($idxtag)) {
$Indexer = enhanced_idx_get_indexer();
$result = $Indexer->deletePage($page);
if ($result === "locked") {
if ($verbose) {
print "Indexer: locked" . DOKU_LF;
}
return false;
}
@unlink($idxtag);
}
if ($verbose) {
print "Indexer: index disabled for {$page}" . DOKU_LF;
}
return $result;
}
$Indexer = enhanced_idx_get_indexer();
$pid = $Indexer->getPID($page);
if ($pid === false) {
if ($verbose) {
print "Indexer: getting the PID failed for {$page}" . DOKU_LF;
}
return false;
}
$body = '';
$metadata = array();
$metadata['title'] = p_get_metadata($page, 'title', METADATA_RENDER_UNLIMITED);
if (($references = p_get_metadata($page, 'relation references', METADATA_RENDER_UNLIMITED)) !== null) {
$metadata['relation_references'] = array_keys($references);
} else {
$metadata['relation_references'] = array();
}
if (($media = p_get_metadata($page, 'relation media', METADATA_RENDER_UNLIMITED)) !== null) {
$metadata['relation_media'] = array_keys($media);
} else {
$metadata['relation_media'] = array();
}
$data = compact('page', 'body', 'metadata', 'pid');
$evt = new Doku_Event('INDEXER_PAGE_ADD', $data);
if ($evt->advise_before()) {
$data['body'] = $data['body'] . " " . rawWiki($page);
}
$evt->advise_after();
unset($evt);
extract($data);
$result = $Indexer->addPageWords($page, $body);
if ($result === "locked") {
if ($verbose) {
print "Indexer: locked" . DOKU_LF;
}
return false;
}
//.........这里部分代码省略.........
开发者ID:superdav42,项目名称:dokuwiki-enhancedindexer,代码行数:101,代码来源:Doku_Indexer_Enhanced.php
示例16: html_revisions
//.........这里部分代码省略.........
if ($media_id) {
$form->addElement(form_makeOpenTag('div'));
}
if (!$media_id) {
$form->addElement(form_makeOpenTag('span', array('class' => 'sum')));
$form->addElement(' – ');
$form->addElement(htmlspecialchars($INFO['sum']));
$form->addElement(form_makeCloseTag('span'));
}
$form->addElement(form_makeOpenTag('span', array('class' => 'user')));
if (!$media_id) {
$editor = $INFO['editor'];
} else {
$revinfo = getRevisionInfo($id, @filemtime(fullpath(mediaFN($id))), 1024, true);
if ($revinfo['user']) {
$editor = $revinfo['user'];
} else {
$editor = $revinfo['ip'];
}
}
$form->addElement(empty($editor) ? '(' . $lang['external_edit'] . ')' : editorinfo($editor));
$form->addElement(form_makeCloseTag('span'));
$form->addElement('(' . $lang['current'] . ')');
if ($media_id) {
$form->addElement(form_makeCloseTag('div'));
}
$form->addElement(form_makeCloseTag('div'));
$form->addElement(form_makeCloseTag('li'));
}
foreach ($revisions as $rev) {
$date = dformat($rev);
if (!$media_id) {
$info = getRevisionInfo($id, $rev, true);
$exists = page_exists($id, $rev);
} else {
$info = getRevisionInfo($id, $rev, true, true);
$exists = @file_exists(mediaFN($id, $rev));
}
if ($info['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT) {
$form->addElement(form_makeOpenTag('li', array('class' => 'minor')));
} else {
$form->addElement(form_makeOpenTag('li'));
}
$form->addElement(form_makeOpenTag('div', array('class' => 'li')));
if ($exists) {
$form->addElement(form_makeTag('input', array('type' => 'checkbox', 'name' => 'rev2[]', 'value' => $rev)));
} else {
$form->addElement('<img src="' . DOKU_BASE . 'lib/images/blank.gif" width="15" height="11" alt="" />');
}
$form->addElement(form_makeOpenTag('span', array('class' => 'date')));
$form->addElement($date);
$form->addElement(form_makeCloseTag('span'));
if ($exists) {
if (!$media_id) {
$href = wl($id, "rev={$rev},do=diff", false, '&');
} else {
$href = media_managerURL(array('image' => $id, 'rev' => $rev, 'mediado' => 'diff'), '&');
}
$form->addElement(form_makeOpenTag('a', array('href' => $href, 'class' => 'diff_link')));
$form->addElement(form_makeTag('img', array('src' => DOKU_BASE . 'lib/images/diff.png', 'width' => 15, 'height' => 11, 'title' => $lang['diff'], 'alt' => $lang['diff'])));
$form->addElement(form_makeCloseTag('a'));
if (!$media_id) {
$href = wl($id, "rev={$rev}", false, '&');
} else {
$href = media_managerURL(array('image' => $id, 'tab_details' => 'view', 'rev' => $rev), '&');
}
开发者ID:nefercheprure,项目名称:dokuwiki,代码行数:67,代码来源:html.php
示例17: _ft_pageLookup
function _ft_pageLookup(&$data)
{
// split out original parameters
$id = $data['id'];
if (preg_match('/(?:^| )@(\\w+)/', $id, $matches)) {
$ns = cleanID($matches[1]) . ':';
$id = str_replace($matches[0], '', $id);
}
$in_ns = $data['in_ns'];
$in_title = $data['in_title'];
$cleaned = cleanID($id);
$Indexer = idx_get_indexer();
$page_idx = $Indexer->getPages();
$pages = array();
if ($id !== '' && $cleaned !== '') {
foreach ($page_idx as $p_id) {
if (strpos($in_ns ? $p_id : noNSorNS($p_id), $cleaned) !== false) {
if (!isset($pages[$p_id])) {
$pages[$p_id] = p_get_first_heading($p_id, METADATA_DONT_RENDER);
}
}
}
if ($in_title) {
foreach ($Indexer->lookupKey('title', $id, '_ft_pageLookupTitleCompare') as $p_id) {
if (!isset($pages[$p_id])) {
$pages[$p_id] = p_get_first_heading($p_id, METADATA_DONT_RENDER);
}
}
}
}
if (isset($ns)) {
foreach (array_keys($pages) as $p_id) {
if (strpos($p_id, $ns) !== 0) {
unset($pages[$p_id]);
}
}
}
// discard hidden pages
// discard nonexistent pages
// check ACL permissions
foreach (array_keys($pages) as $idx) {
if (!isVisiblePage($idx) || !page_exists($idx) || auth_quickaclcheck($idx) < AUTH_READ) {
unset($pages[$idx]);
}
}
uksort($pages, 'ft_pagesorter');
return $pages;
}
开发者ID:ngharaibeh,项目名称:Methodikos,代码行数:48,代码来源:fulltext.php
示例18: p_get_metadata
/**
* returns the metadata of a page
*
* @param string $id The id of the page the metadata should be returned from
* @param string $key The key of the metdata value that shall be read (by default everything) - separate hierarchies by " " like "date created"
* @param int $render If the page should be rendererd - possible values:
* METADATA_DONT_RENDER, METADATA_RENDER_USING_SIMPLE_CACHE, METADATA_RENDER_USING_CACHE
* METADATA_RENDER_UNLIMITED (also combined with the previous two options),
* default: METADATA_RENDER_USING_CACHE
* @return mixed The requested metadata fields
*
* @author Esther Brunner <[email protected]>
* @author Michael Hamann <[email protected]>
*/
function p_get_metadata($id, $key = '', $render = METADATA_RENDER_USING_CACHE)
{
global $ID;
static $render_count = 0;
// track pages that have already been rendered in order to avoid rendering the same page
// again
static $rendered_pages = array();
// cache the current page
// Benchmarking shows the current page's metadata is generally the only page metadata
// accessed several times. This may catch a few other pages, but that shouldn't be an issue.
$cache = $ID == $id;
$meta = p_read_metadata($id, $cache);
if (!is_numeric($render)) {
if ($render) {
$render = METADATA_RENDER_USING_SIMPLE_CACHE;
} else {
$render = METADATA_DONT_RENDER;
}
}
// prevent recursive calls in the cache
static $recursion = false;
if (!$recursion && $render != METADATA_DONT_RENDER && !isset($rendered_pages[$id]) && page_exists($id)) {
$recursion = true;
$cachefile = new cache_renderer($id, wikiFN($id), 'metadata');
$do_render = false;
if ($render & METADATA_RENDER_UNLIMITED || $render_count < P_GET_METADATA_RENDER_LIMIT) {
if ($render & METADATA_RENDER_USING_SIMPLE_CACHE) {
$pagefn = wikiFN($id);
$metafn = metaFN($id, '.meta');
if (!@file_exists($metafn) || @filemtime($pagefn) > @filemtime($cachefile->cache)) {
$do_render = true;
}
} elseif (!$cachefile->useCache()) {
$do_render = true;
}
}
if ($do_render) {
++$render_count;
$rendered_pages[$id] = true;
$old_meta = $meta;
$meta = p_render_metadata($id, $meta);
// only update the file when the metadata has been changed
if ($meta == $old_meta || p_save_metadata($id, $meta)) {
// store a timestamp in order to make sure that the cachefile is touched
$cachefile->storeCache(time());
} elseif ($meta != $old_meta) {
msg('Unable to save metadata file. Hint: disk full; file permissions; safe_mode setting.', -1);
}
}
$recursion = false;
}
$val = $meta['current'];
// filter by $key
foreach (preg_split('/\\s+/', $key, 2, PREG_SPLIT_NO_EMPTY) as $cur_key) {
if (!isset($val[$cur_key])) {
return null;
}
$val = $val[$cur_key];
}
return $val;
}
开发者ID:nextghost,项目名称:dokuwiki,代码行数:75,代码来源:parserutils.php
示例19: _get_included_pages
/**
* Gives a list of pages for a given include statement
*
* @author Michael Hamann <[email protected]>
*/
function _get_included_pages($mode, $page, $sect, $parent_id, $flags) {
global $conf;
$pages = array();
switch($mode) {
case 'namespace':
$page = cleanID($page);
$ns = utf8_encodeFN(str_replace(':', '/', $page));
// depth is absolute depth, not relative depth, but 0 has a special meaning.
$depth = $flags['depth'] ? $flags['depth'] + substr_count($page, ':') + ($page ? 1 : 0) : 0;
search($pagearrays, $conf['datadir'], 'search_allpages', array('depth' => $depth), $ns);
if (is_array($pagearrays)) {
foreach ($pagearrays as $pagearray) {
if (!isHiddenPage($pagearray['id'])) // skip hidden pages
$pages[] = $pagearray['id'];
}
}
break;
case 'tagtopic':
if (!$this->taghelper)
$this->taghelper =& plugin_load('helper', 'tag');
if(!$this->taghelper) {
msg('You have to install the tag plugin to use this functionality!', -1);
return array();
}
$tag = $page;
$sect = '';
$pagearrays = $this->taghelper->getTopic('', null, $tag);
foreach ($pagearrays as $pagearray) {
$pages[] = $pagearray['id'];
}
break;
default:
$page = $this->_apply_macro($page);
resolve_pageid(getNS($parent_id), $page, $exists); // resolve shortcuts and clean ID
if (auth_quickaclcheck($page) >= AUTH_READ)
$pages[] = $page;
}
if (count($pages) > 1) {
if ($flags['order'] === 'id') {
if ($flags['rsort']) {
usort($pages, array($this, '_r_strnatcasecmp'));
} else {
natcasesort($pages);
}
} else {
$ordered_pages = array();
foreach ($pages as $page) {
$key = '';
switch ($flags['order']) {
case 'title':
$key = p_get_first_heading($page);
break;
case 'created':
$key = p_get_metadata($page, 'date created', METADATA_DONT_RENDER);
break;
case 'modified':
$key = p_get_metadata($page, 'date modified', METADATA_DONT_RENDER);
break;
case 'indexmenu':
$key = p_get_metadata($page, 'indexmenu_n', METADATA_RENDER_USING_SIMPLE_CACHE);
if ($key === null)
$key = '';
break;
case 'custom':
$key = p_get_metadata($page, 'include_n', METADATA_RENDER_USING_SIMPLE_CACHE);
if ($key === null)
$key = '';
break;
}
$key .= '_'.$page;
$ordered_pages[$key] = $page;
}
if ($flags['rsort']) {
uksort($ordered_pages, array($this, '_r_strnatcasecmp'));
} else {
uksort($ordered_pages, 'strnatcasecmp');
}
$pages = $ordered_pages;
}
}
$result = array();
foreach ($pages as $page) {
$exists = page_exists($page);
$result[] = array('id' => $page, 'exists' => $exists, 'parent_id' => $parent_id);
}
return $result;
}
开发者ID:neutrinog,项目名称:Door43,代码行数:94,代码来源:helper.php
示例20: get_pages
/**
* Adds all pages of a specific namespace to the pages array.
*
* @param pages pre-initialised pages array.
* @param ns Namespace in which to look for pages.
* @param depth Search depth.
* @param use_first_header (optional) Includes the first header as page title.
*/
function get_pages(&$pages, $ns, $depth = 0, $use_first_header = false)
{
global $conf;
// find pages
$search_results = array();
search($search_results, $conf['datadir'], 'search_universal', array('depth' => $depth, 'listfiles' => true, 'listdirs' => false, 'pagesonly' => true, 'skipacl' => true, 'firsthead' => true, 'meta' => true), str_replace(':', '/', $ns));
// Start page of the namespace
if ($ns && page_exists($ns)) {
// Add to the search results
$search_results[] = array('id' => $ns, 'ns' => getNS($ns), 'title' => p_get_first_heading($ns, false), 'size' => filesize(wikiFN($ns)), 'mtime' => filemtime(wikiFN($ns)), 'perm' => 16, 'type' => 'f', 'level' => 0, 'open' => 1);
}
// loop through the pages
while ($item = array_shift($search_results)) {
// Check that the user is allowed to read the page
if (auth_quickaclcheck($item['id']) > AUTH_READ) {
continue;
}
// Check that the user is allowed to read the page
if (auth_quickaclcheck($item['ns']) > AUTH_READ)
|
请发表评论