当前位置: 首页>>代码示例>>PHP>>正文


PHP WikiPage::exists方法代码示例

本文整理汇总了PHP中WikiPage::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP WikiPage::exists方法的具体用法?PHP WikiPage::exists怎么用?PHP WikiPage::exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WikiPage的用法示例。


在下文中一共展示了WikiPage::exists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getParserOutput

 /**
  * Lightweight method to get the parser output for a page, checking the parser cache
  * and so on. Doesn't consider most of the stuff that WikiPage::view is forced to
  * consider, so it's not appropriate to use there.
  *
  * @since 1.16 (r52326) for LiquidThreads
  *
  * @param $oldid mixed integer Revision ID or null
  * @param $user User The relevant user
  * @return ParserOutput or false if the given revsion ID is not found
  */
 public function getParserOutput($oldid = null, User $user = null)
 {
     global $wgEnableParserCache, $wgUser;
     $user = is_null($user) ? $wgUser : $user;
     wfProfileIn(__METHOD__);
     // Should the parser cache be used?
     $useParserCache = $wgEnableParserCache && $user->getStubThreshold() == 0 && $this->mPage->exists() && $oldid === null;
     wfDebug(__METHOD__ . ': using parser cache: ' . ($useParserCache ? 'yes' : 'no') . "\n");
     if ($user->getStubThreshold()) {
         wfIncrStats('pcache_miss_stub');
     }
     if ($useParserCache) {
         $parserOutput = ParserCache::singleton()->get($this, $this->mPage->getParserOptions());
         if ($parserOutput !== false) {
             wfProfileOut(__METHOD__);
             return $parserOutput;
         }
     }
     // Cache miss; parse and output it.
     if ($oldid === null) {
         $text = $this->mPage->getRawText();
     } else {
         $rev = Revision::newFromTitle($this->getTitle(), $oldid);
         if ($rev === null) {
             wfProfileOut(__METHOD__);
             return false;
         }
         $text = $rev->getText();
     }
     wfProfileOut(__METHOD__);
     return $this->getOutputFromWikitext($text, $useParserCache);
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:43,代码来源:Article.php

示例2: MWException

 /**
  * Constructor
  *
  * @param WikiPage $page Page we are updating
  * @throws MWException
  */
 function __construct(WikiPage $page)
 {
     parent::__construct(false);
     // no implicit transaction
     $this->mPage = $page;
     if (!$page->exists()) {
         throw new MWException("Page ID not known, perhaps the page doesn't exist?");
     }
 }
开发者ID:jpena88,项目名称:mediawiki-dokku-deploy,代码行数:15,代码来源:LinksDeletionUpdate.php

示例3: filter_antispam

function filter_antispam($formatter, $value, $options)
{
    global $Config;
    $blacklist_pages = array('BadContent', 'LocalBadContent');
    $whitelist_pages = array('GoodContent', 'LocalGoodContent');
    if (!in_array($formatter->page->name, $blacklist_pages) and !in_array($formatter->page->name, $whitelist_pages)) {
        $badcontents_file = !empty($options['.badcontents']) ? $options['.badcontents'] : $Config['badcontents'];
        if (!file_exists($badcontents_file)) {
            return $value;
        }
        $badcontent = file_get_contents($badcontents_file);
        foreach ($blacklist_pages as $list) {
            $p = new WikiPage($list);
            if ($p->exists()) {
                $badcontent .= $p->get_raw_body();
            }
        }
        if (!$badcontent) {
            return $value;
        }
        $badcontents = explode("\n", $badcontent);
        $pattern[0] = '';
        $i = 0;
        foreach ($badcontents as $line) {
            if (isset($line[0]) and $line[0] == '#') {
                continue;
            }
            $line = preg_replace('/[ ]*#.*$/', '', $line);
            $test = @preg_match("/{$line}/i", "");
            if ($test === false) {
                $line = preg_quote($line, '/');
            }
            if ($line) {
                $pattern[$i] .= $line . '|';
            }
            if (strlen($pattern[$i]) > 4000) {
                $i++;
                $pattern[$i] = '';
            }
        }
        for ($k = 0; $k <= $i; $k++) {
            $pattern[$k] = '/(' . substr($pattern[$k], 0, -1) . ')/i';
        }
        #foreach ($whitelist_pages as $list) {
        #    $p=new WikiPage($list);
        #    if ($p->exists()) $goodcontent.=$p->get_raw_body();
        #}
        #$goodcontents=explode("\n",$goodcontent);
        return preg_replace($pattern, "''''''[[HTML(<span class='blocked'>)]]\\1[[HTML(</span>)]]''''''", $value);
    }
    return $value;
}
开发者ID:ahastudio,项目名称:moniwiki,代码行数:52,代码来源:antispam.php

示例4: elseif

 /**
  * @param WikiPage $page Page we are updating
  * @param integer|null $pageId ID of the page we are updating [optional]
  * @throws MWException
  */
 function __construct(WikiPage $page, $pageId = null)
 {
     parent::__construct(false);
     // no implicit transaction
     $this->page = $page;
     if ($page->exists()) {
         $this->pageId = $page->getId();
     } elseif ($pageId) {
         $this->pageId = $pageId;
     } else {
         throw new MWException("Page ID not known, perhaps the page doesn't exist?");
     }
 }
开发者ID:mb720,项目名称:mediawiki,代码行数:18,代码来源:LinksDeletionUpdate.php

示例5: elseif

 /**
  * @param WikiPage $page Page we are updating
  * @param integer|null $pageId ID of the page we are updating [optional]
  * @param string|null $timestamp TS_MW timestamp of deletion
  * @throws MWException
  */
 function __construct(WikiPage $page, $pageId = null, $timestamp = null)
 {
     parent::__construct();
     $this->page = $page;
     if ($pageId) {
         $this->pageId = $pageId;
         // page ID at time of deletion
     } elseif ($page->exists()) {
         $this->pageId = $page->getId();
     } else {
         throw new InvalidArgumentException("Page ID not known. Page doesn't exist?");
     }
     $this->timestamp = $timestamp ?: wfTimestampNow();
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:20,代码来源:LinksDeletionUpdate.php

示例6: createPage

 protected function createPage($page, $text, $model = null)
 {
     if (is_string($page)) {
         $page = Title::newFromText($page);
     }
     if ($page instanceof Title) {
         $page = new WikiPage($page);
     }
     if ($page->exists()) {
         $page->doDeleteArticle("done");
     }
     $page->doEdit($text, "testing", EDIT_NEW);
     return $page;
 }
开发者ID:Jobava,项目名称:diacritice-meta-repo,代码行数:14,代码来源:RevisionStorageTest.php

示例7: createPage

 protected function createPage($page, $text, $model = null)
 {
     if (is_string($page)) {
         if (!preg_match('/:/', $page) && ($model === null || $model === CONTENT_MODEL_WIKITEXT)) {
             $ns = $this->getDefaultWikitextNS();
             $page = MWNamespace::getCanonicalName($ns) . ':' . $page;
         }
         $page = Title::newFromText($page);
     }
     if ($page instanceof Title) {
         $page = new WikiPage($page);
     }
     if ($page->exists()) {
         $page->doDeleteArticle("done");
     }
     $content = ContentHandler::makeContent($text, $page->getTitle(), $model);
     $page->doEditContent($content, "testing", EDIT_NEW);
     return $page;
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:19,代码来源:RevisionStorageTest.php

示例8: onArticleSaveComplete

 /**
  * Clear the cache when the page is edited
  */
 public static function onArticleSaveComplete(WikiPage &$page, &$user, $text, $summary, $minoredit, $watchthis, $sectionanchor, &$flags, $revision, &$status, $baseRevId)
 {
     /**
      * @var $service ArticleService
      */
     if ($page->exists()) {
         $id = $page->getId();
         F::app()->wg->Memc->delete(self::getCacheKey($id));
         if (array_key_exists($id, self::$localCache)) {
             unset(self::$localCache[$id]);
         }
     }
     return true;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:17,代码来源:ArticleService.class.php

示例9: macro_FullSearch


//.........这里部分代码省略.........
        } else {
            $cneedle = _preg_search_escape($needle);
            $test = validate_needle($cneedle);
            if ($test === false) {
                $needle = preg_quote($needle);
            } else {
                $needle = $cneedle;
            }
        }
    }
    $test3 = trim($needle);
    if (!isset($test3[0])) {
        $opts['msg'] = _("Empty expression");
        return $form;
    }
    # set arena and sid
    if (!empty($opts['backlinks'])) {
        $arena = 'backlinks';
    } else {
        if (!empty($opts['keywords'])) {
            $arena = 'keywords';
        } else {
            $arena = 'fullsearch';
        }
    }
    if ($arena == 'fullsearch') {
        $sid = md5($value . 'v' . $offset);
    } else {
        $sid = $value;
    }
    $delay = !empty($DBInfo->default_delaytime) ? $DBInfo->default_delaytime : 0;
    # retrieve cache
    $fc = new Cache_text($arena);
    if (!$formatter->refresh and $fc->exists($sid)) {
        $data = $fc->fetch($sid);
        if (!empty($opts['backlinks'])) {
            // backlinks are not needed to check it.
            $hits = $data;
            // also fetch redirects
            $r = new Cache_Text('redirects');
            $redirects = $r->fetch($sid);
        } else {
            if (is_array($data)) {
                # check cache mtime
                $cmt = $fc->mtime($sid);
                # check update or not
                $dmt = $DBInfo->mtime();
                if ($dmt > $cmt + $delay) {
                    # XXX crude method
                    $data = array();
                } else {
                    # XXX smart but incomplete method
                    if (isset($data['hits'])) {
                        $hits =& $data['hits'];
                    } else {
                        $hits =& $data;
                    }
                    foreach ($hits as $p => $c) {
                        $mp = $DBInfo->getPage($p);
                        $mt = $mp->mtime();
                        if ($mt > $cmt + $delay) {
                            $data = array();
                            break;
                        }
                    }
                }
开发者ID:reviforks,项目名称:moniwiki,代码行数:67,代码来源:FullSearch.php

示例10: testExists

 /**
  * @covers WikiPage::exists
  */
 public function testExists()
 {
     $page = $this->newPage("WikiPageTest_testExists");
     $this->assertFalse($page->exists());
     # -----------------
     $this->createPage($page, "some text", CONTENT_MODEL_WIKITEXT);
     $this->assertTrue($page->exists());
     $page = new WikiPage($page->getTitle());
     $this->assertTrue($page->exists());
     # -----------------
     $page->doDeleteArticle("done testing");
     $this->assertFalse($page->exists());
     $page = new WikiPage($page->getTitle());
     $this->assertFalse($page->exists());
 }
开发者ID:Habatchii,项目名称:wikibase-for-mediawiki,代码行数:18,代码来源:WikiPageTest.php

示例11: latex_ref

function latex_ref($page, $appearance, $hover = '')
{
    global $db;
    if ($hover != '') {
        $hover = ' title="' . $hover . '"';
    }
    $p = new WikiPage($db, $page);
    if ($p->exists()) {
        //    return '<a href="' . viewURL($page) . '"' . $hover . '>' . $page . '</a>';
        return '\\textbf{' . $page . '}';
    } else {
        return '\\textbf{' . $appearance . $hover . "}";
    }
}
开发者ID:BackupTheBerlios,项目名称:hpt-obm-svn,代码行数:14,代码来源:latex.php

示例12: internalAttemptSave


//.........这里部分代码省略.........
         } elseif (!$wgUser->isAllowed('editcontentmodel')) {
             $status->setResult(false, self::AS_NO_CHANGE_CONTENT_MODEL);
             return $status;
         }
         $changingContentModel = true;
         $oldContentModel = $this->mTitle->getContentModel();
     }
     if ($this->changeTags) {
         $changeTagsStatus = ChangeTags::canAddTagsAccompanyingChange($this->changeTags, $wgUser);
         if (!$changeTagsStatus->isOK()) {
             $changeTagsStatus->value = self::AS_CHANGE_TAG_ERROR;
             return $changeTagsStatus;
         }
     }
     if (wfReadOnly()) {
         $status->fatal('readonlytext');
         $status->value = self::AS_READ_ONLY_PAGE;
         return $status;
     }
     if ($wgUser->pingLimiter() || $wgUser->pingLimiter('linkpurge', 0)) {
         $status->fatal('actionthrottledtext');
         $status->value = self::AS_RATE_LIMITED;
         return $status;
     }
     # If the article has been deleted while editing, don't save it without
     # confirmation
     if ($this->wasDeletedSinceLastEdit() && !$this->recreate) {
         $status->setResult(false, self::AS_ARTICLE_WAS_DELETED);
         return $status;
     }
     # Load the page data from the master. If anything changes in the meantime,
     # we detect it by using page_latest like a token in a 1 try compare-and-swap.
     $this->page->loadPageData('fromdbmaster');
     $new = !$this->page->exists();
     if ($new) {
         // Late check for create permission, just in case *PARANOIA*
         if (!$this->mTitle->userCan('create', $wgUser)) {
             $status->fatal('nocreatetext');
             $status->value = self::AS_NO_CREATE_PERMISSION;
             wfDebug(__METHOD__ . ": no create permission\n");
             return $status;
         }
         // Don't save a new page if it's blank or if it's a MediaWiki:
         // message with content equivalent to default (allow empty pages
         // in this case to disable messages, see bug 50124)
         $defaultMessageText = $this->mTitle->getDefaultMessageText();
         if ($this->mTitle->getNamespace() === NS_MEDIAWIKI && $defaultMessageText !== false) {
             $defaultText = $defaultMessageText;
         } else {
             $defaultText = '';
         }
         if (!$this->allowBlankArticle && $this->textbox1 === $defaultText) {
             $this->blankArticle = true;
             $status->fatal('blankarticle');
             $status->setResult(false, self::AS_BLANK_ARTICLE);
             return $status;
         }
         if (!$this->runPostMergeFilters($textbox_content, $status, $wgUser)) {
             return $status;
         }
         $content = $textbox_content;
         $result['sectionanchor'] = '';
         if ($this->section == 'new') {
             if ($this->sectiontitle !== '') {
                 // Insert the section title above the content.
                 $content = $content->addSectionHeader($this->sectiontitle);
开发者ID:OrBin,项目名称:mediawiki,代码行数:67,代码来源:EditPage.php

示例13: html_ref

function html_ref($page, $appearance, $hover = '', $anchor = '', $anchor_appearance = '')
{
    global $db, $SeparateLinkWords;
    if ($hover != '') {
        $hover = ' title="' . $hover . '"';
    }
    $p = new WikiPage($db, $page);
    if ($p->exists()) {
        if ($SeparateLinkWords && $page == $appearance) {
            $appearance = html_split_name($page);
        }
        return '<a href="' . viewURL($page) . $anchor . '"' . $hover . '>' . $appearance . $anchor_appearance . '</a>';
    } else {
        if (validate_page($page) == 1 && $appearance == $page) {
            return $page . '<a href="' . editURL($page) . '"' . $hover . '>?</a>';
        } else {
            return '(' . $appearance . ')<a href="' . editURL($page) . '"' . $hover . '>?</a>';
        }
    }
}
开发者ID:BackupTheBerlios,项目名称:hpt-obm-svn,代码行数:20,代码来源:html.php

示例14: view

 /**
  * This is the default action of the index.php entry point: just view the
  * page of the given title.
  */
 public function view()
 {
     global $wgUser, $wgOut, $wgRequest, $wgParser;
     global $wgUseFileCache, $wgUseETag, $wgDebugToolbar;
     wfProfileIn(__METHOD__);
     # Get variables from query string
     # As side effect this will load the revision and update the title
     # in a revision ID is passed in the request, so this should remain
     # the first call of this method even if $oldid is used way below.
     $oldid = $this->getOldID();
     # Another whitelist check in case getOldID() is altering the title
     $permErrors = $this->getTitle()->getUserPermissionsErrors('read', $wgUser);
     if (count($permErrors)) {
         wfDebug(__METHOD__ . ": denied on secondary read check\n");
         wfProfileOut(__METHOD__);
         throw new PermissionsError('read', $permErrors);
     }
     # getOldID() may as well want us to redirect somewhere else
     if ($this->mRedirectUrl) {
         $wgOut->redirect($this->mRedirectUrl);
         wfDebug(__METHOD__ . ": redirecting due to oldid\n");
         wfProfileOut(__METHOD__);
         return;
     }
     # If we got diff in the query, we want to see a diff page instead of the article.
     if ($wgRequest->getCheck('diff')) {
         wfDebug(__METHOD__ . ": showing diff page\n");
         $this->showDiffPage();
         wfProfileOut(__METHOD__);
         return;
     }
     # Set page title (may be overridden by DISPLAYTITLE)
     $wgOut->setPageTitle($this->getTitle()->getPrefixedText());
     $wgOut->setArticleFlag(true);
     # Allow frames by default
     $wgOut->allowClickjacking();
     $parserCache = ParserCache::singleton();
     $parserOptions = $this->getParserOptions();
     # Render printable version, use printable version cache
     if ($wgOut->isPrintable()) {
         $parserOptions->setIsPrintable(true);
         $parserOptions->setEditSection(false);
     } elseif (!$this->isCurrent() || !$this->getTitle()->quickUserCan('edit')) {
         $parserOptions->setEditSection(false);
     }
     # Try client and file cache
     if (!$wgDebugToolbar && $oldid === 0 && $this->mPage->checkTouched()) {
         if ($wgUseETag) {
             $wgOut->setETag($parserCache->getETag($this, $parserOptions));
         }
         # Is it client cached?
         if ($wgOut->checkLastModified($this->mPage->getTouched())) {
             wfDebug(__METHOD__ . ": done 304\n");
             wfProfileOut(__METHOD__);
             return;
             # Try file cache
         } elseif ($wgUseFileCache && $this->tryFileCache()) {
             wfDebug(__METHOD__ . ": done file cache\n");
             # tell wgOut that output is taken care of
             $wgOut->disable();
             $this->mPage->doViewUpdates($wgUser);
             wfProfileOut(__METHOD__);
             return;
         }
     }
     # Should the parser cache be used?
     $useParserCache = $this->mPage->isParserCacheUsed($parserOptions, $oldid);
     wfDebug('Article::view using parser cache: ' . ($useParserCache ? 'yes' : 'no') . "\n");
     if ($wgUser->getStubThreshold()) {
         wfIncrStats('pcache_miss_stub');
     }
     $this->showRedirectedFromHeader();
     $this->showNamespaceHeader();
     # Iterate through the possible ways of constructing the output text.
     # Keep going until $outputDone is set, or we run out of things to do.
     $pass = 0;
     $outputDone = false;
     $this->mParserOutput = false;
     while (!$outputDone && ++$pass) {
         switch ($pass) {
             case 1:
                 wfRunHooks('ArticleViewHeader', array(&$this, &$outputDone, &$useParserCache));
                 break;
             case 2:
                 # Early abort if the page doesn't exist
                 if (!$this->mPage->exists()) {
                     wfDebug(__METHOD__ . ": showing missing article\n");
                     $this->showMissingArticle();
                     wfProfileOut(__METHOD__);
                     /* Wikia change begin - @author: Marcin, #BugId: 30436 */
                     $text = '';
                     if (wfRunHooks('ArticleNonExistentPage', array(&$this, $wgOut, &$text))) {
                         $this->mParserOutput = $wgParser->parse($text, $this->getTitle(), $parserOptions);
                         $wgOut->addParserOutput($this->mParserOutput);
                     }
                     /* Wikia change end */
//.........这里部分代码省略.........
开发者ID:Tjorriemorrie,项目名称:app,代码行数:101,代码来源:Article.php

示例15: html_group

 /**
  * Create or edit a group
  */
 public function html_group(&$q)
 {
     global $wgOut, $wgUser, $wgScript, $haclgHaloScriptPath, $wgContLang, $haclgContLang;
     $grpTitle = $grpArticle = $grpName = $grpPrefix = NULL;
     if (!empty($q['group'])) {
         $pe = IACLDefinition::nameOfPE($q['group']);
         $t = Title::newFromText($q['group'], HACL_NS_ACL);
         if ($t && $pe[0] == IACL::PE_GROUP) {
             $a = new WikiPage($t);
             if ($a->exists()) {
                 $grpTitle = $t;
                 $grpArticle = $a;
                 $grpPrefix = $haclgContLang->getPetPrefix(IACL::PE_GROUP);
                 $grpName = $pe[1];
             }
         }
     }
     /* Run template */
     ob_start();
     require dirname(__FILE__) . '/../templates/HACL_GroupEditor.tpl.php';
     $html = ob_get_contents();
     ob_end_clean();
     $wgOut->addModules('ext.intraacl.groupeditor');
     $wgOut->setPageTitle($grpTitle ? wfMsg('hacl_grp_editing', $grpTitle->getText()) : wfMsg('hacl_grp_creating'));
     $wgOut->addHTML($html);
 }
开发者ID:hermannschwaerzlerUIBK,项目名称:IntraACL,代码行数:29,代码来源:ACLSpecial.php


注:本文中的WikiPage::exists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。