r94160 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94159‎ | r94160 | r94161 >
Date:15:43, 10 August 2011
Author:ankitgarg833
Status:deferred
Tags:
Comment:
adding Form related Xml and html
Modified paths:
  • /trunk/extensions/PageSchemas/specials/PS_EditSchema.php (modified) (history)

Diff [purge]

Index: trunk/extensions/PageSchemas/specials/PS_EditSchema.php
@@ -90,9 +90,8 @@
9191 self::addJavascript();
9292 $pageSchemaObj = null;
9393 $text_extensions = array(); //This var. will save the html text returned by the extensions
94 - $js_extensions = array();
95 - wfRunHooks( 'getHtmlTextForFieldInputs', array( &$js_extensions, &$text_extensions ));
96 -
 94+ $js_extensions = array();
 95+ wfRunHooks( 'getHtmlTextForFieldInputs', array( &$js_extensions, &$text_extensions ));
9796 $text = "";
9897 $text .= '<p>This category does not exist yet. Create this category and its page schema: </p>';
9998 $text .= ' <form id="createPageSchemaForm" action="" method="post">' . "\n";
@@ -100,6 +99,10 @@
101100 $text .= '<p>Additional XML:
102101 <textarea rows=4 style="width: 100%" name="ps_add_xml"></textarea>
103102 </p> ';
 103+ if($text_extensions['sf_form'] != null){
 104+ $text_ex = preg_replace('/starter/', '1', $text_extensions['sf_form']);
 105+ $text .= $text_ex;
 106+ }
104107 $text .= '<div id="templatesList">';
105108 $text .= '<div class="templateBox" >';
106109 $text .= '<fieldset style="background: #ddd;"><legend>Template</legend> ';
@@ -115,10 +118,18 @@
116119 This field can hold a list of values
117120 </p>
118121 <div class="delimiterInput" style="display: none" ><p>Delimiter for values (default is ","): <input type="text" name="f_delimiter_1" /> </p></div>';
119 - foreach( $text_extensions as $text_ex ){
120 - $text_ex = preg_replace('/starter/', '1', $text_ex);
121 - $text .= $text_ex ;
122 - }
 122+ if($text_extensions['smw'] != null){
 123+ $text_ex = preg_replace('/starter/', '1', $text_extensions['smw']);
 124+ $text .= $text_ex;
 125+ }
 126+ if($text_extensions['sf'] != null){
 127+ $text_ex = preg_replace('/starter/', '1', $text_extensions['sf']);
 128+ $text .= $text_ex;
 129+ }
 130+ if($text_extensions['sd'] != null){
 131+ $text_ex = preg_replace('/starter/', '1', $text_extensions['sd']);
 132+ $text .= $text_ex;
 133+ }
123134 $text .= '<p>Additional XML:
124135 <textarea rows=4 style="width: 100%" name="f_add_xml_1"></textarea>
125136 </p>
@@ -204,10 +215,13 @@
205216 $xml_text_extensions = array(); //This var. will save the xml text returned by the extensions
206217 $js_extensions = array();
207218 wfRunHooks( 'getXmlTextForFieldInputs', array( $wgRequest, &$xml_text_extensions ));
 219+ if( $xml_text_extensions['sf_form'] != null ){
 220+ $Xmltext .= $xml_text_extensions['sf_form'];
 221+ }
