r94451 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94450‎ | r94451 | r94452 >
Date:10:33, 14 August 2011
Author:devayon
Status:deferred
Tags:
Comment:
cleanup for category printouts
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/languages/SMW_Messages.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_QueryUIHelper.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_QueryUIHelper.php
@@ -396,9 +396,11 @@
397397 $propertyValues = $wgRequest->getArray( 'property' );
398398 $categoryValues = $wgRequest->getArray( 'category' );
399399 $categoryLabelValues = $wgRequest->getArray( 'cat_label' );
 400+ $categoryYesValues = $wgRequest->getArray( 'cat_yes' );
 401+ $categoryNoValues = $wgRequest->getArray( 'cat_no' );
400402 $mainColumnLabels = $wgRequest->getArray( 'maincol_label' );
401403 $po = array();
402 - $categoryNamespace = $wgContLang->getNsText( NS_CATEGORY );
 404+
403405 if ( is_array( $mainColumnLabels ) ) {
404406 foreach ( $mainColumnLabels as $key => $label ) {
405407 if ( $label == '' ) {
@@ -409,12 +411,27 @@
410412
411413 }
412414 }
 415+
 416+ $categoryNamespace = $wgContLang->getNsText( NS_CATEGORY );
413417 if ( is_array( $categoryValues ) ) {
414418 foreach ( $categoryValues as $key => $value ) {
415419 if ( trim( $value ) == '' ) {
416420 $po[$key] = "?$categoryNamespace" ;
417421 } else {
418422 $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)){
 427+
 428+ if($categoryYesValues[$key]!==''){
 429+ $po[$key] .="#$categoryYesValues[$key]";
 430+ if($categoryNoValues[$key]!==''){
 431+ $po[$key] .=",$categoryNoValues[$key]";
 432+ }
 433+ }
 434+ }
 435+
419436 }
420437 }
421438 }
@@ -489,6 +506,8 @@
490507 $displayValues = $wgRequest->getArray( 'display' );
491508 $categoryValues = $wgRequest->getArray( 'category' );
492509 $categoryLabelValues = $wgRequest->getArray( 'cat_label' );
 510+ $categoryYesValues = $wgRequest->getArray( 'cat_yes' );
 511+ $categoryNoValues = $wgRequest->getArray( 'cat_no' );
