r99693 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99692‎ | r99693 | r99694 >
Date:16:39, 13 October 2011
Author:yaron
Status:deferred
Tags:
Comment:
Bug fixes and display improvements for automatically-created templates
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_TemplateField.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_TemplateField.php
@@ -154,8 +154,9 @@
155155 }
156156
157157 /**
158 - * Creates the text of a template, when called from either
159 - * Special:CreateTemplate or Special:CreateClass.
 158+ * Creates the text of a template, when called from
 159+ * Special:CreateTemplate, Special:CreateClass or the Page Schemas
 160+ * extension.
160161 *
161162 * @TODO: There's really no good reason why this method is contained
162163 * within this class.
@@ -179,11 +180,10 @@
180181 </pre>
181182 $template_footer
182183 </noinclude><includeonly>
183 -
184184 END;
185185 // Only add a call to #set_internal if the Semantic Internal
186186 // Objects extension is also installed.
187 - if ( !empty( $internal_obj_property) && class_exists( 'SIOInternalObject' ) ) {
 187+ if ( !empty( $internal_obj_property ) && class_exists( 'SIOInternalObject' ) ) {
188188 $setInternalText = '{{#set_internal:' . $internal_obj_property;
189189 } else {
190190 $setInternalText = null;
@@ -211,19 +211,20 @@
212212 $tableText .= "! " . $field->mLabel . "\n";
213213 if ( empty( $field->mSemanticProperty ) ) {
214214 $tableText .= "| {{{" . $field->mFieldName . "|}}}\n";
215 - // if this field is meant to contain a list,
216 - // add on an 'arraymap' function, that will
217 - // call this semantic markup tag on every
218 - // element in the list
219215 } elseif ( !is_null( $setInternalText ) ) {
 216+ $tableText .= "| {{{" . $field->mFieldName . "|}}}\n";
220217 if ( $field->mIsList ) {
221218 $setInternalText .= '|' . $field->mSemanticProperty . '#list={{{' . $field->mFieldName . '|}}}';
222219 } else {
223220 $setInternalText .= '|' . $field->mSemanticProperty . '={{{' . $field->mFieldName . '|}}}';
224221 }
225222 } elseif ( $field->mIsList ) {
226 - // find a string that's not in the semantic
227 - // field call, to be used as the variable
 223+ // If this field is meant to contain a list,
 224+ // add on an 'arraymap' function, that will
 225+ // call this semantic markup tag on every
 226+ // element in the list.
 227+ // Find a string that's not in the semantic
 228+ // field call, to be used as the variable.
228229 $var = "x"; // default - use this if all the attempts fail
229230 if ( strstr( $field->mSemanticProperty, $var ) ) {
230231 $var_options = array( 'y', 'z', 'xx', 'yy', 'zz', 'aa', 'bb', 'cc' );
@@ -252,9 +253,14 @@
253254
254255 END;
255256 }
256 - $tableText .= "|}\n";
257 - if ( !is_null( $setInternalText ) ) {
258 - $setInternalText .= "}}\n";
 257+ $tableText .= "|}";
 258+ // Leave out newlines if there's an internal property
 259+ // set here (which would mean that there are meant to be
 260+ // multiple instances of this template.)
 261+ if ( is_null( $setInternalText ) ) {
 262+ $tableText .= "\n";
 263+ } else {
 264+ $setInternalText .= "}}";
259265 $text .= $setInternalText;
260266 }
261267