global $wgMaxTocLevel, $wgContLang;
$doNumberHeadings = $this->mOptions->getNumberHeadings();
- if( !$this->mTitle->quickUserCan( 'edit' ) ) {
- $showEditLink = 0;
- } else {
- $showEditLink = $this->mOptions->getEditSection();
- }
+ $showEditLink = $this->mOptions->getEditSection();
# Inhibit editsection links if requested in the page
if ( isset( $this->mDoubleUnderscores['noeditsection'] ) ) {
if( $isTemplate ) {
# Put a T flag in the section identifier, to indicate to extractSections()
# that sections inside <includeonly> should be counted.
- $editlink = $sk->doEditSectionLink(Title::newFromText( $titleText ), "T-$sectionIndex");
+ $titleObj = Title::newFromText( $titleText );
+ $section = "T-$sectionIndex";
+ $tooltip = $headlineHint;
} else {
- $editlink = $sk->doEditSectionLink($this->mTitle, $sectionIndex, $headlineHint);
+ $titleObj = $this->mTitle;
+ $section = $sectionIndex;
+ $tooltip = '';
+ }
+ // Use Title::getUserPermissionsErrorsInternal() so that we can pass our User object
+ if( $titleObj->getUserPermissionsErrorsInternal( 'edit', $this->mOptions->getUser(), false ) === array() ){
+ $editlink = $sk->doEditSectionLink( $titleObj, $section, $tooltip );
+ } else {
+ $editlink = '';
}
} else {
$editlink = '';
* $options is a bit field, RLH_FOR_UPDATE to select for update
*/
function replaceLinkHolders( &$text, $options = 0 ) {
- global $wgUser;
global $wgContLang;
$fname = 'Parser::replaceLinkHolders';
wfProfileIn( $fname.'-check' );
$dbr = wfGetDB( DB_SLAVE );
$page = $dbr->tableName( 'page' );
- $threshold = $wgUser->getOption('stubthreshold');
+ $threshold = $this->mOptions->getStubThreshold();
# Sort by namespace
asort( $this->mLinkHolders['namespaces'] );
* @todo document
* @ingroup Parser
*/
-class ParserOptions
-{
+class ParserOptions {
# All variables are supposed to be private in theory, although in practise this is not the case.
- var $mUseTeX; # Use texvc to expand <math> tags
- var $mUseDynamicDates; # Use DateFormatter to format dates
- var $mInterwikiMagic; # Interlanguage links are removed and returned in an array
- var $mAllowExternalImages; # Allow external images inline
- var $mAllowExternalImagesFrom; # If not, any exception?
- var $mSkin; # Reference to the preferred skin
- var $mDateFormat; # Date format index
- var $mEditSection; # Create "edit section" links
- var $mNumberHeadings; # Automatically number headings
- var $mAllowSpecialInclusion; # Allow inclusion of special pages
- var $mTidy; # Ask for tidy cleanup
- var $mInterfaceMessage; # Which lang to call for PLURAL and GRAMMAR
- var $mTargetLanguage; # Overrides above setting with arbitrary language
- var $mMaxIncludeSize; # Maximum size of template expansions, in bytes
- var $mMaxPPNodeCount; # Maximum number of nodes touched by PPFrame::expand()
- var $mMaxPPExpandDepth; # Maximum recursion depth in PPFrame::expand()
- var $mMaxTemplateDepth; # Maximum recursion depth for templates within templates
- var $mRemoveComments; # Remove HTML comments. ONLY APPLIES TO PREPROCESS OPERATIONS
- var $mTemplateCallback; # Callback for template fetching
- var $mEnableLimitReport; # Enable limit report in an HTML comment on output
- var $mTimestamp; # Timestamp used for {{CURRENTDAY}} etc.
-
- var $mUser; # Stored user object, just used to initialise the skin
+ var $mUseTeX; //!< Use texvc to expand <math> tags
+ var $mUseDynamicDates; //!< Use DateFormatter to format dates
+ var $mInterwikiMagic; //!< Interlanguage links are removed and returned in an array
+ var $mAllowExternalImages; //!< Allow external images inline
+ var $mAllowExternalImagesFrom; //!< If not, any exception?
+ var $mSkin; //!< Reference to the preferred skin
+ var $mDateFormat; //!< Date format index
+ var $mEditSection; //!< Create "edit section" links
+ var $mNumberHeadings; //!< Automatically number headings
+ var $mStubThreshold; //!< Treshold for marking pages as "stub"
+ var $mAllowSpecialInclusion; //!< Allow inclusion of special pages
+ var $mTidy; //!< Ask for tidy cleanup
+ var $mInterfaceMessage; //!< Which lang to call for PLURAL and GRAMMAR
+ var $mTargetLanguage; //!< Overrides above setting with arbitrary language
+ var $mMaxIncludeSize; //!< Maximum size of template expansions, in bytes
+ var $mMaxPPNodeCount; //!< Maximum number of nodes touched by PPFrame::expand()
+ var $mMaxPPExpandDepth; //!< Maximum recursion depth in PPFrame::expand()
+ var $mMaxTemplateDepth; //!< Maximum recursion depth for templates within templates
+ var $mRemoveComments; //!< Remove HTML comments. ONLY APPLIES TO PREPROCESS OPERATIONS
+ var $mTemplateCallback; //!< Callback for template fetching
+ var $mEnableLimitReport; //!< Enable limit report in an HTML comment on output
+ var $mTimestamp; //!< Timestamp used for {{CURRENTDAY}} etc.
+
+ var $mUser; //!< Stored user object
function getUseTeX() { return $this->mUseTeX; }
function getUseDynamicDates() { return $this->mUseDynamicDates; }
function getAllowExternalImagesFrom() { return $this->mAllowExternalImagesFrom; }
function getEditSection() { return $this->mEditSection; }
function getNumberHeadings() { return $this->mNumberHeadings; }
+ function getStubThreshold() { return $this->mStubThreshold; }
function getAllowSpecialInclusion() { return $this->mAllowSpecialInclusion; }
function getTidy() { return $this->mTidy; }
function getInterfaceMessage() { return $this->mInterfaceMessage; }
function getTemplateCallback() { return $this->mTemplateCallback; }
function getEnableLimitReport() { return $this->mEnableLimitReport; }
+ function getUser() {
+ return $this->mUser;
+ }
+
function getSkin() {
if ( !isset( $this->mSkin ) ) {
$this->mSkin = $this->mUser->getSkin();
function setDateFormat( $x ) { return wfSetVar( $this->mDateFormat, $x ); }
function setEditSection( $x ) { return wfSetVar( $this->mEditSection, $x ); }
function setNumberHeadings( $x ) { return wfSetVar( $this->mNumberHeadings, $x ); }
+ function setStubThreshold( $x ) { return wfSetVar( $this->mStubThreshold, $x ); }
function setAllowSpecialInclusion( $x ) { return wfSetVar( $this->mAllowSpecialInclusion, $x ); }
function setTidy( $x ) { return wfSetVar( $this->mTidy, $x); }
function setSkin( $x ) { $this->mSkin = $x; }
/**
* Get parser options
- * @static
+ * @param $user User
*/
static function newFromUser( $user ) {
return new ParserOptions( $user );
global $wgUseTeX, $wgUseDynamicDates, $wgInterwikiMagic, $wgAllowExternalImages;
global $wgAllowExternalImagesFrom, $wgAllowSpecialInclusion, $wgMaxArticleSize;
global $wgMaxPPNodeCount, $wgMaxTemplateDepth, $wgMaxPPExpandDepth;
- $fname = 'ParserOptions::initialiseFromUser';
- wfProfileIn( $fname );
+
+ wfProfileIn( __METHOD__ );
+
if ( !$userInput ) {
global $wgUser;
if ( isset( $wgUser ) ) {
$this->mDateFormat = null; # Deferred
$this->mEditSection = true;
$this->mNumberHeadings = $user->getOption( 'numberheadings' );
+ $this->mStubThreshold = $user->getOption( 'stubthreshold' );
$this->mAllowSpecialInclusion = $wgAllowSpecialInclusion;
$this->mTidy = false;
$this->mInterfaceMessage = false;
$this->mRemoveComments = true;
$this->mTemplateCallback = array( 'Parser', 'statelessFetchTemplate' );
$this->mEnableLimitReport = false;
- wfProfileOut( $fname );
+
+ wfProfileOut( __METHOD__ );
}
}