本文整理汇总了PHP中page_exists函数的典型用法代码示例。如果您正苦于以下问题:PHP page_exists函数的具体用法?PHP page_exists怎么用?PHP page_exists使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了page_exists函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例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());
}
}
示例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)));
}
示例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();
}
示例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));
}
示例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");
}
示例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));
}
示例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;
}
示例9: tpl_navigation
/**
* Prints the navigation
*
* @author Michael Klier <chi@chimeric.de>
*/
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>';
}
示例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');
}
}
示例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);
}
示例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;
}
示例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;
}
示例14: handle_ajax_call
/**
* Handles the AJAX calls
*
* @author Michael Klier <chi@chimeric.de>
*/
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))));
}
}
}
}
}
示例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 <tnharris@whoopdedo.org>
*/
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;
}
//.........这里部分代码省略.........