예제 #1
0
 /**
  * Extract a redirect destination from a string and return an
  * array of Titles, or null if the text doesn't contain a valid redirect
  * The last element in the array is the final destination after all redirects
  * have been resolved (up to $wgMaxRedirects times)
  *
  * @param string $text Text with possible redirect
  * @return Title[] Array of Titles, with the destination last
  * @deprecated since 1.21, use Content::getRedirectChain instead.
  */
 public static function newFromRedirectArray($text)
 {
     ContentHandler::deprecated(__METHOD__, '1.21');
     $content = ContentHandler::makeContent($text, null, CONTENT_MODEL_WIKITEXT);
     return $content->getRedirectChain();
 }
예제 #2
0
	/**
	 * Return an applicable autosummary if one exists for the given edit.
	 * @param string|null $oldtext the previous text of the page.
	 * @param string|null $newtext The submitted text of the page.
	 * @param int $flags bitmask: a bitmask of flags submitted for the edit.
	 * @return string An appropriate autosummary, or an empty string.
	 *
	 * @deprecated since 1.21, use ContentHandler::getAutosummary() instead
	 */
	public static function getAutosummary( $oldtext, $newtext, $flags ) {
		// NOTE: stub for backwards-compatibility. assumes the given text is wikitext. will break horribly if it isn't.

		ContentHandler::deprecated( __METHOD__, '1.21' );

		$handler = ContentHandler::getForModelID( CONTENT_MODEL_WIKITEXT );
		$oldContent = is_null( $oldtext ) ? null : $handler->unserializeContent( $oldtext );
		$newContent = is_null( $newtext ) ? null : $handler->unserializeContent( $newtext );

		return $handler->getAutosummary( $oldContent, $newContent, $flags );
	}
예제 #3
0
 /**
  * @return string
  *
  * @deprecated Since 1.21, use getContent() instead.
  */
 function getText()
 {
     ContentHandler::deprecated(__METHOD__, '1.21');
     return $this->text;
 }
예제 #4
0
 /**
  * Use specified text instead of loading from the database
  * @deprecated since 1.21, use setContent() instead.
  */
 public function setText($oldText, $newText)
 {
     ContentHandler::deprecated(__METHOD__, "1.21");
     $oldContent = ContentHandler::makeContent($oldText, $this->getTitle());
     $newContent = ContentHandler::makeContent($newText, $this->getTitle());
     $this->setContent($oldContent, $newContent);
 }
예제 #5
0
 /**
  * Get text of an article from database
  * Does *NOT* follow redirects.
  *
  * @protected
  * @note this is really internal functionality that should really NOT be used by other functions. For accessing
  *       article content, use the WikiPage class, especially WikiBase::getContent(). However, a lot of legacy code
  *       uses this method to retrieve page text from the database, so the function has to remain public for now.
  *
  * @return mixed string containing article contents, or false if null
  * @deprecated in 1.21, use WikiPage::getContent() instead
  */
 function fetchContent()
 {
     #BC cruft!
     ContentHandler::deprecated(__METHOD__, '1.21');
     if ($this->mContentLoaded && $this->mContent) {
         return $this->mContent;
     }
     wfProfileIn(__METHOD__);
     $content = $this->fetchContentObject();
     $this->mContent = ContentHandler::getContentText($content);
     #@todo: get rid of mContent everywhere!
     ContentHandler::runLegacyHooks('ArticleAfterFetchContent', array(&$this, &$this->mContent));
     wfProfileOut(__METHOD__);
     return $this->mContent;
 }
예제 #6
0
 /**
  * Get text of an article from database
  * Does *NOT* follow redirects.
  *
  * @protected
  * @note This is really internal functionality that should really NOT be
  * used by other functions. For accessing article content, use the WikiPage
  * class, especially WikiBase::getContent(). However, a lot of legacy code
  * uses this method to retrieve page text from the database, so the function
  * has to remain public for now.
  *
  * @return string|bool String containing article contents, or false if null
  * @deprecated since 1.21, use WikiPage::getContent() instead
  */
 function fetchContent()
 {
     // BC cruft!
     ContentHandler::deprecated(__METHOD__, '1.21');
     if ($this->mContentLoaded && $this->mContent) {
         return $this->mContent;
     }
     $content = $this->fetchContentObject();
     if (!$content) {
         return false;
     }
     // @todo Get rid of mContent everywhere!
     $this->mContent = ContentHandler::getContentText($content);
     ContentHandler::runLegacyHooks('ArticleAfterFetchContent', array(&$this, &$this->mContent));
     return $this->mContent;
 }
