59 lines
1.3 KiB
PHP
59 lines
1.3 KiB
PHP
<?php
|
|
|
|
class Layout extends mfLayout {
|
|
protected static $instance;
|
|
|
|
|
|
public static function singleton($param=false) {
|
|
if(!isset(self::$instance)) {
|
|
$c=__CLASS__;
|
|
self::$instance=new $c($param);
|
|
}
|
|
return self::$instance;
|
|
}
|
|
|
|
public static function dotToComma($num) {
|
|
return str_replace(".", ",", $num);
|
|
}
|
|
|
|
public static function commaToDot($num) {
|
|
return str_replace(",", ".", $num);
|
|
}
|
|
|
|
public static function dateToInt($date) {
|
|
if(!preg_match('/^(\d\d)\.(\d\d)\.(\d\d\d\d)$/',$date, $m)) {
|
|
return false;
|
|
} else {
|
|
$day = intval($m[1]);
|
|
$month = intval($m[2]);
|
|
$year = intval($m[3]);
|
|
|
|
if($day > 31 || $day < 1
|
|
|| $month > 12 || $month < 1)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
$date_ts = mktime(0,0,0,$month,$day,$year);
|
|
return $date_ts;
|
|
}
|
|
}
|
|
|
|
public static function intToDate($int) {
|
|
return date("d.m.Y", $int);
|
|
}
|
|
|
|
/*
|
|
* Gets mfBaseModel object from Cache or gets in from DB and saves it to Cache
|
|
*/
|
|
public static function getMfValuecacheObject($objectname, $id) {
|
|
$object = mfValuecache::singleton()->get("mfObjectmodel-$objectname-".$id);
|
|
if(!$object) {
|
|
$object = new $objectname($id);
|
|
mfValuecache::singleton()->set("mfObjectmodel-$objectname-".$id, $object);
|
|
}
|
|
|
|
return $object;
|
|
}
|
|
}
|