r90450 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90449‎ | r90450 | r90451 >
Date:09:11, 20 June 2011
Author:nikerabbit
Status:resolved
Tags:
Comment:
Clean up to CreateClass:
* Message fixes, including hardcoded punctuation and message reuse
* Zero to article constructor
* Some other code that was doing this in difficult way
Modified paths:
  • /trunk/extensions/SemanticForms/languages/SF_Messages.php (modified) (history)
  • /trunk/extensions/SemanticForms/specials/SF_CreateClass.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/specials/SF_CreateClass.php
@@ -61,8 +61,6 @@
6262 $numStartingRows = 10;
6363 self::addJavascript( $numStartingRows );
6464
65 - $create_button_text = wfMsg( 'create' );
66 -
6765 $property_name_error_str = '';
6866 $save_page = $wgRequest->getCheck( 'save' );
6967 if ( $save_page ) {
@@ -70,8 +68,7 @@
7169 $form_name = trim( $wgRequest->getVal( "form_name" ) );
7270 $category_name = trim( $wgRequest->getVal( "category_name" ) );
7371 if ( $template_name == '' | $form_name == '' || $category_name == '' ) {
74 - $text = Xml::element( 'p', null, wfMsg( 'sf_createclass_missingvalues' ) );
75 - $wgOut->addHTML( $text );
 72+ $wgOut->addWikiMsg( 'sf_createclass_missingvalues' );
7673 return;
7774 }
7875 $fields = array();
@@ -106,7 +103,7 @@
107104 // create the template, and save it
108105 $full_text = SFTemplateField::createTemplateText( $template_name, $fields, null, $category_name, null, null, null );
109106 $template_title = Title::makeTitleSafe( NS_TEMPLATE, $template_name );
110 - $template_article = new Article( $template_title );
 107+ $template_article = new Article( $template_title, 0 );
111108 $edit_summary = '';
112109 $template_article->doEdit( $full_text, $edit_summary );
113110
@@ -130,8 +127,7 @@
131128 $jobs[] = new SFCreatePageJob( $category_title, $params );
132129 Job::batchInsert( $jobs );
133130
134 - $text = Xml::element( 'p', null, wfMsg( 'sf_createclass_success' ) );
135 - $wgOut->addHTML( $text );
 131+ $wgOut->addWikiMsg( 'sf_createclass_success' );
136132 return;
137133 }
138134
@@ -147,21 +143,21 @@
148144 $creation_links[] = SFUtils::linkForSpecialPage( $sk, 'CreateCategory' );
149145 $create_class_docu = wfMsg( 'sf_createclass_docu', $wgLang->listToText( $creation_links ) );
150146 $leave_field_blank = wfMsg( 'sf_createclass_leavefieldblank' );
151 - $form_name_label = wfMsg( 'sf_createform_nameinput' );
 147+ $form_name_label = wfMsg( 'sf_createclass_nameinput' );
152148 $template_name_label = wfMsg( 'sf_createtemplate_namelabel' );
153149 $category_name_label = wfMsg( 'sf_createcategory_name' );
154150 $property_name_label = wfMsg( 'sf_createproperty_propname' );
155151 $field_name_label = wfMsg( 'sf_createtemplate_fieldname' );
156152 $type_label = wfMsg( 'sf_createproperty_proptype' );
157 - $allowed_values_label = wfMsg( 'sf_createclass_allowedvalues' ) . wfMsg( 'colon-separator' );
158 - $list_of_values_label = wfMsg( 'sf_createclass_listofvalues' ) . '?';
 153+ $allowed_values_label = wfMsg( 'sf_createclass_allowedvalues' );
 154+ $list_of_values_label = wfMsg( 'sf_createclass_listofvalues' );
159155
160156 $text = <<<END
161157 <form action="" method="post">
162158 <p>$create_class_docu</p>
163159 <p>$leave_field_blank</p>
164160 <p>$template_name_label <input type="text" size="30" name="template_name"></p>
165 - <p>$form_name_label: <input type="text" size="30" name="form_name"></p>
 161+ <p>$form_name_label <input type="text" size="30" name="form_name"></p>
166162 <p>$category_name_label <input type="text" size="30" name="category_name"></p>
167163 <div>
168164 <table id="mainTable">
@@ -222,13 +218,13 @@
223219 );
224220 $text .= Xml::tags( 'p', null, $add_another_button ) . "\n";
225221 // Set 'title' as hidden field, in case there's no URL niceness
226 - $cc = Title::makeTitleSafe( NS_SPECIAL, 'CreateClass' );
 222+ $cc = $this->getTitle();
227223 $text .= Html::Hidden( 'title', SFUtils::titleURLString( $cc ) ) . "\n";
228224 $text .= Xml::element( 'input',
229225 array(
230226 'type' => 'submit',
231227 'name' => 'save',
232 - 'value' => $create_button_text
 228+ 'value' => wfMsg( 'sf_createclass_create' );
233229 )
234230 );
235231 $text .= "</form>\n";
Index: trunk/extensions/SemanticForms/languages/SF_Messages.php
@@ -103,11 +103,13 @@
104104 'sf_createcategory_makesubcategory' => 'Make this a subcategory of another category (optional):',
105105 'createclass' => 'Create a class',
106106 'sf_createclass_docu' => 'Enter all the data here to create the properties, template, form and category for a single class. For more options, use the pages $1 instead.',
107 - 'sf_createclass_allowedvalues' => 'Allowed values',
108 - 'sf_createclass_listofvalues' => 'List of values',
 107+ 'sf_createclass_allowedvalues' => 'Allowed values:',
 108+ 'sf_createclass_listofvalues' => 'List of values?',
109109 'sf_createclass_leavefieldblank' => 'If the field name is the same as the property name, you can leave it blank.',
 110+ 'sf_createclass_nameinput' => 'Form name:',
110111 'sf_createclass_missingvalues' => 'Not all required fields were filled out.',
111112 'sf_createclass_success' => 'Properties, template, form and category will be created.',
 113+ 'sf_createclass_create' => 'Create',
112114 'formstart' => 'Start of form',
113115 'sf_formstart_badform' => 'Error: no form page was found at $1.',
114116 'sf_formstart_badtitle' => 'Error: "$1" is an invalid title for a page.',
@@ -128,7 +130,7 @@
129131 'sf_formcreate' => 'Create with form',
130132 'sf_viewform' => 'View form',
131133 'sf_editsource' => 'Edit source',
132 - 'sf_formedit_edittitle' => 'Edit $1: $2',
 134+ 'sf_formedit_edittitle' => 'Edit $1: $2',
133135 'sf_formedit_morethanoneform' => "'''Warning:''' More than one default form is defined for this page.",
134136 'sf_formedit_formwarning' => 'Warning: This page <a href="$1">already exists</a>, but it does not use this form.',
135137 'sf_formedit_remove' => 'Remove',

Follow-up revisions

RevisionCommit summaryAuthorDate
r90451And fix syntax error in r90450...nikerabbit09:14, 20 June 2011

Status & tagging log