Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_QueryUIHelper.php |
— | — | @@ -394,6 +394,9 @@ |
395 | 395 | $params = array(); |
396 | 396 | $orderValues = $wgRequest->getArray( 'order' ); |
397 | 397 | $propertyValues = $wgRequest->getArray( 'property' ); |
| 398 | + $propertyLabelValues = $wgRequest->getArray( 'prop_label' ); |
| 399 | + $propertyLimitValues = $wgRequest->getArray( 'prop_limit' ); |
| 400 | + $propertyFormatValues = $wgRequest->getArray( 'prop_format' ); |
398 | 401 | $categoryValues = $wgRequest->getArray( 'category' ); |
399 | 402 | $categoryLabelValues = $wgRequest->getArray( 'cat_label' ); |
400 | 403 | $categoryYesValues = $wgRequest->getArray( 'cat_yes' ); |
— | — | @@ -419,19 +422,15 @@ |
420 | 423 | $po[$key] = "?$categoryNamespace" ; |
421 | 424 | } else { |
422 | 425 | $po[$key] = "?$categoryNamespace:$value"; |
423 | | - if (is_array($categoryYesValues) && |
424 | | - is_array($categoryNoValues) && |
425 | | - array_key_exists($key, $categoryYesValues) && |
426 | | - array_key_exists($key, $categoryNoValues)){ |
| 426 | + if ( is_array( $categoryYesValues ) && |
| 427 | + is_array( $categoryNoValues ) && |
| 428 | + array_key_exists( $key, $categoryYesValues ) && |
| 429 | + array_key_exists( $key, $categoryNoValues ) ) { |
427 | 430 | |
428 | | - if($categoryYesValues[$key]!==''){ |
429 | | - $po[$key] .="#$categoryYesValues[$key]"; |
430 | | - if($categoryNoValues[$key]!==''){ |
431 | | - $po[$key] .=",$categoryNoValues[$key]"; |
432 | | - } |
| 431 | + if ( $categoryYesValues[$key] !== '' && $categoryNoValues[$key] !== '' ) { |
| 432 | + $po[$key] .= "#$categoryYesValues[$key],$categoryNoValues[$key]"; |
433 | 433 | } |
434 | 434 | } |
435 | | - |
436 | 435 | } |
437 | 436 | } |
438 | 437 | } |
— | — | @@ -451,11 +450,7 @@ |
452 | 451 | unset( $propertyValues[$key] ); |
453 | 452 | } |
454 | 453 | if ( is_array( $orderValues ) && array_key_exists( $key, $orderValues ) && $orderValues[$key] != 'NONE' ) { |
455 | | - $prop = substr( $propertyValues[$key], 1 ); // removing the leading '?' |
456 | | - if ( !strpos( $prop, '#' ) === false ) $prop = strstr( $prop, '#', true ); // removing format options |
457 | | - if ( !strpos( $prop, '=' ) === false ) $prop = strstr( $prop, '=', true ); // removing format options |
458 | | - |
459 | | - $params['sort'] .= ( $params['sort'] != '' ? ',':'' ) . $prop; |
| 454 | + $params['sort'] .= ( $params['sort'] != '' ? ',':'' ) . $propertyValues[$key]; |
460 | 455 | $params['order'] .= ( $params['order'] != '' ? ',':'' ) . $orderValues[$key]; |
461 | 456 | } |
462 | 457 | } |
— | — | @@ -469,9 +464,25 @@ |
470 | 465 | if ( is_array( $displayValues ) ) { |
471 | 466 | foreach ( $displayValues as $key => $value ) { |
472 | 467 | if ( $value == '1' && array_key_exists( $key, $propertyValues ) ) { |
473 | | - $propertyValues[$key] = trim( $propertyValues[$key] ); |
474 | | - $propertyValues[$key] = ( $propertyValues[$key][0] == '?' ) ? $propertyValues[$key]:'?' . $propertyValues[$key]; |
475 | | - $po[$key] = $propertyValues[$key]; |
| 468 | + $propertyValues[$key] = '?' . trim( $propertyValues[$key] ); // adding leading ? |
| 469 | + if ( is_array( $propertyFormatValues ) && // adding PO format |
| 470 | + array_key_exists( $key, $propertyFormatValues ) && |
| 471 | + $propertyFormatValues[$key] != '' ) { |
| 472 | + $propertyValues[$key] .= '#' . $propertyFormatValues[$key]; |
| 473 | + } |
| 474 | + if ( is_array( $propertyLabelValues ) && |
| 475 | + array_key_exists( $key, $propertyLabelValues ) && |
| 476 | + $propertyLabelValues[$key] != '' ) { // adding label |
| 477 | + $propertyValues[$key] .= ' = ' . $propertyLabelValues[$key]; |
| 478 | + } |
| 479 | + if ( is_array( $propertyLimitValues ) && // adding limit |
| 480 | + array_key_exists( $key, $propertyLimitValues ) && |
| 481 | + $propertyLimitValues[$key] != '' ) { |
| 482 | + $po[] = $propertyValues[$key]; |
| 483 | + $po[] = '+limit=' . $propertyLimitValues[$key]; |
| 484 | + } else { |
| 485 | + $po[] = $propertyValues[$key]; |
| 486 | + } |
476 | 487 | } |
477 | 488 | } |
478 | 489 | } |
— | — | @@ -502,6 +513,9 @@ |
503 | 514 | // START: create form elements already submitted earlier via form |
504 | 515 | // attempting to load parameters from $wgRequest |
505 | 516 | $propertyValues = $wgRequest->getArray( 'property' ); |
| 517 | + $propertyLabelValues = $wgRequest->getArray( 'prop_label' ); |
| 518 | + $propertyFormatValues = $wgRequest->getArray( 'prop_format' ); |
| 519 | + $propertyLimitValues = $wgRequest->getArray( 'prop_limit' ); |
506 | 520 | $orderValues = $wgRequest->getArray( 'order' ); |
507 | 521 | $displayValues = $wgRequest->getArray( 'display' ); |
508 | 522 | $categoryValues = $wgRequest->getArray( 'category' ); |
— | — | @@ -528,41 +542,98 @@ |
529 | 543 | * Printouts and sorting were set via another widget/form/source, so |
530 | 544 | * create elements by fetching data from $uiCore. The exact ordering |
531 | 545 | * of Ui elements might not be preserved, if the above block were to |
532 | | - * be removed. This is a bit of a hack, converting all strings to |
533 | | - * lowercase to simplify searching procedure and using in_array. |
| 546 | + * be removed. |
534 | 547 | */ |
| 548 | + $propertyValues = array(); |
| 549 | + $propertyLabelValues = array(); |
| 550 | + $propertyFormatValues = array(); |
| 551 | + $propertyLimitValues = array(); |
| 552 | + $orderValues = array(); |
| 553 | + $displayValues = array(); |
| 554 | + $categoryValues = array(); |
| 555 | + $categoryLabelValues = array(); |
| 556 | + $categoryYesValues = array(); |
| 557 | + $categoryNoValues = array(); |
| 558 | + $mainColumnLabels = array(); |
535 | 559 | |
536 | | - $po = explode( '?', $this->getPOStrings() ); |
537 | | - reset( $po ); |
538 | | - foreach ( $po as $key => $value ) { |
539 | | - $po[$key] = strtolower( trim( $value ) ); |
540 | | - if ( $po[$key] == '' ) { |
541 | | - unset ( $po[$key] ); |
542 | | - } |
543 | | - } |
544 | | - |
545 | 560 | $params = $this->uiCore->getParameters(); |
546 | 561 | if ( array_key_exists( 'sort', $params ) && array_key_exists( 'order', $params ) ) { |
547 | | - $propertyValues = explode( ',', strtolower( $params['sort'] ) ); |
548 | | - $orderValues = explode( ',', $params['order'] ); |
549 | | - reset( $propertyValues ); |
550 | | - reset( $orderValues ); |
| 562 | + $sortVal = explode( ',', trim( strtolower( $params['sort'] ) ) ); |
| 563 | + $orderVal = explode( ',', $params['order'] ); |
| 564 | + reset( $sortVal ); |
| 565 | + reset( $orderVal ); |
| 566 | + // give up if sort and order dont have equal number of elements |
| 567 | + if ( count( $sortVal ) !== count( $orderVal ) ) { |
| 568 | + $orderVal = array(); |
| 569 | + $sortVal = array(); |
| 570 | + } |
551 | 571 | } else { |
552 | | - $orderValues = array(); // do not even show one sort input here |
553 | | - $propertyValues = array(); |
| 572 | + $orderVal = array(); |
| 573 | + $sortVal = array(); |
554 | 574 | } |
555 | | - foreach ( $po as $poValue ) { |
556 | | - if ( !in_array( $poValue, $propertyValues ) ) { |
557 | | - $propertyValues[] = $poValue; |
558 | | - } |
559 | | - } |
560 | | - $displayValues = array(); |
561 | | - reset( $propertyValues ); |
562 | | - foreach ( $propertyValues as $propertyKey => $propertyValue ) { |
563 | | - if ( in_array( $propertyValue, $po ) ) { |
564 | | - $displayValues[$propertyKey] = "yes"; |
| 575 | + $printOuts = ( $this->uiCore->getPrintOuts() ); |
| 576 | + $counter = 0; |
| 577 | + foreach ( $printOuts as $poKey => $poValue ) { |
| 578 | + if ( $poValue->getMode() == SMWPrintRequest::PRINT_CATS ) { |
| 579 | + $categoryValues[$counter] = ''; |
| 580 | + $categoryLabelValues[$counter] = $poValue->getLabel(); |
| 581 | + $categoryYesValues[$counter] = ''; |
| 582 | + $categoryNoValues[$counter] = ''; |
| 583 | + $counter++; |
| 584 | + } elseif ( $poValue->getMode() == SMWPrintRequest::PRINT_PROP ) { |
| 585 | + $tempProperty = trim( strtolower( $poValue->getData()->getText() ) ); |
| 586 | + $searchKey = array_search( $tempProperty, $sortVal ); |
| 587 | + if ( !( $searchKey === false ) ) { |
| 588 | + while ( $searchKey != 0 ) { |
| 589 | + $propertyValues[$counter] = array_shift( $sortVal ); |
| 590 | + $orderValues[$counter] = array_shift( $orderVal ); |
| 591 | + $propertyLabelValues[$counter] = ''; |
| 592 | + $propertyFormatValues[$counter] = ''; |
| 593 | + $propertyLimitValues[$counter] = ''; |
| 594 | + $counter++; |
| 595 | + $searchKey--; |
| 596 | + } |
| 597 | + $propertyValues[$counter] = $poValue->getData()->getText(); |
| 598 | + $propertyLabelValues[$counter] = ( $poValue->getLabel() == $propertyValues[$counter] ) ? '':$poValue->getLabel(); |
| 599 | + $propertyFormatValues[$counter] = $poValue->getOutputFormat(); |
| 600 | + $propertyLimitValues[$counter] = $poValue->getParameter( 'limit' ) ? $poValue->getParameter( 'limit' ):''; |
| 601 | + $orderValues[$counter] = $orderVal[0]; |
| 602 | + $displayValues[$counter] = '1'; |
| 603 | + $counter++; |
| 604 | + array_shift( $orderVal ); |
| 605 | + array_shift( $sortVal ); |
| 606 | + } else { |
| 607 | + $propertyValues[$counter] = $poValue->getData()->getText(); |
| 608 | + $propertyLabelValues[$counter] = ( $poValue->getLabel() == $propertyValues[$counter] ) ? '':$poValue->getLabel(); |
| 609 | + $propertyFormatValues[$counter] = $poValue->getOutputFormat(); |
| 610 | + $propertyLimitValues[$counter] = $poValue->getParameter( 'limit' ) ? $poValue->getParameter( 'limit' ):''; |
| 611 | + $displayValues[$counter] = '1'; |
| 612 | + $counter++; |
| 613 | + } |
| 614 | + } elseif ( $poValue->getMode() == SMWPrintRequest::PRINT_THIS ) { |
| 615 | + $mainColumnLabels[$counter] = $poValue->getLabel(); |
| 616 | + $counter++; |
| 617 | + } elseif ( $poValue->getMode() == SMWPrintRequest::PRINT_CCAT ) { |
| 618 | + $outputFormat = explode( ',', $poValue->getOutputFormat() ); |
| 619 | + if ( !array_key_exists( 1, $outputFormat ) ) { |
| 620 | + $outputFormat[1] = ''; |
| 621 | + } |
| 622 | + $categoryValues[$counter] = $poValue->getData()->getText(); |
| 623 | + $categoryLabelValues[$counter] = $poValue->getLabel(); |
| 624 | + $categoryYesValues[$counter] = $outputFormat[0]; |
| 625 | + $categoryNoValues[$counter] = $outputFormat[1]; |
| 626 | + $counter++; |
565 | 627 | } |
| 628 | + |
566 | 629 | } |
| 630 | + while ( !empty( $sortVal ) ) { |
| 631 | + $propertyValues[$counter] = array_shift( $sortVal ); |
| 632 | + $orderValues[$counter] = array_shift( $orderVal ); |
| 633 | + $propertyLabelValues[$counter] = ''; |
| 634 | + $propertyFormatValues[$counter] = ''; |
| 635 | + $propertyLimitValues[$counter] = ''; |
| 636 | + $counter++; |
| 637 | + } |
567 | 638 | } |
568 | 639 | $i = 0; |
569 | 640 | $additionalPOs = array(); |
— | — | @@ -609,15 +680,31 @@ |
610 | 681 | |
611 | 682 | $if4 = ( is_array( $displayValues ) && array_key_exists( $key, $displayValues ) ); |
612 | 683 | $result .= Xml::checkLabel( wfMsg( 'smw_qui_shownresults' ), "display[$i]", "display$i", $if4 ); |
| 684 | + |
| 685 | + if ( is_array( $propertyLabelValues ) && array_key_exists( $key, $propertyLabelValues ) ) { |
| 686 | + $result .= Xml::hidden( "prop_label[$i]", $propertyLabelValues[$key], array( 'id' => "prop_label$i" ) ); |
| 687 | + } else { |
| 688 | + $result .= Xml::hidden( "prop_label[$i]", '', array( 'id' => "prop_label$i" ) ); |
| 689 | + } |
| 690 | + if ( is_array( $propertyFormatValues ) && array_key_exists( $key, $propertyFormatValues ) ) { |
| 691 | + $result .= Xml::hidden( "prop_format[$i]", $propertyFormatValues[$key], array( 'id' => "prop_format$i" ) ); |
| 692 | + } else { |
| 693 | + $result .= Xml::hidden( "prop_format[$i]", '', array( 'id' => "prop_format$i" ) ); |
| 694 | + } |
| 695 | + if ( is_array( $propertyLimitValues ) && array_key_exists( $key, $propertyLimitValues ) ) { |
| 696 | + $result .= Xml::hidden( "prop_limit[$i]", $propertyLimitValues[$key], array( 'id' => "prop_limit$i" ) ); |
| 697 | + } else { |
| 698 | + $result .= Xml::hidden( "prop_limit[$i]", '', array( 'id' => "prop_limit$i" ) ); |
| 699 | + } |
613 | 700 | $result .= ' <a id="more' . $i . '" "class="smwq-more" href="javascript:smw_makePropDialog(\'' . $i . '\')"> ' . WfMsg( 'smw_qui_options' ) . ' </a> '; |
614 | 701 | |
615 | 702 | $result .= Xml::closeElement( 'div' ); |
616 | 703 | $i++; |
617 | 704 | } |
618 | 705 | if ( is_array( $categoryValues ) && array_key_exists( $key, $categoryValues ) && |
619 | | - is_array($categoryLabelValues) && array_key_exists( $key, $categoryLabelValues ) && |
620 | | - is_array($categoryYesValues) && array_key_exists( $key, $categoryYesValues ) && |
621 | | - is_array($categoryNoValues) && array_key_exists( $key, $categoryNoValues )) { |
| 706 | + is_array( $categoryLabelValues ) && array_key_exists( $key, $categoryLabelValues ) && |
| 707 | + is_array( $categoryYesValues ) && array_key_exists( $key, $categoryYesValues ) && |
| 708 | + is_array( $categoryNoValues ) && array_key_exists( $key, $categoryNoValues ) ) { |
622 | 709 | /* |
623 | 710 | * Make an element for additional categories |
624 | 711 | */ |
— | — | @@ -625,9 +712,9 @@ |
626 | 713 | $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>' . |
627 | 714 | wfMsg( 'smw_qui_category' ) . |
628 | 715 | Xml::input( "category[$i]", '25', $categoryValues[$key], array( 'id' => "category$i" ) ) . " " . |
629 | | - Html::hidden("cat_label[$i]", $categoryLabelValues[$key], array('id'=>"cat_label$i")). |
630 | | - Html::hidden("cat_yes[$i]", $categoryYesValues[$key], array('id'=>"cat_yes$i")). |
631 | | - Html::hidden("cat_no[$i]", $categoryNoValues[$key], array('id'=>"cat_no$i")). |
| 716 | + Html::hidden( "cat_label[$i]", $categoryLabelValues[$key], array( 'id' => "cat_label$i" ) ) . |
| 717 | + Html::hidden( "cat_yes[$i]", $categoryYesValues[$key], array( 'id' => "cat_yes$i" ) ) . |
| 718 | + Html::hidden( "cat_no[$i]", $categoryNoValues[$key], array( 'id' => "cat_no$i" ) ) . |
632 | 719 | ' <a id="more' . $i . '" "class="smwq-more" href="javascript:smw_makeCatDialog(\'' . $i . '\')"> ' . WfMsg( 'smw_qui_options' ) . ' </a> ' . |
633 | 720 | Xml::closeElement( 'div' ); |
634 | 721 | $i++; |
— | — | @@ -651,12 +738,15 @@ |
652 | 739 | $hiddenProperty = Html::openElement( 'div', array( 'id' => 'property_starter', 'class' => 'smwsort', 'style' => 'display:none' ) ) . |
653 | 740 | '<span class="smw-remove"><a><img src="' . $smwgScriptPath . '/skins/images/close-button.png" alt="' . wfMsg( 'smw_qui_delete' ) . '"></a></span>' . |
654 | 741 | wfMsg( 'smw_qui_property' ) . |
655 | | - Xml::input( "property_num", '35' ) . " " . |
| 742 | + Xml::input( 'property_num', '35' ) . " " . |
656 | 743 | Html::openElement( 'select', array( 'name' => 'order_num' ) ) . |
657 | 744 | Xml::option( wfMsg( 'smw_qui_nosort' ), 'NONE' ) . |
658 | 745 | Xml::option( wfMsg( 'smw_qui_ascorder' ), 'ASC' ) . |
659 | 746 | Xml::option( wfMsg( 'smw_qui_descorder' ), 'DESC' ) . |
660 | 747 | Xml::closeElement( 'select' ) . |
| 748 | + Xml::hidden( 'prop_label_num', '' ) . |
| 749 | + Xml::hidden( 'prop_format_num', '' ) . |
| 750 | + Xml::hidden( 'prop_limit_num', '' ) . |
661 | 751 | Xml::checkLabel( wfMsg( 'smw_qui_shownresults' ), "display_num", '', true ) . |
662 | 752 | Xml::closeElement( 'div' ); |
663 | 753 | $hiddenProperty = json_encode( $hiddenProperty ); |
— | — | @@ -665,9 +755,9 @@ |
666 | 756 | '<span class="smw-remove"><a><img src="' . $smwgScriptPath . '/skins/images/close-button.png" alt="' . wfMsg( 'smw_qui_delete' ) . '"></a></span>' . |
667 | 757 | wfMsg( 'smw_qui_category' ) . |
668 | 758 | Xml::input( "category_num", '25' ) . " " . |
669 | | - '<input type="hidden" name="cat_label_num" />'. |
670 | | - '<input type="hidden" name="cat_yes_num" />'. |
671 | | - '<input type="hidden" name="cat_no_num" />'. |
| 759 | + '<input type="hidden" name="cat_label_num" />' . |
| 760 | + '<input type="hidden" name="cat_yes_num" />' . |
| 761 | + '<input type="hidden" name="cat_no_num" />' . |
672 | 762 | Xml::closeElement( 'div' ); |
673 | 763 | $hiddenCategory = json_encode( $hiddenCategory ); |
674 | 764 | |
— | — | @@ -678,26 +768,32 @@ |
679 | 769 | Xml::closeElement( 'div' ); |
680 | 770 | $hiddenMainColumn = json_encode( $hiddenMainColumn ); |
681 | 771 | |
| 772 | + // create dialogbox for Property options |
| 773 | + $propertyHtml = Xml::inputLabelSep( 'Property:', '', 'd-property', 'd-property' ); // todo i18n |
| 774 | + $propertyLabelHtml = Xml::inputLabelSep( 'Label:', '', 'd-prop-label', 'd-prop-label' );// todo i18n |
| 775 | + $propertyFormatHtml = Xml::inputLabelSep( 'Format:', '', 'd-prop-format', 'd-prop-format' );// todo i18n |
| 776 | + $propertyLimitHtml = Xml::inputLabelSep( 'Limit:', 'd-prop-limit', 'd-prop-limit' ); // todo i18n |
682 | 777 | $propertyDialogBox = Xml::openElement( 'div', array( 'id' => 'prop-dialog', 'title' => wfMsg( 'smw_prp_options' ), 'class' => 'smwpropdialog' ) ) . |
683 | | - Xml::inputLabel( 'Property:', '', 'd-property', 'd-property' ) . '<br/>' . // todo i18n |
684 | | - Xml::inputLabel( 'Label:', '', 'd-property-label', 'd-property-label' ) . '<br/>' . // todo i18n |
685 | | - '<label for="format-custom">Format:</label> ' . |
686 | | - Xml::input( 'format-custom', false, false, array( 'id' => 'd-property-format-custom' ) ) . '<br/>' . |
687 | | - // Xml::inputLabel( 'Limit:', 'd-property-limit', 'd-property-limit' ) . '<br/>' . // todo i18n |
688 | | - '<input type="hidden" name="d-property-code" id="d-property-code">' . |
| 778 | + '<table>' . |
| 779 | + '<tr><td>' . $propertyHtml[0] . '</td><td>' . $propertyHtml[1] . '</td></tr>' . |
| 780 | + '<tr><td>' . $propertyLabelHtml[0] . '</td><td>' . $propertyLabelHtml[1] . '</td></tr>' . |
| 781 | + '<tr><td>' . $propertyLimitHtml[0] . '</td><td>' . $propertyLimitHtml[1] . '</td></tr>' . |
| 782 | + '<tr><td>' . $propertyFormatHtml[0] . '</td><td>' . $propertyFormatHtml[1] . '</td></tr>' . |
| 783 | + '</table>' . |
689 | 784 | Xml::closeElement( 'div' ); |
690 | | - //create dialogbox for Category options |
691 | | - $categoryHtml=Xml::inputLabelSep( wfMsg('smw_qui_dcategory'), '', 'd-category', 'd-category' ); |
692 | | - $categoryLabelHtml=Xml::inputLabelSep( wfMsg('smw_qui_dlabel'), '', 'd-category-label', 'd-category-label' ); |
693 | | - $categoryYesHtml=Xml::inputLabelSep( wfMsg('smw_qui_dcatyes'), '', 'd-category-yes', 'd-category-yes' ); |
694 | | - $categoryNoHtml=Xml::inputLabelSep( wfMsg('smw_qui_dcatno'), '', 'd-category-no', 'd-category-no' ); |
695 | | - $categoryDialogBox = Xml::openElement( 'div', array( 'id' => 'cat-dialog', 'title' => wfMsg('smw_qui_catopts'), 'class' => 'smwcatdialog' ) ) . |
696 | | - '<table>'. |
697 | | - '<tr><td>'.$categoryHtml[0].'</td><td>'.$categoryHtml[1].'</td></tr>'. |
698 | | - '<tr><td>'.$categoryYesHtml[0].'</td><td>'.$categoryYesHtml[1].'</td></tr>'. |
699 | | - '<tr><td>'.$categoryNoHtml[0].'</td><td>'.$categoryNoHtml[1].'</td></tr>'. |
700 | | - '<tr><td>'.$categoryLabelHtml[0].'</td><td>'.$categoryLabelHtml[1].'</td></tr>'. |
701 | | - '</table>'. |
| 785 | + |
| 786 | + // create dialogbox for Category options |
| 787 | + $categoryHtml = Xml::inputLabelSep( wfMsg( 'smw_qui_dcategory' ), '', 'd-category', 'd-category' ); |
| 788 | + $categoryLabelHtml = Xml::inputLabelSep( wfMsg( 'smw_qui_dlabel' ), '', 'd-category-label', 'd-category-label' ); |
| 789 | + $categoryYesHtml = Xml::inputLabelSep( wfMsg( 'smw_qui_dcatyes' ), '', 'd-category-yes', 'd-category-yes' ); |
| 790 | + $categoryNoHtml = Xml::inputLabelSep( wfMsg( 'smw_qui_dcatno' ), '', 'd-category-no', 'd-category-no' ); |
| 791 | + $categoryDialogBox = Xml::openElement( 'div', array( 'id' => 'cat-dialog', 'title' => wfMsg( 'smw_qui_catopts' ), 'class' => 'smwcatdialog' ) ) . |
| 792 | + '<table>' . |
| 793 | + '<tr><td>' . $categoryHtml[0] . '</td><td>' . $categoryHtml[1] . '</td></tr>' . |
| 794 | + '<tr><td>' . $categoryYesHtml[0] . '</td><td>' . $categoryYesHtml[1] . '</td></tr>' . |
| 795 | + '<tr><td>' . $categoryNoHtml[0] . '</td><td>' . $categoryNoHtml[1] . '</td></tr>' . |
| 796 | + '<tr><td>' . $categoryLabelHtml[0] . '</td><td>' . $categoryLabelHtml[1] . '</td></tr>' . |
| 797 | + '</table>' . |
702 | 798 | Xml::closeElement( 'div' ); |
703 | 799 | |
704 | 800 | $result .= '<div id="sorting_main"></div>' . "\n"; |
— | — | @@ -730,7 +826,7 @@ |
731 | 827 | |
732 | 828 | jQuery.getJSON(url, 'search='+request.term, function(data){ |
733 | 829 | //remove the namespace prefix 'Property:' from returned data |
734 | | - for(i=0;i<data[1].length;i++) data[1][i]='?'+data[1][i].substr(data[1][i].indexOf(':')+1); |
| 830 | + for(i=0;i<data[1].length;i++) data[1][i]=data[1][i].substr(data[1][i].indexOf(':')+1); |
735 | 831 | response(data[1]); |
736 | 832 | }); |
737 | 833 | |
— | — | @@ -745,7 +841,7 @@ |
746 | 842 | url=wgScriptPath+'/api.php?action=opensearch&limit=10&namespace='+wgNamespaceIds['category']+'&format=jsonfm'; |
747 | 843 | |
748 | 844 | jQuery.getJSON(url, 'search='+request.term, function(data){ |
749 | | - //remove the namespace prefix 'Property:' from returned data |
| 845 | + //remove the namespace prefix 'Category:' from returned data |
750 | 846 | for(i=0;i<data[1].length;i++) data[1][i]=data[1][i].substr(data[1][i].indexOf(':')+1); |
751 | 847 | response(data[1]); |
752 | 848 | }); |
— | — | @@ -766,18 +862,6 @@ |
767 | 863 | } |
768 | 864 | |
769 | 865 | $javascriptText .= <<<EOT |
770 | | -function smw_prop_code_update(){ |
771 | | - code = '?'+jQuery('#d-property')[0].value; |
772 | | - if(code!=''){ |
773 | | - if(jQuery('#d-property-format-custom')[0].value !=''){ |
774 | | - code = code + jQuery('#d-property-format-custom')[0].value; |
775 | | - } |
776 | | - if(jQuery('#d-property-label')[0].value !=''){ |
777 | | - code = code + ' = '+ jQuery('#d-property-label')[0].value; |
778 | | - } |
779 | | - jQuery('#d-property-code')[0].value= code; |
780 | | - } |
781 | | -} |
782 | 866 | |
783 | 867 | function smw_makeCatDialog(cat_id){ |
784 | 868 | jQuery('#prop-cat input').attr('value',''); |
— | — | @@ -791,32 +875,21 @@ |
792 | 876 | jQuery('#d-category-no').attr('value',no); |
793 | 877 | jQuery('#d-category-label').attr('value',label); |
794 | 878 | jQuery('#d-category').attr('value',cat); |
795 | | - |
| 879 | + |
796 | 880 | jQuery('#cat-dialog').dialog.id=cat_id; |
797 | 881 | jQuery('#cat-dialog').dialog('open'); |
798 | 882 | } |
799 | 883 | |
800 | 884 | function smw_makePropDialog(prop_id){ |
801 | 885 | jQuery('#prop-dialog input').attr('value',''); |
802 | | - prop=val=jQuery('#property'+prop_id)[0].value; |
803 | | - if(val[0]='?') val=prop=prop.substr(1); |
804 | | - if((i=val.indexOf('='))!=-1) prop=prop.substring(0, i); |
805 | | - if((i=val.indexOf('#'))!=-1) prop=prop.substring(0, i); |
806 | | - if(val.split('=')[1]){ |
807 | | - label=val.split('=')[1].trim(); |
808 | | - }else{ |
809 | | - label=""; |
810 | | - } |
811 | | - format = val.split('=')[0]; |
812 | | - if(format.indexOf('#')!=-1){ |
813 | | - format=format.substr(format.indexOf('#')); |
814 | | - }else{ |
815 | | - format=""; |
816 | | - } |
817 | | - |
818 | | - jQuery('#d-property').attr('value', prop.trim()); |
819 | | - jQuery('#d-property-label').attr('value', label); |
820 | | - jQuery('#d-property-format-custom').attr('value', format.trim()); |
| 886 | + prop=jQuery('#property'+prop_id).attr('value'); |
| 887 | + label=jQuery('#prop_label'+prop_id).attr('value'); |
| 888 | + format=jQuery('#prop_format'+prop_id).attr('value'); |
| 889 | + limit=jQuery('#prop_limit'+prop_id).attr('value'); |
| 890 | + jQuery('#d-property').attr('value', prop); |
| 891 | + jQuery('#d-prop-label').attr('value', label); |
| 892 | + jQuery('#d-prop-limit').attr('value', limit); |
| 893 | + jQuery('#d-prop-format').attr('value', format); |
821 | 894 | jQuery('#prop-dialog').dialog.id=prop_id; |
822 | 895 | jQuery('#prop-dialog').dialog('open'); |
823 | 896 | } |
— | — | @@ -967,12 +1040,19 @@ |
968 | 1041 | autoOpen: false, |
969 | 1042 | modal: true, |
970 | 1043 | resizable: true, |
971 | | - minHeight: 200, |
972 | | - minWidth: 400, |
973 | 1044 | buttons: { |
974 | 1045 | "{$okMsg}": function(){ |
975 | | - smw_prop_code_update(); |
976 | | - jQuery('#property'+jQuery(this).dialog.id)[0].value=jQuery('#d-property-code')[0].value; |
| 1046 | + id=jQuery(this).dialog.id; |
| 1047 | + property=jQuery('#d-property').attr('value'); |
| 1048 | + label=jQuery('#d-prop-label').attr('value'); |
| 1049 | + limit=jQuery('#d-prop-limit').attr('value'); |
| 1050 | + format=jQuery('#d-prop-format').attr('value'); |
| 1051 | + |
| 1052 | + |
| 1053 | + jQuery('#property'+id).attr('value',property); |
| 1054 | + jQuery('#prop_label'+id).attr('value',label); |
| 1055 | + jQuery('#prop_limit'+id).attr('value',limit); |
| 1056 | + jQuery('#prop_format'+id).attr('value',format); |
977 | 1057 | jQuery(this).dialog("close"); |
978 | 1058 | }, |
979 | 1059 | "{$cancelMsg}": function(){ |