Index: trunk/extensions/InlineEditor/InlineEditor.class.php |
— | — | @@ -6,63 +6,63 @@ |
7 | 7 | * able to pass this object to different hook functions. |
8 | 8 | */ |
9 | 9 | class InlineEditor { |
10 | | - private static $fallbackReason; ///< reason for not using the editor, used for showing a message |
11 | | - const REASON_BROWSER = 1; ///< reason is an incompatible browser |
12 | | - const REASON_ADVANCED = 2; ///< reason is editing an 'advanced' page, whatever that may be |
13 | | - |
14 | | - private $article; ///< Article object to edit |
15 | | - private $editModes; ///< array of different edit modes, see addEditMode() |
16 | | - private $extendedEditPage; ///< ExtendedEditPage object we're using to handle editor logic |
17 | | - |
| 10 | + private static $fallbackReason; /// < reason for not using the editor, used for showing a message |
| 11 | + const REASON_BROWSER = 1; /// < reason is an incompatible browser |
| 12 | + const REASON_ADVANCED = 2; /// < reason is editing an 'advanced' page, whatever that may be |
| 13 | + |
| 14 | + private $article; /// < Article object to edit |
| 15 | + private $editModes; /// < array of different edit modes, see addEditMode() |
| 16 | + private $extendedEditPage; /// < ExtendedEditPage object we're using to handle editor logic |
| 17 | + |
18 | 18 | /** |
19 | 19 | * Main entry point, hooks into MediaWikiPerformAction. |
20 | 20 | * Checks whether or not to spawn the editor, and does so if nessicary. |
21 | 21 | */ |
22 | 22 | public static function mediaWikiPerformAction( $output, $article, $title, $user, $request, $wiki ) { |
23 | 23 | global $wgHooks; |
24 | | - |
| 24 | + |
25 | 25 | // the action of the page, i.e. 'view' or 'edit' |
26 | 26 | $action = $wiki->getVal( 'Action' ); |
27 | | - |
| 27 | + |
28 | 28 | // check if the editor could be used on this page, and if so, hide the [edit] links |
29 | 29 | if ( self::isValidBrowser() && !self::isAdvancedPage( $article, $title ) ) { |
30 | 30 | self::hideEditSection( $output ); |
31 | 31 | } |
32 | | - |
| 32 | + |
33 | 33 | // return if the action is not 'edit' or if it's disabled |
34 | | - if( $action != 'edit' || in_array( $action, $wiki->getVal( 'DisabledActions', array() ) ) ) |
| 34 | + if ( $action != 'edit' || in_array( $action, $wiki->getVal( 'DisabledActions', array() ) ) ) |
35 | 35 | { |
36 | 36 | return true; |
37 | 37 | } |
38 | | - |
| 38 | + |
39 | 39 | // check if the 'fulleditor' parameter is set either in GET or POST |
40 | 40 | if ( $request->getCheck( 'fulleditor' ) ) { |
41 | 41 | // hook into the edit page to inject the hidden 'fulleditor' input field again |
42 | 42 | $wgHooks['EditPage::showEditForm:fields'][] = 'InlineEditor::showEditFormFields'; |
43 | 43 | return true; |
44 | 44 | } |
45 | | - |
| 45 | + |
46 | 46 | // terminate if the browser is not supported |
47 | | - if( !self::isValidBrowser() ) { |
| 47 | + if ( !self::isValidBrowser() ) { |
48 | 48 | self::$fallbackReason = self::REASON_BROWSER; |
49 | 49 | return true; |
50 | 50 | } |
51 | | - |
| 51 | + |
52 | 52 | // terminate if we consider this page 'advanced' |
53 | | - if( self::isAdvancedPage( $article, $title ) ) { |
| 53 | + if ( self::isAdvancedPage( $article, $title ) ) { |
54 | 54 | self::$fallbackReason = self::REASON_ADVANCED; |
55 | 55 | return true; |
56 | 56 | } |
57 | | - |
| 57 | + |
58 | 58 | // start the session if needed |
59 | | - if( session_id() == '' ) { |
| 59 | + if ( session_id() == '' ) { |
60 | 60 | wfSetupSession(); |
61 | 61 | } |
62 | | - |
| 62 | + |
63 | 63 | // try to spawn the editor and render the page |
64 | 64 | $editor = new InlineEditor( $article ); |
65 | | - if( $editor->render( $output ) ) { |
66 | | - return false; |
| 65 | + if ( $editor->render( $output ) ) { |
| 66 | + return false; |
67 | 67 | } |
68 | 68 | else { |
69 | 69 | // if rendering fails for some reason, terminate and show the advanced page notice |
— | — | @@ -70,19 +70,19 @@ |
71 | 71 | return true; |
72 | 72 | } |
73 | 73 | } |
74 | | - |
| 74 | + |
75 | 75 | /** |
76 | 76 | * Hooks into EditPage::showEditForm:initial. Shows a message if there is a fallback reason set. |
77 | | - * @param $editPage EditPage |
| 77 | + * @param $editPage EditPage |
78 | 78 | */ |
79 | 79 | public static function showEditForm( &$editPage ) { |
80 | 80 | global $wgExtensionAssetsPath, $wgOut, $wgRequest; |
81 | | - |
| 81 | + |
82 | 82 | // check for a fallback reason |
83 | | - if( isset( self::$fallbackReason ) ) { |
| 83 | + if ( isset( self::$fallbackReason ) ) { |
84 | 84 | // add the style for fallback message |
85 | 85 | $wgOut->addExtensionStyle( $wgExtensionAssetsPath . "/InlineEditor/EditForm.css?0" ); |
86 | | - |
| 86 | + |
87 | 87 | // show the appropriate message at the top of the page |
88 | 88 | switch( self::$fallbackReason ) { |
89 | 89 | case self::REASON_BROWSER: |
— | — | @@ -93,19 +93,19 @@ |
94 | 94 | break; |
95 | 95 | } |
96 | 96 | } |
97 | | - |
| 97 | + |
98 | 98 | return true; |
99 | 99 | } |
100 | | - |
| 100 | + |
101 | 101 | /** |
102 | 102 | * Prepends a fallback message at the top of the page. |
103 | 103 | * @param $html String with correct HTML |
104 | 104 | */ |
105 | 105 | private static function prependFallbackMessage( $html ) { |
106 | 106 | global $wgOut; |
107 | | - $wgOut->prependHTML( '<div class="inlineEditorMessage">' . $html . '</div>'); |
| 107 | + $wgOut->prependHTML( '<div class="inlineEditorMessage">' . $html . '</div>' ); |
108 | 108 | } |
109 | | - |
| 109 | + |
110 | 110 | /** |
111 | 111 | * Checks if the browser is supported. |
112 | 112 | * This function is borrowed from EditPage::checkUnicodeCompliantBrowser(). |
— | — | @@ -118,13 +118,13 @@ |
119 | 119 | } |
120 | 120 | $currentbrowser = $_SERVER["HTTP_USER_AGENT"]; |
121 | 121 | foreach ( $wgInlineEditorBrowserBlacklist as $browser ) { |
122 | | - if ( preg_match($browser, $currentbrowser) ) { |
| 122 | + if ( preg_match( $browser, $currentbrowser ) ) { |
123 | 123 | return false; |
124 | 124 | } |
125 | 125 | } |
126 | 126 | return true; |
127 | 127 | } |
128 | | - |
| 128 | + |
129 | 129 | /** |
130 | 130 | * Check if the page is 'advanced'. For now, that means it has to be in an allowed namespace. |
131 | 131 | * @param $article Article |
— | — | @@ -133,13 +133,13 @@ |
134 | 134 | */ |
135 | 135 | private static function isAdvancedPage( &$article, &$title ) { |
136 | 136 | global $wgInlineEditorAllowedNamespaces; |
137 | | - if( !empty( $wgInlineEditorAllowedNamespaces ) |
| 137 | + if ( !empty( $wgInlineEditorAllowedNamespaces ) |
138 | 138 | && !in_array( $title->getNamespace(), $wgInlineEditorAllowedNamespaces ) ) { |
139 | 139 | return true; |
140 | 140 | } |
141 | 141 | return false; |
142 | 142 | } |
143 | | - |
| 143 | + |
144 | 144 | /** |
145 | 145 | * Entry point for the 'Preview' function through Ajax. |
146 | 146 | * No real point in securing this, as nothing is actually saved. |
— | — | @@ -150,11 +150,11 @@ |
151 | 151 | public static function ajaxPreview( $json, $pageName ) { |
152 | 152 | $title = Title::newFromText( $pageName ); |
153 | 153 | $article = Article::newFromId( $title->getArticleId() ); |
154 | | - |
| 154 | + |
155 | 155 | $editor = new InlineEditor( $article ); |
156 | 156 | return $editor->preview( $json ); |
157 | 157 | } |
158 | | - |
| 158 | + |
159 | 159 | /** |
160 | 160 | * Hide the [edit] links on the page by enabling a piece of CSS (instead of screwing with the parser cache). |
161 | 161 | * @param $output OutputPage |
— | — | @@ -163,7 +163,7 @@ |
164 | 164 | global $wgExtensionAssetsPath; |
165 | 165 | $output->addExtensionStyle( $wgExtensionAssetsPath . "/InlineEditor/HideEditSection.css?0" ); |
166 | 166 | } |
167 | | - |
| 167 | + |
168 | 168 | /** |
169 | 169 | * Add a 'fulleditor' hidden input field to the normal edit page |
170 | 170 | * @param $editpage EditPage |
— | — | @@ -171,11 +171,11 @@ |
172 | 172 | */ |
173 | 173 | public static function showEditFormFields( &$editpage, &$output ) { |
174 | 174 | $output->addHTML( |
175 | | - HTML::rawElement( 'input', array( 'name' => 'fulleditor', 'type' => 'hidden', 'value' => '1' )) |
| 175 | + HTML::rawElement( 'input', array( 'name' => 'fulleditor', 'type' => 'hidden', 'value' => '1' ) ) |
176 | 176 | ); |
177 | 177 | return true; |
178 | 178 | } |
179 | | - |
| 179 | + |
180 | 180 | /** |
181 | 181 | * Constructor which takes only an Article object |
182 | 182 | * @param $article Article |
— | — | @@ -184,7 +184,7 @@ |
185 | 185 | $this->article = $article; |
186 | 186 | $editmodes = array(); |
187 | 187 | } |
188 | | - |
| 188 | + |
189 | 189 | /** |
190 | 190 | * Render the editor. |
191 | 191 | * Spawns an ExtendedEditPage which is an EditPage with some specific logic for this editor. |
— | — | @@ -195,43 +195,43 @@ |
196 | 196 | */ |
197 | 197 | public function render( &$output ) { |
198 | 198 | global $wgParser, $wgHooks, $wgRequest, $wgExtensionAssetsPath; |
199 | | - |
| 199 | + |
200 | 200 | // create an InlineEditorText object which generates the HTML and JSON for the editor |
201 | 201 | $text = new InlineEditorText( $this->article ); |
202 | | - |
| 202 | + |
203 | 203 | // if the page is being saved, retrieve the wikitext from the JSON |
204 | | - if( $wgRequest->wasPosted() ) { |
| 204 | + if ( $wgRequest->wasPosted() ) { |
205 | 205 | $text->loadFromJson( $wgRequest->getVal( 'json' ) ); |
206 | 206 | $wgRequest->setVal( 'wpTextbox1', $text->getWikiOriginal() ); |
207 | 207 | } |
208 | | - |
| 208 | + |
209 | 209 | // try to init, or else return false, which will spawn an 'advanced page' notice |
210 | 210 | $this->extendedEditPage = new ExtendedEditPage( $this->article ); |
211 | | - if( $this->extendedEditPage->initInlineEditor() ) { |
| 211 | + if ( $this->extendedEditPage->initInlineEditor() ) { |
212 | 212 | // IMPORTANT: if the page was being saved, the script has been terminated by now!! |
213 | | - |
| 213 | + |
214 | 214 | // include the required JS and CSS files |
215 | 215 | $output->includeJQuery(); |
216 | 216 | $output->addScriptFile( $wgExtensionAssetsPath . "/InlineEditor/jquery.inlineEditor.js?0" ); |
217 | 217 | $output->addScriptFile( $wgExtensionAssetsPath . "/InlineEditor/jquery.inlineEditor.basicEditor.js?0" ); |
218 | 218 | $output->addScriptFile( $wgExtensionAssetsPath . "/InlineEditor/jquery-ui-effects-1.8.4.min.js?0" ); |
219 | 219 | $output->addExtensionStyle( $wgExtensionAssetsPath . "/InlineEditor/InlineEditor.css?0" ); |
220 | | - |
| 220 | + |
221 | 221 | // have the different kind of editors register themselves |
222 | 222 | wfRunHooks( 'InlineEditorDefineEditors', array( &$this, &$output ) ); |
223 | | - |
| 223 | + |
224 | 224 | // load the wikitext into the InlineEditorText object |
225 | 225 | $text->loadFromWikiText( $this->extendedEditPage->getWikiText() ); |
226 | | - |
| 226 | + |
227 | 227 | // add a large <div> around the marked wikitext to denote the editing position |
228 | 228 | $parserOutput = $text->getParserOutputMarked(); |
229 | 229 | $parserOutput->setText( '<div id="editContent">' . $parserOutput->getText() . '</div>' ); |
230 | | - |
| 230 | + |
231 | 231 | // put the marked output into the page |
232 | 232 | $output->addParserOutput( $parserOutput ); |
233 | | - |
| 233 | + |
234 | 234 | // add the different edit modes and initial JSON state in Javascript, and finally init the editor |
235 | | - $output->addInlineScript( |
| 235 | + $output->addInlineScript( |
236 | 236 | 'jQuery( document ).ready( function() { |
237 | 237 | jQuery.inlineEditor.editModes = ["' . implode( '","', array_keys( $this->editModes ) ) . '"]; |
238 | 238 | jQuery.inlineEditor.currentMode = "' . reset( $this->editModes ) . '"; |
— | — | @@ -239,7 +239,7 @@ |
240 | 240 | jQuery.inlineEditor.init(); |
241 | 241 | } );' |
242 | 242 | ); |
243 | | - |
| 243 | + |
244 | 244 | // hook into SiteNoticeBefore to display the two boxes above the title |
245 | 245 | // @todo: fix this in core, make sure that anything can be inserted above the title, outside #siteNotice |
246 | 246 | $wgHooks['SiteNoticeBefore'][] = array( $this, 'siteNoticeBefore' ); |
— | — | @@ -249,7 +249,7 @@ |
250 | 250 | return false; |
251 | 251 | } |
252 | 252 | } |
253 | | - |
| 253 | + |
254 | 254 | /** |
255 | 255 | * Get the Article being edited |
256 | 256 | * @return Article |
— | — | @@ -257,7 +257,7 @@ |
258 | 258 | public function getArticle() { |
259 | 259 | return $this->article; |
260 | 260 | } |
261 | | - |
| 261 | + |
262 | 262 | /** |
263 | 263 | * Pass JSON into an InlineEditorText object and return combined JSON (HTML + sentence representation) |
264 | 264 | * @param $json String |
— | — | @@ -268,23 +268,23 @@ |
269 | 269 | $text->loadFromJson( $json ); |
270 | 270 | return $text->getCombinedJson(); |
271 | 271 | } |
272 | | - |
| 272 | + |
273 | 273 | /** |
274 | | - * Hooks into SiteNoticeBefore. Renders the edit interface above the title of the page. |
| 274 | + * Hooks into SiteNoticeBefore. Renders the edit interface above the title of the page. |
275 | 275 | * @param $siteNotice String |
276 | 276 | */ |
277 | 277 | public function siteNoticeBefore( &$siteNotice ) { |
278 | 278 | $siteNotice = $this->renderEditBox() . $this->renderEditModes(); |
279 | 279 | return false; |
280 | 280 | } |
281 | | - |
| 281 | + |
282 | 282 | /** |
283 | 283 | * Add an edit mode to the list. |
284 | 284 | * @param $name String Name to be used in id-fields |
285 | 285 | * @param $caption String Name to be displayed |
286 | 286 | * @param $description String Description to be displayed when the mode is selected (*escaped* HTML only!) |
287 | 287 | */ |
288 | | - public function addEditMode($name, $caption, $description) { |
| 288 | + public function addEditMode( $name, $caption, $description ) { |
289 | 289 | $this->editModes[$name] = array( |
290 | 290 | 'radioid' => 'radio-' . $name, |
291 | 291 | 'descriptionid' => 'description-' . $name, |
— | — | @@ -292,19 +292,19 @@ |
293 | 293 | 'description' => $description |
294 | 294 | ); |
295 | 295 | } |
296 | | - |
| 296 | + |
297 | 297 | /** |
298 | 298 | * Generates "Edit box" (the first one) |
299 | 299 | * This looks like this: |
300 | 300 | * <div class="editbox"> |
301 | 301 | * inline-editor-editbox-top |
302 | 302 | * <hr/> |
303 | | - * |
| 303 | + * |
304 | 304 | * inline-editor-editbox-changes-question |
305 | 305 | * <input class="summary" name="summary" /> |
306 | 306 | * <div class="example">inline-editor-editbox-changes-example</div> |
307 | 307 | * <hr/> |
308 | | - * |
| 308 | + * |
309 | 309 | * <div class="side"> |
310 | 310 | * inline-editor-editbox-publish-notice |
311 | 311 | * <div class="terms">inline-editor-editbox-publish-terms</div> |
— | — | @@ -315,31 +315,33 @@ |
316 | 316 | private function renderEditBox() { |
317 | 317 | $top = wfMsgExt( 'inline-editor-editbox-top', 'parseinline' ); |
318 | 318 | $top .= '<hr/>'; |
319 | | - |
| 319 | + |
320 | 320 | $summary = wfMsgExt( 'inline-editor-editbox-changes-question', 'parseinline' ); |
321 | | - $summary .= Html::input( 'wpSummary', $this->extendedEditPage->getSummary(), |
| 321 | + $summary .= Html::input( 'wpSummary', $this->extendedEditPage->getSummary(), |
322 | 322 | 'text', array( 'class' => 'summary', 'maxlength' => 250 ) ); |
323 | | - $summary .= Html::rawElement( 'div', array( 'class' => 'example' ), |
| 323 | + $summary .= Html::rawElement( 'div', array( 'class' => 'example' ), |
324 | 324 | wfMsgExt( 'inline-editor-editbox-changes-example', 'parseinline' ) ); |
325 | 325 | $summary .= '<hr/>'; |
326 | | - |
327 | | - $terms = Html::rawElement( 'div', array( 'class' => 'terms' ), |
328 | | - wfMsgExt( 'inline-editor-editbox-publish-terms', 'parseinline', '[[' . wfMsgForContent( 'copyrightpage' ) . ']]' ) ); |
329 | | - $publish = Html::rawElement( 'div', array( 'class' => 'side' ), |
330 | | - wfMsgExt( 'inline-editor-editbox-publish-notice', 'parseinline' ) . $terms ); |
| 326 | + |
| 327 | + $terms = Html::rawElement( 'div', array( 'class' => 'terms' ), |
| 328 | + // @todo FIXME: Create a link to content language copyrightpage with plain content |
| 329 | + // link description. |
| 330 | + wfMsgExt( 'inline-editor-editbox-publish-terms', 'parseinline', '[[' . wfMsgForContent( 'copyrightpage' ) . ']]' ) ); |
| 331 | + $publish = Html::rawElement( 'div', array( 'class' => 'side' ), |
| 332 | + wfMsgExt( 'inline-editor-editbox-publish-notice', 'parseinline' ) . $terms ); |
331 | 333 | $publish .= Html::rawElement( 'a', array( 'id' => 'publish', 'href' => '#' ), |
332 | 334 | wfMsgExt( 'inline-editor-editbox-publish-caption', 'parseinline' ) ); |
333 | | - $publish .= HTML::rawElement( 'input', array( 'id' => 'json', 'name' => 'json', 'type' => 'hidden' )); |
334 | | - |
335 | | - $form = Html::rawElement( 'form', array( |
| 335 | + $publish .= HTML::rawElement( 'input', array( 'id' => 'json', 'name' => 'json', 'type' => 'hidden' ) ); |
| 336 | + |
| 337 | + $form = Html::rawElement( 'form', array( |
336 | 338 | 'id' => 'editForm', |
337 | 339 | 'method' => 'POST', |
338 | 340 | 'action' => $this->extendedEditPage->getSubmitUrl() ), $top . $summary . $publish ); |
339 | | - |
340 | | - |
| 341 | + |
| 342 | + |
341 | 343 | return Html::rawElement( 'div', array( 'class' => 'editbox' ), $form ); |
342 | 344 | } |
343 | | - |
| 345 | + |
344 | 346 | /** |
345 | 347 | * Generates "Edit mode" box (the second one) |
346 | 348 | * This looks like this: |
— | — | @@ -359,43 +361,43 @@ |
360 | 362 | * @return string HTML |
361 | 363 | */ |
362 | 364 | private function renderEditModes() { |
363 | | - if (!isset($this->editModes)) return ''; |
364 | | - |
365 | | - $header = Html::rawElement( 'div', array( 'class' => 'radio title' ), |
| 365 | + if ( !isset( $this->editModes ) ) return ''; |
| 366 | + |
| 367 | + $header = Html::rawElement( 'div', array( 'class' => 'radio title' ), |
366 | 368 | wfMsgExt( 'inline-editor-editmodes-caption', 'parseinline' ) ); |
367 | | - |
| 369 | + |
368 | 370 | $descriptions = ''; |
369 | 371 | $first = true; |
370 | | - foreach( $this->editModes as $editmode ) { |
| 372 | + foreach ( $this->editModes as $editmode ) { |
371 | 373 | $inputOptions = array( 'id' => $editmode['radioid'], 'class' => 'optionMode' ); |
372 | | - if ($first) { |
| 374 | + if ( $first ) { |
373 | 375 | $inputOptions['checked'] = 'checked'; |
374 | 376 | $first = false; |
375 | 377 | } |
376 | 378 | $input = Html::input( 'optionMode', '', 'radio', $inputOptions ); |
377 | | - $label = Html::rawElement('label', array( 'for' => $editmode['radioid'] ), $editmode['caption'] ); |
378 | | - |
| 379 | + $label = Html::rawElement( 'label', array( 'for' => $editmode['radioid'] ), $editmode['caption'] ); |
| 380 | + |
379 | 381 | $header .= Html::rawElement( 'div', array( 'class' => 'radio' ), $input . $label ); |
380 | | - |
381 | | - $descriptions .= Html::rawElement('div', array( 'class' => 'descriptionInner', 'id' => $editmode['descriptionid']), |
| 382 | + |
| 383 | + $descriptions .= Html::rawElement( 'div', array( 'class' => 'descriptionInner', 'id' => $editmode['descriptionid'] ), |
382 | 384 | $editmode['description'] ); |
383 | 385 | } |
384 | | - |
| 386 | + |
385 | 387 | $header .= Html::rawElement( 'div', array( 'class' => 'button' ), |
386 | 388 | Html::rawElement( 'a', array( 'id' => 'redo', 'href' => '#' ), |
387 | 389 | wfMsgExt( 'inline-editor-editmodes-redo', 'parseinline' ) ) |
388 | 390 | ); |
389 | 391 | $header .= Html::rawElement( 'div', array( 'class' => 'button' ), |
390 | 392 | Html::rawElement( 'a', array( 'id' => 'undo', 'href' => '#' ), |
391 | | - wfMsgExt( 'inline-editor-editmodes-undo', 'parseinline' ) ) |
| 393 | + wfMsgExt( 'inline-editor-editmodes-undo', 'parseinline' ) ) |
392 | 394 | ); |
393 | 395 | $header .= Html::rawElement( 'div', array( 'class' => 'button' ), |
394 | 396 | Html::rawElement( 'div', array( 'id' => 'editCounter', 'href' => '#' ), '#0' ) |
395 | 397 | ); |
396 | | - |
| 398 | + |
397 | 399 | return Html::rawElement( 'div', array( 'class' => 'editmode' ), |
398 | 400 | Html::rawElement( 'div', array( 'class' => 'header' ), $header ) |
399 | 401 | . Html::rawElement( 'div', array( 'class' => 'descriptionOuter' ), $descriptions ) |
400 | 402 | ); |
401 | 403 | } |
402 | | -} |
\ No newline at end of file |
| 404 | +} |
Index: trunk/extensions/InlineEditor/ListEditor/ListEditor.i18n.php |
— | — | @@ -15,10 +15,8 @@ |
16 | 16 | 'list-editor-desc' => 'Adds the "Lists" edit mode for the InlineEditor', |
17 | 17 | |
18 | 18 | 'list-editor-editmode-caption' => "Lists", |
19 | | - 'list-editor-editmode-description' => " |
20 | | -Lists work like shown below. |
21 | | -You can also make a new list by going in any other mode, like the '''Text''' mode, |
22 | | -and add a list like the one below. |
| 19 | + 'list-editor-editmode-description' => "Lists work like shown below. |
| 20 | +You can also make a new list by going in any other mode, like the '''Text''' mode, and add a list like the one below. |
23 | 21 | |
24 | 22 | {| width=\"100%\" style=\"background-color: inherit\" |
25 | 23 | ! Code |
— | — | @@ -38,6 +36,5 @@ |
39 | 37 | *** deeper levels |
40 | 38 | |} |
41 | 39 | |
42 | | -[http://meta.wikimedia.org/wiki/Help:List More information] |
43 | | - ", |
44 | | -); |
\ No newline at end of file |
| 40 | +[http://meta.wikimedia.org/wiki/Help:List More information]", |
| 41 | +); |
Index: trunk/extensions/InlineEditor/ListEditor/ListEditor.php |
— | — | @@ -38,4 +38,4 @@ |
39 | 39 | $wgHooks['InlineEditorDefineEditors'][] = 'ListEditor::defineEditors'; |
40 | 40 | |
41 | 41 | // i18n messages |
42 | | -$wgExtensionMessagesFiles['ListEditor'] = $dir . 'ListEditor.i18n.php'; |
\ No newline at end of file |
| 42 | +$wgExtensionMessagesFiles['ListEditor'] = $dir . 'ListEditor.i18n.php'; |
Index: trunk/extensions/InlineEditor/ListEditor/ListEditor.class.php |
— | — | @@ -1,9 +1,9 @@ |
2 | 2 | <?php |
| 3 | + |
3 | 4 | /** |
4 | | - * Simple editor for lists. |
| 5 | + * Simple editor for lists. |
5 | 6 | */ |
6 | 7 | class ListEditor { |
7 | | - |
8 | 8 | /** |
9 | 9 | * This function hooks into InlineEditorMark and marks the media. |
10 | 10 | * @param $inlineEditorText InlineEditorText |
— | — | @@ -11,23 +11,23 @@ |
12 | 12 | public static function mark( &$inlineEditorText ) { |
13 | 13 | // get the original wikitext |
14 | 14 | $text = $inlineEditorText->getWikiOriginal(); |
15 | | - |
| 15 | + |
16 | 16 | $matches = array(); |
17 | 17 | preg_match_all( '/(\n|^)(([*#;:].*(\n|$))+)/', $text, $matches, PREG_OFFSET_CAPTURE ); |
18 | | - |
19 | | - foreach( $matches[2] as $match ) { |
| 18 | + |
| 19 | + foreach ( $matches[2] as $match ) { |
20 | 20 | $start = $match[1]; |
21 | 21 | $end = $start + strlen( $match[0] ); |
22 | | - |
| 22 | + |
23 | 23 | // do not include the trailing newline |
24 | | - if( substr( $match[0], -1) == "\n" ) $end--; |
25 | | - |
| 24 | + if ( substr( $match[0], -1 ) == "\n" ) $end--; |
| 25 | + |
26 | 26 | $inlineEditorText->addPiece( new InlineEditorPiece( $start, $end, 'listEditorElement', false ) ); |
27 | 27 | } |
28 | | - |
| 28 | + |
29 | 29 | return true; |
30 | 30 | } |
31 | | - |
| 31 | + |
32 | 32 | /** |
33 | 33 | * Hooks into InlineEditorDefineEditors. Adds the option to to the list and adds CSS and JS files |
34 | 34 | * @param $editor InlineEditor |
— | — | @@ -35,16 +35,16 @@ |
36 | 36 | */ |
37 | 37 | public static function defineEditors( &$editor, &$output ) { |
38 | 38 | global $wgExtensionAssetsPath; |
39 | | - |
| 39 | + |
40 | 40 | $editor->addEditMode( |
41 | | - 'listEditor', |
42 | | - wfMsgExt( 'list-editor-editmode-caption', 'parseinline' ), |
43 | | - wfMsgExt( 'list-editor-editmode-description','parseinline' ) |
| 41 | + 'listEditor', |
| 42 | + wfMsgExt( 'list-editor-editmode-caption', 'parseinline' ), |
| 43 | + wfMsgExt( 'list-editor-editmode-description', 'parseinline' ) |
44 | 44 | ); |
45 | | - |
46 | | - $output->addExtensionStyle( "$wgExtensionAssetsPath/InlineEditor/ListEditor/ListEditor.css?0"); |
| 45 | + |
| 46 | + $output->addExtensionStyle( "$wgExtensionAssetsPath/InlineEditor/ListEditor/ListEditor.css?0" ); |
47 | 47 | $output->addScriptFile( "$wgExtensionAssetsPath/InlineEditor/ListEditor/jquery.inlineEditor.editors.listEditor.js?0" ); |
48 | | - |
| 48 | + |
49 | 49 | return true; |
50 | 50 | } |
51 | | -} |
\ No newline at end of file |
| 51 | +} |
Index: trunk/extensions/InlineEditor/TemplateEditor/TemplateEditor.i18n.php |
— | — | @@ -15,11 +15,8 @@ |
16 | 16 | 'template-editor-desc' => 'Adds the "Template" edit mode for the InlineEditor', |
17 | 17 | |
18 | 18 | 'template-editor-editmode-caption' => "Templates", |
19 | | - 'template-editor-editmode-description' => " |
20 | | -Templates are used to show the same thing on multiple pages. |
21 | | -To fully understand templates, you should read documentation |
22 | | -found online. |
| 19 | + 'template-editor-editmode-description' => "Templates are used to show the same thing on multiple pages. |
| 20 | +To fully understand templates, you should read documentation found online. |
23 | 21 | |
24 | | -[http://www.mediawiki.org/wiki/Help:Templates More information] |
25 | | -", |
26 | | -); |
\ No newline at end of file |
| 22 | +[http://www.mediawiki.org/wiki/Help:Templates More information].", |
| 23 | +); |
Index: trunk/extensions/InlineEditor/TemplateEditor/TemplateEditor.php |
— | — | @@ -38,4 +38,4 @@ |
39 | 39 | $wgHooks['InlineEditorDefineEditors'][] = 'TemplateEditor::defineEditors'; |
40 | 40 | |
41 | 41 | // i18n messages |
42 | | -$wgExtensionMessagesFiles['TemplateEditor'] = $dir . 'TemplateEditor.i18n.php'; |
\ No newline at end of file |
| 42 | +$wgExtensionMessagesFiles['TemplateEditor'] = $dir . 'TemplateEditor.i18n.php'; |
Index: trunk/extensions/InlineEditor/TemplateEditor/TemplateEditor.class.php |
— | — | @@ -1,9 +1,9 @@ |
2 | 2 | <?php |
| 3 | + |
3 | 4 | /** |
4 | | - * Simple editor for templates. |
| 5 | + * Simple editor for templates. |
5 | 6 | */ |
6 | 7 | class TemplateEditor { |
7 | | - |
8 | 8 | /** |
9 | 9 | * This function hooks into InlineEditorMark and marks the media. |
10 | 10 | * @param $inlineEditorText InlineEditorText |
— | — | @@ -11,19 +11,19 @@ |
12 | 12 | public static function mark( &$inlineEditorText ) { |
13 | 13 | // get the original wikitext |
14 | 14 | $text = $inlineEditorText->getWikiOriginal(); |
15 | | - |
| 15 | + |
16 | 16 | $matches = array(); |
17 | | - preg_match_all('/^(\{\{.*?\}\})/ms', $text, $matches, PREG_OFFSET_CAPTURE); |
18 | | - |
19 | | - foreach( $matches[0] as $match ) { |
| 17 | + preg_match_all( '/^(\{\{.*?\}\})/ms', $text, $matches, PREG_OFFSET_CAPTURE ); |
| 18 | + |
| 19 | + foreach ( $matches[0] as $match ) { |
20 | 20 | $start = $match[1]; |
21 | 21 | $end = $start + strlen( $match[0] ); |
22 | 22 | $inlineEditorText->addPiece( new InlineEditorPiece( $start, $end, 'templateEditorElement templateEditorElementNotEditing', false ) ); |
23 | 23 | } |
24 | | - |
| 24 | + |
25 | 25 | return true; |
26 | 26 | } |
27 | | - |
| 27 | + |
28 | 28 | /** |
29 | 29 | * Hooks into InlineEditorDefineEditors. Adds the option to to the list and adds CSS and JS files |
30 | 30 | * @param $editor InlineEditor |
— | — | @@ -31,16 +31,16 @@ |
32 | 32 | */ |
33 | 33 | public static function defineEditors( &$editor, &$output ) { |
34 | 34 | global $wgExtensionAssetsPath; |
35 | | - |
| 35 | + |
36 | 36 | $editor->addEditMode( |
37 | | - 'templateEditor', |
38 | | - wfMsgExt( 'template-editor-editmode-caption', 'parseinline' ), |
39 | | - wfMsgExt( 'template-editor-editmode-description','parseinline' ) |
| 37 | + 'templateEditor', |
| 38 | + wfMsgExt( 'template-editor-editmode-caption', 'parseinline' ), |
| 39 | + wfMsgExt( 'template-editor-editmode-description', 'parseinline' ) |
40 | 40 | ); |
41 | | - |
42 | | - $output->addExtensionStyle( "$wgExtensionAssetsPath/InlineEditor/TemplateEditor/TemplateEditor.css?0"); |
| 41 | + |
| 42 | + $output->addExtensionStyle( "$wgExtensionAssetsPath/InlineEditor/TemplateEditor/TemplateEditor.css?0" ); |
43 | 43 | $output->addScriptFile( "$wgExtensionAssetsPath/InlineEditor/TemplateEditor/jquery.inlineEditor.editors.templateEditor.js?0" ); |
44 | | - |
| 44 | + |
45 | 45 | return true; |
46 | 46 | } |
47 | | -} |
\ No newline at end of file |
| 47 | +} |
Index: trunk/extensions/InlineEditor/InlineEditorText.class.php |
— | — | @@ -3,19 +3,19 @@ |
4 | 4 | /** |
5 | 5 | * Stores wikitext, pieces and previous markings, and generates HTML and JSON from them. |
6 | 6 | * Can import wikitext and previous markings from JSON and from an original article. |
7 | | - * |
| 7 | + * |
8 | 8 | * Computation path is as follows: |
9 | | - * |
| 9 | + * |
10 | 10 | * First time editing the page: |
11 | 11 | * wikitext from article => adding of new pieces => generating HTML (using parser) and JSON array |
12 | | - * |
| 12 | + * |
13 | 13 | * Previewing the page: |
14 | 14 | * JSON array with pieces + last edit diff => adding of new pieces |
15 | 15 | * => computing overlap of pieces with previous markings => generating HTML (using parser) and JSON array |
16 | 16 | * => generating combined JSON array |
17 | 17 | * |
18 | 18 | * Saving the page: |
19 | | - * JSON array with pieces => new wikitext |
| 19 | + * JSON array with pieces => new wikitext |
20 | 20 | * |
21 | 21 | */ |
22 | 22 | class InlineEditorText { |
— | — | @@ -27,7 +27,7 @@ |
28 | 28 | private $article; |
29 | 29 | private $pieces; |
30 | 30 | private $previousMarkings; |
31 | | - |
| 31 | + |
32 | 32 | /** |
33 | 33 | * @param $article Article The article to work with. |
34 | 34 | */ |
— | — | @@ -36,7 +36,7 @@ |
37 | 37 | $this->pieces = array(); |
38 | 38 | $this->previousMarkings = array(); |
39 | 39 | } |
40 | | - |
| 40 | + |
41 | 41 | /** |
42 | 42 | * Load the original wikitext from $wikiText. |
43 | 43 | * @param $wikiText String |
— | — | @@ -45,53 +45,53 @@ |
46 | 46 | $this->reset(); |
47 | 47 | $this->wikiOriginal = $wikiText; |
48 | 48 | } |
49 | | - |
| 49 | + |
50 | 50 | /** |
51 | 51 | * Get the original wikitext. |
52 | 52 | * @return String Original wikitext |
53 | 53 | */ |
54 | 54 | public function getWikiOriginal() { |
55 | | - return $this->wikiOriginal; |
| 55 | + return $this->wikiOriginal; |
56 | 56 | } |
57 | | - |
| 57 | + |
58 | 58 | /** |
59 | 59 | * Get the HTML with <span> and <div> markings. |
60 | 60 | * @return String HTML |
61 | 61 | */ |
62 | 62 | public function getParserOutputMarked() { |
63 | | - if( !isset( $this->parserOutputMarked ) ) $this->process(); |
64 | | - return $this->parserOutputMarked; |
| 63 | + if ( !isset( $this->parserOutputMarked ) ) $this->process(); |
| 64 | + return $this->parserOutputMarked; |
65 | 65 | } |
66 | | - |
| 66 | + |
67 | 67 | /** |
68 | 68 | * Get JSON representation of the wikitext and markings. |
69 | 69 | * @return String JSON |
70 | 70 | */ |
71 | 71 | public function getWikiJson() { |
72 | | - if( !isset( $this->wikiJsonText ) ) $this->toJsonText(); |
73 | | - return $this->wikiJsonText; |
| 72 | + if ( !isset( $this->wikiJsonText ) ) $this->toJsonText(); |
| 73 | + return $this->wikiJsonText; |
74 | 74 | } |
75 | | - |
| 75 | + |
76 | 76 | /** |
77 | 77 | * Get a combined JSON representation of the wikitext with markings, and marked HTML. |
78 | 78 | * @return String JSON with HTML in it |
79 | 79 | */ |
80 | 80 | public function getCombinedJson() { |
81 | | - if( !isset( $this->combinedJson ) ) $this->toCombinedJson(); |
| 81 | + if ( !isset( $this->combinedJson ) ) $this->toCombinedJson(); |
82 | 82 | return $this->combinedJson; |
83 | 83 | } |
84 | | - |
| 84 | + |
85 | 85 | /** |
86 | | - * Add a marking piece to the list of pieces. To be called by the different edit modes. |
| 86 | + * Add a marking piece to the list of pieces. To be called by the different edit modes. |
87 | 87 | * @param $piece InlineEditorPiece |
88 | 88 | */ |
89 | 89 | public function addPiece( InlineEditorPiece $piece ) { |
90 | | - if( isset( $this->pieces[$piece->getStart()] ) ) return; |
91 | | - if( !$piece->isValid() ) return; |
92 | | - |
| 90 | + if ( isset( $this->pieces[$piece->getStart()] ) ) return; |
| 91 | + if ( !$piece->isValid() ) return; |
| 92 | + |
93 | 93 | $this->pieces[$piece->getStart()] = $piece; |
94 | 94 | } |
95 | | - |
| 95 | + |
96 | 96 | /** |
97 | 97 | * Reset the object. |
98 | 98 | */ |
— | — | @@ -104,7 +104,7 @@ |
105 | 105 | $this->pieces = array(); |
106 | 106 | $this->previousMarkings = array(); |
107 | 107 | } |
108 | | - |
| 108 | + |
109 | 109 | /** |
110 | 110 | * Load original wikitext and previous markings from JSON |
111 | 111 | * @param $json String JSON string from the client side editor |
— | — | @@ -112,74 +112,74 @@ |
113 | 113 | public function loadFromJson( $json ) { |
114 | 114 | // first of all, reset the object |
115 | 115 | $this->reset(); |
116 | | - |
| 116 | + |
117 | 117 | // decode the JSON to an associative array |
118 | 118 | $input = FormatJson::decode( $json, true ); |
119 | | - |
| 119 | + |
120 | 120 | // if the 'lastEdit' attribute is set, this contains the edit the user made |
121 | 121 | // the original text is kept intact, but we don't need it, so just overwrite it with the new text |
122 | | - if( isset($input['lastEdit']) ) { |
| 122 | + if ( isset( $input['lastEdit'] ) ) { |
123 | 123 | $input['originalWiki']['locations'][$input['lastEdit']['id']]['text'] = $input['lastEdit']['text']; |
124 | 124 | } |
125 | | - |
| 125 | + |
126 | 126 | // convert the 'locations' array (by id) to the $pieces array (by position) |
127 | 127 | $pieces = array(); |
128 | | - foreach( $input['originalWiki']['locations'] as $id => $piece ) { |
| 128 | + foreach ( $input['originalWiki']['locations'] as $id => $piece ) { |
129 | 129 | $piece['id'] = $id; |
130 | 130 | $pieces[$piece['pos']] = $piece; |
131 | 131 | } |
132 | | - |
| 132 | + |
133 | 133 | // sort the $pieces array by position |
134 | | - ksort($pieces); |
135 | | - |
| 134 | + ksort( $pieces ); |
| 135 | + |
136 | 136 | // init loop variables |
137 | 137 | $text = ''; // reconstructed wikitext |
138 | 138 | $lastPos = 0; // position in the text of the previous piece |
139 | 139 | $offset = 0; // total amount of wikitext *inside* pieces so far |
140 | | - |
| 140 | + |
141 | 141 | // iterate on all pieces |
142 | | - foreach( $pieces as $pos => $piece) { |
| 142 | + foreach ( $pieces as $pos => $piece ) { |
143 | 143 | // calculate the length of the piece |
144 | 144 | $length = strlen( $piece['text'] ); |
145 | | - |
| 145 | + |
146 | 146 | // add the wikitext between the previous piece and this piece |
147 | 147 | $text .= substr( $input['originalWiki']['text'], $lastPos, $pos - $lastPos ); |
148 | | - |
| 148 | + |
149 | 149 | // add the wikitext of the piece itself |
150 | 150 | $text .= $piece['text']; |
151 | | - |
| 151 | + |
152 | 152 | // if this piece was last edited or marked before, add it to previousMarkings |
153 | | - if( ( isset( $input['lastEdit'] ) && $input['lastEdit']['id'] == $piece['id'] ) |
154 | | - || $piece['edited'] ) |
| 153 | + if ( ( isset( $input['lastEdit'] ) && $input['lastEdit']['id'] == $piece['id'] ) |
| 154 | + || $piece['edited'] ) |
155 | 155 | { |
156 | 156 | // because these positions are within the text *with* the pieces included, |
157 | 157 | // the position has to be offsetted by exactly the total length of pieces so far |
158 | 158 | $previousStart = $pos + $offset; |
159 | 159 | $previousMarking = new InlineEditorPreviousMarking( $previousStart, $previousStart + $length ); |
160 | 160 | $previousMarking->setEdited( true ); |
161 | | - |
162 | | - if( isset( $input['lastEdit'] ) && $input['lastEdit']['id'] == $piece['id'] ) { |
| 161 | + |
| 162 | + if ( isset( $input['lastEdit'] ) && $input['lastEdit']['id'] == $piece['id'] ) { |
163 | 163 | $previousMarking->setLastEdit( true ); |
164 | 164 | } |
165 | | - |
| 165 | + |
166 | 166 | // last sanity check before adding the marking |
167 | | - if( $previousMarking->isValid() ) { |
| 167 | + if ( $previousMarking->isValid() ) { |
168 | 168 | $this->previousMarkings[$previousStart] = $previousMarking; |
169 | 169 | } |
170 | 170 | } |
171 | | - |
| 171 | + |
172 | 172 | // set variables for next round |
173 | | - $lastPos = $pos; |
174 | | - $offset += $length; |
| 173 | + $lastPos = $pos; |
| 174 | + $offset += $length; |
175 | 175 | } |
176 | | - |
| 176 | + |
177 | 177 | // add the text after the last piece |
178 | 178 | $text .= substr( $input['originalWiki']['text'], $lastPos ); |
179 | | - |
| 179 | + |
180 | 180 | // store it as the original wikitext |
181 | 181 | $this->wikiOriginal = $text; |
182 | 182 | } |
183 | | - |
| 183 | + |
184 | 184 | /** |
185 | 185 | * Encodes the wikiJsonArray to a JSON string and stores it. |
186 | 186 | */ |
— | — | @@ -187,41 +187,41 @@ |
188 | 188 | if ( !isset( $this->wikiJsonArray ) ) $this->process(); |
189 | 189 | $this->wikiJsonText = FormatJson::encode( $this->wikiJsonArray ); |
190 | 190 | } |
191 | | - |
| 191 | + |
192 | 192 | /** |
193 | 193 | * Encodes both the wikiJsonArray and the parserOutputMarked to a JSON string and stores it. |
194 | 194 | */ |
195 | 195 | private function toCombinedJson() { |
196 | 196 | if ( !isset( $this->wikiJsonArray ) || !isset( $this->parserOutputMarked ) ) $this->process(); |
197 | | - |
198 | | - $combined = array('html' => $this->parserOutputMarked->getText(), 'wiki' => $this->wikiJsonArray); |
| 197 | + |
| 198 | + $combined = array( 'html' => $this->parserOutputMarked->getText(), 'wiki' => $this->wikiJsonArray ); |
199 | 199 | $this->combinedJson = FormatJson::encode( $combined ); |
200 | 200 | } |
201 | | - |
| 201 | + |
202 | 202 | /** |
203 | 203 | * Calls the InlineEditorMark hook to have pieces added, and calculates the JSON and marked HTML. |
204 | 204 | */ |
205 | 205 | private function process() { |
206 | 206 | global $wgParser; |
207 | | - |
| 207 | + |
208 | 208 | // make sure the pieces are added by the edit modes |
209 | 209 | wfRunHooks( 'InlineEditorMark', array( &$this ) ); |
210 | | - |
| 210 | + |
211 | 211 | // init the basic variables |
212 | 212 | $last = 0; // end position of the last piece in the original wikitext |
213 | 213 | $offset = 0; // total amount of wikitext *inside* pieces so far |
214 | 214 | $wikiMarked = ''; // marked wikitext to run through the parser |
215 | 215 | $jsonText = ''; // wikitext in JSON, which has the pieces *removed* |
216 | 216 | $jsonLocations = array(); // pieces with positions where to insert them in $jsonText |
217 | | - |
| 217 | + |
218 | 218 | // sort the pieces by start position |
219 | 219 | ksort( $this->pieces ); |
220 | | - |
| 220 | + |
221 | 221 | // make sure the 'edited' and 'lastEdit' properties on pieces are correctly set |
222 | 222 | $this->applyPreviousMarkings(); |
223 | | - |
| 223 | + |
224 | 224 | // iterate on all pieces |
225 | | - foreach( $this->pieces as $start => $piece ) { |
| 225 | + foreach ( $this->pieces as $start => $piece ) { |
226 | 226 | // do not allow overlap of pieces, so only take those with the lowest |
227 | 227 | // starting position |
228 | 228 | if ( $start < $last ) { |
— | — | @@ -230,24 +230,24 @@ |
231 | 231 | else { |
232 | 232 | // get the end and calculate the length of the current piece |
233 | 233 | $end = $piece->getEnd(); |
234 | | - $length = $end-$start; |
235 | | - |
| 234 | + $length = $end -$start; |
| 235 | + |
236 | 236 | // get the text between last piece and this piece |
237 | | - $prePieceText = substr($this->wikiOriginal, $last, $start-$last); |
238 | | - |
| 237 | + $prePieceText = substr( $this->wikiOriginal, $last, $start -$last ); |
| 238 | + |
239 | 239 | // get the text of the piece itself |
240 | | - $pieceText = substr($this->wikiOriginal, $start, $length); |
241 | | - |
| 240 | + $pieceText = substr( $this->wikiOriginal, $start, $length ); |
| 241 | + |
242 | 242 | // add the text between last piece and this piece, followed by |
243 | 243 | // the text of the piece surrounded by markings |
244 | | - $wikiMarked .= $prePieceText |
245 | | - . $piece->renderStartMarking() |
| 244 | + $wikiMarked .= $prePieceText |
| 245 | + . $piece->renderStartMarking() |
246 | 246 | . $pieceText |
247 | 247 | . $piece->renderEndMarking(); |
248 | | - |
| 248 | + |
249 | 249 | // only add the text between pieces to the JSON text |
250 | 250 | $jsonText .= $prePieceText; |
251 | | - |
| 251 | + |
252 | 252 | // add the piece and position in $jsonText to the list of locations |
253 | 253 | // note that because we're taking out exactly the length of text within pieces, |
254 | 254 | // we can subtract this number from the start position of the piece, to obtain |
— | — | @@ -255,89 +255,89 @@ |
256 | 256 | $jsonLocations[$piece->getId()] = array( |
257 | 257 | 'text' => $pieceText, |
258 | 258 | 'pos' => $start - $offset, |
259 | | - 'edited' => ($piece->getEdited() ? '1' : '0') |
| 259 | + 'edited' => ( $piece->getEdited() ? '1' : '0' ) |
260 | 260 | ); |
261 | | - |
| 261 | + |
262 | 262 | // set variables for the next round |
263 | 263 | $offset += $length; |
264 | 264 | $last = $end; |
265 | 265 | } |
266 | 266 | } |
267 | | - |
| 267 | + |
268 | 268 | // get the text after the last piece and add it to both variables |
269 | | - $postPieceText = substr($this->wikiOriginal, $last); |
| 269 | + $postPieceText = substr( $this->wikiOriginal, $last ); |
270 | 270 | $wikiMarked .= $postPieceText; |
271 | 271 | $jsonText .= $postPieceText; |
272 | | - |
| 272 | + |
273 | 273 | // store the JSON text and locations |
274 | 274 | $this->wikiJsonArray = array( 'text' => $jsonText, 'locations' => $jsonLocations ); |
275 | | - |
| 275 | + |
276 | 276 | // get the same parser options as usual, but remove [edit] links |
277 | 277 | $parserOptions = clone $this->article->getParserOptions(); |
278 | 278 | $parserOptions->setEditSection( false ); |
279 | | - |
| 279 | + |
280 | 280 | // run $wikiMarked through the parser and store the result |
281 | | - $this->parserOutputMarked = $wgParser->parse( $wikiMarked, $this->article->getTitle(), |
| 281 | + $this->parserOutputMarked = $wgParser->parse( $wikiMarked, $this->article->getTitle(), |
282 | 282 | $parserOptions, true, true, $this->article->getRevIdFetched() ); |
283 | 283 | } |
284 | | - |
| 284 | + |
285 | 285 | /** |
286 | 286 | * Checks if pieces have overlap with previous markings and marks them again with |
287 | 287 | * 'edited' or 'lastEdit'. |
288 | | - * |
| 288 | + * |
289 | 289 | * A piece can have overlap with multiple previous markings, but not with many. To |
290 | 290 | * avoid checking all pieces against all markings, a smarter algorithm is employed. |
291 | | - * |
292 | | - * When both the pieces are sorted (*precondition*) and the previous markings are |
| 291 | + * |
| 292 | + * When both the pieces are sorted (*precondition*) and the previous markings are |
293 | 293 | * sorted (which is done in the function), both arrays can be walked. For the array of |
294 | 294 | * previous markings we define a $firstId and $lastId. The end of the first previous marking |
295 | | - * has to be at least on or past the start of the current piece. The start of the last |
| 295 | + * has to be at least on or past the start of the current piece. The start of the last |
296 | 296 | * previous marking has to be at least past the end of the current piece. This way we can |
297 | 297 | * increment $firstId and $lastId until this is true, and we have a smaller window to |
298 | 298 | * check. |
299 | | - * |
| 299 | + * |
300 | 300 | * @return unknown_type |
301 | 301 | */ |
302 | 302 | private function applyPreviousMarkings() { |
303 | 303 | // if there are no previous markings there is no point in checking |
304 | | - if( empty( $this->previousMarkings ) ) return; |
305 | | - |
| 304 | + if ( empty( $this->previousMarkings ) ) return; |
| 305 | + |
306 | 306 | // start both at the beginning |
307 | 307 | $firstId = 0; |
308 | 308 | $lastId = 0; |
309 | | - |
| 309 | + |
310 | 310 | // sort based on start position |
311 | 311 | ksort( $this->previousMarkings ); |
312 | | - |
| 312 | + |
313 | 313 | // use an array with as keys 0, 1, 2, etc. |
314 | 314 | $previous = array_values( $this->previousMarkings ); |
315 | | - |
| 315 | + |
316 | 316 | // interate over all pieces |
317 | | - foreach( $this->pieces as $start => $piece ) { |
| 317 | + foreach ( $this->pieces as $start => $piece ) { |
318 | 318 | $end = $piece->getEnd(); |
319 | | - |
| 319 | + |
320 | 320 | // move the pointer of the first previous marking so it overlaps with the piece |
321 | | - while( isset( $previous[$firstId] ) && $previous[$firstId]->getEnd() < $start ) { |
| 321 | + while ( isset( $previous[$firstId] ) && $previous[$firstId]->getEnd() < $start ) { |
322 | 322 | $firstId++; |
323 | 323 | } |
324 | | - |
| 324 | + |
325 | 325 | // if the pointer to the first previous marking has gone too far, there is nothing |
326 | 326 | // to check for anymore: we're done |
327 | | - if( !isset( $previous[$firstId] ) ) return; |
328 | | - |
| 327 | + if ( !isset( $previous[$firstId] ) ) return; |
| 328 | + |
329 | 329 | // move the pointer of the last previous marking so it just doesn't overlap |
330 | | - while( isset( $previous[$lastId] ) && $previous[$lastId]->getStart() <= $end ) { |
| 330 | + while ( isset( $previous[$lastId] ) && $previous[$lastId]->getStart() <= $end ) { |
331 | 331 | $lastId++; |
332 | 332 | } |
333 | | - |
| 333 | + |
334 | 334 | // check the (small) window of previous markings for overlap |
335 | | - for( $i = $firstId; $i < $lastId; $i++ ) { |
| 335 | + for ( $i = $firstId; $i < $lastId; $i++ ) { |
336 | 336 | // this should always be true, but check anyway! |
337 | | - if( $previous[$i]->inMarking( $piece ) ) { |
338 | | - if( $previous[$i]->getEdited() ) $piece->setEdited( true ); |
339 | | - if( $previous[$i]->getLastEdit() ) $piece->setLastEdit( true ); |
| 337 | + if ( $previous[$i]->inMarking( $piece ) ) { |
| 338 | + if ( $previous[$i]->getEdited() ) $piece->setEdited( true ); |
| 339 | + if ( $previous[$i]->getLastEdit() ) $piece->setLastEdit( true ); |
340 | 340 | } |
341 | 341 | } |
342 | 342 | } |
343 | 343 | } |
344 | | -} |
\ No newline at end of file |
| 344 | +} |
Index: trunk/extensions/InlineEditor/InlineEditorPiece.class.php |
— | — | @@ -4,16 +4,16 @@ |
5 | 5 | * Denotes the start and end of an editiable piece in the wikitext, along with some properties. |
6 | 6 | */ |
7 | 7 | class InlineEditorPiece { |
8 | | - private static $lastId = 0; ///< counter which is used to generate unique ids |
9 | | - |
10 | | - private $start; ///< start position of the piece in the wikitext |
11 | | - private $end; ///< end position of the piece in the wikitext |
12 | | - private $class; ///< class(es) attached to the piece, usually identifies the edit mode |
13 | | - private $inline; ///< whether or not the piece is inline (span) or not (div) |
14 | | - private $id; ///< unique id of this piece |
15 | | - private $edited; ///< boolean whether or not (part of) the piece has been edited before |
16 | | - private $lastEdit; ///< boolean whether or not (part of) the piece was in the last edit |
17 | | - |
| 8 | + private static $lastId = 0; /// < counter which is used to generate unique ids |
| 9 | + |
| 10 | + private $start; /// < start position of the piece in the wikitext |
| 11 | + private $end; /// < end position of the piece in the wikitext |
| 12 | + private $class; /// < class(es) attached to the piece, usually identifies the edit mode |
| 13 | + private $inline; /// < whether or not the piece is inline (span) or not (div) |
| 14 | + private $id; /// < unique id of this piece |
| 15 | + private $edited; /// < boolean whether or not (part of) the piece has been edited before |
| 16 | + private $lastEdit; /// < boolean whether or not (part of) the piece was in the last edit |
| 17 | + |
18 | 18 | // getter functions for most private variables |
19 | 19 | public function getStart() { return $this->start; } |
20 | 20 | public function getEnd() { return $this->end; } |
— | — | @@ -21,28 +21,28 @@ |
22 | 22 | public function getId() { return $this->id; } |
23 | 23 | public function getEdited() { return $this->edited; } |
24 | 24 | public function getLastEdit() { return $this->lastEdit; } |
25 | | - |
| 25 | + |
26 | 26 | // setter functions for edited and lastEdit, as these are not set by the different editors, |
27 | 27 | // but by InlineEditorText |
28 | 28 | public function setEdited( $val ) { $this->edited = $val; } |
29 | 29 | public function setLastEdit( $val ) { $this->lastEdit = $val; } |
30 | | - |
| 30 | + |
31 | 31 | /** |
32 | 32 | * @param $start Integer Start of the piece, offset in number of characters from the begin of the wikitext |
33 | 33 | * @param $end Integer End of the piece, offset in number of characters from the begin of the wikitext |
34 | 34 | * @param $class String Class(es) the piece should be labeled with |
35 | 35 | * @param $inline Boolean Whether the piece is inline (span) or not (div), a div also adds newlines |
36 | 36 | */ |
37 | | - function __construct($start, $end, $class, $inline) { |
| 37 | + function __construct( $start, $end, $class, $inline ) { |
38 | 38 | $this->start = $start; |
39 | 39 | $this->end = $end; |
40 | 40 | $this->class = $class; |
41 | 41 | $this->inline = $inline; |
42 | 42 | $this->id = self::uniqueId(); |
43 | 43 | $this->edited = false; |
44 | | - $this->lastEdit = false; |
| 44 | + $this->lastEdit = false; |
45 | 45 | } |
46 | | - |
| 46 | + |
47 | 47 | /** |
48 | 48 | * Render the open tag, depending on $this->inline this is a <span> or a <div>. |
49 | 49 | * @return String HTML |
— | — | @@ -51,7 +51,7 @@ |
52 | 52 | $attribs = array( 'class' => $this->getFullClass(), 'id' => $this->id ); |
53 | 53 | return HTML::openElement( $this->getElement(), $attribs ) . $this->getNewline(); |
54 | 54 | } |
55 | | - |
| 55 | + |
56 | 56 | /** |
57 | 57 | * Render the close tag. |
58 | 58 | * @return String HTML |
— | — | @@ -59,7 +59,7 @@ |
60 | 60 | public function renderEndMarking() { |
61 | 61 | return $this->getNewline() . '</' . $this->getElement() . '>'; |
62 | 62 | } |
63 | | - |
| 63 | + |
64 | 64 | /** |
65 | 65 | * Simple check to prevent invalid values. |
66 | 66 | * @return boolean |
— | — | @@ -67,15 +67,15 @@ |
68 | 68 | public function isValid() { |
69 | 69 | return $this->end > $this->start; |
70 | 70 | } |
71 | | - |
| 71 | + |
72 | 72 | /** |
73 | | - * Get the class that should be rendered, this may include 'edited' and 'lastEdit' for highlighting. |
| 73 | + * Get the class that should be rendered, this may include 'edited' and 'lastEdit' for highlighting. |
74 | 74 | * @return String All the classes |
75 | 75 | */ |
76 | 76 | private function getFullClass() { |
77 | | - return $this->class . ($this->edited ? ' edited' : '') . ($this->lastEdit ? ' lastEdit' : ''); |
| 77 | + return $this->class . ( $this->edited ? ' edited' : '' ) . ( $this->lastEdit ? ' lastEdit' : '' ); |
78 | 78 | } |
79 | | - |
| 79 | + |
80 | 80 | /** |
81 | 81 | * Get the element name based on $this->inline. |
82 | 82 | * @return String Element name |
— | — | @@ -83,7 +83,7 @@ |
84 | 84 | private function getElement() { |
85 | 85 | return $this->inline ? 'span' : 'div'; |
86 | 86 | } |
87 | | - |
| 87 | + |
88 | 88 | /** |
89 | 89 | * Get a newline or not based on $this->inline. |
90 | 90 | * @return String Empty string or single newline character |
— | — | @@ -91,7 +91,7 @@ |
92 | 92 | private function getNewline() { |
93 | 93 | return $this->inline ? '' : "\n"; |
94 | 94 | } |
95 | | - |
| 95 | + |
96 | 96 | /** |
97 | 97 | * Get a unique id by using self::$lastId and incrementing it. |
98 | 98 | * @return String |
— | — | @@ -99,4 +99,4 @@ |
100 | 100 | private static function uniqueId() { |
101 | 101 | return 'inline-editor-' . self::$lastId++; |
102 | 102 | } |
103 | | -} |
\ No newline at end of file |
| 103 | +} |
Index: trunk/extensions/InlineEditor/InlineEditorPreviousMarking.class.php |
— | — | @@ -4,11 +4,11 @@ |
5 | 5 | * Denotes the start and end of previously edited pieces in the wikitext. |
6 | 6 | */ |
7 | 7 | class InlineEditorPreviousMarking { |
8 | | - private $start; ///< start position of the piece in the wikitext |
9 | | - private $end; ///< end position of the piece in the wikitext |
10 | | - private $edited; ///< boolean whether or not (part of) the piece has been edited before |
11 | | - private $lastEdit; ///< boolean whether or not (part of) the piece was in the last edit |
12 | | - |
| 8 | + private $start; /// < start position of the piece in the wikitext |
| 9 | + private $end; /// < end position of the piece in the wikitext |
| 10 | + private $edited; /// < boolean whether or not (part of) the piece has been edited before |
| 11 | + private $lastEdit; /// < boolean whether or not (part of) the piece was in the last edit |
| 12 | + |
13 | 13 | // getters and setters for the private variables |
14 | 14 | public function getStart() { return $this->start; } |
15 | 15 | public function getEnd() { return $this->end; } |
— | — | @@ -16,16 +16,16 @@ |
17 | 17 | public function getLastEdit() { return $this->lastEdit; } |
18 | 18 | public function setEdited( $val ) { $this->edited = $val; } |
19 | 19 | public function setLastEdit( $val ) { $this->lastEdit = $val; } |
20 | | - |
| 20 | + |
21 | 21 | /** |
22 | 22 | * @param $start Integer Start of the piece, offset in number of characters from the begin of the wikitext |
23 | 23 | * @param $end Integer End of the piece, offset in number of characters from the begin of the wikitext |
24 | 24 | */ |
25 | | - function __construct($start, $end) { |
| 25 | + function __construct( $start, $end ) { |
26 | 26 | $this->start = $start; |
27 | 27 | $this->end = $end; |
28 | 28 | } |
29 | | - |
| 29 | + |
30 | 30 | /** |
31 | 31 | * Checks if an InlineEditorPiece overlaps *or touches* with this marking. |
32 | 32 | * @param $piece InlineEditorPiece |
— | — | @@ -34,9 +34,9 @@ |
35 | 35 | public function inMarking( InlineEditorPiece $piece ) { |
36 | 36 | $start = $piece->getStart(); |
37 | 37 | $end = $piece->getEnd(); |
38 | | - return ($start >= $this->start && $start <= $this->end) || ($end >= $this->start && $end <= $this->end); |
| 38 | + return ( $start >= $this->start && $start <= $this->end ) || ( $end >= $this->start && $end <= $this->end ); |
39 | 39 | } |
40 | | - |
| 40 | + |
41 | 41 | /** |
42 | 42 | * Simple check to prevent invalid values. |
43 | 43 | * @return boolean |
— | — | @@ -44,4 +44,4 @@ |
45 | 45 | public function isValid() { |
46 | 46 | return $this->end > $this->start; |
47 | 47 | } |
48 | | -} |
\ No newline at end of file |
| 48 | +} |
Index: trunk/extensions/InlineEditor/MediaEditor/MediaEditor.class.php |
— | — | @@ -1,9 +1,9 @@ |
2 | 2 | <?php |
| 3 | + |
3 | 4 | /** |
4 | | - * Simple editor for media (images, video, sound). |
| 5 | + * Simple editor for media (images, video, sound). |
5 | 6 | */ |
6 | 7 | class MediaEditor { |
7 | | - |
8 | 8 | /** |
9 | 9 | * This function hooks into InlineEditorMark and marks the media. |
10 | 10 | * @param $inlineEditorText InlineEditorText |
— | — | @@ -11,33 +11,33 @@ |
12 | 12 | public static function mark( &$inlineEditorText ) { |
13 | 13 | // get the original wikitext |
14 | 14 | $text = $inlineEditorText->getWikiOriginal(); |
15 | | - |
| 15 | + |
16 | 16 | $matches = array(); |
17 | 17 | preg_match_all( '/^\s*(\[\[(.*:.*)\]\])\s*$/m', $text, $matches, PREG_OFFSET_CAPTURE ); |
18 | | - |
19 | | - foreach( $matches[1] as $id => $match ) { |
| 18 | + |
| 19 | + foreach ( $matches[1] as $id => $match ) { |
20 | 20 | $link = $matches[2][$id][0]; |
21 | | - $firstPipe = strpos($link, '|'); |
22 | | - if( $firstPipe !== false ) { |
| 21 | + $firstPipe = strpos( $link, '|' ); |
| 22 | + if ( $firstPipe !== false ) { |
23 | 23 | $url = substr( $link, 0, $firstPipe ); |
24 | 24 | } |
25 | 25 | else { |
26 | 26 | $url = $link; |
27 | 27 | } |
28 | | - |
| 28 | + |
29 | 29 | $title = Title::newFromText( $url ); |
30 | 30 | $namespace = $title->getNamespace(); |
31 | | - |
32 | | - if( $namespace == NS_FILE ) { |
| 31 | + |
| 32 | + if ( $namespace == NS_FILE ) { |
33 | 33 | $start = $match[1]; |
34 | 34 | $end = $start + strlen( $match[0] ); |
35 | 35 | $inlineEditorText->addPiece( new InlineEditorPiece( $start, $end, 'mediaEditorElement', false ) ); |
36 | 36 | } |
37 | 37 | } |
38 | | - |
| 38 | + |
39 | 39 | return true; |
40 | 40 | } |
41 | | - |
| 41 | + |
42 | 42 | /** |
43 | 43 | * Hooks into InlineEditorDefineEditors. Adds the option to to the list and adds CSS and JS files |
44 | 44 | * @param $editor InlineEditor |
— | — | @@ -45,16 +45,16 @@ |
46 | 46 | */ |
47 | 47 | public static function defineEditors( &$editor, &$output ) { |
48 | 48 | global $wgExtensionAssetsPath; |
49 | | - |
| 49 | + |
50 | 50 | $editor->addEditMode( |
51 | | - 'mediaEditor', |
52 | | - wfMsgExt( 'media-editor-editmode-caption', 'parseinline' ), |
53 | | - wfMsgExt( 'media-editor-editmode-description','parseinline' ) |
| 51 | + 'mediaEditor', |
| 52 | + wfMsgExt( 'media-editor-editmode-caption', 'parseinline' ), |
| 53 | + wfMsgExt( 'media-editor-editmode-description', 'parseinline' ) |
54 | 54 | ); |
55 | | - |
56 | | - $output->addExtensionStyle( "$wgExtensionAssetsPath/InlineEditor/MediaEditor/MediaEditor.css?0"); |
| 55 | + |
| 56 | + $output->addExtensionStyle( "$wgExtensionAssetsPath/InlineEditor/MediaEditor/MediaEditor.css?0" ); |
57 | 57 | $output->addScriptFile( "$wgExtensionAssetsPath/InlineEditor/MediaEditor/jquery.inlineEditor.editors.mediaEditor.js?0" ); |
58 | | - |
| 58 | + |
59 | 59 | return true; |
60 | 60 | } |
61 | | -} |
\ No newline at end of file |
| 61 | +} |
Index: trunk/extensions/InlineEditor/MediaEditor/MediaEditor.i18n.php |
— | — | @@ -15,12 +15,10 @@ |
16 | 16 | 'media-editor-desc' => 'Adds the "Media" edit mode for the InlineEditor', |
17 | 17 | |
18 | 18 | 'media-editor-editmode-caption' => "Media", |
19 | | - 'media-editor-editmode-description' => " |
20 | | -You can edit media like images, video and sound using this mode. |
| 19 | + 'media-editor-editmode-description' => "You can edit media like images, video and sound using this mode. |
21 | 20 | Sometimes templates are used to display images, in which case you have to use the '''Template''' mode. |
22 | 21 | |
23 | 22 | :<code><nowiki>[[File:Example.jpg|thumb|An example file]]</nowiki></code> |
24 | 23 | |
25 | | -[http://en.wikipedia.org/wiki/Help:Files More information] |
26 | | -", |
27 | | -); |
\ No newline at end of file |
| 24 | +[http://en.wikipedia.org/wiki/Help:Files More information].", |
| 25 | +); |
Index: trunk/extensions/InlineEditor/MediaEditor/MediaEditor.php |
— | — | @@ -38,4 +38,4 @@ |
39 | 39 | $wgHooks['InlineEditorDefineEditors'][] = 'MediaEditor::defineEditors'; |
40 | 40 | |
41 | 41 | // i18n messages |
42 | | -$wgExtensionMessagesFiles['MediaEditor'] = $dir . 'MediaEditor.i18n.php'; |
\ No newline at end of file |
| 42 | +$wgExtensionMessagesFiles['MediaEditor'] = $dir . 'MediaEditor.i18n.php'; |
Index: trunk/extensions/InlineEditor/InlineEditor.i18n.php |
— | — | @@ -14,16 +14,18 @@ |
15 | 15 | $messages['en'] = array( |
16 | 16 | 'inline-editor-desc' => 'Provides an alternative editor which is easier to use', |
17 | 17 | |
18 | | - 'inline-editor-editbox-top' => "'''Awesome, you're editing {{SITENAME}}!'''<br/>You can edit the article below, by clicking on <span class=\"highlightExample\">blue elements</span> in the article.", |
| 18 | + 'inline-editor-editbox-top' => "'''Awesome, you are editing {{SITENAME}}!'''<br />You can edit the article below, by clicking on <span class=\"highlightExample\">blue elements</span> in the page.", |
19 | 19 | 'inline-editor-editbox-changes-question' => "Can you briefly describe the changes you're making?", |
20 | 20 | 'inline-editor-editbox-changes-example' => 'For example: "Fixed spelling mistake", "Corrected facts", "Wrote a new paragraph", etc.', |
21 | | - 'inline-editor-editbox-publish-notice' => "When you're done, don't forget to publish the page!", |
22 | | - //'inline-editor-editbox-publish-terms' => 'When you click "Publish", you agree to the [http://wikimediafoundation.org/wiki/Terms_of_Use Terms of Use]. This means that you agree to share your contributions under a free license.', |
23 | | - 'inline-editor-editbox-publish-terms' => 'When you click "Publish", you agree with our copyright policy. See $1 for more information.', |
| 21 | + 'inline-editor-editbox-publish-notice' => "When you are done, do not forget to publish the page!", |
| 22 | + // 'inline-editor-editbox-publish-terms' => 'When you click "Publish", you agree to the [http://wikimediafoundation.org/wiki/Terms_of_Use Terms of Use]. This means that you agree to share your contributions under a free license.', |
| 23 | + 'inline-editor-editbox-publish-terms' => 'When you click "Publish", you agree with our copyright policy. |
| 24 | +See $1 for more information.', |
24 | 25 | 'inline-editor-editbox-publish-caption' => 'Publish', |
25 | 26 | 'inline-editor-editmodes-caption' => 'Edit mode:', |
26 | 27 | 'inline-editor-redirect-browser' => 'The new editing interface is not supported by your browser.', |
27 | | - 'inline-editor-redirect-advanced' => "Editing this page is considered '''advanced''' use of Wikipedia. You can only use the '''full editor''' for this page.", |
| 28 | + 'inline-editor-redirect-advanced' => "Editing this page is considered '''advanced''' use of MediaWiki. |
| 29 | +You can only use the '''full editor''' for this page.", |
28 | 30 | 'inline-editor-editmodes-undo' => 'Undo', |
29 | 31 | 'inline-editor-editmodes-redo' => 'Redo', |
30 | | -); |
\ No newline at end of file |
| 32 | +); |
Index: trunk/extensions/InlineEditor/ExtendedEditPage.class.php |
— | — | @@ -1,11 +1,11 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | | - * This is basically an EditPage with some specific functions for the InlineEditor. This |
| 4 | + * This is basically an EditPage with some specific functions for the InlineEditor. This |
5 | 5 | * allows retrieval of wikitext, summary and a submit URL, and handles when to fall back |
6 | | - * to the full/traditional editor. |
| 6 | + * to the full/traditional editor. |
7 | 7 | */ |
8 | 8 | class ExtendedEditPage extends EditPage { |
9 | | - |
| 9 | + |
10 | 10 | /** |
11 | 11 | * Inits the edit page for the InlineEditor. |
12 | 12 | * This is largely a copy-paste from EditPage::edit(), with some specific changes. |
— | — | @@ -13,18 +13,18 @@ |
14 | 14 | public function initInlineEditor() { |
15 | 15 | global $wgRequest, $wgOut; |
16 | 16 | $this->importFormData( $wgRequest ); |
17 | | - |
18 | | - if( !empty( $this->section ) ) return false; |
19 | | - |
| 17 | + |
| 18 | + if ( !empty( $this->section ) ) return false; |
| 19 | + |
20 | 20 | // @todo: refactor this piece in EditPage.php to (a) different function(s) |
21 | 21 | // so that this is not an ugly copy-paste |
22 | | - |
| 22 | + |
23 | 23 | if ( wfReadOnly() && $this->save ) { |
24 | 24 | // Force preview |
25 | 25 | $this->save = false; |
26 | 26 | $this->preview = true; |
27 | 27 | } |
28 | | - |
| 28 | + |
29 | 29 | $permErrors = $this->getEditPermissionErrors(); |
30 | 30 | if ( $permErrors ) { |
31 | 31 | wfDebug( __METHOD__ . ": User can't edit\n" ); |
— | — | @@ -47,7 +47,7 @@ |
48 | 48 | } |
49 | 49 | } |
50 | 50 | } |
51 | | - |
| 51 | + |
52 | 52 | // If they used redlink=1 and the page exists, redirect to the main article |
53 | 53 | if ( $wgRequest->getBool( 'redlink' ) && $this->mTitle->exists() ) { |
54 | 54 | $wgOut->redirect( $this->mTitle->getFullURL() ); |
— | — | @@ -59,18 +59,18 @@ |
60 | 60 | $this->isCssSubpage = $this->mTitle->isCssSubpage(); |
61 | 61 | $this->isJsSubpage = $this->mTitle->isJsSubpage(); |
62 | 62 | $this->isValidCssJsSubpage = $this->mTitle->isValidCssJsSubpage(); |
63 | | - |
| 63 | + |
64 | 64 | // catch the HTML that the intro throws |
65 | 65 | // if anything is thrown, fall back to the normal editor |
66 | 66 | $wgOut->clearHTML(); |
67 | 67 | if ( $this->formtype == 'initial' || $this->firsttime ) { |
68 | 68 | $this->showIntro(); |
69 | | - if( $wgOut->getHTML() != '' ) { |
| 69 | + if ( $wgOut->getHTML() != '' ) { |
70 | 70 | $wgOut->clearHTML(); |
71 | 71 | return false; |
72 | 72 | } |
73 | 73 | } |
74 | | - |
| 74 | + |
75 | 75 | if ( 'initial' == $this->formtype || 'preview' == $this->formtype || $this->firsttime ) { |
76 | 76 | if ( $this->initialiseForm() !== false ) { |
77 | 77 | return true; |
— | — | @@ -82,7 +82,7 @@ |
83 | 83 | elseif ( 'save' == $this->formtype ) { |
84 | 84 | // attemptSave does a redirect *itself* when it's succesful! |
85 | 85 | $this->attemptSave(); |
86 | | - if( $this->isConflict ) { |
| 86 | + if ( $this->isConflict ) { |
87 | 87 | return false; |
88 | 88 | } |
89 | 89 | else { |
— | — | @@ -93,7 +93,7 @@ |
94 | 94 | return false; |
95 | 95 | } |
96 | 96 | } |
97 | | - |
| 97 | + |
98 | 98 | /** |
99 | 99 | * Get the wikitext to render the page from |
100 | 100 | * @return String |
— | — | @@ -101,7 +101,7 @@ |
102 | 102 | public function getWikiText() { |
103 | 103 | return $this->textbox1; |
104 | 104 | } |
105 | | - |
| 105 | + |
106 | 106 | /** |
107 | 107 | * Get the summary to show in the input field |
108 | 108 | * @return String |
— | — | @@ -109,7 +109,7 @@ |
110 | 110 | public function getSummary() { |
111 | 111 | return $this->summary; |
112 | 112 | } |
113 | | - |
| 113 | + |
114 | 114 | /** |
115 | 115 | * Get the URL to submit to, with some options in the URL that are usually hidden fields |
116 | 116 | * @return String |
— | — | @@ -122,11 +122,11 @@ |
123 | 123 | 'wpEdittime' => $this->edittime, |
124 | 124 | 'wpStarttime' => $this->starttime |
125 | 125 | ); |
126 | | - |
127 | | - if( $this->scrolltop ) $options['wpScrolltop'] = 1; |
128 | | - if( $this->minoredit ) $options['wpMinorEdit'] = 1; |
129 | | - if( $this->watchthis ) $options['wpWatchthis'] = 1; |
130 | | - |
| 126 | + |
| 127 | + if ( $this->scrolltop ) $options['wpScrolltop'] = 1; |
| 128 | + if ( $this->minoredit ) $options['wpMinorEdit'] = 1; |
| 129 | + if ( $this->watchthis ) $options['wpWatchthis'] = 1; |
| 130 | + |
131 | 131 | return $this->mTitle->getLocalURL( $options ); |
132 | 132 | } |
133 | | -} |
\ No newline at end of file |
| 133 | +} |
Index: trunk/extensions/InlineEditor/ReferenceEditor/ReferenceEditor.class.php |
— | — | @@ -1,9 +1,9 @@ |
2 | 2 | <?php |
| 3 | + |
3 | 4 | /** |
4 | | - * Simple editor for references. |
| 5 | + * Simple editor for references. |
5 | 6 | */ |
6 | 7 | class ReferenceEditor { |
7 | | - |
8 | 8 | /** |
9 | 9 | * This function hooks into InlineEditorMark and marks the references. |
10 | 10 | * @param $inlineEditorText InlineEditorText |
— | — | @@ -11,19 +11,19 @@ |
12 | 12 | public static function mark( &$inlineEditorText ) { |
13 | 13 | // get the original wikitext |
14 | 14 | $text = $inlineEditorText->getWikiOriginal(); |
15 | | - |
| 15 | + |
16 | 16 | $matches = array(); |
17 | 17 | preg_match_all( '/<ref[^\/]*?>.*?<\/ref>|<ref.*?\/>/is', $text, $matches, PREG_OFFSET_CAPTURE ); |
18 | | - |
19 | | - foreach( $matches[0] as $match ) { |
| 18 | + |
| 19 | + foreach ( $matches[0] as $match ) { |
20 | 20 | $start = $match[1]; |
21 | 21 | $end = $start + strlen( $match[0] ); |
22 | 22 | $inlineEditorText->addPiece( new InlineEditorPiece( $start, $end, 'referenceEditorElement', true ) ); |
23 | 23 | } |
24 | | - |
| 24 | + |
25 | 25 | return true; |
26 | 26 | } |
27 | | - |
| 27 | + |
28 | 28 | /** |
29 | 29 | * Hooks into InlineEditorDefineEditors. Adds the option to to the list and adds CSS and JS files |
30 | 30 | * @param $editor InlineEditor |
— | — | @@ -31,16 +31,16 @@ |
32 | 32 | */ |
33 | 33 | public static function defineEditors( &$editor, &$output ) { |
34 | 34 | global $wgExtensionAssetsPath; |
35 | | - |
| 35 | + |
36 | 36 | $editor->addEditMode( |
37 | | - 'referenceEditor', |
38 | | - wfMsgExt( 'reference-editor-editmode-caption', 'parseinline' ), |
39 | | - wfMsgExt( 'reference-editor-editmode-description','parseinline' ) |
| 37 | + 'referenceEditor', |
| 38 | + wfMsgExt( 'reference-editor-editmode-caption', 'parseinline' ), |
| 39 | + wfMsgExt( 'reference-editor-editmode-description', 'parseinline' ) |
40 | 40 | ); |
41 | | - |
42 | | - $output->addExtensionStyle( "$wgExtensionAssetsPath/InlineEditor/ReferenceEditor/ReferenceEditor.css?0"); |
| 41 | + |
| 42 | + $output->addExtensionStyle( "$wgExtensionAssetsPath/InlineEditor/ReferenceEditor/ReferenceEditor.css?0" ); |
43 | 43 | $output->addScriptFile( "$wgExtensionAssetsPath/InlineEditor/ReferenceEditor/jquery.inlineEditor.editors.referenceEditor.js?0" ); |
44 | | - |
| 44 | + |
45 | 45 | return true; |
46 | 46 | } |
47 | | -} |
\ No newline at end of file |
| 47 | +} |
Index: trunk/extensions/InlineEditor/ReferenceEditor/ReferenceEditor.i18n.php |
— | — | @@ -15,12 +15,10 @@ |
16 | 16 | 'reference-editor-desc' => 'Adds the "References" edit mode for the InlineEditor', |
17 | 17 | |
18 | 18 | 'reference-editor-editmode-caption' => "References", |
19 | | - 'reference-editor-editmode-description' => " |
20 | | -References are placed after a piece of text. |
| 19 | + 'reference-editor-editmode-description' => "References are placed after a piece of text. |
21 | 20 | You can edit them in this mode, and add new references in the '''Text''' mode. |
22 | 21 | |
23 | 22 | :<code><nowiki>According to scientists, the Sun is pretty big. <ref>E. Miller, The Sun, (New York: Academic Press, 2005), 23-5.</ref></nowiki></code> |
24 | 23 | |
25 | | -[http://www.mediawiki.org/wiki/Extension:Cite/Cite.php More information] |
26 | | -", |
27 | | -); |
\ No newline at end of file |
| 24 | +[http://www.mediawiki.org/wiki/Extension:Cite/Cite.php More information].", |
| 25 | +); |
Index: trunk/extensions/InlineEditor/ReferenceEditor/ReferenceEditor.php |
— | — | @@ -38,4 +38,4 @@ |
39 | 39 | $wgHooks['InlineEditorDefineEditors'][] = 'ReferenceEditor::defineEditors'; |
40 | 40 | |
41 | 41 | // i18n messages |
42 | | -$wgExtensionMessagesFiles['ReferenceEditor'] = $dir . 'ReferenceEditor.i18n.php'; |
\ No newline at end of file |
| 42 | +$wgExtensionMessagesFiles['ReferenceEditor'] = $dir . 'ReferenceEditor.i18n.php'; |
Index: trunk/extensions/InlineEditor/FullEditor/FullEditor.php |
— | — | @@ -37,4 +37,4 @@ |
38 | 38 | $wgHooks['InlineEditorDefineEditors'][] = 'FullEditor::defineEditors'; |
39 | 39 | |
40 | 40 | // i18n messages |
41 | | -$wgExtensionMessagesFiles['FullEditor'] = $dir . 'FullEditor.i18n.php'; |
\ No newline at end of file |
| 41 | +$wgExtensionMessagesFiles['FullEditor'] = $dir . 'FullEditor.i18n.php'; |
Index: trunk/extensions/InlineEditor/FullEditor/FullEditor.class.php |
— | — | @@ -1,17 +1,18 @@ |
2 | 2 | <?php |
| 3 | + |
3 | 4 | /** |
4 | 5 | * This 'editor' just shows some description with a link to the full/traditional editor. |
5 | 6 | */ |
6 | 7 | class FullEditor { |
7 | 8 | public static function defineEditors( &$editor, &$output ) { |
8 | 9 | $editor->addEditMode( |
9 | | - 'FullEditor', |
10 | | - wfMsgExt( 'fulleditor-editmode-caption', 'parseinline' ), |
| 10 | + 'FullEditor', |
| 11 | + wfMsgExt( 'fulleditor-editmode-caption', 'parseinline' ), |
11 | 12 | wfMsgExt( 'fulleditor-editmode-description', 'parseinline' ) |
12 | | - . '<br/><a class="fulleditor" href="' . $editor->getArticle()->getTitle()->getLocalURL( 'action=edit&fulleditor=1' ) . '">' |
| 13 | + . '<br /><a class="fulleditor" href="' . $editor->getArticle()->getTitle()->getLocalURL( 'action=edit&fulleditor=1' ) . '">' |
13 | 14 | . wfMsgExt( 'fulleditor-editmode-description-link', 'parseinline' ) |
14 | 15 | . '</a>' |
15 | 16 | ); |
16 | 17 | return true; |
17 | 18 | } |
18 | | -} |
\ No newline at end of file |
| 19 | +} |
Index: trunk/extensions/InlineEditor/FullEditor/FullEditor.i18n.php |
— | — | @@ -15,9 +15,8 @@ |
16 | 16 | 'fulleditor-desc' => 'Provides a link to the full editor for the InlineEditor', |
17 | 17 | |
18 | 18 | 'fulleditor-editmode-caption' => 'Full editor', |
19 | | - 'fulleditor-editmode-description' => " |
20 | | -If you want full control over the page, you can use the full editor. |
| 19 | + 'fulleditor-editmode-description' => "If you want full control over the page, you can use the full editor. |
21 | 20 | With this editor you can edit the [http://en.wikipedia.org/wiki/Help:Wiki_markup Wiki markup] directly. |
22 | | -The editor is also more complex to use, but to have full control of editing Wikipedia, that's worth it!", |
23 | | - 'fulleditor-editmode-description-link' => 'Use the full editor »', |
24 | | -); |
\ No newline at end of file |
| 21 | +The editor is also more complex to use, but to have full control of editing this wikis, may be worth it!", |
| 22 | + 'fulleditor-editmode-description-link' => 'Use the full editor »', |
| 23 | +); |
Index: trunk/extensions/InlineEditor/SentenceEditor/SentenceEditor.i18n.php |
— | — | @@ -16,27 +16,23 @@ |
17 | 17 | |
18 | 18 | 'sentence-editor-editmode-caption' => "Text", |
19 | 19 | /* |
20 | | - 'sentence-editor-editmode-description' => " |
21 | | -There are a few [http://en.wikipedia.org/wiki/Wikipedia:Simplified_ruleset guidelines] for editing an article:<br/> |
| 20 | + 'sentence-editor-editmode-description' => "There are a few [http://en.wikipedia.org/wiki/Wikipedia:Simplified_ruleset guidelines] for editing an article:<br/> |
22 | 21 | * Write what you think is best for the article, or as we say here: [http://en.wikipedia.org/wiki/Wikipedia:Be_bold be bold when updating pages]! If you feel that a rule prevents you from improving Wikipedia, [http://en.wikipedia.org/wiki/Wikipedia:Ignore_all_rules ignore it]. |
23 | 22 | * [http://en.wikipedia.org/wiki/Wikipedia:What_Wikipedia_is_not Wikipedia is an encyclopedia.] Someone else should be able to [http://en.wikipedia.org/wiki/Wikipedia:Verifiability verify] what you've written, for example in books or online. |
24 | | -* Write from a [http://en.wikipedia.org/wiki/Wikipedia:Neutral_point_of_view neutral point of view], and use your [http://en.wikipedia.org/wiki/Wikipedia:Copyrights own words]. |
25 | | - ", |
| 23 | +* Write from a [http://en.wikipedia.org/wiki/Wikipedia:Neutral_point_of_view neutral point of view], and use your [http://en.wikipedia.org/wiki/Wikipedia:Copyrights own words].", |
26 | 24 | */ |
27 | | - 'sentence-editor-editmode-description' => " |
28 | | -Edit sentences by clicking on them. You can use wiki syntax to format the text. Some examples: |
| 25 | + 'sentence-editor-editmode-description' => "Edit sentences by clicking on them. You can use wiki syntax to format the text. Some examples: |
29 | 26 | {| width=\"100%\" style=\"background-color: inherit\" |
30 | 27 | ! Code |
31 | 28 | ! Output |
32 | 29 | |- |
33 | 30 | | <code><nowiki>Here's a link to the [[Main Page]].</nowiki></code> |
34 | | -| Here's a link to the [[Main Page]]. |
| 31 | +| Here is a link to the [[Main Page]]. |
35 | 32 | |- |
36 | 33 | | <code><nowiki>This is ''italic text'' and this is '''bold text'''.</nowiki></code> |
37 | 34 | | This is ''italic text'' and this is '''bold text'''. |
38 | | -|- |
| 35 | +|- |
39 | 36 | | <code><nowiki>[http://meta.wikimedia.org/wiki/Help:Editing More information]</nowiki></code> |
40 | 37 | | [http://meta.wikimedia.org/wiki/Help:Editing More information] |
41 | | -|} |
42 | | - ", |
43 | | -); |
\ No newline at end of file |
| 38 | +|}", |
| 39 | +); |
Index: trunk/extensions/InlineEditor/SentenceEditor/SentenceEditor.php |
— | — | @@ -43,4 +43,4 @@ |
44 | 44 | $wgExtensionMessagesFiles['SentenceEditor'] = $dir . 'SentenceEditor.i18n.php'; |
45 | 45 | |
46 | 46 | // default settings |
47 | | -$wgSentenceEditorDetectionDefault = 'SentenceDetectionBasic'; |
\ No newline at end of file |
| 47 | +$wgSentenceEditorDetectionDefault = 'SentenceDetectionBasic'; |
Index: trunk/extensions/InlineEditor/SentenceEditor/SentenceDetection/SentenceDetectionBasic.class.php |
— | — | @@ -1,36 +1,37 @@ |
2 | 2 | <?php |
| 3 | + |
3 | 4 | /** |
4 | 5 | * Basic implementation of sentence splitting. Not recommended for actual use, but does the job |
5 | 6 | * for a simple demo. |
6 | 7 | */ |
7 | 8 | class SentenceDetectionBasic implements ISentenceDetection { |
8 | 9 | private $wikiTexts; |
9 | | - |
| 10 | + |
10 | 11 | function __construct() { |
11 | 12 | $this->wikiTexts = array(); |
12 | 13 | } |
13 | | - |
| 14 | + |
14 | 15 | public function addWikiText( $text, $offset ) { |
15 | 16 | $this->wikiTexts[] = array( 'text' => $text, 'offset' => $offset ); |
16 | 17 | } |
17 | | - |
| 18 | + |
18 | 19 | public function addPiecesToText( InlineEditorText &$inlineEditorText, $class, $inline ) { |
19 | 20 | $pieces = array(); |
20 | | - foreach( $this->wikiTexts as $wikiText ) { |
21 | | - $sentences = preg_split( "/(?<!\..|\...|\....)([\?\!\.]+)\s(?!.\.|..\.|...\.)/u", $wikiText['text'], -1, |
| 21 | + foreach ( $this->wikiTexts as $wikiText ) { |
| 22 | + $sentences = preg_split( "/(?<!\..|\...|\....)([\?\!\.]+)\s(?!.\.|..\.|...\.)/u", $wikiText['text'], -1, |
22 | 23 | PREG_SPLIT_OFFSET_CAPTURE | PREG_SPLIT_DELIM_CAPTURE ); |
23 | | - |
24 | | - foreach( $sentences as $index => $sentence ) { |
25 | | - if( $index % 2 == 0 ) { |
26 | | - if( isset( $sentences[$index+1] ) ) { |
27 | | - $sentence[0] .= $sentences[$index+1][0]; |
| 24 | + |
| 25 | + foreach ( $sentences as $index => $sentence ) { |
| 26 | + if ( $index % 2 == 0 ) { |
| 27 | + if ( isset( $sentences[$index + 1] ) ) { |
| 28 | + $sentence[0] .= $sentences[$index + 1][0]; |
28 | 29 | } |
29 | 30 | $start = $wikiText['offset'] + $sentence[1]; |
30 | | - $end = $start + strlen( $sentence[0] ); |
| 31 | + $end = $start + strlen( $sentence[0] ); |
31 | 32 | $inlineEditorText->addPiece( new InlineEditorPiece( $start, $end, $class, $inline ) ); |
32 | 33 | } |
33 | 34 | } |
34 | 35 | } |
35 | 36 | return $pieces; |
36 | 37 | } |
37 | | -} |
\ No newline at end of file |
| 38 | +} |
Index: trunk/extensions/InlineEditor/SentenceEditor/SentenceDetection/ISentenceDetection.class.php |
— | — | @@ -1,18 +1,19 @@ |
2 | 2 | <?php |
| 3 | + |
3 | 4 | /** |
4 | 5 | * This interface defines what a sentence detector should be able to do, which is |
5 | 6 | * adding portions of wikitext and adding the detected sentences as pieces to an |
6 | | - * InlineEditorText object. |
| 7 | + * InlineEditorText object. |
7 | 8 | */ |
8 | 9 | interface ISentenceDetection { |
9 | 10 | /** |
10 | 11 | * Add a bit of wikitext to the object. The wikitext has to be split in sentences while |
11 | | - * remembering the position of each sentence. |
| 12 | + * remembering the position of each sentence. |
12 | 13 | * @param $text String |
13 | 14 | * @param $position Integer |
14 | 15 | */ |
15 | 16 | public function addWikiText( $text, $position ); |
16 | | - |
| 17 | + |
17 | 18 | /** |
18 | 19 | * All the sentences and their offsets have to be added as pieces to $inlineEditorText. |
19 | 20 | * @param $inlineEditorText InlineEditorText Object the pieces should be added to |
— | — | @@ -20,4 +21,4 @@ |
21 | 22 | * @param $inline Boolean whether the pieces are inline or not |
22 | 23 | */ |
23 | 24 | public function addPiecesToText( InlineEditorText &$inlineEditorText, $class, $inline ); |
24 | | -} |
\ No newline at end of file |
| 25 | +} |
Index: trunk/extensions/InlineEditor/SentenceEditor/SentenceEditor.class.php |
— | — | @@ -1,48 +1,48 @@ |
2 | 2 | <?php |
| 3 | + |
3 | 4 | /** |
4 | 5 | * This editor allows for editing individual sentences. It strips the wikitext from |
5 | | - * things that are too hard to edit, and leaves the splitting of sentences to a |
6 | | - * class that implements the interface ISentenceDetection. |
7 | | - * |
| 6 | + * things that are too hard to edit, and leaves the splitting of sentences to a |
| 7 | + * class that implements the interface ISentenceDetection. |
| 8 | + * |
8 | 9 | * It's very much possible to create an extension that inherits from this class to |
9 | 10 | * do the detection another way, i.e. without the preprocessing and splitting. |
10 | 11 | */ |
11 | 12 | class SentenceEditor { |
12 | | - |
13 | 13 | /** |
14 | 14 | * This function hooks into InlineEditorMark and marks the sentences. |
15 | 15 | * @param $inlineEditorText InlineEditorText |
16 | 16 | */ |
17 | 17 | public static function mark( &$inlineEditorText ) { |
18 | 18 | global $wgSentenceEditorDetectionDefault; |
19 | | - |
| 19 | + |
20 | 20 | // get the original wikitext |
21 | 21 | $text = $inlineEditorText->getWikiOriginal(); |
22 | | - |
| 22 | + |
23 | 23 | // preprocess the text by replacing everything difficult by spaces |
24 | 24 | $text = self::preprocess( $text ); |
25 | | - |
| 25 | + |
26 | 26 | // split what's left into sensible blocks of text |
27 | 27 | $split = self::split( $text ); |
28 | | - |
| 28 | + |
29 | 29 | // get the default detection class and make it able for extensions to alter it |
30 | 30 | $detectionClass = $wgSentenceEditorDetectionDefault; |
31 | 31 | wfRunHooks( 'SentenceEditorDetectionClass', array( &$detectionClass ) ); |
32 | | - |
| 32 | + |
33 | 33 | // spawn the detection class and add the texts and position |
34 | 34 | $detection = new $detectionClass(); |
35 | | - foreach( $split as $wikiText ) { |
| 35 | + foreach ( $split as $wikiText ) { |
36 | 36 | // $wikiText[0] is the text, $wikiText[1] is the position of that text |
37 | 37 | $detection->addWikiText( $wikiText[0], $wikiText[1] ); |
38 | 38 | } |
39 | | - |
| 39 | + |
40 | 40 | // have the detection class add the pieces to the InlineEditorText object, |
41 | 41 | // class 'sentenceEditorElement', inline elements |
42 | 42 | $detection->addPiecesToText( $inlineEditorText, 'sentenceEditorElement', true ); |
43 | | - |
| 43 | + |
44 | 44 | return true; |
45 | 45 | } |
46 | | - |
| 46 | + |
47 | 47 | /** |
48 | 48 | * Hooks into InlineEditorDefineEditors. Adds the option to to the list and adds CSS and JS files |
49 | 49 | * @param $editor InlineEditor |
— | — | @@ -50,21 +50,21 @@ |
51 | 51 | */ |
52 | 52 | public static function defineEditors( &$editor, &$output ) { |
53 | 53 | global $wgExtensionAssetsPath; |
54 | | - |
| 54 | + |
55 | 55 | $editor->addEditMode( |
56 | | - 'sentenceEditor', |
57 | | - wfMsgExt( 'sentence-editor-editmode-caption', 'parseinline' ), |
58 | | - wfMsgExt( 'sentence-editor-editmode-description','parseinline' ) |
| 56 | + 'sentenceEditor', |
| 57 | + wfMsgExt( 'sentence-editor-editmode-caption', 'parseinline' ), |
| 58 | + wfMsgExt( 'sentence-editor-editmode-description', 'parseinline' ) |
59 | 59 | ); |
60 | | - |
61 | | - $output->addExtensionStyle( "$wgExtensionAssetsPath/InlineEditor/SentenceEditor/SentenceEditor.css?0"); |
| 60 | + |
| 61 | + $output->addExtensionStyle( "$wgExtensionAssetsPath/InlineEditor/SentenceEditor/SentenceEditor.css?0" ); |
62 | 62 | $output->addScriptFile( "$wgExtensionAssetsPath/InlineEditor/SentenceEditor/jquery.inlineEditor.editors.sentenceEditor.js?0" ); |
63 | 63 | $output->addScriptFile( "$wgExtensionAssetsPath/InlineEditor/SentenceEditor/jquery.textWidth.js?0" ); |
64 | 64 | $output->addScriptFile( "$wgExtensionAssetsPath/InlineEditor/SentenceEditor/jquery.elastic.js?0" ); |
65 | | - |
| 65 | + |
66 | 66 | return true; |
67 | 67 | } |
68 | | - |
| 68 | + |
69 | 69 | /** |
70 | 70 | * Replaces all occurences of unsupported wikitext by spaces. This is to make sure the |
71 | 71 | * positions of what's left are still the same as those in the original wikitext |
— | — | @@ -73,40 +73,40 @@ |
74 | 74 | */ |
75 | 75 | protected static function preprocess( $wikitext ) { |
76 | 76 | $patterns = array(); |
77 | | - |
| 77 | + |
78 | 78 | // remove references |
79 | 79 | $patterns[] = '/(<ref[^>\/]*>.*?<\/ref>)/is'; |
80 | | - |
| 80 | + |
81 | 81 | // remove references like <ref/> |
82 | 82 | $patterns[] = '/(<ref.*?\/>)/i'; |
83 | | - |
| 83 | + |
84 | 84 | // remove templates starting at the beginning of a line (or with whitespace) |
85 | 85 | $patterns[] = '/^\s*(\{\{.*?\}\})/ms'; |
86 | | - |
| 86 | + |
87 | 87 | // remove tables |
88 | 88 | $patterns[] = '/(\{\|.*?\|\})/'; |
89 | | - |
| 89 | + |
90 | 90 | // remove links with : in it |
91 | 91 | $patterns[] = '/(\[\[[^:\[\]]*:[^:\[\]]*\]\])/'; |
92 | | - |
| 92 | + |
93 | 93 | // remove headings |
94 | 94 | $patterns[] = '/^(=+[^=]*=+)\s*$/m'; |
95 | | - |
| 95 | + |
96 | 96 | // remove lists, indents, things like that |
97 | 97 | $patterns[] = '/^[\*#:;](.*)$/m'; |
98 | | - |
| 98 | + |
99 | 99 | return preg_replace_callback( $patterns, 'SentenceEditor::makeSpaces', $wikitext ); |
100 | 100 | } |
101 | | - |
| 101 | + |
102 | 102 | /** |
103 | 103 | * Function used by preprocess() to replace matches with spaces |
104 | 104 | * @param $matches array |
105 | 105 | * @return String |
106 | 106 | */ |
107 | 107 | protected static function makeSpaces ( $matches ) { |
108 | | - return str_repeat( ' ', strlen($matches[0]) ); |
| 108 | + return str_repeat( ' ', strlen( $matches[0] ) ); |
109 | 109 | } |
110 | | - |
| 110 | + |
111 | 111 | /** |
112 | 112 | * Splits the wikitext into pieces of actual text. A split is forced where there are |
113 | 113 | * two spaces or a newline. This way, it's possible to have the users define the sentences. |
— | — | @@ -116,12 +116,12 @@ |
117 | 117 | protected static function split( $wikitext ) { |
118 | 118 | // split where there are at least two spaces, or a newline, or the beginning of the text |
119 | 119 | $splits = preg_split( '/\s\s+|\n\s*|^/', $wikitext, -1, PREG_SPLIT_OFFSET_CAPTURE ); |
120 | | - |
| 120 | + |
121 | 121 | // remove small occurences |
122 | | - foreach( $splits as $index => $split ) { |
123 | | - if( strlen( $split[0] ) < 2 ) unset( $splits[$index] ); |
| 122 | + foreach ( $splits as $index => $split ) { |
| 123 | + if ( strlen( $split[0] ) < 2 ) unset( $splits[$index] ); |
124 | 124 | } |
125 | | - |
| 125 | + |
126 | 126 | return $splits; |
127 | 127 | } |
128 | | -} |
\ No newline at end of file |
| 128 | +} |
Index: trunk/extensions/InlineEditor/InlineEditor.php |
— | — | @@ -9,7 +9,7 @@ |
10 | 10 | * |
11 | 11 | * Usage: Include the following line in your LocalSettings.php |
12 | 12 | * require_once( "$IP/extensions/InlineEditor.php" ); |
13 | | - * |
| 13 | + * |
14 | 14 | * To enable all provided editors, add this in your LocalSettings.php: |
15 | 15 | * require_once( "$IP/extensions/InlineEditor/InlineEditor.php" ); |
16 | 16 | * require_once( "$IP/extensions/InlineEditor/SentenceEditor/SentenceEditor.php" ); |
— | — | @@ -37,7 +37,7 @@ |
38 | 38 | ); |
39 | 39 | |
40 | 40 | // current directory including trailing slash |
41 | | -$dir = dirname(__FILE__) . '/'; |
| 41 | +$dir = dirname( __FILE__ ) . '/'; |
42 | 42 | |
43 | 43 | // add autoload classes |
44 | 44 | $wgAutoloadClasses['InlineEditor'] = $dir . 'InlineEditor.class.php'; |
— | — | @@ -58,4 +58,4 @@ |
59 | 59 | |
60 | 60 | // default options |
61 | 61 | $wgInlineEditorBrowserBlacklist = $wgBrowserBlackList; |
62 | | -$wgInlineEditorAllowedNamespaces = array( NS_MAIN, NS_TALK, NS_USER, NS_USER_TALK ); |
\ No newline at end of file |
| 62 | +$wgInlineEditorAllowedNamespaces = array( NS_MAIN, NS_TALK, NS_USER, NS_USER_TALK ); |