return $string;
}
- public static function formatDate($str, $format='Y-m-d H:i:s', $tz=null)
- {
- if (!$tz)
- $tz = IPF::get('time_zone');
- $date = new DateTime($str, new DateTimeZone('UTC'));
- $date->setTimeZone(new DateTimeZone($tz));
- return gmdate($format, $date->format('U') + $date->getOffset());
- }
-
- static function dateCompare($date1, $date2=null)
- {
- if (strlen($date1) == 10) {
- $date1 .= ' 23:59:59';
- }
- if (is_null($date2)) {
- $date2 = time();
- } else {
- if (strlen($date2) == 10) {
- $date2 .= ' 23:59:59';
- }
- $date2 = strtotime(str_replace('-', '/', $date2));
- }
- $date1 = strtotime(str_replace('-', '/', $date1));
- return $date2 - $date1;
- }
-
public static function insertDirectory($path, $directory)
{
$parts = pathinfo($path);
$dir->close();
return true;
}
-
- public static function print_r($subject, $ignore = array(), $depth = 5, $refChain = array())
- {
- $s = '';
- if ($depth > 20) return;
- if (is_object($subject)) {
- foreach ($refChain as $refVal)
- if ($refVal === $subject) {
- $s .= "*RECURSION*\n";
- return;
- }
- array_push($refChain, $subject);
- $s .= get_class($subject) . " Object ( \n";
- $subject = (array) $subject;
- foreach ($subject as $key => $val)
- if (is_array($ignore) && !in_array($key, $ignore, 1)) {
- $s .= str_repeat(" ", $depth * 4) . '[';
- if ($key{0} == "\0") {
- $keyParts = explode("\0", $key);
- $s .= $keyParts[2] . (($keyParts[1] == '*') ? ':protected' : ':private');
- } else
- $s .= $key;
- $s .= '] => ';
- IPF_Utils::print_r($val, $ignore, $depth + 1, $refChain);
- }
- $s .= str_repeat(" ", ($depth - 1) * 4) . ")\n";
- array_pop($refChain);
- } elseif (is_array($subject)) {
- $s .= "Array ( \n";
- foreach ($subject as $key => $val)
- if (is_array($ignore) && !in_array($key, $ignore, 1)) {
- $s .= str_repeat(" ", $depth * 4) . '[' . $key . '] => ';
- IPF_Utils::print_r($val, $ignore, $depth + 1, $refChain);
- }
- $s .= str_repeat(" ", ($depth - 1) * 4) . ")\n";
- } else
- $s .= $subject . "\n";
- return $s;
- }
-
- public static function timestamp()
- {
- list($f,$i) = explode(' ',microtime());
- return $i.substr((string)$f,2,6);
- }
-
- static function TrimP($html)
- {
- $strL = "<p>"; $lenL = 3;
- $strR = "</p>"; $lenR = 4;
- if (0 == strcasecmp(substr($html, 0, $lenL), $strL)
- && 0 == strcasecmp(substr($html, -$lenR), $strR)){
- return substr($html, $lenL, strlen($html) - ($lenL + $lenR));
- }
- return $html;
- }
-
- static function moneyFormat($val)
- {
- return number_format((float)$val,2);
- }
-
- static function toSlug($slug)
- {
- if ($slug)
- return strtolower(preg_replace('/[^A-Z^a-z^0-9^\/\_]+/', '-', $slug));
- return $slug;
- }
}