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


PHP Title::exists方法代码示例

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


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

示例1: assertValidCommentTitle

 /**
  * @throws \Email\Check
  */
 private function assertValidCommentTitle()
 {
     if (!$this->commentTitle instanceof \Title) {
         throw new Check("Could not find comment for revision ID given by currentRevId");
     }
     if (!$this->commentTitle->exists()) {
         throw new Check("Comment doesn't exist.");
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:12,代码来源:CommentController.class.php

示例2: assertValidTitle

 /**
  * @throws \Email\Check
  */
 private function assertValidTitle()
 {
     if (!$this->pageTitle instanceof \Title) {
         throw new Check("Invalid value passed for title");
     }
     if (!$this->pageTitle->exists()) {
         throw new Check("Title doesn't exist.");
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:12,代码来源:FounderController.class.php

示例3: assertValidPostTitle

 /**
  * @throws \Email\Check
  */
 private function assertValidPostTitle()
 {
     if (!$this->postTitle instanceof \Title) {
         $articleID = $this->getVal('childArticleID', false);
         throw new Check("Could not find post for article ID '{$articleID}' given by childArticleID");
     }
     if (!$this->postTitle->exists()) {
         throw new Check("Post doesn't exist.");
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:13,代码来源:BlogPostController.class.php

示例4: getData

 /**
  * Returns infobox data
  *
  * @return array in format [ 'data' => [], 'sources' => [] ] or [] will be returned
  */
 public function getData()
 {
     if ($this->title && $this->title->exists()) {
         $parserOutput = Article::newFromTitle($this->title, RequestContext::getMain())->getParserOutput();
         $data = $parserOutput ? $parserOutput->getProperty(self::INFOBOXES_PROPERTY_NAME) : false;
         //return empty [] to prevent false on non existing infobox data
         return $data ? $data : [];
     }
     return [];
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:15,代码来源:PortableInfoboxDataService.class.php

示例5: assertUserRolesSet

 protected function assertUserRolesSet()
 {
     if (empty($this->authorUserName)) {
         throw new Check("Could not determine message author");
     }
     if (empty($this->wallUserName)) {
         throw new Check("Could not determine message owner");
     }
     if (!$this->wallTitle->exists()) {
         throw new Check("Given Message Wall doesn't exist");
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:12,代码来源:WallMessageController.class.php

示例6: assertValidPageAddedToCategory

 /**
  * @throws \Email\Check
  */
 protected function assertValidPageAddedToCategory()
 {
     if (!$this->pageAddedToCategory instanceof \Title) {
         throw new Check("Invalid value passed for pageAddedToCategory (param: pageTitle)");
     }
     if (!$this->pageAddedToCategory->exists()) {
         // Check master DB just in case the page was just created and it
         // hasn't been replicated to the slave yet
         if ($this->pageAddedToCategory->getArticleID(\Title::GAID_FOR_UPDATE) == 0) {
             throw new Check("pageAddedToCategory doesn't exist.");
         }
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:16,代码来源:CategoryAddController.class.php

示例7: execute

 public function execute($par)
 {
     $this->useTransactionalTimeLimit();
     $this->checkReadOnly();
     $this->setHeaders();
     $this->outputHeader();
     $request = $this->getRequest();
     $target = !is_null($par) ? $par : $request->getVal('target');
     // Yes, the use of getVal() and getText() is wanted, see bug 20365
     $oldTitleText = $request->getVal('wpOldTitle', $target);
     if (is_string($oldTitleText)) {
         $this->oldTitle = Title::newFromText($oldTitleText);
     }
     if ($this->oldTitle === null) {
         // Either oldTitle wasn't passed, or newFromText returned null
         throw new ErrorPageError('notargettitle', 'notargettext');
     }
     if (!$this->oldTitle->exists()) {
         throw new ErrorPageError('nopagetitle', 'nopagetext');
     }
     $newTitleTextMain = $request->getText('wpNewTitleMain');
     $newTitleTextNs = $request->getInt('wpNewTitleNs', $this->oldTitle->getNamespace());
     // Backwards compatibility for forms submitting here from other sources
     // which is more common than it should be..
     $newTitleText_bc = $request->getText('wpNewTitle');
     $this->newTitle = strlen($newTitleText_bc) > 0 ? Title::newFromText($newTitleText_bc) : Title::makeTitleSafe($newTitleTextNs, $newTitleTextMain);
     $user = $this->getUser();
     # Check rights
     $permErrors = $this->oldTitle->getUserPermissionsErrors('move', $user);
     if (count($permErrors)) {
         // Auto-block user's IP if the account was "hard" blocked
         DeferredUpdates::addCallableUpdate(function () use($user) {
             $user->spreadAnyEditBlock();
         });
         throw new PermissionsError('move', $permErrors);
     }
     $def = !$request->wasPosted();
     $this->reason = $request->getText('wpReason');
     $this->moveTalk = $request->getBool('wpMovetalk', $def);
     $this->fixRedirects = $request->getBool('wpFixRedirects', $def);
     $this->leaveRedirect = $request->getBool('wpLeaveRedirect', $def);
     $this->moveSubpages = $request->getBool('wpMovesubpages', false);
     $this->deleteAndMove = $request->getBool('wpDeleteAndMove') && $request->getBool('wpConfirm');
     $this->moveOverShared = $request->getBool('wpMoveOverSharedFile', false);
     $this->watch = $request->getCheck('wpWatch') && $user->isLoggedIn();
     if ('submit' == $request->getVal('action') && $request->wasPosted() && $user->matchEditToken($request->getVal('wpEditToken'))) {
         $this->doSubmit();
     } else {
         $this->showForm(array());
     }
 }
开发者ID:ngertrudiz,项目名称:mediawiki,代码行数:51,代码来源:SpecialMovepage.php

示例8: initialize

 /**
  * Set up all member variables using a database query.
  * @throws MWException
  * @return bool True on success, false on failure.
  */
 protected function initialize()
 {
     if ($this->mName === null && $this->mID === null) {
         throw new MWException(__METHOD__ . ' has both names and IDs null');
     } elseif ($this->mID === null) {
         $where = ['cat_title' => $this->mName];
     } elseif ($this->mName === null) {
         $where = ['cat_id' => $this->mID];
     } else {
         # Already initialized
         return true;
     }
     $dbr = wfGetDB(DB_REPLICA);
     $row = $dbr->selectRow('category', ['cat_id', 'cat_title', 'cat_pages', 'cat_subcats', 'cat_files'], $where, __METHOD__);
     if (!$row) {
         # Okay, there were no contents.  Nothing to initialize.
         if ($this->mTitle) {
             # If there is a title object but no record in the category table,
             # treat this as an empty category.
             $this->mID = false;
             $this->mName = $this->mTitle->getDBkey();
             $this->mPages = 0;
             $this->mSubcats = 0;
             $this->mFiles = 0;
             # If the title exists, call refreshCounts to add a row for it.
             if ($this->mTitle->exists()) {
                 DeferredUpdates::addCallableUpdate([$this, 'refreshCounts']);
             }
             return true;
         } else {
             return false;
             # Fail
         }
     }
     $this->mID = $row->cat_id;
     $this->mName = $row->cat_title;
     $this->mPages = $row->cat_pages;
     $this->mSubcats = $row->cat_subcats;
     $this->mFiles = $row->cat_files;
     # (bug 13683) If the count is negative, then 1) it's obviously wrong
     # and should not be kept, and 2) we *probably* don't have to scan many
     # rows to obtain the correct figure, so let's risk a one-time recount.
     if ($this->mPages < 0 || $this->mSubcats < 0 || $this->mFiles < 0) {
         $this->mPages = max($this->mPages, 0);
         $this->mSubcats = max($this->mSubcats, 0);
         $this->mFiles = max($this->mFiles, 0);
         DeferredUpdates::addCallableUpdate([$this, 'refreshCounts']);
     }
     return true;
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:55,代码来源:Category.php

示例9: onArticleFromTitle

 /**
  * set appropriate status code for deleted pages
  *
  * @author ADi
  * @param Title $title
  * @param Article $article
  * @return bool
  */
 public function onArticleFromTitle(&$title, &$article)
 {
     if (!$title->exists() && $title->isDeleted()) {
         F::app()->wg->Out->setStatusCode(SEOTweaksHooksHelper::DELETED_PAGES_STATUS_CODE);
     }
     return true;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:15,代码来源:SEOTweaksHooksHelper.class.php

示例10: doBasicChecks

	/**
	 * Do the basic checks whether moving is possible and whether
	 * the input looks anywhere near sane.
	 * @return bool
	 */
	protected function doBasicChecks() {
		global $wgOut;
		# Check for database lock
		if ( wfReadOnly() ) {
			$wgOut->readOnlyPage();
			return false;
		}

		if ( $this->title === null ) {
			$wgOut->showErrorPage( 'notargettitle', 'notargettext' );
			return false;
		}

		if ( !$this->title->exists() ) {
			$wgOut->showErrorPage( 'nopagetitle', 'nopagetext' );
			return false;
		}

		# Check rights
		$permErrors = $this->title->getUserPermissionsErrors( 'delete', $this->user );
		if ( !empty( $permErrors ) ) {
			$wgOut->showPermissionsErrorPage( $permErrors );
			return false;
		}

		// Let the caller know it's safe to continue
		return true;
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:33,代码来源:SpecialPageTranslationDeletePage.php

示例11: executeWhenAvailable

 /**
  * Render the special page
  * @param string $par parameter as subpage of specialpage
  */
 public function executeWhenAvailable($par = '')
 {
     $out = $this->getOutput();
     $out->setPageTitle($this->msg('history'));
     $out->addModuleStyles(array('mobile.pagelist.styles', 'mobile.pagesummary.styles'));
     $this->offset = $this->getRequest()->getVal('offset', false);
     if ($par) {
         // enter article history view
         $this->title = Title::newFromText($par);
         if ($this->title && $this->title->exists()) {
             // make sure, the content of the page supports the default history page
             if (!self::shouldUseSpecialHistory($this->title)) {
                 // and if not, redirect to the default history action
                 $out->redirect($this->title->getLocalUrl(array('action' => 'history')));
                 return;
             }
             $this->addModules();
             $this->getOutput()->addHtml(Html::openElement('div', array('class' => 'history content-unstyled')));
             $this->renderHeaderBar($this->title);
             $res = $this->doQuery();
             $this->showHistory($res);
             $this->getOutput()->addHtml(Html::closeElement('div'));
             return;
         }
     }
     $this->showPageNotFound();
 }
开发者ID:micha6554,项目名称:mediawiki-extensions-MobileFrontend,代码行数:31,代码来源:SpecialMobileHistory.php

示例12: onAfterInitialize

 /**
  * set appropriate status code for deleted pages
  *
  * @author ADi
  * @author Władysław Bodzek <wladek@wikia-inc.com>
  * @param Title $title
  * @param Article $article
  * @return bool
  */
 public static function onAfterInitialize(&$title, &$article, &$output)
 {
     if (!$title->exists() && $title->isDeleted()) {
         $setDeletedStatusCode = true;
         // handle special cases
         switch ($title->getNamespace()) {
             case NS_CATEGORY:
                 // skip non-empty categories
                 if (Category::newFromTitle($title)->getPageCount() > 0) {
                     $setDeletedStatusCode = false;
                 }
                 break;
             case NS_FILE:
                 // skip existing file with deleted description
                 $file = wfFindFile($title);
                 if ($file && $file->exists()) {
                     $setDeletedStatusCode = false;
                 }
                 break;
         }
         if ($setDeletedStatusCode) {
             $output->setStatusCode(SEOTweaksHooksHelper::DELETED_PAGES_STATUS_CODE);
         }
     }
     return true;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:35,代码来源:SEOTweaksHooksHelper.class.php

示例13: getTitles

	/**
	 * return the page titles of the subpages in an array
	 * @return array all titles
	 * @private
	 */
	function getTitles() {
		wfProfileIn( __METHOD__ );

		$dbr = wfGetDB( DB_SLAVE );

		$conditions = array();
		$options = array();
		$order = strtoupper( $this->order );

		if( $this->ordermethod == 'title' ) {
			$options['ORDER BY'] = 'page_title ' . $order;
		} elseif( $this->ordermethod == 'lastedit' ) {
			$options['ORDER BY'] = 'page_touched ' . $order;
		}
		if( $this->parent !== -1) {
			$this->ptitle = Title::newFromText( $this->parent );
			# note that non-existent pages may nevertheless have valid subpages
			# on the other hand, not checking that the page exists can let input through which causes database errors
			if ( $this->ptitle instanceof Title && $this->ptitle->exists() && $this->ptitle->userCanRead() ) {
				$parent = $this->ptitle->getDBkey();
				$this->parent = $parent;
				$this->namespace = $this->ptitle->getNsText();
				$nsi = $this->ptitle->getNamespace();
			} else {
				$this->error( wfMsg('spl3_debug','parent') );
				return null;
			}
		} else {
			$this->ptitle = $this->title;
			$parent = $this->title->getDBkey();
			$this->parent = $parent;
			$this->namespace = $this->title->getNsText();
			$nsi = $this->title->getNamespace();
		}

		// don't let list cross namespaces
		if ( strlen( $nsi ) > 0 ) {
			$conditions['page_namespace'] = $nsi;
		}
		$conditions['page_is_redirect'] = 0;
		$conditions[] = 'page_title ' . $dbr->buildLike( $parent . '/', $dbr->anyString() );

		$fields = array();
		$fields[] = 'page_title';
		$fields[] = 'page_namespace';
		$res = $dbr->select( 'page', $fields, $conditions, __METHOD__, $options );

		$titles = array();
		foreach ( $res as $row ) {
			$title = Title::makeTitleSafe( $row->page_namespace, $row->page_title );
			if( $title ) {
				$titles[] = $title;
			}
		}
		wfProfileOut( __METHOD__ );
		return $titles;
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:62,代码来源:SubPageList3.php

示例14: wfAutoPageCreateTextForImagePlaceholder

function wfAutoPageCreateTextForImagePlaceholder(Title $title, &$text)
{
    // this was for RT#45568 - Bartek
    // basic idea is to load the template for ImagePlaceholder to work when the article does not yet exist
    // but on view, not on article edit (on preview the placeholder is blocked by default)
    global $wgRequest;
    if (!$title->exists() && 'edit' != $wgRequest->getVal('action')) {
        $text = wfMsgForContent('newpagelayout');
    }
    return true;
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:11,代码来源:AutoPageCreate.php

示例15: create

 public static function create(Title $title)
 {
     wfProfileIn(__METHOD__);
     if (empty($title) || $title->exists()) {
         return;
     }
     $article = F::build('Article', array($title));
     $status = $article->doEdit('', 'Article created', EDIT_NEW, false, F::app()->wg->user);
     wfProfileOut(__METHOD__);
     return self::newFromTitle($article->getTitle());
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:11,代码来源:RelatedVideosNamespaceData.class.php


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