r94336 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94335‎ | r94336 | r94337 >
Date:10:31, 12 August 2011
Author:devayon
Status:deferred
Tags:
Comment:
follow-up: r94233, r94116.
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/languages/SMW_Messages.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_SpecialQueryCreator.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_SpecialQueryCreator.php
@@ -147,7 +147,6 @@
148148 $po = array();
149149 $category_namespace = $wgContLang->getNsText( NS_CATEGORY );
150150 if ( is_array( $main_column_labels ) ) {
151 - $po['mainlabel'] = '-'; // disables mainlabel parameter so that the UI can control it from here
152151 foreach ( $main_column_labels as $key => $label ) {
153152 if ( $label == '' ) {
154153 $po[$key] = "?";
@@ -156,8 +155,6 @@
157156 }
158157
159158 }
160 - } else {
161 - $po['mainlabel'] = ''; // enables mainlabel parameter
162159 }
163160 if ( is_array( $category_values ) ) {
164161 foreach ( $category_values as $key => $value ) {
@@ -300,7 +297,10 @@
301298 $i = 0;
302299 $additional_POs = array();
303300 if ( is_array( $property_values ) ) {
304 - $additional_POs = array_merge( $additional_POs, $property_values );
 301+ $keys = array_keys( $property_values );
 302+ foreach ( $keys as $value ) {
 303+ $additional_POs[$value] = $property_values[$value]; // array_merge won't work because numeric keys need to be preserved
 304+ }
305305 }
306306 if ( is_array( $category_values ) ) {// same as testing $category_label_values
307307 $keys = array_keys( $category_values );
@@ -339,7 +339,7 @@
340340
341341 $if4 = ( is_array( $display_values ) and array_key_exists( $key, $display_values ) );
342342 $result .= Xml::checkLabel( wfMsg( 'smw_qui_shownresults' ), "display[$i]", "display$i", $if4 );
343 - $result .= ' <a id="more' . $i . '" "class="smwq-more" href="javascript:smw_makePropDialog(\'' . $i . '\')"> options </a> '; // TODO: i18n
 343+ $result .= ' <a id="more' . $i . '" "class="smwq-more" href="javascript:smw_makePropDialog(\'' . $i . '\')"> ' . WfMsg( 'smw_qui_options' ) . ' </a> ';
344344
345345 $result .= Xml::closeElement( 'div' );
346346 $i++;
@@ -350,11 +350,11 @@
351351 */
352352 $result .= Html::openElement( 'div', array( 'id' => "sort_div_$i", 'class' => 'smwsort' ) );
353353 $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>' .
354 - 'Category (optional)' . // todo: i18n
 354+ wfMsg( 'smw_qui_category' ) .
355355 Xml::input( "category[$i]", '20', $category_values[$key], array( 'id' => "category$i" ) ) . " " .
356 - 'Label' . // todo: i18n
 356+ wfMsg( 'smw_qui_label' ) .
357357 Xml::input( "cat_label[$i]", '20', array_key_exists( $key, $category_label_values ) ? $category_label_values[$key]:false, array( 'id' => "cat_label$i" ) ) . " " .
358 - ' <a id="more' . $i . '" "class="smwq-more" href="javascript:smw_makeCatDialog(\'' . $i . '\')"> options </a> ' . // TODO: i18n
 358+ ' <a id="more' . $i . '" "class="smwq-more" href="javascript:smw_makeCatDialog(\'' . $i . '\')"> ' . WfMsg( 'smw_qui_options' ) . ' </a> ' .
359359 Xml::closeElement( 'div' );
360360 $i++;
361361 }
@@ -389,9 +389,9 @@
390390
391391 $hidden_category = Html::openElement( 'div', array( 'id' => 'category_starter', 'class' => 'smwsort', 'style' => 'display:none' ) ) .
392392 '<span class="smw-remove"><a><img src="' . $smwgScriptPath . '/skins/images/close-button.png" alt="' . wfMsg( 'smw_qui_delete' ) . '"></a></span>' .
393 - 'Category (optional)' . // todo: i18n
 393+ wfMsg( 'smw_qui_category' ) .
394394 Xml::input( "category_num", '20' ) . " " .
395 - 'Label' . // todo: i18n
 395+ wfMsg( 'smw_qui_label' ) .
396396 Xml::input( "cat_label_num", '20' ) . " " .
397397 Xml::closeElement( 'div' );
398398 $hidden_category = json_encode( $hidden_category );
@@ -403,7 +403,7 @@
404404 Xml::closeElement( 'div' );
405405 $hidden_main_column = json_encode( $hidden_main_column );
406406
407 - $property_dialog_box = Xml::openElement( 'div', array( 'id' => 'prop-dialog', 'title' => 'Property Options', 'class' => 'smwpropdialog' ) ) . // todo i18n
 407+ $property_dialog_box = Xml::openElement( 'div', array( 'id' => 'prop-dialog', 'title' => wfMsg( 'smw_prp_options' ), 'class' => 'smwpropdialog' ) ) .
408408 Xml::inputLabel( 'Property:', '', 'd-property', 'd-property' ) . '<br/>' . // todo i18n
409409 Xml::inputLabel( 'Label:', '', 'd-property-label', 'd-property-label' ) . '<br/>' . // todo i18n
410410 '<label for="d-format">Format:</label> ' . Html::openElement( 'select', array( 'name' => 'd-format', 'id' => 'd-format' ) ) . // todo i18n
@@ -415,23 +415,27 @@
416416 '<input type="hidden" name="d-property-code" id="d-property-code">' .
417417 Xml::closeElement( 'div' );
418418 $category_dialog_box = Xml::openElement( 'div', array( 'id' => 'cat-dialog', 'title' => 'Category Options', 'class' => 'smwcatdialog' ) ) . // todo i18n
419 - Xml::inputLabel( 'Category:', '', 'd-category', 'd-category' ) . '<br/>' . // todo i18n
420419 Xml::inputLabel( 'Label:', '', 'd-category-label', 'd-category-label' ) . '<br/>' . // todo i18n
421 - Xml::inputLabel( 'Yes:', '', 'd-category-yes', 'd-category-yes' ) . '<br/>' . // todo i18n
422 - Xml::inputLabel( 'No:', '', 'd-category-no', 'd-category-no' ) . '<br/>' . // todo i18n
423 - 'Code :<input type="text" name="d-category-code" id="d-category-code">' . // todo hide
 420+ Xml::inputLabel( 'Category:', '', 'd-category', 'd-category' ) . '<br/><br/>' . // todo i18n
 421+ Xml::inputLabel( 'Show text when category is present:', '', 'd-category-yes', 'd-category-yes' ) . '<br/><br/>' . // todo i18n
 422+ Xml::inputLabel( 'Show text when category is absent:', '', 'd-category-no', 'd-category-no' ) . '<br/><br/>' . // todo i18n
 423+ '<input type="hidden" name="d-category-code" id="d-category-code">' .
424424 Xml::closeElement( 'div' );
425425
426426 $result .= '<div id="sorting_main"></div>' . "\n";
427427 $result .= '[<a href="javascript:smw_addPropertyInstance(\'property_starter\', \'sorting_main\')">' . wfMsg( 'smw_qui_addnprop' ) . '</a>]' .
428 - '[<a href="javascript:smw_addCategoryInstance(\'category_starter\', \'sorting_main\')">' . 'Add additional category' . '</a>]' . // todo i18n
429 - '[<a href="javascript:smw_addMainColInstance(\'maincol_starter\', \'sorting_main\')">' . 'Add main column' . '</a>]' . // todo i18n
 428+ '[<a href="javascript:smw_addCategoryInstance(\'category_starter\', \'sorting_main\')">' . wfMsg( 'smw_qui_addcategory' ) . '</a>]' .
 429+ '[<a href="javascript:smw_addMainColInstance(\'maincol_starter\', \'sorting_main\')">' . wfMsg( 'smw_qui_addrescol' ) . '</a>]' .
430430 "\n";
431431
432432 // Javascript code for handling adding and removing the "sort" inputs
433433 if ( $enableAutocomplete == SMWQueryUI::ENABLE_AUTO_SUGGEST ) {
434434 $this->addAutocompletionJavascriptAndCSS();
435435 }
 436+ // localisation messages for javascript
 437+ $optionsMsg = wfMsg( 'smw_qui_options' );
 438+ $okMsg = wfMsg( 'smw_qui_ok' );
 439+ $cancelMsg = wfMsg( 'smw_qui_cancel' );
436440 $javascript_text = <<<EOT
437441 <script type="text/javascript">
438442 var num_elements = {$num_sort_values};
@@ -498,16 +502,41 @@
499503 }
500504
501505 function smw_cat_code_update(){
 506+ cat = jQuery('#d-category').attr('value');
 507+ label =code= jQuery('#d-category-label').attr('value');
 508+ yes = jQuery('#d-category-yes').attr('value');
 509+ no = jQuery('#d-category-no').attr('value');
 510+ if (cat.trim()!='' && yes.trim()!=''){
 511+ code=cat+'#'+yes;
 512+ if(no.trim()!=''){
 513+ code=code+','+no;
 514+ }
 515+ }
 516+ jQuery('#d-category-code').attr('value', code);
502517
503518 }
504519
505520 function smw_makeCatDialog(cat_id){
506521 jQuery('#prop-cat input').attr('value','');
507522 cat=jQuery('#category'+cat_id)[0].value;
508 - jQuery('#d-category').attr('value',cat);
509523 label=jQuery('#cat_label'+cat_id)[0].value;
 524+ cats=cat.split('#');
 525+ cat= cats[0];
 526+ if(cats[1]){
 527+ yes_no = cats[1].split(',');
 528+ if(yes_no[1]){
 529+ no=yes_no[1];
 530+ } else {
 531+ no = '';
 532+ }
 533+ yes=yes_no[0];
 534+ jQuery('#d-category-yes').attr('value',yes);
 535+ jQuery('#d-category-no').attr('value',no);
 536+ }
510537 jQuery('#d-category-label').attr('value',label);
511 - //jQuery('#cat-dialog').dialog('open');
 538+ jQuery('#d-category').attr('value',cat);
 539+ jQuery('#cat-dialog').dialog.id=cat_id;
 540+ jQuery('#cat-dialog').dialog('open');
512541 }
513542
514543 function smw_makePropDialog(prop_id){
@@ -558,7 +587,7 @@
559588
560589 //Create 'more' link
561590 var more_button =document.createElement('span');
562 - more_button.innerHTML = ' <a class="smwq-more" href="javascript:smw_makePropDialog(\'' + num_elements + '\')">options</a> '; //TODO: i18n
 591+ more_button.innerHTML = ' <a class="smwq-more" href="javascript:smw_makePropDialog(\'' + num_elements + '\')">{$optionsMsg}</a> ';
563592 more_button.id = 'more'+num_elements;
564593 new_div.appendChild(more_button);
565594
@@ -594,7 +623,7 @@
595624
596625 //Create 'more' link
597626 var more_button =document.createElement('span');
598 - more_button.innerHTML = ' <a class="smwq-more" href="javascript:smw_makeCatDialog(\'' + num_elements + '\')">options</a> '; //TODO: i18n
 627+ more_button.innerHTML = ' <a class="smwq-more" href="javascript:smw_makeCatDialog(\'' + num_elements + '\')">{$optionsMsg}</a> ';
599628 more_button.id = 'more'+num_elements;
600629 new_div.appendChild(more_button);
601630
@@ -657,18 +686,20 @@
658687 minHeight: 200,
659688 minWidth: 400,
660689 buttons: {
661 - "Ok": function(){ //todo i18
 690+ "{$okMsg}": function(){
662691 smw_cat_code_update();
663 - // todo: move modal window data to main window form controls;
 692+ label = jQuery('#d-category-label').attr('value');
 693+ code = jQuery('#d-category-code').attr('value');
 694+ jQuery('#category'+jQuery(this).dialog.id).attr('value',code);
 695+ jQuery('#cat_label'+jQuery(this).dialog.id).attr('value',label);
664696 jQuery(this).dialog("close");
665697 },
666 - "Cancel": function(){ //todo:i18n
 698+ "{$cancelMsg}": function(){
667699 jQuery('#cat-dialog input').attr('value','');
668700 jQuery(this).dialog("close");
669701 }
670702 }
671703 });
672 - //todo: run smw_cat_code_update() when input values in category modal windows changes
673704
674705 jQuery('#prop-dialog').dialog({
675706 autoOpen: false,
@@ -677,19 +708,18 @@
678709 minHeight: 200,
679710 minWidth: 400,
680711 buttons: {
681 - "Ok": function(){ //todo: i18n
 712+ "{$okMsg}": function(){
682713 smw_prop_code_update();
683 - jQuery('#property'+jQuery('#prop-dialog').dialog.id)[0].value=jQuery('#d-property-code')[0].value;
 714+ jQuery('#property'+jQuery(this).dialog.id)[0].value=jQuery('#d-property-code')[0].value;
684715 jQuery(this).dialog("close");
685716 },
686 - "Cancel": function(){ //todo: i18n
 717+ "{$cancelMsg}": function(){
687718 jQuery('#prop-dialog input').attr('value','');
688719 jQuery(this).dialog("close");
689720 }
690721 }
691722 });
692723 jQuery('#sort-more').click(function(){jQuery('#prop-dialog').dialog("open");});
693 - jQuery('#prop-dialog input').bind('keyup click', smw_prop_code_update );
694724
695725 jQuery('#d-format').bind('change', function(event){
696726 jQuery('#d-property-format-custom').attr('value', jQuery('#d-format').attr('value'));
@@ -706,24 +736,5 @@
707737 $wgOut->addScript( $javascript_text );
708738 return $result;
709739 }
710 -
711 -
712 - /**
713 - * Compatibility method to get the skin; MW 1.18 introduces a getSkin method
714 - * in SpecialPage.
715 - *
716 - * @since 1.6
717 - *
718 - * @return Skin
719 - */
720 - public function getSkin() {
721 - if ( method_exists( 'SpecialPage', 'getSkin' ) ) {
722 - return parent::getSkin();
723 - } else {
724 - global $wgUser;
725 - return $wgUser->getSkin();
726 - }
727 - }
728 -
729740 }
730741
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_Messages.php
@@ -254,7 +254,15 @@
255255 'smw_qui_descorder' => 'Descending',
256256 'smw_qui_addnprop' => 'Add additional properties',
257257 'smw_qui_delete' => 'Remove',
258 - 'smw_qui_rescol' => 'Result column label',
 258+ 'smw_qui_rescol' => 'Column label',
 259+ 'smw_qui_options' => 'options',
 260+ 'smw_qui_addcategory' => 'Add additional category',
 261+ 'smw_qui_addrescol' => 'Add result column',
 262+ 'smw_qui_ok' => 'Ok',
 263+ 'smw_qui_cancel' => 'Cancel',
 264+ 'smw_qui_category' => 'Category (optional)',
 265+ 'smw_qui_label' => 'Label',
 266+ 'smw_prp_options' => 'Property Options',
259267
260268 // Messages for the search by property special
261269 'searchbyproperty' => 'Search by property',
@@ -415,6 +423,10 @@
416424 'smw_qui_nosort' => 'Option in a drop-down menu indicating that user does not want any sorting to be done',
417425 'smw_qui_addnprop' => 'Clicking on this message creates a new form to add more properties',
418426 'smw_qui_delete' => 'Removes/deletes a form option',
 427+ 'smw_qui_rescol' => 'Label for the main result column. See http://semantic-mediawiki.org/wiki/Help:Displaying_information#The_main_result_column/ for further information. The text appears as a label next to an text-box',
 428+ 'smw_qui_ok' => 'Ok button',
 429+ 'smw_qui_cancel' => 'Cancel button',
 430+ 'smw_prp_options' => 'Advanced options for property (title for a new modal window)',
419431 'smw_sbv_property' => '{{Identical|Property}}',
420432 'smw_sbv_value' => '{{Identical|Value}}',
421433 'smw_sbv_submit' => '{{Identical|Find results}}',

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r94116added control for category optionsdevayon15:44, 9 August 2011
r94233added control for main columndevayon09:20, 11 August 2011