r94322 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94321‎ | r94322 | r94323 >
Date:04:26, 12 August 2011
Author:ankitgarg833
Status:deferred
Tags:
Comment:
adding regex for <pageSchema> tag .
minor bugs.
Modified paths:
  • /trunk/extensions/PageSchemas/specials/PS_EditSchema.php (modified) (history)

Diff [purge]

Index: trunk/extensions/PageSchemas/specials/PS_EditSchema.php
@@ -229,7 +229,7 @@
230230 if( $xml_text_extensions['sf_form'] != null ){
231231 $Xmltext .= $xml_text_extensions['sf_form'];
232232 }
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.
234234 foreach ( $wgRequest->getValues() as $var => $val ) {
235235 if(substr($var,0,7) == 't_name_'){
236236 $templateNum = substr($var,7,1);
@@ -282,18 +282,24 @@
283283 }
284284 }
285285 $Xmltext .= '</PageSchema>';
 286+ $pageSchemaObj = new PSSchema( $category );
286287 $categoryTitle = Title::newFromText( $category, NS_CATEGORY );
287288 $categoryArticle = new Article( $categoryTitle );
288289 $pageText = $categoryArticle->getContent();
289 - //$replaced_text = preg_replace('/<PageSchema*<\/PageSchema>/', $Xmltext, $pageText );
 290+ $title = Title::newFromText( $category, NS_CATEGORY );
290291 $jobs = array();
291 - if( $wgRequest->getText('is_edit')=='true' ){
 292+ $params = array();
 293+ if( $pageSchemaObj->isPSDefined() ){
292294 //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 );
293301 }else{
294 - $title = Title::newFromText( $category, NS_CATEGORY );
295 - $params = array();
296302 $params['user_id'] = $wgUser->getId();
297 - $params['page_text'] = $Xmltext;
 303+ $params['page_text'] = $Xmltext.$pageText;
298304 $jobs[] = new PSCreatePageJob( $title, $params );
299305 Job::batchInsert( $jobs );
300306 }
@@ -426,7 +432,8 @@
427433 <textarea rows=4 style="width: 100%" name="f_add_xml_'.$field_count.'"></textarea>
428434 </p>
429435 <input type="button" value="Remove field" class="deleteField" /></fieldset>
430 - </div>
 436+ </div>
 437+ </div>
431438 ';
432439 $field_count++;
433440 $text_4 .= '<script type="text/javascript">

Status & tagging log