493512 $mainColumnLabels = $wgRequest->getArray( 'maincol_label' );
494513
495514 if ( is_array( $propertyValues ) || is_array( $categoryValues ) || is_array( $mainColumnLabels ) ) {
@@ -595,7 +614,10 @@
596615 $result .= Xml::closeElement( 'div' );
597616 $i++;
598617 }
599 - if ( is_array( $categoryValues ) && array_key_exists( $key, $categoryValues ) ) {
 618+ 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 )) {
600622 /*
601623 * Make an element for additional categories
602624 */
@@ -603,8 +625,9 @@
604626 $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>' .
605627 wfMsg( 'smw_qui_category' ) .
606628 Xml::input( "category[$i]", '25', $categoryValues[$key], array( 'id' => "category$i" ) ) . " " .
607 - wfMsg( 'smw_qui_label' ) .
608 - Xml::input( "cat_label[$i]", '20', array_key_exists( $key, $categoryLabelValues ) ? $categoryLabelValues[$key]:false, array( 'id' => "cat_label$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")).
609632 ' <a id="more' . $i . '" "class="smwq-more" href="javascript:smw_makeCatDialog(\'' . $i . '\')"> ' . WfMsg( 'smw_qui_options' ) . ' </a> ' .
610633 Xml::closeElement( 'div' );
611634 $i++;
@@ -642,8 +665,9 @@
643666 '<span class="smw-remove"><a><img src="' . $smwgScriptPath . '/skins/images/close-button.png" alt="' . wfMsg( 'smw_qui_delete' ) . '"></a></span>' .
644667 wfMsg( 'smw_qui_category' ) .
645668 Xml::input( "category_num", '25' ) . " " .
646 - wfMsg( 'smw_qui_label' ) .
647 - Xml::input( "cat_label_num", '20' ) . " " .
 669+ '<input type="hidden" name="cat_label_num" />'.
 670+ '<input type="hidden" name="cat_yes_num" />'.
 671+ '<input type="hidden" name="cat_no_num" />'.
648672 Xml::closeElement( 'div' );
649673 $hiddenCategory = json_encode( $hiddenCategory );
650674
@@ -662,12 +686,18 @@
663687 // Xml::inputLabel( 'Limit:', 'd-property-limit', 'd-property-limit' ) . '<br/>' . // todo i18n
664688 '<input type="hidden" name="d-property-code" id="d-property-code">' .
665689 Xml::closeElement( 'div' );
666 - $categoryDialogBox = Xml::openElement( 'div', array( 'id' => 'cat-dialog', 'title' => 'Category Options', 'class' => 'smwcatdialog' ) ) . // todo i18n
667 - Xml::inputLabel( 'Label:', '', 'd-category-label', 'd-category-label' ) . '<br/>' . // todo i18n
668 - Xml::inputLabel( 'Category:', '', 'd-category', 'd-category' ) . '<br/><br/>' . // todo i18n
669 - Xml::inputLabel( 'Show text when category is present:', '', 'd-category-yes', 'd-category-yes' ) . '<br/><br/>' . // todo i18n
670 - Xml::inputLabel( 'Show text when category is absent:', '', 'd-category-no', 'd-category-no' ) . '<br/><br/>' . // todo i18n
671 - '<input type="hidden" name="d-category-code" id="d-category-code">' .
 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>'.
672702 Xml::closeElement( 'div' );
673703
674704 $result .= '<div id="sorting_main"></div>' . "\n";
@@ -749,40 +779,19 @@
750780 }
751781 }
752782
753 -function smw_cat_code_update(){
754 - cat = code = jQuery('#d-category').attr('value');
755 - label = jQuery('#d-category-label').attr('value');
756 - yes = jQuery('#d-category-yes').attr('value');
757 - no = jQuery('#d-category-no').attr('value');
758 - if (cat.trim()!='' && yes.trim()!=''){
759 - code=cat+'#'+yes;
760 - if(no.trim()!=''){
761 - code=code+','+no;
762 - }
763 - }
764 - jQuery('#d-category-code').attr('value', code);
765 -
766 -}
767 -
768783 function smw_makeCatDialog(cat_id){
769784 jQuery('#prop-cat input').attr('value','');
 785+
770786 cat=jQuery('#category'+cat_id)[0].value;
771787 label=jQuery('#cat_label'+cat_id)[0].value;
772 - cats=cat.split('#');
773 - cat= cats[0];
774 - if(cats[1]){
775 - yes_no = cats[1].split(',');
776 - if(yes_no[1]){
777 - no=yes_no[1];
778 - } else {
779 - no = '';
780 - }
781 - yes=yes_no[0];
782 - jQuery('#d-category-yes').attr('value',yes);
783 - jQuery('#d-category-no').attr('value',no);
784 - }
 788+ yes = jQuery('#cat_yes'+cat_id)[0].value;
 789+ no = jQuery('#cat_no'+cat_id)[0].value;
 790+
 791+ jQuery('#d-category-yes').attr('value',yes);
 792+ jQuery('#d-category-no').attr('value',no);
785793 jQuery('#d-category-label').attr('value',label);
786794 jQuery('#d-category').attr('value',cat);
 795+
787796 jQuery('#cat-dialog').dialog.id=cat_id;
788797 jQuery('#cat-dialog').dialog('open');
789798 }
@@ -935,11 +944,16 @@
936945 minWidth: 400,
937946 buttons: {
938947 "{$okMsg}": function(){
939 - smw_cat_code_update();
 948+ cat = jQuery('#d-category').attr('value');
940949 label = jQuery('#d-category-label').attr('value');
941 - code = jQuery('#d-category-code').attr('value');
942 - jQuery('#category'+jQuery(this).dialog.id).attr('value',code);
943 - jQuery('#cat_label'+jQuery(this).dialog.id).attr('value',label);
 950+ yes = jQuery('#d-category-yes').attr('value');
 951+ no = jQuery('#d-category-no').attr('value');
 952+ id=jQuery(this).dialog.id;
 953+
 954+ jQuery('#category'+id).attr('value',cat);
 955+ jQuery('#cat_label'+id).attr('value',label);
 956+ jQuery('#cat_yes'+id).attr('value',yes);
 957+ jQuery('#cat_no'+id).attr('value',no);
944958 jQuery(this).dialog("close");
945959 },
946960 "{$cancelMsg}": function(){
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_Messages.php
@@ -244,7 +244,7 @@
245245 Names(<strong>[[Germany]]</strong>) and Namespaces (<strong>[[{{ns:help}}:+]]</strong>)',
246246
247247 //Generic messages for Query UI
248 - 'smw_qui_property' => 'Property',
 248+ 'smw_qui_property' => '<strong>Property</strong>',
249249 'smw_qui_shownresults' => 'show in results',
250250 'smw_qui_noquery' => 'No query has been specified',
251251 'smw_qui_invalidprop' => '"$1" may not be a valid property',
@@ -252,17 +252,22 @@
253253 'smw_qui_nosort' => 'No sorting',
254254 'smw_qui_ascorder' => 'Ascending',
255255 'smw_qui_descorder' => 'Descending',
256 - 'smw_qui_addnprop' => 'Add additional properties',
 256+ 'smw_qui_addnprop' => 'Add additional property',
257257 'smw_qui_delete' => 'Remove',
258 - 'smw_qui_rescol' => 'Column label',
 258+ 'smw_qui_rescol' => '<strong>Query Matches</strong> Label',
259259 'smw_qui_options' => 'options',
260260 'smw_qui_addcategory' => 'Add additional category',
261261 'smw_qui_addrescol' => 'Add main result column',
262262 'smw_qui_ok' => 'Ok',
263263 'smw_qui_cancel' => 'Cancel',
264 - 'smw_qui_category' => 'Category (optional)',
 264+ 'smw_qui_category' => '<strong>Category</strong>',
265265 'smw_qui_label' => 'Label',
266266 'smw_prp_options' => 'Property Options',
 267+ 'smw_qui_catopts' => 'Category Options',
 268+ 'smw_qui_dlabel' => 'Label:',
 269+ 'smw_qui_dcategory' => 'Category:',
 270+ 'smw_qui_dcatyes' => 'Show text when category is present:',
 271+ 'smw_qui_dcatno' => 'Show text when category is absent:',
267272
268273 // Messages for the search by property special
269274 'searchbyproperty' => 'Search by property',