Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_SpecialQueryCreator.php |
— | — | @@ -66,7 +66,7 @@ |
67 | 67 | * Overridden from parent to ignore GUI parameters 'format' 'limit' and 'offset' |
68 | 68 | */ |
69 | 69 | protected function showFormatOptions( $format, array $paramValues, array $ignoredAttribs = array() ) { |
70 | | - return parent::showFormatOptions( $format, $paramValues, array( 'format', 'limit', 'offset' ) ); |
| 70 | + return parent::showFormatOptions( $format, $paramValues, array( 'format', 'limit', 'offset', 'mainlabel' ) ); |
71 | 71 | } |
72 | 72 | /** |
73 | 73 | * Creates the input form |
— | — | @@ -143,8 +143,20 @@ |
144 | 144 | $property_values = $wgRequest->getArray( 'property' ); |
145 | 145 | $category_values = $wgRequest->getArray( 'category' ); |
146 | 146 | $category_label_values = $wgRequest->getArray( 'cat_label' ); |
| 147 | + $main_column_labels = $wgRequest->getArray( 'maincol_label' ); |
147 | 148 | $po = array(); |
148 | 149 | $category_namespace = $wgContLang->getNsText( NS_CATEGORY ); |
| 150 | + if ( is_array( $main_column_labels ) ) { |
| 151 | + $po['mainlabel'] = '-'; // disables mainlabel parameter so that the UI can control it from here |
| 152 | + foreach ( $main_column_labels as $key => $label ) { |
| 153 | + if ( $label == '' ) { |
| 154 | + $po[$key] = "?"; |
| 155 | + } else { |
| 156 | + $po[$key] = "? = $label"; |
| 157 | + } |
| 158 | + |
| 159 | + } |
| 160 | + } |
149 | 161 | if ( is_array( $category_values ) ) { |
150 | 162 | foreach ( $category_values as $key => $value ) { |
151 | 163 | if ( trim( $value ) == '' ) { |
— | — | @@ -227,8 +239,9 @@ |
228 | 240 | $display_values = $wgRequest->getArray( 'display' ); |
229 | 241 | $category_values = $wgRequest->getArray( 'category' ); |
230 | 242 | $category_label_values = $wgRequest->getArray( 'cat_label' ); |
| 243 | + $main_column_labels = $wgRequest->getArray( 'maincol_label' ); |
231 | 244 | |
232 | | - if ( is_array( $property_values ) or is_array( $category_values ) ) { |
| 245 | + if ( is_array( $property_values ) or is_array( $category_values ) or is_array( $main_column_labels ) ) { |
233 | 246 | /* |
234 | 247 | * Printouts were set via this Ui |
235 | 248 | */ |
— | — | @@ -293,10 +306,18 @@ |
294 | 307 | $additional_POs[$value] = $category_values[$value]; // array_merge won't work because numeric keys need to be preserved |
295 | 308 | } |
296 | 309 | } |
| 310 | + if ( is_array( $main_column_labels ) ) { |
| 311 | + $keys = array_keys( $main_column_labels ); |
| 312 | + foreach ( $keys as $value ) { |
| 313 | + $additional_POs[$value] = $main_column_labels[$value]; // array_merge won't work because numeric keys need to be preserved |
| 314 | + } |
| 315 | + } |
297 | 316 | ksort( $additional_POs ); |
298 | 317 | foreach ( $additional_POs as $key => $value ) { |
299 | 318 | if ( is_array( $property_values ) and array_key_exists( $key, $property_values ) ) { |
300 | | - // make a element for additional properties |
| 319 | + /* |
| 320 | + * Make an element for additional properties |
| 321 | + */ |
301 | 322 | $result .= Html::openElement( 'div', array( 'id' => "sort_div_$i", 'class' => 'smwsort' ) ); |
302 | 323 | $result .= '<span class="smw-remove"><a href="javascript:removePOInstance(\'sort_div_' . $i . '\')"><img src="' . $smwgScriptPath . '/skins/images/close-button.png" alt="' . wfMsg( 'smw_qui_delete' ) . '"></a></span>'; |
303 | 324 | $result .= wfMsg( 'smw_qui_property' ); |
— | — | @@ -322,6 +343,9 @@ |
323 | 344 | $i++; |
324 | 345 | } |
325 | 346 | if ( is_array( $category_values ) and array_key_exists( $key, $category_values ) ) { |
| 347 | + /* |
| 348 | + * Make an element for additional categories |
| 349 | + */ |
326 | 350 | $result .= Html::openElement( 'div', array( 'id' => "sort_div_$i", 'class' => 'smwsort' ) ); |
327 | 351 | $result .= '<span class="smw-remove"><a href="javascript:removePOInstance(\'sort_div_' . $i . '\')"><img src="' . $smwgScriptPath . '/skins/images/close-button.png" alt="' . wfMsg( 'smw_qui_delete' ) . '"></a></span>' . |
328 | 352 | 'Category (optional)' . // todo: i18n |
— | — | @@ -332,6 +356,17 @@ |
333 | 357 | Xml::closeElement( 'div' ); |
334 | 358 | $i++; |
335 | 359 | } |
| 360 | + if ( is_array( $main_column_labels ) and array_key_exists( $key, $main_column_labels ) ) { |
| 361 | + /* |
| 362 | + * Make an element for main column |
| 363 | + */ |
| 364 | + $result .= Html::openElement( 'div', array( 'id' => "sort_div_$i", 'class' => 'smwsort' ) ) . |
| 365 | + '<span class="smw-remove"><a href="javascript:removePOInstance(\'sort_div_' . $i . '\')"><img src="' . $smwgScriptPath . '/skins/images/close-button.png" alt="' . wfMsg( 'smw_qui_delete' ) . '"></a></span>' . |
| 366 | + wfMsg( 'smw_qui_rescol' ) . |
| 367 | + Xml::input( "maincol_label[$i]", '20', $main_column_labels[$key], array ( 'id' => "maincol_label$i" ) ) . " " . |
| 368 | + Xml::closeElement( 'div' ); |
| 369 | + $i++; |
| 370 | + } |
336 | 371 | } |
337 | 372 | $num_sort_values = $i; |
338 | 373 | // END: create form elements already submitted earlier via form |
— | — | @@ -359,6 +394,13 @@ |
360 | 395 | Xml::closeElement( 'div' ); |
361 | 396 | $hidden_category = json_encode( $hidden_category ); |
362 | 397 | |
| 398 | + $hidden_main_column = Html::openElement( 'div', array( 'id' => 'maincol_starter', 'class' => 'smwsort', 'style' => 'display:none' ) ) . |
| 399 | + '<span class="smw-remove"><a><img src="' . $smwgScriptPath . '/skins/images/close-button.png" alt="' . wfMsg( 'smw_qui_delete' ) . '"></a></span>' . |
| 400 | + wfMsg( 'smw_qui_rescol' ) . |
| 401 | + Xml::input( "maincol_label_num", '20' ) . " " . |
| 402 | + Xml::closeElement( 'div' ); |
| 403 | + $hidden_main_column = json_encode( $hidden_main_column ); |
| 404 | + |
363 | 405 | $property_dialog_box = Xml::openElement( 'div', array( 'id' => 'prop-dialog', 'title' => 'Property Options', 'class' => 'smwpropdialog' ) ) . // todo i18n |
364 | 406 | Xml::inputLabel( 'Property:', '', 'd-property', 'd-property' ) . '<br/>' . // todo i18n |
365 | 407 | Xml::inputLabel( 'Label:', '', 'd-property-label', 'd-property-label' ) . '<br/>' . // todo i18n |
— | — | @@ -381,6 +423,7 @@ |
382 | 424 | $result .= '<div id="sorting_main"></div>' . "\n"; |
383 | 425 | $result .= '[<a href="javascript:smw_addPropertyInstance(\'property_starter\', \'sorting_main\')">' . wfMsg( 'smw_qui_addnprop' ) . '</a>]' . |
384 | 426 | '[<a href="javascript:smw_addCategoryInstance(\'category_starter\', \'sorting_main\')">' . 'Add additional category' . '</a>]' . // todo i18n |
| 427 | + '[<a href="javascript:smw_addMainColInstance(\'maincol_starter\', \'sorting_main\')">' . 'Add main column' . '</a>]' . // todo i18n |
385 | 428 | "\n"; |
386 | 429 | |
387 | 430 | // Javascript code for handling adding and removing the "sort" inputs |
— | — | @@ -563,6 +606,36 @@ |
564 | 607 | smw_category_autocomplete(); |
565 | 608 | } |
566 | 609 | |
| 610 | +function smw_addMainColInstance(starter_div_id, main_div_id) { |
| 611 | + var starter_div = document.getElementById(starter_div_id); |
| 612 | + var main_div = document.getElementById(main_div_id); |
| 613 | + |
| 614 | + //Create the new instance |
| 615 | + var new_div = starter_div.cloneNode(true); |
| 616 | + var div_id = 'sort_div_' + num_elements; |
| 617 | + new_div.id = div_id; |
| 618 | + new_div.style.display = 'block'; |
| 619 | + jQuery(new_div.getElementsByTagName('label')).attr('for', 'display'+num_elements); |
| 620 | + var children = new_div.getElementsByTagName('*'); |
| 621 | + var x; |
| 622 | + for (x = 0; x < children.length; x++) { |
| 623 | + if (children[x].for) children[x].for="display"+num_elements; |
| 624 | + if (children[x].name){ |
| 625 | + children[x].id = children[x].name.replace(/_num/, ''+num_elements); |
| 626 | + children[x].name = children[x].name.replace(/_num/, '[' + num_elements + ']'); |
| 627 | + } |
| 628 | + } |
| 629 | + |
| 630 | + //Add the new instance |
| 631 | + main_div.appendChild(new_div); |
| 632 | + |
| 633 | + // initialize delete button |
| 634 | + st='sort_div_'+num_elements; |
| 635 | + jQuery('#'+new_div.id).find(".smw-remove a")[0].href="javascript:removePOInstance('"+st+"')"; |
| 636 | + num_elements++; |
| 637 | + smw_category_autocomplete(); |
| 638 | +} |
| 639 | + |
567 | 640 | function removePOInstance(div_id) { |
568 | 641 | var olddiv = document.getElementById(div_id); |
569 | 642 | var parent = olddiv.parentNode; |
— | — | @@ -572,6 +645,7 @@ |
573 | 646 | jQuery(function(){ |
574 | 647 | jQuery('$hidden_property').appendTo(document.body); |
575 | 648 | jQuery('$hidden_category').appendTo(document.body); |
| 649 | + jQuery('$hidden_main_column').appendTo(document.body); |
576 | 650 | jQuery('$property_dialog_box').appendTo(document.body); |
577 | 651 | jQuery('$category_dialog_box').appendTo(document.body); |
578 | 652 | jQuery('#cat-dialog').dialog({ |
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_Messages.php |
— | — | @@ -254,6 +254,7 @@ |
255 | 255 | 'smw_qui_descorder' => 'Descending', |
256 | 256 | 'smw_qui_addnprop' => 'Add additional properties', |
257 | 257 | 'smw_qui_delete' => 'Remove', |
| 258 | + 'smw_qui_rescol' => 'Result column label', |
258 | 259 | |
259 | 260 | // Messages for the search by property special |
260 | 261 | 'searchbyproperty' => 'Search by property', |