r107888 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107887‎ | r107888 | r107889 >
Date:15:27, 3 January 2012
Author:yaron
Status:ok
Tags:
Comment:
emoved a variety of code for backward compatibility for MW < 1.16, which is no longer supported - especially calls to SFUtils::loadMessages()
Modified paths:
  • /trunk/extensions/SemanticForms/SemanticForms.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_FormEditTab.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_FormLinker.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_FormPrinter.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_FormUtils.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_ParserFunctions.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_Utils.php (modified) (history)
  • /trunk/extensions/SemanticForms/specials/SF_CreateCategory.php (modified) (history)
  • /trunk/extensions/SemanticForms/specials/SF_CreateClass.php (modified) (history)
  • /trunk/extensions/SemanticForms/specials/SF_CreateForm.php (modified) (history)
  • /trunk/extensions/SemanticForms/specials/SF_CreateProperty.php (modified) (history)
  • /trunk/extensions/SemanticForms/specials/SF_CreateTemplate.php (modified) (history)
  • /trunk/extensions/SemanticForms/specials/SF_FormEdit.php (modified) (history)
  • /trunk/extensions/SemanticForms/specials/SF_FormStart.php (modified) (history)
  • /trunk/extensions/SemanticForms/specials/SF_Forms.php (modified) (history)
  • /trunk/extensions/SemanticForms/specials/SF_RunQuery.php (modified) (history)
  • /trunk/extensions/SemanticForms/specials/SF_Templates.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/specials/SF_Forms.php
