r95543 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95542‎ | r95543 | r95544 >
Date:23:06, 25 August 2011
Author:yaron
Status:ok
Tags:
Comment:
Fixes to r95541, for static methods
Modified paths:
  • /trunk/extensions/MeanEditor/MeanEditorEditPage.body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MeanEditor/MeanEditorEditPage.body.php
@@ -293,7 +293,7 @@
294294 return $buttons;
295295 }
296296
297 - function substitute_hashed_img_urls($text) {
 297+ static function substitute_hashed_img_urls($text) {
298298 while (preg_match('/\[\[Image:(.*?)\]\]/', $text, $matches)) {
299299 $img = $matches[1];
300300 $hash = md5($img);
@@ -306,7 +306,7 @@
307307 return $text;
308308 }
309309
310 - function deny_visual_because_of($reason, &$edit_context) {
 310+ static function deny_visual_because_of($reason, &$edit_context) {
311311 global $wgOut;
312312 $wgOut->addHTML('<p class="visual_editing_denied errorbox">' . wfMsg('no_visual') . '<em class="visual_editing_denied_reason">'.$reason.'</em></p>');
313313 # FIXME: Doesn't work. Why?
@@ -316,13 +316,13 @@
317317 }
318318
319319 # Return true to force traditional editing
320 - function wiki2html($article, $user, &$edit_context, &$wiki_text) {
 320+ static function wiki2html($article, $user, &$edit_context, &$wiki_text) {
321321 global $wgUploadPath, $wgArticlePath;
322322 $meaneditor_page_src = str_replace('$1', '', $wgArticlePath);
323323
324324 # Detect code sections (lines beginning with whitespace)
325325 if (preg_match('/^[ \t]/m',$wiki_text))
326 - return deny_visual_because_of(wfMsg('reason_whitespace'), $edit_context);
 326+ return self::deny_visual_because_of(wfMsg('reason_whitespace'), $edit_context);
327327
328328 # Detect custom tags: only <br />, super/sub-scripts and references are supported at the moment
329329 # TODO: expand the safe list
@@ -341,7 +341,7 @@
342342 $wiki_text=str_replace('<sub>','__TEMP__TEMP__sub',$wiki_text);
343343 $wiki_text=str_replace('</sub>','__TEMP__TEMP__csub',$wiki_text);
344344 if (!((strpos($wiki_text, '<')===FALSE) && (strpos($wiki_text, '>')===FALSE)))
345 - return deny_visual_because_of(wfMsg('reason_tag'), $edit_context);
 345+ return self::deny_visual_because_of(wfMsg('reason_tag'), $edit_context);
346346 $wiki_text=str_replace('__TEMP__TEMP__br','<br />', $wiki_text);
347347 $wiki_text=str_replace('__TEMP__TEMP__allreferences','references_here',$wiki_text);
348348 $wiki_text=str_replace('__TEMP__TEMP__sup','<sup>',$wiki_text);
@@ -355,7 +355,7 @@
356356 $unwanted_chars_at_beginning = array(':', ';');
357357 foreach ($unwanted_chars_at_beginning as $uc)
358358 if (preg_match('/^'.$uc.'/m',$wiki_text))
359 - return deny_visual_because_of(wfMsg('reason_indent', $uc), $edit_context);
 359+ return self::deny_visual_because_of(wfMsg('reason_indent', $uc), $edit_context);
360360
361361 # <hr>, from Parser.php... TODO: other regexps can be directly stolen from there
362362 $wiki_text=preg_replace('/(^|\n)-----*/', '\\1<hr />', $wiki_text);
@@ -384,7 +384,7 @@
385385 if (!$wgHashedUploadDirectory) {
386386 $wiki_text=preg_replace('/\[\[Image:(.*?)\]\]/','<img alt="\1" src="' . $wgUploadPath . '/\1" />',$wiki_text);
387387 } else {
388 - $wiki_text = substitute_hashed_img_urls($wiki_text);
 388+ $wiki_text = self::substitute_hashed_img_urls($wiki_text);
389389 }
390390
391391 $wiki_text=preg_replace('/\[\[Image:(.*?)\]\]/','<img alt="\1" src="' . $wgUploadPath . '/\1" />',$wiki_text);
@@ -395,7 +395,7 @@
396396
397397 #Substitute [[ syntax (internal links)
398398 if (preg_match('/\[\[([^|\]]*?):(.*?)\|(.*?)\]\]/',$wiki_text,$unwanted_matches))
399 - return deny_visual_because_of(wfMsg('reason_special_link', $unwanted_matches[0]), $edit_context);
 399+ return self::deny_visual_because_of(wfMsg('reason_special_link', $unwanted_matches[0]), $edit_context);
400400 #Preserve #section links from the draconic feature detection
401401 $wiki_text=preg_replace_callback('/\[\[(.*?)\|(.*?)\]\]/',
402402 create_function('$matches', 'return "[[".str_replace("#","__TEMP_MEAN_hash",$matches[1])."|".str_replace("#","__TEMP_MEAN_hash",$matches[2])."]]";'),
@@ -428,7 +428,7 @@
429429 $unwanted_chars = array('[', ']', '|', '{', '}', '#', '*');
430430 foreach ($unwanted_chars as $uc)
431431 if (!($unwanted_match = strpos($wiki_text, $uc) === FALSE))
432 - return deny_visual_because_of(wfMsg('reason_forbidden_char', $uc), $edit_context);
 432+ return self::deny_visual_because_of(wfMsg('reason_forbidden_char', $uc), $edit_context);
433433
434434 # Restore numbered entities
435435 $wiki_text=str_replace('__TEMP__MEAN__nument','&#',$wiki_text);
@@ -453,7 +453,7 @@
454454 return false;
455455 }
456456
457 - function html2wiki($article, $user, &$edit_context, &$html_text) {
 457+ static function html2wiki($article, $user, &$edit_context, &$html_text) {
458458 global $wgArticlePath;
459459 $meaneditor_page_src = str_replace('$1', '', $wgArticlePath);
460460 $meaneditor_page_src_escaped = addcslashes($meaneditor_page_src, '/.');
@@ -518,7 +518,7 @@
519519 return false;
520520 }
521521
522 - function showBox(&$edit_context, $html_text, $rows, $cols, $ew) {
 522+ static function showBox(&$edit_context, $html_text, $rows, $cols, $ew) {
523523 global $wgOut, $wgArticlePath, $wgStylePath, $wgUploadPath, $wgLang;
524524 $wiki_path = str_replace('$1', '', $wgArticlePath);
525525 $wgOut->addScriptFile('../../extensions/MeanEditor/wymeditor/jquery/jquery.js');

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r95541Moved some global functions into MeanEditorEditPage class, removed some unnec...yaron22:59, 25 August 2011

Status & tagging log