r31913 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r31912‎ | r31913 | r31914 >
Date:12:55, 13 March 2008
Author:yaron
Status:old
Tags:
Comment:
Added sdfBooleanToString() function
Modified paths:
  • /trunk/extensions/SemanticDrilldown/includes/SD_GlobalFunctions.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticDrilldown/includes/SD_GlobalFunctions.php
@@ -7,7 +7,7 @@
88
99 if (!defined('MEDIAWIKI')) die();
1010
11 -define('SD_VERSION','0.3.8');
 11+define('SD_VERSION','0.3.9');
1212
1313 // constants for special properties
1414 define('SD_SP_HAS_FILTER', 1);
@@ -510,6 +510,27 @@
511511 }
512512 }
513513
 514+function sdfBooleanToString($bool_value) {
 515+ $words_field_name = ($bool_value == true) ? 'smw_true_words' : 'smw_false_words';
 516+ $words_array = explode(',', wfMsgForContent($words_field_name));
 517+ // go with the value in the array that tends to be "yes" or "no" -
 518+ // for SMW 0.7 it's the 2nd word, and for SMW 1.0 it's the 3rd
 519+ $smw_version = SMW_VERSION;
 520+ if ($smw_version{0} == '0')
 521+ $index_of_word = 1;
 522+ else
 523+ $index_of_word = 2;
 524+ // capitalize first letter of word
 525+ if (count($words_array) > $index_of_word) {
 526+ $string_value = ucwords($words_array[$index_of_word]);
 527+ } elseif (count($words_array) == 0) {
 528+ $string_value = $bool_value; // a safe value if no words are found
 529+ } else {
 530+ $string_value = ucwords($words_array[0]);
 531+ }
 532+ return $string_value;
 533+}
 534+
514535 /**
515536 * Prints the mini-form contained at the bottom of various pages, that
516537 * allows pages to spoof a normal edit page, that can preview, save,

Status & tagging log