Index: trunk/extensions/DidYouMean/DidYouMean.php |
— | — | @@ -90,16 +90,18 @@ |
91 | 91 | |
92 | 92 | if (preg_match( "/{{[sS]ee\|([^}]*)}}/", $text, $see )) { |
93 | 93 | wfDebug( "HIPP: see Hit\n" ); |
| 94 | + $hasTemplate = true; |
94 | 95 | $sees = explode("|", $see[1]); |
95 | 96 | } elseif (preg_match( "/{{[xX]see(\|[^}]*)}}/", $text, $see )) { |
96 | 97 | wfDebug( "HIPP: xsee Hit\n" ); |
| 98 | + $hasTemplate = true; |
97 | 99 | preg_match_all( "/\|\[\[([^]|]*)(?:\|([^|]*))?\]\](?: \(([^)]*)\))?/", $see[1], $ma ); |
98 | 100 | $sees = $ma[1]; |
99 | 101 | } else { |
100 | 102 | wfDebug( "HIPP: (x)see Miss\n" ); |
101 | 103 | # there's no {{see}} in this chunk of wikitext |
102 | 104 | # if this is the 1st chunk of the article itself we can put an empty {{see}} there. |
103 | | - $text = "{{see|}}\n" . $text; |
| 105 | + $hasTemplate = false; |
104 | 106 | $sees = array(); |
105 | 107 | } |
106 | 108 | |
— | — | @@ -118,10 +120,15 @@ |
119 | 121 | |
120 | 122 | # TODO is it better to use $parser->insertStripItem() ? |
121 | 123 | |
122 | | - if (count($sees)) |
| 124 | + if (count($sees)) { |
| 125 | + if( !$hasTemplate ) { |
| 126 | + // We need to squish in a fresh copy of the template... |
| 127 | + $text = "{{see|}}\n" . $text; |
| 128 | + } |
123 | 129 | $built_sees = build_sees($sees); |
124 | | - else |
| 130 | + } else { |
125 | 131 | $built_sees = ''; |
| 132 | + } |
126 | 133 | |
127 | 134 | $text = preg_replace( |
128 | 135 | '/{{[xX]?[sS]ee\|[^}]*}}/', |
— | — | @@ -297,10 +304,10 @@ |
298 | 305 | return true; |
299 | 306 | |
300 | 307 | if ($article->isRedirect($text)) { |
301 | | - if (!$wgParser->mDymRedirBeforeEdit && !($flags & EDIT_NEW)) |
| 308 | + if (empty( $wgParser->mDymRedirBeforeEdit ) && !($flags & EDIT_NEW)) |
302 | 309 | wfDymDoDelete( $article->getID() ); |
303 | 310 | } else { |
304 | | - if ($wgParser->mDymRedirBeforeEdit || $flags & EDIT_NEW) |
| 311 | + if (!empty( $wgParser->mDymRedirBeforeEdit ) || $flags & EDIT_NEW) |
305 | 312 | wfDymDoInsert( $article->getID(), $article->getTitle()->getText() ); |
306 | 313 | } |
307 | 314 | |