예제 #7
0
 /**
  * Attempts to merge text content with base and current revisions
  *
  * @param $editText string
  *
  * @return bool
  * @deprecated since 1.21, use mergeChangesIntoContent() instead
  */
 function mergeChangesInto(&$editText)
 {
     ContentHandler::deprecated(__METHOD__, "1.21");
     $editContent = $this->toEditContent($editText);
     $ok = $this->mergeChangesIntoContent($editContent);
     if ($ok) {
         $editText = $this->toEditText($editContent);
         return true;
     }
     return false;
 }
예제 #8
0
 /**
  * Fetch revision text without regard for view restrictions
  *
  * @return String
  *
  * @deprecated since 1.21. Instead, use Revision::getContent( Revision::RAW )
  *                         or Revision::getSerializedData() as appropriate.
  */
 public function getRawText()
 {
     ContentHandler::deprecated(__METHOD__, "1.21");
     return $this->getText(self::RAW);
 }
예제 #9
0
 /**
  * Call to WikiPage function for backwards compatibility.
  * @see WikiPage::getText
  */
 public function getText($audience = Revision::FOR_PUBLIC, User $user = null)
 {
     ContentHandler::deprecated(__METHOD__, '1.21');
     return $this->mPage->getText($audience, $user);
 }
예제 #10
0
 /**
  * Call to WikiPage function for backwards compatibility.
  * @see WikiPage::replaceSection
  */
 public function replaceSection($sectionId, $text, $sectionTitle = '', $edittime = null)
 {
     ContentHandler::deprecated(__METHOD__, '1.21');
     return $this->mPage->replaceSection($sectionId, $text, $sectionTitle, $edittime);
 }
예제 #11
0
 /**
  * @private
  * @todo document
  *
  * @param $editText string
  *
  * @return bool
  * @deprecated since 1.21, use mergeChangesIntoContent() instead
  */
 function mergeChangesInto(&$editText)
 {
     ContentHandler::deprecated(__METHOD__, "1.21");
     wfProfileIn(__METHOD__);
     $db = wfGetDB(DB_MASTER);
     // This is the revision the editor started from
     $baseRevision = $this->getBaseRevision();
     if (is_null($baseRevision)) {
         wfProfileOut(__METHOD__);
         return false;
     }
     $baseText = $baseRevision->getText();
     // The current state, we want to merge updates into it
     $currentRevision = Revision::loadFromTitle($db, $this->mTitle);
     if (is_null($currentRevision)) {
         wfProfileOut(__METHOD__);
         return false;
     }
     $currentText = $currentRevision->getText();
     $result = '';
     $editText = $this->toEditText($editText);
     if (wfMerge($baseText, $editText, $currentText, $result)) {
         $editText = $result;
         wfProfileOut(__METHOD__);
         return true;
     } else {
         wfProfileOut(__METHOD__);
         return false;
     }
 }
예제 #12
0
 /**
  * Fetch revision text if it's available to the specified audience.
  * If the specified audience does not have the ability to view this
  * revision, an empty string will be returned.
  *
  * @param int $audience One of:
  *   Revision::FOR_PUBLIC       to be displayed to all users
  *   Revision::FOR_THIS_USER    to be displayed to the given user
  *   Revision::RAW              get the text regardless of permissions
  * @param User $user User object to check for, only if FOR_THIS_USER is passed
  *   to the $audience parameter
  *
  * @deprecated since 1.21, use getContent() instead
  * @todo Replace usage in core
  * @return string
  */
 public function getText($audience = self::FOR_PUBLIC, User $user = null)
 {
     ContentHandler::deprecated(__METHOD__, '1.21');
     $content = $this->getContent($audience, $user);
     return ContentHandler::getContentText($content);
     # returns the raw content text, if applicable
 }
예제 #13
0
 /**
  * Generate a diff, no caching
  *
  * @param string $otext Old text, must be already segmented
  * @param string $ntext New text, must be already segmented
  *
  * @return bool|string
  * @deprecated since 1.21, use generateContentDiffBody() instead!
  */
 public function generateDiffBody($otext, $ntext)
 {
     ContentHandler::deprecated(__METHOD__, "1.21");
     return $this->generateTextDiffBody($otext, $ntext);
 }