r84142 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84141‎ | r84142 | r84143 >
Date:02:48, 17 March 2011
Author:yaron
Status:deferred
Tags:
Comment:
Improved setting of hidden field, other small changes
Modified paths:
  • /trunk/extensions/SemanticForms/specials/SF_CreateClass.php (modified) (history)
  • /trunk/extensions/SemanticForms/specials/SF_CreateForm.php (modified) (history)
  • /trunk/extensions/SemanticForms/specials/SF_CreateTemplate.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/specials/SF_CreateForm.php
@@ -45,7 +45,7 @@
4646 }
4747
4848 function doSpecialCreateForm() {
49 - global $wgOut, $wgRequest, $wgUser, $sfgScriptPath, $wgContLang;
 49+ global $wgOut, $wgRequest, $wgUser, $sfgScriptPath;
5050 $db = wfGetDB( DB_SLAVE );
5151
5252 SFUtils::loadMessages();
@@ -53,7 +53,6 @@
5454 // Create Javascript to populate fields to let the user input
5555 // parameters for the field, based on the input type selected in the
5656 // dropdown.
57 - global $wgUser;
5857 $skin = $wgUser->getSkin();
5958 $url = $skin->makeSpecialUrl( 'CreateForm', "showinputtypeoptions=' + this.val() + '&formfield=' + this.attr('formfieldid') + '" );
6059 foreach ( $wgRequest->getValues() as $param => $value ) {
@@ -205,10 +204,10 @@
206205 }
207206
208207 $text = ' <form action="" method="post">' . "\n";
 208+
209209 // Set 'title' field, in case there's no URL niceness.
210 - $mw_namespace_labels = $wgContLang->getNamespaces();
211 - $special_namespace = $mw_namespace_labels[NS_SPECIAL];
212 - $text .= "\t" . Xml::hidden( 'title', "$special_namespace:CreateForm" ) . "\n";
 210+ $cf = Title::makeTitleSafe( NS_SPECIAL, 'CreateForm' );
 211+ $text .= "\t" . Xml::hidden( 'title', SFUtils::titleURLString( $cf ) ) . "\n";
213212 $text .= ' <p>' . wfMsg( 'sf_createform_nameinput' ) . ' ' . wfMsg( 'sf_createform_nameinputdesc' ) . ' <input size=25 name="form_name" value="' . $form_name . '">';
214213 if ( ! empty( $form_name_error_str ) )
215214 $text .= ' ' . Xml::element( 'font', array( 'color' => 'red' ), $form_name_error_str );
Index: trunk/extensions/SemanticForms/specials/SF_CreateClass.php
@@ -110,11 +110,6 @@
111111
112112 $datatype_labels = $smwgContLang->getDatatypeLabels();
113113
114 - // set 'title' as hidden field, in case there's no URL niceness
115 - global $wgContLang;
116 - $mw_namespace_labels = $wgContLang->getNamespaces();
117 - $special_namespace = $mw_namespace_labels[NS_SPECIAL];
118 -
119114 // make links to all the other 'Create...' pages, in order to
120115 // link to them at the top of the page
121116 $sk = $wgUser->getSkin();
@@ -231,16 +226,12 @@
232227 'onclick' => "addRowDynamic('$optionsStr')"
233228 )
234229 );
235 - $text .= Xml::tags( 'p', null, $add_another_button );
 230+ $text .= Xml::tags( 'p', null, $add_another_button ) . "\n";
 231+ // Set 'title' as hidden field, in case there's no URL niceness
 232+ $cc = Title::makeTitleSafe( NS_SPECIAL, 'CreateClass' );
 233+ $text .= Xml::hidden( 'title', SFUtils::titleURLString( $cc ) ) . "\n";
236234 $text .= Xml::element( 'input',
237235 array(
238 - 'type' => 'hidden',
239 - 'name' => 'title',
240 - 'value' => "$special_namespace:CreateClass",
241 - )
242 - );
243 - $text .= Xml::element( 'input',
244 - array(
245236 'type' => 'submit',
246237 'name' => 'save',
247238 'value' => $create_button_text
Index: trunk/extensions/SemanticForms/specials/SF_CreateTemplate.php
@@ -6,10 +6,6 @@
77 * @author Yaron Koren
88 */
99
10 -/**
11 - * Protect against register_globals vulnerabilities.
12 - * This line must be present before any global variable is referenced.
13 - */
1410 if ( !defined( 'MEDIAWIKI' ) ) die();
1511
1612 class SFCreateTemplate extends SpecialPage {
@@ -30,10 +26,11 @@
3127 public static function getAllPropertyNames() {
3228 $all_properties = array();
3329
34 - // set limit on results - a temporary fix until SMW's
 30+ // Set limit on results - we don't want a massive dropdown
 31+ // of properties, if there are a lot of properties in this wiki.
3532 // getProperties() functions stop requiring a limit
3633 $options = new SMWRequestOptions();
37 - $options->limit = 10000;
 34+ $options->limit = 500;
3835 $used_properties = smwfGetStore()->getPropertiesSpecial( $options );
3936
4037 foreach ( $used_properties as $property ) {
@@ -92,7 +89,7 @@
9390 }
9491
9592 static function printCreateTemplateForm() {
96 - global $wgOut, $wgRequest, $wgUser, $sfgScriptPath, $wgContLang;
 93+ global $wgOut, $wgRequest, $wgUser, $sfgScriptPath;
9794
9895 SFUtils::loadMessages();
9996
@@ -103,7 +100,8 @@
104101 $category = $wgRequest->getVal( 'category' );
105102 $cur_id = 1;
106103 $fields = array();
107 - # cycle through the query values, setting the appropriate local variables
 104+ // Cycle through the query values, setting the appropriate
 105+ // local variables.
108106 foreach ( $wgRequest->getValues() as $var => $val ) {
109107 $var_elements = explode( "_", $var );
110108 // we only care about query variables of the form "a_b"
@@ -148,10 +146,10 @@
149147 }
150148
151149 $text .= ' <form action="" method="post">' . "\n";
 150+
152151 // set 'title' field, in case there's no URL niceness
153 - $mw_namespace_labels = $wgContLang->getNamespaces();
154 - $special_namespace = $mw_namespace_labels[NS_SPECIAL];
155 - $text .= "\t" . '<input type="hidden" name="title" value="' . $special_namespace . ':CreateTemplate">' . "\n";
 152+ $ct = Title::makeTitleSafe( NS_SPECIAL, 'CreateTemplate' );
 153+ $text .= "\t" . Xml::hidden( 'title', SFUtils::titleURLString( $ct ) ) . "\n";
156154 $text .= "\t<p>" . wfMsg( 'sf_createtemplate_namelabel' ) . ' <input size="25" name="template_name" value="' . $template_name . '"> <font color="red">' . $template_name_error_str . '</font></p>' . "\n";
157155 $text .= "\t<p>" . wfMsg( 'sf_createtemplate_categorylabel' ) . ' <input size="25" name="category" value="' . $category . '"></p>' . "\n";
158156 $text .= "\t<fieldset>\n";