Index: trunk/extensions/PageSchemas/specials/PS_GeneratePages.php |
— | — | @@ -8,12 +8,10 @@ |
9 | 9 | class GeneratePages extends IncludableSpecialPage { |
10 | 10 | function __construct() { |
11 | 11 | parent::__construct( 'GeneratePages' ); |
12 | | - wfLoadExtensionMessages('GeneratePages'); |
13 | 12 | } |
14 | 13 | |
15 | 14 | function execute( $category ) { |
16 | 15 | global $wgRequest, $wgOut; |
17 | | - global $wgSkin; |
18 | 16 | |
19 | 17 | $this->setHeaders(); |
20 | 18 | $param = $wgRequest->getText('param'); |
— | — | @@ -57,7 +55,6 @@ |
58 | 56 | // the page to be created. |
59 | 57 | wfRunHooks( 'PageSchemasGetPageList', array( $pageSchemaObj, &$pageList ) ); |
60 | 58 | foreach( $pageList as $page ){ |
61 | | - //$page_link = $wgSkin->link( $page ); |
62 | 59 | $pageURL = $page->getFullUrl(); |
63 | 60 | $pageName = PageSchemas::titleString( $page ); |
64 | 61 | $pageLink = Html::element( 'a', array( 'href' => $pageURL ), $pageName ); |
— | — | @@ -70,7 +67,6 @@ |
71 | 68 | } |
72 | 69 | |
73 | 70 | function generatePages ( $categoryName, $toGenPageList ) { |
74 | | - global $wgRequest, $wgOut; |
75 | 71 | $pageSchema = new PSSchema( $categoryName ); |
76 | 72 | $pageSchema->generateAllPages( $toGenPageList ); |
77 | 73 | } |
Index: trunk/extensions/PageSchemas/specials/PS_EditSchema.php |
— | — | @@ -8,7 +8,6 @@ |
9 | 9 | class EditSchema extends IncludableSpecialPage { |
10 | 10 | function __construct() { |
11 | 11 | parent::__construct( 'EditSchema' ); |
12 | | - wfLoadExtensionMessages('EditSchema'); |
13 | 12 | } |
14 | 13 | |
15 | 14 | public static function addJavascript() { |
— | — | @@ -82,36 +81,22 @@ |
83 | 82 | $wgOut->addScript( $jsText ); |
84 | 83 | } |
85 | 84 | |
86 | | - function execute( $category ) { |
87 | | - global $wgRequest, $wgOut, $wgUser; |
88 | | - global $wgSkin; |
89 | | - |
90 | | - $this->setHeaders(); |
91 | | - $text_1 = '<p>'.wfMsg( 'ps-page-desc-cat-not-exist' ).'</p>'; |
92 | | - $text_2 = '<p>'.wfMsg( 'ps-page-desc-ps-not-exist' ).'</p>'; |
93 | | - $text_3 = '<p>'.wfMsg( 'ps-page-desc-edit-schema' ).'</p>'; |
94 | | - $text_4 = ''; |
95 | | - self::addJavascript(); |
96 | | - $schema_name_label = wfMsg('ps-schema-name-label'); |
| 85 | + function blankFormHTML( $htmlFromExtensions ) { |
| 86 | + //$schema_name_label = wfMsg('ps-schema-name-label'); |
97 | 87 | $add_xml_label = wfMsg('ps-add-xml-label'); |
98 | 88 | |
99 | | - $pageSchemaObj = null; |
100 | | - $text_extensions = array(); //This var. will save the html text returned by the extensions |
101 | | - $js_extensions = array(); |
102 | | - wfRunHooks( 'getHtmlTextForFieldInputs', array( &$js_extensions, &$text_extensions )); |
103 | | - $text = ""; |
104 | | - $text .= ' <form id="createPageSchemaForm" action="" method="post">' . "\n"; |
| 89 | + $text = ' <form id="createPageSchemaForm" action="" method="post">' . "\n"; |
105 | 90 | //$text .= '<p>'.$schema_name_label.' <input type="text" name="s_name"/> </p> '; |
106 | 91 | $text .= '<p>'.$add_xml_label.' |
107 | 92 | <textarea rows=4 style="width: 100%" name="ps_add_xml"></textarea> |
108 | 93 | </p> '; |
109 | | - if ($text_extensions['sf_form'] != null ) { |
110 | | - $text_ex = preg_replace('/starter/', '1', $text_extensions['sf_form']); |
| 94 | + if ( $htmlFromExtensions['sf_form'] != null ) { |
| 95 | + $text_ex = preg_replace( '/starter/', '1', $htmlFromExtensions['sf_form'] ); |
111 | 96 | $text .= $text_ex; |
112 | 97 | } |
113 | | - $delimeter_label = wfMsg('ps-delimeter-label'); |
114 | | - $multiple_temp_label = wfMsg('ps-multiple-temp-label'); |
115 | | - $field_list_label = wfMsg('ps-field-list-label'); |
| 98 | + $delimeter_label = wfMsg( 'ps-delimeter-label' ); |
| 99 | + $multiple_temp_label = wfMsg( 'ps-multiple-temp-label' ); |
| 100 | + $field_list_label = wfMsg( 'ps-field-list-label' ); |
116 | 101 | |
117 | 102 | $text .= '<div id="templatesList">'; |
118 | 103 | $text .= '<div class="templateBox" >'; |
— | — | @@ -128,16 +113,16 @@ |
129 | 114 | $field_list_label . ' |
130 | 115 | </p> |
131 | 116 | <div class="delimiterInput" style="display: none" ><p>' . $delimeter_label . ' <input type="text" name="f_delimiter_1" /> </p></div>'; |
132 | | - if ($text_extensions['smw'] != null ) { |
133 | | - $text_ex = preg_replace('/starter/', '1', $text_extensions['smw']); |
| 117 | + if ( $htmlFromExtensions['smw'] != null ) { |
| 118 | + $text_ex = preg_replace( '/starter/', '1', $htmlFromExtensions['smw'] ); |
134 | 119 | $text .= $text_ex; |
135 | 120 | } |
136 | | - if ($text_extensions['sf'] != null ) { |
137 | | - $text_ex = preg_replace('/starter/', '1', $text_extensions['sf']); |
| 121 | + if ($htmlFromExtensions['sf'] != null ) { |
| 122 | + $text_ex = preg_replace('/starter/', '1', $htmlFromExtensions['sf']); |
138 | 123 | $text .= $text_ex; |
139 | 124 | } |
140 | | - if ($text_extensions['sd'] != null ) { |
141 | | - $text_ex = preg_replace('/starter/', '1', $text_extensions['sd']); |
| 125 | + if ($htmlFromExtensions['sd'] != null ) { |
| 126 | + $text_ex = preg_replace('/starter/', '1', $htmlFromExtensions['sd']); |
142 | 127 | $text .= $text_ex; |
143 | 128 | } |
144 | 129 | |
— | — | @@ -176,6 +161,11 @@ |
177 | 162 | <input type="submit" id="wpSave" name="wpSave" value="Save" /> |
178 | 163 | </div>'; |
179 | 164 | $text .= ' </form>'; |
| 165 | + |
| 166 | + return $text; |
| 167 | + } |
| 168 | + |
| 169 | + function starterFieldHTML( $htmlFromExtensions ) { |
180 | 170 | $starter_text = '<div class="templateBox" id="starterTemplate" style="display: none"> |
181 | 171 | <fieldset style="background: #ddd;"> |
182 | 172 | <legend>Template</legend> |
— | — | @@ -202,14 +192,14 @@ |
203 | 193 | <p><input type="checkbox" name="f_is_list_starter" class="isListCheckbox" /> This field can hold a list of values |
204 | 194 |   </p> |
205 | 195 | <div class="delimiterInput" style="display: none" ><p>Delimiter for values (default is ","): <input type="text" name="f_delimiter_starter" /> </p></div>'; |
206 | | - if ($text_extensions['smw'] != null ) { |
207 | | - $starter_text .= $text_extensions['smw']; |
| 196 | + if ($htmlFromExtensions['smw'] != null ) { |
| 197 | + $starter_text .= $htmlFromExtensions['smw']; |
208 | 198 | } |
209 | | - if ($text_extensions['sf'] != null ) { |
210 | | - $starter_text .= $text_extensions['sf']; |
| 199 | + if ($htmlFromExtensions['sf'] != null ) { |
| 200 | + $starter_text .= $htmlFromExtensions['sf']; |
211 | 201 | } |
212 | | - if ($text_extensions['sd'] != null ) { |
213 | | - $starter_text .= $text_extensions['sd']; |
| 202 | + if ($htmlFromExtensions['sd'] != null ) { |
| 203 | + $starter_text .= $htmlFromExtensions['sd']; |
214 | 204 | } |
215 | 205 | $starter_text .= '<p>'.$add_xml_label.' |
216 | 206 | <textarea rows=4 style="width: 100%" name="f_add_xml_starter"></textarea> |
— | — | @@ -217,23 +207,36 @@ |
218 | 208 | <input type="button" value="Remove field" class="deleteField" /> |
219 | 209 | </fieldset> |
220 | 210 | </div>'; |
221 | | - $text .= $starter_text; |
| 211 | + return $starter_text; |
| 212 | + } |
| 213 | + |
| 214 | + function execute( $category ) { |
| 215 | + global $wgRequest, $wgOut, $wgUser; |
| 216 | + global $wgSkin; |
| 217 | + |
| 218 | + $this->setHeaders(); |
| 219 | + $text_3 = '<p>'.wfMsg( 'ps-page-desc-edit-schema' ).'</p>'; |
| 220 | + self::addJavascript(); |
| 221 | + |
| 222 | + $htmlFromExtensions = array(); //This var. will save the html text returned by the extensions |
| 223 | + $js_extensions = array(); |
| 224 | + wfRunHooks( 'getHtmlTextForFieldInputs', array( &$js_extensions, &$htmlFromExtensions ) ); |
| 225 | + |
222 | 226 | $save_page = $wgRequest->getCheck( 'wpSave' ); |
223 | 227 | if ( $save_page ) { |
224 | | - //Generate the Xml from the Form elements |
| 228 | + //Generate the XML from the Form elements |
225 | 229 | $XMLtext = ""; |
226 | 230 | //$s_name = $wgRequest->getText('s_name'); |
227 | 231 | $XMLtext .= '<PageSchema>'; |
228 | | - $ps_add_xml = $wgRequest->getText('ps_add_xml'); |
| 232 | + $ps_add_xml = $wgRequest->getText( 'ps_add_xml' ); |
229 | 233 | $XMLtext .= $ps_add_xml; |
230 | 234 | $fieldName = ""; |
231 | 235 | $fieldNum= -1; |
232 | 236 | $templateNum = -1; |
233 | | - $xml_text_extensions = array(); //This var. will save the xml text returned by the extensions |
234 | | - $js_extensions = array(); |
235 | | - wfRunHooks( 'getXmlTextForFieldInputs', array( $wgRequest, &$xml_text_extensions )); |
236 | | - if ( $xml_text_extensions['sf_form'] != null ) { |
237 | | - $XMLtext .= $xml_text_extensions['sf_form']; |
| 237 | + $xmlFromExtensions = array(); //This var. will save the xml text returned by the extensions |
| 238 | + wfRunHooks( 'getXmlTextForFieldInputs', array( $wgRequest, &$xmlFromExtensions )); |
| 239 | + if ( $xmlFromExtensions['sf_form'] != null ) { |
| 240 | + $XMLtext .= $xmlFromExtensions['sf_form']; |
238 | 241 | } |
239 | 242 | $indexGlobalField = 0 ; //this variable is use to index the array returned by extensions for XML. |
240 | 243 | foreach ( $wgRequest->getValues() as $var => $val ) { |
— | — | @@ -260,20 +263,20 @@ |
261 | 264 | } elseif (substr($var,0,8) == 'f_label_' ) { |
262 | 265 | $XMLtext .= '<Label>'.$val.'</Label>'; |
263 | 266 | //Get XML parsed from extensions |
264 | | - if ( $xml_text_extensions['smw'] != null ) { |
265 | | - $xml_ex_array = $xml_text_extensions['smw']; |
| 267 | + if ( $xmlFromExtensions['smw'] != null ) { |
| 268 | + $xml_ex_array = $xmlFromExtensions['smw']; |
266 | 269 | if ($xml_ex_array[$indexGlobalField] != null ) { |
267 | 270 | $XMLtext .= $xml_ex_array[$indexGlobalField] ; |
268 | 271 | } |
269 | 272 | } |
270 | | - if ( $xml_text_extensions['sf'] != null ) { |
271 | | - $xml_ex_array = $xml_text_extensions['sf']; |
| 273 | + if ( $xmlFromExtensions['sf'] != null ) { |
| 274 | + $xml_ex_array = $xmlFromExtensions['sf']; |
272 | 275 | if ($xml_ex_array[$indexGlobalField] != null ) { |
273 | 276 | $XMLtext .= $xml_ex_array[$indexGlobalField] ; |
274 | 277 | } |
275 | 278 | } |
276 | | - if ( $xml_text_extensions['sd'] != null ) { |
277 | | - $xml_ex_array = $xml_text_extensions['sd']; |
| 279 | + if ( $xmlFromExtensions['sd'] != null ) { |
| 280 | + $xml_ex_array = $xmlFromExtensions['sd']; |
278 | 281 | if ($xml_ex_array[$indexGlobalField] != null ) { |
279 | 282 | $XMLtext .= $xml_ex_array[$indexGlobalField] ; |
280 | 283 | } |
— | — | @@ -292,7 +295,6 @@ |
293 | 296 | $categoryTitle = Title::newFromText( $category, NS_CATEGORY ); |
294 | 297 | $categoryArticle = new Article( $categoryTitle ); |
295 | 298 | $pageText = $categoryArticle->getContent(); |
296 | | - $title = Title::newFromText( $category, NS_CATEGORY ); |
297 | 299 | $jobs = array(); |
298 | 300 | $params = array(); |
299 | 301 | if ( $pageSchemaObj->isPSDefined() ) { |
— | — | @@ -304,213 +306,223 @@ |
305 | 307 | $params['page_text'] = $XMLtext . $pageText; |
306 | 308 | } |
307 | 309 | $params['user_id'] = $wgUser->getId(); |
308 | | - $jobs[] = new PSCreatePageJob( $title, $params ); |
| 310 | + $jobs[] = new PSCreatePageJob( $categoryTitle, $params ); |
309 | 311 | Job::batchInsert( $jobs ); |
310 | | - } else { |
311 | | - if ( $category != "" ) { |
312 | | - $pageSchemaObj = new PSSchema( $category ); |
313 | | - $title = Title::newFromText( $category, NS_CATEGORY ); |
314 | | - $pageId = $title->getArticleID(); |
315 | | - $dbr = wfGetDB( DB_SLAVE ); |
316 | | - //get the result set, query : slect page_props |
317 | | - $res = $dbr->select( 'page_props', |
| 312 | + return true; |
| 313 | + } |
| 314 | + |
| 315 | + if ( $category == "" ) { |
| 316 | + // No category was specified - show the list of categories with a page schema defined. |
| 317 | + $cat_titles = array(); |
| 318 | + $count_title = 0; |
| 319 | + $text = ""; |
| 320 | + $dbr = wfGetDB( DB_SLAVE ); |
| 321 | + //get the result set, query : slect page_props |
| 322 | + $res = $dbr->select( 'page_props', |
318 | 323 | array( |
319 | 324 | 'pp_page', |
320 | 325 | 'pp_propname', |
321 | 326 | 'pp_value' |
322 | 327 | ), |
323 | 328 | array( |
324 | | - 'pp_page' => $pageId, |
325 | | - ) |
326 | | - ); |
327 | | - //first row of the result set |
328 | | - $row = $dbr->fetchRow( $res ); |
329 | | - if ( $row == null && !$title->exists() ) { |
330 | | - //Create form here, Cat doesnt exist, create new cat with this text |
331 | | - $text_1 .= $text; |
332 | | - $wgOut->addHTML( $text_1 ); |
333 | | - } else { |
334 | | - if ( ($row[1] == 'PageSchema') && ($row[2] != null ) ) { |
335 | | - //Populate the form here with autocompleted values |
336 | | - $pageXMLstr = $row[2]; |
337 | | - $pageXML = simplexml_load_string ( $pageXMLstr ); |
338 | | - $ps_add_xml = ""; |
339 | | - //$pageName = (string)$pageXML->attributes()->name; |
340 | | - $text_4 .= ''; |
341 | | - $text_4 .= '<form id="editPageSchemaForm" action="" method="post">' . "\n"; |
342 | | - //$text_4 .= '<p>'.$schema_name_label.' <input type="text" name="s_name" value="'.$pageName.'" /> </p> '; |
343 | | - foreach ( $pageXML->children() as $template_xml ) { |
344 | | - if ( ($template_xml->getName() != 'Template') && ($template_xml->getName() != 'semanticforms_Form') ) { |
345 | | - $ps_add_xml .= (string)$template_xml->asXML(); |
346 | | - } |
347 | | - } |
348 | | - $text_4 .= '<p>' . $add_xml_label . ' |
| 329 | + 'pp_propname' => 'PageSchema' |
| 330 | + ) |
| 331 | + ); |
| 332 | + while ( $row = $dbr->fetchRow( $res ) ) { |
| 333 | + if ( $row[2] != null ) { |
| 334 | + $page_id_cat = $row[0]; |
| 335 | + if ( Title::newFromId($page_id_cat)->getNamespace() == NS_CATEGORY ) { |
| 336 | + $cat_text = Title::newFromId($page_id_cat)->getText(); |
| 337 | + $generatePagesPage = SpecialPage::getTitleFor( 'EditSchema' ); |
| 338 | + $url = $generatePagesPage ->getFullURL() . '/' . $cat_text; |
| 339 | + $text .= '<a href='.$url.'>' . $cat_text . '</a> <br /> '; |
| 340 | + } |
| 341 | + } |
| 342 | + } |
| 343 | + $dbr->freeResult( $res ); |
| 344 | + $wgOut->addHTML( $text ); |
| 345 | + return true; |
| 346 | + } |
| 347 | + |
| 348 | + // We have a category - show a form. |
| 349 | + $formHTML = self::blankFormHTML( $htmlFromExtensions ); |
| 350 | + $formHTML .= self::starterFieldHTML( $htmlFromExtensions ); |
| 351 | + |
| 352 | + $pageSchemaObj = new PSSchema( $category ); |
| 353 | + $title = Title::newFromText( $category, NS_CATEGORY ); |
| 354 | + $pageId = $title->getArticleID(); |
| 355 | + $dbr = wfGetDB( DB_SLAVE ); |
| 356 | + //get the result set, query : select page_props |
| 357 | + $res = $dbr->select( 'page_props', |
| 358 | + array( |
| 359 | + 'pp_page', |
| 360 | + 'pp_propname', |
| 361 | + 'pp_value' |
| 362 | + ), |
| 363 | + array( |
| 364 | + 'pp_page' => $pageId, |
| 365 | + ) |
| 366 | + ); |
| 367 | + |
| 368 | + //first row of the result set |
| 369 | + $row = $dbr->fetchRow( $res ); |
| 370 | + if ( $row == null && !$title->exists() ) { |
| 371 | + //Create form here, Cat doesnt exist, create new cat with this text |
| 372 | + $text = '<p>'.wfMsg( 'ps-page-desc-cat-not-exist' ).'</p>'; |
| 373 | + $text .= $formHTML; |
| 374 | + $wgOut->addHTML( $text ); |
| 375 | + return true; |
| 376 | + } |
| 377 | + |
| 378 | + if ( ($row[1] != 'PageSchema') || ($row[2] == null ) ) { |
| 379 | + $text = '<p>'.wfMsg( 'ps-page-desc-ps-not-exist' ).'</p>'; |
| 380 | + $text .= $formHTML; |
| 381 | + $wgOut->addHTML($text ); |
| 382 | + } |
| 383 | + |
| 384 | + // Populate the form here with autocompleted values |
| 385 | + $pageXMLstr = $row[2]; |
| 386 | + $pageXML = simplexml_load_string( $pageXMLstr ); |
| 387 | + $ps_add_xml = ""; |
| 388 | + //$pageName = (string)$pageXML->attributes()->name; |
| 389 | + $text_4 = '<form id="editPageSchemaForm" action="" method="post">' . "\n"; |
| 390 | + //$text_4 .= '<p>'.$schema_name_label.' <input type="text" name="s_name" value="'.$pageName.'" /> </p> '; |
| 391 | + foreach ( $pageXML->children() as $template_xml ) { |
| 392 | + if ( ( $template_xml->getName() != 'Template') && ($template_xml->getName() != 'semanticforms_Form') ) { |
| 393 | + $ps_add_xml .= (string)$template_xml->asXML(); |
| 394 | + } |
| 395 | + } |
| 396 | + $text_4 .= '<p>' . $add_xml_label . ' |
349 | 397 | <textarea rows=4 style="width: 100%" name="ps_add_xml" >' . $ps_add_xml . '</textarea> |
350 | 398 | </p> '; |
351 | 399 | |
352 | | - $filled_html_text_extensions = array(); |
353 | | - wfRunHooks( 'getFilledHtmlTextForFieldInputs', array( $pageSchemaObj, &$filled_html_text_extensions )); |
354 | | - if ( $filled_html_text_extensions['sf_form'] != null ) { |
355 | | - $text_ex = preg_replace('/starter/', '1', $filled_html_text_extensions['sf_form']); |
356 | | - $text_4 .= $text_ex; |
| 400 | + $filledHTMLFromExtensions = array(); |
| 401 | + wfRunHooks( 'getFilledHtmlTextForFieldInputs', array( $pageSchemaObj, &$filledHTMLFromExtensions )); |
| 402 | + if ( $filledHTMLFromExtensions['sf_form'] != null ) { |
| 403 | + $text_ex = preg_replace('/starter/', '1', $filledHTMLFromExtensions['sf_form']); |
| 404 | + $text_4 .= $text_ex; |
| 405 | + } |
| 406 | + $text_4 .= '<div id="templatesList">'; |
| 407 | + $template_num = 0; |
| 408 | + /* index for template objects */ |
| 409 | + foreach ( $pageXML->children() as $tag => $template_xml ) { |
| 410 | + if ( $tag == 'Template' ) { |
| 411 | + $template_add_xml = ""; |
| 412 | + $template_num++; |
| 413 | + $field_count = 0; |
| 414 | + if ( count($template_xml->children()) > 0 ) { |
| 415 | + $templateName = (string) $template_xml->attributes()->name; |
| 416 | + $text_4 .= '<div class="templateBox" >'; |
| 417 | + $text_4 .= '<fieldset style="background: #ddd;"><legend>Template</legend> '; |
| 418 | + $text_4 .= '<p>Name: <input type="text" name="t_name_'.$template_num.'" value="'.$templateName.'" /></p> '; |
| 419 | + if ( ((string) $template_xml->attributes()->multiple) == "multiple" ) { |
| 420 | + $text_4 .= '<p><input type="checkbox" checked name="is_multiple_'.$template_num.'"/> Allow multiple instances of this template</p> '; |
| 421 | + } else { |
| 422 | + $text_4 .= '<p><input type="checkbox" name="is_multiple_'.$template_num.'"/> Allow multiple instances of this template</p> '; |
| 423 | + } |
| 424 | + foreach ( $template_xml->children() as $field_xml ) { |
| 425 | + if ( $field_xml->getName() != 'Field' ) { |
| 426 | + $template_add_xml .= (string)$field_xml->asXML(); |
357 | 427 | } |
358 | | - $text_4 .= '<div id="templatesList">'; |
359 | | - $template_num = 0; |
360 | | - /* index for template objects */ |
361 | | - foreach ( $pageXML->children() as $tag => $template_xml ) { |
362 | | - if ( $tag == 'Template' ) { |
363 | | - $template_add_xml = ""; |
364 | | - $template_num++; |
365 | | - $field_count = 0; |
366 | | - if ( count($template_xml->children()) > 0 ) { |
367 | | - $templateName = (string) $template_xml->attributes()->name; |
368 | | - $text_4 .= '<div class="templateBox" >'; |
369 | | - $text_4 .= '<fieldset style="background: #ddd;"><legend>Template</legend> '; |
370 | | - $text_4 .= '<p>Name: <input type="text" name="t_name_'.$template_num.'" value="'.$templateName.'" /></p> '; |
371 | | - if ( ((string) $template_xml->attributes()->multiple) == "multiple" ) { |
372 | | - $text_4 .= '<p><input type="checkbox" checked name="is_multiple_'.$template_num.'"/> Allow multiple instances of this template</p> '; |
373 | | - } else { |
374 | | - $text_4 .= '<p><input type="checkbox" name="is_multiple_'.$template_num.'"/> Allow multiple instances of this template</p> '; |
375 | | - } |
376 | | - foreach ( $template_xml->children() as $field_xml ) { |
377 | | - if ( $field_xml->getName() != 'Field' ) { |
378 | | - $template_add_xml .= (string)$field_xml->asXML(); |
379 | | - } |
380 | | - } |
381 | | - $text_4 .= '<div id="fieldsList_'.$template_num.'">'; |
382 | | - $list_values = false; |
383 | | - foreach ($template_xml->children() as $field_xml) { |
384 | | - if ( $field_xml->getName() == "Field" ) { |
385 | | - $fieldName = (string)$field_xml->attributes()->name; |
386 | | - $text_4 .= '<div class="fieldBox" >'; |
387 | | - $text_4 .= '<fieldset style="background: #bbb;"><legend>Field</legend> '; |
388 | | - if ( ((string)$field_xml->attributes()->list) == "list") { |
389 | | - $list_values = true; |
390 | | - } |
391 | | - if ( ((string)$field_xml->attributes()->delimiter) != null || ((string)$field_xml->attributes()->delimiter) != '' ) { |
392 | | - $delimiter = (string)$field_xml->attributes()->delimiter; |
393 | | - } |
394 | | - foreach ($field_xml->children() as $tag => $child ) { |
395 | | - if ( $tag == 'Label' ) { |
396 | | - $fieldLabel = (string)$child; |
397 | | - } |
398 | | - } |
399 | | - $text_4 .= '<p>Field name: <input size="15" name="f_name_'.$field_count.'" value="'.$fieldName.'" >'; |
400 | | - $text_4 .= 'Display label: <input size="15" name="f_label_'.$field_count.'" value="'.$fieldLabel.'" > |
| 428 | + } |
| 429 | + $text_4 .= '<div id="fieldsList_'.$template_num.'">'; |
| 430 | + $list_values = false; |
| 431 | + foreach ( $template_xml->children() as $field_xml ) { |
| 432 | + if ( $field_xml->getName() == "Field" ) { |
| 433 | + $fieldName = (string)$field_xml->attributes()->name; |
| 434 | + $text_4 .= '<div class="fieldBox" >'; |
| 435 | + $text_4 .= '<fieldset style="background: #bbb;"><legend>Field</legend> '; |
| 436 | + if ( ((string)$field_xml->attributes()->list) == "list") { |
| 437 | + $list_values = true; |
| 438 | + } |
| 439 | + if ( ((string)$field_xml->attributes()->delimiter) != null || ((string)$field_xml->attributes()->delimiter) != '' ) { |
| 440 | + $delimiter = (string)$field_xml->attributes()->delimiter; |
| 441 | + } |
| 442 | + foreach ($field_xml->children() as $tag => $child ) { |
| 443 | + if ( $tag == 'Label' ) { |
| 444 | + $fieldLabel = (string)$child; |
| 445 | + } |
| 446 | + } |
| 447 | + $text_4 .= '<p>Field name: <input size="15" name="f_name_'.$field_count.'" value="'.$fieldName.'" >'; |
| 448 | + $text_4 .= 'Display label: <input size="15" name="f_label_'.$field_count.'" value="'.$fieldLabel.'" > |
401 | 449 | </p> '; |
402 | | - if ($list_values ) { |
403 | | - $text_4 .= '<p><input type="checkbox" name="f_is_list_'.$field_count.'" checked class="isListCheckbox" /> This field can hold a list of values</p> '; |
404 | | - $text_4 .= '<div class="delimiterInput" style="display:"><p>Delimiter for values (default is ","): <input type="text" name="f_delimiter_'.$field_count.'" value="'.$delimiter.'" /> </p></div>'; |
405 | | - } else { |
406 | | - $text_4 .= '<p><input type="checkbox" name="f_is_list_'.$field_count.'" class="isListCheckbox" /> This field can hold a list of values</p> '; |
407 | | - $text_4 .= '<div class="delimiterInput" style="display: none" ><p>Delimiter for values (default is ","): <input type="text" name="f_delimiter_'.$field_count.'" /> </p></div>'; |
408 | | - } |
409 | | - //Inserting HTML text from Extensions |
| 450 | + if ($list_values ) { |
| 451 | + $text_4 .= '<p><input type="checkbox" name="f_is_list_'.$field_count.'" checked class="isListCheckbox" /> This field can hold a list of values</p> '; |
| 452 | + $text_4 .= '<div class="delimiterInput" style="display:"><p>Delimiter for values (default is ","): <input type="text" name="f_delimiter_'.$field_count.'" value="'.$delimiter.'" /> </p></div>'; |
| 453 | + } else { |
| 454 | + $text_4 .= '<p><input type="checkbox" name="f_is_list_'.$field_count.'" class="isListCheckbox" /> This field can hold a list of values</p> '; |
| 455 | + $text_4 .= '<div class="delimiterInput" style="display: none" ><p>Delimiter for values (default is ","): <input type="text" name="f_delimiter_'.$field_count.'" /> </p></div>'; |
| 456 | + } |
| 457 | + //Inserting HTML text from Extensions |
410 | 458 | |
411 | | - if ( $filled_html_text_extensions['smw'] != null ) { |
412 | | - $text_ex_array = $filled_html_text_extensions['smw']; |
413 | | - if ( $text_ex_array[$field_count] != null ) { |
414 | | - $text_ex = preg_replace('/starter/', $field_count, $text_ex_array[$field_count]); |
415 | | - $text_4 .= $text_ex; |
416 | | - } |
417 | | - } |
418 | | - if ( $filled_html_text_extensions['sf'] != null ) { |
419 | | - $text_ex_array = $filled_html_text_extensions['sf']; |
420 | | - if ( $text_ex_array[$field_count] != null ) { |
421 | | - $text_ex = preg_replace('/starter/', $field_count, $text_ex_array[$field_count]); |
422 | | - $text_4 .= $text_ex; |
423 | | - } |
424 | | - } |
425 | | - if ( $filled_html_text_extensions['sd'] != null ) { |
426 | | - $text_ex_array = $filled_html_text_extensions['sd']; |
427 | | - if ( $text_ex_array[$field_count] != null ) { |
428 | | - $text_ex = preg_replace('/starter/', $field_count, $text_ex_array[$field_count]); |
429 | | - $text_4 .= $text_ex; |
430 | | - } |
431 | | - } |
| 459 | + if ( $filledHTMLFromExtensions['smw'] != null ) { |
| 460 | + $text_ex_array = $filledHTMLFromExtensions['smw']; |
| 461 | + if ( $text_ex_array[$field_count] != null ) { |
| 462 | + $text_ex = preg_replace('/starter/', $field_count, $text_ex_array[$field_count]); |
| 463 | + $text_4 .= $text_ex; |
| 464 | + } |
| 465 | + } |
| 466 | + if ( $filledHTMLFromExtensions['sf'] != null ) { |
| 467 | + $text_ex_array = $filledHTMLFromExtensions['sf']; |
| 468 | + if ( $text_ex_array[$field_count] != null ) { |
| 469 | + $text_ex = preg_replace('/starter/', $field_count, $text_ex_array[$field_count]); |
| 470 | + $text_4 .= $text_ex; |
| 471 | + } |
| 472 | + } |
| 473 | + if ( $filledHTMLFromExtensions['sd'] != null ) { |
| 474 | + $text_ex_array = $filledHTMLFromExtensions['sd']; |
| 475 | + if ( $text_ex_array[$field_count] != null ) { |
| 476 | + $text_ex = preg_replace('/starter/', $field_count, $text_ex_array[$field_count]); |
| 477 | + $text_4 .= $text_ex; |
| 478 | + } |
| 479 | + } |
432 | 480 | |
433 | | - $text_4 .= '<p>'.$add_xml_label.' |
| 481 | + $text_4 .= '<p>'.$add_xml_label.' |
434 | 482 | <textarea rows=4 style="width: 100%" name="f_add_xml_'.$field_count.'"></textarea> |
435 | 483 | </p> |
436 | 484 | <input type="button" value="Remove field" class="deleteField" /></fieldset> |
437 | 485 | </div> |
438 | 486 | </div> |
439 | 487 | '; |
440 | | - $field_count++; |
441 | | - $text_4 .= '<script type="text/javascript"> |
| 488 | + $field_count++; |
| 489 | + $text_4 .= '<script type="text/javascript"> |
442 | 490 | updateFieldNum('.$field_count.'); |
443 | 491 | </script>'; |
444 | | - } |
445 | | - } |
446 | | - $text_4 .= '</div>'; |
447 | | - $add_field_button = Xml::element( 'input', |
448 | | - array( |
449 | | - 'type' => 'button', |
450 | | - 'value' => 'Add field', |
451 | | - 'onclick' => "createTemplateAddField($template_num)" |
452 | | - ) |
453 | | - ); |
454 | | - $text_4 .= Xml::tags( 'p', null, $add_field_button ) . "\n"; |
455 | | - $text_4 .= '<hr /> |
456 | | - <p>'.$add_xml_label.' |
457 | | - <textarea rows=4 style="width: 100%" name="t_add_xml_'.$template_num.'">'.$template_add_xml.'</textarea> |
458 | | - </p> |
459 | | - <p><input type="button" value="Remove template" class="deleteTemplate" /></p> |
460 | | - </fieldset> </div>'; |
461 | | - } |
462 | 492 | } |
463 | 493 | } |
464 | | - $add_template_button = Xml::element( 'input', |
| 494 | + $text_4 .= '</div>'; |
| 495 | + $add_field_button = Xml::element( 'input', |
465 | 496 | array( |
466 | 497 | 'type' => 'button', |
467 | | - 'value' => 'Add template', |
468 | | - 'onclick' => "createAddTemplate()" |
| 498 | + 'value' => 'Add field', |
| 499 | + 'onclick' => "createTemplateAddField($template_num)" |
469 | 500 | ) |
470 | 501 | ); |
471 | | - $text_4 .= Xml::tags( 'p', null, $add_template_button ) . "\n"; |
472 | | - $text_4 .= ' <hr /> |
473 | | - <div class="editButtons"> |
474 | | - <input type="submit" id="wpSave" name="wpSave" value="Save" /> |
475 | | - </div>'; |
476 | | - $text_4 .= ' </form>'; |
477 | | - $text_4 .= $starter_text; |
478 | | - $wgOut->addHTML($text_4); |
479 | | - } else { |
480 | | - $text_2 .= $text; |
481 | | - $wgOut->addHTML($text_2); |
| 502 | + $text_4 .= Xml::tags( 'p', null, $add_field_button ) . "\n"; |
| 503 | + $text_4 .= '<hr /> |
| 504 | + <p>'.$add_xml_label.' |
| 505 | + <textarea rows=4 style="width: 100%" name="t_add_xml_'.$template_num.'">'.$template_add_xml.'</textarea> |
| 506 | + </p> |
| 507 | + <p><input type="button" value="Remove template" class="deleteTemplate" /></p> |
| 508 | + </fieldset> </div>'; |
482 | 509 | } |
483 | 510 | } |
484 | | - } else { |
485 | | - $cat_titles = array(); |
486 | | - $count_title = 0; |
487 | | - $text = ""; |
488 | | - $dbr = wfGetDB( DB_SLAVE ); |
489 | | - //get the result set, query : slect page_props |
490 | | - $res = $dbr->select( 'page_props', |
| 511 | + } |
| 512 | + $add_template_button = Xml::element( 'input', |
491 | 513 | array( |
492 | | - 'pp_page', |
493 | | - 'pp_propname', |
494 | | - 'pp_value' |
495 | | - ), |
496 | | - array( |
497 | | - 'pp_propname' => 'PageSchema' |
| 514 | + 'type' => 'button', |
| 515 | + 'value' => 'Add template', |
| 516 | + 'onclick' => "createAddTemplate()" |
498 | 517 | ) |
499 | | - ); |
500 | | - while ( $row = $dbr->fetchRow( $res ) ) { |
501 | | - if ( $row[2] != null ) { |
502 | | - $page_id_cat = $row[0]; |
503 | | - if ( Title::newFromId($page_id_cat)->getNamespace() == NS_CATEGORY ) { |
504 | | - $cat_text = Title::newFromId($page_id_cat)->getText(); |
505 | | - $generatePagesPage = SpecialPage::getTitleFor( 'EditSchema' ); |
506 | | - $url = $generatePagesPage ->getFullURL() . '/' . $cat_text; |
507 | | - $text .= '<a href='.$url.'>' . $cat_text . '</a> <br /> '; |
508 | | - } |
509 | | - } |
510 | | - } |
511 | | - $dbr->freeResult( $res ); |
512 | | - $wgOut->addHTML( $text ); |
513 | | - } |
| 518 | + ); |
| 519 | + $text_4 .= Xml::tags( 'p', null, $add_template_button ) . "\n"; |
| 520 | + $text_4 .= ' <hr /> |
| 521 | + <div class="editButtons"> |
| 522 | + <input type="submit" id="wpSave" name="wpSave" value="Save" /> |
| 523 | + </div>'; |
| 524 | + $text_4 .= ' </form>'; |
| 525 | + $text_4 .= self::starterFieldHTML( $htmlFromExtensions ); |
| 526 | + $wgOut->addHTML($text_4); |
| 527 | + return true; |
514 | 528 | } |
515 | | - return true; |
516 | | - } |
517 | 529 | } |