00001 <?php 00002 00008 class ParserOptions { 00009 # All variables are supposed to be private in theory, although in practise this is not the case. 00010 var $mUseDynamicDates; # Use DateFormatter to format dates 00011 var $mInterwikiMagic; # Interlanguage links are removed and returned in an array 00012 var $mAllowExternalImages; # Allow external images inline 00013 var $mAllowExternalImagesFrom; # If not, any exception? 00014 var $mEnableImageWhitelist; # If not or it doesn't match, should we check an on-wiki whitelist? 00015 var $mSkin; # Reference to the preferred skin 00016 var $mDateFormat; # Date format index 00017 var $mEditSection; # Create "edit section" links 00018 var $mNumberHeadings; # Automatically number headings 00019 var $mAllowSpecialInclusion; # Allow inclusion of special pages 00020 var $mTidy; # Ask for tidy cleanup 00021 var $mInterfaceMessage; # Which lang to call for PLURAL and GRAMMAR 00022 var $mTargetLanguage; # Overrides above setting with arbitrary language 00023 var $mMaxIncludeSize; # Maximum size of template expansions, in bytes 00024 var $mMaxPPNodeCount; # Maximum number of nodes touched by PPFrame::expand() 00025 var $mMaxPPExpandDepth; # Maximum recursion depth in PPFrame::expand() 00026 var $mMaxTemplateDepth; # Maximum recursion depth for templates within templates 00027 var $mRemoveComments; # Remove HTML comments. ONLY APPLIES TO PREPROCESS OPERATIONS 00028 var $mTemplateCallback; # Callback for template fetching 00029 var $mEnableLimitReport; # Enable limit report in an HTML comment on output 00030 var $mTimestamp; # Timestamp used for {{CURRENTDAY}} etc. 00031 var $mExternalLinkTarget; # Target attribute for external links 00032 00033 var $mUser; # Stored user object, just used to initialise the skin 00034 var $mIsPreview; # Parsing the page for a "preview" operation 00035 var $mIsSectionPreview; # Parsing the page for a "preview" operation on a single section 00036 var $mIsPrintable; # Parsing the printable version of the page 00037 00038 function getUseDynamicDates() { return $this->mUseDynamicDates; } 00039 function getInterwikiMagic() { return $this->mInterwikiMagic; } 00040 function getAllowExternalImages() { return $this->mAllowExternalImages; } 00041 function getAllowExternalImagesFrom() { return $this->mAllowExternalImagesFrom; } 00042 function getEnableImageWhitelist() { return $this->mEnableImageWhitelist; } 00043 function getEditSection() { return $this->mEditSection; } 00044 function getNumberHeadings() { return $this->mNumberHeadings; } 00045 function getAllowSpecialInclusion() { return $this->mAllowSpecialInclusion; } 00046 function getTidy() { return $this->mTidy; } 00047 function getInterfaceMessage() { return $this->mInterfaceMessage; } 00048 function getTargetLanguage() { return $this->mTargetLanguage; } 00049 function getMaxIncludeSize() { return $this->mMaxIncludeSize; } 00050 function getMaxPPNodeCount() { return $this->mMaxPPNodeCount; } 00051 function getMaxTemplateDepth() { return $this->mMaxTemplateDepth; } 00052 function getRemoveComments() { return $this->mRemoveComments; } 00053 function getTemplateCallback() { return $this->mTemplateCallback; } 00054 function getEnableLimitReport() { return $this->mEnableLimitReport; } 00055 function getCleanSignatures() { return $this->mCleanSignatures; } 00056 function getExternalLinkTarget() { return $this->mExternalLinkTarget; } 00057 function getIsPreview() { return $this->mIsPreview; } 00058 function getIsSectionPreview() { return $this->mIsSectionPreview; } 00059 function getIsPrintable() { return $this->mIsPrintable; } 00060 00061 function getSkin() { 00062 if ( !isset( $this->mSkin ) ) { 00063 $this->mSkin = $this->mUser->getSkin(); 00064 } 00065 return $this->mSkin; 00066 } 00067 00068 function getDateFormat() { 00069 if ( !isset( $this->mDateFormat ) ) { 00070 $this->mDateFormat = $this->mUser->getDatePreference(); 00071 } 00072 return $this->mDateFormat; 00073 } 00074 00075 function getTimestamp() { 00076 if ( !isset( $this->mTimestamp ) ) { 00077 $this->mTimestamp = wfTimestampNow(); 00078 } 00079 return $this->mTimestamp; 00080 } 00081 00082 function setUseDynamicDates( $x ) { return wfSetVar( $this->mUseDynamicDates, $x ); } 00083 function setInterwikiMagic( $x ) { return wfSetVar( $this->mInterwikiMagic, $x ); } 00084 function setAllowExternalImages( $x ) { return wfSetVar( $this->mAllowExternalImages, $x ); } 00085 function setAllowExternalImagesFrom( $x ) { return wfSetVar( $this->mAllowExternalImagesFrom, $x ); } 00086 function setEnableImageWhitelist( $x ) { return wfSetVar( $this->mEnableImageWhitelist, $x ); } 00087 function setDateFormat( $x ) { return wfSetVar( $this->mDateFormat, $x ); } 00088 function setEditSection( $x ) { return wfSetVar( $this->mEditSection, $x ); } 00089 function setNumberHeadings( $x ) { return wfSetVar( $this->mNumberHeadings, $x ); } 00090 function setAllowSpecialInclusion( $x ) { return wfSetVar( $this->mAllowSpecialInclusion, $x ); } 00091 function setTidy( $x ) { return wfSetVar( $this->mTidy, $x); } 00092 function setSkin( $x ) { $this->mSkin = $x; } 00093 function setInterfaceMessage( $x ) { return wfSetVar( $this->mInterfaceMessage, $x); } 00094 function setTargetLanguage( $x ) { return wfSetVar( $this->mTargetLanguage, $x); } 00095 function setMaxIncludeSize( $x ) { return wfSetVar( $this->mMaxIncludeSize, $x ); } 00096 function setMaxPPNodeCount( $x ) { return wfSetVar( $this->mMaxPPNodeCount, $x ); } 00097 function setMaxTemplateDepth( $x ) { return wfSetVar( $this->mMaxTemplateDepth, $x ); } 00098 function setRemoveComments( $x ) { return wfSetVar( $this->mRemoveComments, $x ); } 00099 function setTemplateCallback( $x ) { return wfSetVar( $this->mTemplateCallback, $x ); } 00100 function enableLimitReport( $x = true ) { return wfSetVar( $this->mEnableLimitReport, $x ); } 00101 function setTimestamp( $x ) { return wfSetVar( $this->mTimestamp, $x ); } 00102 function setCleanSignatures( $x ) { return wfSetVar( $this->mCleanSignatures, $x ); } 00103 function setExternalLinkTarget( $x ) { return wfSetVar( $this->mExternalLinkTarget, $x ); } 00104 function setIsPreview( $x ) { return wfSetVar( $this->mIsPreview, $x ); } 00105 function setIsSectionPreview( $x ) { return wfSetVar( $this->mIsSectionPreview, $x ); } 00106 function setIsPrintable( $x ) { return wfSetVar( $this->mIsPrintable, $x ); } 00107 00108 function __construct( $user = null ) { 00109 $this->initialiseFromUser( $user ); 00110 } 00111 00116 static function newFromUser( $user ) { 00117 return new ParserOptions( $user ); 00118 } 00119 00121 function initialiseFromUser( $userInput ) { 00122 global $wgUseDynamicDates, $wgInterwikiMagic, $wgAllowExternalImages; 00123 global $wgAllowExternalImagesFrom, $wgEnableImageWhitelist, $wgAllowSpecialInclusion, $wgMaxArticleSize; 00124 global $wgMaxPPNodeCount, $wgMaxTemplateDepth, $wgMaxPPExpandDepth, $wgCleanSignatures; 00125 global $wgExternalLinkTarget; 00126 00127 wfProfileIn( __METHOD__ ); 00128 00129 if ( !$userInput ) { 00130 global $wgUser; 00131 if ( isset( $wgUser ) ) { 00132 $user = $wgUser; 00133 } else { 00134 $user = new User; 00135 } 00136 } else { 00137 $user =& $userInput; 00138 } 00139 00140 $this->mUser = $user; 00141 00142 $this->mUseDynamicDates = $wgUseDynamicDates; 00143 $this->mInterwikiMagic = $wgInterwikiMagic; 00144 $this->mAllowExternalImages = $wgAllowExternalImages; 00145 $this->mAllowExternalImagesFrom = $wgAllowExternalImagesFrom; 00146 $this->mEnableImageWhitelist = $wgEnableImageWhitelist; 00147 $this->mSkin = null; # Deferred 00148 $this->mDateFormat = null; # Deferred 00149 $this->mEditSection = true; 00150 $this->mNumberHeadings = $user->getOption( 'numberheadings' ); 00151 $this->mAllowSpecialInclusion = $wgAllowSpecialInclusion; 00152 $this->mTidy = false; 00153 $this->mInterfaceMessage = false; 00154 $this->mTargetLanguage = null; // default depends on InterfaceMessage setting 00155 $this->mMaxIncludeSize = $wgMaxArticleSize * 1024; 00156 $this->mMaxPPNodeCount = $wgMaxPPNodeCount; 00157 $this->mMaxPPExpandDepth = $wgMaxPPExpandDepth; 00158 $this->mMaxTemplateDepth = $wgMaxTemplateDepth; 00159 $this->mRemoveComments = true; 00160 $this->mTemplateCallback = array( 'Parser', 'statelessFetchTemplate' ); 00161 $this->mEnableLimitReport = false; 00162 $this->mCleanSignatures = $wgCleanSignatures; 00163 $this->mExternalLinkTarget = $wgExternalLinkTarget; 00164 $this->mIsPreview = false; 00165 $this->mIsSectionPreview = false; 00166 00167 wfProfileOut( __METHOD__ ); 00168 } 00169 }