Index: trunk/extensions/PageSchemas/specials/PS_EditSchema.php |
— | — | @@ -229,7 +229,7 @@ |
230 | 230 | if( $xml_text_extensions['sf_form'] != null ){ |
231 | 231 | $Xmltext .= $xml_text_extensions['sf_form']; |
232 | 232 | } |
233 | | - $indexGlobalField = 0 ; //this variable is use to index the array returned by extensions for XML. |
| 233 | + $indexGlobalField = 0 ; //this variable is use to index the array returned by extensions for XML. |
234 | 234 | foreach ( $wgRequest->getValues() as $var => $val ) { |
235 | 235 | if(substr($var,0,7) == 't_name_'){ |
236 | 236 | $templateNum = substr($var,7,1); |
— | — | @@ -282,18 +282,24 @@ |
283 | 283 | } |
284 | 284 | } |
285 | 285 | $Xmltext .= '</PageSchema>'; |
| 286 | + $pageSchemaObj = new PSSchema( $category ); |
286 | 287 | $categoryTitle = Title::newFromText( $category, NS_CATEGORY ); |
287 | 288 | $categoryArticle = new Article( $categoryTitle ); |
288 | 289 | $pageText = $categoryArticle->getContent(); |
289 | | - //$replaced_text = preg_replace('/<PageSchema*<\/PageSchema>/', $Xmltext, $pageText ); |
| 290 | + $title = Title::newFromText( $category, NS_CATEGORY ); |
290 | 291 | $jobs = array(); |
291 | | - if( $wgRequest->getText('is_edit')=='true' ){ |
| 292 | + $params = array(); |
| 293 | + if( $pageSchemaObj->isPSDefined() ){ |
292 | 294 | //Do some preg-replace magic |
| 295 | + $tag = "PageSchema"; |
| 296 | + $replaced_text = preg_replace('{<'.$tag.'[^>]*>([^@]*?)</'.$tag.'>'.'}', $Xmltext , $pageText); |
| 297 | + $params['user_id'] = $wgUser->getId(); |
| 298 | + $params['page_text'] = $replaced_text; |
| 299 | + $jobs[] = new PSCreatePageJob( $title, $params ); |
| 300 | + Job::batchInsert( $jobs ); |
293 | 301 | }else{ |
294 | | - $title = Title::newFromText( $category, NS_CATEGORY ); |
295 | | - $params = array(); |
296 | 302 | $params['user_id'] = $wgUser->getId(); |
297 | | - $params['page_text'] = $Xmltext; |
| 303 | + $params['page_text'] = $Xmltext.$pageText; |
298 | 304 | $jobs[] = new PSCreatePageJob( $title, $params ); |
299 | 305 | Job::batchInsert( $jobs ); |
300 | 306 | } |
— | — | @@ -426,7 +432,8 @@ |
427 | 433 | <textarea rows=4 style="width: 100%" name="f_add_xml_'.$field_count.'"></textarea> |
428 | 434 | </p> |
429 | 435 | <input type="button" value="Remove field" class="deleteField" /></fieldset> |
430 | | - </div> |
| 436 | + </div> |
| 437 | + </div> |
431 | 438 | '; |
432 | 439 | $field_count++; |
433 | 440 | $text_4 .= '<script type="text/javascript"> |