Markus, Fabian, and all:
The code for SMW_DV_Time.php contains two methods created by you, and
one created by myself, that could be defined as static methods. Reason:
They never, never, reference member properties or non-static class methods.
This patch (patch.7) changes those functions to static functions and
applies appropriate scope-resolution identifiers.
Temlakos
--- ../SemanticMediaWiki-lng/SMW_DV_Time.php 2009-08-12 10:22:31.000000000
-0400
+++ ./SMW_DV_Time.php 2009-08-12 10:41:35.000000000 -0400
@@ -174,7 +174,7 @@
//timezone handling
if(preg_match("/([+\-][0-2]?[0-9](:(30|00))?)/u",
$time, $match2)){ //get timezone definition
- $offset = $this->normalizeTimeValue($match2[0]);
+ $offset =
SMWTimeValue::normalizeTimeValue($match2[0]);
$sign = 1;
if($offset[0] == '-') $sign = -1;
$offset = substr($offset,1);
@@ -184,7 +184,7 @@
$time = str_replace($match2[0],'',$time);
}
- list($hours,$minutes,$seconds) =
explode(':',$this->normalizeTimeValue($time),3);
+ list($hours,$minutes,$seconds) =
explode(':',SMWTimeValue::normalizeTimeValue($time),3);
//am/pm handling
if($this->m_timeannotation != false){
@@ -194,7 +194,7 @@
}
}
- $this->m_time =
$this->normalizeValue($hours).":".$this->normalizeValue($minutes).":".$this->normalizeValue($seconds);
+ $this->m_time =
SMWTimeValue::normalizeValue($hours).":".SMWTimeValue::normalizeValue($minutes).":".SMWTimeValue::normalizeValue($seconds);
$regexp = "/(\040|T){0,1}".str_replace("+", "\+",
$match[0])."(\040){0,1}/u"; //delete time value and preceding and following
chars
$filteredvalue = preg_replace($regexp,'',
$filteredvalue); //value without time
}
@@ -210,7 +210,7 @@
$hours = substr($time,0,2);
$minutes = substr($time,2,2);
$seconds = (strlen($time) > 4) ? substr($time,4,2) :
'00';
- $this->m_time =
$this->normalizeValue($hours).":".$this->normalizeValue($minutes).":".$this->normalizeValue($seconds);
+ $this->m_time =
SMWTimeValue::normalizeValue($hours).":".SMWTimeValue::normalizeValue($minutes).":".SMWTimeValue::normalizeValue($seconds);
$regexp = "/(\040|T){0,1}".str_replace("+", "\+",
$match[0])."(\040){0,1}/u"; //delete time value and preceding and following
chars
$filteredvalue = preg_replace($regexp,'',
$filteredvalue); //value without time
}
@@ -310,7 +310,7 @@
return true;
}
- protected function findMonth($label) {
+ protected static function findMonth($label) {
global $smwgContLang;
$retVal = $smwgContLang->findMonth($label);
if ( $retVal !== false ) {
@@ -346,7 +346,7 @@
}
return SMW_DAY;
}
- $monthnumber = $this->findMonth($digit);
+ $monthnumber = SMWTimeValue::findMonth($digit);
if ( $monthnumber !== false ) {
if($prelimModel == 'Jl') {
$this->m_monthj = $monthnumber;
@@ -536,7 +536,7 @@
* also be set to FALSE to detect this situation.
*/
public function getTimeString($default = '00:00:00') {
- return ($this->m_time !=
false)?$this->normalizeTimeValue($this->m_time):$default;
+ return ($this->m_time !=
false)?SMWTimeValue::normalizeTimeValue($this->m_time):$default;
}
/**
@@ -555,9 +555,9 @@
public function getXMLSchemaDate($mindefault = true) {
if ($this->isValid()) {
if ($mindefault) {
- return number_format($this->m_year, 0, '.',
'').'-'.$this->normalizeValue($this->getMonth()).'-'.$this->normalizeValue($this->getDay()).'T'.$this->getTimeString();
+ return number_format($this->m_year, 0, '.',
'').'-'.SMWTimeValue::normalizeValue($this->getMonth()).'-'.SMWTimeValue::normalizeValue($this->getDay()).'T'.$this->getTimeString();
} else {
- return number_format($this->m_year, 0, '.',
'').'-'.$this->normalizeValue($this->getMonth(12)).'-'.$this->normalizeValue($this->getDay(31)).'T'.$this->getTimeString('23:59:59');
+ return number_format($this->m_year, 0, '.',
'').'-'.SMWTimeValue::normalizeValue($this->getMonth(12)).'-'.SMWTimeValue::normalizeValue($this->getDay(31)).'T'.$this->getTimeString('23:59:59');
}
} else {
return false;
@@ -615,15 +615,15 @@
}
}
- protected function normalizeValue($value){
+ protected static function normalizeValue($value){
if(strlen($value) == 1) {
$value = "0".$value;
}
return $value;
}
- protected function normalizeTimeValue($value){
- $value = $this->normalizeValue($value);
+ protected static function normalizeTimeValue($value){
+ $value = SMWTimeValue::normalizeValue($value);
$parts = explode(":",$value);
switch (count($parts)) {
case 1: return $parts[0].":00:00";
@@ -703,7 +703,7 @@
$time = $time - $hours * 3600;
$minutes = intval($time / 60);
$seconds = intval($time - $minutes * 60);
- $this->m_time =
$this->normalizeValue($hours).":".$this->normalizeValue($minutes).":".$this->normalizeValue($seconds);
+ $this->m_time =
SMWTimeValue::normalizeValue($hours).":".SMWTimeValue::normalizeValue($minutes).":".SMWTimeValue::normalizeValue($seconds);
}
/// Convert Julian Day to m_year, m_month, and m_day according to the
proper model.
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Semediawiki-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/semediawiki-devel