Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_SpecialQueryCreator.php |
— | — | @@ -37,13 +37,17 @@ |
38 | 38 | $html_output = $this->makeResults( $p ); |
39 | 39 | if ( $this->uiCore->getQueryString() != "" ) { |
40 | 40 | if ( $this->usesNavigationBar() ) { |
41 | | - $html_output .= $this->getNavigationBar ( $this->uiCore->getLimit(), $this->uiCore->getOffset(), $this->uiCore->hasFurtherResults() ); // ? can we preload offset and limit? |
| 41 | + $html_output .= Html::rawElement( 'div', array( 'class' => 'smw-qc-navbar' ), |
| 42 | + $this->getNavigationBar ( $this->uiCore->getLimit(), $this->uiCore->getOffset(), $this->uiCore->hasFurtherResults() ) |
| 43 | + ); // ? can we preload offset and limit? |
42 | 44 | } |
43 | 45 | |
44 | | - $html_output .= "<br/>" . $this->uiCore->getHTMLResult() . "<br>"; |
| 46 | + $html_output .= Html::rawElement( 'div', array( 'class' => 'smw-qc-result' ), $this->uiCore->getHTMLResult() ); |
45 | 47 | |
46 | 48 | if ( $this->usesNavigationBar() ) { |
47 | | - $html_output .= $this->getNavigationBar ( $this->uiCore->getLimit(), $this->uiCore->getOffset(), $this->uiCore->hasFurtherResults() ); // ? can we preload offset and limit? |
| 49 | + $html_output .= Html::rawElement( 'div', array( 'class' => 'smw-qc-navbar' ), |
| 50 | + $this->getNavigationBar ( $this->uiCore->getLimit(), $this->uiCore->getOffset(), $this->uiCore->hasFurtherResults() ) |
| 51 | + ); // ? can we preload offset and limit? |
48 | 52 | } |
49 | 53 | } |
50 | 54 | $wgOut->addHTML( $html_output ); |
— | — | @@ -112,7 +116,7 @@ |
113 | 117 | $result .= '</div>'; // end of hidden additional options |
114 | 118 | $result .= '<br /><input type="submit" value="' . wfMsg( 'smw_ask_submit' ) . '"/>' . |
115 | 119 | '<input type="hidden" name="eq" value="no"/>' . |
116 | | - "\n</form>"; |
| 120 | + "\n</form><br/>"; |
117 | 121 | |
118 | 122 | return $result; |
119 | 123 | |
— | — | @@ -126,11 +130,12 @@ |
127 | 131 | * Overrides method from SMWQueryUI (modal window added) |
128 | 132 | * |
129 | 133 | * @global boolean $smwgQSortingSupport |
| 134 | + * @global Language $wgContLang |
130 | 135 | * @param WebRequest $wgRequest |
131 | 136 | * @return string |
132 | 137 | */ |
133 | 138 | protected function processPoSortFormBox( WebRequest $wgRequest ) { |
134 | | - global $smwgQSortingSupport; |
| 139 | + global $smwgQSortingSupport, $wgContLang; |
135 | 140 | if ( !$smwgQSortingSupport ) return array(); |
136 | 141 | |
137 | 142 | $params = array(); |
— | — | @@ -139,12 +144,13 @@ |
140 | 145 | $category_values = $wgRequest->getArray( 'category' ); |
141 | 146 | $category_label_values = $wgRequest->getArray( 'cat_label' ); |
142 | 147 | $po = array(); |
| 148 | + $category_namespace = $wgContLang->getNsText( NS_CATEGORY ); |
143 | 149 | if ( is_array( $category_values ) ) { |
144 | 150 | foreach ( $category_values as $key => $value ) { |
145 | 151 | if ( trim( $value ) == '' ) { |
146 | | - $po[$key] = '?Category'; // Todo: i18n |
| 152 | + $po[$key] = "?$category_namespace" ; |
147 | 153 | } else { |
148 | | - $po[$key] = '?Category:' . $value; // Todo: i18n |
| 154 | + $po[$key] = "?$category_namespace:$value"; |
149 | 155 | } |
150 | 156 | } |
151 | 157 | } |
— | — | @@ -222,12 +228,17 @@ |
223 | 229 | $category_values = $wgRequest->getArray( 'category' ); |
224 | 230 | $category_label_values = $wgRequest->getArray( 'cat_label' ); |
225 | 231 | |
226 | | - if ( is_array( $property_values ) ) { |
227 | | - // removing empty values |
228 | | - foreach ( $property_values as $key => $property_value ) { |
229 | | - $property_values[$key] = trim( $property_value ); |
230 | | - if ( $property_value == '' ) { |
231 | | - unset( $property_values[$key] ); |
| 232 | + if ( is_array( $property_values ) or is_array( $category_values ) ) { |
| 233 | + /* |
| 234 | + * Printouts were set via this Ui |
| 235 | + */ |
| 236 | + if ( is_array( $property_values ) ) { |
| 237 | + // remove empty property values |
| 238 | + foreach ( $property_values as $key => $property_value ) { |
| 239 | + $property_values[$key] = trim( $property_value ); |
| 240 | + if ( $property_value == '' ) { |
| 241 | + unset( $property_values[$key] ); |
| 242 | + } |
232 | 243 | } |
233 | 244 | } |
234 | 245 | } else { |
— | — | @@ -258,19 +269,18 @@ |
259 | 270 | $order_values = array(); // do not even show one sort input here |
260 | 271 | $property_values = array(); |
261 | 272 | } |
262 | | - |
263 | | - foreach ( $po as $po_key => $po_value ) { |
| 273 | + foreach ( $po as $po_value ) { |
264 | 274 | if ( !in_array( $po_value, $property_values ) ) { |
265 | 275 | $property_values[] = $po_value; |
266 | 276 | } |
267 | | - } |
268 | | - $display_values = array(); |
269 | | - reset( $property_values ); |
270 | | - foreach ( $property_values as $property_key => $property_value ) { |
271 | | - if ( in_array( $property_value, $po ) ) { |
272 | | - $display_values[$property_key] = "yes"; |
273 | | - } |
274 | | - } |
| 277 | + } |
| 278 | + $display_values = array(); |
| 279 | + reset( $property_values ); |
| 280 | + foreach ( $property_values as $property_key => $property_value ) { |
| 281 | + if ( in_array( $property_value, $po ) ) { |
| 282 | + $display_values[$property_key] = "yes"; |
| 283 | + } |
| 284 | + } |
275 | 285 | } |
276 | 286 | $i = 0; |
277 | 287 | $additional_POs = array(); |
— | — | @@ -278,11 +288,14 @@ |
279 | 289 | $additional_POs = array_merge( $additional_POs, $property_values ); |
280 | 290 | } |
281 | 291 | if ( is_array( $category_values ) ) {// same as testing $category_label_values |
282 | | - $additional_POs = array_merge( $additional_POs, $category_values ); |
| 292 | + $keys = array_keys( $category_values ); |
| 293 | + foreach ( $keys as $value ) { |
| 294 | + $additional_POs[$value] = $category_values[$value]; // array_merge won't work because numeric keys need to be preserved |
| 295 | + } |
283 | 296 | } |
284 | 297 | ksort( $additional_POs ); |
285 | 298 | foreach ( $additional_POs as $key => $value ) { |
286 | | - if ( array_key_exists( $key, $property_values ) ) { |
| 299 | + if ( is_array( $property_values ) and array_key_exists( $key, $property_values ) ) { |
287 | 300 | // make a element for additional properties |
288 | 301 | $result .= Html::openElement( 'div', array( 'id' => "sort_div_$i", 'class' => 'smw-sort' ) ); |
289 | 302 | $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>'; |
— | — | @@ -312,9 +325,9 @@ |
313 | 326 | $result .= Html::openElement( 'div', array( 'id' => "sort_div_$i", 'class' => 'smw-sort' ) ); |
314 | 327 | $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>' . |
315 | 328 | 'Category (optional)' . // todo: i18n |
316 | | - Xml::input( "category[$i]", '20', $category_values[$key] ) . " " . |
| 329 | + Xml::input( "category[$i]", '20', $category_values[$key], array( 'id' => "category$i" ) ) . " " . |
317 | 330 | 'Label' . // todo: i18n |
318 | | - Xml::input( "cat_label[$i]", '20', array_key_exists( $key, $category_label_values ) ? $category_label_values[$key]:false ) . " " . |
| 331 | + Xml::input( "cat_label[$i]", '20', array_key_exists( $key, $category_label_values ) ? $category_label_values[$key]:false, array( 'id' => "cat_label$i" ) ) . " " . |
319 | 332 | ' <a id="more' . $i . '" "class="smwq-more" href="javascript:smw_makeCatDialog(\'' . $i . '\')"> options </a> ' . // TODO: i18n |
320 | 333 | Xml::closeElement( 'div' ); |
321 | 334 | $i++; |
— | — | @@ -349,7 +362,7 @@ |
350 | 363 | $property_dialog_box = Xml::openElement( 'div', array( 'id' => 'prop-dialog', 'title' => 'Property Options', 'class' => 'smw-prop-dialog' ) ) . // todo i18n |
351 | 364 | Xml::inputLabel( 'Property:', '', 'd-property', 'd-property' ) . '<br/>' . // todo i18n |
352 | 365 | Xml::inputLabel( 'Label:', '', 'd-property-label', 'd-property-label' ) . '<br/>' . // todo i18n |
353 | | - 'Format: ' . Html::openElement( 'select', array( 'name' => 'd-format', 'id' => 'd-format' ) ) . // todo i18n |
| 366 | + '<label for="d-format">Format:</label> ' . Html::openElement( 'select', array( 'name' => 'd-format', 'id' => 'd-format' ) ) . // todo i18n |
354 | 367 | Xml::option( 'None (default)', ' ' ) . // todo i18n |
355 | 368 | Xml::option( 'Simple', '#-' ) . // todo i18n |
356 | 369 | Xml::closeElement( 'select' ) . |
— | — | @@ -397,6 +410,7 @@ |
398 | 411 | } |
399 | 412 | }); |
400 | 413 | } |
| 414 | + |
401 | 415 | function smw_category_autocomplete(){ |
402 | 416 | jQuery('[name*="category"]').autocomplete({ |
403 | 417 | minLength: 2, |
— | — | @@ -417,47 +431,63 @@ |
418 | 432 | $javascript_text .= <<<EOT |
419 | 433 | function smw_property_autocomplete(){ |
420 | 434 | } |
| 435 | + |
421 | 436 | function smw_category_autocomplete(){ |
422 | 437 | } |
| 438 | + |
423 | 439 | EOT; |
424 | 440 | } |
425 | 441 | |
426 | 442 | $javascript_text .= <<<EOT |
427 | 443 | function smw_prop_code_update(){ |
428 | | - code = '?'+\$j('#d-property')[0].value; |
429 | | - if(code!=''){ |
430 | | - if(\$j('#d-property-format-custom')[0].value !=''){ |
431 | | - code = code + \$j('#d-property-format-custom')[0].value; |
432 | | - } |
433 | | - if(\$j('#d-property-label')[0].value !=''){ |
434 | | - code = code + ' = '+ \$j('#d-property-label')[0].value; |
435 | | - } |
436 | | - \$j('#d-property-code')[0].value= code; |
| 444 | + code = '?'+jQuery('#d-property')[0].value; |
| 445 | + if(code!=''){ |
| 446 | + if(jQuery('#d-property-format-custom')[0].value !=''){ |
| 447 | + code = code + jQuery('#d-property-format-custom')[0].value; |
437 | 448 | } |
| 449 | + if(jQuery('#d-property-label')[0].value !=''){ |
| 450 | + code = code + ' = '+ jQuery('#d-property-label')[0].value; |
| 451 | + } |
| 452 | + jQuery('#d-property-code')[0].value= code; |
| 453 | + } |
438 | 454 | } |
| 455 | + |
| 456 | +function smw_cat_code_update(){ |
| 457 | + |
| 458 | +} |
| 459 | + |
| 460 | +function smw_makeCatDialog(cat_id){ |
| 461 | + jQuery('#prop-cat input').attr('value',''); |
| 462 | + cat=jQuery('#category'+cat_id)[0].value; |
| 463 | + jQuery('#d-category').attr('value',cat); |
| 464 | + label=jQuery('#cat_label'+cat_id)[0].value; |
| 465 | + jQuery('#d-category-label').attr('value',label); |
| 466 | + //jQuery('#cat-dialog').dialog('open'); |
| 467 | +} |
| 468 | + |
439 | 469 | function smw_makePropDialog(prop_id){ |
440 | | - jQuery('#prop-dialog input').attr('value',''); |
441 | | - prop=val=\$j('#property'+prop_id)[0].value; |
442 | | - if(val[0]='?') val=prop=prop.substr(1); |
443 | | - if((i=val.indexOf('='))!=-1) prop=prop.substring(0, i); |
444 | | - if((i=val.indexOf('#'))!=-1) prop=prop.substring(0, i); |
445 | | - if(val.split('=')[1]){ |
446 | | - label=val.split('=')[1].trim(); |
447 | | - }else{ |
448 | | - label=""; |
449 | | - } |
450 | | - format = val.split('=')[0]; |
451 | | - if(format.indexOf('#')!=-1){ |
452 | | - format=format.substr(format.indexOf('#')); |
453 | | - }else{ |
454 | | - format=""; |
455 | | - } |
| 470 | + jQuery('#prop-dialog input').attr('value',''); |
| 471 | + prop=val=jQuery('#property'+prop_id)[0].value; |
| 472 | + if(val[0]='?') val=prop=prop.substr(1); |
| 473 | + if((i=val.indexOf('='))!=-1) prop=prop.substring(0, i); |
| 474 | + if((i=val.indexOf('#'))!=-1) prop=prop.substring(0, i); |
| 475 | + if(val.split('=')[1]){ |
| 476 | + label=val.split('=')[1].trim(); |
| 477 | + }else{ |
| 478 | + label=""; |
| 479 | + } |
| 480 | + format = val.split('=')[0]; |
| 481 | + if(format.indexOf('#')!=-1){ |
| 482 | + format=format.substr(format.indexOf('#')); |
| 483 | + }else{ |
| 484 | + format=""; |
| 485 | + } |
456 | 486 | |
457 | | - \$j('#d-property').attr('value', prop.trim()); |
458 | | - \$j('#d-property-label').attr('value', label); |
459 | | - \$j('#d-property-format-custom').attr('value', format.trim()); |
460 | | - \$j('#prop-dialog').dialog.id=prop_id; |
461 | | - \$j('#prop-dialog').dialog('open'); |
| 487 | + jQuery('#d-property').attr('value', prop.trim()); |
| 488 | + jQuery('#d-property-label').attr('value', label); |
| 489 | + jQuery('#d-property-format-custom').attr('value', format.trim()); |
| 490 | + jQuery('#prop-dialog').dialog.id=prop_id; |
| 491 | + jQuery('#prop-dialog').dialog('open'); |
462 | 492 | } |
463 | 493 | // code for handling adding and removing the "sort" inputs |
464 | 494 | |
— | — | @@ -550,7 +580,20 @@ |
551 | 581 | resizable: true, |
552 | 582 | minHeight: 200, |
553 | 583 | minWidth: 400, |
| 584 | + buttons: { |
| 585 | + "Ok": function(){ //todo i18 |
| 586 | + smw_cat_code_update(); |
| 587 | + // todo: move modal window data to main window form controls; |
| 588 | + jQuery(this).dialog("close"); |
| 589 | + }, |
| 590 | + "Cancel": function(){ //todo:i18n |
| 591 | + jQuery('#cat-dialog input').attr('value',''); |
| 592 | + jQuery(this).dialog("close"); |
| 593 | + } |
| 594 | + } |
554 | 595 | }); |
| 596 | + //todo: run smw_cat_code_update() when input values in category modal windows changes |
| 597 | + |
555 | 598 | jQuery('#prop-dialog').dialog({ |
556 | 599 | autoOpen: false, |
557 | 600 | modal: true, |
— | — | @@ -560,7 +603,7 @@ |
561 | 604 | buttons: { |
562 | 605 | "Ok": function(){ //todo: i18n |
563 | 606 | smw_prop_code_update(); |
564 | | - \$j('#property'+\$j('#prop-dialog').dialog.id)[0].value=\$j('#d-property-code')[0].value; |
| 607 | + jQuery('#property'+jQuery('#prop-dialog').dialog.id)[0].value=jQuery('#d-property-code')[0].value; |
565 | 608 | jQuery(this).dialog("close"); |
566 | 609 | }, |
567 | 610 | "Cancel": function(){ //todo: i18n |
— | — | @@ -577,10 +620,9 @@ |
578 | 621 | smw_prop_code_update(); |
579 | 622 | }); |
580 | 623 | }); |
581 | | -function smw_makeCatDialog(cat_id){ |
582 | | - //\$j('#cat-dialog').dialog('open'); |
583 | | -} |
| 624 | + |
584 | 625 | jQuery(document).ready(smw_property_autocomplete); |
| 626 | +jQuery(document).ready(smw_category_autocomplete); |
585 | 627 | </script> |
586 | 628 | |
587 | 629 | EOT; |