Index: trunk/extensions/PageSchemas/specials/PS_EditSchema.php |
— | — | @@ -12,7 +12,7 @@ |
13 | 13 | } |
14 | 14 | public static function addJavascript() { |
15 | 15 | global $wgOut; |
16 | | - |
| 16 | + |
17 | 17 | PageSchemas::addJavascriptAndCSS(); |
18 | 18 | |
19 | 19 | // TODO - this should be in a JS file |
— | — | @@ -84,6 +84,7 @@ |
85 | 85 | $text_3 = '<p>This category exists,have a page schema. Edit schema:" </p>'; |
86 | 86 | $text_4 = ''; |
87 | 87 | self::addJavascript(); |
| 88 | + $pageSchemaObj = null; |
88 | 89 | $text_extensions = array(); //This var. will save the html text returned by the extensions |
89 | 90 | $js_extensions = array(); |
90 | 91 | wfRunHooks( 'getHtmlTextForFieldInputs', array( &$js_extensions, &$text_extensions )); |
— | — | @@ -249,13 +250,13 @@ |
250 | 251 | $params = array(); |
251 | 252 | $params['user_id'] = $wgUser->getId(); |
252 | 253 | $params['page_text'] = $pageText.$Xmltext; |
253 | | - $jobs[] = new PSCreatePageJob( $title, $params ); |
| 254 | + $jobs[] = new PSCreatePageJob( $title, $params ); |
254 | 255 | Job::batchInsert( $jobs ); |
255 | 256 | } |
256 | 257 | } |
257 | 258 | else{ |
258 | 259 | if ( $category != "" ) { |
259 | | - |
| 260 | + $pageSchemaObj = new PSSchema( $category ); |
260 | 261 | $title = Title::newFromText( $category, NS_CATEGORY ); |
261 | 262 | $pageId = $title->getArticleID(); |
262 | 263 | $dbr = wfGetDB( DB_SLAVE ); |
— | — | @@ -303,6 +304,7 @@ |
304 | 305 | if ( $tag == 'Template' ){ |
305 | 306 | $template_add_xml = ""; |
306 | 307 | $template_num++; |
| 308 | + $field_count = 0; |
307 | 309 | if( count($template_xml->children()) > 0 ){ |
308 | 310 | $templateName = (string) $template_xml->attributes()->name; |
309 | 311 | $text_4 .= '<div class="templateBox" >'; |
— | — | @@ -317,7 +319,7 @@ |
318 | 320 | if ( $field_xml->getName() != 'Field' ){ |
319 | 321 | $template_add_xml .= (string)$field_xml->asXML(); |
320 | 322 | } |
321 | | - } |
| 323 | + } |
322 | 324 | foreach ($template_xml->children() as $field_xml) { |
323 | 325 | if ( $field_xml->getName() == "Field" ){ |
324 | 326 | $fieldName = (string)$field_xml->attributes()->name; |
— | — | @@ -336,22 +338,32 @@ |
337 | 339 | } |
338 | 340 | } |
339 | 341 | $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.'" > |
341 | 343 | </p> '; |
342 | 344 | if($list_values){ |
343 | 345 | $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>'; |
345 | 347 | }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>'; |
348 | 350 | } |
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> |
351 | 362 | </p> |
352 | 363 | <input type="button" value="Remove field" class="deleteField" /></fieldset> |
353 | 364 | </div> |
354 | 365 | </div> |
355 | 366 | '; |
| 367 | + $field_count++; |
356 | 368 | } |
357 | 369 | |
358 | 370 | } |