r93982 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93981‎ | r93982 | r93983 >
Date:16:23, 5 August 2011
Author:ankitgarg833
Status:deferred
Tags:
Comment:
SD code handled in EditSchema
Modified paths:
  • /trunk/extensions/PageSchemas/specials/PS_EditSchema.php (modified) (history)

Diff [purge]

Index: trunk/extensions/PageSchemas/specials/PS_EditSchema.php
@@ -12,7 +12,7 @@
1313 }
1414 public static function addJavascript() {
1515 global $wgOut;
16 -
 16+
1717 PageSchemas::addJavascriptAndCSS();
1818
1919 // TODO - this should be in a JS file
@@ -84,6 +84,7 @@
8585 $text_3 = '<p>This category exists,have a page schema. Edit schema:" </p>';
8686 $text_4 = '';
8787 self::addJavascript();
 88+ $pageSchemaObj = null;
8889 $text_extensions = array(); //This var. will save the html text returned by the extensions
8990 $js_extensions = array();
9091 wfRunHooks( 'getHtmlTextForFieldInputs', array( &$js_extensions, &$text_extensions ));
@@ -249,13 +250,13 @@
250251 $params = array();
251252 $params['user_id'] = $wgUser->getId();
252253 $params['page_text'] = $pageText.$Xmltext;
253 - $jobs[] = new PSCreatePageJob( $title, $params );
 254+ $jobs[] = new PSCreatePageJob( $title, $params );
254255 Job::batchInsert( $jobs );
255256 }
256257 }
257258 else{
258259 if ( $category != "" ) {
259 -
 260+ $pageSchemaObj = new PSSchema( $category );
260261 $title = Title::newFromText( $category, NS_CATEGORY );
261262 $pageId = $title->getArticleID();
262263 $dbr = wfGetDB( DB_SLAVE );
@@ -303,6 +304,7 @@
304305 if ( $tag == 'Template' ){
305306 $template_add_xml = "";
306307 $template_num++;
 308+ $field_count = 0;
307309 if( count($template_xml->children()) > 0 ){
308310 $templateName = (string) $template_xml->attributes()->name;
309311 $text_4 .= '<div class="templateBox" >';
@@ -317,7 +319,7 @@
318320 if ( $field_xml->getName() != 'Field' ){
319321 $template_add_xml .= (string)$field_xml->asXML();
320322 }
321 - }
 323+ }
322324 foreach ($template_xml->children() as $field_xml) {
323325 if ( $field_xml->getName() == "Field" ){
324326 $fieldName = (string)$field_xml->attributes()->name;
@@ -336,22 +338,32 @@
337339 }
338340 }
339341 $text_4 .= '<p>Field name: <input size="15" name="f_name_'.$template_num.'" value="'.$fieldName.'" >';
340 - $text_4 .= 'Display label: <input size="15" name="f_label_'.$template_num.'" value="'.$fieldLabel.'" >
 342+ $text_4 .= 'Display label: <input size="15" name="f_label_'.$field_count.'" value="'.$fieldLabel.'" >
341343 </p> ';
342344 if($list_values){
343345 $text_4 .= '<p><input type="checkbox" name="f_is_list_'.$template_num.'" checked class="isListCheckbox" /> This field can hold a list of values</p> ';
344 - $text_4 .= '<div class="delimiterInput" style="display:" ><p>Delimiter for values (default is ","): <input type="text" name="f_delimiter_'.$template_num.'" value="'.$delimiter.'" /> </p></div>';
 346+ $text_4 .= '<div class="delimiterInput" style="display:" ><p>Delimiter for values (default is ","): <input type="text" name="f_delimiter_'.$field_count.'" value="'.$delimiter.'" /> </p></div>';
345347 }else{
346 - $text_4 .= '<p><input type="checkbox" name="f_is_list_'.$template_num.'" class="isListCheckbox" /> This field can hold a list of values</p> ';
347 - $text_4 .= '<div class="delimiterInput" style="display: none" ><p>Delimiter for values (default is ","): <input type="text" name="f_delimiter_'.$template_num.'" /> </p></div>';
 348+ $text_4 .= '<p><input type="checkbox" name="f_is_list_'.$field_count.'" class="isListCheckbox" /> This field can hold a list of values</p> ';
 349+ $text_4 .= '<div class="delimiterInput" style="display: none" ><p>Delimiter for values (default is ","): <input type="text" name="f_delimiter_'.$field_count.'" /> </p></div>';
348350 }
349 - $text_4 .= '<p>Additional XML:
350 - <textarea rows=4 style="width: 100%" name="f_add_xml_'.$template_num.'"></textarea>
 351+ //Inserting HTML text from Extensions
 352+ $filled_html_text_extensions = array();
 353+ wfRunHooks( 'getFilledHtmlTextForFieldInputs', array( $pageSchemaObj, &$filled_html_text_extensions ));
 354+ foreach( $filled_html_text_extensions as $text_ex_array ){
 355+ if( $text_ex_array[$field_count] != null ){
 356+ $text_ex = preg_replace('/starter/', $field_count, $text_ex_array[$field_count]);
 357+ $text_4 .= $text_ex;
 358+ }
 359+ }
 360+ $text_4 .= '<p>Additional XML:
 361+ <textarea rows=4 style="width: 100%" name="f_add_xml_'.$field_count.'"></textarea>
351362 </p>
352363 <input type="button" value="Remove field" class="deleteField" /></fieldset>
353364 </div>
354365 </div>
355366 ';
 367+ $field_count++;
356368 }
357369
358370 }

Status & tagging log