Index: trunk/extensions/PageSchemas/specials/PS_EditSchema.php |
— | — | @@ -90,9 +90,8 @@ |
91 | 91 | self::addJavascript(); |
92 | 92 | $pageSchemaObj = null; |
93 | 93 | $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 )); |
97 | 96 | $text = ""; |
98 | 97 | $text .= '<p>This category does not exist yet. Create this category and its page schema: </p>'; |
99 | 98 | $text .= ' <form id="createPageSchemaForm" action="" method="post">' . "\n"; |
— | — | @@ -100,6 +99,10 @@ |
101 | 100 | $text .= '<p>Additional XML: |
102 | 101 | <textarea rows=4 style="width: 100%" name="ps_add_xml"></textarea> |
103 | 102 | </p> '; |
| 103 | + if($text_extensions['sf_form'] != null){ |
| 104 | + $text_ex = preg_replace('/starter/', '1', $text_extensions['sf_form']); |
| 105 | + $text .= $text_ex; |
| 106 | + } |
104 | 107 | $text .= '<div id="templatesList">'; |
105 | 108 | $text .= '<div class="templateBox" >'; |
106 | 109 | $text .= '<fieldset style="background: #ddd;"><legend>Template</legend> '; |
— | — | @@ -115,10 +118,18 @@ |
116 | 119 | This field can hold a list of values |
117 | 120 | </p> |
118 | 121 | <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 | + } |
123 | 134 | $text .= '<p>Additional XML: |
124 | 135 | <textarea rows=4 style="width: 100%" name="f_add_xml_1"></textarea> |
125 | 136 | </p> |
— | — | @@ -204,10 +215,13 @@ |
205 | 216 | $xml_text_extensions = array(); //This var. will save the xml text returned by the extensions |
206 | 217 | $js_extensions = array(); |
207 | 218 | wfRunHooks( 'getXmlTextForFieldInputs', array( $wgRequest, &$xml_text_extensions )); |
| 219 | + if( $xml_text_extensions['sf_form'] != null ){ |
| 220 | + $Xmltext .= $xml_text_extensions['sf_form']; |
| 221 | + } |
208 | 222 | $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 ) { |
210 | 224 | if(substr($var,0,7) == 't_name_'){ |
211 | | - $templateNum = substr($var,7,1); |
| 225 | + $templateNum = substr($var,7,1); |
212 | 226 | if($wgRequest->getCheck( 'is_multiple_'.$templateNum )){ |
213 | 227 | $Xmltext .= '<Template name="'.$val.'" multiple="multiple">'; |
214 | 228 | }else{ |
— | — | @@ -229,9 +243,24 @@ |
230 | 244 | }else if(substr($var,0,8) == 'f_label_'){ |
231 | 245 | $Xmltext .= '<Label>'.$val.'</Label>'; |
232 | 246 | //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 | + } |
235 | 252 | } |
| 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 | + } |
236 | 265 | $indexGlobalField++ ; |
237 | 266 | }else if(substr($var,0,10) == 'f_add_xml_'){ |
238 | 267 | $Xmltext .= $val; |
— | — | @@ -241,13 +270,11 @@ |
242 | 271 | $Xmltext .= '</Template>'; |
243 | 272 | } |
244 | 273 | } |
245 | | - $Xmltext .= '</PageSchema>'; |
246 | | - wfDebugLog( 'myextension', 'Xmltext: ' . print_r( $Xmltext, true ) ); |
| 274 | + $Xmltext .= '</PageSchema>'; |
247 | 275 | $categoryTitle = Title::newFromText( $category, NS_CATEGORY ); |
248 | 276 | $categoryArticle = new Article( $categoryTitle ); |
249 | 277 | $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 ); |
252 | 279 | $jobs = array(); |
253 | 280 | if( $wgRequest->getText('is_edit')=='true' ){ |
254 | 281 | //Do some preg-replace magic |
— | — | @@ -295,15 +322,21 @@ |
296 | 323 | $text_4 .= '<form id="editPageSchemaForm" action="" method="post">' . "\n"; |
297 | 324 | $text_4 .= '<p>Name of schema: <input type="text" name="s_name" value="'.$pageName.'" /> </p> '; |
298 | 325 | foreach ( $pageXml->children() as $template_xml ) { |
299 | | - if ( $template_xml->getName() != 'Template' ){ |
| 326 | + if ( ($template_xml->getName() != 'Template') && ($template_xml->getName() != 'Form') ){ |
300 | 327 | $ps_add_xml .= (string)$template_xml->asXML(); |
301 | 328 | } |
302 | 329 | } |
303 | 330 | $text_4 .= '<p>Additional XML: |
304 | 331 | <textarea rows=4 style="width: 100%" name="ps_add_xml" >'.$ps_add_xml.'</textarea> |
305 | 332 | </p> '; |
306 | | - $text_4 .= '<div id="templatesList">'; |
307 | 333 | |
| 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">'; |
308 | 341 | $template_num = 0; |
309 | 342 | /* index for template objects */ |
310 | 343 | foreach ( $pageXml->children() as $tag => $template_xml ) { |
— | — | @@ -355,14 +388,29 @@ |
356 | 389 | $text_4 .= '<div class="delimiterInput" style="display: none" ><p>Delimiter for values (default is ","): <input type="text" name="f_delimiter_'.$field_count.'" /> </p></div>'; |
357 | 390 | } |
358 | 391 | //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']; |
362 | 395 | if( $text_ex_array[$field_count] != null ){ |
363 | 396 | $text_ex = preg_replace('/starter/', $field_count, $text_ex_array[$field_count]); |
364 | 397 | $text_4 .= $text_ex; |
365 | 398 | } |
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 | + |
367 | 415 | $text_4 .= '<p>Additional XML: |
368 | 416 | <textarea rows=4 style="width: 100%" name="f_add_xml_'.$field_count.'"></textarea> |
369 | 417 | </p> |