[vanillin commit] r295 - trunk/library/Framework

1 view
Skip to first unread message

codesite...@google.com

unread,
Oct 14, 2007, 4:05:24 PM10/14/07
to vanilli...@googlegroups.com
Author: helgith
Date: Sun Oct 14 13:05:07 2007
New Revision: 295

Modified:
trunk/library/Framework/Functions.php

Log:
Abiilty to override the language defnition of the date thing in TimeDiff

Modified: trunk/library/Framework/Functions.php
==============================================================================
--- trunk/library/Framework/Functions.php (original)
+++ trunk/library/Framework/Functions.php Sun Oct 14 13:05:07 2007
@@ -54,7 +54,7 @@
$Handle = @fopen($File, 'wb');
if ($Handle) {
$Lines[] = $Append;
- $Lines[] = '?>';
+ $Lines[] = '?>';
if (!@fwrite($Handle, implode('', $Lines))) $Success = 0;
@fclose($Handle);
} else {
@@ -111,7 +111,7 @@
$sReturn = urldecode($sReturn);
$sReturn = preg_replace('/[^A-Za-z0-9 ]/', '', $sReturn);
$sReturn = str_replace(' ', '-', $sReturn);
- return strtolower(str_replace('--', '-', $sReturn));
+ return strtolower(str_replace('--', '-', $sReturn));
}

function CreateArrayEntry(&$Array, $Key, $Value) {
@@ -140,7 +140,7 @@
}
}
}
-
+
// Examine Extensions directory
$FolderHandle = @opendir($Context->Configuration["EXTENSIONS_PATH"]);
if (!$FolderHandle) {
@@ -256,7 +256,7 @@
} elseif ($InValue == 'Y') {
return 1;
} elseif ($InValue == 'N') {
- return 0;
+ return 0;
} elseif ($InValue == 'TRUE') {
return 1;
} elseif ($InValue == 'FALSE') {
@@ -284,7 +284,7 @@
$aReturn = ForceSet(@$_POST[$VariableName], $DefaultValue);
$aReturn = ForceArray($aReturn, $DefaultValue);
}
- return $aReturn;
+ return $aReturn;
}

// Check both the get and post incoming data for a variable
@@ -297,13 +297,13 @@
$bReturn = ForceSet(@$_POST[$VariableName], $DefaultBool);
$bReturn = ForceBool($bReturn, $DefaultBool);
}
- return $bReturn;
+ return $bReturn;
}

function ForceIncomingCookieString($VariableName, $DefaultValue) {
$sReturn = ForceSet(@$_COOKIE[$VariableName], $DefaultValue);
$sReturn = ForceString($sReturn, $DefaultValue);
- return $sReturn;
+ return $sReturn;
}

// Check both the get and post incoming data for a variable
@@ -320,7 +320,7 @@
// If the value found was less than 0, set it to the default value
if($iReturn < 0) $iReturn == $DefaultValue;

- return $iReturn;
+ return $iReturn;
}

// Check both the get and post incoming data for a variable
@@ -340,7 +340,7 @@
return ($iReturn == 0) ? $DefaultValue : $iReturn;
}

-// Takes a variable and checks to see if it's set.
+// Takes a variable and checks to see if it's set.
// Returns the value if set, or the default value if not set.
function ForceSet($InValue, $DefaultValue) {
return isset($InValue) ? $InValue : $DefaultValue;
@@ -440,7 +440,7 @@
return addslashes($sReturn);
}

-// Takes a user defined string and formats it for page display.
+// Takes a user defined string and formats it for page display.
// You can optionally remove html from the string.
function FormatStringForDisplay($inValue, $bStripHtml = true,
$AllowEncodedQuotes = true) {
$sReturn = trim($inValue);
@@ -501,7 +501,7 @@
$sReturn = ForceString(@$_SERVER['REMOTE_ADDR'], '');
if (strlen($sReturn) > 20) $sReturn = substr($sReturn, 0, 19);
if ($FormatIpForDatabaseInput) $sReturn =
FormatStringForDatabaseInput($sReturn, 1);
- return $sReturn;
+ return $sReturn;
}

function GetRequestUri() {
@@ -520,12 +520,13 @@
return FormatStringForDisplay($FullPath);
}

