http://www.mediawiki.org/wiki/Special:Code/MediaWiki/90974
Revision: 90974
Author: jeroendedauw
Date: 2011-06-28 15:49:47 +0000 (Tue, 28 Jun 2011)
Log Message:
-----------
some stylizing
Modified Paths:
--------------
trunk/extensions/SemanticResultFormats/Math/SRF_Math.php
trunk/extensions/SemanticResultFormats/RELEASE-NOTES
trunk/extensions/SemanticResultFormats/SRF_ParserFunctions.php
trunk/extensions/SemanticResultFormats/SemanticResultFormats.php
Modified: trunk/extensions/SemanticResultFormats/Math/SRF_Math.php
===================================================================
--- trunk/extensions/SemanticResultFormats/Math/SRF_Math.php 2011-06-28
15:48:38 UTC (rev 90973)
+++ trunk/extensions/SemanticResultFormats/Math/SRF_Math.php 2011-06-28
15:49:47 UTC (rev 90974)
@@ -55,7 +55,7 @@
case 'average':
return array_sum( $numbers ) / count( $numbers
);
break;
- case 'mean':
+ case 'median':
sort( $numbers, SORT_NUMERIC );
$position = ( count( $numbers ) + 1 ) / 2 - 1;
return ( $numbers[ceil( $position )] +
$numbers[floor( $position )] ) / 2;
Modified: trunk/extensions/SemanticResultFormats/RELEASE-NOTES
===================================================================
--- trunk/extensions/SemanticResultFormats/RELEASE-NOTES 2011-06-28
15:48:38 UTC (rev 90973)
+++ trunk/extensions/SemanticResultFormats/RELEASE-NOTES 2011-06-28
15:49:47 UTC (rev 90974)
@@ -6,7 +6,7 @@
Changes in this version:
* Added compatibility with SMW 1.6.
-* Added product and mean formats.
+* Added product and median formats.
* Rewrote math formats for efficiency, correct recursion and handling of
multiple numerical properties.
* Cleaned up the graph format.
* Fixed division by zero issue (oh shii~) in the tagcloud format.
Modified: trunk/extensions/SemanticResultFormats/SRF_ParserFunctions.php
===================================================================
--- trunk/extensions/SemanticResultFormats/SRF_ParserFunctions.php
2011-06-28 15:48:38 UTC (rev 90973)
+++ trunk/extensions/SemanticResultFormats/SRF_ParserFunctions.php
2011-06-28 15:49:47 UTC (rev 90974)
@@ -15,9 +15,6 @@
* @ingroup SemanticResultFormats
* @author David Loomer
*/
-
-if ( !defined( 'MEDIAWIKI' ) ) die();
-
class SRFParserFunctions {
static function registerFunctions( &$parser ) {
@@ -86,38 +83,53 @@
// otherwise fall back to defaults.
if ( $wgRequest->getCheck( 'year' ) && $wgRequest->getCheck(
'month' ) ) {
$query_year = $wgRequest->getVal( 'year' );
- if ( is_numeric( $query_year ) && ( intval( $query_year
) == $query_year ) )
+
+ if ( is_numeric( $query_year ) && ( intval( $query_year
) == $query_year ) ) {
$lower_year = $query_year;
- else
+ }
+ else {
$lower_year = $default_year;
+ }
$query_month = $wgRequest->getVal( 'month' );
- if ( is_numeric( $query_month ) && ( intval(
$query_month ) == $query_month ) && $query_month >= 1 && $query_month <= 12 )
+ if ( is_numeric( $query_month ) && ( intval(
$query_month ) == $query_month ) && $query_month >= 1 && $query_month <= 12 ) {
$lower_month = $query_month;
- else
+ }
+ else {
$lower_month = $default_month;
+ }
if ( $wgRequest->getCheck( 'day' ) ) {
$query_day = $wgRequest->getVal( 'day' );
- if ( is_numeric( $query_day ) && ( intval(
$query_day ) == $query_day ) && $query_day >= 1 && $query_day <= 31 )
+
+ if ( is_numeric( $query_day ) && ( intval(
$query_day ) == $query_day ) && $query_day >= 1 && $query_day <= 31 ) {
$lower_day = $query_day;
- else
+ }
+ else {
$lower_day = '1';
+ }
+
$lower_day = $wgRequest->getVal( 'day' );
} elseif ( $calendar_type != 'month'
&& (int)$lower_year == (int)$default_year
- && (int)$lower_month == (int)$default_month )
- $lower_day = $default_day;
- else
+ && (int)$lower_month == (int)$default_month ) {
+ $lower_day = $default_day;
+ }
+ else {
$lower_day = '1';
+ }
} else {
$lower_year = $default_year;
$lower_month = $default_month;
- if ( $calendar_type == 'month' )
+
+ if ( $calendar_type == 'month' ) {
$lower_day = 1;
- else
+ }
+ else {
$lower_month = $default_day;
+ }
}
+
$lower_date = mktime( 0, 0, 0, $lower_month, $lower_day,
$lower_year );
// Date to be queried
@@ -141,13 +153,21 @@
// If necessary, adjust bounds to comply with required days of
week for each.
if ( $calendar_type == 'month' || $calendar_start_day >= 0 ) {
$lower_offset = date( "w", $lower_date ) -
$calendar_start_day;
- if ( $lower_offset < 0 ) $lower_offset += 7;
+
+ if ( $lower_offset < 0 ) {
+ $lower_offset += 7;
+ }
+
if ( $calendar_type == 'month' ) {
$upper_offset = $calendar_start_day + 6 - date(
"w", $upper_date );
- if ( $upper_offset > 6 ) $upper_offset -= 7;
+
+ if ( $upper_offset > 6 ) {
+ $upper_offset -= 7;
+ }
} else {
$upper_offset = 0 - $lower_offset;
}
+
$lower_date = $lower_date - 86400 * $lower_offset;
$upper_date = $upper_date + 86400 * $upper_offset;
}
@@ -157,4 +177,5 @@
return array( $lower_date, $upper_date, $return_date );
}
+
}
Modified: trunk/extensions/SemanticResultFormats/SemanticResultFormats.php
===================================================================
--- trunk/extensions/SemanticResultFormats/SemanticResultFormats.php
2011-06-28 15:48:38 UTC (rev 90973)
+++ trunk/extensions/SemanticResultFormats/SemanticResultFormats.php
2011-06-28 15:49:47 UTC (rev 90974)
@@ -113,7 +113,7 @@
'average' => 'SRFMath',
'min' => 'SRFMath',
'max' => 'SRFMath',
- 'mean' => 'SRFMath',
+ 'median' => 'SRFMath',
'exhibit' => 'SRFExhibit',
'googlebar' => 'SRFGoogleBar',
'googlepie' => 'SRFGooglePie',
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs