Index: trunk/extensions/PageSchemas/specials/PS_EditSchema.php |
— | — | @@ -258,25 +258,25 @@ |
259 | 259 | /** |
260 | 260 | * Returns the HTML for a section of the form comprising one template. |
261 | 261 | */ |
262 | | - static function printTemplateSection( $template_num = 'tnum', $template_xml = null, $pageSchemaTemplate = null ) { |
263 | | - if ( is_null( $pageSchemaTemplate ) ) { |
264 | | - $pageSchemaTemplateFields = array(); |
| 262 | + static function printTemplateSection( $template_num = 'tnum', $templateXML = null, $psTemplate = null ) { |
| 263 | + if ( is_null( $psTemplate ) ) { |
| 264 | + $psTemplateFields = array(); |
265 | 265 | } else { |
266 | | - $pageSchemaTemplateFields = $pageSchemaTemplate->getFields(); |
| 266 | + $psTemplateFields = $psTemplate->getFields(); |
267 | 267 | } |
268 | 268 | $attrs = array(); |
269 | 269 | $templateXMLElements = array(); |
270 | 270 | $text = "\t"; |
271 | | - if ( is_null( $template_xml ) ) { |
| 271 | + if ( is_null( $templateXML ) ) { |
272 | 272 | $text .= '<div class="templateBox" id="starterTemplate" style="display: none">' . "\n"; |
273 | 273 | $templateName = ''; |
274 | 274 | } else { |
275 | 275 | $text .= '<div class="templateBox" >' . "\n"; |
276 | | - $templateName = (string) $template_xml->attributes()->name; |
277 | | - if ( ( (string)$template_xml->attributes()->multiple ) == "multiple" ) { |
| 276 | + $templateName = (string) $templateXML->attributes()->name; |
| 277 | + if ( ( (string)$templateXML->attributes()->multiple ) == "multiple" ) { |
278 | 278 | $attrs['checked'] = 'checked'; |
279 | 279 | } |
280 | | - $templateXMLElements = $template_xml->children(); |
| 280 | + $templateXMLElements = $templateXML->children(); |
281 | 281 | } |
282 | 282 | $templateNameInput = wfMsg( 'ps-namelabel' ) . ' '; |
283 | 283 | $templateNameInput .= Html::input( 't_name_' . $template_num, $templateName, 'text' ); |
— | — | @@ -294,7 +294,7 @@ |
295 | 295 | */ |
296 | 296 | |
297 | 297 | $htmlForTemplate = array(); |
298 | | - wfRunHooks( 'PageSchemasGetTemplateHTML', array( $pageSchemaTemplate, &$htmlForTemplate ) ); |
| 298 | + wfRunHooks( 'PageSchemasGetTemplateHTML', array( $psTemplate, &$htmlForTemplate ) ); |
299 | 299 | foreach ( $htmlForTemplate as $valuesFromExtension ) { |
300 | 300 | $html = self::printFieldHTMLForExtension( $valuesFromExtension ); |
301 | 301 | $templateHTML .= str_replace( 'num', $template_num, $html ); |
— | — | @@ -304,15 +304,15 @@ |
305 | 305 | $fieldNumInTemplate = 0; |
306 | 306 | // If this is a "starter" template, create the starter |
307 | 307 | // field HTML. |
308 | | - if ( is_null( $pageSchemaTemplate ) ) { |
| 308 | + if ( is_null( $psTemplate ) ) { |
309 | 309 | $templateHTML .= self::printFieldSection(); |
310 | 310 | } |
311 | 311 | foreach ( $templateXMLElements as $templateXMLElement ) { |
312 | 312 | if ( empty( $templateXMLElement ) ) { |
313 | 313 | // Do nothing (?) |
314 | 314 | } elseif ( $templateXMLElement->getName() == "Field" ) { |
315 | | - $pageSchemaField = $pageSchemaTemplateFields[$fieldNumInTemplate]; |
316 | | - $templateHTML .= self::printFieldSection( $templateXMLElement, $pageSchemaField ); |
| 315 | + $psTemplateField = $psTemplateFields[$fieldNumInTemplate]; |
| 316 | + $templateHTML .= self::printFieldSection( $templateXMLElement, $psTemplateField ); |
317 | 317 | $fieldNumInTemplate++; |
318 | 318 | } |
319 | 319 | } |
— | — | @@ -342,9 +342,9 @@ |
343 | 343 | wfRunHooks( 'PageSchemasGetSchemaHTML', array( $pageSchemaObj, &$htmlForSchema ) ); |
344 | 344 | |
345 | 345 | if ( is_null( $pageSchemaObj ) ) { |
346 | | - $template_all = array(); |
| 346 | + $psTemplates = array(); |
347 | 347 | } else { |
348 | | - $template_all = $pageSchemaObj->getTemplates(); |
| 348 | + $psTemplates = $pageSchemaObj->getTemplates(); |
349 | 349 | } |
350 | 350 | |
351 | 351 | if ( is_null( $pageXML ) ) { |
— | — | @@ -373,16 +373,16 @@ |
374 | 374 | |
375 | 375 | $text .= '<div id="templatesList">' . "\n"; |
376 | 376 | |
377 | | - $template_num = 0; |
| 377 | + $templateNum = 0; |
378 | 378 | |
379 | 379 | // Add 'starter', hidden template section. |
380 | 380 | $text .= self::printTemplateSection(); |
381 | 381 | /* index for template objects */ |
382 | | - foreach ( $pageXMLChildren as $tag => $template_xml ) { |
| 382 | + foreach ( $pageXMLChildren as $tag => $pageXMLChild ) { |
383 | 383 | if ( $tag == 'Template' ) { |
384 | | - $pageSchemaTemplate = $template_all[$template_num]; |
385 | | - $text .= self::printTemplateSection( $template_num, $template_xml, $pageSchemaTemplate ); |
386 | | - $template_num++; |
| 384 | + $psTemplate = $psTemplates[$templateNum]; |
| 385 | + $text .= self::printTemplateSection( $templateNum, $pageXMLChild, $psTemplate ); |
| 386 | + $templateNum++; |
387 | 387 | } |
388 | 388 | } |
389 | 389 | $add_template_button = Xml::element( 'input', |