Index: trunk/phase3/includes/parser/Parser.lol |
— | — | @@ -1,5282 +0,0 @@ |
2 | | - DO NOT WANT
|
3 | | - NOT WANT @defgroup Parser Parser
|
4 | | - NOT WANT
|
5 | | - NOT WANT @file
|
6 | | - NOT WANT @ingroup Parser
|
7 | | - NOT WANT File for Parser and related classes
|
8 | | - WANT
|
9 | | -
|
10 | | -
|
11 | | - DO NOT WANT
|
12 | | - NOT WANT PHP Parser - Processes wiki markup (which uses a more user-friendly
|
13 | | - NOT WANT syntax, such as "[[link]]" for making links), and provides a one-way
|
14 | | - NOT WANT transformation of that wiki markup it into XHTML output / markup
|
15 | | - NOT WANT (which in turn the browser understands, and can display).
|
16 | | - NOT WANT
|
17 | | - NOT WANT <pre>
|
18 | | - NOT WANT There are five main entry points into the Parser class:
|
19 | | - NOT WANT parse()
|
20 | | - NOT WANT produces HTML output
|
21 | | - NOT WANT preSaveTransform().
|
22 | | - NOT WANT produces altered wiki markup.
|
23 | | - NOT WANT preprocess()
|
24 | | - NOT WANT removes HTML comments and expands templates
|
25 | | - NOT WANT cleanSig()
|
26 | | - NOT WANT Cleans a signature before saving it to preferences
|
27 | | - NOT WANT extractSections()
|
28 | | - NOT WANT Extracts sections from an article for section editing
|
29 | | - NOT WANT getPreloadText()
|
30 | | - NOT WANT Removes <noinclude> sections, and <includeonly> tags.
|
31 | | - NOT WANT
|
32 | | - NOT WANT Globals used:
|
33 | | - NOT WANT objects: $wgLang, $wgContLang
|
34 | | - NOT WANT
|
35 | | - NOT WANT NOT $wgArticle, $wgUser or $wgTitle. Keep them away!
|
36 | | - NOT WANT
|
37 | | - NOT WANT settings:
|
38 | | - NOT WANT $wgUseTex*, $wgUseDynamicDates*, $wgInterwikiMagic*,
|
39 | | - NOT WANT $wgNamespacesWithSubpages, $wgAllowExternalImages*,
|
40 | | - NOT WANT $wgLocaltimezone, $wgAllowSpecialInclusion*,
|
41 | | - NOT WANT $wgMaxArticleSize*
|
42 | | - NOT WANT
|
43 | | - NOT WANT * only within ParserOptions
|
44 | | - NOT WANT </pre>
|
45 | | - NOT WANT
|
46 | | - NOT WANT @ingroup Parser
|
47 | | - WANT
|
48 | | - IM IN UR SPECIAL Parser
|
49 | | - DO NOT WANT
|
50 | | - NOT WANT Update this version number when the ParserOutput format
|
51 | | - NOT WANT changes in an incompatible way, so the parser cache
|
52 | | - NOT WANT can automatically discard old data.
|
53 | | - WANT
|
54 | | - I ALWAYZ HAS VERSION IZ '1.6.4';
|
55 | | -
|
56 | | - BTW Flags for Parser::setFunctionHook
|
57 | | - BTW Also available as global constants from Defines.php
|
58 | | - I ALWAYZ HAS SFH_NO_HASH IZ 1;
|
59 | | - I ALWAYZ HAS SFH_OBJECT_ARGS IZ 2;
|
60 | | -
|
61 | | - BTW Constants needed for external link processing
|
62 | | - BTW Everything except bracket, space, or control characters
|
63 | | - I ALWAYZ HAS EXT_LINK_URL_CLASS IZ '[^][<>"\\x00-\\x20\\x7F]';
|
64 | | - I ALWAYZ HAS EXT_IMAGE_REGEX IZ '/^(http:\/\/|https:\/\/)([^][<>"\\x00-\\x20\\x7F]+)
|
65 | | - \\/([A-Za-z0-9_.,~%\\-+&;#*?!=()@\\x80-\\xFF]+)\\.((?i)gif|png|jpg|jpeg)$/Sx';
|
66 | | -
|
67 | | - BTW State constants for the definition list colon extraction
|
68 | | - I ALWAYZ HAS COLON_STATE_TEXT IZ 0;
|
69 | | - I ALWAYZ HAS COLON_STATE_TAG IZ 1;
|
70 | | - I ALWAYZ HAS COLON_STATE_TAGSTART IZ 2;
|
71 | | - I ALWAYZ HAS COLON_STATE_CLOSETAG IZ 3;
|
72 | | - I ALWAYZ HAS COLON_STATE_TAGSLASH IZ 4;
|
73 | | - I ALWAYZ HAS COLON_STATE_COMMENT IZ 5;
|
74 | | - I ALWAYZ HAS COLON_STATE_COMMENTDASH IZ 6;
|
75 | | - I ALWAYZ HAS COLON_STATE_COMMENTDASHDASH IZ 7;
|
76 | | -
|
77 | | - BTW Flags for preprocessToDom
|
78 | | - I ALWAYZ HAS PTD_FOR_INCLUSION IZ 1;
|
79 | | -
|
80 | | - BTW Allowed values for $this->mOutputType
|
81 | | - BTW Parameter to startExternalParse().
|
82 | | - I ALWAYZ HAS OT_HTML IZ 1; # like parse()
|
83 | | - I ALWAYZ HAS OT_WIKI IZ 2; # like preSaveTransform()
|
84 | | - I ALWAYZ HAS OT_PREPROCESS IZ 3; # like preprocess()
|
85 | | - I ALWAYZ HAS OT_MSG IZ 3;
|
86 | | - I ALWAYZ HAS OT_PLAIN IZ 4; # like extractSections() - portions of the original are returned unchanged.
|
87 | | -
|
88 | | - BTW Marker Suffix needs to be accessible staticly.
|
89 | | - I ALWAYZ HAS MARKER_SUFFIX IZ "-QINU\x7f";
|
90 | | -
|
91 | | - BTW Persistent:
|
92 | | - I HAS UR $mTagHooks, $mTransparentTagHooks, $mFunctionHooks, $mFunctionSynonyms, $mVariables
|
93 | | - I HAS UR $mSubstWords, $mImageParams, $mImageParamsMagicArray, $mStripList, $mMarkerIndex
|
94 | | - I HAS UR $mPreprocessor, $mExtLinkBracketedRegex, $mUrlProtocols, $mDefaultStripList
|
95 | | - I HAS UR $mVarCache, $mConf, $mFunctionTagHooks
|
96 | | -
|
97 | | -
|
98 | | - BTW Cleared with clearState():
|
99 | | - I HAS UR $mOutput, $mAutonumber, $mDTopen, $mStripState
|
100 | | - I HAS UR $mIncludeCount, $mArgStack, $mLastSection, $mInPre
|
101 | | - I HAS UR $mLinkHolders, $mLinkID
|
102 | | - I HAS UR $mIncludeSizes, $mPPNodeCount, $mDefaultSort
|
103 | | - I HAS UR $mTplExpandCache # empty-frame expansion cache
|
104 | | - I HAS UR $mTplRedirCache, $mTplDomCache, $mHeadings, $mDoubleUnderscores
|
105 | | - I HAS UR $mExpensiveFunctionCount # number of expensive parser function calls
|
106 | | -
|
107 | | - BTW Temporary
|
108 | | - BTW These are variables reset at least once per parse regardless of $clearState
|
109 | | - I HAS UR $mOptions # ParserOptions object
|
110 | | - I HAS UR $mTitle # Title context, used for self-link rendering and similar things
|
111 | | - I HAS UR $mOutputType # Output type, one of the OT_xxx constants
|
112 | | - I HAS UR $ot # Shortcut alias, see setOutputType()
|
113 | | - I HAS UR $mRevisionId # ID to display in {{REVISIONID}} tags
|
114 | | - I HAS UR $mRevisionTimestamp # The timestamp of the specified revision ID
|
115 | | - I HAS UR $mRevIdForTs # The revision ID which was used to fetch the timestamp
|
116 | | -
|
117 | | - DO NOT WANT
|
118 | | - NOT WANT Constructor
|
119 | | - NOT WANT
|
120 | | - NOT WANT @public
|
121 | | - WANT
|
122 | | - SO IM LIKE __construct WITH UR $conf = array()
|
123 | | - UR SPECIAL mConf IZ $conf;
|
124 | | - UR SPECIAL mTagHooks IZ EMPTY;
|
125 | | - UR SPECIAL mTransparentTagHooks IZ EMPTY;
|
126 | | - UR SPECIAL mFunctionHooks IZ EMPTY;
|
127 | | - UR SPECIAL mFunctionTagHooks IZ EMPTY;
|
128 | | - UR SPECIAL mFunctionSynonyms IZ BUCKET 0 => array(), 1 => array() );
|
129 | | - UR SPECIAL mDefaultStripList IZ $this->mStripList = array();
|
130 | | - UR SPECIAL mUrlProtocols IZ wfUrlProtocols();
|
131 | | - UR SPECIAL mExtLinkBracketedRegex IZ '/\[(\b(' . wfUrlProtocols() . ')'.
|
132 | | - '[^][<>"\\x00-\\x20\\x7F]+) *([^\]\\x0a\\x0d]*?)\]/S';
|
133 | | - UR SPECIAL mVarCache IZ EMPTY;
|
134 | | - IZ isset( $conf['preprocessorClass'] )
|
135 | | - UR SPECIAL mPreprocessorClass IZ $conf['preprocessorClass'];
|
136 | | - ORLY extension_loaded( 'domxml' )
|
137 | | - BTW PECL extension that conflicts with the core DOM extension (bug 13770)
|
138 | | - IM ON UR wfDebug DOING "Warning: you have the obsolete domxml extension for PHP. Please remove it!\n"
|
139 | | - UR SPECIAL mPreprocessorClass IZ 'Preprocessor_Hash';
|
140 | | - ORLY extension_loaded( 'dom' )
|
141 | | - UR SPECIAL mPreprocessorClass IZ 'Preprocessor_DOM';
|
142 | | - NOWAI
|
143 | | - UR SPECIAL mPreprocessorClass IZ 'Preprocessor_Hash';
|
144 | | - KTHX
|
145 | | - UR SPECIAL mMarkerIndex IZ 0;
|
146 | | - UR SPECIAL mFirstCall IZ true;
|
147 | | - KTHX
|
148 | | -
|
149 | | - DO NOT WANT
|
150 | | - NOT WANT Reduce memory usage to reduce the impact of circular references
|
151 | | - WANT
|
152 | | - SO IM LIKE __destruct
|
153 | | - IZ isset( $this->mLinkHolders )
|
154 | | - IM ON UR SPECIAL mLinkHolders->__destruct
|
155 | | - KTHX
|
156 | | - IM IN UR this ITZA name => $value
|
157 | | - IM ON UR unset DOING $this->$name
|
158 | | - KTHX
|
159 | | - KTHX
|
160 | | -
|
161 | | - DO NOT WANT
|
162 | | - NOT WANT Do various kinds of initialisation on the first call of the parser
|
163 | | - WANT
|
164 | | - SO IM LIKE firstCallInit
|
165 | | - IZ !$this->mFirstCall
|
166 | | - return;
|
167 | | - KTHX
|
168 | | - UR SPECIAL mFirstCall IZ false;
|
169 | | -
|
170 | | - IM ON UR wfProfileIn DOING __METHOD__
|
171 | | -
|
172 | | - CoreParserFunctions::register( $this );
|
173 | | - CoreTagHooks::register( $this );
|
174 | | - IM ON UR SPECIAL initialiseVariables
|
175 | | -
|
176 | | - IM ON UR wfRunHooks DOING 'ParserFirstCallInit', array( &$this )
|
177 | | - IM ON UR wfProfileOut DOING __METHOD__
|
178 | | - KTHX
|
179 | | -
|
180 | | - DO NOT WANT
|
181 | | - NOT WANT Clear Parser state
|
182 | | - NOT WANT
|
183 | | - NOT WANT @private
|
184 | | - WANT
|
185 | | - SO IM LIKE clearState
|
186 | | - IM ON UR wfProfileIn DOING __METHOD__
|
187 | | - IZ $this->mFirstCall
|
188 | | - IM ON UR SPECIAL firstCallInit
|
189 | | - KTHX
|
190 | | - UR SPECIAL mOutput IZ new ParserOutput;
|
191 | | - UR SPECIAL mAutonumber IZ 0;
|
192 | | - UR SPECIAL mLastSection IZ '';
|
193 | | - UR SPECIAL mDTopen IZ false;
|
194 | | - UR SPECIAL mIncludeCount IZ EMPTY;
|
195 | | - UR SPECIAL mStripState IZ new StripState;
|
196 | | - UR SPECIAL mArgStack IZ false;
|
197 | | - UR SPECIAL mInPre IZ false;
|
198 | | - UR SPECIAL mLinkHolders IZ new LinkHolderArray( $this );
|
199 | | - UR SPECIAL mLinkID IZ 0;
|
200 | | - UR SPECIAL mRevisionTimestamp IZ $this->mRevisionId = null;
|
201 | | - UR SPECIAL mVarCache IZ EMPTY;
|
202 | | -
|
203 | | - DO NOT WANT
|
204 | | - NOT WANT Prefix for temporary replacement strings for the multipass parser.
|
205 | | - NOT WANT \x07 should never appear in input as it's disallowed in XML.
|
206 | | - NOT WANT Using it at the front also gives us a little extra robustness
|
207 | | - NOT WANT since it shouldn't match when butted up against identifier-like
|
208 | | - NOT WANT string constructs.
|
209 | | - NOT WANT
|
210 | | - NOT WANT Must not consist of all title characters, or else it will change
|
211 | | - NOT WANT the behaviour of <nowiki> in a link.
|
212 | | - WANT
|
213 | | - BTW $this->mUniqPrefix = "\x07UNIQ" . Parser::getRandomString();
|
214 | | - BTW Changed to \x7f to allow XML double-parsing -- TS
|
215 | | - UR SPECIAL mUniqPrefix IZ "\x7fUNIQ" . self::getRandomString();
|
216 | | -
|
217 | | -
|
218 | | - BTW Clear these on every parse, bug 4549
|
219 | | - UR SPECIAL mTplExpandCache IZ $this->mTplRedirCache = $this->mTplDomCache = array();
|
220 | | -
|
221 | | - UR SPECIAL mShowToc IZ true;
|
222 | | - UR SPECIAL mForceTocPosition IZ false;
|
223 | | - UR SPECIAL mIncludeSizes IZ BUCKET
|
224 | | - 'post-expand' => 0,
|
225 | | - 'arg' => 0,
|
226 | | - BUCKET
|
227 | | - UR SPECIAL mPPNodeCount IZ 0;
|
228 | | - UR SPECIAL mDefaultSort IZ false;
|
229 | | - UR SPECIAL mHeadings IZ EMPTY;
|
230 | | - UR SPECIAL mDoubleUnderscores IZ EMPTY;
|
231 | | - UR SPECIAL mExpensiveFunctionCount IZ 0;
|
232 | | -
|
233 | | - BTW Fix cloning
|
234 | | - IZ isset( $this->mPreprocessor ) && $this->mPreprocessor->parser !== $this
|
235 | | - UR SPECIAL mPreprocessor IZ null;
|
236 | | - KTHX
|
237 | | -
|
238 | | - IM ON UR wfRunHooks DOING 'ParserClearState', array( &$this )
|
239 | | - IM ON UR wfProfileOut DOING __METHOD__
|
240 | | - KTHX
|
241 | | -
|
242 | | - SO IM LIKE setOutputType WITH UR $ot
|
243 | | - UR SPECIAL mOutputType IZ $ot;
|
244 | | - BTW Shortcut alias
|
245 | | - UR SPECIAL ot IZ BUCKET
|
246 | | - 'html' => $ot == self::OT_HTML,
|
247 | | - 'wiki' => $ot == self::OT_WIKI,
|
248 | | - 'pre' => $ot == self::OT_PREPROCESS,
|
249 | | - 'plain' => $ot == self::OT_PLAIN,
|
250 | | - BUCKET
|
251 | | - KTHX
|
252 | | -
|
253 | | - DO NOT WANT
|
254 | | - NOT WANT Set the context title
|
255 | | - WANT
|
256 | | - SO IM LIKE setTitle WITH UR $t
|
257 | | - IZ !$t || $t instanceof FakeTitle
|
258 | | - I HAS t IZ Title::newFromText( 'NO TITLE' )
|
259 | | - KTHX
|
260 | | -
|
261 | | - IZ strval( $t->getFragment() ) !== ''
|
262 | | - BTW Strip the fragment to avoid various odd effects
|
263 | | - UR SPECIAL mTitle IZ clone $t;
|
264 | | - IM ON UR SPECIAL mTitle->setFragment DOING ''
|
265 | | - NOWAI
|
266 | | - UR SPECIAL mTitle IZ $t;
|
267 | | - KTHX
|
268 | | - KTHX
|
269 | | -
|
270 | | - DO NOT WANT
|
271 | | - NOT WANT Accessor for mUniqPrefix.
|
272 | | - NOT WANT
|
273 | | - NOT WANT @public
|
274 | | - WANT
|
275 | | - SO IM LIKE uniqPrefix
|
276 | | - IZ !isset( $this->mUniqPrefix )
|
277 | | - BTW @todo Fixme: this is probably *horribly wrong*
|
278 | | - BTW LanguageConverter seems to want $wgParser's uniqPrefix, however
|
279 | | - BTW if this is called for a parser cache hit, the parser may not
|
280 | | - BTW have ever been initialized in the first place.
|
281 | | - BTW Not really sure what the heck is supposed to be going on here.
|
282 | | - I FOUND MAH ''
|
283 | | - BTW throw new MWException( "Accessing uninitialized mUniqPrefix" );
|
284 | | - KTHX
|
285 | | - I FOUND MAH $this->mUniqPrefix
|
286 | | - KTHX
|
287 | | -
|
288 | | - DO NOT WANT
|
289 | | - NOT WANT Convert wikitext to HTML
|
290 | | - NOT WANT Do not call this function recursively.
|
291 | | - NOT WANT
|
292 | | - NOT WANT @param $text String: text we want to parse
|
293 | | - NOT WANT @param $title A title object
|
294 | | - NOT WANT @param $options ParserOptions
|
295 | | - NOT WANT @param $linestart boolean
|
296 | | - NOT WANT @param $clearState boolean
|
297 | | - NOT WANT @param $revid Int: number to pass in {{REVISIONID}}
|
298 | | - NOT WANT @return ParserOutput a ParserOutput
|
299 | | - WANT
|
300 | | - SO IM LIKE parse WITH UR $text, Title $title, ParserOptions $options, $linestart = true, $clearState = true, $revid = null
|
301 | | - DO NOT WANT
|
302 | | - NOT WANT First pass--just handle <nowiki> sections, pass the rest off
|
303 | | - NOT WANT to internalParse() which does all the real work.
|
304 | | - WANT
|
305 | | -
|
306 | | - I HAS UR $wgUseTidy, $wgAlwaysUseTidy, $wgContLang, $wgDisableLangConversion ON UR INTERNETS
|
307 | | - I HAS fname IZ __METHOD__.'-' . wfGetCaller()
|
308 | | - IM ON UR wfProfileIn DOING __METHOD__
|
309 | | - IM ON UR wfProfileIn DOING $fname
|
310 | | -
|
311 | | - IZ $clearState
|
312 | | - IM ON UR SPECIAL clearState
|
313 | | - KTHX
|
314 | | -
|
315 | | - UR SPECIAL mOptions IZ $options;
|
316 | | - IM ON UR SPECIAL setTitle DOING $title # Page title has to be set for the pre-processor
|
317 | | -
|
318 | | - I HAS oldRevisionId IZ $this->mRevisionId
|
319 | | - I HAS oldRevisionTimestamp IZ $this->mRevisionTimestamp
|
320 | | - IZ $revid !== null
|
321 | | - UR SPECIAL mRevisionId IZ $revid;
|
322 | | - UR SPECIAL mRevisionTimestamp IZ null;
|
323 | | - KTHX
|
324 | | - IM ON UR SPECIAL setOutputType DOING self::OT_HTML
|
325 | | - IM ON UR wfRunHooks DOING 'ParserBeforeStrip', array( &$this, &$text, &$this->mStripState )
|
326 | | - BTW No more strip!
|
327 | | - IM ON UR wfRunHooks DOING 'ParserAfterStrip', array( &$this, &$text, &$this->mStripState )
|
328 | | - I HAS text IZ $this->internalParse( $text )
|
329 | | -
|
330 | | - I HAS text IZ $this->mStripState->unstripGeneral( $text )
|
331 | | -
|
332 | | - BTW Clean up special characters, only run once, next-to-last before doBlockLevels
|
333 | | - I HAS fixtags IZ BUCKET
|
334 | | - BTW french spaces, last one Guillemet-left
|
335 | | - BTW only if there is something before the space
|
336 | | - '/(.) (?=\\?|:|;|!|%|\\302\\273)/' => '\\1 \\2',
|
337 | | - BTW french spaces, Guillemet-right
|
338 | | - '/(\\302\\253) /' => '\\1 ',
|
339 | | - '/ (!\s*important)/' => ' \\1', # Beware of CSS magic word !important, bug #11874.
|
340 | | - BUCKET
|
341 | | - I HAS text IZ preg_replace( array_keys( $fixtags ), array_values( $fixtags ), $text )
|
342 | | -
|
343 | | - I HAS text IZ $this->doBlockLevels( $text, $linestart )
|
344 | | -
|
345 | | - IM ON UR SPECIAL replaceLinkHolders DOING $text
|
346 | | -
|
347 | | - BTW The position of the convert() call should not be changed. it
|
348 | | - BTW assumes that the links are all replaced and the only thing left
|
349 | | - BTW is the <nowiki> mark.
|
350 | | - if ( !( $wgDisableLangConversion
|
351 | | - || isset( $this->mDoubleUnderscores['nocontentconvert'] )
|
352 | | - || $this->mTitle->isTalkPage()
|
353 | | - || $this->mTitle->isConversionTable() ) ) {
|
354 | | - I HAS text IZ $wgContLang->convert( $text )
|
355 | | - KTHX
|
356 | | -
|
357 | | - BTW A title may have been set in a conversion rule.
|
358 | | - BTW Note that if a user tries to set a title in a conversion
|
359 | | - BTW rule but content conversion was not done, then the parser
|
360 | | - BTW won't pick it up. This is probably expected behavior.
|
361 | | - IZ $wgContLang->getConvRuleTitle()
|
362 | | - IM ON UR SPECIAL mOutput->setTitleText DOING $wgContLang->getConvRuleTitle()
|
363 | | - KTHX
|
364 | | -
|
365 | | - I HAS text IZ $this->mStripState->unstripNoWiki( $text )
|
366 | | -
|
367 | | - IM ON UR wfRunHooks DOING 'ParserBeforeTidy', array( &$this, &$text )
|
368 | | -
|
369 | | -//!JF Move to its own function
|
370 | | -
|
371 | | - I HAS uniq_prefix IZ $this->mUniqPrefix
|
372 | | - I HAS matches IZ EMPTY
|
373 | | - I HAS elements IZ array_keys( $this->mTransparentTagHooks )
|
374 | | - I HAS text IZ self::extractTagsAndParams( $elements, $text, $matches, $uniq_prefix )
|
375 | | -
|
376 | | - IM IN UR matches ITZA marker => $data
|
377 | | - list( $element, $content, $params, $tag ) = $data;
|
378 | | - I HAS tagName IZ strtolower( $element )
|
379 | | - IZ isset( $this->mTransparentTagHooks[$tagName] )
|
380 | | - I HAS output IZ call_user_func_array( $this->mTransparentTagHooks[$tagName], array( $content, $params, $this ) )
|
381 | | - NOWAI
|
382 | | - I HAS output IZ $tag
|
383 | | - KTHX
|
384 | | - IM ON UR SPECIAL mStripState->general->setPair DOING $marker, $output
|
385 | | - KTHX
|
386 | | - I HAS text IZ $this->mStripState->unstripGeneral( $text )
|
387 | | -
|
388 | | - I HAS text IZ Sanitizer::normalizeCharReferences( $text )
|
389 | | -
|
390 | | - IZ ( $wgUseTidy && $this->mOptions->mTidy ) || $wgAlwaysUseTidy
|
391 | | - I HAS text IZ MWTidy::tidy( $text )
|
392 | | - NOWAI
|
393 | | - BTW attempt to sanitize at least some nesting problems
|
394 | | - BTW (bug #2702 and quite a few others)
|
395 | | - I HAS tidyregs IZ BUCKET
|
396 | | - BTW ''Something [http://www.cool.com cool''] -->
|
397 | | - BTW <i>Something</i><a href="http://www.cool.com"..><i>cool></i></a>
|
398 | | - '/(<([bi])>)(<([bi])>)?([^<]*)(<\/?a[^<]*>)([^<]*)(<\/\\4>)?(<\/\\2>)/' =>
|
399 | | - '\\1\\3\\5\\8\\9\\6\\1\\3\\7\\8\\9',
|
400 | | - BTW fix up an anchor inside another anchor, only
|
401 | | - BTW at least for a single single nested link (bug 3695)
|
402 | | - '/(<a[^>]+>)([^<]*)(<a[^>]+>[^<]*)<\/a>(.*)<\/a>/' =>
|
403 | | - '\\1\\2</a>\\3</a>\\1\\4</a>',
|
404 | | - BTW fix div inside inline elements- doBlockLevels won't wrap a line which
|
405 | | - BTW contains a div, so fix it up here; replace
|
406 | | - BTW div with escaped text
|
407 | | - '/(<([aib]) [^>]+>)([^<]*)(<div([^>]*)>)(.*)(<\/div>)([^<]*)(<\/\\2>)/' =>
|
408 | | - '\\1\\3<div\\5>\\6</div>\\8\\9',
|
409 | | - BTW remove empty italic or bold tag pairs, some
|
410 | | - BTW introduced by rules above
|
411 | | - '/<([bi])><\/\\1>/' => '',
|
412 | | - BUCKET
|
413 | | -
|
414 | | - text IZ preg_replace(
|
415 | | - array_keys( $tidyregs ),
|
416 | | - array_values( $tidyregs ),
|
417 | | - $text );
|
418 | | - KTHX
|
419 | | - I HAS UR $wgExpensiveParserFunctionLimit ON UR INTERNETS
|
420 | | - IZ $this->mExpensiveFunctionCount > $wgExpensiveParserFunctionLimit
|
421 | | - IM ON UR SPECIAL limitationWarn DOING 'expensive-parserfunction', $this->mExpensiveFunctionCount, $wgExpensiveParserFunctionLimit
|
422 | | - KTHX
|
423 | | -
|
424 | | - IM ON UR wfRunHooks DOING 'ParserAfterTidy', array( &$this, &$text )
|
425 | | -
|
426 | | - BTW Information on include size limits, for the benefit of users who try to skirt them
|
427 | | - IZ $this->mOptions->getEnableLimitReport()
|
428 | | - I HAS max IZ $this->mOptions->getMaxIncludeSize()
|
429 | | - I HAS PFreport IZ "Expensive parser function count: {$this->mExpensiveFunctionCount}/$wgExpensiveParserFunctionLimit\n"
|
430 | | - $limitReport =
|
431 | | - "NewPP limit report\n" .
|
432 | | - "Preprocessor node count: {$this->mPPNodeCount}/{$this->mOptions->mMaxPPNodeCount}\n" .
|
433 | | - "Post-expand include size: {$this->mIncludeSizes['post-expand']}/$max bytes\n" .
|
434 | | - "Template argument size: {$this->mIncludeSizes['arg']}/$max bytes\n".
|
435 | | - I HAS PFreport
|
436 | | - IM ON UR wfRunHooks DOING 'ParserLimitReport', array( $this, &$limitReport )
|
437 | | - text HAS MOAR "\n<!-- \n$limitReport-->\n";
|
438 | | - KTHX
|
439 | | - IM ON UR SPECIAL mOutput->setText DOING $text
|
440 | | -
|
441 | | - UR SPECIAL mRevisionId IZ $oldRevisionId;
|
442 | | - UR SPECIAL mRevisionTimestamp IZ $oldRevisionTimestamp;
|
443 | | - IM ON UR wfProfileOut DOING $fname
|
444 | | - IM ON UR wfProfileOut DOING __METHOD__
|
445 | | -
|
446 | | - I FOUND MAH $this->mOutput
|
447 | | - KTHX
|
448 | | -
|
449 | | - DO NOT WANT
|
450 | | - NOT WANT Recursive parser entry point that can be called from an extension tag
|
451 | | - NOT WANT hook.
|
452 | | - NOT WANT
|
453 | | - NOT WANT If $frame is not provided, then template variables (e.g., {{{1}}}) within $text are not expanded
|
454 | | - NOT WANT
|
455 | | - NOT WANT @param $text String: text extension wants to have parsed
|
456 | | - NOT WANT @param PPFrame $frame: The frame to use for expanding any template variables
|
457 | | - WANT
|
458 | | - SO IM LIKE recursiveTagParse WITH UR $text, $frame=false
|
459 | | - IM ON UR wfProfileIn DOING __METHOD__
|
460 | | - IM ON UR wfRunHooks DOING 'ParserBeforeStrip', array( &$this, &$text, &$this->mStripState )
|
461 | | - IM ON UR wfRunHooks DOING 'ParserAfterStrip', array( &$this, &$text, &$this->mStripState )
|
462 | | - I HAS text IZ $this->internalParse( $text, false, $frame )
|
463 | | - IM ON UR wfProfileOut DOING __METHOD__
|
464 | | - I FOUND MAH $text
|
465 | | - KTHX
|
466 | | -
|
467 | | - DO NOT WANT
|
468 | | - NOT WANT Expand templates and variables in the text, producing valid, static wikitext.
|
469 | | - NOT WANT Also removes comments.
|
470 | | - WANT
|
471 | | - SO IM LIKE preprocess WITH UR $text, $title, $options, $revid = null
|
472 | | - IM ON UR wfProfileIn DOING __METHOD__
|
473 | | - IM ON UR SPECIAL clearState
|
474 | | - IM ON UR SPECIAL setOutputType DOING self::OT_PREPROCESS
|
475 | | - UR SPECIAL mOptions IZ $options;
|
476 | | - IM ON UR SPECIAL setTitle DOING $title
|
477 | | - IZ $revid !== null
|
478 | | - UR SPECIAL mRevisionId IZ $revid;
|
479 | | - KTHX
|
480 | | - IM ON UR wfRunHooks DOING 'ParserBeforeStrip', array( &$this, &$text, &$this->mStripState )
|
481 | | - IM ON UR wfRunHooks DOING 'ParserAfterStrip', array( &$this, &$text, &$this->mStripState )
|
482 | | - I HAS text IZ $this->replaceVariables( $text )
|
483 | | - I HAS text IZ $this->mStripState->unstripBoth( $text )
|
484 | | - IM ON UR wfProfileOut DOING __METHOD__
|
485 | | - I FOUND MAH $text
|
486 | | - KTHX
|
487 | | -
|
488 | | - DO NOT WANT
|
489 | | - NOT WANT Process the wikitext for the ?preload= feature. (bug 5210)
|
490 | | - NOT WANT
|
491 | | - NOT WANT <noinclude>, <includeonly> etc. are parsed as for template transclusion,
|
492 | | - NOT WANT comments, templates, arguments, tags hooks and parser functions are untouched.
|
493 | | - WANT
|
494 | | - SO IM LIKE getPreloadText WITH UR $text, $title, $options
|
495 | | - BTW Parser (re)initialisation
|
496 | | - IM ON UR SPECIAL clearState
|
497 | | - IM ON UR SPECIAL setOutputType DOING self::OT_PLAIN
|
498 | | - UR SPECIAL mOptions IZ $options;
|
499 | | - IM ON UR SPECIAL setTitle DOING $title
|
500 | | -
|
501 | | - I HAS flags IZ PPFrame::NO_ARGS | PPFrame::NO_TEMPLATES
|
502 | | - I HAS dom IZ $this->preprocessToDom( $text, self::PTD_FOR_INCLUSION )
|
503 | | - I FOUND MAH $this->getPreprocessor()->newFrame()->expand( $dom, $flags )
|
504 | | - KTHX
|
505 | | -
|
506 | | - DO NOT WANT
|
507 | | - NOT WANT Get a random string
|
508 | | - NOT WANT
|
509 | | - NOT WANT @private
|
510 | | - NOT WANT @static
|
511 | | - WANT
|
512 | | - SO IM LIKE getRandomString
|
513 | | - I FOUND MAH dechex( mt_rand( 0, 0x7fffffff ) ) . dechex( mt_rand( 0, 0x7fffffff ) )
|
514 | | - KTHX
|
515 | | -
|
516 | | - function &getTitle() { return $this->mTitle; }
|
517 | | - SO IM LIKE getOptions TESTING UR return $this->mOptions;
|
518 | | - SO IM LIKE getRevisionId TESTING UR return $this->mRevisionId;
|
519 | | - SO IM LIKE getOutput TESTING UR return $this->mOutput;
|
520 | | - SO IM LIKE nextLinkID TESTING UR return $this->mLinkID++;
|
521 | | -
|
522 | | - SO IM LIKE getFunctionLang
|
523 | | - I HAS UR $wgLang, $wgContLang ON UR INTERNETS
|
524 | | -
|
525 | | - I HAS target IZ $this->mOptions->getTargetLanguage()
|
526 | | - IZ $target !== null
|
527 | | - I FOUND MAH $target
|
528 | | - NOWAI
|
529 | | - I FOUND MAH $this->mOptions->getInterfaceMessage() ? $wgLang : $wgContLang
|
530 | | - KTHX
|
531 | | - KTHX
|
532 | | -
|
533 | | - DO NOT WANT
|
534 | | - NOT WANT Get a preprocessor object
|
535 | | - WANT
|
536 | | - SO IM LIKE getPreprocessor
|
537 | | - IZ !isset( $this->mPreprocessor )
|
538 | | - I HAS class IZ $this->mPreprocessorClass
|
539 | | - UR SPECIAL mPreprocessor IZ new $class( $this );
|
540 | | - KTHX
|
541 | | - I FOUND MAH $this->mPreprocessor
|
542 | | - KTHX
|
543 | | -
|
544 | | - DO NOT WANT
|
545 | | - NOT WANT Replaces all occurrences of HTML-style comments and the given tags
|
546 | | - NOT WANT in the text with a random marker and returns the next text. The output
|
547 | | - NOT WANT parameter $matches will be an associative array filled with data in
|
548 | | - NOT WANT the form:
|
549 | | - NOT WANT 'UNIQ-xxxxx' => array(
|
550 | | - NOT WANT 'element',
|
551 | | - NOT WANT 'tag content',
|
552 | | - NOT WANT array( 'param' => 'x' ),
|
553 | | - NOT WANT '<element param="x">tag content</element>' ) )
|
554 | | - NOT WANT
|
555 | | - NOT WANT @param $elements list of element names. Comments are always extracted.
|
556 | | - NOT WANT @param $text Source text string.
|
557 | | - NOT WANT @param $uniq_prefix
|
558 | | - NOT WANT
|
559 | | - NOT WANT @public
|
560 | | - NOT WANT @static
|
561 | | - WANT
|
562 | | - SO IM LIKE extractTagsAndParams WITH UR $elements, $text, &$matches, $uniq_prefix = ''
|
563 | | - static $n = 1;
|
564 | | - I HAS stripped IZ ''
|
565 | | - I HAS matches IZ EMPTY
|
566 | | -
|
567 | | - I HAS taglist IZ implode( '|', $elements )
|
568 | | - I HAS start IZ "/<($taglist)(\\s+[^>]*?|\\s*?)(\/?" . ">)|<(!--)/i"
|
569 | | -
|
570 | | - STEALIN UR $text != ''
|
571 | | - I HAS p IZ preg_split( $start, $text, 2, PREG_SPLIT_DELIM_CAPTURE )
|
572 | | - stripped HAS MOAR $p[0];
|
573 | | - IZ count( $p ) < 5
|
574 | | - break;
|
575 | | - KTHX
|
576 | | - IZ count( $p ) > 5
|
577 | | - BTW comment
|
578 | | - I HAS element IZ $p[4]
|
579 | | - I HAS attributes IZ ''
|
580 | | - I HAS close IZ ''
|
581 | | - I HAS inside IZ $p[5]
|
582 | | - NOWAI
|
583 | | - BTW tag
|
584 | | - I HAS element IZ $p[1]
|
585 | | - I HAS attributes IZ $p[2]
|
586 | | - I HAS close IZ $p[3]
|
587 | | - I HAS inside IZ $p[4]
|
588 | | - KTHX
|
589 | | -
|
590 | | - I HAS marker IZ "$uniq_prefix-$element-" . sprintf( '%08X', $n++ ) . self::MARKER_SUFFIX
|
591 | | - stripped HAS MOAR $marker;
|
592 | | -
|
593 | | - IZ $close === '/>'
|
594 | | - BTW Empty element tag, <tag />
|
595 | | - I HAS content
|
596 | | - I HAS text IZ $inside
|
597 | | - I HAS tail
|
598 | | - NOWAI
|
599 | | - IZ $element === '!--'
|
600 | | - I HAS end IZ '/(-->)/'
|
601 | | - NOWAI
|
602 | | - I HAS end IZ "/(<\\/$element\\s*>)/i"
|
603 | | - KTHX
|
604 | | - I HAS q IZ preg_split( $end, $inside, 2, PREG_SPLIT_DELIM_CAPTURE )
|
605 | | - I HAS content IZ $q[0]
|
606 | | - IZ count( $q ) < 3
|
607 | | - BTW No end tag -- let it run out to the end of the text.
|
608 | | - I HAS tail IZ ''
|
609 | | - I HAS text IZ ''
|
610 | | - NOWAI
|
611 | | - I HAS tail IZ $q[1]
|
612 | | - I HAS text IZ $q[2]
|
613 | | - KTHX
|
614 | | - KTHX
|
615 | | -
|
616 | | - $matches[$marker] = array( $element,
|
617 | | - $content,
|
618 | | - Sanitizer::decodeTagAttributes( $attributes ),
|
619 | | - "<$element$attributes$close$content$tail" );
|
620 | | - KTHX
|
621 | | - I FOUND MAH $stripped
|
622 | | - KTHX
|
623 | | -
|
624 | | - DO NOT WANT
|
625 | | - NOT WANT Get a list of strippable XML-like elements
|
626 | | - WANT
|
627 | | - SO IM LIKE getStripList
|
628 | | - I FOUND MAH $this->mStripList
|
629 | | - KTHX
|
630 | | -
|
631 | | - DO NOT WANT
|
632 | | - NOT WANT @deprecated use replaceVariables
|
633 | | - WANT
|
634 | | - SO IM LIKE strip WITH UR $text, $state, $stripcomments = false , $dontstrip = array()
|
635 | | - I FOUND MAH $text
|
636 | | - KTHX
|
637 | | -
|
638 | | - DO NOT WANT
|
639 | | - NOT WANT Restores pre, math, and other extensions removed by strip()
|
640 | | - NOT WANT
|
641 | | - NOT WANT always call unstripNoWiki() after this one
|
642 | | - NOT WANT @private
|
643 | | - NOT WANT @deprecated use $this->mStripState->unstrip()
|
644 | | - WANT
|
645 | | - SO IM LIKE unstrip WITH UR $text, $state
|
646 | | - I FOUND MAH $state->unstripGeneral( $text )
|
647 | | - KTHX
|
648 | | -
|
649 | | - DO NOT WANT
|
650 | | - NOT WANT Always call this after unstrip() to preserve the order
|
651 | | - NOT WANT
|
652 | | - NOT WANT @private
|
653 | | - NOT WANT @deprecated use $this->mStripState->unstrip()
|
654 | | - WANT
|
655 | | - SO IM LIKE unstripNoWiki WITH UR $text, $state
|
656 | | - I FOUND MAH $state->unstripNoWiki( $text )
|
657 | | - KTHX
|
658 | | -
|
659 | | - DO NOT WANT
|
660 | | - NOT WANT @deprecated use $this->mStripState->unstripBoth()
|
661 | | - WANT
|
662 | | - SO IM LIKE unstripForHTML WITH UR $text
|
663 | | - I FOUND MAH $this->mStripState->unstripBoth( $text )
|
664 | | - KTHX
|
665 | | -
|
666 | | - DO NOT WANT
|
667 | | - NOT WANT Add an item to the strip state
|
668 | | - NOT WANT Returns the unique tag which must be inserted into the stripped text
|
669 | | - NOT WANT The tag will be replaced with the original text in unstrip()
|
670 | | - NOT WANT
|
671 | | - NOT WANT @private
|
672 | | - WANT
|
673 | | - SO IM LIKE insertStripItem WITH UR $text
|
674 | | - I HAS rnd IZ "{$this->mUniqPrefix}-item-{$this->mMarkerIndex}-" . self::MARKER_SUFFIX
|
675 | | - $this->mMarkerIndex++;
|
676 | | - IM ON UR SPECIAL mStripState->general->setPair DOING $rnd, $text
|
677 | | - I FOUND MAH $rnd
|
678 | | - KTHX
|
679 | | -
|
680 | | - DO NOT WANT
|
681 | | - NOT WANT Interface with html tidy
|
682 | | - NOT WANT @deprecated Use MWTidy::tidy()
|
683 | | - WANT
|
684 | | - SO IM ALWAYS LIKE tidy WITH UR $text
|
685 | | - IM ON UR wfDeprecated DOING __METHOD__
|
686 | | - I FOUND MAH MWTidy::tidy( $text )
|
687 | | - KTHX
|
688 | | -
|
689 | | - DO NOT WANT
|
690 | | - NOT WANT parse the wiki syntax used to render tables
|
691 | | - NOT WANT
|
692 | | - NOT WANT @private
|
693 | | - WANT
|
694 | | - SO IM LIKE doTableStuff WITH UR $text
|
695 | | - IM ON UR wfProfileIn DOING __METHOD__
|
696 | | -
|
697 | | - I HAS lines IZ StringUtils::explode( "\n", $text )
|
698 | | - I HAS out IZ ''
|
699 | | - I HAS td_history IZ EMPTY # Is currently a td tag open?
|
700 | | - I HAS last_tag_history IZ EMPTY # Save history of last lag activated (td, th or caption)
|
701 | | - I HAS tr_history IZ EMPTY # Is currently a tr tag open?
|
702 | | - I HAS tr_attributes IZ EMPTY # history of tr attributes
|
703 | | - I HAS has_opened_tr IZ EMPTY # Did this table open a <tr> element?
|
704 | | - I HAS indent_level IZ 0 # indent level of the table
|
705 | | -
|
706 | | - IM IN UR lines ITZA outLine
|
707 | | - I HAS line IZ trim( $outLine )
|
708 | | -
|
709 | | - IZ $line == '' # empty line, go to next line
|
710 | | - out HAS MOAR $outLine."\n";
|
711 | | - continue;
|
712 | | - KTHX
|
713 | | - I HAS first_character IZ $line[0]
|
714 | | - I HAS matches IZ EMPTY
|
715 | | -
|
716 | | - IZ preg_match( '/^(:*)\{\|(.*)$/', $line , $matches )
|
717 | | - BTW First check if we are starting a new table
|
718 | | - I HAS indent_level IZ strlen( $matches[1] )
|
719 | | -
|
720 | | - I HAS attributes IZ $this->mStripState->unstripBoth( $matches[2] )
|
721 | | - I HAS attributes IZ Sanitizer::fixTagAttributes( $attributes , 'table' )
|
722 | | -
|
723 | | - I HAS outLine IZ str_repeat( '<dl><dd>' , $indent_level ) . "<table{$attributes}>"
|
724 | | - IM ON UR array_push DOING $td_history , false
|
725 | | - IM ON UR array_push DOING $last_tag_history , ''
|
726 | | - IM ON UR array_push DOING $tr_history , false
|
727 | | - IM ON UR array_push DOING $tr_attributes , ''
|
728 | | - IM ON UR array_push DOING $has_opened_tr , false
|
729 | | - ORLY count( $td_history ) == 0
|
730 | | - BTW Don't do any of the following
|
731 | | - out HAS MOAR $outLine."\n";
|
732 | | - continue;
|
733 | | - ORLY substr( $line , 0 , 2 ) === '|}'
|
734 | | - BTW We are ending a table
|
735 | | - I HAS line IZ '</table>' . substr( $line , 2 )
|
736 | | - I HAS last_tag IZ array_pop( $last_tag_history )
|
737 | | -
|
738 | | - IZ !array_pop( $has_opened_tr )
|
739 | | - I HAS line IZ "<tr><td></td></tr>{$line}"
|
740 | | - KTHX
|
741 | | -
|
742 | | - IZ array_pop( $tr_history )
|
743 | | - I HAS line IZ "</tr>{$line}"
|
744 | | - KTHX
|
745 | | -
|
746 | | - IZ array_pop( $td_history )
|
747 | | - I HAS line IZ "</{$last_tag}>{$line}"
|
748 | | - KTHX
|
749 | | - IM ON UR array_pop DOING $tr_attributes
|
750 | | - I HAS outLine IZ $line . str_repeat( '</dd></dl>' , $indent_level )
|
751 | | - ORLY substr( $line , 0 , 2 ) === '|-'
|
752 | | - BTW Now we have a table row
|
753 | | - I HAS line IZ preg_replace( '#^\|-+#', '', $line )
|
754 | | -
|
755 | | - BTW Whats after the tag is now only attributes
|
756 | | - I HAS attributes IZ $this->mStripState->unstripBoth( $line )
|
757 | | - I HAS attributes IZ Sanitizer::fixTagAttributes( $attributes, 'tr' )
|
758 | | - IM ON UR array_pop DOING $tr_attributes
|
759 | | - IM ON UR array_push DOING $tr_attributes, $attributes
|
760 | | -
|
761 | | - I HAS line IZ ''
|
762 | | - I HAS last_tag IZ array_pop( $last_tag_history )
|
763 | | - IM ON UR array_pop DOING $has_opened_tr
|
764 | | - IM ON UR array_push DOING $has_opened_tr , true
|
765 | | -
|
766 | | - IZ array_pop( $tr_history )
|
767 | | - I HAS line IZ '</tr>'
|
768 | | - KTHX
|
769 | | -
|
770 | | - IZ array_pop( $td_history )
|
771 | | - I HAS line IZ "</{$last_tag}>{$line}"
|
772 | | - KTHX
|
773 | | -
|
774 | | - I HAS outLine IZ $line
|
775 | | - IM ON UR array_push DOING $tr_history , false
|
776 | | - IM ON UR array_push DOING $td_history , false
|
777 | | - IM ON UR array_push DOING $last_tag_history , ''
|
778 | | - ORLY $first_character === '|' || $first_character === '!' || substr( $line , 0 , 2 ) === '|+'
|
779 | | - BTW This might be cell elements, td, th or captions
|
780 | | - IZ substr( $line , 0 , 2 ) === '|+'
|
781 | | - I HAS first_character IZ '+'
|
782 | | - I HAS line IZ substr( $line , 1 )
|
783 | | - KTHX
|
784 | | -
|
785 | | - I HAS line IZ substr( $line , 1 )
|
786 | | -
|
787 | | - IZ $first_character === '!'
|
788 | | - I HAS line IZ str_replace( '!!' , '||' , $line )
|
789 | | - KTHX
|
790 | | -
|
791 | | - BTW Split up multiple cells on the same line.
|
792 | | - BTW FIXME : This can result in improper nesting of tags processed
|
793 | | - BTW by earlier parser steps, but should avoid splitting up eg
|
794 | | - BTW attribute values containing literal "||".
|
795 | | - I HAS cells IZ StringUtils::explodeMarkup( '||' , $line )
|
796 | | -
|
797 | | - I HAS outLine IZ ''
|
798 | | -
|
799 | | - BTW Loop through each table cell
|
800 | | - IM IN UR cells ITZA cell
|
801 | | - I HAS previous IZ ''
|
802 | | - IZ $first_character !== '+'
|
803 | | - I HAS tr_after IZ array_pop( $tr_attributes )
|
804 | | - IZ !array_pop( $tr_history )
|
805 | | - I HAS previous IZ "<tr{$tr_after}>\n"
|
806 | | - KTHX
|
807 | | - IM ON UR array_push DOING $tr_history , true
|
808 | | - IM ON UR array_push DOING $tr_attributes , ''
|
809 | | - IM ON UR array_pop DOING $has_opened_tr
|
810 | | - IM ON UR array_push DOING $has_opened_tr , true
|
811 | | - KTHX
|
812 | | -
|
813 | | - I HAS last_tag IZ array_pop( $last_tag_history )
|
814 | | -
|
815 | | - IZ array_pop( $td_history )
|
816 | | - I HAS previous IZ "</{$last_tag}>{$previous}"
|
817 | | - KTHX
|
818 | | -
|
819 | | - IZ $first_character === '|'
|
820 | | - I HAS last_tag IZ 'td'
|
821 | | - ORLY $first_character === '!'
|
822 | | - I HAS last_tag IZ 'th'
|
823 | | - ORLY $first_character === '+'
|
824 | | - I HAS last_tag IZ 'caption'
|
825 | | - NOWAI
|
826 | | - I HAS last_tag IZ ''
|
827 | | - KTHX
|
828 | | -
|
829 | | - IM ON UR array_push DOING $last_tag_history , $last_tag
|
830 | | -
|
831 | | - BTW A cell could contain both parameters and data
|
832 | | - I HAS cell_data IZ explode( '|' , $cell , 2 )
|
833 | | -
|
834 | | - BTW Bug 553: Note that a '|' inside an invalid link should not
|
835 | | - BTW be mistaken as delimiting cell parameters
|
836 | | - IZ strpos( $cell_data[0], '[[' ) !== false
|
837 | | - I HAS cell IZ "{$previous}<{$last_tag}>{$cell}"
|
838 | | - ORLY count( $cell_data ) == 1
|
839 | | - I HAS cell IZ "{$previous}<{$last_tag}>{$cell_data[0]}"
|
840 | | - NOWAI
|
841 | | - I HAS attributes IZ $this->mStripState->unstripBoth( $cell_data[0] )
|
842 | | - I HAS attributes IZ Sanitizer::fixTagAttributes( $attributes , $last_tag )
|
843 | | - I HAS cell IZ "{$previous}<{$last_tag}{$attributes}>{$cell_data[1]}"
|
844 | | - KTHX
|
845 | | -
|
846 | | - outLine HAS MOAR $cell;
|
847 | | - IM ON UR array_push DOING $td_history , true
|
848 | | - KTHX
|
849 | | - KTHX
|
850 | | - out HAS MOAR $outLine . "\n";
|
851 | | - KTHX
|
852 | | -
|
853 | | - BTW Closing open td, tr && table
|
854 | | - STEALIN UR count( $td_history ) > 0
|
855 | | - IZ array_pop( $td_history )
|
856 | | - out HAS MOAR "</td>\n";
|
857 | | - KTHX
|
858 | | - IZ array_pop( $tr_history )
|
859 | | - out HAS MOAR "</tr>\n";
|
860 | | - KTHX
|
861 | | - IZ !array_pop( $has_opened_tr )
|
862 | | - out HAS MOAR "<tr><td></td></tr>\n" ;
|
863 | | - KTHX
|
864 | | -
|
865 | | - out HAS MOAR "</table>\n";
|
866 | | - KTHX
|
867 | | -
|
868 | | - BTW Remove trailing line-ending (b/c)
|
869 | | - IZ substr( $out, -1 ) === "\n"
|
870 | | - I HAS out IZ substr( $out, 0, -1 )
|
871 | | - KTHX
|
872 | | -
|
873 | | - BTW special case: don't return empty table
|
874 | | - IZ $out === "<table>\n<tr><td></td></tr>\n</table>"
|
875 | | - I HAS out IZ ''
|
876 | | - KTHX
|
877 | | -
|
878 | | - IM ON UR wfProfileOut DOING __METHOD__
|
879 | | -
|
880 | | - I FOUND MAH $out
|
881 | | - KTHX
|
882 | | -
|
883 | | - DO NOT WANT
|
884 | | - NOT WANT Helper function for parse() that transforms wiki markup into
|
885 | | - NOT WANT HTML. Only called for $mOutputType == self::OT_HTML.
|
886 | | - NOT WANT
|
887 | | - NOT WANT @private
|
888 | | - WANT
|
889 | | - SO IM LIKE internalParse WITH UR $text, $isMain = true, $frame=false
|
890 | | - IM ON UR wfProfileIn DOING __METHOD__
|
891 | | -
|
892 | | - I HAS origText IZ $text
|
893 | | -
|
894 | | - BTW Hook to suspend the parser in this state
|
895 | | - IZ !wfRunHooks( 'ParserBeforeInternalParse', array( &$this, &$text, &$this->mStripState ) )
|
896 | | - IM ON UR wfProfileOut DOING __METHOD__
|
897 | | - I FOUND MAH $text
|
898 | | - KTHX
|
899 | | -
|
900 | | - BTW if $frame is provided, then use $frame for replacing any variables
|
901 | | - IZ $frame
|
902 | | - BTW use frame depth to infer how include/noinclude tags should be handled
|
903 | | - BTW depth=0 means this is the top-level document; otherwise it's an included document
|
904 | | - IZ !$frame->depth
|
905 | | - I HAS flag IZ 0
|
906 | | - NOWAI
|
907 | | - I HAS flag IZ Parser::PTD_FOR_INCLUSION
|
908 | | - I HAS dom IZ $this->preprocessToDom( $text, $flag )
|
909 | | - I HAS text IZ $frame->expand( $dom )
|
910 | | - KTHX
|
911 | | - NOWAI
|
912 | | - BTW if $frame is not provided, then use old-style replaceVariables
|
913 | | - I HAS text IZ $this->replaceVariables( $text )
|
914 | | - KTHX
|
915 | | -
|
916 | | - I HAS text IZ Sanitizer::removeHTMLtags( $text, array( &$this, 'attributeStripCallback' ), false, array_keys( $this->mTransparentTagHooks ) )
|
917 | | - IM ON UR wfRunHooks DOING 'InternalParseBeforeLinks', array( &$this, &$text, &$this->mStripState )
|
918 | | -
|
919 | | - BTW Tables need to come after variable replacement for things to work
|
920 | | - BTW properly; putting them before other transformations should keep
|
921 | | - BTW exciting things like link expansions from showing up in surprising
|
922 | | - BTW places.
|
923 | | - I HAS text IZ $this->doTableStuff( $text )
|
924 | | -
|
925 | | - I HAS text IZ preg_replace( '/(^|\n)-----*/', '\\1<hr />', $text )
|
926 | | -
|
927 | | - I HAS text IZ $this->doDoubleUnderscore( $text )
|
928 | | -
|
929 | | - I HAS text IZ $this->doHeadings( $text )
|
930 | | - IZ $this->mOptions->getUseDynamicDates()
|
931 | | - I HAS df IZ DateFormatter::getInstance()
|
932 | | - I HAS text IZ $df->reformat( $this->mOptions->getDateFormat(), $text )
|
933 | | - KTHX
|
934 | | - I HAS text IZ $this->doAllQuotes( $text )
|
935 | | - I HAS text IZ $this->replaceInternalLinks( $text )
|
936 | | - I HAS text IZ $this->replaceExternalLinks( $text )
|
937 | | -
|
938 | | - BTW replaceInternalLinks may sometimes leave behind
|
939 | | - BTW absolute URLs, which have to be masked to hide them from replaceExternalLinks
|
940 | | - I HAS text IZ str_replace( $this->mUniqPrefix.'NOPARSE', '', $text )
|
941 | | -
|
942 | | - I HAS text IZ $this->doMagicLinks( $text )
|
943 | | - I HAS text IZ $this->formatHeadings( $text, $origText, $isMain )
|
944 | | -
|
945 | | - IM ON UR wfProfileOut DOING __METHOD__
|
946 | | - I FOUND MAH $text
|
947 | | - KTHX
|
948 | | -
|
949 | | - DO NOT WANT
|
950 | | - NOT WANT Replace special strings like "ISBN xxx" and "RFC xxx" with
|
951 | | - NOT WANT magic external links.
|
952 | | - NOT WANT
|
953 | | - NOT WANT DML
|
954 | | - NOT WANT @private
|
955 | | - WANT
|
956 | | - SO IM LIKE doMagicLinks WITH UR $text
|
957 | | - IM ON UR wfProfileIn DOING __METHOD__
|
958 | | - I HAS prots IZ $this->mUrlProtocols
|
959 | | - I HAS urlChar IZ self::EXT_LINK_URL_CLASS
|
960 | | - text IZ preg_replace_callback(
|
961 | | - '!(?: # Start cases
|
962 | | - (<a[ \t\r\n>].*?</a>) | # m[1]: Skip link text
|
963 | | - (<.*?>) | # m[2]: Skip stuff inside HTML elements' . "
|
964 | | - (\\b(?:$prots)$urlChar+) | # m[3]: Free external links" . '
|
965 | | - (?:RFC|PMID)\s+([0-9]+) | # m[4]: RFC or PMID, capture number
|
966 | | - ISBN\s+(\b # m[5]: ISBN, capture number
|
967 | | - (?: 97[89] [\ \-]? )? # optional 13-digit ISBN prefix
|
968 | | - (?: [0-9] [\ \-]? ){9} # 9 digits with opt. delimiters
|
969 | | - [0-9Xx] # check digit
|
970 | | - \b)
|
971 | | - )!x', array( &$this, 'magicLinkCallback' ), $text );
|
972 | | - IM ON UR wfProfileOut DOING __METHOD__
|
973 | | - I FOUND MAH $text
|
974 | | - KTHX
|
975 | | -
|
976 | | - SO IM LIKE magicLinkCallback WITH UR $m
|
977 | | - IZ isset( $m[1] ) && $m[1] !== ''
|
978 | | - BTW Skip anchor
|
979 | | - I FOUND MAH $m[0]
|
980 | | - ORLY isset( $m[2] ) && $m[2] !== ''
|
981 | | - BTW Skip HTML element
|
982 | | - I FOUND MAH $m[0]
|
983 | | - ORLY isset( $m[3] ) && $m[3] !== ''
|
984 | | - BTW Free external link
|
985 | | - I FOUND MAH $this->makeFreeExternalLink( $m[0] )
|
986 | | - ORLY isset( $m[4] ) && $m[4] !== ''
|
987 | | - BTW RFC or PMID
|
988 | | - I HAS CssClass IZ ''
|
989 | | - IZ substr( $m[0], 0, 3 ) === 'RFC'
|
990 | | - I HAS keyword IZ 'RFC'
|
991 | | - I HAS urlmsg IZ 'rfcurl'
|
992 | | - I HAS CssClass IZ 'mw-magiclink-rfc'
|
993 | | - I HAS id IZ $m[4]
|
994 | | - ORLY substr( $m[0], 0, 4 ) === 'PMID'
|
995 | | - I HAS keyword IZ 'PMID'
|
996 | | - I HAS urlmsg IZ 'pubmedurl'
|
997 | | - I HAS CssClass IZ 'mw-magiclink-pmid'
|
998 | | - I HAS id IZ $m[4]
|
999 | | - NOWAI
|
1000 | | - throw new MWException( __METHOD__.': unrecognised match type "' .
|
1001 | | - IM ON UR substr DOING $m[0], 0, 20 ) . '"'
|
1002 | | - KTHX
|
1003 | | - I HAS url IZ wfMsg( $urlmsg, $id)
|
1004 | | - I HAS sk IZ $this->mOptions->getSkin()
|
1005 | | - I HAS la IZ $sk->getExternalLinkAttributes( "external $CssClass" )
|
1006 | | - I FOUND MAH "<a href=\"{$url}\"{$la}>{$keyword} {$id}</a>"
|
1007 | | - ORLY isset( $m[5] ) && $m[5] !== ''
|
1008 | | - BTW ISBN
|
1009 | | - I HAS isbn IZ $m[5]
|
1010 | | - num IZ strtr( $isbn, array(
|
1011 | | - '-' => '',
|
1012 | | - ' ' => '',
|
1013 | | - 'x' => 'X',
|
1014 | | - ));
|
1015 | | - I HAS titleObj IZ SpecialPage::getTitleFor( 'Booksources', $num )
|
1016 | | - return'<a href="' .
|
1017 | | - $titleObj->escapeLocalUrl() .
|
1018 | | - "\" class=\"internal mw-magiclink-isbn\">ISBN $isbn</a>";
|
1019 | | - NOWAI
|
1020 | | - I FOUND MAH $m[0]
|
1021 | | - KTHX
|
1022 | | - KTHX
|
1023 | | -
|
1024 | | - DO NOT WANT
|
1025 | | - NOT WANT Make a free external link, given a user-supplied URL
|
1026 | | - NOT WANT @return HTML
|
1027 | | - NOT WANT @private
|
1028 | | - WANT
|
1029 | | - SO IM LIKE makeFreeExternalLink WITH UR $url
|
1030 | | - I HAS UR $wgContLang ON UR INTERNETS
|
1031 | | - IM ON UR wfProfileIn DOING __METHOD__
|
1032 | | -
|
1033 | | - I HAS sk IZ $this->mOptions->getSkin()
|
1034 | | - I HAS trail IZ ''
|
1035 | | -
|
1036 | | - BTW The characters '<' and '>' (which were escaped by
|
1037 | | - BTW removeHTMLtags()) should not be included in
|
1038 | | - BTW URLs, per RFC 2396.
|
1039 | | - I HAS m2 IZ EMPTY
|
1040 | | - IZ preg_match( '/&(lt|gt);/', $url, $m2, PREG_OFFSET_CAPTURE )
|
1041 | | - I HAS trail IZ substr( $url, $m2[0][1] ) . $trail
|
1042 | | - I HAS url IZ substr( $url, 0, $m2[0][1] )
|
1043 | | - KTHX
|
1044 | | -
|
1045 | | - BTW Move trailing punctuation to $trail
|
1046 | | - I HAS sep IZ ',;\.:!?'
|
1047 | | - BTW If there is no left bracket, then consider right brackets fair game too
|
1048 | | - IZ strpos( $url, '(' ) === false
|
1049 | | - sep HAS MOAR ')';
|
1050 | | - KTHX
|
1051 | | -
|
1052 | | - I HAS numSepChars IZ strspn( strrev( $url ), $sep )
|
1053 | | - IZ $numSepChars
|
1054 | | - I HAS trail IZ substr( $url, -$numSepChars ) . $trail
|
1055 | | - I HAS url IZ substr( $url, 0, -$numSepChars )
|
1056 | | - KTHX
|
1057 | | -
|
1058 | | - I HAS url IZ Sanitizer::cleanUrl( $url )
|
1059 | | -
|
1060 | | - BTW Is this an external image?
|
1061 | | - I HAS text IZ $this->maybeMakeExternalImage( $url )
|
1062 | | - IZ $text === false
|
1063 | | - BTW Not an image, make a link
|
1064 | | - text IZ $sk->makeExternalLink( $url, $wgContLang->markNoConversion($url), true, 'free',
|
1065 | | - IM ON UR SPECIAL getExternalLinkAttribs DOING $url )
|
1066 | | - BTW Register it in the output object...
|
1067 | | - BTW Replace unnecessary URL escape codes with their equivalent characters
|
1068 | | - I HAS pasteurized IZ self::replaceUnusualEscapes( $url )
|
1069 | | - IM ON UR SPECIAL mOutput->addExternalLink DOING $pasteurized
|
1070 | | - KTHX
|
1071 | | - IM ON UR wfProfileOut DOING __METHOD__
|
1072 | | - I FOUND MAH $text . $trail
|
1073 | | - KTHX
|
1074 | | -
|
1075 | | -
|
1076 | | - DO NOT WANT
|
1077 | | - NOT WANT Parse headers and return html
|
1078 | | - NOT WANT
|
1079 | | - NOT WANT @private
|
1080 | | - WANT
|
1081 | | - SO IM LIKE doHeadings WITH UR $text
|
1082 | | - IM ON UR wfProfileIn DOING __METHOD__
|
1083 | | - for ( $i = 6; $i >= 1; --$i ) {
|
1084 | | - I HAS h IZ str_repeat( '=', $i )
|
1085 | | - text IZ preg_replace( "/^$h(.+)$h\\s*$/m",
|
1086 | | - "<h$i>\\1</h$i>", $text );
|
1087 | | - KTHX
|
1088 | | - IM ON UR wfProfileOut DOING __METHOD__
|
1089 | | - I FOUND MAH $text
|
1090 | | - KTHX
|
1091 | | -
|
1092 | | - DO NOT WANT
|
1093 | | - NOT WANT Replace single quotes with HTML markup
|
1094 | | - NOT WANT @private
|
1095 | | - NOT WANT @return string the altered text
|
1096 | | - WANT
|
1097 | | - SO IM LIKE doAllQuotes WITH UR $text
|
1098 | | - IM ON UR wfProfileIn DOING __METHOD__
|
1099 | | - I HAS outtext IZ ''
|
1100 | | - I HAS lines IZ StringUtils::explode( "\n", $text )
|
1101 | | - IM IN UR lines ITZA line
|
1102 | | - outtext HAS MOAR $this->doQuotes( $line ) . "\n";
|
1103 | | - KTHX
|
1104 | | - I HAS outtext IZ substr( $outtext, 0,-1 )
|
1105 | | - IM ON UR wfProfileOut DOING __METHOD__
|
1106 | | - I FOUND MAH $outtext
|
1107 | | - KTHX
|
1108 | | -
|
1109 | | - DO NOT WANT
|
1110 | | - NOT WANT Helper function for doAllQuotes()
|
1111 | | - WANT
|
1112 | | - SO IM LIKE doQuotes WITH UR $text
|
1113 | | - I HAS arr IZ preg_split( "/(''+)/", $text, -1, PREG_SPLIT_DELIM_CAPTURE )
|
1114 | | - IZ count( $arr ) == 1
|
1115 | | - I FOUND MAH $text
|
1116 | | - NOWAI
|
1117 | | - BTW First, do some preliminary work. This may shift some apostrophes from
|
1118 | | - BTW being mark-up to being text. It also counts the number of occurrences
|
1119 | | - BTW of bold and italics mark-ups.
|
1120 | | - I HAS i IZ 0
|
1121 | | - I HAS numbold IZ 0
|
1122 | | - I HAS numitalics IZ 0
|
1123 | | - IM IN UR arr ITZA r
|
1124 | | - IZ ( $i % 2 ) == 1
|
1125 | | - BTW If there are ever four apostrophes, assume the first is supposed to
|
1126 | | - BTW be text, and the remaining three constitute mark-up for bold text.
|
1127 | | - IZ strlen( $arr[$i] ) == 4
|
1128 | | - $arr[$i-1] .= "'";
|
1129 | | - $arr[$i] = "'''";
|
1130 | | - ORLY strlen( $arr[$i] ) > 5
|
1131 | | - BTW If there are more than 5 apostrophes in a row, assume they're all
|
1132 | | - BTW text except for the last 5.
|
1133 | | - $arr[$i-1] .= str_repeat( "'", strlen( $arr[$i] ) - 5 );
|
1134 | | - $arr[$i] = "'''''";
|
1135 | | - KTHX
|
1136 | | - BTW Count the number of occurrences of bold and italics mark-ups.
|
1137 | | - BTW We are not counting sequences of five apostrophes.
|
1138 | | - IZ strlen( $arr[$i] ) == 2
|
1139 | | - $numitalics++;
|
1140 | | - ORLY strlen( $arr[$i] ) == 3
|
1141 | | - $numbold++;
|
1142 | | - ORLY strlen( $arr[$i] ) == 5
|
1143 | | - $numitalics++;
|
1144 | | - $numbold++;
|
1145 | | - KTHX
|
1146 | | - KTHX
|
1147 | | - $i++;
|
1148 | | - KTHX
|
1149 | | -
|
1150 | | - BTW If there is an odd number of both bold and italics, it is likely
|
1151 | | - BTW that one of the bold ones was meant to be an apostrophe followed
|
1152 | | - BTW by italics. Which one we cannot know for certain, but it is more
|
1153 | | - BTW likely to be one that has a single-letter word before it.
|
1154 | | - IZ ( $numbold % 2 == 1 ) && ( $numitalics % 2 == 1 )
|
1155 | | - I HAS i IZ 0
|
1156 | | - I HAS firstsingleletterword IZ -1
|
1157 | | - I HAS firstmultiletterword IZ -1
|
1158 | | - I HAS firstspace IZ -1
|
1159 | | - IM IN UR arr ITZA r
|
1160 | | - IZ ( $i % 2 == 1 ) and ( strlen( $r ) == 3 )
|
1161 | | - I HAS x1 IZ substr( $arr[$i-1], -1 )
|
1162 | | - I HAS x2 IZ substr( $arr[$i-1], -2, 1 )
|
1163 | | - IZ $x1 === ' '
|
1164 | | - IZ $firstspace == -1
|
1165 | | - I HAS firstspace IZ $i
|
1166 | | - KTHX
|
1167 | | - KTHX elseif ( $x2 === ' ') {
|
1168 | | - IZ $firstsingleletterword == -1
|
1169 | | - I HAS firstsingleletterword IZ $i
|
1170 | | - KTHX
|
1171 | | - NOWAI
|
1172 | | - IZ $firstmultiletterword == -1
|
1173 | | - I HAS firstmultiletterword IZ $i
|
1174 | | - KTHX
|
1175 | | - KTHX
|
1176 | | - KTHX
|
1177 | | - $i++;
|
1178 | | - KTHX
|
1179 | | -
|
1180 | | - BTW If there is a single-letter word, use it!
|
1181 | | - IZ $firstsingleletterword > -1
|
1182 | | - $arr[$firstsingleletterword] = "''";
|
1183 | | - $arr[$firstsingleletterword-1] .= "'";
|
1184 | | - ORLY $firstmultiletterword > -1
|
1185 | | - BTW If not, but there's a multi-letter word, use that one.
|
1186 | | - $arr[$firstmultiletterword] = "''";
|
1187 | | - $arr[$firstmultiletterword-1] .= "'";
|
1188 | | - ORLY $firstspace > -1
|
1189 | | - BTW ... otherwise use the first one that has neither.
|
1190 | | - BTW (notice that it is possible for all three to be -1 if, for example,
|
1191 | | - BTW there is only one pentuple-apostrophe in the line)
|
1192 | | - $arr[$firstspace] = "''";
|
1193 | | - $arr[$firstspace-1] .= "'";
|
1194 | | - KTHX
|
1195 | | - KTHX
|
1196 | | -
|
1197 | | - BTW Now let's actually convert our apostrophic mush to HTML!
|
1198 | | - I HAS output IZ ''
|
1199 | | - I HAS buffer IZ ''
|
1200 | | - I HAS state IZ ''
|
1201 | | - I HAS i IZ 0
|
1202 | | - IM IN UR arr ITZA r
|
1203 | | - IZ ( $i % 2 ) == 0
|
1204 | | - IZ $state === 'both'
|
1205 | | - buffer HAS MOAR $r;
|
1206 | | - NOWAI
|
1207 | | - output HAS MOAR $r;
|
1208 | | - KTHX
|
1209 | | - NOWAI
|
1210 | | - IZ strlen( $r ) == 2
|
1211 | | - IZ $state === 'i'
|
1212 | | - output HAS MOAR '</i>'; $state = '';
|
1213 | | - ORLY $state === 'bi'
|
1214 | | - output HAS MOAR '</i>'; $state = 'b';
|
1215 | | - ORLY $state === 'ib'
|
1216 | | - output HAS MOAR '</b></i><b>'; $state = 'b';
|
1217 | | - ORLY $state === 'both'
|
1218 | | - output HAS MOAR '<b><i>'.$buffer.'</i>'; $state = 'b';
|
1219 | | - NOWAI # $state can be 'b' or ''
|
1220 | | - output HAS MOAR '<i>'; $state .= 'i';
|
1221 | | - KTHX
|
1222 | | - ORLY strlen( $r ) == 3
|
1223 | | - IZ $state === 'b'
|
1224 | | - output HAS MOAR '</b>'; $state = '';
|
1225 | | - ORLY $state === 'bi'
|
1226 | | - output HAS MOAR '</i></b><i>'; $state = 'i';
|
1227 | | - ORLY $state === 'ib'
|
1228 | | - output HAS MOAR '</b>'; $state = 'i';
|
1229 | | - ORLY $state === 'both'
|
1230 | | - output HAS MOAR '<i><b>'.$buffer.'</b>'; $state = 'i';
|
1231 | | - NOWAI # $state can be 'i' or ''
|
1232 | | - output HAS MOAR '<b>'; $state .= 'b';
|
1233 | | - KTHX
|
1234 | | - ORLY strlen( $r ) == 5
|
1235 | | - IZ $state === 'b'
|
1236 | | - output HAS MOAR '</b><i>'; $state = 'i';
|
1237 | | - ORLY $state === 'i'
|
1238 | | - output HAS MOAR '</i><b>'; $state = 'b';
|
1239 | | - ORLY $state === 'bi'
|
1240 | | - output HAS MOAR '</i></b>'; $state = '';
|
1241 | | - ORLY $state === 'ib'
|
1242 | | - output HAS MOAR '</b></i>'; $state = '';
|
1243 | | - ORLY $state === 'both'
|
1244 | | - output HAS MOAR '<i><b>'.$buffer.'</b></i>'; $state = '';
|
1245 | | - NOWAI # ($state == '')
|
1246 | | - I HAS buffer IZ ''; $state = 'both'
|
1247 | | - KTHX
|
1248 | | - KTHX
|
1249 | | - KTHX
|
1250 | | - $i++;
|
1251 | | - KTHX
|
1252 | | - BTW Now close all remaining tags. Notice that the order is important.
|
1253 | | - IZ $state === 'b' || $state === 'ib'
|
1254 | | - output HAS MOAR '</b>';
|
1255 | | - KTHX
|
1256 | | - IZ $state === 'i' || $state === 'bi' || $state === 'ib'
|
1257 | | - output HAS MOAR '</i>';
|
1258 | | - KTHX
|
1259 | | - IZ $state === 'bi'
|
1260 | | - output HAS MOAR '</b>';
|
1261 | | - KTHX
|
1262 | | - BTW There might be lonely ''''', so make sure we have a buffer
|
1263 | | - IZ $state === 'both' && $buffer
|
1264 | | - output HAS MOAR '<b><i>'.$buffer.'</i></b>';
|
1265 | | - KTHX
|
1266 | | - I FOUND MAH $output
|
1267 | | - KTHX
|
1268 | | - KTHX
|
1269 | | -
|
1270 | | - DO NOT WANT
|
1271 | | - NOT WANT Replace external links (REL)
|
1272 | | - NOT WANT
|
1273 | | - NOT WANT Note: this is all very hackish and the order of execution matters a lot.
|
1274 | | - NOT WANT Make sure to run maintenance/parserTests.php if you change this code.
|
1275 | | - NOT WANT
|
1276 | | - NOT WANT @private
|
1277 | | - WANT
|
1278 | | - SO IM LIKE replaceExternalLinks WITH UR $text
|
1279 | | - I HAS UR $wgContLang ON UR INTERNETS
|
1280 | | - IM ON UR wfProfileIn DOING __METHOD__
|
1281 | | -
|
1282 | | - I HAS sk IZ $this->mOptions->getSkin()
|
1283 | | -
|
1284 | | - I HAS bits IZ preg_split( $this->mExtLinkBracketedRegex, $text, -1, PREG_SPLIT_DELIM_CAPTURE )
|
1285 | | - I HAS s IZ array_shift( $bits )
|
1286 | | -
|
1287 | | - I HAS i IZ 0
|
1288 | | - STEALIN UR $i<count( $bits )
|
1289 | | - I HAS url IZ $bits[$i++]
|
1290 | | - I HAS protocol IZ $bits[$i++]
|
1291 | | - I HAS text IZ $bits[$i++]
|
1292 | | - I HAS trail IZ $bits[$i++]
|
1293 | | -
|
1294 | | - BTW The characters '<' and '>' (which were escaped by
|
1295 | | - BTW removeHTMLtags()) should not be included in
|
1296 | | - BTW URLs, per RFC 2396.
|
1297 | | - I HAS m2 IZ EMPTY
|
1298 | | - IZ preg_match( '/&(lt|gt);/', $url, $m2, PREG_OFFSET_CAPTURE )
|
1299 | | - I HAS text IZ substr( $url, $m2[0][1] ) . ' ' . $text
|
1300 | | - I HAS url IZ substr( $url, 0, $m2[0][1] )
|
1301 | | - KTHX
|
1302 | | -
|
1303 | | - BTW If the link text is an image URL, replace it with an <img> tag
|
1304 | | - BTW This happened by accident in the original parser, but some people used it extensively
|
1305 | | - I HAS img IZ $this->maybeMakeExternalImage( $text )
|
1306 | | - IZ $img !== false
|
1307 | | - I HAS text IZ $img
|
1308 | | - KTHX
|
1309 | | -
|
1310 | | - I HAS dtrail IZ ''
|
1311 | | -
|
1312 | | - BTW Set linktype for CSS - if URL==text, link is essentially free
|
1313 | | - I HAS linktype IZ ( $text === $url ) ? 'free' : 'text'
|
1314 | | -
|
1315 | | - BTW No link text, e.g. [http://domain.tld/some.link]
|
1316 | | - IZ $text == ''
|
1317 | | - BTW Autonumber if allowed. See bug #5918
|
1318 | | - IZ strpos( wfUrlProtocols(), substr( $protocol, 0, strpos( $protocol, ':' ) ) ) !== false
|
1319 | | - I HAS langObj IZ $this->getFunctionLang()
|
1320 | | - I HAS text IZ '[' . $langObj->formatNum( ++$this->mAutonumber ) . ']'
|
1321 | | - I HAS linktype IZ 'autonumber'
|
1322 | | - NOWAI
|
1323 | | - BTW Otherwise just use the URL
|
1324 | | - I HAS text IZ htmlspecialchars( $url )
|
1325 | | - I HAS linktype IZ 'free'
|
1326 | | - KTHX
|
1327 | | - NOWAI
|
1328 | | - BTW Have link text, e.g. [http://domain.tld/some.link text]s
|
1329 | | - BTW Check for trail
|
1330 | | - IM ON UR list DOING $dtrail, $trail ) = Linker::splitTrail( $trail
|
1331 | | - KTHX
|
1332 | | -
|
1333 | | - I HAS text IZ $wgContLang->markNoConversion( $text )
|
1334 | | -
|
1335 | | - I HAS url IZ Sanitizer::cleanUrl( $url )
|
1336 | | -
|
1337 | | - BTW Use the encoded URL
|
1338 | | - BTW This means that users can paste URLs directly into the text
|
1339 | | - BTW Funny characters like ö aren't valid in URLs anyway
|
1340 | | - BTW This was changed in August 2004
|
1341 | | - s HAS MOAR $sk->makeExternalLink( $url, $text, false, $linktype,
|
1342 | | - $this->getExternalLinkAttribs( $url ) ) . $dtrail . $trail;
|
1343 | | -
|
1344 | | - BTW Register link in the output object.
|
1345 | | - BTW Replace unnecessary URL escape codes with the referenced character
|
1346 | | - BTW This prevents spammers from hiding links from the filters
|
1347 | | - I HAS pasteurized IZ self::replaceUnusualEscapes( $url )
|
1348 | | - IM ON UR SPECIAL mOutput->addExternalLink DOING $pasteurized
|
1349 | | - KTHX
|
1350 | | -
|
1351 | | - IM ON UR wfProfileOut DOING __METHOD__
|
1352 | | - I FOUND MAH $s
|
1353 | | - KTHX
|
1354 | | -
|
1355 | | - DO NOT WANT
|
1356 | | - NOT WANT Get an associative array of additional HTML attributes appropriate for a
|
1357 | | - NOT WANT particular external link. This currently may include rel => nofollow
|
1358 | | - NOT WANT (depending on configuration, namespace, and the URL's domain) and/or a
|
1359 | | - NOT WANT target attribute (depending on configuration).
|
1360 | | - NOT WANT
|
1361 | | - NOT WANT @param string $url Optional URL, to extract the domain from for rel =>
|
1362 | | - NOT WANT nofollow if appropriate
|
1363 | | - NOT WANT @return array Associative array of HTML attributes
|
1364 | | - WANT
|
1365 | | - SO IM LIKE getExternalLinkAttribs WITH UR $url = false
|
1366 | | - I HAS attribs IZ EMPTY
|
1367 | | - I HAS UR $wgNoFollowLinks, $wgNoFollowNsExceptions ON UR INTERNETS
|
1368 | | - I HAS ns IZ $this->mTitle->getNamespace()
|
1369 | | - IZ $wgNoFollowLinks && !in_array( $ns, $wgNoFollowNsExceptions )
|
1370 | | - $attribs['rel'] = 'nofollow';
|
1371 | | -
|
1372 | | - I HAS UR $wgNoFollowDomainExceptions ON UR INTERNETS
|
1373 | | - IZ $wgNoFollowDomainExceptions
|
1374 | | - I HAS bits IZ wfParseUrl( $url )
|
1375 | | - IZ is_array( $bits ) && isset( $bits['host'] )
|
1376 | | - IM IN UR wgNoFollowDomainExceptions ITZA domain
|
1377 | | - IZ substr( $bits['host'], -strlen( $domain ) ) == $domain
|
1378 | | - IM ON UR unset DOING $attribs['rel']
|
1379 | | - break;
|
1380 | | - KTHX
|
1381 | | - KTHX
|
1382 | | - KTHX
|
1383 | | - KTHX
|
1384 | | - KTHX
|
1385 | | - IZ $this->mOptions->getExternalLinkTarget()
|
1386 | | - $attribs['target'] = $this->mOptions->getExternalLinkTarget();
|
1387 | | - KTHX
|
1388 | | - I FOUND MAH $attribs
|
1389 | | - KTHX
|
1390 | | -
|
1391 | | -
|
1392 | | - DO NOT WANT
|
1393 | | - NOT WANT Replace unusual URL escape codes with their equivalent characters
|
1394 | | - NOT WANT @param string
|
1395 | | - NOT WANT @return string
|
1396 | | - NOT WANT @static
|
1397 | | - NOT WANT @todo This can merge genuinely required bits in the path or query string,
|
1398 | | - NOT WANT breaking legit URLs. A proper fix would treat the various parts of
|
1399 | | - NOT WANT the URL differently; as a workaround, just use the output for
|
1400 | | - NOT WANT statistical records, not for actual linking/output.
|
1401 | | - WANT
|
1402 | | - SO IM ALWAYS LIKE replaceUnusualEscapes WITH UR $url
|
1403 | | - return preg_replace_callback( '/%[0-9A-Fa-f]{2}/',
|
1404 | | - IM ON UR array DOING __CLASS__, 'replaceUnusualEscapesCallback' ), $url
|
1405 | | - KTHX
|
1406 | | -
|
1407 | | - DO NOT WANT
|
1408 | | - NOT WANT Callback function used in replaceUnusualEscapes().
|
1409 | | - NOT WANT Replaces unusual URL escape codes with their equivalent character
|
1410 | | - NOT WANT @static
|
1411 | | - NOT WANT @private
|
1412 | | - WANT
|
1413 | | - SO IM ALWAYS LIKE replaceUnusualEscapesCallback WITH UR $matches
|
1414 | | - I HAS char IZ urldecode( $matches[0] )
|
1415 | | - I HAS ord IZ ord( $char )
|
1416 | | - BTW Is it an unsafe or HTTP reserved character according to RFC 1738?
|
1417 | | - IZ $ord > 32 && $ord < 127 && strpos( '<>"#{}|\^~[]`;/?', $char ) === false
|
1418 | | - BTW No, shouldn't be escaped
|
1419 | | - I FOUND MAH $char
|
1420 | | - NOWAI
|
1421 | | - BTW Yes, leave it escaped
|
1422 | | - I FOUND MAH $matches[0]
|
1423 | | - KTHX
|
1424 | | - KTHX
|
1425 | | -
|
1426 | | - DO NOT WANT
|
1427 | | - NOT WANT make an image if it's allowed, either through the global
|
1428 | | - NOT WANT option, through the exception, or through the on-wiki whitelist
|
1429 | | - NOT WANT @private
|
1430 | | - WANT
|
1431 | | - SO IM LIKE maybeMakeExternalImage WITH UR $url
|
1432 | | - I HAS sk IZ $this->mOptions->getSkin()
|
1433 | | - I HAS imagesfrom IZ $this->mOptions->getAllowExternalImagesFrom()
|
1434 | | - I HAS imagesexception IZ !empty( $imagesfrom )
|
1435 | | - I HAS text IZ false
|
1436 | | - BTW $imagesfrom could be either a single string or an array of strings, parse out the latter
|
1437 | | - IZ $imagesexception && is_array( $imagesfrom )
|
1438 | | - I HAS imagematch IZ false
|
1439 | | - IM IN UR imagesfrom ITZA match
|
1440 | | - IZ strpos( $url, $match ) === 0
|
1441 | | - I HAS imagematch IZ true
|
1442 | | - break;
|
1443 | | - KTHX
|
1444 | | - KTHX
|
1445 | | - ORLY $imagesexception
|
1446 | | - I HAS imagematch IZ ( strpos( $url, $imagesfrom ) === 0 )
|
1447 | | - NOWAI
|
1448 | | - I HAS imagematch IZ false
|
1449 | | - KTHX
|
1450 | | - if ( $this->mOptions->getAllowExternalImages()
|
1451 | | - || ( $imagesexception && $imagematch ) ) {
|
1452 | | - IZ preg_match( self::EXT_IMAGE_REGEX, $url )
|
1453 | | - BTW Image found
|
1454 | | - I HAS text IZ $sk->makeExternalImage( $url )
|
1455 | | - KTHX
|
1456 | | - KTHX
|
1457 | | - if ( !$text && $this->mOptions->getEnableImageWhitelist()
|
1458 | | - && preg_match( self::EXT_IMAGE_REGEX, $url ) ) {
|
1459 | | - I HAS whitelist IZ explode( "\n", wfMsgForContent( 'external_image_whitelist' ) )
|
1460 | | - IM IN UR whitelist ITZA entry
|
1461 | | - BTW Sanitize the regex fragment, make it case-insensitive, ignore blank entries/comments
|
1462 | | - IZ strpos( $entry, '#' ) === 0 || $entry === ''
|
1463 | | - continue;
|
1464 | | - KTHX
|
1465 | | - IZ preg_match( '/' . str_replace( '/', '\\/', $entry ) . '/i', $url )
|
1466 | | - BTW Image matches a whitelist entry
|
1467 | | - I HAS text IZ $sk->makeExternalImage( $url )
|
1468 | | - break;
|
1469 | | - KTHX
|
1470 | | - KTHX
|
1471 | | - KTHX
|
1472 | | - I FOUND MAH $text
|
1473 | | - KTHX
|
1474 | | -
|
1475 | | - DO NOT WANT
|
1476 | | - NOT WANT Process [[ ]] wikilinks
|
1477 | | - NOT WANT @return processed text
|
1478 | | - NOT WANT
|
1479 | | - NOT WANT @private
|
1480 | | - WANT
|
1481 | | - SO IM LIKE replaceInternalLinks WITH UR $s
|
1482 | | - IM ON UR SPECIAL mLinkHolders->merge DOING $this->replaceInternalLinks2( $s )
|
1483 | | - I FOUND MAH $s
|
1484 | | - KTHX
|
1485 | | -
|
1486 | | - DO NOT WANT
|
1487 | | - NOT WANT Process [[ ]] wikilinks (RIL)
|
1488 | | - NOT WANT @return LinkHolderArray
|
1489 | | - NOT WANT
|
1490 | | - NOT WANT @private
|
1491 | | - WANT
|
1492 | | - SO IM LIKE replaceInternalLinks2 WITH UR &$s
|
1493 | | - I HAS UR $wgContLang ON UR INTERNETS
|
1494 | | -
|
1495 | | - IM ON UR wfProfileIn DOING __METHOD__
|
1496 | | -
|
1497 | | - IM ON UR wfProfileIn DOING __METHOD__.'-setup'
|
1498 | | - static $tc = FALSE, $e1, $e1_img;
|
1499 | | - BTW the % is needed to support urlencoded titles as well
|
1500 | | - IZ !$tc
|
1501 | | - I HAS tc IZ Title::legalChars() . '#%'
|
1502 | | - BTW Match a link having the form [[namespace:link|alternate]]trail
|
1503 | | - I HAS e1 IZ "/^([{$tc}]+)(?:\\|(.+?))?]](.*)\$/sD"
|
1504 | | - BTW Match cases where there is no "]]", which might still be images
|
1505 | | - I HAS e1_img IZ "/^([{$tc}]+)\\|(.*)\$/sD"
|
1506 | | - KTHX
|
1507 | | -
|
1508 | | - I HAS sk IZ $this->mOptions->getSkin()
|
1509 | | - I HAS holders IZ new LinkHolderArray( $this )
|
1510 | | -
|
1511 | | - BTW split the entire text string on occurences of [[
|
1512 | | - I HAS a IZ StringUtils::explode( '[[', ' ' . $s )
|
1513 | | - BTW get the first element (all text up to first [[), and remove the space we added
|
1514 | | - I HAS s IZ $a->current()
|
1515 | | - $a->next();
|
1516 | | - I HAS line IZ $a->current() # Workaround for broken ArrayIterator::next() that returns "void"
|
1517 | | - I HAS s IZ substr( $s, 1 )
|
1518 | | -
|
1519 | | - I HAS useLinkPrefixExtension IZ $wgContLang->linkPrefixExtension()
|
1520 | | - I HAS e2
|
1521 | | - IZ $useLinkPrefixExtension
|
1522 | | - BTW Match the end of a line for a word that's not followed by whitespace,
|
1523 | | - BTW e.g. in the case of 'The Arab al[[Razi]]', 'al' will be matched
|
1524 | | - I HAS e2 IZ wfMsgForContent( 'linkprefix' )
|
1525 | | - KTHX
|
1526 | | -
|
1527 | | - IZ is_null( $this->mTitle )
|
1528 | | - IM ON UR wfProfileOut DOING __METHOD__.'-setup'
|
1529 | | - IM ON UR wfProfileOut DOING __METHOD__
|
1530 | | - throw new MWException( __METHOD__.": \$this->mTitle is null\n" );
|
1531 | | - KTHX
|
1532 | | - I HAS nottalk IZ !$this->mTitle->isTalkPage()
|
1533 | | -
|
1534 | | - IZ $useLinkPrefixExtension
|
1535 | | - I HAS m IZ EMPTY
|
1536 | | - IZ preg_match( $e2, $s, $m )
|
1537 | | - I HAS first_prefix IZ $m[2]
|
1538 | | - NOWAI
|
1539 | | - I HAS first_prefix IZ false
|
1540 | | - KTHX
|
1541 | | - NOWAI
|
1542 | | - I HAS prefix IZ ''
|
1543 | | - KTHX
|
1544 | | -
|
1545 | | - IZ $wgContLang->hasVariants()
|
1546 | | - I HAS selflink IZ $wgContLang->convertLinkToAllVariants( $this->mTitle->getPrefixedText() )
|
1547 | | - NOWAI
|
1548 | | - I HAS selflink IZ BUCKET $this->mTitle->getPrefixedText() );
|
1549 | | - KTHX
|
1550 | | - I HAS useSubpages IZ $this->areSubpagesAllowed()
|
1551 | | - IM ON UR wfProfileOut DOING __METHOD__.'-setup'
|
1552 | | -
|
1553 | | - BTW Loop for each link
|
1554 | | - for ( ; $line !== false && $line !== null ; $a->next(), $line = $a->current() ) {
|
1555 | | - BTW Check for excessive memory usage
|
1556 | | - IZ $holders->isBig()
|
1557 | | - BTW Too big
|
1558 | | - BTW Do the existence check, replace the link holders and clear the array
|
1559 | | - $holders->replace( $s );
|
1560 | | - $holders->clear();
|
1561 | | - KTHX
|
1562 | | -
|
1563 | | - IZ $useLinkPrefixExtension
|
1564 | | - IM ON UR wfProfileIn DOING __METHOD__.'-prefixhandling'
|
1565 | | - IZ preg_match( $e2, $s, $m )
|
1566 | | - I HAS prefix IZ $m[2]
|
1567 | | - I HAS s IZ $m[1]
|
1568 | | - NOWAI
|
1569 | | - $prefix='';
|
1570 | | - KTHX
|
1571 | | - BTW first link
|
1572 | | - IZ $first_prefix
|
1573 | | - I HAS prefix IZ $first_prefix
|
1574 | | - I HAS first_prefix IZ false
|
1575 | | - KTHX
|
1576 | | - IM ON UR wfProfileOut DOING __METHOD__.'-prefixhandling'
|
1577 | | - KTHX
|
1578 | | -
|
1579 | | - I HAS might_be_img IZ false
|
1580 | | -
|
1581 | | - IM ON UR wfProfileIn DOING __METHOD__."-e1"
|
1582 | | - IZ preg_match( $e1, $line, $m ) # page with normal text or alt
|
1583 | | - I HAS text IZ $m[2]
|
1584 | | - BTW If we get a ] at the beginning of $m[3] that means we have a link that's something like:
|
1585 | | - BTW [[Image:Foo.jpg|[http://example.com desc]]] <- having three ] in a row fucks up,
|
1586 | | - BTW the real problem is with the $e1 regex
|
1587 | | - BTW See bug 1300.
|
1588 | | - BTW
|
1589 | | - BTW Still some problems for cases where the ] is meant to be outside punctuation,
|
1590 | | - BTW and no image is in sight. See bug 2095.
|
1591 | | - BTW
|
1592 | | - if ( $text !== '' &&
|
1593 | | - substr( $m[3], 0, 1 ) === ']' &&
|
1594 | | - strpos( $text, '[' ) !== false
|
1595 | | - )
|
1596 | | - {
|
1597 | | - text HAS MOAR ']'; # so that replaceExternalLinks($text) works later
|
1598 | | - $m[3] = substr( $m[3], 1 );
|
1599 | | - KTHX
|
1600 | | - BTW fix up urlencoded title texts
|
1601 | | - IZ strpos( $m[1], '%' ) !== false
|
1602 | | - BTW Should anchors '#' also be rejected?
|
1603 | | - $m[1] = str_replace( array('<', '>'), array('<', '>'), urldecode( $m[1] ) );
|
1604 | | - KTHX
|
1605 | | - I HAS trail IZ $m[3]
|
1606 | | - ORLY preg_match( $e1_img, $line, $m ) # Invalid, but might be an image with a link in its caption
|
1607 | | - I HAS might_be_img IZ true
|
1608 | | - I HAS text IZ $m[2]
|
1609 | | - IZ strpos( $m[1], '%' ) !== false
|
1610 | | - $m[1] = urldecode( $m[1] );
|
1611 | | - KTHX
|
1612 | | - I HAS trail IZ ""
|
1613 | | - NOWAI # Invalid form; output directly
|
1614 | | - s HAS MOAR $prefix . '[[' . $line ;
|
1615 | | - IM ON UR wfProfileOut DOING __METHOD__."-e1"
|
1616 | | - continue;
|
1617 | | - KTHX
|
1618 | | - IM ON UR wfProfileOut DOING __METHOD__."-e1"
|
1619 | | - IM ON UR wfProfileIn DOING __METHOD__."-misc"
|
1620 | | -
|
1621 | | - BTW Don't allow internal links to pages containing
|
1622 | | - BTW PROTO: where PROTO is a valid URL protocol; these
|
1623 | | - BTW should be external links.
|
1624 | | - IZ preg_match( '/^\b(?:' . wfUrlProtocols() . ')/', $m[1] )
|
1625 | | - s HAS MOAR $prefix . '[[' . $line ;
|
1626 | | - IM ON UR wfProfileOut DOING __METHOD__."-misc"
|
1627 | | - continue;
|
1628 | | - KTHX
|
1629 | | -
|
1630 | | - BTW Make subpage if necessary
|
1631 | | - IZ $useSubpages
|
1632 | | - I HAS link IZ $this->maybeDoSubpageLink( $m[1], $text )
|
1633 | | - NOWAI
|
1634 | | - I HAS link IZ $m[1]
|
1635 | | - KTHX
|
1636 | | -
|
1637 | | - I HAS noforce IZ ( substr( $m[1], 0, 1 ) !== ':' )
|
1638 | | - IZ !$noforce
|
1639 | | - BTW Strip off leading ':'
|
1640 | | - I HAS link IZ substr( $link, 1 )
|
1641 | | - KTHX
|
1642 | | -
|
1643 | | - IM ON UR wfProfileOut DOING __METHOD__."-misc"
|
1644 | | - IM ON UR wfProfileIn DOING __METHOD__."-title"
|
1645 | | - I HAS nt IZ Title::newFromText( $this->mStripState->unstripNoWiki( $link ) )
|
1646 | | - IZ $nt === null
|
1647 | | - s HAS MOAR $prefix . '[[' . $line;
|
1648 | | - IM ON UR wfProfileOut DOING __METHOD__."-title"
|
1649 | | - continue;
|
1650 | | - KTHX
|
1651 | | -
|
1652 | | - I HAS ns IZ $nt->getNamespace()
|
1653 | | - I HAS iw IZ $nt->getInterWiki()
|
1654 | | - IM ON UR wfProfileOut DOING __METHOD__."-title"
|
1655 | | -
|
1656 | | - IZ $might_be_img # if this is actually an invalid link
|
1657 | | - IM ON UR wfProfileIn DOING __METHOD__."-might_be_img"
|
1658 | | - IZ $ns == NS_FILE && $noforce # but might be an image
|
1659 | | - I HAS found IZ false
|
1660 | | - STEALIN UR true
|
1661 | | - BTW look at the next 'line' to see if we can close it there
|
1662 | | - $a->next();
|
1663 | | - I HAS next_line IZ $a->current()
|
1664 | | - IZ $next_line === false || $next_line === null
|
1665 | | - break;
|
1666 | | - KTHX
|
1667 | | - I HAS m IZ explode( ']]', $next_line, 3 )
|
1668 | | - IZ count( $m ) == 3
|
1669 | | - BTW the first ]] closes the inner link, the second the image
|
1670 | | - I HAS found IZ true
|
1671 | | - text HAS MOAR "[[{$m[0]}]]{$m[1]}";
|
1672 | | - I HAS trail IZ $m[2]
|
1673 | | - break;
|
1674 | | - ORLY count( $m ) == 2
|
1675 | | - BTW if there's exactly one ]] that's fine, we'll keep looking
|
1676 | | - text HAS MOAR "[[{$m[0]}]]{$m[1]}";
|
1677 | | - NOWAI
|
1678 | | - BTW if $next_line is invalid too, we need look no further
|
1679 | | - text HAS MOAR '[[' . $next_line;
|
1680 | | - break;
|
1681 | | - KTHX
|
1682 | | - KTHX
|
1683 | | - IZ !$found
|
1684 | | - BTW we couldn't find the end of this imageLink, so output it raw
|
1685 | | - BTW but don't ignore what might be perfectly normal links in the text we've examined
|
1686 | | - $holders->merge( $this->replaceInternalLinks2( $text ) );
|
1687 | | - s HAS MOAR "{$prefix}[[$link|$text";
|
1688 | | - BTW note: no $trail, because without an end, there *is* no trail
|
1689 | | - IM ON UR wfProfileOut DOING __METHOD__."-might_be_img"
|
1690 | | - continue;
|
1691 | | - KTHX
|
1692 | | - NOWAI # it's not an image, so output it raw
|
1693 | | - s HAS MOAR "{$prefix}[[$link|$text";
|
1694 | | - BTW note: no $trail, because without an end, there *is* no trail
|
1695 | | - IM ON UR wfProfileOut DOING __METHOD__."-might_be_img"
|
1696 | | - continue;
|
1697 | | - KTHX
|
1698 | | - IM ON UR wfProfileOut DOING __METHOD__."-might_be_img"
|
1699 | | - KTHX
|
1700 | | -
|
1701 | | - I HAS wasblank IZ ( $text == '' )
|
1702 | | - IZ $wasblank
|
1703 | | - I HAS text IZ $link
|
1704 | | - KTHX
|
1705 | | -
|
1706 | | - BTW Link not escaped by : , create the various objects
|
1707 | | - IZ $noforce
|
1708 | | -
|
1709 | | - BTW Interwikis
|
1710 | | - IM ON UR wfProfileIn DOING __METHOD__."-interwiki"
|
1711 | | - IZ $iw && $this->mOptions->getInterwikiMagic() && $nottalk && $wgContLang->getLanguageName( $iw )
|
1712 | | - IM ON UR SPECIAL mOutput->addLanguageLink DOING $nt->getFullText()
|
1713 | | - I HAS s IZ rtrim( $s . $prefix )
|
1714 | | - s HAS MOAR trim( $trail, "\n" ) == '' ? '': $prefix . $trail;
|
1715 | | - IM ON UR wfProfileOut DOING __METHOD__."-interwiki"
|
1716 | | - continue;
|
1717 | | - KTHX
|
1718 | | - IM ON UR wfProfileOut DOING __METHOD__."-interwiki"
|
1719 | | -
|
1720 | | - IZ $ns == NS_FILE
|
1721 | | - IM ON UR wfProfileIn DOING __METHOD__."-image"
|
1722 | | - IZ !wfIsBadImage( $nt->getDBkey(), $this->mTitle )
|
1723 | | - IZ $wasblank
|
1724 | | - BTW if no parameters were passed, $text
|
1725 | | - BTW becomes something like "File:Foo.png",
|
1726 | | - BTW which we don't want to pass on to the
|
1727 | | - BTW image generator
|
1728 | | - I HAS text IZ ''
|
1729 | | - NOWAI
|
1730 | | - BTW recursively parse links inside the image caption
|
1731 | | - BTW actually, this will parse them in any other parameters, too,
|
1732 | | - BTW but it might be hard to fix that, and it doesn't matter ATM
|
1733 | | - I HAS text IZ $this->replaceExternalLinks( $text )
|
1734 | | - $holders->merge( $this->replaceInternalLinks2( $text ) );
|
1735 | | - KTHX
|
1736 | | - BTW cloak any absolute URLs inside the image markup, so replaceExternalLinks() won't touch them
|
1737 | | - s HAS MOAR $prefix . $this->armorLinks( $this->makeImage( $nt, $text, $holders ) ) . $trail;
|
1738 | | - NOWAI
|
1739 | | - s HAS MOAR $prefix . $trail;
|
1740 | | - KTHX
|
1741 | | - IM ON UR SPECIAL mOutput->addImage DOING $nt->getDBkey()
|
1742 | | - IM ON UR wfProfileOut DOING __METHOD__."-image"
|
1743 | | - continue;
|
1744 | | -
|
1745 | | - KTHX
|
1746 | | -
|
1747 | | - IZ $ns == NS_CATEGORY
|
1748 | | - IM ON UR wfProfileIn DOING __METHOD__."-category"
|
1749 | | - I HAS s IZ rtrim( $s . "\n" ) # bug 87
|
1750 | | -
|
1751 | | - IZ $wasblank
|
1752 | | - I HAS sortkey IZ $this->getDefaultSort()
|
1753 | | - NOWAI
|
1754 | | - I HAS sortkey IZ $text
|
1755 | | - KTHX
|
1756 | | - I HAS sortkey IZ Sanitizer::decodeCharReferences( $sortkey )
|
1757 | | - I HAS sortkey IZ str_replace( "\n", '', $sortkey )
|
1758 | | - I HAS sortkey IZ $wgContLang->convertCategoryKey( $sortkey )
|
1759 | | - IM ON UR SPECIAL mOutput->addCategory DOING $nt->getDBkey(), $sortkey
|
1760 | | -
|
1761 | | - DO NOT WANT
|
1762 | | - NOT WANT Strip the whitespace Category links produce, see bug 87
|
1763 | | - NOT WANT @todo We might want to use trim($tmp, "\n") here.
|
1764 | | - WANT
|
1765 | | - s HAS MOAR trim( $prefix . $trail, "\n" ) == '' ? '': $prefix . $trail;
|
1766 | | -
|
1767 | | - IM ON UR wfProfileOut DOING __METHOD__."-category"
|
1768 | | - continue;
|
1769 | | - KTHX
|
1770 | | - KTHX
|
1771 | | -
|
1772 | | - BTW Self-link checking
|
1773 | | - IZ $nt->getFragment() === '' && $ns != NS_SPECIAL
|
1774 | | - IZ in_array( $nt->getPrefixedText(), $selflink, true )
|
1775 | | - s HAS MOAR $prefix . $sk->makeSelfLinkObj( $nt, $text, '', $trail );
|
1776 | | - continue;
|
1777 | | - KTHX
|
1778 | | - KTHX
|
1779 | | -
|
1780 | | - BTW NS_MEDIA is a pseudo-namespace for linking directly to a file
|
1781 | | - BTW FIXME: Should do batch file existence checks, see comment below
|
1782 | | - IZ $ns == NS_MEDIA
|
1783 | | - IM ON UR wfProfileIn DOING __METHOD__."-media"
|
1784 | | - BTW Give extensions a chance to select the file revision for us
|
1785 | | - I HAS skip IZ $time = false
|
1786 | | - IM ON UR wfRunHooks DOING 'BeforeParserMakeImageLinkObj', array( &$this, &$nt, &$skip, &$time )
|
1787 | | - IZ $skip
|
1788 | | - I HAS link IZ $sk->link( $nt )
|
1789 | | - NOWAI
|
1790 | | - I HAS link IZ $sk->makeMediaLinkObj( $nt, $text, $time )
|
1791 | | - KTHX
|
1792 | | - BTW Cloak with NOPARSE to avoid replacement in replaceExternalLinks
|
1793 | | - s HAS MOAR $prefix . $this->armorLinks( $link ) . $trail;
|
1794 | | - IM ON UR SPECIAL mOutput->addImage DOING $nt->getDBkey()
|
1795 | | - IM ON UR wfProfileOut DOING __METHOD__."-media"
|
1796 | | - continue;
|
1797 | | - KTHX
|
1798 | | -
|
1799 | | - IM ON UR wfProfileIn DOING __METHOD__."-always_known"
|
1800 | | - BTW Some titles, such as valid special pages or files in foreign repos, should
|
1801 | | - BTW be shown as bluelinks even though they're not included in the page table
|
1802 | | - BTW
|
1803 | | - BTW FIXME: isAlwaysKnown() can be expensive for file links; we should really do
|
1804 | | - BTW batch file existence checks for NS_FILE and NS_MEDIA
|
1805 | | - IZ $iw == '' && $nt->isAlwaysKnown()
|
1806 | | - IM ON UR SPECIAL mOutput->addLink DOING $nt
|
1807 | | - s HAS MOAR $this->makeKnownLinkHolder( $nt, $text, '', $trail, $prefix );
|
1808 | | - NOWAI
|
1809 | | - BTW Links will be added to the output link list after checking
|
1810 | | - s HAS MOAR $holders->makeHolder( $nt, $text, '', $trail, $prefix );
|
1811 | | - KTHX
|
1812 | | - IM ON UR wfProfileOut DOING __METHOD__."-always_known"
|
1813 | | - KTHX
|
1814 | | - IM ON UR wfProfileOut DOING __METHOD__
|
1815 | | - I FOUND MAH $holders
|
1816 | | - KTHX
|
1817 | | -
|
1818 | | - DO NOT WANT
|
1819 | | - NOT WANT Make a link placeholder. The text returned can be later resolved to a real link with
|
1820 | | - NOT WANT replaceLinkHolders(). This is done for two reasons: firstly to avoid further
|
1821 | | - NOT WANT parsing of interwiki links, and secondly to allow all existence checks and
|
1822 | | - NOT WANT article length checks (for stub links) to be bundled into a single query.
|
1823 | | - NOT WANT
|
1824 | | - NOT WANT @deprecated
|
1825 | | - WANT
|
1826 | | - SO IM LIKE makeLinkHolder WITH UR &$nt, $text = '', $query = '', $trail = '', $prefix = ''
|
1827 | | - I FOUND MAH $this->mLinkHolders->makeHolder( $nt, $text, $query, $trail, $prefix )
|
1828 | | - KTHX
|
1829 | | -
|
1830 | | - DO NOT WANT
|
1831 | | - NOT WANT Render a forced-blue link inline; protect against double expansion of
|
1832 | | - NOT WANT URLs if we're in a mode that prepends full URL prefixes to internal links.
|
1833 | | - NOT WANT Since this little disaster has to split off the trail text to avoid
|
1834 | | - NOT WANT breaking URLs in the following text without breaking trails on the
|
1835 | | - NOT WANT wiki links, it's been made into a horrible function.
|
1836 | | - NOT WANT
|
1837 | | - NOT WANT @param Title $nt
|
1838 | | - NOT WANT @param string $text
|
1839 | | - NOT WANT @param string $query
|
1840 | | - NOT WANT @param string $trail
|
1841 | | - NOT WANT @param string $prefix
|
1842 | | - NOT WANT @return string HTML-wikitext mix oh yuck
|
1843 | | - WANT
|
1844 | | - SO IM LIKE makeKnownLinkHolder WITH UR $nt, $text = '', $query = '', $trail = '', $prefix = ''
|
1845 | | - IM ON UR list DOING $inside, $trail ) = Linker::splitTrail( $trail
|
1846 | | - I HAS sk IZ $this->mOptions->getSkin()
|
1847 | | - BTW FIXME: use link() instead of deprecated makeKnownLinkObj()
|
1848 | | - I HAS link IZ $sk->makeKnownLinkObj( $nt, $text, $query, $inside, $prefix )
|
1849 | | - I FOUND MAH $this->armorLinks( $link ) . $trail
|
1850 | | - KTHX
|
1851 | | -
|
1852 | | - DO NOT WANT
|
1853 | | - NOT WANT Insert a NOPARSE hacky thing into any inline links in a chunk that's
|
1854 | | - NOT WANT going to go through further parsing steps before inline URL expansion.
|
1855 | | - NOT WANT
|
1856 | | - NOT WANT Not needed quite as much as it used to be since free links are a bit
|
1857 | | - NOT WANT more sensible these days. But bracketed links are still an issue.
|
1858 | | - NOT WANT
|
1859 | | - NOT WANT @param string more-or-less HTML
|
1860 | | - NOT WANT @return string less-or-more HTML with NOPARSE bits
|
1861 | | - WANT
|
1862 | | - SO IM LIKE armorLinks WITH UR $text
|
1863 | | - return preg_replace( '/\b(' . wfUrlProtocols() . ')/',
|
1864 | | - "{$this->mUniqPrefix}NOPARSE$1", $text );
|
1865 | | - KTHX
|
1866 | | -
|
1867 | | - DO NOT WANT
|
1868 | | - NOT WANT Return true if subpage links should be expanded on this page.
|
1869 | | - NOT WANT @return bool
|
1870 | | - WANT
|
1871 | | - SO IM LIKE areSubpagesAllowed
|
1872 | | - BTW Some namespaces don't allow subpages
|
1873 | | - I FOUND MAH MWNamespace::hasSubpages( $this->mTitle->getNamespace() )
|
1874 | | - KTHX
|
1875 | | -
|
1876 | | - DO NOT WANT
|
1877 | | - NOT WANT Handle link to subpage if necessary
|
1878 | | - NOT WANT @param string $target the source of the link
|
1879 | | - NOT WANT @param string &$text the link text, modified as necessary
|
1880 | | - NOT WANT @return string the full name of the link
|
1881 | | - NOT WANT @private
|
1882 | | - WANT
|
1883 | | - SO IM LIKE maybeDoSubpageLink WITH UR $target, &$text
|
1884 | | - I FOUND MAH Linker::normalizeSubpageLink( $this->mTitle, $target, $text )
|
1885 | | - KTHX
|
1886 | | -
|
1887 | | - DO NOT WANT#@+
|
1888 | | - NOT WANT Used by doBlockLevels()
|
1889 | | - NOT WANT @private
|
1890 | | - WANT
|
1891 | | - SO IM LIKE closeParagraph
|
1892 | | - I HAS result IZ ''
|
1893 | | - IZ $this->mLastSection != ''
|
1894 | | - I HAS result IZ '</' . $this->mLastSection . ">\n"
|
1895 | | - KTHX
|
1896 | | - UR SPECIAL mInPre IZ false;
|
1897 | | - UR SPECIAL mLastSection IZ '';
|
1898 | | - I FOUND MAH $result
|
1899 | | - KTHX
|
1900 | | - DO NOT WANT
|
1901 | | - NOT WANT getCommon() returns the length of the longest common substring
|
1902 | | - NOT WANT of both arguments, starting at the beginning of both.
|
1903 | | - NOT WANT @private
|
1904 | | - WANT
|
1905 | | - SO IM LIKE getCommon WITH UR $st1, $st2
|
1906 | | - I HAS fl IZ strlen( $st1 )
|
1907 | | - I HAS shorter IZ strlen( $st2 )
|
1908 | | - IZ $fl < $shorter
|
1909 | | - I HAS shorter IZ $fl
|
1910 | | - KTHX
|
1911 | | -
|
1912 | | - for ( $i = 0; $i < $shorter; ++$i ) {
|
1913 | | - IZ $st1{$i} != $st2{$i}
|
1914 | | - break;
|
1915 | | - KTHX
|
1916 | | - KTHX
|
1917 | | - I FOUND MAH $i
|
1918 | | - KTHX
|
1919 | | - DO NOT WANT
|
1920 | | - NOT WANT These next three functions open, continue, and close the list
|
1921 | | - NOT WANT element appropriate to the prefix character passed into them.
|
1922 | | - NOT WANT @private
|
1923 | | - WANT
|
1924 | | - SO IM LIKE openList WITH UR $char
|
1925 | | - I HAS result IZ $this->closeParagraph()
|
1926 | | -
|
1927 | | - IZ '*' === $char
|
1928 | | - result HAS MOAR '<ul><li>';
|
1929 | | - ORLY '#' === $char
|
1930 | | - result HAS MOAR '<ol><li>';
|
1931 | | - ORLY ':' === $char
|
1932 | | - result HAS MOAR '<dl><dd>';
|
1933 | | - ORLY ';' === $char
|
1934 | | - result HAS MOAR '<dl><dt>';
|
1935 | | - UR SPECIAL mDTopen IZ true;
|
1936 | | - NOWAI
|
1937 | | - I HAS result IZ '<!-- ERR 1 -->'
|
1938 | | - KTHX
|
1939 | | -
|
1940 | | - I FOUND MAH $result
|
1941 | | - KTHX
|
1942 | | -
|
1943 | | - DO NOT WANT
|
1944 | | - NOT WANT TODO: document
|
1945 | | - NOT WANT @param $char String
|
1946 | | - NOT WANT @private
|
1947 | | - WANT
|
1948 | | - SO IM LIKE nextItem WITH UR $char
|
1949 | | - IZ '*' === $char || '#' === $char
|
1950 | | - I FOUND MAH '</li><li>'
|
1951 | | - ORLY ':' === $char || ';' === $char
|
1952 | | - I HAS close IZ '</dd>'
|
1953 | | - IZ $this->mDTopen
|
1954 | | - I HAS close IZ '</dt>'
|
1955 | | - KTHX
|
1956 | | - IZ ';' === $char
|
1957 | | - UR SPECIAL mDTopen IZ true;
|
1958 | | - I FOUND MAH $close . '<dt>'
|
1959 | | - NOWAI
|
1960 | | - UR SPECIAL mDTopen IZ false;
|
1961 | | - I FOUND MAH $close . '<dd>'
|
1962 | | - KTHX
|
1963 | | - KTHX
|
1964 | | - I FOUND MAH '<!-- ERR 2 -->'
|
1965 | | - KTHX
|
1966 | | -
|
1967 | | - DO NOT WANT
|
1968 | | - NOT WANT TODO: document
|
1969 | | - NOT WANT @param $char String
|
1970 | | - NOT WANT @private
|
1971 | | - WANT
|
1972 | | - SO IM LIKE closeList WITH UR $char
|
1973 | | - IZ '*' === $char
|
1974 | | - I HAS text IZ '</li></ul>'
|
1975 | | - ORLY '#' === $char
|
1976 | | - I HAS text IZ '</li></ol>'
|
1977 | | - ORLY ':' === $char
|
1978 | | - IZ $this->mDTopen
|
1979 | | - UR SPECIAL mDTopen IZ false;
|
1980 | | - I HAS text IZ '</dt></dl>'
|
1981 | | - NOWAI
|
1982 | | - I HAS text IZ '</dd></dl>'
|
1983 | | - KTHX
|
1984 | | - NOWAI
|
1985 | | - I FOUND MAH '<!-- ERR 3 -->'
|
1986 | | - KTHX
|
1987 | | - I FOUND MAH $text."\n"
|
1988 | | - KTHX
|
1989 | | - DO NOT WANT#@-*/
|
1990 | | -
|
1991 | | - DO NOT WANT
|
1992 | | - NOT WANT Make lists from lines starting with ':', '*', '#', etc. (DBL)
|
1993 | | - NOT WANT
|
1994 | | - NOT WANT @param $linestart bool whether or not this is at the start of a line.
|
1995 | | - NOT WANT @private
|
1996 | | - NOT WANT @return string the lists rendered as HTML
|
1997 | | - WANT
|
1998 | | - SO IM LIKE doBlockLevels WITH UR $text, $linestart
|
1999 | | - IM ON UR wfProfileIn DOING __METHOD__
|
2000 | | -
|
2001 | | - BTW Parsing through the text line by line. The main thing
|
2002 | | - BTW happening here is handling of block-level elements p, pre,
|
2003 | | - BTW and making lists from lines starting with * # : etc.
|
2004 | | - BTW
|
2005 | | - I HAS textLines IZ StringUtils::explode( "\n", $text )
|
2006 | | -
|
2007 | | - I HAS lastPrefix IZ $output = ''
|
2008 | | - UR SPECIAL mDTopen IZ $inBlockElem = false;
|
2009 | | - I HAS prefixLength IZ 0
|
2010 | | - I HAS paragraphStack IZ false
|
2011 | | -
|
2012 | | - IM IN UR textLines ITZA oLine
|
2013 | | - BTW Fix up $linestart
|
2014 | | - IZ !$linestart
|
2015 | | - output HAS MOAR $oLine;
|
2016 | | - I HAS linestart IZ true
|
2017 | | - continue;
|
2018 | | - KTHX
|
2019 | | - BTW * = ul
|
2020 | | - BTW # = ol
|
2021 | | - BTW ; = dt
|
2022 | | - BTW : = dd
|
2023 | | -
|
2024 | | - I HAS lastPrefixLength IZ strlen( $lastPrefix )
|
2025 | | - I HAS preCloseMatch IZ preg_match( '/<\\/pre/i', $oLine )
|
2026 | | - I HAS preOpenMatch IZ preg_match( '/<pre/i', $oLine )
|
2027 | | - BTW If not in a <pre> element, scan for and figure out what prefixes are there.
|
2028 | | - IZ !$this->mInPre
|
2029 | | - BTW Multiple prefixes may abut each other for nested lists.
|
2030 | | - I HAS prefixLength IZ strspn( $oLine, '*#:;' )
|
2031 | | - I HAS prefix IZ substr( $oLine, 0, $prefixLength )
|
2032 | | -
|
2033 | | - BTW eh?
|
2034 | | - BTW ; and : are both from definition-lists, so they're equivalent
|
2035 | | - BTW for the purposes of determining whether or not we need to open/close
|
2036 | | - BTW elements.
|
2037 | | - I HAS prefix2 IZ str_replace( ';', ':', $prefix )
|
2038 | | - I HAS t IZ substr( $oLine, $prefixLength )
|
2039 | | - UR SPECIAL mInPre IZ (bool)$preOpenMatch;
|
2040 | | - NOWAI
|
2041 | | - BTW Don't interpret any other prefixes in preformatted text
|
2042 | | - I HAS prefixLength IZ 0
|
2043 | | - I HAS prefix IZ $prefix2 = ''
|
2044 | | - I HAS t IZ $oLine
|
2045 | | - KTHX
|
2046 | | -
|
2047 | | - BTW List generation
|
2048 | | - IZ $prefixLength && $lastPrefix === $prefix2
|
2049 | | - BTW Same as the last item, so no need to deal with nesting or opening stuff
|
2050 | | - output HAS MOAR $this->nextItem( substr( $prefix, -1 ) );
|
2051 | | - I HAS paragraphStack IZ false
|
2052 | | -
|
2053 | | - if ( substr( $prefix, -1 ) === ';') {
|
2054 | | - BTW The one nasty exception: definition lists work like this:
|
2055 | | - BTW ; title : definition text
|
2056 | | - BTW So we check for : in the remainder text to split up the
|
2057 | | - BTW title and definition, without b0rking links.
|
2058 | | - I HAS term IZ $t2 = ''
|
2059 | | - IZ $this->findColonNoLinks( $t, $term, $t2 ) !== false
|
2060 | | - I HAS t IZ $t2
|
2061 | | - output HAS MOAR $term . $this->nextItem( ':' );
|
2062 | | - KTHX
|
2063 | | - KTHX
|
2064 | | - ORLY $prefixLength || $lastPrefixLength
|
2065 | | - BTW We need to open or close prefixes, or both.
|
2066 | | -
|
2067 | | - BTW Either open or close a level...
|
2068 | | - I HAS commonPrefixLength IZ $this->getCommon( $prefix, $lastPrefix )
|
2069 | | - I HAS paragraphStack IZ false
|
2070 | | -
|
2071 | | - BTW Close all the prefixes which aren't shared.
|
2072 | | - STEALIN UR $commonPrefixLength < $lastPrefixLength
|
2073 | | - output HAS MOAR $this->closeList( $lastPrefix[$lastPrefixLength-1] );
|
2074 | | - --$lastPrefixLength;
|
2075 | | - KTHX
|
2076 | | -
|
2077 | | - BTW Continue the current prefix if appropriate.
|
2078 | | - IZ $prefixLength <= $commonPrefixLength && $commonPrefixLength > 0
|
2079 | | - output HAS MOAR $this->nextItem( $prefix[$commonPrefixLength-1] );
|
2080 | | - KTHX
|
2081 | | -
|
2082 | | - BTW Open prefixes where appropriate.
|
2083 | | - STEALIN UR $prefixLength > $commonPrefixLength
|
2084 | | - I HAS char IZ substr( $prefix, $commonPrefixLength, 1 )
|
2085 | | - output HAS MOAR $this->openList( $char );
|
2086 | | -
|
2087 | | - IZ ';' === $char
|
2088 | | - BTW FIXME: This is dupe of code above
|
2089 | | - IZ $this->findColonNoLinks( $t, $term, $t2 ) !== false
|
2090 | | - I HAS t IZ $t2
|
2091 | | - output HAS MOAR $term . $this->nextItem( ':' );
|
2092 | | - KTHX
|
2093 | | - KTHX
|
2094 | | - ++$commonPrefixLength;
|
2095 | | - KTHX
|
2096 | | - I HAS lastPrefix IZ $prefix2
|
2097 | | - KTHX
|
2098 | | -
|
2099 | | - BTW If we have no prefixes, go to paragraph mode.
|
2100 | | - IZ 0 == $prefixLength
|
2101 | | - IM ON UR wfProfileIn DOING __METHOD__."-paragraph"
|
2102 | | - BTW No prefix (not in list)--go to paragraph mode
|
2103 | | - BTW XXX: use a stack for nestable elements like span, table and div
|
2104 | | - I HAS openmatch IZ preg_match('/(?:<table|<blockquote|<h1|<h2|<h3|<h4|<h5|<h6|<pre|<tr|<p|<ul|<ol|<li|<\\/tr|<\\/td|<\\/th)/iS', $t )
|
2105 | | - closematch IZ preg_match(
|
2106 | | - '/(?:<\\/table|<\\/blockquote|<\\/h1|<\\/h2|<\\/h3|<\\/h4|<\\/h5|<\\/h6|'.
|
2107 | | - '<td|<th|<\\/?div|<hr|<\\/pre|<\\/p|'.$this->mUniqPrefix.'-pre|<\\/li|<\\/ul|<\\/ol|<\\/?center)/iS', $t );
|
2108 | | - IZ $openmatch or $closematch
|
2109 | | - I HAS paragraphStack IZ false
|
2110 | | - # TODO bug 5718: paragraph closed
|
2111 | | - output HAS MOAR $this->closeParagraph();
|
2112 | | - IZ $preOpenMatch and !$preCloseMatch
|
2113 | | - UR SPECIAL mInPre IZ true;
|
2114 | | - KTHX
|
2115 | | - IZ $closematch
|
2116 | | - I HAS inBlockElem IZ false
|
2117 | | - NOWAI
|
2118 | | - I HAS inBlockElem IZ true
|
2119 | | - KTHX
|
2120 | | - ORLY !$inBlockElem && !$this->mInPre
|
2121 | | - IZ ' ' == substr( $t, 0, 1 ) and ( $this->mLastSection === 'pre' || trim( $t ) != '' )
|
2122 | | - BTW pre
|
2123 | | - IZ $this->mLastSection !== 'pre'
|
2124 | | - I HAS paragraphStack IZ false
|
2125 | | - output HAS MOAR $this->closeParagraph().'<pre>';
|
2126 | | - UR SPECIAL mLastSection IZ 'pre';
|
2127 | | - KTHX
|
2128 | | - I HAS t IZ substr( $t, 1 )
|
2129 | | - NOWAI
|
2130 | | - BTW paragraph
|
2131 | | - IZ trim( $t ) == ''
|
2132 | | - IZ $paragraphStack
|
2133 | | - output HAS MOAR $paragraphStack.'<br />';
|
2134 | | - I HAS paragraphStack IZ false
|
2135 | | - UR SPECIAL mLastSection IZ 'p';
|
2136 | | - NOWAI
|
2137 | | - IZ $this->mLastSection !== 'p'
|
2138 | | - output HAS MOAR $this->closeParagraph();
|
2139 | | - UR SPECIAL mLastSection IZ '';
|
2140 | | - I HAS paragraphStack IZ '<p>'
|
2141 | | - NOWAI
|
2142 | | - I HAS paragraphStack IZ '</p><p>'
|
2143 | | - KTHX
|
2144 | | - KTHX
|
2145 | | - NOWAI
|
2146 | | - IZ $paragraphStack
|
2147 | | - output HAS MOAR $paragraphStack;
|
2148 | | - I HAS paragraphStack IZ false
|
2149 | | - UR SPECIAL mLastSection IZ 'p';
|
2150 | | - ORLY $this->mLastSection !== 'p'
|
2151 | | - output HAS MOAR $this->closeParagraph().'<p>';
|
2152 | | - UR SPECIAL mLastSection IZ 'p';
|
2153 | | - KTHX
|
2154 | | - KTHX
|
2155 | | - KTHX
|
2156 | | - KTHX
|
2157 | | - IM ON UR wfProfileOut DOING __METHOD__."-paragraph"
|
2158 | | - KTHX
|
2159 | | - BTW somewhere above we forget to get out of pre block (bug 785)
|
2160 | | - IZ $preCloseMatch && $this->mInPre
|
2161 | | - UR SPECIAL mInPre IZ false;
|
2162 | | - KTHX
|
2163 | | - IZ $paragraphStack === false
|
2164 | | - output HAS MOAR $t."\n";
|
2165 | | - KTHX
|
2166 | | - KTHX
|
2167 | | - STEALIN UR $prefixLength
|
2168 | | - output HAS MOAR $this->closeList( $prefix2[$prefixLength-1] );
|
2169 | | - --$prefixLength;
|
2170 | | - KTHX
|
2171 | | - IZ $this->mLastSection != ''
|
2172 | | - output HAS MOAR '</' . $this->mLastSection . '>';
|
2173 | | - UR SPECIAL mLastSection IZ '';
|
2174 | | - KTHX
|
2175 | | -
|
2176 | | - IM ON UR wfProfileOut DOING __METHOD__
|
2177 | | - I FOUND MAH $output
|
2178 | | - KTHX
|
2179 | | -
|
2180 | | - DO NOT WANT
|
2181 | | - NOT WANT Split up a string on ':', ignoring any occurences inside tags
|
2182 | | - NOT WANT to prevent illegal overlapping.
|
2183 | | - NOT WANT @param string $str the string to split
|
2184 | | - NOT WANT @param string &$before set to everything before the ':'
|
2185 | | - NOT WANT @param string &$after set to everything after the ':'
|
2186 | | - NOT WANT return string the position of the ':', or false if none found
|
2187 | | - WANT
|
2188 | | - SO IM LIKE findColonNoLinks WITH UR $str, &$before, &$after
|
2189 | | - IM ON UR wfProfileIn DOING __METHOD__
|
2190 | | -
|
2191 | | - I HAS pos IZ strpos( $str, ':' )
|
2192 | | - IZ $pos === false
|
2193 | | - BTW Nothing to find!
|
2194 | | - IM ON UR wfProfileOut DOING __METHOD__
|
2195 | | - I FOUND MAH false
|
2196 | | - KTHX
|
2197 | | -
|
2198 | | - I HAS lt IZ strpos( $str, '<' )
|
2199 | | - IZ $lt === false || $lt > $pos
|
2200 | | - BTW Easy; no tag nesting to worry about
|
2201 | | - I HAS before IZ substr( $str, 0, $pos )
|
2202 | | - I HAS after IZ substr( $str, $pos+1 )
|
2203 | | - IM ON UR wfProfileOut DOING __METHOD__
|
2204 | | - I FOUND MAH $pos
|
2205 | | - KTHX
|
2206 | | -
|
2207 | | - BTW Ugly state machine to walk through avoiding tags.
|
2208 | | - I HAS state IZ self::COLON_STATE_TEXT
|
2209 | | - I HAS stack IZ 0
|
2210 | | - I HAS len IZ strlen( $str )
|
2211 | | - for( $i = 0; $i < $len; $i++ ) {
|
2212 | | - I HAS c IZ $str{$i}
|
2213 | | -
|
2214 | | - switch( $state ) {
|
2215 | | - BTW (Using the number is a performance hack for common cases)
|
2216 | | - case 0: # self::COLON_STATE_TEXT:
|
2217 | | - switch( $c ) {
|
2218 | | - case "<":
|
2219 | | - BTW Could be either a <start> tag or an </end> tag
|
2220 | | - I HAS state IZ self::COLON_STATE_TAGSTART
|
2221 | | - break;
|
2222 | | - case ":":
|
2223 | | - IZ $stack == 0
|
2224 | | - BTW We found it!
|
2225 | | - I HAS before IZ substr( $str, 0, $i )
|
2226 | | - I HAS after IZ substr( $str, $i + 1 )
|
2227 | | - IM ON UR wfProfileOut DOING __METHOD__
|
2228 | | - I FOUND MAH $i
|
2229 | | - KTHX
|
2230 | | - BTW Embedded in a tag; don't break it.
|
2231 | | - break;
|
2232 | | - default:
|
2233 | | - BTW Skip ahead looking for something interesting
|
2234 | | - I HAS colon IZ strpos( $str, ':', $i )
|
2235 | | - IZ $colon === false
|
2236 | | - BTW Nothing else interesting
|
2237 | | - IM ON UR wfProfileOut DOING __METHOD__
|
2238 | | - I FOUND MAH false
|
2239 | | - KTHX
|
2240 | | - I HAS lt IZ strpos( $str, '<', $i )
|
2241 | | - IZ $stack === 0
|
2242 | | - IZ $lt === false || $colon < $lt
|
2243 | | - BTW We found it!
|
2244 | | - I HAS before IZ substr( $str, 0, $colon )
|
2245 | | - I HAS after IZ substr( $str, $colon + 1 )
|
2246 | | - IM ON UR wfProfileOut DOING __METHOD__
|
2247 | | - I FOUND MAH $i
|
2248 | | - KTHX
|
2249 | | - KTHX
|
2250 | | - IZ $lt === false
|
2251 | | - BTW Nothing else interesting to find; abort!
|
2252 | | - BTW We're nested, but there's no close tags left. Abort!
|
2253 | | - break 2;
|
2254 | | - KTHX
|
2255 | | - BTW Skip ahead to next tag start
|
2256 | | - I HAS i IZ $lt
|
2257 | | - I HAS state IZ self::COLON_STATE_TAGSTART
|
2258 | | - KTHX
|
2259 | | - break;
|
2260 | | - case 1: # self::COLON_STATE_TAG:
|
2261 | | - BTW In a <tag>
|
2262 | | - switch( $c ) {
|
2263 | | - case ">":
|
2264 | | - $stack++;
|
2265 | | - I HAS state IZ self::COLON_STATE_TEXT
|
2266 | | - break;
|
2267 | | - case "/":
|
2268 | | - BTW Slash may be followed by >?
|
2269 | | - I HAS state IZ self::COLON_STATE_TAGSLASH
|
2270 | | - break;
|
2271 | | - default:
|
2272 | | - BTW ignore
|
2273 | | - KTHX
|
2274 | | - break;
|
2275 | | - case 2: # self::COLON_STATE_TAGSTART:
|
2276 | | - switch( $c ) {
|
2277 | | - case "/":
|
2278 | | - I HAS state IZ self::COLON_STATE_CLOSETAG
|
2279 | | - break;
|
2280 | | - case "!":
|
2281 | | - I HAS state IZ self::COLON_STATE_COMMENT
|
2282 | | - break;
|
2283 | | - case ">":
|
2284 | | - BTW Illegal early close? This shouldn't happen D:
|
2285 | | - I HAS state IZ self::COLON_STATE_TEXT
|
2286 | | - break;
|
2287 | | - default:
|
2288 | | - I HAS state IZ self::COLON_STATE_TAG
|
2289 | | - KTHX
|
2290 | | - break;
|
2291 | | - case 3: # self::COLON_STATE_CLOSETAG:
|
2292 | | - BTW In a </tag>
|
2293 | | - IZ $c === ">"
|
2294 | | - I HAS stack--
|
2295 | | - IZ $stack < 0
|
2296 | | - IM ON UR wfDebug DOING __METHOD__.": Invalid input; too many close tags\n"
|
2297 | | - IM ON UR wfProfileOut DOING __METHOD__
|
2298 | | - I FOUND MAH false
|
2299 | | - KTHX
|
2300 | | - I HAS state IZ self::COLON_STATE_TEXT
|
2301 | | - KTHX
|
2302 | | - break;
|
2303 | | - case self::COLON_STATE_TAGSLASH:
|
2304 | | - IZ $c === ">"
|
2305 | | - BTW Yes, a self-closed tag <blah/>
|
2306 | | - I HAS state IZ self::COLON_STATE_TEXT
|
2307 | | - NOWAI
|
2308 | | - BTW Probably we're jumping the gun, and this is an attribute
|
2309 | | - I HAS state IZ self::COLON_STATE_TAG
|
2310 | | - KTHX
|
2311 | | - break;
|
2312 | | - case 5: # self::COLON_STATE_COMMENT:
|
2313 | | - IZ $c === "-"
|
2314 | | - I HAS state IZ self::COLON_STATE_COMMENTDASH
|
2315 | | - KTHX
|
2316 | | - break;
|
2317 | | - case self::COLON_STATE_COMMENTDASH:
|
2318 | | - IZ $c === "-"
|
2319 | | - I HAS state IZ self::COLON_STATE_COMMENTDASHDASH
|
2320 | | - NOWAI
|
2321 | | - I HAS state IZ self::COLON_STATE_COMMENT
|
2322 | | - KTHX
|
2323 | | - break;
|
2324 | | - case self::COLON_STATE_COMMENTDASHDASH:
|
2325 | | - IZ $c === ">"
|
2326 | | - I HAS state IZ self::COLON_STATE_TEXT
|
2327 | | - NOWAI
|
2328 | | - I HAS state IZ self::COLON_STATE_COMMENT
|
2329 | | - KTHX
|
2330 | | - break;
|
2331 | | - default:
|
2332 | | - throw new MWException( "State machine error in " . __METHOD__ );
|
2333 | | - KTHX
|
2334 | | - KTHX
|
2335 | | - IZ $stack > 0
|
2336 | | - IM ON UR wfDebug DOING __METHOD__.": Invalid input; not enough close tags (stack $stack, state $state)\n"
|
2337 | | - I FOUND MAH false
|
2338 | | - KTHX
|
2339 | | - IM ON UR wfProfileOut DOING __METHOD__
|
2340 | | - I FOUND MAH false
|
2341 | | - KTHX
|
2342 | | -
|
2343 | | - DO NOT WANT
|
2344 | | - NOT WANT Return value of a magic variable (like PAGENAME)
|
2345 | | - NOT WANT
|
2346 | | - NOT WANT @private
|
2347 | | - WANT
|
2348 | | - SO IM LIKE getVariableValue WITH UR $index, $frame=false
|
2349 | | - I HAS UR $wgContLang, $wgSitename, $wgServer, $wgServerName ON UR INTERNETS
|
2350 | | - I HAS UR $wgScriptPath, $wgStylePath ON UR INTERNETS
|
2351 | | -
|
2352 | | - DO NOT WANT
|
2353 | | - NOT WANT Some of these require message or data lookups and can be
|
2354 | | - NOT WANT expensive to check many times.
|
2355 | | - WANT
|
2356 | | - IZ wfRunHooks( 'ParserGetVariableValueVarCache', array( &$this, &$this->mVarCache ) )
|
2357 | | - IZ isset( $this->mVarCache[$index] )
|
2358 | | - I FOUND MAH $this->mVarCache[$index]
|
2359 | | - KTHX
|
2360 | | - KTHX
|
2361 | | -
|
2362 | | - I HAS ts IZ wfTimestamp( TS_UNIX, $this->mOptions->getTimestamp() )
|
2363 | | - IM ON UR wfRunHooks DOING 'ParserGetVariableValueTs', array( &$this, &$ts )
|
2364 | | -
|
2365 | | - BTW Use the time zone
|
2366 | | - I HAS UR $wgLocaltimezone ON UR INTERNETS
|
2367 | | - IZ isset( $wgLocaltimezone )
|
2368 | | - I HAS oldtz IZ date_default_timezone_get()
|
2369 | | - IM ON UR date_default_timezone_set DOING $wgLocaltimezone
|
2370 | | - KTHX
|
2371 | | -
|
2372 | | - I HAS localTimestamp IZ date( 'YmdHis', $ts )
|
2373 | | - I HAS localMonth IZ date( 'm', $ts )
|
2374 | | - I HAS localMonth1 IZ date( 'n', $ts )
|
2375 | | - I HAS localMonthName IZ date( 'n', $ts )
|
2376 | | - I HAS localDay IZ date( 'j', $ts )
|
2377 | | - I HAS localDay2 IZ date( 'd', $ts )
|
2378 | | - I HAS localDayOfWeek IZ date( 'w', $ts )
|
2379 | | - I HAS localWeek IZ date( 'W', $ts )
|
2380 | | - I HAS localYear IZ date( 'Y', $ts )
|
2381 | | - I HAS localHour IZ date( 'H', $ts )
|
2382 | | - IZ isset( $wgLocaltimezone )
|
2383 | | - IM ON UR date_default_timezone_set DOING $oldtz
|
2384 | | - KTHX
|
2385 | | -
|
2386 | | - switch ( $index ) {
|
2387 | | - case 'currentmonth':
|
2388 | | - I HAS value IZ $wgContLang->formatNum( gmdate( 'm', $ts ) )
|
2389 | | - break;
|
2390 | | - case 'currentmonth1':
|
2391 | | - I HAS value IZ $wgContLang->formatNum( gmdate( 'n', $ts ) )
|
2392 | | - break;
|
2393 | | - case 'currentmonthname':
|
2394 | | - I HAS value IZ $wgContLang->getMonthName( gmdate( 'n', $ts ) )
|
2395 | | - break;
|
2396 | | - case 'currentmonthnamegen':
|
2397 | | - I HAS value IZ $wgContLang->getMonthNameGen( gmdate( 'n', $ts ) )
|
2398 | | - break;
|
2399 | | - case 'currentmonthabbrev':
|
2400 | | - I HAS value IZ $wgContLang->getMonthAbbreviation( gmdate( 'n', $ts ) )
|
2401 | | - break;
|
2402 | | - case 'currentday':
|
2403 | | - I HAS value IZ $wgContLang->formatNum( gmdate( 'j', $ts ) )
|
2404 | | - break;
|
2405 | | - case 'currentday2':
|
2406 | | - I HAS value IZ $wgContLang->formatNum( gmdate( 'd', $ts ) )
|
2407 | | - break;
|
2408 | | - case 'localmonth':
|
2409 | | - I HAS value IZ $wgContLang->formatNum( $localMonth )
|
2410 | | - break;
|
2411 | | - case 'localmonth1':
|
2412 | | - I HAS value IZ $wgContLang->formatNum( $localMonth1 )
|
2413 | | - break;
|
2414 | | - case 'localmonthname':
|
2415 | | - I HAS value IZ $wgContLang->getMonthName( $localMonthName )
|
2416 | | - break;
|
2417 | | - case 'localmonthnamegen':
|
2418 | | - I HAS value IZ $wgContLang->getMonthNameGen( $localMonthName )
|
2419 | | - break;
|
2420 | | - case 'localmonthabbrev':
|
2421 | | - I HAS value IZ $wgContLang->getMonthAbbreviation( $localMonthName )
|
2422 | | - break;
|
2423 | | - case 'localday':
|
2424 | | - I HAS value IZ $wgContLang->formatNum( $localDay )
|
2425 | | - break;
|
2426 | | - case 'localday2':
|
2427 | | - I HAS value IZ $wgContLang->formatNum( $localDay2 )
|
2428 | | - break;
|
2429 | | - case 'pagename':
|
2430 | | - I HAS value IZ wfEscapeWikiText( $this->mTitle->getText() )
|
2431 | | - break;
|
2432 | | - case 'pagenamee':
|
2433 | | - I HAS value IZ $this->mTitle->getPartialURL()
|
2434 | | - break;
|
2435 | | - case 'fullpagename':
|
2436 | | - I HAS value IZ wfEscapeWikiText( $this->mTitle->getPrefixedText() )
|
2437 | | - break;
|
2438 | | - case 'fullpagenamee':
|
2439 | | - I HAS value IZ $this->mTitle->getPrefixedURL()
|
2440 | | - break;
|
2441 | | - case 'subpagename':
|
2442 | | - I HAS value IZ wfEscapeWikiText( $this->mTitle->getSubpageText() )
|
2443 | | - break;
|
2444 | | - case 'subpagenamee':
|
2445 | | - I HAS value IZ $this->mTitle->getSubpageUrlForm()
|
2446 | | - break;
|
2447 | | - case 'basepagename':
|
2448 | | - I HAS value IZ wfEscapeWikiText( $this->mTitle->getBaseText() )
|
2449 | | - break;
|
2450 | | - case 'basepagenamee':
|
2451 | | - I HAS value IZ wfUrlEncode( str_replace( ' ', '_', $this->mTitle->getBaseText() ) )
|
2452 | | - break;
|
2453 | | - case 'talkpagename':
|
2454 | | - IZ $this->mTitle->canTalk()
|
2455 | | - I HAS talkPage IZ $this->mTitle->getTalkPage()
|
2456 | | - I HAS value IZ wfEscapeWikiText( $talkPage->getPrefixedText() )
|
2457 | | - NOWAI
|
2458 | | - I HAS value IZ ''
|
2459 | | - KTHX
|
2460 | | - break;
|
2461 | | - case 'talkpagenamee':
|
2462 | | - IZ $this->mTitle->canTalk()
|
2463 | | - I HAS talkPage IZ $this->mTitle->getTalkPage()
|
2464 | | - I HAS value IZ $talkPage->getPrefixedUrl()
|
2465 | | - NOWAI
|
2466 | | - I HAS value IZ ''
|
2467 | | - KTHX
|
2468 | | - break;
|
2469 | | - case 'subjectpagename':
|
2470 | | - I HAS subjPage IZ $this->mTitle->getSubjectPage()
|
2471 | | - I HAS value IZ wfEscapeWikiText( $subjPage->getPrefixedText() )
|
2472 | | - break;
|
2473 | | - case 'subjectpagenamee':
|
2474 | | - I HAS subjPage IZ $this->mTitle->getSubjectPage()
|
2475 | | - I HAS value IZ $subjPage->getPrefixedUrl()
|
2476 | | - break;
|
2477 | | - case 'revisionid':
|
2478 | | - BTW Let the edit saving system know we should parse the page
|
2479 | | - BTW *after* a revision ID has been assigned.
|
2480 | | - IM ON UR SPECIAL mOutput->setFlag DOING 'vary-revision'
|
2481 | | - IM ON UR wfDebug DOING __METHOD__ . ": {{REVISIONID}} used, setting vary-revision...\n"
|
2482 | | - I HAS value IZ $this->mRevisionId
|
2483 | | - break;
|
2484 | | - case 'revisionday':
|
2485 | | - BTW Let the edit saving system know we should parse the page
|
2486 | | - BTW *after* a revision ID has been assigned. This is for null edits.
|
2487 | | - IM ON UR SPECIAL mOutput->setFlag DOING 'vary-revision'
|
2488 | | - IM ON UR wfDebug DOING __METHOD__ . ": {{REVISIONDAY}} used, setting vary-revision...\n"
|
2489 | | - I HAS value IZ intval( substr( $this->getRevisionTimestamp(), 6, 2 ) )
|
2490 | | - break;
|
2491 | | - case 'revisionday2':
|
2492 | | - BTW Let the edit saving system know we should parse the page
|
2493 | | - BTW *after* a revision ID has been assigned. This is for null edits.
|
2494 | | - IM ON UR SPECIAL mOutput->setFlag DOING 'vary-revision'
|
2495 | | - IM ON UR wfDebug DOING __METHOD__ . ": {{REVISIONDAY2}} used, setting vary-revision...\n"
|
2496 | | - I HAS value IZ substr( $this->getRevisionTimestamp(), 6, 2 )
|
2497 | | - break;
|
2498 | | - case 'revisionmonth':
|
2499 | | - BTW Let the edit saving system know we should parse the page
|
2500 | | - BTW *after* a revision ID has been assigned. This is for null edits.
|
2501 | | - IM ON UR SPECIAL mOutput->setFlag DOING 'vary-revision'
|
2502 | | - IM ON UR wfDebug DOING __METHOD__ . ": {{REVISIONMONTH}} used, setting vary-revision...\n"
|
2503 | | - I HAS value IZ intval( substr( $this->getRevisionTimestamp(), 4, 2 ) )
|
2504 | | - break;
|
2505 | | - case 'revisionyear':
|
2506 | | - BTW Let the edit saving system know we should parse the page
|
2507 | | - BTW *after* a revision ID has been assigned. This is for null edits.
|
2508 | | - IM ON UR SPECIAL mOutput->setFlag DOING 'vary-revision'
|
2509 | | - IM ON UR wfDebug DOING __METHOD__ . ": {{REVISIONYEAR}} used, setting vary-revision...\n"
|
2510 | | - I HAS value IZ substr( $this->getRevisionTimestamp(), 0, 4 )
|
2511 | | - break;
|
2512 | | - case 'revisiontimestamp':
|
2513 | | - BTW Let the edit saving system know we should parse the page
|
2514 | | - BTW *after* a revision ID has been assigned. This is for null edits.
|
2515 | | - IM ON UR SPECIAL mOutput->setFlag DOING 'vary-revision'
|
2516 | | - IM ON UR wfDebug DOING __METHOD__ . ": {{REVISIONTIMESTAMP}} used, setting vary-revision...\n"
|
2517 | | - I HAS value IZ $this->getRevisionTimestamp()
|
2518 | | - break;
|
2519 | | - case 'revisionuser':
|
2520 | | - BTW Let the edit saving system know we should parse the page
|
2521 | | - BTW *after* a revision ID has been assigned. This is for null edits.
|
2522 | | - IM ON UR SPECIAL mOutput->setFlag DOING 'vary-revision'
|
2523 | | - IM ON UR wfDebug DOING __METHOD__ . ": {{REVISIONUSER}} used, setting vary-revision...\n"
|
2524 | | - I HAS value IZ $this->getRevisionUser()
|
2525 | | - break;
|
2526 | | - case 'namespace':
|
2527 | | - I HAS value IZ str_replace( '_',' ',$wgContLang->getNsText( $this->mTitle->getNamespace() ) )
|
2528 | | - break;
|
2529 | | - case 'namespacee':
|
2530 | | - I HAS value IZ wfUrlencode( $wgContLang->getNsText( $this->mTitle->getNamespace() ) )
|
2531 | | - break;
|
2532 | | - case 'talkspace':
|
2533 | | - I HAS value IZ $this->mTitle->canTalk() ? str_replace( '_',' ',$this->mTitle->getTalkNsText() ) : ''
|
2534 | | - break;
|
2535 | | - case 'talkspacee':
|
2536 | | - I HAS value IZ $this->mTitle->canTalk() ? wfUrlencode( $this->mTitle->getTalkNsText() ) : ''
|
2537 | | - break;
|
2538 | | - case 'subjectspace':
|
2539 | | - I HAS value IZ $this->mTitle->getSubjectNsText()
|
2540 | | - break;
|
2541 | | - case 'subjectspacee':
|
2542 | | - I HAS value IZ ( wfUrlencode( $this->mTitle->getSubjectNsText() ) )
|
2543 | | - break;
|
2544 | | - case 'currentdayname':
|
2545 | | - I HAS value IZ $wgContLang->getWeekdayName( gmdate( 'w', $ts ) + 1 )
|
2546 | | - break;
|
2547 | | - case 'currentyear':
|
2548 | | - I HAS value IZ $wgContLang->formatNum( gmdate( 'Y', $ts ), true )
|
2549 | | - break;
|
2550 | | - case 'currenttime':
|
2551 | | - I HAS value IZ $wgContLang->time( wfTimestamp( TS_MW, $ts ), false, false )
|
2552 | | - break;
|
2553 | | - case 'currenthour':
|
2554 | | - I HAS value IZ $wgContLang->formatNum( gmdate( 'H', $ts ), true )
|
2555 | | - break;
|
2556 | | - case 'currentweek':
|
2557 | | - BTW @bug 4594 PHP5 has it zero padded, PHP4 does not, cast to
|
2558 | | - BTW int to remove the padding
|
2559 | | - I HAS value IZ $wgContLang->formatNum( (int)gmdate( 'W', $ts ) )
|
2560 | | - break;
|
2561 | | - case 'currentdow':
|
2562 | | - I HAS value IZ $wgContLang->formatNum( gmdate( 'w', $ts ) )
|
2563 | | - break;
|
2564 | | - case 'localdayname':
|
2565 | | - I HAS value IZ $wgContLang->getWeekdayName( $localDayOfWeek + 1 )
|
2566 | | - break;
|
2567 | | - case 'localyear':
|
2568 | | - I HAS value IZ $wgContLang->formatNum( $localYear, true )
|
2569 | | - break;
|
2570 | | - case 'localtime':
|
2571 | | - I HAS value IZ $wgContLang->time( $localTimestamp, false, false )
|
2572 | | - break;
|
2573 | | - case 'localhour':
|
2574 | | - I HAS value IZ $wgContLang->formatNum( $localHour, true )
|
2575 | | - break;
|
2576 | | - case 'localweek':
|
2577 | | - BTW @bug 4594 PHP5 has it zero padded, PHP4 does not, cast to
|
2578 | | - BTW int to remove the padding
|
2579 | | - I HAS value IZ $wgContLang->formatNum( (int)$localWeek )
|
2580 | | - break;
|
2581 | | - case 'localdow':
|
2582 | | - I HAS value IZ $wgContLang->formatNum( $localDayOfWeek )
|
2583 | | - break;
|
2584 | | - case 'numberofarticles':
|
2585 | | - I HAS value IZ $wgContLang->formatNum( SiteStats::articles() )
|
2586 | | - break;
|
2587 | | - case 'numberoffiles':
|
2588 | | - I HAS value IZ $wgContLang->formatNum( SiteStats::images() )
|
2589 | | - break;
|
2590 | | - case 'numberofusers':
|
2591 | | - I HAS value IZ $wgContLang->formatNum( SiteStats::users() )
|
2592 | | - break;
|
2593 | | - case 'numberofactiveusers':
|
2594 | | - I HAS value IZ $wgContLang->formatNum( SiteStats::activeUsers() )
|
2595 | | - break;
|
2596 | | - case 'numberofpages':
|
2597 | | - I HAS value IZ $wgContLang->formatNum( SiteStats::pages() )
|
2598 | | - break;
|
2599 | | - case 'numberofadmins':
|
2600 | | - I HAS value IZ $wgContLang->formatNum( SiteStats::numberingroup( 'sysop' ) )
|
2601 | | - break;
|
2602 | | - case 'numberofedits':
|
2603 | | - I HAS value IZ $wgContLang->formatNum( SiteStats::edits() )
|
2604 | | - break;
|
2605 | | - case 'numberofviews':
|
2606 | | - I HAS value IZ $wgContLang->formatNum( SiteStats::views() )
|
2607 | | - break;
|
2608 | | - case 'currenttimestamp':
|
2609 | | - I HAS value IZ wfTimestamp( TS_MW, $ts )
|
2610 | | - break;
|
2611 | | - case 'localtimestamp':
|
2612 | | - I HAS value IZ $localTimestamp
|
2613 | | - break;
|
2614 | | - case 'currentversion':
|
2615 | | - I HAS value IZ SpecialVersion::getVersion()
|
2616 | | - break;
|
2617 | | - case 'sitename':
|
2618 | | - I FOUND MAH $wgSitename
|
2619 | | - case 'server':
|
2620 | | - I FOUND MAH $wgServer
|
2621 | | - case 'servername':
|
2622 | | - I FOUND MAH $wgServerName
|
2623 | | - case 'scriptpath':
|
2624 | | - I FOUND MAH $wgScriptPath
|
2625 | | - case 'stylepath':
|
2626 | | - I FOUND MAH $wgStylePath
|
2627 | | - case 'directionmark':
|
2628 | | - I FOUND MAH $wgContLang->getDirMark()
|
2629 | | - case 'contentlanguage':
|
2630 | | - I HAS UR $wgContLanguageCode ON UR INTERNETS
|
2631 | | - I FOUND MAH $wgContLanguageCode
|
2632 | | - default:
|
2633 | | - I HAS ret
|
2634 | | - IZ wfRunHooks( 'ParserGetVariableValueSwitch', array( &$this, &$this->mVarCache, &$index, &$ret, &$frame ) )
|
2635 | | - I FOUND MAH $ret
|
2636 | | - NOWAI
|
2637 | | - I FOUND MAH null
|
2638 | | - KTHX
|
2639 | | - KTHX
|
2640 | | -
|
2641 | | - if ( $index )
|
2642 | | - $this->mVarCache[$index] = $value;
|
2643 | | -
|
2644 | | - I FOUND MAH $value
|
2645 | | - KTHX
|
2646 | | -
|
2647 | | - DO NOT WANT
|
2648 | | - NOT WANT initialise the magic variables (like CURRENTMONTHNAME) and substitution modifiers
|
2649 | | - NOT WANT
|
2650 | | - NOT WANT @private
|
2651 | | - WANT
|
2652 | | - SO IM LIKE initialiseVariables
|
2653 | | - IM ON UR wfProfileIn DOING __METHOD__
|
2654 | | - I HAS variableIDs IZ MagicWord::getVariableIDs()
|
2655 | | - I HAS substIDs IZ MagicWord::getSubstIDs()
|
2656 | | -
|
2657 | | - UR SPECIAL mVariables IZ new MagicWordArray( $variableIDs );
|
2658 | | - UR SPECIAL mSubstWords IZ new MagicWordArray( $substIDs );
|
2659 | | - IM ON UR wfProfileOut DOING __METHOD__
|
2660 | | - KTHX
|
2661 | | -
|
2662 | | - DO NOT WANT
|
2663 | | - NOT WANT Preprocess some wikitext and return the document tree.
|
2664 | | - NOT WANT This is the ghost of replace_variables().
|
2665 | | - NOT WANT
|
2666 | | - NOT WANT @param string $text The text to parse
|
2667 | | - NOT WANT @param integer flags Bitwise combination of:
|
2668 | | - NOT WANT self::PTD_FOR_INCLUSION Handle <noinclude>/<includeonly> as if the text is being
|
2669 | | - NOT WANT included. Default is to assume a direct page view.
|
2670 | | - NOT WANT
|
2671 | | - NOT WANT The generated DOM tree must depend only on the input text and the flags.
|
2672 | | - NOT WANT The DOM tree must be the same in OT_HTML and OT_WIKI mode, to avoid a regression of bug 4899.
|
2673 | | - NOT WANT
|
2674 | | - NOT WANT Any flag added to the $flags parameter here, or any other parameter liable to cause a
|
2675 | | - NOT WANT change in the DOM tree for a given text, must be passed through the section identifier
|
2676 | | - NOT WANT in the section edit link and thus back to extractSections().
|
2677 | | - NOT WANT
|
2678 | | - NOT WANT The output of this function is currently only cached in process memory, but a persistent
|
2679 | | - NOT WANT cache may be implemented at a later date which takes further advantage of these strict
|
2680 | | - NOT WANT dependency requirements.
|
2681 | | - NOT WANT
|
2682 | | - NOT WANT @private
|
2683 | | - WANT
|
2684 | | - SO IM LIKE preprocessToDom WITH UR $text, $flags = 0
|
2685 | | - I HAS dom IZ $this->getPreprocessor()->preprocessToObj( $text, $flags )
|
2686 | | - I FOUND MAH $dom
|
2687 | | - KTHX
|
2688 | | -
|
2689 | | - DO NOT WANT
|
2690 | | - NOT WANT Return a three-element array: leading whitespace, string contents, trailing whitespace
|
2691 | | - WANT
|
2692 | | - SO IM ALWAYS LIKE splitWhitespace WITH UR $s
|
2693 | | - I HAS ltrimmed IZ ltrim( $s )
|
2694 | | - I HAS w1 IZ substr( $s, 0, strlen( $s ) - strlen( $ltrimmed ) )
|
2695 | | - I HAS trimmed IZ rtrim( $ltrimmed )
|
2696 | | - I HAS diff IZ strlen( $ltrimmed ) - strlen( $trimmed )
|
2697 | | - IZ $diff > 0
|
2698 | | - I HAS w2 IZ substr( $ltrimmed, -$diff )
|
2699 | | - NOWAI
|
2700 | | - I HAS w2 IZ ''
|
2701 | | - KTHX
|
2702 | | - I FOUND MAH array( $w1, $trimmed, $w2 )
|
2703 | | - KTHX
|
2704 | | -
|
2705 | | - DO NOT WANT
|
2706 | | - NOT WANT Replace magic variables, templates, and template arguments
|
2707 | | - NOT WANT with the appropriate text. Templates are substituted recursively,
|
2708 | | - NOT WANT taking care to avoid infinite loops.
|
2709 | | - NOT WANT
|
2710 | | - NOT WANT Note that the substitution depends on value of $mOutputType:
|
2711 | | - NOT WANT self::OT_WIKI: only {{subst:}} templates
|
2712 | | - NOT WANT self::OT_PREPROCESS: templates but not extension tags
|
2713 | | - NOT WANT self::OT_HTML: all templates and extension tags
|
2714 | | - NOT WANT
|
2715 | | - NOT WANT @param string $tex The text to transform
|
2716 | | - NOT WANT @param PPFrame $frame Object describing the arguments passed to the template.
|
2717 | | - NOT WANT Arguments may also be provided as an associative array, as was the usual case before MW1.12.
|
2718 | | - NOT WANT Providing arguments this way may be useful for extensions wishing to perform variable replacement explicitly.
|
2719 | | - NOT WANT @param bool $argsOnly Only do argument (triple-brace) expansion, not double-brace expansion
|
2720 | | - NOT WANT @private
|
2721 | | - WANT
|
2722 | | - SO IM LIKE replaceVariables WITH UR $text, $frame = false, $argsOnly = false
|
2723 | | - BTW Is there any text? Also, Prevent too big inclusions!
|
2724 | | - IZ strlen( $text ) < 1 || strlen( $text ) > $this->mOptions->getMaxIncludeSize()
|
2725 | | - I FOUND MAH $text
|
2726 | | - KTHX
|
2727 | | - IM ON UR wfProfileIn DOING __METHOD__
|
2728 | | -
|
2729 | | - IZ $frame === false
|
2730 | | - I HAS frame IZ $this->getPreprocessor()->newFrame()
|
2731 | | - ORLY !( $frame instanceof PPFrame )
|
2732 | | - IM ON UR wfDebug DOING __METHOD__." called using plain parameters instead of a PPFrame instance. Creating custom frame.\n"
|
2733 | | - I HAS frame IZ $this->getPreprocessor()->newCustomFrame( $frame )
|
2734 | | - KTHX
|
2735 | | -
|
2736 | | - I HAS dom IZ $this->preprocessToDom( $text )
|
2737 | | - I HAS flags IZ $argsOnly ? PPFrame::NO_TEMPLATES : 0
|
2738 | | - I HAS text IZ $frame->expand( $dom, $flags )
|
2739 | | -
|
2740 | | - IM ON UR wfProfileOut DOING __METHOD__
|
2741 | | - I FOUND MAH $text
|
2742 | | - KTHX
|
2743 | | -
|
2744 | | - BTW Clean up argument array - refactored in 1.9 so parserfunctions can use it, too.
|
2745 | | - SO IM ALWAYS LIKE createAssocArgs WITH UR $args
|
2746 | | - I HAS assocArgs IZ EMPTY
|
2747 | | - I HAS index IZ 1
|
2748 | | - IM IN UR args ITZA arg
|
2749 | | - I HAS eqpos IZ strpos( $arg, '=' )
|
2750 | | - IZ $eqpos === false
|
2751 | | - $assocArgs[$index++] = $arg;
|
2752 | | - NOWAI
|
2753 | | - I HAS name IZ trim( substr( $arg, 0, $eqpos ) )
|
2754 | | - I HAS value IZ trim( substr( $arg, $eqpos+1 ) )
|
2755 | | - IZ $value === false
|
2756 | | - I HAS value IZ ''
|
2757 | | - KTHX
|
2758 | | - IZ $name !== false
|
2759 | | - $assocArgs[$name] = $value;
|
2760 | | - KTHX
|
2761 | | - KTHX
|
2762 | | - KTHX
|
2763 | | -
|
2764 | | - I FOUND MAH $assocArgs
|
2765 | | - KTHX
|
2766 | | -
|
2767 | | - DO NOT WANT
|
2768 | | - NOT WANT Warn the user when a parser limitation is reached
|
2769 | | - NOT WANT Will warn at most once the user per limitation type
|
2770 | | - NOT WANT
|
2771 | | - NOT WANT @param string $limitationType, should be one of:
|
2772 | | - NOT WANT 'expensive-parserfunction' (corresponding messages:
|
2773 | | - NOT WANT 'expensive-parserfunction-warning',
|
2774 | | - NOT WANT 'expensive-parserfunction-category')
|
2775 | | - NOT WANT 'post-expand-template-argument' (corresponding messages:
|
2776 | | - NOT WANT 'post-expand-template-argument-warning',
|
2777 | | - NOT WANT 'post-expand-template-argument-category')
|
2778 | | - NOT WANT 'post-expand-template-inclusion' (corresponding messages:
|
2779 | | - NOT WANT 'post-expand-template-inclusion-warning',
|
2780 | | - NOT WANT 'post-expand-template-inclusion-category')
|
2781 | | - NOT WANT @params int $current, $max When an explicit limit has been
|
2782 | | - NOT WANT exceeded, provide the values (optional)
|
2783 | | - WANT
|
2784 | | - function limitationWarn( $limitationType, $current=null, $max=null) {
|
2785 | | - BTW does no harm if $current and $max are present but are unnecessary for the message
|
2786 | | - I HAS warning IZ wfMsgExt( "$limitationType-warning", array( 'parsemag', 'escape' ), $current, $max )
|
2787 | | - IM ON UR SPECIAL mOutput->addWarning DOING $warning
|
2788 | | - IM ON UR SPECIAL addTrackingCategory DOING "$limitationType-category"
|
2789 | | - KTHX
|
2790 | | -
|
2791 | | - DO NOT WANT
|
2792 | | - NOT WANT Return the text of a template, after recursively
|
2793 | | - NOT WANT replacing any variables or templates within the template.
|
2794 | | - NOT WANT
|
2795 | | - NOT WANT @param array $piece The parts of the template
|
2796 | | - NOT WANT $piece['title']: the title, i.e. the part before the |
|
2797 | | - NOT WANT $piece['parts']: the parameter array
|
2798 | | - NOT WANT $piece['lineStart']: whether the brace was at the start of a line
|
2799 | | - NOT WANT @param PPFrame The current frame, contains template arguments
|
2800 | | - NOT WANT @return string the text of the template
|
2801 | | - NOT WANT @private
|
2802 | | - WANT
|
2803 | | - SO IM LIKE braceSubstitution WITH UR $piece, $frame
|
2804 | | - I HAS UR $wgContLang, $wgNonincludableNamespaces ON UR INTERNETS
|
2805 | | - IM ON UR wfProfileIn DOING __METHOD__
|
2806 | | - IM ON UR wfProfileIn DOING __METHOD__.'-setup'
|
2807 | | -
|
2808 | | - BTW Flags
|
2809 | | - I HAS found IZ false # $text has been filled
|
2810 | | - I HAS nowiki IZ false # wiki markup in $text should be escaped
|
2811 | | - I HAS isHTML IZ false # $text is HTML, armour it against wikitext transformation
|
2812 | | - I HAS forceRawInterwiki IZ false # Force interwiki transclusion to be done in raw mode not rendered
|
2813 | | - I HAS isChildObj IZ false # $text is a DOM node needing expansion in a child frame
|
2814 | | - I HAS isLocalObj IZ false # $text is a DOM node needing expansion in the current frame
|
2815 | | -
|
2816 | | - BTW Title object, where $text came from
|
2817 | | - I HAS title
|
2818 | | -
|
2819 | | - BTW $part1 is the bit before the first |, and must contain only title characters.
|
2820 | | - BTW Various prefixes will be stripped from it later.
|
2821 | | - I HAS titleWithSpaces IZ $frame->expand( $piece['title'] )
|
2822 | | - I HAS part1 IZ trim( $titleWithSpaces )
|
2823 | | - I HAS titleText IZ false
|
2824 | | -
|
2825 | | - BTW Original title text preserved for various purposes
|
2826 | | - I HAS originalTitle IZ $part1
|
2827 | | -
|
2828 | | - BTW $args is a list of argument nodes, starting from index 0, not including $part1
|
2829 | | - I HAS args IZ ( null == $piece['parts'] ) ? array() : $piece['parts']
|
2830 | | - IM ON UR wfProfileOut DOING __METHOD__.'-setup'
|
2831 | | -
|
2832 | | - BTW SUBST
|
2833 | | - IM ON UR wfProfileIn DOING __METHOD__.'-modifiers'
|
2834 | | - IZ !$found
|
2835 | | -
|
2836 | | - I HAS substMatch IZ $this->mSubstWords->matchStartAndRemove( $part1 )
|
2837 | | -
|
2838 | | - BTW Possibilities for substMatch: "subst", "safesubst" or FALSE
|
2839 | | - BTW Decide whether to expand template or keep wikitext as-is.
|
2840 | | - IZ $this->ot['wiki']
|
2841 | | - IZ $substMatch === false
|
2842 | | - I HAS literal IZ true # literal when in PST with no prefix
|
2843 | | - NOWAI
|
2844 | | - I HAS literal IZ false # expand when in PST with subst: or safesubst:
|
2845 | | - KTHX
|
2846 | | - NOWAI
|
2847 | | - IZ $substMatch == 'subst'
|
2848 | | - I HAS literal IZ true # literal when not in PST with plain subst:
|
2849 | | - NOWAI
|
2850 | | - I HAS literal IZ false # expand when not in PST with safesubst: or no prefix
|
2851 | | - KTHX
|
2852 | | - KTHX
|
2853 | | - IZ $literal
|
2854 | | - I HAS text IZ $frame->virtualBracketedImplode( '{{', '|', '}}', $titleWithSpaces, $args )
|
2855 | | - I HAS isLocalObj IZ true
|
2856 | | - I HAS found IZ true
|
2857 | | - KTHX
|
2858 | | - KTHX
|
2859 | | -
|
2860 | | - BTW Variables
|
2861 | | - IZ !$found && $args->getLength() == 0
|
2862 | | - I HAS id IZ $this->mVariables->matchStartToEnd( $part1 )
|
2863 | | - IZ $id !== false
|
2864 | | - I HAS text IZ $this->getVariableValue( $id, $frame )
|
2865 | | - IZ MagicWord::getCacheTTL( $id ) > -1
|
2866 | | - UR SPECIAL mOutput->mContainsOldMagic IZ true;
|
2867 | | - KTHX
|
2868 | | - I HAS found IZ true
|
2869 | | - KTHX
|
2870 | | - KTHX
|
2871 | | -
|
2872 | | - BTW MSG, MSGNW and RAW
|
2873 | | - IZ !$found
|
2874 | | - BTW Check for MSGNW:
|
2875 | | - I HAS mwMsgnw IZ MagicWord::get( 'msgnw' )
|
2876 | | - IZ $mwMsgnw->matchStartAndRemove( $part1 )
|
2877 | | - I HAS nowiki IZ true
|
2878 | | - NOWAI
|
2879 | | - BTW Remove obsolete MSG:
|
2880 | | - I HAS mwMsg IZ MagicWord::get( 'msg' )
|
2881 | | - $mwMsg->matchStartAndRemove( $part1 );
|
2882 | | - KTHX
|
2883 | | -
|
2884 | | - BTW Check for RAW:
|
2885 | | - I HAS mwRaw IZ MagicWord::get( 'raw' )
|
2886 | | - IZ $mwRaw->matchStartAndRemove( $part1 )
|
2887 | | - I HAS forceRawInterwiki IZ true
|
2888 | | - KTHX
|
2889 | | - KTHX
|
2890 | | - IM ON UR wfProfileOut DOING __METHOD__.'-modifiers'
|
2891 | | -
|
2892 | | - BTW Parser functions
|
2893 | | - IZ !$found
|
2894 | | - IM ON UR wfProfileIn DOING __METHOD__ . '-pfunc'
|
2895 | | -
|
2896 | | - I HAS colonPos IZ strpos( $part1, ':' )
|
2897 | | - IZ $colonPos !== false
|
2898 | | - BTW Case sensitive functions
|
2899 | | - I HAS function IZ substr( $part1, 0, $colonPos )
|
2900 | | - IZ isset( $this->mFunctionSynonyms[1][$function] )
|
2901 | | - I HAS function IZ $this->mFunctionSynonyms[1][$function]
|
2902 | | - NOWAI
|
2903 | | - BTW Case insensitive functions
|
2904 | | - I HAS function IZ $wgContLang->lc( $function )
|
2905 | | - IZ isset( $this->mFunctionSynonyms[0][$function] )
|
2906 | | - I HAS function IZ $this->mFunctionSynonyms[0][$function]
|
2907 | | - NOWAI
|
2908 | | - I HAS function IZ false
|
2909 | | - KTHX
|
2910 | | - KTHX
|
2911 | | - IZ $function
|
2912 | | - list( $callback, $flags ) = $this->mFunctionHooks[$function];
|
2913 | | - I HAS initialArgs IZ BUCKET &$this );
|
2914 | | - I HAS funcArgs IZ BUCKET trim( substr( $part1, $colonPos + 1 ) ) );
|
2915 | | - IZ $flags & SFH_OBJECT_ARGS
|
2916 | | - BTW Add a frame parameter, and pass the arguments as an array
|
2917 | | - I HAS allArgs IZ $initialArgs
|
2918 | | - $allArgs[] = $frame;
|
2919 | | - for ( $i = 0; $i < $args->getLength(); $i++ ) {
|
2920 | | - $funcArgs[] = $args->item( $i );
|
2921 | | - KTHX
|
2922 | | - $allArgs[] = $funcArgs;
|
2923 | | - NOWAI
|
2924 | | - BTW Convert arguments to plain text
|
2925 | | - for ( $i = 0; $i < $args->getLength(); $i++ ) {
|
2926 | | - $funcArgs[] = trim( $frame->expand( $args->item( $i ) ) );
|
2927 | | - KTHX
|
2928 | | - I HAS allArgs IZ array_merge( $initialArgs, $funcArgs )
|
2929 | | - KTHX
|
2930 | | -
|
2931 | | - BTW Workaround for PHP bug 35229 and similar
|
2932 | | - IZ !is_callable( $callback )
|
2933 | | - IM ON UR wfProfileOut DOING __METHOD__ . '-pfunc'
|
2934 | | - IM ON UR wfProfileOut DOING __METHOD__
|
2935 | | - throw new MWException( "Tag hook for $function is not callable\n" );
|
2936 | | - KTHX
|
2937 | | - I HAS result IZ call_user_func_array( $callback, $allArgs )
|
2938 | | - I HAS found IZ true
|
2939 | | - I HAS noparse IZ true
|
2940 | | - I HAS preprocessFlags IZ 0
|
2941 | | -
|
2942 | | - IZ is_array( $result )
|
2943 | | - IZ isset( $result[0] )
|
2944 | | - I HAS text IZ $result[0]
|
2945 | | - IM ON UR unset DOING $result[0]
|
2946 | | - KTHX
|
2947 | | -
|
2948 | | - BTW Extract flags into the local scope
|
2949 | | - BTW This allows callers to set flags such as nowiki, found, etc.
|
2950 | | - IM ON UR extract DOING $result
|
2951 | | - NOWAI
|
2952 | | - I HAS text IZ $result
|
2953 | | - KTHX
|
2954 | | - IZ !$noparse
|
2955 | | - I HAS text IZ $this->preprocessToDom( $text, $preprocessFlags )
|
2956 | | - I HAS isChildObj IZ true
|
2957 | | - KTHX
|
2958 | | - KTHX
|
2959 | | - KTHX
|
2960 | | - IM ON UR wfProfileOut DOING __METHOD__ . '-pfunc'
|
2961 | | - KTHX
|
2962 | | -
|
2963 | | - BTW Finish mangling title and then check for loops.
|
2964 | | - BTW Set $title to a Title object and $titleText to the PDBK
|
2965 | | - IZ !$found
|
2966 | | - I HAS ns IZ NS_TEMPLATE
|
2967 | | - BTW Split the title into page and subpage
|
2968 | | - I HAS subpage IZ ''
|
2969 | | - I HAS part1 IZ $this->maybeDoSubpageLink( $part1, $subpage )
|
2970 | | - IZ $subpage !== ''
|
2971 | | - I HAS ns IZ $this->mTitle->getNamespace()
|
2972 | | - KTHX
|
2973 | | - I HAS title IZ Title::newFromText( $part1, $ns )
|
2974 | | - IZ $title
|
2975 | | - I HAS titleText IZ $title->getPrefixedText()
|
2976 | | - BTW Check for language variants if the template is not found
|
2977 | | - IZ $wgContLang->hasVariants() && $title->getArticleID() == 0
|
2978 | | - $wgContLang->findVariantLink( $part1, $title, true );
|
2979 | | - KTHX
|
2980 | | - BTW Do recursion depth check
|
2981 | | - I HAS limit IZ $this->mOptions->getMaxTemplateDepth()
|
2982 | | - IZ $frame->depth >= $limit
|
2983 | | - I HAS found IZ true
|
2984 | | - text IZ '<span class="error">'
|
2985 | | - . wfMsgForContent( 'parser-template-recursion-depth-warning', $limit )
|
2986 | | - . '</span>';
|
2987 | | - KTHX
|
2988 | | - KTHX
|
2989 | | - KTHX
|
2990 | | -
|
2991 | | - BTW Load from database
|
2992 | | - IZ !$found && $title
|
2993 | | - IM ON UR wfProfileIn DOING __METHOD__ . '-loadtpl'
|
2994 | | - IZ !$title->isExternal()
|
2995 | | - if ( $title->getNamespace() == NS_SPECIAL
|
2996 | | - && $this->mOptions->getAllowSpecialInclusion()
|
2997 | | - && $this->ot['html'] )
|
2998 | | - {
|
2999 | | - I HAS text IZ SpecialPage::capturePath( $title )
|
3000 | | - IZ is_string( $text )
|
3001 | | - I HAS found IZ true
|
3002 | | - I HAS isHTML IZ true
|
3003 | | - IM ON UR SPECIAL disableCache
|
3004 | | - KTHX
|
3005 | | - ORLY $wgNonincludableNamespaces && in_array( $title->getNamespace(), $wgNonincludableNamespaces )
|
3006 | | - I HAS found IZ false # access denied
|
3007 | | - IM ON UR wfDebug DOING __METHOD__.": template inclusion denied for " . $title->getPrefixedDBkey()
|
3008 | | - NOWAI
|
3009 | | - IM ON UR list DOING $text, $title ) = $this->getTemplateDom( $title
|
3010 | | - IZ $text !== false
|
3011 | | - I HAS found IZ true
|
3012 | | - I HAS isChildObj IZ true
|
3013 | | - KTHX
|
3014 | | - KTHX
|
3015 | | -
|
3016 | | - BTW If the title is valid but undisplayable, make a link to it
|
3017 | | - IZ !$found && ( $this->ot['html'] || $this->ot['pre'] )
|
3018 | | - I HAS text IZ "[[:$titleText]]"
|
3019 | | - I HAS found IZ true
|
3020 | | - KTHX
|
3021 | | - ORLY $title->isTrans()
|
3022 | | - BTW Interwiki transclusion
|
3023 | | - IZ $this->ot['html'] && !$forceRawInterwiki
|
3024 | | - I HAS text IZ $this->interwikiTransclude( $title, 'render' )
|
3025 | | - I HAS isHTML IZ true
|
3026 | | - NOWAI
|
3027 | | - I HAS text IZ $this->interwikiTransclude( $title, 'raw' )
|
3028 | | - BTW Preprocess it like a template
|
3029 | | - I HAS text IZ $this->preprocessToDom( $text, self::PTD_FOR_INCLUSION )
|
3030 | | - I HAS isChildObj IZ true
|
3031 | | - KTHX
|
3032 | | - I HAS found IZ true
|
3033 | | - KTHX
|
3034 | | -
|
3035 | | - BTW Do infinite loop check
|
3036 | | - BTW This has to be done after redirect resolution to avoid infinite loops via redirects
|
3037 | | - IZ !$frame->loopCheck( $title )
|
3038 | | - I HAS found IZ true
|
3039 | | - I HAS text IZ '<span class="error">' . wfMsgForContent( 'parser-template-loop-warning', $titleText ) . '</span>'
|
3040 | | - IM ON UR wfDebug DOING __METHOD__.": template loop broken at '$titleText'\n"
|
3041 | | - KTHX
|
3042 | | - IM ON UR wfProfileOut DOING __METHOD__ . '-loadtpl'
|
3043 | | - KTHX
|
3044 | | -
|
3045 | | - BTW If we haven't found text to substitute by now, we're done
|
3046 | | - BTW Recover the source wikitext and return it
|
3047 | | - IZ !$found
|
3048 | | - I HAS text IZ $frame->virtualBracketedImplode( '{{', '|', '}}', $titleWithSpaces, $args )
|
3049 | | - IM ON UR wfProfileOut DOING __METHOD__
|
3050 | | - I FOUND MAH array( 'object' => $text )
|
3051 | | - KTHX
|
3052 | | -
|
3053 | | - BTW Expand DOM-style return values in a child frame
|
3054 | | - IZ $isChildObj
|
3055 | | - BTW Clean up argument array
|
3056 | | - I HAS newFrame IZ $frame->newChild( $args, $title )
|
3057 | | -
|
3058 | | - IZ $nowiki
|
3059 | | - I HAS text IZ $newFrame->expand( $text, PPFrame::RECOVER_ORIG )
|
3060 | | - ORLY $titleText !== false && $newFrame->isEmpty()
|
3061 | | - BTW Expansion is eligible for the empty-frame cache
|
3062 | | - IZ isset( $this->mTplExpandCache[$titleText] )
|
3063 | | - I HAS text IZ $this->mTplExpandCache[$titleText]
|
3064 | | - NOWAI
|
3065 | | - I HAS text IZ $newFrame->expand( $text )
|
3066 | | - $this->mTplExpandCache[$titleText] = $text;
|
3067 | | - KTHX
|
3068 | | - NOWAI
|
3069 | | - BTW Uncached expansion
|
3070 | | - I HAS text IZ $newFrame->expand( $text )
|
3071 | | - KTHX
|
3072 | | - KTHX
|
3073 | | - IZ $isLocalObj && $nowiki
|
3074 | | - I HAS text IZ $frame->expand( $text, PPFrame::RECOVER_ORIG )
|
3075 | | - I HAS isLocalObj IZ false
|
3076 | | - KTHX
|
3077 | | -
|
3078 | | - BTW Replace raw HTML by a placeholder
|
3079 | | - BTW Add a blank line preceding, to prevent it from mucking up
|
3080 | | - BTW immediately preceding headings
|
3081 | | - IZ $isHTML
|
3082 | | - I HAS text IZ "\n\n" . $this->insertStripItem( $text )
|
3083 | | - ORLY $nowiki && ( $this->ot['html'] || $this->ot['pre'] )
|
3084 | | - BTW Escape nowiki-style return values
|
3085 | | - I HAS text IZ wfEscapeWikiText( $text )
|
3086 | | - KTHX elseif ( is_string( $text )
|
3087 | | - && !$piece['lineStart']
|
3088 | | - && preg_match( '/^(?:{\\||:|;|#|\*)/', $text ) )
|
3089 | | - {
|
3090 | | - BTW Bug 529: if the template begins with a table or block-level
|
3091 | | - BTW element, it should be treated as beginning a new line.
|
3092 | | - BTW This behaviour is somewhat controversial.
|
3093 | | - I HAS text IZ "\n" . $text
|
3094 | | - KTHX
|
3095 | | -
|
3096 | | - IZ is_string( $text ) && !$this->incrementIncludeSize( 'post-expand', strlen( $text ) )
|
3097 | | - BTW Error, oversize inclusion
|
3098 | | - text IZ "[[$originalTitle]]" .
|
3099 | | - IM ON UR SPECIAL insertStripItem DOING '<!-- WARNING: template omitted, post-expand include size too large -->'
|
3100 | | - IM ON UR SPECIAL limitationWarn DOING 'post-expand-template-inclusion'
|
3101 | | - KTHX
|
3102 | | -
|
3103 | | - IZ $isLocalObj
|
3104 | | - I HAS ret IZ BUCKET 'object' => $text );
|
3105 | | - NOWAI
|
3106 | | - I HAS ret IZ BUCKET 'text' => $text );
|
3107 | | - KTHX
|
3108 | | -
|
3109 | | - IM ON UR wfProfileOut DOING __METHOD__
|
3110 | | - I FOUND MAH $ret
|
3111 | | - KTHX
|
3112 | | -
|
3113 | | - DO NOT WANT
|
3114 | | - NOT WANT Get the semi-parsed DOM representation of a template with a given title,
|
3115 | | - NOT WANT and its redirect destination title. Cached.
|
3116 | | - WANT
|
3117 | | - SO IM LIKE getTemplateDom WITH UR $title
|
3118 | | - I HAS cacheTitle IZ $title
|
3119 | | - I HAS titleText IZ $title->getPrefixedDBkey()
|
3120 | | -
|
3121 | | - IZ isset( $this->mTplRedirCache[$titleText] )
|
3122 | | - list( $ns, $dbk ) = $this->mTplRedirCache[$titleText];
|
3123 | | - I HAS title IZ Title::makeTitle( $ns, $dbk )
|
3124 | | - I HAS titleText IZ $title->getPrefixedDBkey()
|
3125 | | - KTHX
|
3126 | | - IZ isset( $this->mTplDomCache[$titleText] )
|
3127 | | - I FOUND MAH array( $this->mTplDomCache[$titleText], $title )
|
3128 | | - KTHX
|
3129 | | -
|
3130 | | - BTW Cache miss, go to the database
|
3131 | | - IM ON UR list DOING $text, $title ) = $this->fetchTemplateAndTitle( $title
|
3132 | | -
|
3133 | | - IZ $text === false
|
3134 | | - $this->mTplDomCache[$titleText] = false;
|
3135 | | - I FOUND MAH array( false, $title )
|
3136 | | - KTHX
|
3137 | | -
|
3138 | | - I HAS dom IZ $this->preprocessToDom( $text, self::PTD_FOR_INCLUSION )
|
3139 | | - $this->mTplDomCache[ $titleText ] = $dom;
|
3140 | | -
|
3141 | | - IZ !$title->equals( $cacheTitle )
|
3142 | | - $this->mTplRedirCache[$cacheTitle->getPrefixedDBkey()] =
|
3143 | | - IM ON UR array DOING $title->getNamespace(),$cdb = $title->getDBkey()
|
3144 | | - KTHX
|
3145 | | -
|
3146 | | - I FOUND MAH array( $dom, $title )
|
3147 | | - KTHX
|
3148 | | -
|
3149 | | - DO NOT WANT
|
3150 | | - NOT WANT Fetch the unparsed text of a template and register a reference to it.
|
3151 | | - WANT
|
3152 | | - SO IM LIKE fetchTemplateAndTitle WITH UR $title
|
3153 | | - I HAS templateCb IZ $this->mOptions->getTemplateCallback()
|
3154 | | - I HAS stuff IZ call_user_func( $templateCb, $title, $this )
|
3155 | | - I HAS text IZ $stuff['text']
|
3156 | | - I HAS finalTitle IZ isset( $stuff['finalTitle'] ) ? $stuff['finalTitle'] : $title
|
3157 | | - IZ isset( $stuff['deps'] )
|
3158 | | - foreach ( $stuff['deps'] as $dep ) {
|
3159 | | - IM ON UR SPECIAL mOutput->addTemplate DOING $dep['title'], $dep['page_id'], $dep['rev_id']
|
3160 | | - KTHX
|
3161 | | - KTHX
|
3162 | | - I FOUND MAH array( $text, $finalTitle )
|
3163 | | - KTHX
|
3164 | | -
|
3165 | | - SO IM LIKE fetchTemplate WITH UR $title
|
3166 | | - I HAS rv IZ $this->fetchTemplateAndTitle( $title )
|
3167 | | - I FOUND MAH $rv[0]
|
3168 | | - KTHX
|
3169 | | -
|
3170 | | - DO NOT WANT
|
3171 | | - NOT WANT Static function to get a template
|
3172 | | - NOT WANT Can be overridden via ParserOptions::setTemplateCallback().
|
3173 | | - WANT
|
3174 | | - SO IM ALWAYS LIKE statelessFetchTemplate WITH UR $title, $parser=false
|
3175 | | - I HAS text IZ $skip = false
|
3176 | | - I HAS finalTitle IZ $title
|
3177 | | - I HAS deps IZ EMPTY
|
3178 | | -
|
3179 | | - BTW Loop to fetch the article, with up to 1 redirect
|
3180 | | - for ( $i = 0; $i < 2 && is_object( $title ); $i++ ) {
|
3181 | | - BTW Give extensions a chance to select the revision instead
|
3182 | | - I HAS id IZ false # Assume current
|
3183 | | - IM ON UR wfRunHooks DOING 'BeforeParserFetchTemplateAndtitle', array( $parser, &$title, &$skip, &$id )
|
3184 | | -
|
3185 | | - IZ $skip
|
3186 | | - I HAS text IZ false
|
3187 | | - $deps[] = array(
|
3188 | | - 'title' => $title,
|
3189 | | - 'page_id' => $title->getArticleID(),
|
3190 | | - 'rev_id' => null );
|
3191 | | - break;
|
3192 | | - KTHX
|
3193 | | - I HAS rev IZ $id ? Revision::newFromId( $id ) : Revision::newFromTitle( $title )
|
3194 | | - I HAS rev_id IZ $rev ? $rev->getId() : 0
|
3195 | | - BTW If there is no current revision, there is no page
|
3196 | | - IZ $id === false && !$rev
|
3197 | | - I HAS linkCache IZ LinkCache::singleton()
|
3198 | | - $linkCache->addBadLinkObj( $title );
|
3199 | | - KTHX
|
3200 | | -
|
3201 | | - $deps[] = array(
|
3202 | | - 'title' => $title,
|
3203 | | - 'page_id' => $title->getArticleID(),
|
3204 | | - 'rev_id' => $rev_id );
|
3205 | | -
|
3206 | | - IZ $rev
|
3207 | | - I HAS text IZ $rev->getText()
|
3208 | | - ORLY $title->getNamespace() == NS_MEDIAWIKI
|
3209 | | - I HAS UR $wgContLang ON UR INTERNETS
|
3210 | | - I HAS message IZ $wgContLang->lcfirst( $title->getText() )
|
3211 | | - I HAS text IZ wfMsgForContentNoTrans( $message )
|
3212 | | - IZ wfEmptyMsg( $message, $text )
|
3213 | | - I HAS text IZ false
|
3214 | | - break;
|
3215 | | - KTHX
|
3216 | | - NOWAI
|
3217 | | - break;
|
3218 | | - KTHX
|
3219 | | - IZ $text === false
|
3220 | | - break;
|
3221 | | - KTHX
|
3222 | | - BTW Redirect?
|
3223 | | - I HAS finalTitle IZ $title
|
3224 | | - I HAS title IZ Title::newFromRedirect( $text )
|
3225 | | - KTHX
|
3226 | | - return array(
|
3227 | | - 'text' => $text,
|
3228 | | - 'finalTitle' => $finalTitle,
|
3229 | | - 'deps' => $deps );
|
3230 | | - KTHX
|
3231 | | -
|
3232 | | - DO NOT WANT
|
3233 | | - NOT WANT Transclude an interwiki link.
|
3234 | | - WANT
|
3235 | | - SO IM LIKE interwikiTransclude WITH UR $title, $action
|
3236 | | - I HAS UR $wgEnableScaryTranscluding ON UR INTERNETS
|
3237 | | -
|
3238 | | - IZ !$wgEnableScaryTranscluding
|
3239 | | - I FOUND MAH wfMsg('scarytranscludedisabled')
|
3240 | | - KTHX
|
3241 | | -
|
3242 | | - I HAS url IZ $title->getFullUrl( "action=$action" )
|
3243 | | -
|
3244 | | - IZ strlen( $url ) > 255
|
3245 | | - I FOUND MAH wfMsg( 'scarytranscludetoolong' )
|
3246 | | - KTHX
|
3247 | | - I FOUND MAH $this->fetchScaryTemplateMaybeFromCache( $url )
|
3248 | | - KTHX
|
3249 | | -
|
3250 | | - SO IM LIKE fetchScaryTemplateMaybeFromCache WITH UR $url
|
3251 | | - I HAS UR $wgTranscludeCacheExpiry ON UR INTERNETS
|
3252 | | - I HAS dbr IZ wfGetDB( DB_SLAVE )
|
3253 | | - I HAS tsCond IZ $dbr->timestamp( time() - $wgTranscludeCacheExpiry )
|
3254 | | - obj IZ $dbr->selectRow( 'transcache', array('tc_time', 'tc_contents' ),
|
3255 | | - IM ON UR array DOING 'tc_url' => $url, "tc_time >= " . $dbr->addQuotes( $tsCond ) )
|
3256 | | - IZ $obj
|
3257 | | - I FOUND MAH $obj->tc_contents
|
3258 | | - KTHX
|
3259 | | -
|
3260 | | - I HAS text IZ Http::get( $url )
|
3261 | | - IZ !$text
|
3262 | | - I FOUND MAH wfMsg( 'scarytranscludefailed', $url )
|
3263 | | - KTHX
|
3264 | | -
|
3265 | | - I HAS dbw IZ wfGetDB( DB_MASTER )
|
3266 | | - $dbw->replace( 'transcache', array('tc_url'), array(
|
3267 | | - 'tc_url' => $url,
|
3268 | | - 'tc_time' => $dbw->timestamp( time() ),
|
3269 | | - 'tc_contents' => $text)
|
3270 | | - BUCKET
|
3271 | | - I FOUND MAH $text
|
3272 | | - KTHX
|
3273 | | -
|
3274 | | -
|
3275 | | - DO NOT WANT
|
3276 | | - NOT WANT Triple brace replacement -- used for template arguments
|
3277 | | - NOT WANT @private
|
3278 | | - WANT
|
3279 | | - SO IM LIKE argSubstitution WITH UR $piece, $frame
|
3280 | | - IM ON UR wfProfileIn DOING __METHOD__
|
3281 | | -
|
3282 | | - I HAS error IZ false
|
3283 | | - I HAS parts IZ $piece['parts']
|
3284 | | - I HAS nameWithSpaces IZ $frame->expand( $piece['title'] )
|
3285 | | - I HAS argName IZ trim( $nameWithSpaces )
|
3286 | | - I HAS object IZ false
|
3287 | | - I HAS text IZ $frame->getArgument( $argName )
|
3288 | | - if ( $text === false && $parts->getLength() > 0
|
3289 | | - && (
|
3290 | | - $this->ot['html']
|
3291 | | - || $this->ot['pre']
|
3292 | | - || ( $this->ot['wiki'] && $frame->isTemplate() )
|
3293 | | - )
|
3294 | | - ) {
|
3295 | | - BTW No match in frame, use the supplied default
|
3296 | | - I HAS object IZ $parts->item( 0 )->getChildren()
|
3297 | | - KTHX
|
3298 | | - IZ !$this->incrementIncludeSize( 'arg', strlen( $text ) )
|
3299 | | - I HAS error IZ '<!-- WARNING: argument omitted, expansion size too large -->'
|
3300 | | - IM ON UR SPECIAL limitationWarn DOING 'post-expand-template-argument'
|
3301 | | - KTHX
|
3302 | | -
|
3303 | | - IZ $text === false && $object === false
|
3304 | | - BTW No match anywhere
|
3305 | | - I HAS object IZ $frame->virtualBracketedImplode( '{{{', '|', '}}}', $nameWithSpaces, $parts )
|
3306 | | - KTHX
|
3307 | | - IZ $error !== false
|
3308 | | - text HAS MOAR $error;
|
3309 | | - KTHX
|
3310 | | - IZ $object !== false
|
3311 | | - I HAS ret IZ BUCKET 'object' => $object );
|
3312 | | - NOWAI
|
3313 | | - I HAS ret IZ BUCKET 'text' => $text );
|
3314 | | - KTHX
|
3315 | | -
|
3316 | | - IM ON UR wfProfileOut DOING __METHOD__
|
3317 | | - I FOUND MAH $ret
|
3318 | | - KTHX
|
3319 | | -
|
3320 | | - DO NOT WANT
|
3321 | | - NOT WANT Return the text to be used for a given extension tag.
|
3322 | | - NOT WANT This is the ghost of strip().
|
3323 | | - NOT WANT
|
3324 | | - NOT WANT @param array $params Associative array of parameters:
|
3325 | | - NOT WANT name PPNode for the tag name
|
3326 | | - NOT WANT attr PPNode for unparsed text where tag attributes are thought to be
|
3327 | | - NOT WANT attributes Optional associative array of parsed attributes
|
3328 | | - NOT WANT inner Contents of extension element
|
3329 | | - NOT WANT noClose Original text did not have a close tag
|
3330 | | - NOT WANT @param PPFrame $frame
|
3331 | | - WANT
|
3332 | | - SO IM LIKE extensionSubstitution WITH UR $params, $frame
|
3333 | | - I HAS UR $wgRawHtml, $wgContLang ON UR INTERNETS
|
3334 | | -
|
3335 | | - I HAS name IZ $frame->expand( $params['name'] )
|
3336 | | - I HAS attrText IZ !isset( $params['attr'] ) ? null : $frame->expand( $params['attr'] )
|
3337 | | - I HAS content IZ !isset( $params['inner'] ) ? null : $frame->expand( $params['inner'] )
|
3338 | | - I HAS marker IZ "{$this->mUniqPrefix}-$name-" . sprintf( '%08X', $this->mMarkerIndex++ ) . self::MARKER_SUFFIX
|
3339 | | -
|
3340 | | - isFunctionTag IZ isset( $this->mFunctionTagHooks[strtolower($name)] ) &&
|
3341 | | - ( $this->ot['html'] || $this->ot['pre'] );
|
3342 | | - IZ $isFunctionTag
|
3343 | | - I HAS markerType IZ 'none'
|
3344 | | - NOWAI
|
3345 | | - I HAS markerType IZ 'general'
|
3346 | | - KTHX
|
3347 | | - IZ $this->ot['html'] || $isFunctionTag
|
3348 | | - I HAS name IZ strtolower( $name )
|
3349 | | - I HAS attributes IZ Sanitizer::decodeTagAttributes( $attrText )
|
3350 | | - IZ isset( $params['attributes'] )
|
3351 | | - I HAS attributes IZ $attributes + $params['attributes']
|
3352 | | - KTHX
|
3353 | | -
|
3354 | | - IZ isset( $this->mTagHooks[$name] )
|
3355 | | - BTW Workaround for PHP bug 35229 and similar
|
3356 | | - IZ !is_callable( $this->mTagHooks[$name] )
|
3357 | | - throw new MWException( "Tag hook for $name is not callable\n" );
|
3358 | | - KTHX
|
3359 | | - output IZ call_user_func_array( $this->mTagHooks[$name],
|
3360 | | - IM ON UR array DOING $content, $attributes, $this, $frame )
|
3361 | | - ORLY isset( $this->mFunctionTagHooks[$name] )
|
3362 | | - list( $callback, $flags ) = $this->mFunctionTagHooks[$name];
|
3363 | | - IZ !is_callable( $callback )
|
3364 | | - throw new MWException( "Tag hook for $name is not callable\n" );
|
3365 | | - KTHX
|
3366 | | -
|
3367 | | - I HAS output IZ call_user_func_array( $callback, array( &$this, $frame, $content, $attributes ) )
|
3368 | | - NOWAI
|
3369 | | - output IZ '<span class="error">Invalid tag extension name: ' .
|
3370 | | - htmlspecialchars( $name ) . '</span>';
|
3371 | | - KTHX
|
3372 | | -
|
3373 | | - IZ is_array( $output )
|
3374 | | - BTW Extract flags to local scope (to override $markerType)
|
3375 | | - I HAS flags IZ $output
|
3376 | | - I HAS output IZ $flags[0]
|
3377 | | - IM ON UR unset DOING $flags[0]
|
3378 | | - IM ON UR extract DOING $flags
|
3379 | | - KTHX
|
3380 | | - NOWAI
|
3381 | | - IZ is_null( $attrText )
|
3382 | | - I HAS attrText IZ ''
|
3383 | | - KTHX
|
3384 | | - IZ isset( $params['attributes'] )
|
3385 | | - foreach ( $params['attributes'] as $attrName => $attrValue ) {
|
3386 | | - attrText HAS MOAR ' ' . htmlspecialchars( $attrName ) . '="' .
|
3387 | | - htmlspecialchars( $attrValue ) . '"';
|
3388 | | - KTHX
|
3389 | | - KTHX
|
3390 | | - IZ $content === null
|
3391 | | - I HAS output IZ "<$name$attrText/>"
|
3392 | | - NOWAI
|
3393 | | - I HAS close IZ is_null( $params['close'] ) ? '' : $frame->expand( $params['close'] )
|
3394 | | - I HAS output IZ "<$name$attrText>$content$close"
|
3395 | | - KTHX
|
3396 | | - KTHX
|
3397 | | -
|
3398 | | - IZ $markerType === 'none'
|
3399 | | - I FOUND MAH $output
|
3400 | | - ORLY $markerType === 'nowiki'
|
3401 | | - IM ON UR SPECIAL mStripState->nowiki->setPair DOING $marker, $output
|
3402 | | - ORLY $markerType === 'general'
|
3403 | | - IM ON UR SPECIAL mStripState->general->setPair DOING $marker, $output
|
3404 | | - NOWAI
|
3405 | | - throw new MWException( __METHOD__.': invalid marker type' );
|
3406 | | - KTHX
|
3407 | | - I FOUND MAH $marker
|
3408 | | - KTHX
|
3409 | | -
|
3410 | | - DO NOT WANT
|
3411 | | - NOT WANT Increment an include size counter
|
3412 | | - NOT WANT
|
3413 | | - NOT WANT @param string $type The type of expansion
|
3414 | | - NOT WANT @param integer $size The size of the text
|
3415 | | - NOT WANT @return boolean False if this inclusion would take it over the maximum, true otherwise
|
3416 | | - WANT
|
3417 | | - SO IM LIKE incrementIncludeSize WITH UR $type, $size
|
3418 | | - IZ $this->mIncludeSizes[$type] + $size > $this->mOptions->getMaxIncludeSize( $type )
|
3419 | | - I FOUND MAH false
|
3420 | | - NOWAI
|
3421 | | - $this->mIncludeSizes[$type] += $size;
|
3422 | | - I FOUND MAH true
|
3423 | | - KTHX
|
3424 | | - KTHX
|
3425 | | -
|
3426 | | - DO NOT WANT
|
3427 | | - NOT WANT Increment the expensive function count
|
3428 | | - NOT WANT
|
3429 | | - NOT WANT @return boolean False if the limit has been exceeded
|
3430 | | - WANT
|
3431 | | - SO IM LIKE incrementExpensiveFunctionCount
|
3432 | | - I HAS UR $wgExpensiveParserFunctionLimit ON UR INTERNETS
|
3433 | | - $this->mExpensiveFunctionCount++;
|
3434 | | - IZ $this->mExpensiveFunctionCount <= $wgExpensiveParserFunctionLimit
|
3435 | | - I FOUND MAH true
|
3436 | | - KTHX
|
3437 | | - I FOUND MAH false
|
3438 | | - KTHX
|
3439 | | -
|
3440 | | - DO NOT WANT
|
3441 | | - NOT WANT Strip double-underscore items like __NOGALLERY__ and __NOTOC__
|
3442 | | - NOT WANT Fills $this->mDoubleUnderscores, returns the modified text
|
3443 | | - WANT
|
3444 | | - SO IM LIKE doDoubleUnderscore WITH UR $text
|
3445 | | - IM ON UR wfProfileIn DOING __METHOD__
|
3446 | | -
|
3447 | | - BTW The position of __TOC__ needs to be recorded
|
3448 | | - I HAS mw IZ MagicWord::get( 'toc' )
|
3449 | | - IZ $mw->match( $text )
|
3450 | | - UR SPECIAL mShowToc IZ true;
|
3451 | | - UR SPECIAL mForceTocPosition IZ true;
|
3452 | | -
|
3453 | | - BTW Set a placeholder. At the end we'll fill it in with the TOC.
|
3454 | | - I HAS text IZ $mw->replace( '<!--MWTOC-->', $text, 1 )
|
3455 | | -
|
3456 | | - BTW Only keep the first one.
|
3457 | | - I HAS text IZ $mw->replace( '', $text )
|
3458 | | - KTHX
|
3459 | | -
|
3460 | | - BTW Now match and remove the rest of them
|
3461 | | - I HAS mwa IZ MagicWord::getDoubleUnderscoreArray()
|
3462 | | - UR SPECIAL mDoubleUnderscores IZ $mwa->matchAndRemove( $text );
|
3463 | | -
|
3464 | | - IZ isset( $this->mDoubleUnderscores['nogallery'] )
|
3465 | | - UR SPECIAL mOutput->mNoGallery IZ true;
|
3466 | | - KTHX
|
3467 | | - IZ isset( $this->mDoubleUnderscores['notoc'] ) && !$this->mForceTocPosition
|
3468 | | - UR SPECIAL mShowToc IZ false;
|
3469 | | - KTHX
|
3470 | | - IZ isset( $this->mDoubleUnderscores['hiddencat'] ) && $this->mTitle->getNamespace() == NS_CATEGORY
|
3471 | | - IM ON UR SPECIAL mOutput->setProperty DOING 'hiddencat', 'y'
|
3472 | | - IM ON UR SPECIAL addTrackingCategory DOING 'hidden-category-category'
|
3473 | | - KTHX
|
3474 | | - BTW (bug 8068) Allow control over whether robots index a page.
|
3475 | | - BTW
|
3476 | | - BTW FIXME (bug 14899): __INDEX__ always overrides __NOINDEX__ here! This
|
3477 | | - BTW is not desirable, the last one on the page should win.
|
3478 | | - IZ isset( $this->mDoubleUnderscores['noindex'] ) && $this->mTitle->canUseNoindex()
|
3479 | | - IM ON UR SPECIAL mOutput->setIndexPolicy DOING 'noindex'
|
3480 | | - IM ON UR SPECIAL addTrackingCategory DOING 'noindex-category'
|
3481 | | - KTHX
|
3482 | | - IZ isset( $this->mDoubleUnderscores['index'] ) && $this->mTitle->canUseNoindex()
|
3483 | | - IM ON UR SPECIAL mOutput->setIndexPolicy DOING 'index'
|
3484 | | - IM ON UR SPECIAL addTrackingCategory DOING 'index-category'
|
3485 | | - KTHX
|
3486 | | -
|
3487 | | - IM ON UR wfProfileOut DOING __METHOD__
|
3488 | | - I FOUND MAH $text
|
3489 | | - KTHX
|
3490 | | -
|
3491 | | - DO NOT WANT
|
3492 | | - NOT WANT Add a tracking category, getting the title from a system message,
|
3493 | | - NOT WANT or print a debug message if the title is invalid.
|
3494 | | - NOT WANT @param $msg String message key
|
3495 | | - NOT WANT @return Bool whether the addition was successful
|
3496 | | - WANT
|
3497 | | - SO IM LIKE addTrackingCategory WITH UR $msg
|
3498 | | - I HAS cat IZ wfMsgForContent( $msg )
|
3499 | | -
|
3500 | | - BTW Allow tracking categories to be disabled by setting them to "-"
|
3501 | | - IZ $cat === '-'
|
3502 | | - I FOUND MAH false
|
3503 | | - KTHX
|
3504 | | -
|
3505 | | - I HAS containerCategory IZ Title::makeTitleSafe( NS_CATEGORY, $cat )
|
3506 | | - IZ $containerCategory
|
3507 | | - IM ON UR SPECIAL mOutput->addCategory DOING $containerCategory->getDBkey(), $this->getDefaultSort()
|
3508 | | - I FOUND MAH true
|
3509 | | - NOWAI
|
3510 | | - IM ON UR wfDebug DOING __METHOD__.": [[MediaWiki:$msg]] is not a valid title!\n"
|
3511 | | - I FOUND MAH false
|
3512 | | - KTHX
|
3513 | | - KTHX
|
3514 | | -
|
3515 | | - DO NOT WANT
|
3516 | | - NOT WANT This function accomplishes several tasks:
|
3517 | | - NOT WANT 1) Auto-number headings if that option is enabled
|
3518 | | - NOT WANT 2) Add an [edit] link to sections for users who have enabled the option and can edit the page
|
3519 | | - NOT WANT 3) Add a Table of contents on the top for users who have enabled the option
|
3520 | | - NOT WANT 4) Auto-anchor headings
|
3521 | | - NOT WANT
|
3522 | | - NOT WANT It loops through all headlines, collects the necessary data, then splits up the
|
3523 | | - NOT WANT string and re-inserts the newly formatted headlines.
|
3524 | | - NOT WANT
|
3525 | | - NOT WANT @param string $text
|
3526 | | - NOT WANT @param string $origText Original, untouched wikitext
|
3527 | | - NOT WANT @param boolean $isMain
|
3528 | | - NOT WANT @private
|
3529 | | - WANT
|
3530 | | - SO IM LIKE formatHeadings WITH UR $text, $origText, $isMain=true
|
3531 | | - I HAS UR $wgMaxTocLevel, $wgContLang, $wgHtml5, $wgExperimentalHtmlIds ON UR INTERNETS
|
3532 | | -
|
3533 | | - I HAS doNumberHeadings IZ $this->mOptions->getNumberHeadings()
|
3534 | | - I HAS showEditLink IZ $this->mOptions->getEditSection()
|
3535 | | -
|
3536 | | - BTW Do not call quickUserCan unless necessary
|
3537 | | - IZ $showEditLink && !$this->mTitle->quickUserCan( 'edit' )
|
3538 | | - I HAS showEditLink IZ 0
|
3539 | | - KTHX
|
3540 | | -
|
3541 | | - BTW Inhibit editsection links if requested in the page
|
3542 | | - IZ isset( $this->mDoubleUnderscores['noeditsection'] ) || $this->mOptions->getIsPrintable()
|
3543 | | - I HAS showEditLink IZ 0
|
3544 | | - KTHX
|
3545 | | -
|
3546 | | - BTW Get all headlines for numbering them and adding funky stuff like [edit]
|
3547 | | - BTW links - this is for later, but we need the number of headlines right now
|
3548 | | - I HAS matches IZ EMPTY
|
3549 | | - I HAS numMatches IZ preg_match_all( '/<H(?P<level>[1-6])(?P<attrib>.*?'.'>)(?P<header>.*?)<\/H[1-6] *>/i', $text, $matches )
|
3550 | | -
|
3551 | | - BTW if there are fewer than 4 headlines in the article, do not show TOC
|
3552 | | - BTW unless it's been explicitly enabled.
|
3553 | | - enoughToc IZ $this->mShowToc &&
|
3554 | | - ( ( $numMatches >= 4 ) || $this->mForceTocPosition );
|
3555 | | -
|
3556 | | - BTW Allow user to stipulate that a page should have a "new section"
|
3557 | | - BTW link added via __NEWSECTIONLINK__
|
3558 | | - IZ isset( $this->mDoubleUnderscores['newsectionlink'] )
|
3559 | | - IM ON UR SPECIAL mOutput->setNewSection DOING true
|
3560 | | - KTHX
|
3561 | | -
|
3562 | | - BTW Allow user to remove the "new section"
|
3563 | | - BTW link via __NONEWSECTIONLINK__
|
3564 | | - IZ isset( $this->mDoubleUnderscores['nonewsectionlink'] )
|
3565 | | - IM ON UR SPECIAL mOutput->hideNewSection DOING true
|
3566 | | - KTHX
|
3567 | | -
|
3568 | | - BTW if the string __FORCETOC__ (not case-sensitive) occurs in the HTML,
|
3569 | | - BTW override above conditions and always show TOC above first header
|
3570 | | - IZ isset( $this->mDoubleUnderscores['forcetoc'] )
|
3571 | | - UR SPECIAL mShowToc IZ true;
|
3572 | | - I HAS enoughToc IZ true
|
3573 | | - KTHX
|
3574 | | -
|
3575 | | - BTW We need this to perform operations on the HTML
|
3576 | | - I HAS sk IZ $this->mOptions->getSkin()
|
3577 | | -
|
3578 | | - BTW headline counter
|
3579 | | - I HAS headlineCount IZ 0
|
3580 | | - I HAS numVisible IZ 0
|
3581 | | -
|
3582 | | - BTW Ugh .. the TOC should have neat indentation levels which can be
|
3583 | | - BTW passed to the skin functions. These are determined here
|
3584 | | - I HAS toc IZ ''
|
3585 | | - I HAS full IZ ''
|
3586 | | - I HAS head IZ EMPTY
|
3587 | | - I HAS sublevelCount IZ EMPTY
|
3588 | | - I HAS levelCount IZ EMPTY
|
3589 | | - I HAS toclevel IZ 0
|
3590 | | - I HAS level IZ 0
|
3591 | | - I HAS prevlevel IZ 0
|
3592 | | - I HAS toclevel IZ 0
|
3593 | | - I HAS prevtoclevel IZ 0
|
3594 | | - I HAS markerRegex IZ "{$this->mUniqPrefix}-h-(\d+)-" . self::MARKER_SUFFIX
|
3595 | | - I HAS baseTitleText IZ $this->mTitle->getPrefixedDBkey()
|
3596 | | - I HAS oldType IZ $this->mOutputType
|
3597 | | - IM ON UR SPECIAL setOutputType DOING self::OT_WIKI
|
3598 | | - I HAS frame IZ $this->getPreprocessor()->newFrame()
|
3599 | | - I HAS root IZ $this->preprocessToDom( $origText )
|
3600 | | - I HAS node IZ $root->getFirstChild()
|
3601 | | - I HAS byteOffset IZ 0
|
3602 | | - I HAS tocraw IZ EMPTY
|
3603 | | -
|
3604 | | - foreach ( $matches[3] as $headline ) {
|
3605 | | - I HAS isTemplate IZ false
|
3606 | | - I HAS titleText IZ false
|
3607 | | - I HAS sectionIndex IZ false
|
3608 | | - I HAS numbering IZ ''
|
3609 | | - I HAS markerMatches IZ EMPTY
|
3610 | | - IZ preg_match("/^$markerRegex/", $headline, $markerMatches )
|
3611 | | - I HAS serial IZ $markerMatches[1]
|
3612 | | - list( $titleText, $sectionIndex ) = $this->mHeadings[$serial];
|
3613 | | - I HAS isTemplate IZ ( $titleText != $baseTitleText )
|
3614 | | - I HAS headline IZ preg_replace( "/^$markerRegex/", "", $headline )
|
3615 | | - KTHX
|
3616 | | -
|
3617 | | - IZ $toclevel
|
3618 | | - I HAS prevlevel IZ $level
|
3619 | | - I HAS prevtoclevel IZ $toclevel
|
3620 | | - KTHX
|
3621 | | - I HAS level IZ $matches[1][$headlineCount]
|
3622 | | -
|
3623 | | - IZ $level > $prevlevel
|
3624 | | - BTW Increase TOC level
|
3625 | | - $toclevel++;
|
3626 | | - $sublevelCount[$toclevel] = 0;
|
3627 | | - IZ $toclevel<$wgMaxTocLevel
|
3628 | | - I HAS prevtoclevel IZ $toclevel
|
3629 | | - toc HAS MOAR $sk->tocIndent();
|
3630 | | - $numVisible++;
|
3631 | | - KTHX
|
3632 | | - ORLY $level < $prevlevel && $toclevel > 1
|
3633 | | - BTW Decrease TOC level, find level to jump to
|
3634 | | -
|
3635 | | - for ( $i = $toclevel; $i > 0; $i-- ) {
|
3636 | | - IZ $levelCount[$i] == $level
|
3637 | | - BTW Found last matching level
|
3638 | | - I HAS toclevel IZ $i
|
3639 | | - break;
|
3640 | | - ORLY $levelCount[$i] < $level
|
3641 | | - BTW Found first matching level below current level
|
3642 | | - I HAS toclevel IZ $i + 1
|
3643 | | - break;
|
3644 | | - KTHX
|
3645 | | - KTHX
|
3646 | | - IZ $i == 0
|
3647 | | - I HAS toclevel IZ 1
|
3648 | | - KTHX
|
3649 | | - IZ $toclevel<$wgMaxTocLevel
|
3650 | | - IZ $prevtoclevel < $wgMaxTocLevel
|
3651 | | - BTW Unindent only if the previous toc level was shown :p
|
3652 | | - toc HAS MOAR $sk->tocUnindent( $prevtoclevel - $toclevel );
|
3653 | | - I HAS prevtoclevel IZ $toclevel
|
3654 | | - NOWAI
|
3655 | | - toc HAS MOAR $sk->tocLineEnd();
|
3656 | | - KTHX
|
3657 | | - KTHX
|
3658 | | - NOWAI
|
3659 | | - BTW No change in level, end TOC line
|
3660 | | - IZ $toclevel<$wgMaxTocLevel
|
3661 | | - toc HAS MOAR $sk->tocLineEnd();
|
3662 | | - KTHX
|
3663 | | - KTHX
|
3664 | | -
|
3665 | | - $levelCount[$toclevel] = $level;
|
3666 | | -
|
3667 | | - BTW count number of headlines for each level
|
3668 | | - @$sublevelCount[$toclevel]++;
|
3669 | | - I HAS dot IZ 0
|
3670 | | - for( $i = 1; $i <= $toclevel; $i++ ) {
|
3671 | | - IZ !empty( $sublevelCount[$i] )
|
3672 | | - IZ $dot
|
3673 | | - numbering HAS MOAR '.';
|
3674 | | - KTHX
|
3675 | | - numbering HAS MOAR $wgContLang->formatNum( $sublevelCount[$i] );
|
3676 | | - I HAS dot IZ 1
|
3677 | | - KTHX
|
3678 | | - KTHX
|
3679 | | -
|
3680 | | - BTW The safe header is a version of the header text safe to use for links
|
3681 | | - BTW Avoid insertion of weird stuff like <math> by expanding the relevant sections
|
3682 | | - I HAS safeHeadline IZ $this->mStripState->unstripBoth( $headline )
|
3683 | | -
|
3684 | | - BTW Remove link placeholders by the link text.
|
3685 | | - BTW <!--LINK number-->
|
3686 | | - BTW turns into
|
3687 | | - BTW link text with suffix
|
3688 | | - I HAS safeHeadline IZ $this->replaceLinkHoldersText( $safeHeadline )
|
3689 | | -
|
3690 | | - BTW Strip out HTML (other than plain <sup> and <sub>: bug 8393)
|
3691 | | - tocline IZ preg_replace(
|
3692 | | - array( '#<(?!/?(sup|sub)).*?'.'>#', '#<(/?(sup|sub)).*?'.'>#' ),
|
3693 | | - array( '', '<$1>' ),
|
3694 | | - $safeHeadline
|
3695 | | - BUCKET
|
3696 | | - I HAS tocline IZ trim( $tocline )
|
3697 | | -
|
3698 | | - BTW For the anchor, strip out HTML-y stuff period
|
3699 | | - I HAS safeHeadline IZ preg_replace( '/<.*?'.'>/', '', $safeHeadline )
|
3700 | | - I HAS safeHeadline IZ preg_replace( '/[ _]+/', ' ', $safeHeadline )
|
3701 | | - I HAS safeHeadline IZ trim( $safeHeadline )
|
3702 | | -
|
3703 | | - BTW Save headline for section edit hint before it's escaped
|
3704 | | - I HAS headlineHint IZ $safeHeadline
|
3705 | | -
|
3706 | | - IZ $wgHtml5 && $wgExperimentalHtmlIds
|
3707 | | - BTW For reverse compatibility, provide an id that's
|
3708 | | - BTW HTML4-compatible, like we used to.
|
3709 | | - BTW
|
3710 | | - BTW It may be worth noting, academically, that it's possible for
|
3711 | | - BTW the legacy anchor to conflict with a non-legacy headline
|
3712 | | - BTW anchor on the page. In this case likely the "correct" thing
|
3713 | | - BTW would be to either drop the legacy anchors or make sure
|
3714 | | - BTW they're numbered first. However, this would require people
|
3715 | | - BTW to type in section names like "abc_.D7.93.D7.90.D7.A4"
|
3716 | | - BTW manually, so let's not bother worrying about it.
|
3717 | | - legacyHeadline IZ Sanitizer::escapeId( $safeHeadline,
|
3718 | | - IM ON UR array DOING 'noninitial', 'legacy' )
|
3719 | | - I HAS safeHeadline IZ Sanitizer::escapeId( $safeHeadline )
|
3720 | | -
|
3721 | | - IZ $legacyHeadline == $safeHeadline
|
3722 | | - BTW No reason to have both (in fact, we can't)
|
3723 | | - I HAS legacyHeadline IZ false
|
3724 | | - KTHX
|
3725 | | - NOWAI
|
3726 | | - I HAS legacyHeadline IZ false
|
3727 | | - safeHeadline IZ Sanitizer::escapeId( $safeHeadline,
|
3728 | | - 'noninitial' );
|
3729 | | - KTHX
|
3730 | | -
|
3731 | | - BTW HTML names must be case-insensitively unique (bug 10721). FIXME:
|
3732 | | - BTW Does this apply to Unicode characters? Because we aren't
|
3733 | | - BTW handling those here.
|
3734 | | - I HAS arrayKey IZ strtolower( $safeHeadline )
|
3735 | | - IZ $legacyHeadline === false
|
3736 | | - I HAS legacyArrayKey IZ false
|
3737 | | - NOWAI
|
3738 | | - I HAS legacyArrayKey IZ strtolower( $legacyHeadline )
|
3739 | | - KTHX
|
3740 | | -
|
3741 | | - BTW count how many in assoc. array so we can track dupes in anchors
|
3742 | | - IZ isset( $refers[$arrayKey] )
|
3743 | | - $refers[$arrayKey]++;
|
3744 | | - NOWAI
|
3745 | | - $refers[$arrayKey] = 1;
|
3746 | | - KTHX
|
3747 | | - IZ isset( $refers[$legacyArrayKey] )
|
3748 | | - $refers[$legacyArrayKey]++;
|
3749 | | - NOWAI
|
3750 | | - $refers[$legacyArrayKey] = 1;
|
3751 | | - KTHX
|
3752 | | -
|
3753 | | - BTW Don't number the heading if it is the only one (looks silly)
|
3754 | | - if ( $doNumberHeadings && count( $matches[3] ) > 1) {
|
3755 | | - BTW the two are different if the line contains a link
|
3756 | | - I HAS headline IZ $numbering . ' ' . $headline
|
3757 | | - KTHX
|
3758 | | -
|
3759 | | - BTW Create the anchor for linking from the TOC to the section
|
3760 | | - I HAS anchor IZ $safeHeadline
|
3761 | | - I HAS legacyAnchor IZ $legacyHeadline
|
3762 | | - IZ $refers[$arrayKey] > 1
|
3763 | | - anchor HAS MOAR '_' . $refers[$arrayKey];
|
3764 | | - KTHX
|
3765 | | - IZ $legacyHeadline !== false && $refers[$legacyArrayKey] > 1
|
3766 | | - legacyAnchor HAS MOAR '_' . $refers[$legacyArrayKey];
|
3767 | | - KTHX
|
3768 | | - IZ $enoughToc && ( !isset( $wgMaxTocLevel ) || $toclevel < $wgMaxTocLevel )
|
3769 | | - toc HAS MOAR $sk->tocLine( $anchor, $tocline,
|
3770 | | - $numbering, $toclevel, ( $isTemplate ? false : $sectionIndex ) );
|
3771 | | - KTHX
|
3772 | | -
|
3773 | | - BTW Add the section to the section tree
|
3774 | | - BTW Find the DOM node for this header
|
3775 | | - STEALIN UR $node && !$isTemplate
|
3776 | | - IZ $node->getName() === 'h'
|
3777 | | - I HAS bits IZ $node->splitHeading()
|
3778 | | - if ( $bits['i'] == $sectionIndex )
|
3779 | | - break;
|
3780 | | - KTHX
|
3781 | | - $byteOffset += mb_strlen( $this->mStripState->unstripBoth(
|
3782 | | - $frame->expand( $node, PPFrame::RECOVER_ORIG ) ) );
|
3783 | | - I HAS node IZ $node->getNextSibling()
|
3784 | | - KTHX
|
3785 | | - $tocraw[] = array(
|
3786 | | - 'toclevel' => $toclevel,
|
3787 | | - 'level' => $level,
|
3788 | | - 'line' => $tocline,
|
3789 | | - 'number' => $numbering,
|
3790 | | - 'index' => ( $isTemplate ? 'T-' : '' ) . $sectionIndex,
|
3791 | | - 'fromtitle' => $titleText,
|
3792 | | - 'byteoffset' => ( $isTemplate ? null : $byteOffset ),
|
3793 | | - 'anchor' => $anchor,
|
3794 | | - BUCKET
|
3795 | | -
|
3796 | | - BTW give headline the correct <h#> tag
|
3797 | | - IZ $showEditLink && $sectionIndex !== false
|
3798 | | - IZ $isTemplate
|
3799 | | - BTW Put a T flag in the section identifier, to indicate to extractSections()
|
3800 | | - BTW that sections inside <includeonly> should be counted.
|
3801 | | - I HAS editlink IZ $sk->doEditSectionLink( Title::newFromText( $titleText ), "T-$sectionIndex" )
|
3802 | | - NOWAI
|
3803 | | - I HAS editlink IZ $sk->doEditSectionLink( $this->mTitle, $sectionIndex, $headlineHint )
|
3804 | | - KTHX
|
3805 | | - NOWAI
|
3806 | | - I HAS editlink IZ ''
|
3807 | | - KTHX
|
3808 | | - $head[$headlineCount] = $sk->makeHeadline( $level,
|
3809 | | - $matches['attrib'][$headlineCount], $anchor, $headline,
|
3810 | | - $editlink, $legacyAnchor );
|
3811 | | -
|
3812 | | - $headlineCount++;
|
3813 | | - KTHX
|
3814 | | -
|
3815 | | - IM ON UR SPECIAL setOutputType DOING $oldType
|
3816 | | -
|
3817 | | - BTW Never ever show TOC if no headers
|
3818 | | - IZ $numVisible < 1
|
3819 | | - I HAS enoughToc IZ false
|
3820 | | - KTHX
|
3821 | | -
|
3822 | | - IZ $enoughToc
|
3823 | | - IZ $prevtoclevel > 0 && $prevtoclevel < $wgMaxTocLevel
|
3824 | | - toc HAS MOAR $sk->tocUnindent( $prevtoclevel - 1 );
|
3825 | | - KTHX
|
3826 | | - I HAS toc IZ $sk->tocList( $toc )
|
3827 | | - IM ON UR SPECIAL mOutput->setTOCHTML DOING $toc
|
3828 | | - KTHX
|
3829 | | -
|
3830 | | - IZ $isMain
|
3831 | | - IM ON UR SPECIAL mOutput->setSections DOING $tocraw
|
3832 | | - KTHX
|
3833 | | -
|
3834 | | - BTW split up and insert constructed headlines
|
3835 | | -
|
3836 | | - I HAS blocks IZ preg_split( '/<H[1-6].*?' . '>.*?<\/H[1-6]>/i', $text )
|
3837 | | - I HAS i IZ 0
|
3838 | | -
|
3839 | | - IM IN UR blocks ITZA block
|
3840 | | - IZ $showEditLink && $headlineCount > 0 && $i == 0 && $block !== "\n"
|
3841 | | - BTW This is the [edit] link that appears for the top block of text when
|
3842 | | - BTW section editing is enabled
|
3843 | | -
|
3844 | | - BTW Disabled because it broke block formatting
|
3845 | | - BTW For example, a bullet point in the top line
|
3846 | | - BTW $full .= $sk->editSectionLink(0);
|
3847 | | - KTHX
|
3848 | | - full HAS MOAR $block;
|
3849 | | - IZ $enoughToc && !$i && $isMain && !$this->mForceTocPosition
|
3850 | | - BTW Top anchor now in skin
|
3851 | | - I HAS full IZ $full.$toc
|
3852 | | - KTHX
|
3853 | | -
|
3854 | | - IZ !empty( $head[$i] )
|
3855 | | - full HAS MOAR $head[$i];
|
3856 | | - KTHX
|
3857 | | - $i++;
|
3858 | | - KTHX
|
3859 | | - IZ $this->mForceTocPosition
|
3860 | | - I FOUND MAH str_replace( '<!--MWTOC-->', $toc, $full )
|
3861 | | - NOWAI
|
3862 | | - I FOUND MAH $full
|
3863 | | - KTHX
|
3864 | | - KTHX
|
3865 | | -
|
3866 | | - DO NOT WANT
|
3867 | | - NOT WANT Merge $tree2 into $tree1 by replacing the section with index
|
3868 | | - NOT WANT $section in $tree1 and its descendants with the sections in $tree2.
|
3869 | | - NOT WANT Note that in the returned section tree, only the 'index' and
|
3870 | | - NOT WANT 'byteoffset' fields are guaranteed to be correct.
|
3871 | | - NOT WANT @param $tree1 array Section tree from ParserOutput::getSectons()
|
3872 | | - NOT WANT @param $tree2 array Section tree
|
3873 | | - NOT WANT @param $section int Section index
|
3874 | | - NOT WANT @param $title Title Title both section trees come from
|
3875 | | - NOT WANT @param $len2 int Length of the original wikitext for $tree2
|
3876 | | - NOT WANT @return array Merged section tree
|
3877 | | - WANT
|
3878 | | - SO IM ALWAYS LIKE mergeSectionTrees WITH UR $tree1, $tree2, $section, $title, $len2
|
3879 | | - I HAS UR $wgContLang ON UR INTERNETS
|
3880 | | - I HAS newTree IZ EMPTY
|
3881 | | - I HAS targetLevel IZ false
|
3882 | | - I HAS merged IZ false
|
3883 | | - I HAS lastLevel IZ 1
|
3884 | | - I HAS nextIndex IZ 1
|
3885 | | - I HAS numbering IZ BUCKET 0 );
|
3886 | | - I HAS titletext IZ $title->getPrefixedDBkey()
|
3887 | | - IM IN UR tree1 ITZA s
|
3888 | | - IZ $targetLevel !== false
|
3889 | | - IZ $s['level'] <= $targetLevel
|
3890 | | - BTW We've skipped enough
|
3891 | | - I HAS targetLevel IZ false
|
3892 | | - NOWAI
|
3893 | | - continue;
|
3894 | | - KTHX
|
3895 | | - KTHX
|
3896 | | - if ( $s['index'] != $section ||
|
3897 | | - $s['fromtitle'] != $titletext ) {
|
3898 | | - self::incrementNumbering( $numbering,
|
3899 | | - $s['toclevel'], $lastLevel );
|
3900 | | -
|
3901 | | - BTW Rewrite index, byteoffset and number
|
3902 | | - IZ $s['fromtitle'] == $titletext
|
3903 | | - $s['index'] = $nextIndex++;
|
3904 | | - IZ $merged
|
3905 | | - $s['byteoffset'] += $len2;
|
3906 | | - KTHX
|
3907 | | - KTHX
|
3908 | | - $s['number'] = implode( '.', array_map(
|
3909 | | - array( $wgContLang, 'formatnum' ),
|
3910 | | - $numbering ) );
|
3911 | | - I HAS lastLevel IZ $s['toclevel']
|
3912 | | - $newTree[] = $s;
|
3913 | | - NOWAI
|
3914 | | - BTW We're at $section
|
3915 | | - BTW Insert sections from $tree2 here
|
3916 | | - IM IN UR tree2 ITZA s2
|
3917 | | - BTW Rewrite the fields in $s2
|
3918 | | - BTW before inserting it
|
3919 | | - $s2['toclevel'] += $s['toclevel'] - 1;
|
3920 | | - $s2['level'] += $s['level'] - 1;
|
3921 | | - $s2['index'] = $nextIndex++;
|
3922 | | - $s2['byteoffset'] += $s['byteoffset'];
|
3923 | | -
|
3924 | | - self::incrementNumbering( $numbering,
|
3925 | | - $s2['toclevel'], $lastLevel );
|
3926 | | - $s2['number'] = implode( '.', array_map(
|
3927 | | - array( $wgContLang, 'formatnum' ),
|
3928 | | - $numbering ) );
|
3929 | | - I HAS lastLevel IZ $s2['toclevel']
|
3930 | | - $newTree[] = $s2;
|
3931 | | - KTHX
|
3932 | | - BTW Skip all descendants of $section in $tree1
|
3933 | | - I HAS targetLevel IZ $s['level']
|
3934 | | - I HAS merged IZ true
|
3935 | | - KTHX
|
3936 | | - KTHX
|
3937 | | - I FOUND MAH $newTree
|
3938 | | - KTHX
|
3939 | | -
|
3940 | | - DO NOT WANT
|
3941 | | - NOT WANT Increment a section number. Helper function for mergeSectionTrees()
|
3942 | | - NOT WANT @param $number array Array representing a section number
|
3943 | | - NOT WANT @param $level int Current TOC level (depth)
|
3944 | | - NOT WANT @param $lastLevel int Level of previous TOC entry
|
3945 | | - WANT
|
3946 | | - SO IM ALWAYS LIKE incrementNumbering WITH UR &$number, $level, $lastLevel
|
3947 | | - IZ $level > $lastLevel
|
3948 | | - $number[$level - 1] = 1;
|
3949 | | - ORLY $level < $lastLevel
|
3950 | | - foreach ( $number as $key => $unused )
|
3951 | | - IZ $key >= $level
|
3952 | | - IM ON UR unset DOING $number[$key]
|
3953 | | - KTHX
|
3954 | | - $number[$level - 1]++;
|
3955 | | - NOWAI
|
3956 | | - $number[$level - 1]++;
|
3957 | | - KTHX
|
3958 | | - KTHX
|
3959 | | -
|
3960 | | - DO NOT WANT
|
3961 | | - NOT WANT Transform wiki markup when saving a page by doing \r\n -> \n
|
3962 | | - NOT WANT conversion, substitting signatures, {{subst:}} templates, etc.
|
3963 | | - NOT WANT
|
3964 | | - NOT WANT @param string $text the text to transform
|
3965 | | - NOT WANT @param Title &$title the Title object for the current article
|
3966 | | - NOT WANT @param User $user the User object describing the current user
|
3967 | | - NOT WANT @param ParserOptions $options parsing options
|
3968 | | - NOT WANT @param bool $clearState whether to clear the parser state first
|
3969 | | - NOT WANT @return string the altered wiki markup
|
3970 | | - NOT WANT @public
|
3971 | | - WANT
|
3972 | | - SO IM LIKE preSaveTransform WITH UR $text, Title $title, $user, $options, $clearState = true
|
3973 | | - UR SPECIAL mOptions IZ $options;
|
3974 | | - IM ON UR SPECIAL setTitle DOING $title
|
3975 | | - IM ON UR SPECIAL setOutputType DOING self::OT_WIKI
|
3976 | | -
|
3977 | | - IZ $clearState
|
3978 | | - IM ON UR SPECIAL clearState
|
3979 | | - KTHX
|
3980 | | -
|
3981 | | - I HAS pairs IZ BUCKET
|
3982 | | - "\r\n" => "\n",
|
3983 | | - BUCKET
|
3984 | | - I HAS text IZ str_replace( array_keys( $pairs ), array_values( $pairs ), $text )
|
3985 | | - I HAS text IZ $this->pstPass2( $text, $user )
|
3986 | | - I HAS text IZ $this->mStripState->unstripBoth( $text )
|
3987 | | - I FOUND MAH $text
|
3988 | | - KTHX
|
3989 | | -
|
3990 | | - DO NOT WANT
|
3991 | | - NOT WANT Pre-save transform helper function
|
3992 | | - NOT WANT @private
|
3993 | | - WANT
|
3994 | | - SO IM LIKE pstPass2 WITH UR $text, $user
|
3995 | | - I HAS UR $wgContLang, $wgLocaltimezone ON UR INTERNETS
|
3996 | | -
|
3997 | | - BTW Note: This is the timestamp saved as hardcoded wikitext to
|
3998 | | - BTW the database, we use $wgContLang here in order to give
|
3999 | | - BTW everyone the same signature and use the default one rather
|
4000 | | - BTW than the one selected in each user's preferences.
|
4001 | | - BTW (see also bug 12815)
|
4002 | | - I HAS ts IZ $this->mOptions->getTimestamp()
|
4003 | | - IZ isset( $wgLocaltimezone )
|
4004 | | - I HAS tz IZ $wgLocaltimezone
|
4005 | | - NOWAI
|
4006 | | - I HAS tz IZ date_default_timezone_get()
|
4007 | | - KTHX
|
4008 | | -
|
4009 | | - I HAS unixts IZ wfTimestamp( TS_UNIX, $ts )
|
4010 | | - I HAS oldtz IZ date_default_timezone_get()
|
4011 | | - IM ON UR date_default_timezone_set DOING $tz
|
4012 | | - I HAS ts IZ date( 'YmdHis', $unixts )
|
4013 | | - I HAS tzMsg IZ date( 'T', $unixts ) # might vary on DST changeover!
|
4014 | | -
|
4015 | | - BTW Allow translation of timezones trough wiki. date() can return
|
4016 | | - BTW whatever crap the system uses, localised or not, so we cannot
|
4017 | | - BTW ship premade translations.
|
4018 | | - I HAS key IZ 'timezone-' . strtolower( trim( $tzMsg ) )
|
4019 | | - I HAS value IZ wfMsgForContent( $key )
|
4020 | | - IZ !wfEmptyMsg( $key, $value )
|
4021 | | - I HAS tzMsg IZ $value
|
4022 | | - KTHX
|
4023 | | -
|
4024 | | - IM ON UR date_default_timezone_set DOING $oldtz
|
4025 | | -
|
4026 | | - I HAS d IZ $wgContLang->timeanddate( $ts, false, false ) . " ($tzMsg)"
|
4027 | | -
|
4028 | | - BTW Variable replacement
|
4029 | | - BTW Because mOutputType is OT_WIKI, this will only process {{subst:xxx}} type tags
|
4030 | | - I HAS text IZ $this->replaceVariables( $text )
|
4031 | | -
|
4032 | | - BTW Signatures
|
4033 | | - I HAS sigText IZ $this->getUserSig( $user )
|
4034 | | - text IZ strtr( $text, array(
|
4035 | | - '~~~~~' => $d,
|
4036 | | - '~~~~' => "$sigText $d",
|
4037 | | - '~~~' => $sigText
|
4038 | | - ) );
|
4039 | | -
|
4040 | | - BTW Context links: [[|name]] and [[name (context)|]]
|
4041 | | - I HAS UR $wgLegalTitleChars ON UR INTERNETS
|
4042 | | - I HAS tc IZ "[$wgLegalTitleChars]"
|
4043 | | - I HAS nc IZ '[ _0-9A-Za-z\x80-\xff-]' # Namespaces can use non-ascii!
|
4044 | | -
|
4045 | | - I HAS p1 IZ "/\[\[(:?$nc+:|:|)($tc+?)( \\($tc+\\))\\|]]/" # [[ns:page (context)|]]
|
4046 | | - I HAS p4 IZ "/\[\[(:?$nc+:|:|)($tc+?)(($tc+))\\|]]/" # [[ns:page(context)|]]
|
4047 | | - I HAS p3 IZ "/\[\[(:?$nc+:|:|)($tc+?)( \\($tc+\\)|)(, $tc+|)\\|]]/" # [[ns:page (context), context|]]
|
4048 | | - I HAS p2 IZ "/\[\[\\|($tc+)]]/" # [[|page]]
|
4049 | | -
|
4050 | | - BTW try $p1 first, to turn "[[A, B (C)|]]" into "[[A, B (C)|A, B]]"
|
4051 | | - I HAS text IZ preg_replace( $p1, '[[\\1\\2\\3|\\2]]', $text )
|
4052 | | - I HAS text IZ preg_replace( $p4, '[[\\1\\2\\3|\\2]]', $text )
|
4053 | | - I HAS text IZ preg_replace( $p3, '[[\\1\\2\\3\\4|\\2]]', $text )
|
4054 | | -
|
4055 | | - I HAS t IZ $this->mTitle->getText()
|
4056 | | - I HAS m IZ EMPTY
|
4057 | | - IZ preg_match( "/^($nc+:|)$tc+?( \\($tc+\\))$/", $t, $m )
|
4058 | | - I HAS text IZ preg_replace( $p2, "[[$m[1]\\1$m[2]|\\1]]", $text )
|
4059 | | - ORLY preg_match( "/^($nc+:|)$tc+?(, $tc+|)$/", $t, $m ) && "$m[1]$m[2]" != ''
|
4060 | | - I HAS text IZ preg_replace( $p2, "[[$m[1]\\1$m[2]|\\1]]", $text )
|
4061 | | - NOWAI
|
4062 | | - BTW if there's no context, don't bother duplicating the title
|
4063 | | - I HAS text IZ preg_replace( $p2, '[[\\1]]', $text )
|
4064 | | - KTHX
|
4065 | | -
|
4066 | | - BTW Trim trailing whitespace
|
4067 | | - I HAS text IZ rtrim( $text )
|
4068 | | -
|
4069 | | - I FOUND MAH $text
|
4070 | | - KTHX
|
4071 | | -
|
4072 | | - DO NOT WANT
|
4073 | | - NOT WANT Fetch the user's signature text, if any, and normalize to
|
4074 | | - NOT WANT validated, ready-to-insert wikitext.
|
4075 | | - NOT WANT If you have pre-fetched the nickname or the fancySig option, you can
|
4076 | | - NOT WANT specify them here to save a database query.
|
4077 | | - NOT WANT
|
4078 | | - NOT WANT @param User $user
|
4079 | | - NOT WANT @return string
|
4080 | | - WANT
|
4081 | | - SO IM LIKE getUserSig WITH UR &$user, $nickname = false, $fancySig = null
|
4082 | | - I HAS UR $wgMaxSigChars ON UR INTERNETS
|
4083 | | -
|
4084 | | - I HAS username IZ $user->getName()
|
4085 | | -
|
4086 | | - BTW If not given, retrieve from the user object.
|
4087 | | - if ( $nickname === false )
|
4088 | | - I HAS nickname IZ $user->getOption( 'nickname' )
|
4089 | | -
|
4090 | | - IZ is_null( $fancySig )
|
4091 | | - I HAS fancySig IZ $user->getBoolOption( 'fancysig' )
|
4092 | | - KTHX
|
4093 | | -
|
4094 | | - I HAS nickname IZ $nickname == null ? $username : $nickname
|
4095 | | -
|
4096 | | - IZ mb_strlen( $nickname ) > $wgMaxSigChars
|
4097 | | - I HAS nickname IZ $username
|
4098 | | - IM ON UR wfDebug DOING __METHOD__ . ": $username has overlong signature.\n"
|
4099 | | - ORLY $fancySig !== false
|
4100 | | - BTW Sig. might contain markup; validate this
|
4101 | | - IZ $this->validateSig( $nickname ) !== false
|
4102 | | - BTW Validated; clean up (if needed) and return it
|
4103 | | - I FOUND MAH $this->cleanSig( $nickname, true )
|
4104 | | - NOWAI
|
4105 | | - BTW Failed to validate; fall back to the default
|
4106 | | - I HAS nickname IZ $username
|
4107 | | - IM ON UR wfDebug DOING __METHOD__.": $username has bad XML tags in signature.\n"
|
4108 | | - KTHX
|
4109 | | - KTHX
|
4110 | | -
|
4111 | | - BTW Make sure nickname doesnt get a sig in a sig
|
4112 | | - I HAS nickname IZ $this->cleanSigInSig( $nickname )
|
4113 | | -
|
4114 | | - BTW If we're still here, make it a link to the user page
|
4115 | | - I HAS userText IZ wfEscapeWikiText( $username )
|
4116 | | - I HAS nickText IZ wfEscapeWikiText( $nickname )
|
4117 | | - if ( $user->isAnon() ) {
|
4118 | | - I FOUND MAH wfMsgExt( 'signature-anon', array( 'content', 'parsemag' ), $userText, $nickText )
|
4119 | | - NOWAI
|
4120 | | - I FOUND MAH wfMsgExt( 'signature', array( 'content', 'parsemag' ), $userText, $nickText )
|
4121 | | - KTHX
|
4122 | | - KTHX
|
4123 | | -
|
4124 | | - DO NOT WANT
|
4125 | | - NOT WANT Check that the user's signature contains no bad XML
|
4126 | | - NOT WANT
|
4127 | | - NOT WANT @param string $text
|
4128 | | - NOT WANT @return mixed An expanded string, or false if invalid.
|
4129 | | - WANT
|
4130 | | - SO IM LIKE validateSig WITH UR $text
|
4131 | | - IM ON UR return DOING Xml::isWellFormedXmlFragment( $text ) ? $text : false
|
4132 | | - KTHX
|
4133 | | -
|
4134 | | - DO NOT WANT
|
4135 | | - NOT WANT Clean up signature text
|
4136 | | - NOT WANT
|
4137 | | - NOT WANT 1) Strip ~~~, ~~~~ and ~~~~~ out of signatures @see cleanSigInSig
|
4138 | | - NOT WANT 2) Substitute all transclusions
|
4139 | | - NOT WANT
|
4140 | | - NOT WANT @param string $text
|
4141 | | - NOT WANT @param $parsing Whether we're cleaning (preferences save) or parsing
|
4142 | | - NOT WANT @return string Signature text
|
4143 | | - WANT
|
4144 | | - SO IM LIKE cleanSig WITH UR $text, $parsing = false
|
4145 | | - IZ !$parsing
|
4146 | | - I HAS UR $wgTitle ON UR INTERNETS
|
4147 | | - IM ON UR SPECIAL clearState
|
4148 | | - IM ON UR SPECIAL setTitle DOING $wgTitle
|
4149 | | - UR SPECIAL mOptions IZ new ParserOptions;
|
4150 | | - UR SPECIAL setOutputType IZ self::OT_PREPROCESS;
|
4151 | | - KTHX
|
4152 | | -
|
4153 | | - BTW Option to disable this feature
|
4154 | | - IZ !$this->mOptions->getCleanSignatures()
|
4155 | | - I FOUND MAH $text
|
4156 | | - KTHX
|
4157 | | -
|
4158 | | - BTW FIXME: regex doesn't respect extension tags or nowiki
|
4159 | | - BTW => Move this logic to braceSubstitution()
|
4160 | | - I HAS substWord IZ MagicWord::get( 'subst' )
|
4161 | | - I HAS substRegex IZ '/\{\{(?!(?:' . $substWord->getBaseRegex() . '))/x' . $substWord->getRegexCase()
|
4162 | | - I HAS substText IZ '{{' . $substWord->getSynonym( 0 )
|
4163 | | -
|
4164 | | - I HAS text IZ preg_replace( $substRegex, $substText, $text )
|
4165 | | - I HAS text IZ $this->cleanSigInSig( $text )
|
4166 | | - I HAS dom IZ $this->preprocessToDom( $text )
|
4167 | | - I HAS frame IZ $this->getPreprocessor()->newFrame()
|
4168 | | - I HAS text IZ $frame->expand( $dom )
|
4169 | | -
|
4170 | | - IZ !$parsing
|
4171 | | - I HAS text IZ $this->mStripState->unstripBoth( $text )
|
4172 | | - KTHX
|
4173 | | -
|
4174 | | - I FOUND MAH $text
|
4175 | | - KTHX
|
4176 | | -
|
4177 | | - DO NOT WANT
|
4178 | | - NOT WANT Strip ~~~, ~~~~ and ~~~~~ out of signatures
|
4179 | | - NOT WANT @param string $text
|
4180 | | - NOT WANT @return string Signature text with /~{3,5}/ removed
|
4181 | | - WANT
|
4182 | | - SO IM LIKE cleanSigInSig WITH UR $text
|
4183 | | - I HAS text IZ preg_replace( '/~{3,5}/', '', $text )
|
4184 | | - I FOUND MAH $text
|
4185 | | - KTHX
|
4186 | | -
|
4187 | | - DO NOT WANT
|
4188 | | - NOT WANT Set up some variables which are usually set up in parse()
|
4189 | | - NOT WANT so that an external function can call some class members with confidence
|
4190 | | - NOT WANT @public
|
4191 | | - WANT
|
4192 | | - SO IM LIKE startExternalParse WITH UR &$title, $options, $outputType, $clearState = true
|
4193 | | - IM ON UR SPECIAL setTitle DOING $title
|
4194 | | - UR SPECIAL mOptions IZ $options;
|
4195 | | - IM ON UR SPECIAL setOutputType DOING $outputType
|
4196 | | - IZ $clearState
|
4197 | | - IM ON UR SPECIAL clearState
|
4198 | | - KTHX
|
4199 | | - KTHX
|
4200 | | -
|
4201 | | - DO NOT WANT
|
4202 | | - NOT WANT Wrapper for preprocess()
|
4203 | | - NOT WANT
|
4204 | | - NOT WANT @param string $text the text to preprocess
|
4205 | | - NOT WANT @param ParserOptions $options options
|
4206 | | - NOT WANT @return string
|
4207 | | - NOT WANT @public
|
4208 | | - WANT
|
4209 | | - SO IM LIKE transformMsg WITH UR $text, $options
|
4210 | | - I HAS UR $wgTitle ON UR INTERNETS
|
4211 | | - static $executing = false;
|
4212 | | -
|
4213 | | - BTW Guard against infinite recursion
|
4214 | | - IZ $executing
|
4215 | | - I FOUND MAH $text
|
4216 | | - KTHX
|
4217 | | - I HAS executing IZ true
|
4218 | | -
|
4219 | | - IM ON UR wfProfileIn DOING __METHOD__
|
4220 | | - I HAS text IZ $this->preprocess( $text, $wgTitle, $options )
|
4221 | | -
|
4222 | | - I HAS executing IZ false
|
4223 | | - IM ON UR wfProfileOut DOING __METHOD__
|
4224 | | - I FOUND MAH $text
|
4225 | | - KTHX
|
4226 | | -
|
4227 | | - DO NOT WANT
|
4228 | | - NOT WANT Create an HTML-style tag, e.g. <yourtag>special text</yourtag>
|
4229 | | - NOT WANT The callback should have the following form:
|
4230 | | - NOT WANT function myParserHook( $text, $params, &$parser ) { ... }
|
4231 | | - NOT WANT
|
4232 | | - NOT WANT Transform and return $text. Use $parser for any required context, e.g. use
|
4233 | | - NOT WANT $parser->getTitle() and $parser->getOptions() not $wgTitle or $wgOut->mParserOptions
|
4234 | | - NOT WANT
|
4235 | | - NOT WANT @public
|
4236 | | - NOT WANT
|
4237 | | - NOT WANT @param mixed $tag The tag to use, e.g. 'hook' for <hook>
|
4238 | | - NOT WANT @param mixed $callback The callback function (and object) to use for the tag
|
4239 | | - NOT WANT
|
4240 | | - NOT WANT @return The old value of the mTagHooks array associated with the hook
|
4241 | | - WANT
|
4242 | | - SO IM LIKE setHook WITH UR $tag, $callback
|
4243 | | - I HAS tag IZ strtolower( $tag )
|
4244 | | - I HAS oldVal IZ isset( $this->mTagHooks[$tag] ) ? $this->mTagHooks[$tag] : null
|
4245 | | - $this->mTagHooks[$tag] = $callback;
|
4246 | | - IZ !in_array( $tag, $this->mStripList )
|
4247 | | - $this->mStripList[] = $tag;
|
4248 | | - KTHX
|
4249 | | -
|
4250 | | - I FOUND MAH $oldVal
|
4251 | | - KTHX
|
4252 | | -
|
4253 | | - SO IM LIKE setTransparentTagHook WITH UR $tag, $callback
|
4254 | | - I HAS tag IZ strtolower( $tag )
|
4255 | | - I HAS oldVal IZ isset( $this->mTransparentTagHooks[$tag] ) ? $this->mTransparentTagHooks[$tag] : null
|
4256 | | - $this->mTransparentTagHooks[$tag] = $callback;
|
4257 | | -
|
4258 | | - I FOUND MAH $oldVal
|
4259 | | - KTHX
|
4260 | | -
|
4261 | | - DO NOT WANT
|
4262 | | - NOT WANT Remove all tag hooks
|
4263 | | - WANT
|
4264 | | - SO IM LIKE clearTagHooks
|
4265 | | - UR SPECIAL mTagHooks IZ EMPTY;
|
4266 | | - UR SPECIAL mStripList IZ $this->mDefaultStripList;
|
4267 | | - KTHX
|
4268 | | -
|
4269 | | - DO NOT WANT
|
4270 | | - NOT WANT Create a function, e.g. {{sum:1|2|3}}
|
4271 | | - NOT WANT The callback function should have the form:
|
4272 | | - NOT WANT function myParserFunction( &$parser, $arg1, $arg2, $arg3 ) { ... }
|
4273 | | - NOT WANT
|
4274 | | - NOT WANT Or with SFH_OBJECT_ARGS:
|
4275 | | - NOT WANT function myParserFunction( $parser, $frame, $args ) { ... }
|
4276 | | - NOT WANT
|
4277 | | - NOT WANT The callback may either return the text result of the function, or an array with the text
|
4278 | | - NOT WANT in element 0, and a number of flags in the other elements. The names of the flags are
|
4279 | | - NOT WANT specified in the keys. Valid flags are:
|
4280 | | - NOT WANT found The text returned is valid, stop processing the template. This
|
4281 | | - NOT WANT is on by default.
|
4282 | | - NOT WANT nowiki Wiki markup in the return value should be escaped
|
4283 | | - NOT WANT isHTML The returned text is HTML, armour it against wikitext transformation
|
4284 | | - NOT WANT
|
4285 | | - NOT WANT @public
|
4286 | | - NOT WANT
|
4287 | | - NOT WANT @param string $id The magic word ID
|
4288 | | - NOT WANT @param mixed $callback The callback function (and object) to use
|
4289 | | - NOT WANT @param integer $flags a combination of the following flags:
|
4290 | | - NOT WANT SFH_NO_HASH No leading hash, i.e. {{plural:...}} instead of {{#if:...}}
|
4291 | | - NOT WANT
|
4292 | | - NOT WANT SFH_OBJECT_ARGS Pass the template arguments as PPNode objects instead of text. This
|
4293 | | - NOT WANT allows for conditional expansion of the parse tree, allowing you to eliminate dead
|
4294 | | - NOT WANT branches and thus speed up parsing. It is also possible to analyse the parse tree of
|
4295 | | - NOT WANT the arguments, and to control the way they are expanded.
|
4296 | | - NOT WANT
|
4297 | | - NOT WANT The $frame parameter is a PPFrame. This can be used to produce expanded text from the
|
4298 | | - NOT WANT arguments, for instance:
|
4299 | | - NOT WANT $text = isset( $args[0] ) ? $frame->expand( $args[0] ) : '';
|
4300 | | - NOT WANT
|
4301 | | - NOT WANT For technical reasons, $args[0] is pre-expanded and will be a string. This may change in
|
4302 | | - NOT WANT future versions. Please call $frame->expand() on it anyway so that your code keeps
|
4303 | | - NOT WANT working if/when this is changed.
|
4304 | | - NOT WANT
|
4305 | | - NOT WANT If you want whitespace to be trimmed from $args, you need to do it yourself, post-
|
4306 | | - NOT WANT expansion.
|
4307 | | - NOT WANT
|
4308 | | - NOT WANT Please read the documentation in includes/parser/Preprocessor.php for more information
|
4309 | | - NOT WANT about the methods available in PPFrame and PPNode.
|
4310 | | - NOT WANT
|
4311 | | - NOT WANT @return The old callback function for this name, if any
|
4312 | | - WANT
|
4313 | | - SO IM LIKE setFunctionHook WITH UR $id, $callback, $flags = 0
|
4314 | | - I HAS UR $wgContLang ON UR INTERNETS
|
4315 | | -
|
4316 | | - I HAS oldVal IZ isset( $this->mFunctionHooks[$id] ) ? $this->mFunctionHooks[$id][0] : null
|
4317 | | - $this->mFunctionHooks[$id] = array( $callback, $flags );
|
4318 | | -
|
4319 | | - BTW Add to function cache
|
4320 | | - I HAS mw IZ MagicWord::get( $id )
|
4321 | | - if ( !$mw )
|
4322 | | - throw new MWException( __METHOD__.'() expecting a magic word identifier.' );
|
4323 | | -
|
4324 | | - I HAS synonyms IZ $mw->getSynonyms()
|
4325 | | - I HAS sensitive IZ intval( $mw->isCaseSensitive() )
|
4326 | | -
|
4327 | | - IM IN UR synonyms ITZA syn
|
4328 | | - BTW Case
|
4329 | | - IZ !$sensitive
|
4330 | | - I HAS syn IZ $wgContLang->lc( $syn )
|
4331 | | - KTHX
|
4332 | | - BTW Add leading hash
|
4333 | | - IZ !( $flags & SFH_NO_HASH )
|
4334 | | - I HAS syn IZ '#' . $syn
|
4335 | | - KTHX
|
4336 | | - BTW Remove trailing colon
|
4337 | | - IZ substr( $syn, -1, 1 ) === ':'
|
4338 | | - I HAS syn IZ substr( $syn, 0, -1 )
|
4339 | | - KTHX
|
4340 | | - $this->mFunctionSynonyms[$sensitive][$syn] = $id;
|
4341 | | - KTHX
|
4342 | | - I FOUND MAH $oldVal
|
4343 | | - KTHX
|
4344 | | -
|
4345 | | - DO NOT WANT
|
4346 | | - NOT WANT Get all registered function hook identifiers
|
4347 | | - NOT WANT
|
4348 | | - NOT WANT @return array
|
4349 | | - WANT
|
4350 | | - SO IM LIKE getFunctionHooks
|
4351 | | - I FOUND MAH array_keys( $this->mFunctionHooks )
|
4352 | | - KTHX
|
4353 | | -
|
4354 | | - DO NOT WANT
|
4355 | | - NOT WANT Create a tag function, e.g. <test>some stuff</test>.
|
4356 | | - NOT WANT Unlike tag hooks, tag functions are parsed at preprocessor level.
|
4357 | | - NOT WANT Unlike parser functions, their content is not preprocessed.
|
4358 | | - WANT
|
4359 | | - SO IM LIKE setFunctionTagHook WITH UR $tag, $callback, $flags
|
4360 | | - I HAS tag IZ strtolower( $tag )
|
4361 | | - old IZ isset( $this->mFunctionTagHooks[$tag] ) ?
|
4362 | | - $this->mFunctionTagHooks[$tag] : null;
|
4363 | | - $this->mFunctionTagHooks[$tag] = array( $callback, $flags );
|
4364 | | -
|
4365 | | - IZ !in_array( $tag, $this->mStripList )
|
4366 | | - $this->mStripList[] = $tag;
|
4367 | | - KTHX
|
4368 | | -
|
4369 | | - I FOUND MAH $old
|
4370 | | - KTHX
|
4371 | | -
|
4372 | | - DO NOT WANT
|
4373 | | - NOT WANT FIXME: update documentation. makeLinkObj() is deprecated.
|
4374 | | - NOT WANT Replace <!--LINK--> link placeholders with actual links, in the buffer
|
4375 | | - NOT WANT Placeholders created in Skin::makeLinkObj()
|
4376 | | - NOT WANT Returns an array of link CSS classes, indexed by PDBK.
|
4377 | | - WANT
|
4378 | | - SO IM LIKE replaceLinkHolders WITH UR &$text, $options = 0
|
4379 | | - I FOUND MAH $this->mLinkHolders->replace( $text )
|
4380 | | - KTHX
|
4381 | | -
|
4382 | | - DO NOT WANT
|
4383 | | - NOT WANT Replace <!--LINK--> link placeholders with plain text of links
|
4384 | | - NOT WANT (not HTML-formatted).
|
4385 | | - NOT WANT @param string $text
|
4386 | | - NOT WANT @return string
|
4387 | | - WANT
|
4388 | | - SO IM LIKE replaceLinkHoldersText WITH UR $text
|
4389 | | - I FOUND MAH $this->mLinkHolders->replaceText( $text )
|
4390 | | - KTHX
|
4391 | | -
|
4392 | | - DO NOT WANT
|
4393 | | - NOT WANT Renders an image gallery from a text with one line per image.
|
4394 | | - NOT WANT text labels may be given by using |-style alternative text. E.g.
|
4395 | | - NOT WANT Image:one.jpg|The number "1"
|
4396 | | - NOT WANT Image:tree.jpg|A tree
|
4397 | | - NOT WANT given as text will return the HTML of a gallery with two images,
|
4398 | | - NOT WANT labeled 'The number "1"' and
|
4399 | | - NOT WANT 'A tree'.
|
4400 | | - WANT
|
4401 | | - SO IM LIKE renderImageGallery WITH UR $text, $params
|
4402 | | - I HAS ig IZ new ImageGallery()
|
4403 | | - $ig->setContextTitle( $this->mTitle );
|
4404 | | - $ig->setShowBytes( false );
|
4405 | | - $ig->setShowFilename( false );
|
4406 | | - $ig->setParser( $this );
|
4407 | | - $ig->setHideBadImages();
|
4408 | | - $ig->setAttributes( Sanitizer::validateTagAttributes( $params, 'table' ) );
|
4409 | | - $ig->useSkin( $this->mOptions->getSkin() );
|
4410 | | - $ig->mRevisionId = $this->mRevisionId;
|
4411 | | -
|
4412 | | - IZ isset( $params['showfilename'] )
|
4413 | | - $ig->setShowFilename( true );
|
4414 | | - NOWAI
|
4415 | | - $ig->setShowFilename( false );
|
4416 | | - KTHX
|
4417 | | - IZ isset( $params['caption'] )
|
4418 | | - I HAS caption IZ $params['caption']
|
4419 | | - I HAS caption IZ htmlspecialchars( $caption )
|
4420 | | - I HAS caption IZ $this->replaceInternalLinks( $caption )
|
4421 | | - $ig->setCaptionHtml( $caption );
|
4422 | | - KTHX
|
4423 | | - IZ isset( $params['perrow'] )
|
4424 | | - $ig->setPerRow( $params['perrow'] );
|
4425 | | - KTHX
|
4426 | | - IZ isset( $params['widths'] )
|
4427 | | - $ig->setWidths( $params['widths'] );
|
4428 | | - KTHX
|
4429 | | - IZ isset( $params['heights'] )
|
4430 | | - $ig->setHeights( $params['heights'] );
|
4431 | | - KTHX
|
4432 | | -
|
4433 | | - IM ON UR wfRunHooks DOING 'BeforeParserrenderImageGallery', array( &$this, &$ig )
|
4434 | | -
|
4435 | | - I HAS lines IZ StringUtils::explode( "\n", $text )
|
4436 | | - IM IN UR lines ITZA line
|
4437 | | - BTW match lines like these:
|
4438 | | - BTW Image:someimage.jpg|This is some image
|
4439 | | - I HAS matches IZ EMPTY
|
4440 | | - IM ON UR preg_match DOING "/^([^|]+)(\\|(.*))?$/", $line, $matches
|
4441 | | - BTW Skip empty lines
|
4442 | | - IZ count( $matches ) == 0
|
4443 | | - continue;
|
4444 | | - KTHX
|
4445 | | -
|
4446 | | - IZ strpos( $matches[0], '%' ) !== false
|
4447 | | - $matches[1] = urldecode( $matches[1] );
|
4448 | | - KTHX
|
4449 | | - I HAS tp IZ Title::newFromText( $matches[1] )
|
4450 | | - $nt =& $tp;
|
4451 | | - IZ is_null( $nt )
|
4452 | | - BTW Bogus title. Ignore these so we don't bomb out later.
|
4453 | | - continue;
|
4454 | | - KTHX
|
4455 | | - IZ isset( $matches[3] )
|
4456 | | - I HAS label IZ $matches[3]
|
4457 | | - NOWAI
|
4458 | | - I HAS label IZ ''
|
4459 | | - KTHX
|
4460 | | -
|
4461 | | - I HAS html IZ $this->recursiveTagParse( trim( $label ) )
|
4462 | | -
|
4463 | | - $ig->add( $nt, $html );
|
4464 | | -
|
4465 | | - BTW Only add real images (bug #5586)
|
4466 | | - IZ $nt->getNamespace() == NS_FILE
|
4467 | | - IM ON UR SPECIAL mOutput->addImage DOING $nt->getDBkey()
|
4468 | | - KTHX
|
4469 | | - KTHX
|
4470 | | - I FOUND MAH $ig->toHTML()
|
4471 | | - KTHX
|
4472 | | -
|
4473 | | - SO IM LIKE getImageParams WITH UR $handler
|
4474 | | - IZ $handler
|
4475 | | - I HAS handlerClass IZ get_class( $handler )
|
4476 | | - NOWAI
|
4477 | | - I HAS handlerClass IZ ''
|
4478 | | - KTHX
|
4479 | | - IZ !isset( $this->mImageParams[$handlerClass] )
|
4480 | | - BTW Initialise static lists
|
4481 | | - static $internalParamNames = array(
|
4482 | | - 'horizAlign' => array( 'left', 'right', 'center', 'none' ),
|
4483 | | - 'vertAlign' => array( 'baseline', 'sub', 'super', 'top', 'text-top', 'middle',
|
4484 | | - 'bottom', 'text-bottom' ),
|
4485 | | - 'frame' => array( 'thumbnail', 'manualthumb', 'framed', 'frameless',
|
4486 | | - 'upright', 'border', 'link', 'alt' ),
|
4487 | | - BUCKET
|
4488 | | - static $internalParamMap;
|
4489 | | - IZ !$internalParamMap
|
4490 | | - I HAS internalParamMap IZ EMPTY
|
4491 | | - IM IN UR internalParamNames ITZA type => $names
|
4492 | | - IM IN UR names ITZA name
|
4493 | | - I HAS magicName IZ str_replace( '-', '_', "img_$name" )
|
4494 | | - $internalParamMap[$magicName] = array( $type, $name );
|
4495 | | - KTHX
|
4496 | | - KTHX
|
4497 | | - KTHX
|
4498 | | -
|
4499 | | - BTW Add handler params
|
4500 | | - I HAS paramMap IZ $internalParamMap
|
4501 | | - IZ $handler
|
4502 | | - I HAS handlerParamMap IZ $handler->getParamMap()
|
4503 | | - IM IN UR handlerParamMap ITZA magic => $paramName
|
4504 | | - $paramMap[$magic] = array( 'handler', $paramName );
|
4505 | | - KTHX
|
4506 | | - KTHX
|
4507 | | - $this->mImageParams[$handlerClass] = $paramMap;
|
4508 | | - $this->mImageParamsMagicArray[$handlerClass] = new MagicWordArray( array_keys( $paramMap ) );
|
4509 | | - KTHX
|
4510 | | - I FOUND MAH array( $this->mImageParams[$handlerClass], $this->mImageParamsMagicArray[$handlerClass] )
|
4511 | | - KTHX
|
4512 | | -
|
4513 | | - DO NOT WANT
|
4514 | | - NOT WANT Parse image options text and use it to make an image
|
4515 | | - NOT WANT @param Title $title
|
4516 | | - NOT WANT @param string $options
|
4517 | | - NOT WANT @param LinkHolderArray $holders
|
4518 | | - WANT
|
4519 | | - SO IM LIKE makeImage WITH UR $title, $options, $holders = false
|
4520 | | - BTW Check if the options text is of the form "options|alt text"
|
4521 | | - BTW Options are:
|
4522 | | - BTW * thumbnail make a thumbnail with enlarge-icon and caption, alignment depends on lang
|
4523 | | - BTW * left no resizing, just left align. label is used for alt= only
|
4524 | | - BTW * right same, but right aligned
|
4525 | | - BTW * none same, but not aligned
|
4526 | | - BTW * ___px scale to ___ pixels width, no aligning. e.g. use in taxobox
|
4527 | | - BTW * center center the image
|
4528 | | - BTW * frame Keep original image size, no magnify-button.
|
4529 | | - BTW * framed Same as "frame"
|
4530 | | - BTW * frameless like 'thumb' but without a frame. Keeps user preferences for width
|
4531 | | - BTW * upright reduce width for upright images, rounded to full __0 px
|
4532 | | - BTW * border draw a 1px border around the image
|
4533 | | - BTW * alt Text for HTML alt attribute (defaults to empty)
|
4534 | | - BTW * link Set the target of the image link. Can be external, interwiki, or local
|
4535 | | - BTW vertical-align values (no % or length right now):
|
4536 | | - BTW * baseline
|
4537 | | - BTW * sub
|
4538 | | - BTW * super
|
4539 | | - BTW * top
|
4540 | | - BTW * text-top
|
4541 | | - BTW * middle
|
4542 | | - BTW * bottom
|
4543 | | - BTW * text-bottom
|
4544 | | -
|
4545 | | - I HAS parts IZ StringUtils::explode( "|", $options )
|
4546 | | - I HAS sk IZ $this->mOptions->getSkin()
|
4547 | | -
|
4548 | | - BTW Give extensions a chance to select the file revision for us
|
4549 | | - I HAS skip IZ $time = $descQuery = false
|
4550 | | - IM ON UR wfRunHooks DOING 'BeforeParserMakeImageLinkObj', array( &$this, &$title, &$skip, &$time, &$descQuery )
|
4551 | | -
|
4552 | | - IZ $skip
|
4553 | | - I FOUND MAH $sk->link( $title )
|
4554 | | - KTHX
|
4555 | | -
|
4556 | | - BTW Get the file
|
4557 | | - I HAS imagename IZ $title->getDBkey()
|
4558 | | - I HAS file IZ wfFindFile( $title, array( 'time' => $time ) )
|
4559 | | - BTW Get parameter map
|
4560 | | - I HAS handler IZ $file ? $file->getHandler() : false
|
4561 | | -
|
4562 | | - IM ON UR list DOING $paramMap, $mwArray ) = $this->getImageParams( $handler
|
4563 | | -
|
4564 | | - BTW Process the input parameters
|
4565 | | - I HAS caption IZ ''
|
4566 | | - I HAS params IZ BUCKET 'frame' => array(), 'handler' => array(),
|
4567 | | - 'horizAlign' => array(), 'vertAlign' => array() );
|
4568 | | - IM IN UR parts ITZA part
|
4569 | | - I HAS part IZ trim( $part )
|
4570 | | - IM ON UR list DOING $magicName, $value ) = $mwArray->matchVariableStartToEnd( $part
|
4571 | | - I HAS validated IZ false
|
4572 | | - IZ isset( $paramMap[$magicName] )
|
4573 | | - list( $type, $paramName ) = $paramMap[$magicName];
|
4574 | | -
|
4575 | | - BTW Special case; width and height come in one variable together
|
4576 | | - IZ $type === 'handler' && $paramName === 'width'
|
4577 | | - I HAS m IZ EMPTY
|
4578 | | - BTW (bug 13500) In both cases (width/height and width only),
|
4579 | | - BTW permit trailing "px" for backward compatibility.
|
4580 | | - IZ preg_match( '/^([0-9]*)x([0-9]*)\s*(?:px)?\s*$/', $value, $m )
|
4581 | | - I HAS width IZ intval( $m[1] )
|
4582 | | - I HAS height IZ intval( $m[2] )
|
4583 | | - IZ $handler->validateParam( 'width', $width )
|
4584 | | - $params[$type]['width'] = $width;
|
4585 | | - I HAS validated IZ true
|
4586 | | - KTHX
|
4587 | | - IZ $handler->validateParam( 'height', $height )
|
4588 | | - $params[$type]['height'] = $height;
|
4589 | | - I HAS validated IZ true
|
4590 | | - KTHX
|
4591 | | - ORLY preg_match( '/^[0-9]*\s*(?:px)?\s*$/', $value )
|
4592 | | - I HAS width IZ intval( $value )
|
4593 | | - IZ $handler->validateParam( 'width', $width )
|
4594 | | - $params[$type]['width'] = $width;
|
4595 | | - I HAS validated IZ true
|
4596 | | - KTHX
|
4597 | | - KTHX # else no validation -- bug 13436
|
4598 | | - NOWAI
|
4599 | | - IZ $type === 'handler'
|
4600 | | - BTW Validate handler parameter
|
4601 | | - I HAS validated IZ $handler->validateParam( $paramName, $value )
|
4602 | | - NOWAI
|
4603 | | - BTW Validate internal parameters
|
4604 | | - switch( $paramName ) {
|
4605 | | - case 'manualthumb':
|
4606 | | - case 'alt':
|
4607 | | - BTW @todo Fixme: possibly check validity here for
|
4608 | | - BTW manualthumb? downstream behavior seems odd with
|
4609 | | - BTW missing manual thumbs.
|
4610 | | - I HAS validated IZ true
|
4611 | | - I HAS value IZ $this->stripAltText( $value, $holders )
|
4612 | | - break;
|
4613 | | - case 'link':
|
4614 | | - I HAS chars IZ self::EXT_LINK_URL_CLASS
|
4615 | | - I HAS prots IZ $this->mUrlProtocols
|
4616 | | - IZ $value === ''
|
4617 | | - I HAS paramName IZ 'no-link'
|
4618 | | - I HAS value IZ true
|
4619 | | - I HAS validated IZ true
|
4620 | | - ORLY preg_match( "/^$prots/", $value )
|
4621 | | - IZ preg_match( "/^($prots)$chars+$/", $value, $m )
|
4622 | | - I HAS paramName IZ 'link-url'
|
4623 | | - IM ON UR SPECIAL mOutput->addExternalLink DOING $value
|
4624 | | - I HAS validated IZ true
|
4625 | | - KTHX
|
4626 | | - NOWAI
|
4627 | | - I HAS linkTitle IZ Title::newFromText( $value )
|
4628 | | - IZ $linkTitle
|
4629 | | - I HAS paramName IZ 'link-title'
|
4630 | | - I HAS value IZ $linkTitle
|
4631 | | - IM ON UR SPECIAL mOutput->addLink DOING $linkTitle
|
4632 | | - I HAS validated IZ true
|
4633 | | - KTHX
|
4634 | | - KTHX
|
4635 | | - break;
|
4636 | | - default:
|
4637 | | - BTW Most other things appear to be empty or numeric...
|
4638 | | - I HAS validated IZ ( $value === false || is_numeric( trim( $value ) ) )
|
4639 | | - KTHX
|
4640 | | - KTHX
|
4641 | | -
|
4642 | | - IZ $validated
|
4643 | | - $params[$type][$paramName] = $value;
|
4644 | | - KTHX
|
4645 | | - KTHX
|
4646 | | - KTHX
|
4647 | | - IZ !$validated
|
4648 | | - I HAS caption IZ $part
|
4649 | | - KTHX
|
4650 | | - KTHX
|
4651 | | -
|
4652 | | - BTW Process alignment parameters
|
4653 | | - IZ $params['horizAlign']
|
4654 | | - $params['frame']['align'] = key( $params['horizAlign'] );
|
4655 | | - KTHX
|
4656 | | - IZ $params['vertAlign']
|
4657 | | - $params['frame']['valign'] = key( $params['vertAlign'] );
|
4658 | | - KTHX
|
4659 | | -
|
4660 | | - $params['frame']['caption'] = $caption;
|
4661 | | -
|
4662 | | - BTW Will the image be presented in a frame, with the caption below?
|
4663 | | - imageIsFramed IZ isset( $params['frame']['frame'] ) ||
|
4664 | | - isset( $params['frame']['framed'] ) ||
|
4665 | | - isset( $params['frame']['thumbnail'] ) ||
|
4666 | | - IM ON UR isset DOING $params['frame']['manualthumb']
|
4667 | | -
|
4668 | | - BTW In the old days, [[Image:Foo|text...]] would set alt text. Later it
|
4669 | | - BTW came to also set the caption, ordinary text after the image -- which
|
4670 | | - BTW makes no sense, because that just repeats the text multiple times in
|
4671 | | - BTW screen readers. It *also* came to set the title attribute.
|
4672 | | - BTW
|
4673 | | - BTW Now that we have an alt attribute, we should not set the alt text to
|
4674 | | - BTW equal the caption: that's worse than useless, it just repeats the
|
4675 | | - BTW text. This is the framed/thumbnail case. If there's no caption, we
|
4676 | | - BTW use the unnamed parameter for alt text as well, just for the time be-
|
4677 | | - BTW ing, if the unnamed param is set and the alt param is not.
|
4678 | | - BTW
|
4679 | | - BTW For the future, we need to figure out if we want to tweak this more,
|
4680 | | - BTW e.g., introducing a title= parameter for the title; ignoring the un-
|
4681 | | - BTW named parameter entirely for images without a caption; adding an ex-
|
4682 | | - BTW plicit caption= parameter and preserving the old magic unnamed para-
|
4683 | | - BTW meter for BC; ...
|
4684 | | - IZ $imageIsFramed # Framed image
|
4685 | | - IZ $caption === '' && !isset( $params['frame']['alt'] )
|
4686 | | - BTW No caption or alt text, add the filename as the alt text so
|
4687 | | - BTW that screen readers at least get some description of the image
|
4688 | | - $params['frame']['alt'] = $title->getText();
|
4689 | | - KTHX
|
4690 | | - BTW Do not set $params['frame']['title'] because tooltips don't make sense
|
4691 | | - BTW for framed images
|
4692 | | - NOWAI # Inline image
|
4693 | | - IZ !isset( $params['frame']['alt'] )
|
4694 | | - BTW No alt text, use the "caption" for the alt text
|
4695 | | - if ( $caption !== '') {
|
4696 | | - $params['frame']['alt'] = $this->stripAltText( $caption, $holders );
|
4697 | | - NOWAI
|
4698 | | - BTW No caption, fall back to using the filename for the
|
4699 | | - BTW alt text
|
4700 | | - $params['frame']['alt'] = $title->getText();
|
4701 | | - KTHX
|
4702 | | - KTHX
|
4703 | | - BTW Use the "caption" for the tooltip text
|
4704 | | - $params['frame']['title'] = $this->stripAltText( $caption, $holders );
|
4705 | | - KTHX
|
4706 | | -
|
4707 | | - IM ON UR wfRunHooks DOING 'ParserMakeImageParams', array( $title, $file, &$params )
|
4708 | | -
|
4709 | | - BTW Linker does the rest
|
4710 | | - I HAS ret IZ $sk->makeImageLink2( $title, $file, $params['frame'], $params['handler'], $time, $descQuery )
|
4711 | | -
|
4712 | | - BTW Give the handler a chance to modify the parser object
|
4713 | | - IZ $handler
|
4714 | | - $handler->parserTransformHook( $this, $file );
|
4715 | | - KTHX
|
4716 | | -
|
4717 | | - I FOUND MAH $ret
|
4718 | | - KTHX
|
4719 | | -
|
4720 | | - SO IM LIKE stripAltText WITH UR $caption, $holders
|
4721 | | - BTW Strip bad stuff out of the title (tooltip). We can't just use
|
4722 | | - BTW replaceLinkHoldersText() here, because if this function is called
|
4723 | | - BTW from replaceInternalLinks2(), mLinkHolders won't be up-to-date.
|
4724 | | - IZ $holders
|
4725 | | - I HAS tooltip IZ $holders->replaceText( $caption )
|
4726 | | - NOWAI
|
4727 | | - I HAS tooltip IZ $this->replaceLinkHoldersText( $caption )
|
4728 | | - KTHX
|
4729 | | -
|
4730 | | - BTW make sure there are no placeholders in thumbnail attributes
|
4731 | | - BTW that are later expanded to html- so expand them now and
|
4732 | | - BTW remove the tags
|
4733 | | - I HAS tooltip IZ $this->mStripState->unstripBoth( $tooltip )
|
4734 | | - I HAS tooltip IZ Sanitizer::stripAllTags( $tooltip )
|
4735 | | -
|
4736 | | - I FOUND MAH $tooltip
|
4737 | | - KTHX
|
4738 | | -
|
4739 | | - DO NOT WANT
|
4740 | | - NOT WANT Set a flag in the output object indicating that the content is dynamic and
|
4741 | | - NOT WANT shouldn't be cached.
|
4742 | | - WANT
|
4743 | | - SO IM LIKE disableCache
|
4744 | | - IM ON UR wfDebug DOING "Parser output marked as uncacheable.\n"
|
4745 | | - UR SPECIAL mOutput->mCacheTime IZ -1;
|
4746 | | - KTHX
|
4747 | | -
|
4748 | | - DO NOT WANT#@+
|
4749 | | - NOT WANT Callback from the Sanitizer for expanding items found in HTML attribute
|
4750 | | - NOT WANT values, so they can be safely tested and escaped.
|
4751 | | - NOT WANT @param string $text
|
4752 | | - NOT WANT @param PPFrame $frame
|
4753 | | - NOT WANT @return string
|
4754 | | - NOT WANT @private
|
4755 | | - WANT
|
4756 | | - SO IM LIKE attributeStripCallback WITH UR &$text, $frame = false
|
4757 | | - I HAS text IZ $this->replaceVariables( $text, $frame )
|
4758 | | - I HAS text IZ $this->mStripState->unstripBoth( $text )
|
4759 | | - I FOUND MAH $text
|
4760 | | - KTHX
|
4761 | | -
|
4762 | | - DO NOT WANT#@-*/
|
4763 | | -
|
4764 | | - DO NOT WANT#@+
|
4765 | | - NOT WANT Accessor/mutator
|
4766 | | - WANT
|
4767 | | - SO IM LIKE Title WITH UR $x = null TESTING UR return wfSetVar( $this->mTitle, $x );
|
4768 | | - SO IM LIKE Options WITH UR $x = null TESTING UR return wfSetVar( $this->mOptions, $x );
|
4769 | | - SO IM LIKE OutputType WITH UR $x = null TESTING UR return wfSetVar( $this->mOutputType, $x );
|
4770 | | - DO NOT WANT#@-*/
|
4771 | | -
|
4772 | | - DO NOT WANT#@+
|
4773 | | - NOT WANT Accessor
|
4774 | | - WANT
|
4775 | | - SO IM LIKE getTags
|
4776 | | - I FOUND MAH array_merge( array_keys( $this->mTransparentTagHooks ), array_keys( $this->mTagHooks ) )
|
4777 | | - KTHX
|
4778 | | - DO NOT WANT#@-*/
|
4779 | | -
|
4780 | | -
|
4781 | | - DO NOT WANT
|
4782 | | - NOT WANT Break wikitext input into sections, and either pull or replace
|
4783 | | - NOT WANT some particular section's text.
|
4784 | | - NOT WANT
|
4785 | | - NOT WANT External callers should use the getSection and replaceSection methods.
|
4786 | | - NOT WANT
|
4787 | | - NOT WANT @param string $text Page wikitext
|
4788 | | - NOT WANT @param string $section A section identifier string of the form:
|
4789 | | - NOT WANT <flag1> - <flag2> - ... - <section number>
|
4790 | | - NOT WANT
|
4791 | | - NOT WANT Currently the only recognised flag is "T", which means the target section number
|
4792 | | - NOT WANT was derived during a template inclusion parse, in other words this is a template
|
4793 | | - NOT WANT section edit link. If no flags are given, it was an ordinary section edit link.
|
4794 | | - NOT WANT This flag is required to avoid a section numbering mismatch when a section is
|
4795 | | - NOT WANT enclosed by <includeonly> (bug 6563).
|
4796 | | - NOT WANT
|
4797 | | - NOT WANT The section number 0 pulls the text before the first heading; other numbers will
|
4798 | | - NOT WANT pull the given section along with its lower-level subsections. If the section is
|
4799 | | - NOT WANT not found, $mode=get will return $newtext, and $mode=replace will return $text.
|
4800 | | - NOT WANT
|
4801 | | - NOT WANT @param string $mode One of "get" or "replace"
|
4802 | | - NOT WANT @param string $newText Replacement text for section data.
|
4803 | | - NOT WANT @return string for "get", the extracted section text.
|
4804 | | - NOT WANT for "replace", the whole page with the section replaced.
|
4805 | | - WANT
|
4806 | | - SO IM LIKE extractSections WITH UR $text, $section, $mode, $newText=''
|
4807 | | - I HAS UR $wgTitle ON UR INTERNETS
|
4808 | | - IM ON UR SPECIAL clearState
|
4809 | | - IM ON UR SPECIAL setTitle DOING $wgTitle # not generally used but removes an ugly failure mode
|
4810 | | - UR SPECIAL mOptions IZ new ParserOptions;
|
4811 | | - IM ON UR SPECIAL setOutputType DOING self::OT_PLAIN
|
4812 | | - I HAS outText IZ ''
|
4813 | | - I HAS frame IZ $this->getPreprocessor()->newFrame()
|
4814 | | -
|
4815 | | - BTW Process section extraction flags
|
4816 | | - I HAS flags IZ 0
|
4817 | | - I HAS sectionParts IZ explode( '-', $section )
|
4818 | | - I HAS sectionIndex IZ array_pop( $sectionParts )
|
4819 | | - IM IN UR sectionParts ITZA part
|
4820 | | - IZ $part === 'T'
|
4821 | | - $flags |= self::PTD_FOR_INCLUSION;
|
4822 | | - KTHX
|
4823 | | - KTHX
|
4824 | | - BTW Preprocess the text
|
4825 | | - I HAS root IZ $this->preprocessToDom( $text, $flags )
|
4826 | | -
|
4827 | | - BTW <h> nodes indicate section breaks
|
4828 | | - BTW They can only occur at the top level, so we can find them by iterating the root's children
|
4829 | | - I HAS node IZ $root->getFirstChild()
|
4830 | | -
|
4831 | | - BTW Find the target section
|
4832 | | - IZ $sectionIndex == 0
|
4833 | | - BTW Section zero doesn't nest, level=big
|
4834 | | - I HAS targetLevel IZ 1000
|
4835 | | - NOWAI
|
4836 | | - STEALIN UR $node
|
4837 | | - IZ $node->getName() === 'h'
|
4838 | | - I HAS bits IZ $node->splitHeading()
|
4839 | | - IZ $bits['i'] == $sectionIndex
|
4840 | | - I HAS targetLevel IZ $bits['level']
|
4841 | | - break;
|
4842 | | - KTHX
|
4843 | | - KTHX
|
4844 | | - IZ $mode === 'replace'
|
4845 | | - outText HAS MOAR $frame->expand( $node, PPFrame::RECOVER_ORIG );
|
4846 | | - KTHX
|
4847 | | - I HAS node IZ $node->getNextSibling()
|
4848 | | - KTHX
|
4849 | | - KTHX
|
4850 | | -
|
4851 | | - IZ !$node
|
4852 | | - BTW Not found
|
4853 | | - IZ $mode === 'get'
|
4854 | | - I FOUND MAH $newText
|
4855 | | - NOWAI
|
4856 | | - I FOUND MAH $text
|
4857 | | - KTHX
|
4858 | | - KTHX
|
4859 | | -
|
4860 | | - BTW Find the end of the section, including nested sections
|
4861 | | - do {
|
4862 | | - IZ $node->getName() === 'h'
|
4863 | | - I HAS bits IZ $node->splitHeading()
|
4864 | | - I HAS curLevel IZ $bits['level']
|
4865 | | - IZ $bits['i'] != $sectionIndex && $curLevel <= $targetLevel
|
4866 | | - break;
|
4867 | | - KTHX
|
4868 | | - KTHX
|
4869 | | - IZ $mode === 'get'
|
4870 | | - outText HAS MOAR $frame->expand( $node, PPFrame::RECOVER_ORIG );
|
4871 | | - KTHX
|
4872 | | - I HAS node IZ $node->getNextSibling()
|
4873 | | - KTHX while ( $node );
|
4874 | | -
|
4875 | | - BTW Write out the remainder (in replace mode only)
|
4876 | | - IZ $mode === 'replace'
|
4877 | | - BTW Output the replacement text
|
4878 | | - BTW Add two newlines on -- trailing whitespace in $newText is conventionally
|
4879 | | - BTW stripped by the editor, so we need both newlines to restore the paragraph gap
|
4880 | | - BTW Only add trailing whitespace if there is newText
|
4881 | | - IZ $newText != ""
|
4882 | | - outText HAS MOAR $newText . "\n\n";
|
4883 | | - KTHX
|
4884 | | -
|
4885 | | - STEALIN UR $node
|
4886 | | - outText HAS MOAR $frame->expand( $node, PPFrame::RECOVER_ORIG );
|
4887 | | - I HAS node IZ $node->getNextSibling()
|
4888 | | - KTHX
|
4889 | | - KTHX
|
4890 | | -
|
4891 | | - IZ is_string( $outText )
|
4892 | | - BTW Re-insert stripped tags
|
4893 | | - I HAS outText IZ rtrim( $this->mStripState->unstripBoth( $outText ) )
|
4894 | | - KTHX
|
4895 | | -
|
4896 | | - I FOUND MAH $outText
|
4897 | | - KTHX
|
4898 | | -
|
4899 | | - DO NOT WANT
|
4900 | | - NOT WANT This function returns the text of a section, specified by a number ($section).
|
4901 | | - NOT WANT A section is text under a heading like == Heading == or \<h1\>Heading\</h1\>, or
|
4902 | | - NOT WANT the first section before any such heading (section 0).
|
4903 | | - NOT WANT
|
4904 | | - NOT WANT If a section contains subsections, these are also returned.
|
4905 | | - NOT WANT
|
4906 | | - NOT WANT @param string $text text to look in
|
4907 | | - NOT WANT @param string $section section identifier
|
4908 | | - NOT WANT @param string $deftext default to return if section is not found
|
4909 | | - NOT WANT @return string text of the requested section
|
4910 | | - WANT
|
4911 | | - SO IM LIKE getSection WITH UR $text, $section, $deftext=''
|
4912 | | - I FOUND MAH $this->extractSections( $text, $section, "get", $deftext )
|
4913 | | - KTHX
|
4914 | | -
|
4915 | | - SO IM LIKE replaceSection WITH UR $oldtext, $section, $text
|
4916 | | - I FOUND MAH $this->extractSections( $oldtext, $section, "replace", $text )
|
4917 | | - KTHX
|
4918 | | -
|
4919 | | - DO NOT WANT
|
4920 | | - NOT WANT Get the timestamp associated with the current revision, adjusted for
|
4921 | | - NOT WANT the default server-local timestamp
|
4922 | | - WANT
|
4923 | | - SO IM LIKE getRevisionTimestamp
|
4924 | | - IZ is_null( $this->mRevisionTimestamp )
|
4925 | | - IM ON UR wfProfileIn DOING __METHOD__
|
4926 | | - I HAS UR $wgContLang ON UR INTERNETS
|
4927 | | - I HAS dbr IZ wfGetDB( DB_SLAVE )
|
4928 | | - timestamp IZ $dbr->selectField( 'revision', 'rev_timestamp',
|
4929 | | - IM ON UR array DOING 'rev_id' => $this->mRevisionId ), __METHOD__
|
4930 | | -
|
4931 | | - BTW Normalize timestamp to internal MW format for timezone processing.
|
4932 | | - BTW This has the added side-effect of replacing a null value with
|
4933 | | - BTW the current time, which gives us more sensible behavior for
|
4934 | | - BTW previews.
|
4935 | | - I HAS timestamp IZ wfTimestamp( TS_MW, $timestamp )
|
4936 | | -
|
4937 | | - BTW The cryptic '' timezone parameter tells to use the site-default
|
4938 | | - BTW timezone offset instead of the user settings.
|
4939 | | - BTW
|
4940 | | - BTW Since this value will be saved into the parser cache, served
|
4941 | | - BTW to other users, and potentially even used inside links and such,
|
4942 | | - BTW it needs to be consistent for all visitors.
|
4943 | | - UR SPECIAL mRevisionTimestamp IZ $wgContLang->userAdjust( $timestamp, '' );
|
4944 | | -
|
4945 | | - IM ON UR wfProfileOut DOING __METHOD__
|
4946 | | - KTHX
|
4947 | | - I FOUND MAH $this->mRevisionTimestamp
|
4948 | | - KTHX
|
4949 | | -
|
4950 | | - DO NOT WANT
|
4951 | | - NOT WANT Get the name of the user that edited the last revision
|
4952 | | - WANT
|
4953 | | - SO IM LIKE getRevisionUser
|
4954 | | - BTW if this template is subst: the revision id will be blank,
|
4955 | | - BTW so just use the current user's name
|
4956 | | - IZ $this->mRevisionId
|
4957 | | - I HAS revision IZ Revision::newFromId( $this->mRevisionId )
|
4958 | | - I HAS revuser IZ $revision->getUserText()
|
4959 | | - NOWAI
|
4960 | | - I HAS UR $wgUser ON UR INTERNETS
|
4961 | | - I HAS revuser IZ $wgUser->getName()
|
4962 | | - KTHX
|
4963 | | - I FOUND MAH $revuser
|
4964 | | - KTHX
|
4965 | | -
|
4966 | | - DO NOT WANT
|
4967 | | - NOT WANT Mutator for $mDefaultSort
|
4968 | | - NOT WANT
|
4969 | | - NOT WANT @param $sort New value
|
4970 | | - WANT
|
4971 | | - SO IM LIKE setDefaultSort WITH UR $sort
|
4972 | | - UR SPECIAL mDefaultSort IZ $sort;
|
4973 | | - KTHX
|
4974 | | -
|
4975 | | - DO NOT WANT
|
4976 | | - NOT WANT Accessor for $mDefaultSort
|
4977 | | - NOT WANT Will use the title/prefixed title if none is set
|
4978 | | - NOT WANT
|
4979 | | - NOT WANT @return string
|
4980 | | - WANT
|
4981 | | - SO IM LIKE getDefaultSort
|
4982 | | - I HAS UR $wgCategoryPrefixedDefaultSortkey ON UR INTERNETS
|
4983 | | - IZ $this->mDefaultSort !== false
|
4984 | | - I FOUND MAH $this->mDefaultSort
|
4985 | | - KTHX elseif ( $this->mTitle->getNamespace() == NS_CATEGORY ||
|
4986 | | - !$wgCategoryPrefixedDefaultSortkey )
|
4987 | | - {
|
4988 | | - I FOUND MAH $this->mTitle->getText()
|
4989 | | - NOWAI
|
4990 | | - I FOUND MAH $this->mTitle->getPrefixedText()
|
4991 | | - KTHX
|
4992 | | - KTHX
|
4993 | | -
|
4994 | | - DO NOT WANT
|
4995 | | - NOT WANT Accessor for $mDefaultSort
|
4996 | | - NOT WANT Unlike getDefaultSort(), will return false if none is set
|
4997 | | - NOT WANT
|
4998 | | - NOT WANT @return string or false
|
4999 | | - WANT
|
5000 | | - SO IM LIKE getCustomDefaultSort
|
5001 | | - I FOUND MAH $this->mDefaultSort
|
5002 | | - KTHX
|
5003 | | -
|
5004 | | - DO NOT WANT
|
5005 | | - NOT WANT Try to guess the section anchor name based on a wikitext fragment
|
5006 | | - NOT WANT presumably extracted from a heading, for example "Header" from
|
5007 | | - NOT WANT "== Header ==".
|
5008 | | - WANT
|
5009 | | - SO IM LIKE guessSectionNameFromWikiText WITH UR $text
|
5010 | | - BTW Strip out wikitext links(they break the anchor)
|
5011 | | - I HAS text IZ $this->stripSectionName( $text )
|
5012 | | - I HAS headline IZ Sanitizer::decodeCharReferences( $text )
|
5013 | | - BTW strip out HTML
|
5014 | | - I HAS headline IZ StringUtils::delimiterReplace( '<', '>', '', $headline )
|
5015 | | - I HAS headline IZ trim( $headline )
|
5016 | | - I HAS sectionanchor IZ '#' . urlencode( str_replace( ' ', '_', $headline ) )
|
5017 | | - I HAS replacearray IZ BUCKET
|
5018 | | - '%3A' => ':',
|
5019 | | - '%' => '.'
|
5020 | | - BUCKET
|
5021 | | - return str_replace(
|
5022 | | - array_keys( $replacearray ),
|
5023 | | - array_values( $replacearray ),
|
5024 | | - $sectionanchor );
|
5025 | | - KTHX
|
5026 | | -
|
5027 | | - DO NOT WANT
|
5028 | | - NOT WANT Strips a text string of wikitext for use in a section anchor
|
5029 | | - NOT WANT
|
5030 | | - NOT WANT Accepts a text string and then removes all wikitext from the
|
5031 | | - NOT WANT string and leaves only the resultant text (i.e. the result of
|
5032 | | - NOT WANT [[User:WikiSysop|Sysop]] would be "Sysop" and the result of
|
5033 | | - NOT WANT [[User:WikiSysop]] would be "User:WikiSysop") - this is intended
|
5034 | | - NOT WANT to create valid section anchors by mimicing the output of the
|
5035 | | - NOT WANT parser when headings are parsed.
|
5036 | | - NOT WANT
|
5037 | | - NOT WANT @param $text string Text string to be stripped of wikitext
|
5038 | | - NOT WANT for use in a Section anchor
|
5039 | | - NOT WANT @return Filtered text string
|
5040 | | - WANT
|
5041 | | - SO IM LIKE stripSectionName WITH UR $text
|
5042 | | - BTW Strip internal link markup
|
5043 | | - I HAS text IZ preg_replace( '/\[\[:?([^[|]+)\|([^[]+)\]\]/', '$2', $text )
|
5044 | | - I HAS text IZ preg_replace( '/\[\[:?([^[]+)\|?\]\]/', '$1', $text )
|
5045 | | -
|
5046 | | - BTW Strip external link markup (FIXME: Not Tolerant to blank link text
|
5047 | | - BTW I.E. [http://www.mediawiki.org] will render as [1] or something depending
|
5048 | | - BTW on how many empty links there are on the page - need to figure that out.
|
5049 | | - I HAS text IZ preg_replace( '/\[(?:' . wfUrlProtocols() . ')([^ ]+?) ([^[]+)\]/', '$2', $text )
|
5050 | | -
|
5051 | | - BTW Parse wikitext quotes (italics & bold)
|
5052 | | - I HAS text IZ $this->doQuotes( $text )
|
5053 | | -
|
5054 | | - BTW Strip HTML tags
|
5055 | | - I HAS text IZ StringUtils::delimiterReplace( '<', '>', '', $text )
|
5056 | | - I FOUND MAH $text
|
5057 | | - KTHX
|
5058 | | -
|
5059 | | - SO IM LIKE srvus WITH UR $text
|
5060 | | - I FOUND MAH $this->testSrvus( $text, $this->mOutputType )
|
5061 | | - KTHX
|
5062 | | -
|
5063 | | - DO NOT WANT
|
5064 | | - NOT WANT strip/replaceVariables/unstrip for preprocessor regression testing
|
5065 | | - WANT
|
5066 | | - SO IM LIKE testSrvus WITH UR $text, $title, $options, $outputType = self::OT_HTML
|
5067 | | - IM ON UR SPECIAL clearState
|
5068 | | - IZ !$title instanceof Title
|
5069 | | - I HAS title IZ Title::newFromText( $title )
|
5070 | | - KTHX
|
5071 | | - UR SPECIAL mTitle IZ $title;
|
5072 | | - UR SPECIAL mOptions IZ $options;
|
5073 | | - IM ON UR SPECIAL setOutputType DOING $outputType
|
5074 | | - I HAS text IZ $this->replaceVariables( $text )
|
5075 | | - I HAS text IZ $this->mStripState->unstripBoth( $text )
|
5076 | | - I HAS text IZ Sanitizer::removeHTMLtags( $text )
|
5077 | | - I FOUND MAH $text
|
5078 | | - KTHX
|
5079 | | -
|
5080 | | - SO IM LIKE testPst WITH UR $text, $title, $options
|
5081 | | - I HAS UR $wgUser ON UR INTERNETS
|
5082 | | - IZ !$title instanceof Title
|
5083 | | - I HAS title IZ Title::newFromText( $title )
|
5084 | | - KTHX
|
5085 | | - I FOUND MAH $this->preSaveTransform( $text, $title, $wgUser, $options )
|
5086 | | - KTHX
|
5087 | | -
|
5088 | | - SO IM LIKE testPreprocess WITH UR $text, $title, $options
|
5089 | | - IZ !$title instanceof Title
|
5090 | | - I HAS title IZ Title::newFromText( $title )
|
5091 | | - KTHX
|
5092 | | - I FOUND MAH $this->testSrvus( $text, $title, $options, self::OT_PREPROCESS )
|
5093 | | - KTHX
|
5094 | | -
|
5095 | | - SO IM LIKE markerSkipCallback WITH UR $s, $callback
|
5096 | | - I HAS i IZ 0
|
5097 | | - I HAS out IZ ''
|
5098 | | - STEALIN UR $i < strlen( $s )
|
5099 | | - I HAS markerStart IZ strpos( $s, $this->mUniqPrefix, $i )
|
5100 | | - IZ $markerStart === false
|
5101 | | - out HAS MOAR call_user_func( $callback, substr( $s, $i ) );
|
5102 | | - break;
|
5103 | | - NOWAI
|
5104 | | - out HAS MOAR call_user_func( $callback, substr( $s, $i, $markerStart - $i ) );
|
5105 | | - I HAS markerEnd IZ strpos( $s, self::MARKER_SUFFIX, $markerStart )
|
5106 | | - IZ $markerEnd === false
|
5107 | | - out HAS MOAR substr( $s, $markerStart );
|
5108 | | - break;
|
5109 | | - NOWAI
|
5110 | | - $markerEnd += strlen( self::MARKER_SUFFIX );
|
5111 | | - out HAS MOAR substr( $s, $markerStart, $markerEnd - $markerStart );
|
5112 | | - I HAS i IZ $markerEnd
|
5113 | | - KTHX
|
5114 | | - KTHX
|
5115 | | - KTHX
|
5116 | | - I FOUND MAH $out
|
5117 | | - KTHX
|
5118 | | -
|
5119 | | - SO IM LIKE serialiseHalfParsedText WITH UR $text
|
5120 | | - I HAS data IZ EMPTY
|
5121 | | - $data['text'] = $text;
|
5122 | | -
|
5123 | | - BTW First, find all strip markers, and store their
|
5124 | | - BTW data in an array.
|
5125 | | - I HAS stripState IZ new StripState
|
5126 | | - I HAS pos IZ 0
|
5127 | | - while ( ( $start_pos = strpos( $text, $this->mUniqPrefix, $pos ) )
|
5128 | | - && ( $end_pos = strpos( $text, self::MARKER_SUFFIX, $pos ) ) )
|
5129 | | - {
|
5130 | | - $end_pos += strlen( self::MARKER_SUFFIX );
|
5131 | | - I HAS marker IZ substr( $text, $start_pos, $end_pos-$start_pos )
|
5132 | | -
|
5133 | | - IZ !empty( $this->mStripState->general->data[$marker] )
|
5134 | | - I HAS replaceArray IZ $stripState->general
|
5135 | | - I HAS stripText IZ $this->mStripState->general->data[$marker]
|
5136 | | - ORLY !empty( $this->mStripState->nowiki->data[$marker] )
|
5137 | | - I HAS replaceArray IZ $stripState->nowiki
|
5138 | | - I HAS stripText IZ $this->mStripState->nowiki->data[$marker]
|
5139 | | - NOWAI
|
5140 | | - throw new MWException( "Hanging strip marker: '$marker'." );
|
5141 | | - KTHX
|
5142 | | -
|
5143 | | - $replaceArray->setPair( $marker, $stripText );
|
5144 | | - I HAS pos IZ $end_pos
|
5145 | | - KTHX
|
5146 | | - $data['stripstate'] = $stripState;
|
5147 | | -
|
5148 | | - BTW Now, find all of our links, and store THEIR
|
5149 | | - BTW data in an array! :)
|
5150 | | - I HAS links IZ BUCKET 'internal' => array(), 'interwiki' => array() );
|
5151 | | - I HAS pos IZ 0
|
5152 | | -
|
5153 | | - BTW Internal links
|
5154 | | - STEALIN UR ( $start_pos = strpos( $text, '<!--LINK ', $pos ) )
|
5155 | | - IM ON UR list DOING $ns, $trail ) = explode( ':', substr( $text, $start_pos + strlen( '<!--LINK ' ) ), 2
|
5156 | | -
|
5157 | | - I HAS ns IZ trim( $ns )
|
5158 | | - IZ empty( $links['internal'][$ns] )
|
5159 | | - $links['internal'][$ns] = array();
|
5160 | | - KTHX
|
5161 | | -
|
5162 | | - I HAS key IZ trim( substr( $trail, 0, strpos( $trail, '-->' ) ) )
|
5163 | | - $links['internal'][$ns][] = $this->mLinkHolders->internals[$ns][$key];
|
5164 | | - I HAS pos IZ $start_pos + strlen( "<!--LINK $ns:$key-->" )
|
5165 | | - KTHX
|
5166 | | -
|
5167 | | - I HAS pos IZ 0
|
5168 | | -
|
5169 | | - BTW Interwiki links
|
5170 | | - STEALIN UR ( $start_pos = strpos( $text, '<!--IWLINK ', $pos ) )
|
5171 | | - I HAS data IZ substr( $text, $start_pos )
|
5172 | | - I HAS key IZ trim( substr( $data, 0, strpos( $data, '-->' ) ) )
|
5173 | | - $links['interwiki'][] = $this->mLinkHolders->interwiki[$key];
|
5174 | | - I HAS pos IZ $start_pos + strlen( "<!--IWLINK $key-->" )
|
5175 | | - KTHX
|
5176 | | -
|
5177 | | - $data['linkholder'] = $links;
|
5178 | | -
|
5179 | | - I FOUND MAH $data
|
5180 | | - KTHX
|
5181 | | -
|
5182 | | - DO NOT WANT
|
5183 | | - NOT WANT TODO: document
|
5184 | | - NOT WANT @param $data Array
|
5185 | | - NOT WANT @param $intPrefix String unique identifying prefix
|
5186 | | - NOT WANT @return String
|
5187 | | - WANT
|
5188 | | - SO IM LIKE unserialiseHalfParsedText WITH UR $data, $intPrefix = null
|
5189 | | - IZ !$intPrefix
|
5190 | | - I HAS intPrefix IZ $this->getRandomString()
|
5191 | | - KTHX
|
5192 | | -
|
5193 | | - BTW First, extract the strip state.
|
5194 | | - I HAS stripState IZ $data['stripstate']
|
5195 | | - IM ON UR SPECIAL mStripState->general->merge DOING $stripState->general
|
5196 | | - IM ON UR SPECIAL mStripState->nowiki->merge DOING $stripState->nowiki
|
5197 | | -
|
5198 | | - BTW Now, extract the text, and renumber links
|
5199 | | - I HAS text IZ $data['text']
|
5200 | | - I HAS links IZ $data['linkholder']
|
5201 | | -
|
5202 | | - BTW Internal...
|
5203 | | - foreach ( $links['internal'] as $ns => $nsLinks ) {
|
5204 | | - IM IN UR nsLinks ITZA key => $entry
|
5205 | | - I HAS newKey IZ $intPrefix . '-' . $key
|
5206 | | - $this->mLinkHolders->internals[$ns][$newKey] = $entry;
|
5207 | | -
|
5208 | | - I HAS text IZ str_replace( "<!--LINK $ns:$key-->", "<!--LINK $ns:$newKey-->", $text )
|
5209 | | - KTHX
|
5210 | | - KTHX
|
5211 | | -
|
5212 | | - BTW Interwiki...
|
5213 | | - foreach ( $links['interwiki'] as $key => $entry ) {
|
5214 | | - I HAS newKey IZ "$intPrefix-$key"
|
5215 | | - $this->mLinkHolders->interwikis[$newKey] = $entry;
|
5216 | | -
|
5217 | | - I HAS text IZ str_replace( "<!--IWLINK $key-->", "<!--IWLINK $newKey-->", $text )
|
5218 | | - KTHX
|
5219 | | -
|
5220 | | - BTW Should be good to go.
|
5221 | | - I FOUND MAH $text
|
5222 | | - KTHX
|
5223 | | - KTHX
|
5224 | | -
|
5225 | | - DO NOT WANT
|
5226 | | - NOT WANT @todo document, briefly.
|
5227 | | - NOT WANT @ingroup Parser
|
5228 | | - WANT
|
5229 | | - IM IN UR SPECIAL StripState
|
5230 | | - I HAS UR $general, $nowiki
|
5231 | | -
|
5232 | | - SO IM LIKE __construct
|
5233 | | - UR SPECIAL general IZ new ReplacementArray;
|
5234 | | - UR SPECIAL nowiki IZ new ReplacementArray;
|
5235 | | - KTHX
|
5236 | | -
|
5237 | | - SO IM LIKE unstripGeneral WITH UR $text
|
5238 | | - IM ON UR wfProfileIn DOING __METHOD__
|
5239 | | - do {
|
5240 | | - I HAS oldText IZ $text
|
5241 | | - I HAS text IZ $this->general->replace( $text )
|
5242 | | - KTHX while ( $text !== $oldText );
|
5243 | | - IM ON UR wfProfileOut DOING __METHOD__
|
5244 | | - I FOUND MAH $text
|
5245 | | - KTHX
|
5246 | | -
|
5247 | | - SO IM LIKE unstripNoWiki WITH UR $text
|
5248 | | - IM ON UR wfProfileIn DOING __METHOD__
|
5249 | | - do {
|
5250 | | - I HAS oldText IZ $text
|
5251 | | - I HAS text IZ $this->nowiki->replace( $text )
|
5252 | | - KTHX while ( $text !== $oldText );
|
5253 | | - IM ON UR wfProfileOut DOING __METHOD__
|
5254 | | - I FOUND MAH $text
|
5255 | | - KTHX
|
5256 | | -
|
5257 | | - SO IM LIKE unstripBoth WITH UR $text
|
5258 | | - IM ON UR wfProfileIn DOING __METHOD__
|
5259 | | - do {
|
5260 | | - I HAS oldText IZ $text
|
5261 | | - I HAS text IZ $this->general->replace( $text )
|
5262 | | - I HAS text IZ $this->nowiki->replace( $text )
|
5263 | | - KTHX while ( $text !== $oldText );
|
5264 | | - IM ON UR wfProfileOut DOING __METHOD__
|
5265 | | - I FOUND MAH $text
|
5266 | | - KTHX
|
5267 | | - KTHX
|
5268 | | -
|
5269 | | - DO NOT WANT
|
5270 | | - NOT WANT @todo document, briefly.
|
5271 | | - NOT WANT @ingroup Parser
|
5272 | | - WANT
|
5273 | | - IM IN UR SPECIAL OnlyIncludeReplacer
|
5274 | | - var $output = '';
|
5275 | | -
|
5276 | | - SO IM LIKE replace WITH UR $matches
|
5277 | | - IZ substr( $matches[1], -1 ) === "\n"
|
5278 | | - $this->output .= substr( $matches[1], 0, -1 );
|
5279 | | - NOWAI
|
5280 | | - $this->output .= $matches[1];
|
5281 | | - KTHX
|
5282 | | - KTHX
|
5283 | | - KTHX
Index: trunk/phase3/includes/parser/LOLParser.php |
— | — | @@ -1,170 +0,0 @@ |
2 | | -<?php |
3 | | -/* |
4 | | - * lol_core.php Ver 0.3 |
5 | | - * Copyright (c) 2007 Jeff Jones, www.tetraboy.com, 2010 Happy-melon |
6 | | - * |
7 | | - * Permission is hereby granted, free of charge, to any person obtaining a copy |
8 | | - * of this software and associated documentation files (the "Software"), to deal |
9 | | - * in the Software without restriction, including without limitation the rights |
10 | | - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
11 | | - * copies of the Software, and to permit persons to whom the Software is |
12 | | - * furnished to do so, subject to the following conditions: |
13 | | - * |
14 | | - * The above copyright notice and this permission notice shall be included in |
15 | | - * all copies or substantial portions of the Software. |
16 | | - * |
17 | | - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
18 | | - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
19 | | - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
20 | | - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
21 | | - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
22 | | - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
23 | | - * THE SOFTWARE. |
24 | | - */ |
25 | | -function lol_core_parse( $code ) { |
26 | | - return lol_core_replace( $code, 'forwards' ); |
27 | | -} |
28 | | -function lol_core_unparse( $code ) { |
29 | | - return lol_core_replace( $code, 'backwards' ); |
30 | | -} |
31 | | - |
32 | | -define( 'LOL_ANY', '(.+?)' ); |
33 | | -define( 'LOL_LABEL', '([a-zA-Z0-9_-]+)' ); |
34 | | -define( 'LOL_VAR', '\$([a-zA-Z0-9_-]+)' ); |
35 | | -define( 'LOL_FNAME', '([a-zA-Z0-9_\-\>]+)' ); |
36 | | -define( 'LOL_MNAME', '\$this\-\>([a-zA-Z0-9_\-\>]+)' ); |
37 | | -define( 'LOL_VARLIST', '((?:'.LOL_VAR.'(?:,\s*)?)+)' ); |
38 | | -define( 'LOL_CMT', '((\/\/|#) (.*))?'); |
39 | | -function lol_core_replace($code, $dir ) { |
40 | | - $backwards = array( |
41 | | - '/^([\s]*)'.LOL_VAR.'( = null)?;/', '$1 I HAS $2', |
42 | | - '/^([\s]*)var '.LOL_VARLIST.';/', '$1 I HAS UR $2', |
43 | | - '/^([\s]*)global '.LOL_VARLIST.';/', '$1 I HAS UR $2 ON UR INTERNETS', |
44 | | - '/^([\s]*)'.LOL_VAR.' += array\(\);/', '$1 I HAS $2 IZ EMPTY', |
45 | | - '/^([\s]*)'.LOL_VAR.' += array\(/', '$1 I HAS $2 IZ BUCKET', |
46 | | - '/^([\s]*)'.LOL_VAR.' += (.+);/', '$1 I HAS $2 IZ $3', |
47 | | - '/^([\s]*)'.LOL_VAR.'++;/', '$1 $2 UPUP!', |
48 | | - '/^([\s]*)'.LOL_VAR.' = '.LOL_FNAME.'\( (.+) \);/', '$1 $2 IZ ON UR $3 DOING $4', |
49 | | - '/^([\s]*)'.LOL_MNAME.'\(\);/', '$1 IM ON UR SPECIAL $2', |
50 | | - '/^([\s]*)'.LOL_MNAME.'\( (.+) \);/', '$1 IM ON UR SPECIAL $2 DOING $3', |
51 | | - '/^([\s]*)'.LOL_FNAME.'\(\);/', '$1 IM ON UR $2', |
52 | | - '/^([\s]*)'.LOL_FNAME.'\( (.+) \);/', '$1 IM ON UR $2 DOING $3', |
53 | | - |
54 | | - '/^([\s]*)class '.LOL_FNAME.' {/', '$1 IM IN UR SPECIAL $2', |
55 | | - '/^([\s]*)const '.LOL_FNAME.' = (.+)/', '$1 I ALWAYZ HAS $2 IZ $3', |
56 | | - '/^([\s]*)foreach \( '.LOL_VAR.' as \$(.+) \) {/', '$1 IM IN UR $2 ITZA $3', |
57 | | - '/^([\s]*)while \( (.+) \) {/', '$1 STEALIN UR $2', |
58 | | - |
59 | | - '/^([\s]*)return (.*);/', '$1 I FOUND MAH $2', |
60 | | - |
61 | | - '/^([\s]*)'.LOL_VAR.' = (.*)/', '$1 $2 IZ $3', |
62 | | - '/^([\s]*)'.LOL_VAR.' \.= (.*)/', '$1 $2 HAS MOAR $3', |
63 | | - '/^([\s]*)'.LOL_MNAME.' = array\(\)/', '$1 UR SPECIAL $2 IZ EMPTY', |
64 | | - '/^([\s]*)'.LOL_MNAME.' = array\(/', '$1 UR SPECIAL $2 IZ BUCKET', |
65 | | - '/^([\s]*)'.LOL_MNAME.' = (.*)/', '$1 UR SPECIAL $2 IZ $3', |
66 | | - |
67 | | - '/^([\s]*)(?:private |protected |public )?function '.LOL_FNAME.' ?\(\) \{ (.+) \}/', '$1 SO IM LIKE $2 TESTING UR $3', |
68 | | - '/^([\s]*)(?:private |protected |public )?function '.LOL_FNAME.' ?\( (.*) \) \{ (.+) \}/', '$1 SO IM LIKE $2 WITH UR $3 TESTING UR $4', |
69 | | - '/^([\s]*)(?:private |protected |public )?function '.LOL_FNAME.' ?\( (.*) \) \{/', '$1 SO IM LIKE $2 WITH UR $3', |
70 | | - '/^([\s]*)(?:private |protected |public )?function '.LOL_FNAME.' ?\(\) \{/', '$1 SO IM LIKE $2', |
71 | | - '/^([\s]*)(?:private |protected |public )?static function '.LOL_FNAME.' ?\(\) \{/', '$1 SO IM ALWAYS LIKE $2', |
72 | | - '/^([\s]*)(?:private |protected |public )?static function '.LOL_FNAME.' ?\( (.*) \) \{/', '$1 SO IM ALWAYS LIKE $2 WITH UR $3', |
73 | | - |
74 | | - '/^([\s]*)if \( (.+) \) \{/', '$1 IZ $2', |
75 | | - '/^([\s]*)\} elseif \( (.+) \) \{/', '$1 ORLY $2', |
76 | | - '/^([\s]*)\} else \{/', '$1 NOWAI', |
77 | | - |
78 | | - '/^([\s]*)(\/\/|\#) (.*)/', '$1 BTW $3', |
79 | | - '/^([\s]*)\/\*\*?/', '$1 DO NOT WANT', |
80 | | - '/^([\s]*)\*\//', '$1 WANT', |
81 | | - '/^([\s]*)\* ?(.*)/', '$1 NOT WANT $2', |
82 | | - |
83 | | - '/^([\s]*)\);/', '$1 BUCKET', |
84 | | - '/^([\s]*)\}/', '$1 KTHX', |
85 | | - ); |
86 | | - |
87 | | - $forwards = array( |
88 | | - '/^([\s]*) I HAS UR '.LOL_VARLIST.' ON UR INTERNETS[\s]+/', '$1 global $2;', |
89 | | - '/^([\s]*) I HAS UR '.LOL_VARLIST.'[\s]+/', '$1 var $2;', |
90 | | - '/^([\s]*) I HAS '.LOL_LABEL.' IZ BUCKET[\s]+/', '$1\$$2 = array(', |
91 | | - '/^([\s]*) I HAS '.LOL_LABEL.' IZ EMPTY[\s]+/', '$1 \$$2 = array();', |
92 | | - '/^([\s]*) I HAS '.LOL_LABEL.' IZ '.LOL_ANY.''.LOL_CMT.'[\s]+$/', '$1 \$$2 = $3; $4', |
93 | | - '/^([\s]*) I HAS '.LOL_LABEL.'[\s]+/', '$1 \$$2;', |
94 | | - '/^([\s]*) '.LOL_LABEL.' IZ ON UR '.LOL_FNAME.' DOING '.LOL_ANY.''.LOL_CMT.'[\s]+$/', '$1 \$$2 = $3( $4 ); $5', |
95 | | - '/^([\s]*) IM ON UR SPECIAL '.LOL_FNAME.' DOING '.LOL_ANY.''.LOL_CMT.'[\s]*$/', '$1 \$this->$2( $3 ); $4', |
96 | | - '/^([\s]*) IM ON UR SPECIAL '.LOL_FNAME.'[\s]*/', '$1 \$this->$2();', |
97 | | - '/^([\s]*) IM ON UR '.LOL_FNAME.' DOING(.+)'.LOL_CMT.'[\s]+/', '$1 $2( $3 ); $4', |
98 | | - '/^([\s]*) IM ON UR '.LOL_FNAME.'[\s]+/', '$1 $2();', |
99 | | - '/^([\s]*) '.LOL_LABEL.' UPUP[\s]+/', '$1 $2++', |
100 | | - |
101 | | - '/^([\s]*) IM IN UR SPECIAL '.LOL_FNAME.'[\s]+/', '$1 class $2 {', |
102 | | - '/^([\s]*) I ALWAYZ HAS '.LOL_FNAME.' IZ (.+)[\s]+/', '$1 const $2 = $3', |
103 | | - '/^([\s]*) IM IN UR '.LOL_LABEL.' ITZA (.+)[\s]+/', '$1 foreach ( \$$2 as \$$3 ) {', |
104 | | - '/^([\s]*) STEALIN UR (.+)[\s]+/', '$1 while( $2 ) {', |
105 | | - |
106 | | - '/^([\s]*) I FOUND MAH (.*)[\s]+/', '$1 return $2;', |
107 | | - |
108 | | - '/^([\s]*) UR SPECIAL '.LOL_FNAME.' IZ EMPTY[\s]*/', '$1 \$this->$2 = array()', |
109 | | - '/^([\s]*) UR SPECIAL '.LOL_FNAME.' IZ BUCKET[\s]+/', '$1 \$this->$2 = array(', |
110 | | - '/^([\s]*) UR SPECIAL '.LOL_FNAME.' IZ '.LOL_ANY.''.LOL_CMT.'[\s]*$/', '$1 \$this->$2 = $3 $4', |
111 | | - '/^([\s]*)'.LOL_LABEL.' IZ (.*)[\s]+/', '$1 \$$2 = $3', |
112 | | - '/^([\s]*)'.LOL_LABEL.' HAS MOAR (.*)[\s]+/', '$1 \$$2 .= $3', |
113 | | - |
114 | | - '/^([\s]*) SO IM LIKE '.LOL_FNAME.' TESTING UR (.+)[\s]+/', '$1 function $2(){ $3 }', |
115 | | - '/^([\s]*) SO IM LIKE '.LOL_FNAME.' WITH UR (.*) TESTING UR (.+)[\s]+/', '$1 function $2( $3 ) { $4 }', |
116 | | - '/^([\s]*) SO IM LIKE '.LOL_FNAME.' WITH UR (.*)[\s]+/', '$1 function $2( $3 ) {', |
117 | | - '/^([\s]*) SO IM LIKE '.LOL_FNAME.'[\s]+/', '$1 function $2(){', |
118 | | - '/^([\s]*) SO IM ALWAYS LIKE '.LOL_FNAME.' WITH UR (.*)[\s]+/', '$1 static function $2( $3 ) {', |
119 | | - '/^([\s]*) SO IM ALWAYS LIKE '.LOL_FNAME.'[\s]+/', '$1 static function $2(){', |
120 | | - |
121 | | - '/^([\s]*) IZ '.LOL_ANY.''.LOL_CMT.'[\s]+$/', '$1 if( $2 ) { $3', |
122 | | - '/^([\s]*) ORLY '.LOL_ANY.''.LOL_CMT.'[\s]+$/', '$1 } elseif( $2 ) { $3', |
123 | | - '/^([\s]*) NOWAI[\s]+/', '$1 } else {', |
124 | | - |
125 | | - '/^([\s]*) BTW (.*)[\s]*/', '$1 # $2', |
126 | | - '/^([\s]*) DO NOT WANT[\s]*/', '$1 /**', |
127 | | - '/^([\s]*) WANT[\s]*/', '$1 */', |
128 | | - '/^([\s]*) NOT WANT (.*)[\s]*/', '$1 * $2', |
129 | | - |
130 | | - '/^([\s]*) BUCKET[\s]*/', '$1 );', |
131 | | - '/^([\s]*) KTHX[\s]*/', '$1 }', |
132 | | - ); |
133 | | - |
134 | | - $code = is_array( $code ) |
135 | | - ? $code |
136 | | - : explode("\n",$code); |
137 | | - |
138 | | - $search = array(); |
139 | | - $replace = array(); |
140 | | - foreach( $$dir as $key => $var ){ |
141 | | - if( 1 & $key ) { |
142 | | - $replace[] = $var; |
143 | | - } else { |
144 | | - $search[] = $var; |
145 | | - } |
146 | | - } |
147 | | - |
148 | | - $code = preg_replace( $search, $replace, $code ); |
149 | | - $code = implode( "\n", $code ); |
150 | | - return $code; |
151 | | -} |
152 | | - |
153 | | - |
154 | | - |
155 | | -## Parser implementation ## |
156 | | -if( false ){ # set to false to disable |
157 | | - $lol = file( dirname(__FILE__).'/Parser.lol', FILE_IGNORE_NEW_LINES ); |
158 | | - $php = lol_core_parse( $lol ); |
159 | | - try { |
160 | | - eval( $php ); |
161 | | - } catch ( Exception $e ){ |
162 | | - require_once( 'Parser.php' ); |
163 | | - } |
164 | | -} else { |
165 | | - # You're no fun... |
166 | | - require_once( 'Parser.php' ); |
167 | | -} |
168 | | - |
169 | | - |
170 | | - |
171 | | - |
Index: trunk/phase3/includes/AutoLoader.php |
— | — | @@ -463,7 +463,7 @@ |
464 | 464 | 'PPNode_Hash_Tree' => 'includes/parser/Preprocessor_Hash.php', |
465 | 465 | 'PPTemplateFrame_DOM' => 'includes/parser/Preprocessor_DOM.php', |
466 | 466 | 'PPTemplateFrame_Hash' => 'includes/parser/Preprocessor_Hash.php', |
467 | | - 'Parser' => 'includes/parser/LOLParser.php', |
| 467 | + 'Parser' => 'includes/parser/Parser.php', |
468 | 468 | 'ParserCache' => 'includes/parser/ParserCache.php', |
469 | 469 | 'ParserOptions' => 'includes/parser/ParserOptions.php', |
470 | 470 | 'ParserOutput' => 'includes/parser/ParserOutput.php', |