-function GetTableName($Key, &$TableCollection, $Prefix) {
- if ($Key == "User") {
- return $TableCollection[$Key];
- } else {
- return $Prefix.$TableCollection[$Key];
- }
+function GetTableName($Key, &$TableCollection, $Prefix)
+{
+ if ($Key == 'User') {
+ return $TableCollection[$Key];
+ }
+
+ return $Prefix.$TableCollection[$Key];
}

function GetUrl(&$Configuration, $PageName, $Divider = '', $Key = '',
$Value = '', $PageNumber='', $Querystring='', $Suffix = '') {
@@ -574,12 +575,13 @@

// Checks for a custom version of the specified file
// Returns the path to the custom file (if it exists) or the default otherwise
-function ThemeFilePath(&$Configuration, $FileName) {
- if (file_exists($Configuration['THEME_PATH'].$FileName)) {
- return $Configuration['THEME_PATH'].$FileName;
- } else {
- return $Configuration["APPLICATION_PATH"]."themes/".$FileName;
- }
+function ThemeFilePath($Configuration, $FileName)
+{
+ if (file_exists($Configuration['THEME_PATH'].$FileName)) {
+ return $Configuration['THEME_PATH'].$FileName;
+ }
+
+ return $Configuration['APPLICATION_PATH'].'themes/'.$FileName;
}

function MysqlDateTime($Timestamp = '') {
@@ -600,9 +602,9 @@
$QueryString = str_replace(array('%26', '%3D'), array('&', '='), $QueryString);
$Path .= '?' . $QueryString;
}
-
+
$UrlContents = false;
-
+
if (empty($Host)) {
$Context->WarningCollector->Add(str_replace('\\1', $URL, $Context->GetDefinition('InvalidHostName')));
} else {
@@ -722,7 +724,7 @@
$FolderPath = $FolderPath.$FileName;
header('Pragma: public');
header('Expires: 0');
- header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
+ header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Type: application/force-download');
header('Content-Type: application/octet-stream');
header('Content-Type: application/download');
@@ -744,13 +746,13 @@
return $sReturn;
}

-// Cuts a string to the specified length.
+// Cuts a string to the specified length.
// Then moves back to the previous space so words are not sliced
half-way through.
function SliceString($InString, $Length) {
$Space = ' ';
$sReturn = '';
if (strlen($InString) > $Length) {
- $sReturn = substr(trim($InString), 0, $Length);
+ $sReturn = substr(trim($InString), 0, $Length);
$sReturn = substr($sReturn, 0, strlen($sReturn) -
strpos(strrev($sReturn), $Space));
$sReturn .= '...';
} else {
@@ -760,7 +762,7 @@
}

function Strip_Slashes($InString) {
- return MAGIC_QUOTES_ON ? stripslashes($InString) : $InString;
+ return MAGIC_QUOTES_ON ? stripslashes($InString) : $InString;
}

function SubtractDaysFromTimeStamp($TimeStamp,
$NumberOfDaysToSubtract) {
@@ -771,19 +773,23 @@
}
}

-function TimeDiff(&$Context, $Time, $TimeToCompare = '') {
+function TimeDiff(&$Context, $Time, $TimeToCompare = '', $Override
= '') {
if ($TimeToCompare == '') $TimeToCompare = time();
$Difference = $TimeToCompare-$Time;
$Days = floor($Difference/60/60/24);
-
+
if ($Days > 7) {
- return date($Context->GetDefinition('OldPostDateFormatCode'), $Time);
+ if ($Override === '') {
+ return date($Context->GetDefinition('OldPostDateFormatCode'), $Time);
+ } else {
+ return date($Override, $Time);
+ }
} elseif ($Days > 1) {
return str_replace('//1', $Days, $Context->GetDefinition('XDaysAgo'));
} elseif ($Days == 1) {
return str_replace('//1', $Days, $Context->GetDefinition('XDayAgo'));
} else {
-
+
$Difference -= $Days*60*60*24;
$Hours = floor($Difference/60/60);
if ($Hours > 1) {
@@ -791,15 +797,15 @@
} elseif ($Hours == 1) {
return str_replace('//1', $Hours, $Context->GetDefinition('XHourAgo'));
} else {
-
+
$Difference -= $Hours*60*60;
- $Minutes = floor($Difference/60);
+ $Minutes = floor($Difference/60);
if ($Minutes > 1) {
return str_replace('//1', $Minutes, $Context->GetDefinition('XMinutesAgo'));
} elseif ($Minutes == 1) {
return str_replace('//1', $Minutes, $Context->GetDefinition('XMinuteAgo'));
} else {
-
+
$Difference -= $Minutes*60;
$Seconds = $Difference;
if ($Seconds == 1) {
@@ -831,12 +837,12 @@
$Minute = $Matches[5];
$Second = $Matches[6];
return mktime($Hour, $Minute, $Second, $Month, $Day, $Year);
-
+
} elseif (preg_match('/^(\d{4})-(\d{2})-(\d{2})$/', $DateTime,
$Matches)) {
$Year = $Matches[1];
$Month = $Matches[2];
- $Day = $Matches[3];
- return mktime(0, 0, 0, $Month, $Day, $Year);
+ $Day = $Matches[3];
+ return mktime(0, 0, 0, $Month, $Day, $Year);
}
}

@@ -852,7 +858,7 @@
}
}
}
- return $aReturn;
+ return $aReturn;
}

function UnserializeAssociativeArray($InSerialArray) {
@@ -861,7 +867,7 @@
$aReturn = @unserialize($InSerialArray);
if (!is_array($aReturn)) $aReturn = array();
}
- return $aReturn;
+ return $aReturn;
}

// Instantiate a simple validator
@@ -881,5 +887,5 @@
function WriteEmail($Email, $LinkText = '') {
echo(GetEmail($Email, $LinkText));
}
-
+
?>

Reply all
Reply to author
Forward
0 new messages