@@ -17,7 +17,6 @@
1818 */
1919 function __construct() {
2020 parent::__construct( 'Forms' );
21 - SFUtils::loadMessages();
2221 }
2322
2423 function execute( $query ) {
@@ -55,8 +54,6 @@
5655 function getPageHeader() {
5756 global $wgUser;
5857
59 - SFUtils::loadMessages();
60 -
6158 $sk = $wgUser->getSkin();
6259 $create_form_link = SFUtils::linkForSpecialPage( $sk, 'CreateForm' );
6360 $header = "<p>" . $create_form_link . ".</p>\n";
Index: trunk/extensions/SemanticForms/specials/SF_CreateForm.php
@@ -18,7 +18,6 @@
1919 */
2020 function __construct() {
2121 parent::__construct( 'CreateForm' );
22 - SFUtils::loadMessages();
2322 }
2423
2524 function execute( $query ) {
@@ -51,8 +50,6 @@
5251 global $wgOut, $wgRequest, $wgUser, $sfgScriptPath;
5352 $db = wfGetDB( DB_SLAVE );
5453
55 - SFUtils::loadMessages();
56 -
5754 // Create Javascript to populate fields to let the user input
5855 // parameters for the field, based on the input type selected
5956 // in the dropdown.
Index: trunk/extensions/SemanticForms/specials/SF_CreateProperty.php
@@ -18,7 +18,6 @@
1919 */
2020 function __construct() {
2121 parent::__construct( 'CreateProperty' );
22 - SFUtils::loadMessages();
2322 }
2423
2524 function execute( $query ) {
@@ -58,8 +57,6 @@
5958 global $wgOut, $wgRequest, $sfgScriptPath;
6059 global $smwgContLang;
6160
62 - SFUtils::loadMessages();
63 -
6461 # cycle through the query values, setting the appropriate local variables
6562 $property_name = $wgRequest->getVal( 'property_name' );
6663 $property_type = $wgRequest->getVal( 'property_type' );
Index: trunk/extensions/SemanticForms/specials/SF_CreateClass.php
@@ -19,7 +19,6 @@
2020 */
2121 public function __construct() {
2222 parent::__construct( 'CreateClass', 'createclass' );
23 - SFUtils::loadMessages();
2423 }
2524
2625 static function addJavascript( $numStartingRows ) {
Index: trunk/extensions/SemanticForms/specials/SF_FormEdit.php
@@ -22,7 +22,6 @@
2323 */
2424 function __construct() {
2525 parent::__construct( 'FormEdit' );
26 - SFUtils::loadMessages();
2726 }
2827
2928 function execute( $query, $redirectOnError = true ) {
@@ -90,8 +89,6 @@
9190 static function printForm( &$form_name, &$target_name, $alt_forms = array(), $redirectOnError = false ) {
9291 global $wgOut, $wgRequest, $wgUser, $sfgFormPrinter;
9392
94 - SFUtils::loadMessages();
95 -
9693 // If we have no form name we might as well stop right away
9794 if ( $form_name === '' ) {
9895 return 'sf_formedit_badurl';
Index: trunk/extensions/SemanticForms/specials/SF_RunQuery.php
@@ -17,7 +17,6 @@
1818 */
1919 function __construct() {
2020 parent::__construct( 'RunQuery' );
21 - SFUtils::loadMessages();
2221 }
2322
2423 function execute( $query ) {
@@ -88,11 +87,8 @@
8988 // isn't needed.
9089 if ( $wgParser->getOutput() == null ) {
9190 $headItems = array();
92 - // method was added in MW 1.16
93 - } elseif ( method_exists( $wgParser->getOutput(), 'getHeadItems' ) ) {
94 - $headItems = $wgParser->getOutput()->getHeadItems();
9591 } else {
96 - $headItems = $wgParser->getOutput()->mHeadItems;
 92+ $headItems = $wgParser->getOutput()->getHeadItems();
9793 }
9894 foreach ( $headItems as $key => $item ) {
9995 $wgOut->addHeadItem( $key, "\t\t" . $item . "\n" );
Index: trunk/extensions/SemanticForms/specials/SF_Templates.php
@@ -17,7 +17,6 @@
1818 */
1919 function __construct() {
2020 parent::__construct( 'Templates' );
21 - SFUtils::loadMessages();
2221 }
2322
2423 function execute( $query ) {
@@ -56,8 +55,6 @@
5756 function getPageHeader() {
5857 global $wgUser;
5958
60 - SFUtils::loadMessages();
61 -
6259 $sk = $wgUser->getSkin();
6360 $create_template_link = SFUtils::linkForSpecialPage( $sk, 'CreateTemplate' );
6461 $header = "<p>" . $create_template_link . ".</p>\n";
@@ -115,7 +112,6 @@
116113 $text = $skin->makeLinkObj( $title, htmlspecialchars( $title->getText() ) );
117114 $category = $this->getCategoryDefinedByTemplate( $title );
118115 if ( $category !== '' ) {
119 - SFUtils::loadMessages();
120116 $text .= ' ' . wfMsgExt( 'sf_templates_definescat', 'parseinline', SFUtils::linkText( NS_CATEGORY, $category ) );
121117 }
122118 return $text;
Index: trunk/extensions/SemanticForms/specials/SF_CreateTemplate.php
@@ -18,7 +18,6 @@
1919 */
2020 public function SFCreateTemplate() {
2121 parent::__construct( 'CreateTemplate' );
22 - SFUtils::loadMessages();
2322 }
2423
2524 public function execute( $query ) {
@@ -73,8 +72,6 @@
7473 }
7574
7675 public static function printFieldEntryBox( $id, $all_properties, $display = true ) {
77 - SFUtils::loadMessages();
78 -
7976 $fieldString = $display ? '' : 'id="starterField" style="display: none"';
8077 $text = "\t<div class=\"fieldBox\" $fieldString>\n";
8178 $text .= "\t<p>" . wfMsg( 'sf_createtemplate_fieldname' ) . ' ' .
@@ -150,7 +147,6 @@
151148 function printCreateTemplateForm() {
152149 global $wgOut, $wgRequest, $wgUser, $sfgScriptPath;
153150
154 - SFUtils::loadMessages();
155151 self::addJavascript();
156152
157153 $text = '';
Index: trunk/extensions/SemanticForms/specials/SF_CreateCategory.php
@@ -18,7 +18,6 @@
1919 */
2020 function __construct() {
2121 parent::__construct( 'CreateCategory' );
22 - SFUtils::loadMessages();
2322 }
2423
2524 function execute( $query ) {
@@ -27,7 +26,6 @@
2827 }
2928
3029 static function createCategoryText( $default_form, $category_name, $parent_category ) {
31 - SFUtils::loadMessages();
3230
3331 if ( $default_form === '' ) {
3432 $text = wfMsgForContent( 'sf_category_desc', $category_name );
@@ -50,8 +48,6 @@
5149 function doSpecialCreateCategory() {
5250 global $wgOut, $wgRequest, $wgUser, $sfgScriptPath;
5351
54 - SFUtils::loadMessages();
55 -
5652 # cycle through the query values, setting the appropriate local variables
5753 $category_name = $wgRequest->getVal( 'category_name' );
5854 $default_form = $wgRequest->getVal( 'default_form' );
Index: trunk/extensions/SemanticForms/specials/SF_FormStart.php
@@ -19,7 +19,6 @@
2020 */
2121 function __construct() {
2222 parent::__construct( 'FormStart' );
23 - SFUtils::loadMessages();
2423 }
2524
2625 function execute( $query ) {
@@ -27,7 +26,6 @@
2827
2928 $this->setHeaders();
3029
31 - SFUtils::loadMessages();
3230 $form_name = $wgRequest->getVal( 'form' );
3331 $target_namespace = $wgRequest->getVal( 'namespace' );
3432 $super_page = $wgRequest->getVal( 'super_page' );
Index: trunk/extensions/SemanticForms/includes/SF_FormEditTab.php
@@ -37,8 +37,6 @@
3838 global $wgRequest, $wgUser;
3939 global $sfgRenameEditTabs, $sfgRenameMainEditTab;
4040
41 - SFUtils::loadMessages();
42 -
4341 $user_can_edit = $wgUser->isAllowed( 'edit' ) && $title->userCan( 'edit' );
4442 // Create the form edit tab, and apply whatever changes are
4543 // specified by the edit-tab global variables.
@@ -144,7 +142,6 @@
145143 return true;
146144 }
147145 if ( count( $form_names ) > 1 ) {
148 - SFUtils::loadMessages();
149146 $warning_text = "\t" . '<div class="warningMessage">' . wfMsg( 'sf_formedit_morethanoneform' ) . "</div>\n";
150147 $wgOut->addHTML( $warning_text );
151148 }
Index: trunk/extensions/SemanticForms/includes/SF_Utils.php
@@ -14,25 +14,9 @@
1515 */
1616 public static function linkForSpecialPage( $skin, $specialPageName ) {
1717 $specialPage = SpecialPage::getPage( $specialPageName );
18 - // link() method was added in MW 1.16
19 - if ( method_exists( $skin, 'link' ) ) {
20 - return $skin->link( $specialPage->getTitle(), $specialPage->getDescription() );
21 - } else {
22 - return $skin->makeKnownLinkObj( $specialPage->getTitle(), $specialPage->getDescription() );
23 - }
 18+ return $skin->link( $specialPage->getTitle(), $specialPage->getDescription() );
2419 }
2520
26 - public static function isCapitalized( $title ) {
27 - // Method was added in MW 1.16.
28 - $realFunction = array( 'MWNamespace', 'isCapitalized' );
29 - if ( is_callable( $realFunction ) ) {
30 - return MWNamespace::isCapitalized( $title->getNamespace() );
31 - } else {
32 - global $wgCapitalLinks;
33 - return $wgCapitalLinks;
34 - }
35 - }
36 -
3721 /**
3822 * Creates the name of the page that appears in the URL;
3923 * this method is necessary because Title::getPartialURL(), for
@@ -43,7 +27,7 @@
4428 if ( $namespace !== '' ) {
4529 $namespace .= ':';
4630 }
47 - if ( self::isCapitalized( $title ) ) {
 31+ if ( MWNamespace::isCapitalized( $title->getNamespace() ) ) {
4832 global $wgContLang;
4933 return $namespace . $wgContLang->ucfirst( $title->getPartialURL() );
5034 } else {
@@ -60,7 +44,7 @@
6145 if ( $namespace !== '' ) {
6246 $namespace .= ':';
6347 }
64 - if ( self::isCapitalized( $title ) ) {
 48+ if ( MWNamespace::isCapitalized( $title->getNamespace() ) ) {
6549 global $wgContLang;
6650 return $namespace . $wgContLang->ucfirst( $title->getText() );
6751 } else {
@@ -652,7 +636,7 @@
653637
654638 // The query depends on whether this is a property, category,
655639 // concept or namespace.
656 - if ( $source_type == 'property' || $source_type == 'attribute' || $source_type == 'relation' ) {
 640+ if ( $source_type == 'property' ) {
657641 $names_array = self::getAllValuesForProperty( $source_name );
658642 } elseif ( $source_type == 'category' ) {
659643 $names_array = self::getAllPagesForCategory( $source_name, 10 );
@@ -719,27 +703,10 @@
720704 }
721705
722706 /**
723 - * Loads messages only for MediaWiki versions that need it (< 1.16)
724 - */
725 - public static function loadMessages() {
726 - global $wgVersion;
727 - if ( version_compare( $wgVersion, '1.16', '<' ) ) {
728 - wfLoadExtensionMessages( 'SemanticForms' );
729 - }
730 - }
731 -
732 - /**
733707 * Gets the word in the wiki's language, as defined in Semantic
734708 * MediaWiki, for either the value 'yes' or 'no'.
735709 */
736710 public static function getWordForYesOrNo( $isYes ) {
737 - global $wgVersion;
738 - // Manually load SMW's message values here, in case they
739 - // didn't get loaded before.
740 - if ( version_compare( $wgVersion, '1.16', '<' ) ) {
741 - wfLoadExtensionMessages( 'SemanticMediaWiki' );
742 - }
743 -
744711 $wordsMsg = ( $isYes ) ? 'smw_true_words' : 'smw_false_words';
745712 $possibleWords = explode( ',', wfMsgForContent( $wordsMsg ) );
746713 // Get the value in the series that tends to be "yes" or "no" -
Index: trunk/extensions/SemanticForms/includes/SF_FormPrinter.php
@@ -174,11 +174,7 @@
175175 if ( $count > 0 ) {
176176 $pager->mLimit = 10;
177177 $out->addHTML( '<div class="mw-warning-with-logexcerpt">' );
178 - // the message name changed in MW 1.16
179 - if ( ! wfEmptyMsg( 'moveddeleted-notice', wfMsg( 'moveddeleted-notice' ) ) )
180 - $out->addWikiMsg( 'moveddeleted-notice' );
181 - else
182 - $out->addWikiMsg( 'recreate-deleted-warn' );
 178+ $out->addWikiMsg( 'moveddeleted-notice' );
183179 $out->addHTML(
184180 $loglist->beginLogEventsList() .
185181 $pager->getBody() .
Index: trunk/extensions/SemanticForms/includes/SF_FormLinker.php
@@ -241,7 +241,6 @@
242242 if ( '' === $namespace_name ) {
243243 // If it's in the main (blank) namespace, check for the
244244 // file named with the word for "Main" in this language.
245 - SFUtils::loadMessages();
246245 $namespace_name = wfMsgForContent( 'sf_blank_namespace' );
247246 }
248247 if ( $form_edit_link = self::getFormEditLinkForPage( $title, $namespace_name, NS_PROJECT ) ) {
@@ -339,7 +338,6 @@
340339 if ( NS_MAIN === $namespace ) {
341340 // If it's in the main (blank) namespace, check for the
342341 // file named with the word for "Main" in this language.
343 - SFUtils::loadMessages();
344342 $namespace_label = wfMsgForContent( 'sf_blank_namespace' );
345343 } else {
346344 global $wgContLang;
Index: trunk/extensions/SemanticForms/includes/SF_FormUtils.php
@@ -41,12 +41,7 @@
4242 }
4343
4444 static function hiddenFieldHTML( $input_name, $cur_value ) {
45 - // 'Html' class was added in MW 1.16
46 - if ( class_exists( 'Html' ) ) {
47 - return "\t" . Html::hidden( $input_name, $cur_value ) . "\n";
48 - } else {
49 - return "\t" . Xml::hidden( $input_name, $cur_value ) . "\n";
50 - }
 45+ return "\t" . Html::hidden( $input_name, $cur_value ) . "\n";
5146 }
5247
5348 /**
Index: trunk/extensions/SemanticForms/includes/SF_ParserFunctions.php
@@ -199,8 +199,7 @@
200200 $inTooltip = Sanitizer::decodeCharReferences( $value );
201201 } elseif ( $param_name == 'target' ) {
202202 $inTargetName = $value;
203 - } elseif ( $param_name == null && $value == 'popup'
204 - && version_compare( $wgVersion, '1.16', '>=' ) ) {
 203+ } elseif ( $param_name == null && $value == 'popup' ) {
205204 self::loadScriptsForPopupForm( $parser );
206205 $classStr = 'popupformlink';
207206 }
@@ -315,8 +314,7 @@
316315 $autocompletion_type = 'namespace';
317316 } elseif ( $param_name == 'remote autocompletion' ) {
318317 $inRemoteAutocompletion = true;
319 - } elseif ( $param_name == null && $value == 'popup'
320 - && version_compare( $wgVersion, '1.16', '>=' ) ) {
 318+ } elseif ( $param_name == null && $value == 'popup' ) {
321319 self::loadScriptsForPopupForm( $parser );
322320 $classStr = 'popupforminput';
323321 }
@@ -415,7 +413,6 @@
416414 ) . "\n";
417415 }
418416 }
419 - SFUtils::loadMessages();
420417 $button_str = ( $inButtonStr != '' ) ? $inButtonStr : wfMsg( 'sf_formstart_createoredit' );
421418 $str .= <<<END
422419 <input type="submit" value="$button_str" /></p>
Index: trunk/extensions/SemanticForms/SemanticForms.php
@@ -172,7 +172,7 @@
173173
174174 $wgExtensionMessagesFiles['SemanticForms'] = $sfgIP . '/languages/SF_Messages.php';
175175 $wgExtensionMessagesFiles['SemanticFormsAlias'] = $sfgIP . '/languages/SF_Aliases.php';
176 -// Allow for file-upload windows for MW >= 1.16.1
 176+// Allow for popup windows for file upload
177177 $wgEditPageFrameOptions = 'SAMEORIGIN';
178178
179179 // register client-side modules

Status & tagging log