208222 $indexGlobalField = 0 ; //this variable is use to index the array returned by extensions for XML.
209 - foreach ( $wgRequest->getValues() as $var => $val ) {
 223+ foreach ( $wgRequest->getValues() as $var => $val ) {
210224 if(substr($var,0,7) == 't_name_'){
211 - $templateNum = substr($var,7,1);
 225+ $templateNum = substr($var,7,1);
212226 if($wgRequest->getCheck( 'is_multiple_'.$templateNum )){
213227 $Xmltext .= '<Template name="'.$val.'" multiple="multiple">';
214228 }else{
@@ -229,9 +243,24 @@
230244 }else if(substr($var,0,8) == 'f_label_'){
231245 $Xmltext .= '<Label>'.$val.'</Label>';
232246 //Get Xml parsed from extensions,
233 - foreach( $xml_text_extensions as $xml_ex_array ){
234 - $Xmltext .= $xml_ex_array[$indexGlobalField] ;
 247+ if( $xml_text_extensions['smw'] != null ){
 248+ $xml_ex_array = $xml_text_extensions['smw'];
 249+ if($xml_ex_array[$indexGlobalField] != null){
 250+ $Xmltext .= $xml_ex_array[$indexGlobalField] ;
 251+ }
235252 }
 253+ if( $xml_text_extensions['sf'] != null ){
 254+ $xml_ex_array = $xml_text_extensions['sf'];
 255+ if($xml_ex_array[$indexGlobalField] != null){
 256+ $Xmltext .= $xml_ex_array[$indexGlobalField] ;
 257+ }
 258+ }
 259+ if( $xml_text_extensions['sd'] != null ){
 260+ $xml_ex_array = $xml_text_extensions['sd'];
 261+ if($xml_ex_array[$indexGlobalField] != null){
 262+ $Xmltext .= $xml_ex_array[$indexGlobalField] ;
 263+ }
 264+ }
236265 $indexGlobalField++ ;
237266 }else if(substr($var,0,10) == 'f_add_xml_'){
238267 $Xmltext .= $val;
@@ -241,13 +270,11 @@
242271 $Xmltext .= '</Template>';
243272 }
244273 }
245 - $Xmltext .= '</PageSchema>';
246 - wfDebugLog( 'myextension', 'Xmltext: ' . print_r( $Xmltext, true ) );
 274+ $Xmltext .= '</PageSchema>';
247275 $categoryTitle = Title::newFromText( $category, NS_CATEGORY );
248276 $categoryArticle = new Article( $categoryTitle );
249277 $pageText = $categoryArticle->getContent();
250 - $replaced_text = preg_replace('/<PageSchema>*<\/PageSchema>/', $Xmltext, $pageText );
251 - wfDebugLog( 'myextension', 'Xmltext: ' . print_r( $replaced_text, true ) );
 278+ //$replaced_text = preg_replace('/<PageSchema*<\/PageSchema>/', $Xmltext, $pageText );
252279 $jobs = array();
253280 if( $wgRequest->getText('is_edit')=='true' ){
254281 //Do some preg-replace magic
@@ -295,15 +322,21 @@
296323 $text_4 .= '<form id="editPageSchemaForm" action="" method="post">' . "\n";
297324 $text_4 .= '<p>Name of schema: <input type="text" name="s_name" value="'.$pageName.'" /> </p> ';
298325 foreach ( $pageXml->children() as $template_xml ) {
299 - if ( $template_xml->getName() != 'Template' ){
 326+ if ( ($template_xml->getName() != 'Template') && ($template_xml->getName() != 'Form') ){
300327 $ps_add_xml .= (string)$template_xml->asXML();
301328 }
302329 }
303330 $text_4 .= '<p>Additional XML:
304331 <textarea rows=4 style="width: 100%" name="ps_add_xml" >'.$ps_add_xml.'</textarea>
305332 </p> ';
306 - $text_4 .= '<div id="templatesList">';
307333
 334+ $filled_html_text_extensions = array();
 335+ wfRunHooks( 'getFilledHtmlTextForFieldInputs', array( $pageSchemaObj, &$filled_html_text_extensions ));
 336+ if($filled_html_text_extensions['sf_form'] != null){
 337+ $text_ex = preg_replace('/starter/', '1', $filled_html_text_extensions['sf_form']);
 338+ $text_4 .= $text_ex;
 339+ }
 340+ $text_4 .= '<div id="templatesList">';
308341 $template_num = 0;
309342 /* index for template objects */
310343 foreach ( $pageXml->children() as $tag => $template_xml ) {
@@ -355,14 +388,29 @@
356389 $text_4 .= '<div class="delimiterInput" style="display: none" ><p>Delimiter for values (default is ","): <input type="text" name="f_delimiter_'.$field_count.'" /> </p></div>';
357390 }
358391 //Inserting HTML text from Extensions
359 - $filled_html_text_extensions = array();
360 - wfRunHooks( 'getFilledHtmlTextForFieldInputs', array( $pageSchemaObj, &$filled_html_text_extensions ));
361 - foreach( $filled_html_text_extensions as $text_ex_array ){
 392+
 393+ if( $filled_html_text_extensions['smw'] != null ){
 394+ $text_ex_array = $filled_html_text_extensions['smw'];
362395 if( $text_ex_array[$field_count] != null ){
363396 $text_ex = preg_replace('/starter/', $field_count, $text_ex_array[$field_count]);
364397 $text_4 .= $text_ex;
365398 }
366 - }
 399+ }
 400+ if( $filled_html_text_extensions['sf'] != null ){
 401+ $text_ex_array = $filled_html_text_extensions['sf'];
 402+ if( $text_ex_array[$field_count] != null ){
 403+ $text_ex = preg_replace('/starter/', $field_count, $text_ex_array[$field_count]);
 404+ $text_4 .= $text_ex;
 405+ }
 406+ }
 407+ if( $filled_html_text_extensions['sd'] != null ){
 408+ $text_ex_array = $filled_html_text_extensions['sd'];
 409+ if( $text_ex_array[$field_count] != null ){
 410+ $text_ex = preg_replace('/starter/', $field_count, $text_ex_array[$field_count]);
 411+ $text_4 .= $text_ex;
 412+ }
 413+ }
 414+
367415 $text_4 .= '<p>Additional XML:
368416 <textarea rows=4 style="width: 100%" name="f_add_xml_'.$field_count.'"></textarea>
369417 </p>

Status & tagging log