getLine() . " Message: " . $e->getMessage() . " Referer: " . getenv('HTTP_REFERER'));
}
//Utils::ArrayDisplay($db, __FILE__.' - '.__LINE__);
Registry::Set('db', $db);
Registry::Set('dbTemp', $dbTemp);
Config::Set('site', $site);
Registry::Set('smartyTemplate', self::$template);
$title = array();
Registry::Set('title', $title);
self::PageConfig();
}
public static function SetAppSafeMode() {
MFLog::Error('Switching into the SafeMod.');
self::$appSafeMode = true;
}
public static function GetAppSafeMode() {
return self::$appSafeMode;
}
/**
* Parametry konfiguracyjne strony zmieniane przez autora lub administratora
*
*/
public static function PageConfig() {
try {
// zaczytuje do rejestru dane z tabeli Setup
$config = SetupDAL::GetAllVariables();
$rConfig = array();
foreach ($config as $key => $value) {
//Utils::ArrayDisplay($config);
$rConfig[$value['variable']] = $value['value'];
}
Config::SetDbConfig($rConfig);
} catch (MysqlException $e) {
self::SetAppSafeMode();
}
/*
$captchaStatus = true;
$moderateStatus = false;
Registry::Set('captchaStatus', $captchaStatus);
Registry::Set('moderateStatus', $moderateStatus);
*/
// ustawienia local dla czasu
setlocale(LC_TIME, 'pl_PL', 'pl', 'Polish_Poland.28592');
}
/**
* Ladowanie plikow konfiguracyjnych
*
* @param PageType $site Typ strony
*/
public static function LoadConfig($site) {
include_once('config/' . $site . '/path.config.php');
include_once('config/' . $site . '/param.config.php');
include_once('config/' . $site . '/db.config.php');
if ($site == 'Admin') {
include_once('config/' . $site . '/panel.config.php');
}
//-cONDIF INI DO WYYWALENIA!!
//Config::LoadIniConfig(Config::Get('PATH_CORE') . '/config/' . $site . '/db.config.ini', true);
}
/**
* Ladowanie i konfiguracja Smarty
*
*/
public static function LoadSmarty() {
require_once('lib/Smarty3/Smarty.class.php');
require_once('lib/SmartyValidate/libs/SmartyValidate.class.php');
$smarty = new Smarty();
$smarty->setErrorReporting(E_ALL ^E_DEPRECATED);
$smarty = new TemplateMaster();
//
$smarty->template_dir = Config::Get('PATH_SMARTY_TEMPLATE');
$smarty->compile_dir = Config::Get('PATH_SMARTY_COMPILE');
$smarty->cache_dir = Config::Get('PATH_SMARTY_CACHE');
$smarty->addPluginsDir(Config::Get('PATH_SMARTY_PLUGINS'));
$smarty->config_dir = Config::Get('PATH_CONFIG');
$smarty->cache_lifetime = 60;
//Utils::ArrayDisplay($smarty);
if(Config::Get('SMARTY_INTERNAL_CACHING') == true) {
$smarty->caching = Config::Get('SMARTY_CACHING_METHOD');
} else {
$smarty->caching = 0;
}
//$smarty->error_reporting = 0;
$smarty->assign('urlStatic', Config::Get('URL_STATIC_CONTENT'));
//$smarty->assign('commentIndent', COMMENT_INDENT);
$smarty->assign('dynamicContent', null);
$smarty->assign("pageStyle", 'style.css');
$smarty->assign('urlMain', Config::Get('URL_MAIN'));
$smarty->assign('pageDescription', null);
MFLog::Warn(serialize($smarty));
// //Utils::ArrayDisplay($smarty);
//$smarty->cache
//$smarty->testInstall();
Registry::Set('smarty', $smarty);
}
/**
* Wyswietla szablon Smarty
*
* @return Wgenerowana strona
*/
public static function SmartyDisplay() {
$smarty = Registry::Get('smarty');
return $smarty->display(self::$template);
}
/**
* Laduje pliki z klasami
*
* @param $name Nazwa pozadanej klasy
*/
public static function LoadClass($name) {
//echo $name."
";
if (file_exists(Config::Get('PATH_CORE') . '/class/' . $name . '.class.php')) {
self::RequireOnce(Config::Get('PATH_CORE') . '/class/' . $name . '.class.php');
} else if (file_exists(Config::Get('PATH_MAIN_APP') .'module/' . $name . '.mod.php')) {
self::RequireOnce(Config::Get('PATH_MAIN_APP').'module/' . $name . '.mod.php');
} else if (file_exists(Config::Get('PATH_CORE') . '/model/' . $name . '.class.php')) {
self::RequireOnce(Config::Get('PATH_CORE') . '/model/' . $name . '.class.php');
} else if (file_exists(Config::Get('PATH_CORE') . '/lib/' . $name . '.class.php')) {
self::RequireOnce(Config::Get('PATH_CORE') . '/lib/' . $name . '.class.php');
} else if (file_exists(PATH_CORE . '/model/' . strtolower(str_replace('DAL', '', $name)) . '/' . $name . '.class.php')) {
include(PATH_CORE . '/model/' . strtolower(str_replace('DAL', '', $name)) . '/' . $name . '.class.php');
} else {
//echo '/lib/' . $name . '.class.php'."
";
preg_match_all('/[A-Z]/', $name, $matches);
if (isset($matches[0][1])) {
$firstChar = substr($name, 0, 1);
$fullpathArray = explode($matches[0][1], substr($name, 1), 2);
$fullpathFile = PATH_CORE . '/model/' . strtolower($firstChar) . $fullpathArray[0] . '/' . $matches[0][1] . $fullpathArray[1] . '.class.php';
if (file_exists($fullpathFile)) {
include($fullpathFile);
}
}
$path = str_replace('_', '/', $name);
// $filePath = array_shift($filePath);
//
// if(is_array($filePath)) {
// $path = implode('/', $filePath);
// } else {
// $path = $filePath;
// }
// $name = str_replace($path.'_', '', $name);
if (file_exists(Config::Get('PATH_CORE') . '/' . $path . '.class.php')) {
self::RequireOnce(Config::Get('PATH_CORE') . '/' . $path . '.class.php');
} else if (file_exists(Config::Get('PATH_CORE') . '/class/' . $path . '.class.php')) {
self::RequireOnce(Config::Get('PATH_CORE') . '/class/' . $path . '.class.php');
} else if (file_exists(Config::Get('PATH_CORE') . '/model/' . $path . '.class.php')) {
self::RequireOnce(Config::Get('PATH_CORE') . '/model/' . $path . '.class.php');
} else if (file_exists(Config::Get('PATH_CORE') . '/lib/' . $path . '.class.php')) {
self::RequireOnce(Config::Get('PATH_CORE') . '/lib/' . $path . '.class.php');
}
}
}
/**
* Zamyka aplikacje
*
*/
public static function Garbage() {
$db = Registry::Get('db');
$db->__destruct();
}
public static function RequireOnce($file) {
//print_r($file);
require_once($file);
}
public static function LoadPlugin($plugin) {
self::RequireOnce('plugins/' . $plugin . '.php');
}
}
/**
* Klasa wyboru typu aplikacji
*
*/
class PageType {
/**
* Część użytkowa
*
*/
const STRONA = 'Strona';
/**
* Część użytkowa
*
*/
const Package = 'Package';
/**
* Część użytkowa
*
*/
//const Lubricant = 'Lubricant';
/**
* Część administracyjna
*/
//const Company = 'Company';
/**
* Część administracyjna
*/
const ADMIN = 'Admin';
/**
* Część serwerowa
*/
const SERVER = 'Server';
}
/**
* Bloka dynamiczny jako funkcja do smarty
*
* @param unknown_type $param
* @param unknown_type $content
* @param unknown_type $smarty
* @return unknown
*/
function SmartyBlockDynamic($param, $content, &$smarty) {
return $content;
}
/**
* Zwraca biezacy url
*
* @return unknown
*/
function SelfUrl() {
$s = (empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on")) ? "s" : "";
$protocol = StrLeft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/") . $s;
$port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":" . $_SERVER["SERVER_PORT"]);
return $protocol . "://" . $_SERVER['SERVER_NAME'] . $port . $_SERVER['REQUEST_URI'];
}
/**
* Funkcja pomocnicza do SelfUrl()
*
* @param unknown_type $s1
* @param unknown_type $s2
* @return unknown
*/
function StrLeft($s1, $s2) {
return substr($s1, 0, strpos($s1, $s2));
}
?>