implemented global notification and reworked setFlash Function

This commit is contained in:
Luca Haid
2024-03-07 16:06:01 +01:00
parent b5ca7724d9
commit b0e2f3de33
5 changed files with 433 additions and 490 deletions

View File

@@ -1,105 +1,71 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title><?=MFAPPNAME_FULL?></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<!-- App favicon -->
<link rel="shortcut icon" href="<?=self::getResourcePath()?>assets/images/favicon.ico">
<head>
<meta charset="utf-8" />
<title><?=MFAPPNAME_FULL?></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<!-- App favicon -->
<link rel="shortcut icon" href="<?=self::getResourcePath()?>assets/images/favicon.ico">
<!-- App css -->
<link href="<?=self::getResourcePath()?>fontawesome/css/all.min.css?<?=date('U')?>" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>assets/css/bootstrap.min.css?<?=date('U')?>" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>assets/css/icons.css" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>assets/css/app.css?<?=date('U')?>" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>assets/css/leaflet.css" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>assets/css/thetool.css?<?=date('U')?>" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>assets/libs/select2/select2.min.css" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>assets/css/bootstrap-select.min.css" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>css/bootstrap-datepicker3.min.css" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>plugins/summernote/summernote-bs4.css" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>datatables/datatables.min.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<?=self::getResourcePath()?>js/jquery.min.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>assets/libs/select2/select2.min.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>js/bootstrap-datepicker.min.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>js/bootstrap-datepicker.de.min.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>assets/js/geo/geo.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>assets/js/leaflet.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>assets/js/leaflet.MakiMarkers.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>js/popper.min.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>js/bootstrap.min.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>assets/js/bootstrap-select.min.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>js/bootstrap-autocomplete.min.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>datatables/datatables.min.js"></script>
<?php if(MFAPPNAME == "devthetool"): ?>
<!-- App css -->
<link href="<?=self::getResourcePath()?>fontawesome/css/all.min.css?<?=date('U')?>" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>assets/css/bootstrap.min.css?<?=date('U')?>" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>assets/css/icons.css" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>assets/css/app.css?<?=date('U')?>" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>assets/css/leaflet.css" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>assets/css/thetool.css?<?=date('U')?>" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>assets/libs/select2/select2.min.css" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>assets/css/bootstrap-select.min.css" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>css/bootstrap-datepicker3.min.css" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>plugins/summernote/summernote-bs4.css" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>plugins/notification/notify.min.css" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>datatables/datatables.min.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<?=self::getResourcePath()?>js/jquery.min.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>assets/libs/select2/select2.min.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>js/bootstrap-datepicker.min.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>js/bootstrap-datepicker.de.min.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>assets/js/geo/geo.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>assets/js/leaflet.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>assets/js/leaflet.MakiMarkers.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>js/popper.min.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>js/bootstrap.min.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>assets/js/bootstrap-select.min.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>js/bootstrap-autocomplete.min.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>datatables/datatables.min.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>plugins/notification/notify.js"></script>
<script type="text/javascript">
window.mfNotify = <?=isset($mfNotify) ? json_encode($mfNotify) : "null"; ?>;
window.TT_CONFIG = {};
<?php
if(isset($JSGlobals) && is_array($JSGlobals) && count($JSGlobals)):
foreach($JSGlobals as $key => $value): ?>
window.TT_CONFIG.<?=$key?> = <?=is_array($value) ? json_encode($value) : "'$value'"; ?>;
<?php endforeach; endif;?>
</script>
<?php if(MFAPPNAME == "devthetool"): ?>
<style type="text/css">
body {
border-left: 8px dashed #f672a7;
}
body {
border-left: 8px dashed #f672a7;
}
</style>
<?php endif; ?>
<?php endif; ?>
</head>
</head>
<body>
<!-- Navigation Bar-->
<header id="topnav">
<?php include(realpath(dirname(__FILE__)."/")."/topbar.php"); ?>
<?php include(realpath(dirname(__FILE__)."/")."/menu.php"); ?>
</header>
<!-- End Navigation Bar-->
<body>
<!-- Navigation Bar-->
<header id="topnav">
<?php include(realpath(dirname(__FILE__)."/")."/topbar.php"); ?>
<?php include(realpath(dirname(__FILE__)."/")."/menu.php"); ?>
</header>
<!-- End Navigation Bar-->
<div class="wrapper">
<div class="container-fluid">
<?php if(isset($_flash_set) && $_flash_set == true): ?>
<?php if(isset($mfError) && !empty($mfError)): ?>
<div class="row mr-1">
<div class="col-md-1"></div>
<div class="col-md-10 alert alert-danger alert-dismissible">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
<h5><i class="icon fas fa-ban"></i> Fehler</h5>
<?=$mfError?>
</div>
</div>
<?php endif; ?>
<?php if(isset($mfWarning) && !empty($mfWarning)): ?>
<div class="row mr-1">
<div class="col-md-1"></div>
<div class="col-md-10 alert alert-warning alert-dismissible">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
<h5><i class="icon fas fa-exclamation-triangle"></i> Warnung</h5>
<?=$mfWarning?>
</div>
</div>
<?php endif; ?>
<?php if(isset($mfInfo) && !empty($mfInfo)): ?>
<div class="row mr-1">
<div class="col-md-1"></div>
<div class="col-md-10 alert alert-info alert-dismissible">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
<h5><i class="icon fas fa-info"></i> Info</h5>
<?=$mfInfo?>
</div>
</div>
<?php endif; ?>
<?php if(isset($mfSuccess) && !empty($mfSuccess)): ?>
<div class="row mr-1">
<div class="col-md-1"></div>
<div class="col-md-10 alert alert-success alert-dismissible">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
<h5><i class="icon fas fa-check"></i> Erfolgreich</h5>
<?=$mfSuccess?>
</div>
</div>
<?php endif; ?>
<?php endif; ?>
<div class="container-fluid">

View File

@@ -1,129 +1,87 @@
<?/** @var TYPE_NAME $git_merge_ts */?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title><?=MFAPPNAME_FULL?></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<!-- App favicon -->
<link rel="shortcut icon" href="<?=self::getResourcePath()?>assets/images/favicon.ico">
<head>
<meta charset="utf-8" />
<title><?=MFAPPNAME_FULL?></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<!-- App favicon -->
<link rel="shortcut icon" href="<?=self::getResourcePath()?>assets/images/favicon.ico">
<!-- App css -->
<link href="<?=self::getResourcePath()?>fontawesome/css/all.min.css?<?=$git_merge_ts?>" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>assets/css/bootstrap.min.css?<?=$git_merge_ts?>" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>assets/css/icons.css" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>assets/css/app.css?<?=$git_merge_ts?>" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>assets/css/leaflet.css" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>assets/css/thetool.css?<?=$git_merge_ts?>" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>assets/libs/select2/select2.min.css" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>assets/css/bootstrap-select.min.css" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>css/bootstrap-datepicker3.min.css" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>plugins/summernote/summernote-bs4.css" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>datatables/datatables.min.css?<?=$git_merge_ts?>" rel="stylesheet" type="text/css" />
<?php if(isset($additionalCSS) && is_array($additionalCSS) && count($additionalCSS)): ?>
<?php foreach($additionalCSS as $css): ?>
<!-- App css -->
<link href="<?=self::getResourcePath()?>fontawesome/css/all.min.css?<?=$git_merge_ts?>" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>assets/css/bootstrap.min.css?<?=$git_merge_ts?>" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>assets/css/icons.css" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>assets/css/app.css?<?=$git_merge_ts?>" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>assets/css/leaflet.css" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>assets/css/thetool.css?<?=$git_merge_ts?>" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>assets/libs/select2/select2.min.css" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>assets/css/bootstrap-select.min.css" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>css/bootstrap-datepicker3.min.css" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>plugins/summernote/summernote-bs4.css" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>plugins/notification/notify.min.css" rel="stylesheet" type="text/css" />
<link href="<?=self::getResourcePath()?>datatables/datatables.min.css?<?=$git_merge_ts?>" rel="stylesheet" type="text/css" />
<?php if(isset($additionalCSS) && is_array($additionalCSS) && count($additionalCSS)): ?>
<?php foreach($additionalCSS as $css): ?>
<link rel="stylesheet" href="<?=self::getResourcePath()?><?=$css?>?<?=$git_merge_ts?>" />
<?php endforeach; ?>
<?php endif; ?>
<script type="text/javascript" src="<?=self::getResourcePath()?>js/jquery.min.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>assets/libs/select2/select2.full.min.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>js/bootstrap-datepicker.min.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>js/bootstrap-datepicker.de.min.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>assets/js/geo/geo.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>assets/js/leaflet.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>assets/js/leaflet.MakiMarkers.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>js/popper.min.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>js/bootstrap.min.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>assets/js/bootstrap-select.min.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>js/bootstrap-autocomplete.min.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>datatables/datatables.min.js?<?=$git_merge_ts?>"></script>
<?php endforeach; ?>
<?php endif; ?>
<?php if(isset($JSGlobals) && is_array($JSGlobals) && count($JSGlobals)): ?>
<script type="text/javascript">
window.TT_CONFIG = {};
<?php foreach($JSGlobals as $key => $value): ?>
window.TT_CONFIG.<?=$key?> = <?=is_array($value) ? json_encode($value) : "'$value'"; ?>;
<?php endforeach; ?>
</script>
<?php endif; ?>
<?php if(isset($additionalJS) && is_array($additionalJS) && count($additionalJS)): ?>
<?php foreach($additionalJS as $js): ?>
<script type="text/javascript" src="<?=self::getResourcePath()?>js/jquery.min.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>assets/libs/select2/select2.full.min.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>js/bootstrap-datepicker.min.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>js/bootstrap-datepicker.de.min.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>assets/js/geo/geo.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>assets/js/leaflet.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>assets/js/leaflet.MakiMarkers.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>js/popper.min.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>js/bootstrap.min.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>assets/js/bootstrap-select.min.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>js/bootstrap-autocomplete.min.js"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>datatables/datatables.min.js?<?=$git_merge_ts?>"></script>
<script type="text/javascript" src="<?=self::getResourcePath()?>plugins/notification/notify.js"></script>
<script type="text/javascript">
window.mfNotify = <?=isset($mfNotify) ? json_encode($mfNotify) : "null"; ?>;
window.TT_CONFIG = {};
<?php
if(isset($JSGlobals) && is_array($JSGlobals) && count($JSGlobals)):
foreach($JSGlobals as $key => $value): ?>
window.TT_CONFIG.<?=$key?> = <?=is_array($value) ? json_encode($value) : "'$value'"; ?>;
<?php endforeach; endif;?>
</script>
<?php if(isset($additionalJS) && is_array($additionalJS) && count($additionalJS)): ?>
<?php foreach($additionalJS as $js): ?>
<script src="<?=self::getResourcePath()?><?=$js?>?<?=$git_merge_ts?>"></script>
<?php endforeach; ?>
<?php endif; ?>
<?php if(MFAPPNAME == "devthetool"): ?>
<?php endforeach; ?>
<?php endif; ?>
<?php if(MFAPPNAME == "devthetool"): ?>
<style type="text/css">
body {
border-left: 8px dashed #f672a7;
}
body {
border-left: 8px dashed #f672a7;
}
</style>
<?php endif; ?>
<?php endif; ?>
</head>
<body>
<script type="text/javascript">
baseurl = '<?=self::getResourcePath()?>';
</script>
<!-- Navigation Bar-->
<header id="topnav">
<?php include(realpath(dirname(__FILE__)."/")."/topbar.php"); ?>
<?php include(realpath(dirname(__FILE__)."/")."/menu.php"); ?>
</header>
<!-- End Navigation Bar-->
</head>
<body>
<script type="text/javascript">
baseurl = '<?=self::getResourcePath()?>';
</script>
<!-- Navigation Bar-->
<header id="topnav">
<?php include(realpath(dirname(__FILE__)."/")."/topbar.php"); ?>
<?php include(realpath(dirname(__FILE__)."/")."/menu.php"); ?>
</header>
<!-- End Navigation Bar-->
<div class="wrapper pl-0 pl-lg-1 pr-0 pr-lg-1 ">
<div class="container-fluid">
<?php if(isset($_flash_set) && $_flash_set == true): ?>
<?php if(isset($mfError) && !empty($mfError)): ?>
<div class="row mr-1">
<div class="col-md-1"></div>
<div class="col-md-10 alert alert-danger alert-dismissible">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
<h5><i class="icon fas fa-ban"></i> Fehler</h5>
<?=$mfError?>
</div>
</div>
<?php endif; ?>
<?php if(isset($mfWarning) && !empty($mfWarning)): ?>
<div class="row mr-1">
<div class="col-md-1"></div>
<div class="col-md-10 alert alert-warning alert-dismissible">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
<h5><i class="icon fas fa-exclamation-triangle"></i> Warnung</h5>
<?=$mfWarning?>
</div>
</div>
<?php endif; ?>
<?php if(isset($mfInfo) && !empty($mfInfo)): ?>
<div class="row mr-1">
<div class="col-md-1"></div>
<div class="col-md-10 alert alert-info alert-dismissible">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
<h5><i class="icon fas fa-info"></i> Info</h5>
<?=$mfInfo?>
</div>
</div>
<?php endif; ?>
<?php if(isset($mfSuccess) && !empty($mfSuccess)): ?>
<div class="row mr-1">
<div class="col-md-1"></div>
<div class="col-md-10 alert alert-success alert-dismissible">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
<h5><i class="icon fas fa-check"></i> Erfolgreich</h5>
<?=$mfSuccess?>
</div>
</div>
<?php endif; ?>
<?php endif; ?>
<div class="container-fluid">

View File

@@ -2,309 +2,285 @@
class mfLayout {
private $log;
private $tvars = array();
private $template = "cli";
private $package = "default";
private $inline;
private $returnValue;
protected static $instance;
private $log;
private $tvars = array();
private $template = "cli";
private $package = "default";
private $inline;
private $returnValue;
protected static $instance;
public function __construct() {
$this->log = mfLoghandler::singleton();
$this->inline = new stdClass();
public function __construct() {
$this->log = mfLoghandler::singleton();
$this->inline = new stdClass();
if (!defined("LAYOUT_DEFAULTPACKAGE")) {
$this->package = "default";
} else {
$this->package = LAYOUT_DEFAULTPACKAGE;
}
if (method_exists($this, "init")) {
$this->init();
}
}
public static function singleton($param = false) {
if (!isset(self::$instance)) {
$c = __CLASS__;
self::$instance = new $c($param);
}
return self::$instance;
}
public function set($name, $value) {
$this->tvars[$name] = $value;
}
public function get($name) {
if(array_key_exists($name, $this->tvars)) {
return $this->tvars[$name];
}
return null;
}
public function setPackage($package) {
$this->package = $package;
}
public function setTemplate($template) {
$this->template = $template;
}
private function setReturnValue($value) {
$this->returnValue = $value;
}
public function getReturnedValue() {
return $this->returnValue;
}
private function getTplPath() {
return VIEWDIR . "/" . $this->package . "/" . $this->template . ".php";
}
public function templatePathExists() {
return file_exists($this->getTplPath());
}
public function render() {
$this->defaultLayoutvariables();
$tpl_path = $this->getTplPath();
if(!is_file($tpl_path)) {
$tpl_path = VIEWDIR . "/default/" . $this->template . ".php";
}
foreach ($this->tvars as $name => $value) {
if ($name === "this")
continue;
$$name = $value;
}
ob_end_clean();
ob_start();
include($tpl_path);
return ob_get_clean();
}
public function display() {
echo $this->render();
}
public function renderPDF($filename = false, $extraPdfArgs = false) {
$html = $this->render();
if (!$filename)
$filename = date('U') . "-" . rand(1000, 9999) . ".pdf";
$wk = new mfWkhtmltopdf($html);
$pdfargs = "";
if ($extraPdfArgs) {
$pdfargs .= " $extraPdfArgs";
}
$filename = $wk->generate($filename, $pdfargs);
if (!$filename) {
throw new Exception("Error generating PDF document.");
}
$file = PDFOUTPUTPATH . "/$filename";
return $file;
}
public function displayPDF($filename = false, $extraPdfArgs = false) {
$filepath = $this->renderPDF($filename, $extraPdfArgs);
if (!$filename && strpos($filepath, "/") !== false) {
$path_parts = explode("/", $filepath);
$filename = end($path_parts);
}
header('Content-Type: application/octet-stream');
header('Content-disposition: attachment; filename=' . $filename);
header('Content-Transfer-Encoding: binary');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Type: ' . mime_content_type($filepath));
header("Content-Length: " . filesize($filepath));
readfile($filepath);
exit;
}
public function setFlash($msg, $type = "info") {
// info, warning, error
if (!$msg) {
return true;
}
if ($type == "error") {
$_SESSION[MFAPPNAME . '_mfError'] = $msg;
} elseif ($type == "warning" || $type == "warn") {
$_SESSION[MFAPPNAME . '_mfWarning'] = $msg;
} elseif ($type == "success") {
$_SESSION[MFAPPNAME . '_mfSuccess'] = $msg;
} else {
$_SESSION[MFAPPNAME . '_mfInfo'] = $msg;
}
return true;
}
private function defaultLayoutvariables() {
$this->set('mfLayoutPackage', $this->package);
if (isset($_SESSION[MFAPPNAME . '_mfError'])) {
$this->set("mfError", $_SESSION[MFAPPNAME . '_mfError']);
$this->set("_flash_set", true);
unset($_SESSION[MFAPPNAME . '_mfError']);
}
if (isset($_SESSION[MFAPPNAME . '_mfWarning'])) {
$this->set("mfWarning", $_SESSION[MFAPPNAME . '_mfWarning']);
$this->set("_flash_set", true);
unset($_SESSION[MFAPPNAME . '_mfWarning']);
}
if (isset($_SESSION[MFAPPNAME . '_mfInfo'])) {
$this->set("mfInfo", $_SESSION[MFAPPNAME . '_mfInfo']);
$this->set("_flash_set", true);
unset($_SESSION[MFAPPNAME . '_mfInfo']);
}
if (isset($_SESSION[MFAPPNAME . '_mfSuccess'])) {
$this->set("mfSuccess", $_SESSION[MFAPPNAME . '_mfSuccess']);
$this->set("_flash_set", true);
unset($_SESSION[MFAPPNAME . '_mfSuccess']);
}
}
/*
* Begin inline functions
*/
public static function strtrim($string, $chars) {
if (strlen($string) <= $chars)
return $string;
return substr($string, 0, $chars) . "...";
}
// produces url for generating links
public static function getUrl($mod, $action = null, $param = null) {
if (!$mod) {
return "";
}
if (MFUSEFANCYURLS) {
// use fancy urls
$url = MFFANCYBASEURL;
if ($mod) {
$url .= "/$mod";
if ($action) {
$url .= "/$action";
if (!defined("LAYOUT_DEFAULTPACKAGE")) {
$this->package = "default";
} else {
$this->package = LAYOUT_DEFAULTPACKAGE;
}
if (method_exists($this, "init")) {
$this->init();
}
}
$url = preg_replace('#//#', '/', $url);
} else {
// no fancy urls
$url = "?action=$mod";
if ($action) {
$url .= "_$action";
}
}
if (is_array($param) && count($param)) {
$url .= (MFUSEFANCYURLS) ? "/?" : "&amp;";
$param_qs = http_build_query($param);
$url .= "$param_qs";
}
return $url;
}
public static function getResourcePath() {
if (MFUSEFANCYURLS) {
$path = MFFANCYBASEURL;
if (substr($path, -1, 1) != "/") {
$path .= "/";
}
} else {
$path = "";
}
return $path;
}
public function cycle() {
$args = func_get_args();
if (is_array($this->inline->cycle) && count($this->inline->cycle)) {
if (array_diff($this->inline->cycle, $args)) { // if different, start new cycle
$this->inline->cycle = $args;
$this->inline->cyclecount = 0;
}
} else {
$this->inline->cycle = $args;
$this->inline->cyclecount = 0;
public static function singleton($param = false) {
if (!isset(self::$instance)) {
$c = __CLASS__;
self::$instance = new $c($param);
}
return self::$instance;
}
if ($this->inline->cyclecount >= count($this->inline->cycle)) {
$this->inline->cyclecount = 0;
public function set($name, $value) {
$this->tvars[$name] = $value;
}
return $this->inline->cycle[$this->inline->cyclecount++];
}
public function get($name) {
if(array_key_exists($name, $this->tvars)) {
return $this->tvars[$name];
}
return null;
}
public function setPackage($package) {
$this->package = $package;
}
public function setTemplate($template) {
$this->template = $template;
}
private function setReturnValue($value) {
$this->returnValue = $value;
}
public function getReturnedValue() {
return $this->returnValue;
}
private function getTplPath() {
return VIEWDIR . "/" . $this->package . "/" . $this->template . ".php";
}
public function templatePathExists() {
return file_exists($this->getTplPath());
}
public function render() {
$this->defaultLayoutvariables();
$tpl_path = $this->getTplPath();
if(!is_file($tpl_path)) {
$tpl_path = VIEWDIR . "/default/" . $this->template . ".php";
}
foreach ($this->tvars as $name => $value) {
if ($name === "this")
continue;
$$name = $value;
}
ob_end_clean();
ob_start();
include($tpl_path);
return ob_get_clean();
}
public function display() {
echo $this->render();
}
public function renderPDF($filename = false, $extraPdfArgs = false) {
$html = $this->render();
if (!$filename)
$filename = date('U') . "-" . rand(1000, 9999) . ".pdf";
$wk = new mfWkhtmltopdf($html);
$pdfargs = "";
if ($extraPdfArgs) {
$pdfargs .= " $extraPdfArgs";
}
$filename = $wk->generate($filename, $pdfargs);
if (!$filename) {
throw new Exception("Error generating PDF document.");
}
$file = PDFOUTPUTPATH . "/$filename";
return $file;
}
public function displayPDF($filename = false, $extraPdfArgs = false) {
$filepath = $this->renderPDF($filename, $extraPdfArgs);
if (!$filename && strpos($filepath, "/") !== false) {
$path_parts = explode("/", $filepath);
$filename = end($path_parts);
}
header('Content-Type: application/octet-stream');
header('Content-disposition: attachment; filename=' . $filename);
header('Content-Transfer-Encoding: binary');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Type: ' . mime_content_type($filepath));
header("Content-Length: " . filesize($filepath));
readfile($filepath);
exit;
}
public function setFlash($msg, $type = "info") {
// info, warning, error
if (!$msg) {
return true;
}
$_SESSION[MFAPPNAME . '_mfNotify'] = array("type" => $type, "message" => $msg);
return true;
}
private function defaultLayoutvariables() {
$this->set('mfLayoutPackage', $this->package);
if (isset($_SESSION[MFAPPNAME . '_mfNotify'])) {
$this->set("mfNotify", $_SESSION[MFAPPNAME . '_mfNotify']);
unset($_SESSION[MFAPPNAME . '_mfNotify']);
}
}
/*
* Begin inline functions
*/
public static function strtrim($string, $chars) {
if (strlen($string) <= $chars)
return $string;
return substr($string, 0, $chars) . "...";
}
// produces url for generating links
public static function getUrl($mod, $action = null, $param = null) {
if (!$mod) {
return "";
}
if (MFUSEFANCYURLS) {
// use fancy urls
$url = MFFANCYBASEURL;
if ($mod) {
$url .= "/$mod";
if ($action) {
$url .= "/$action";
}
}
$url = preg_replace('#//#', '/', $url);
} else {
// no fancy urls
$url = "?action=$mod";
if ($action) {
$url .= "_$action";
}
}
if (is_array($param) && count($param)) {
$url .= (MFUSEFANCYURLS) ? "/?" : "&amp;";
$param_qs = http_build_query($param);
$url .= "$param_qs";
}
return $url;
}
public static function getResourcePath() {
if (MFUSEFANCYURLS) {
$path = MFFANCYBASEURL;
if (substr($path, -1, 1) != "/") {
$path .= "/";
}
} else {
$path = "";
}
return $path;
}
public function cycle() {
$args = func_get_args();
if (is_array($this->inline->cycle) && count($this->inline->cycle)) {
if (array_diff($this->inline->cycle, $args)) { // if different, start new cycle
$this->inline->cycle = $args;
$this->inline->cyclecount = 0;
}
} else {
$this->inline->cycle = $args;
$this->inline->cyclecount = 0;
}
if ($this->inline->cyclecount >= count($this->inline->cycle)) {
$this->inline->cyclecount = 0;
}
return $this->inline->cycle[$this->inline->cyclecount++];
}
}
function mfLayoutInclude($filename, $folder = "") {
global $mfLayoutPackage;
if($folder) {
$folder = $folder."/";
}
global $mfLayoutPackage;
$inc_path = VIEWDIR . "/" . LAYOUT_DEFAULTPACKAGE . "/" . $folder . $filename;
if(!file_exists($inc_path)) {
$inc_path = VIEWDIR . "/default/" . $folder . $filename;
}
if($folder) {
$folder = $folder."/";
}
include $inc_path;
$inc_path = VIEWDIR . "/" . LAYOUT_DEFAULTPACKAGE . "/" . $folder . $filename;
if(!file_exists($inc_path)) {
$inc_path = VIEWDIR . "/default/" . $folder . $filename;
}
include $inc_path;
}
/*
* global variable $lang to avoid loading it every time it's accessed
*/
if(!isset($lang)) {
$lang = [];
$lang = [];
}
$last_translation_failed = false;
function __($_string, $prefix = null) {
global $lang;
global $last_translation_failed;
$last_translation_failed = false;
$string = str_replace(["Ä","Ö","Ü","ß","ä","ö","ü","ß"], ["ae","oe","ue","ss","ae","oe","ue", "ss"], strtolower($_string));
if(!$lang) {
//mfLoghandler::singleton()->debug("Loading language file for __() function");
include(BASEDIR . "/lang/de.php");
}
if($prefix) {
$string = "$prefix.$string";
}
if (array_key_exists($string, $lang['de'])) {
return $lang['de'][$string];
}
$last_translation_failed = true;
return $string;
global $lang;
global $last_translation_failed;
$last_translation_failed = false;
$string = str_replace(["Ä","Ö","Ü","ß","ä","ö","ü","ß"], ["ae","oe","ue","ss","ae","oe","ue", "ss"], strtolower($_string));
if(!$lang) {
//mfLoghandler::singleton()->debug("Loading language file for __() function");
include(BASEDIR . "/lang/de.php");
}
if($prefix) {
$string = "$prefix.$string";
}
if (array_key_exists($string, $lang['de'])) {
return $lang['de'][$string];
}
$last_translation_failed = true;
return $string;
}
function __last_translation_failed() {
global $last_translation_failed;
return $last_translation_failed;
}
global $last_translation_failed;
return $last_translation_failed;
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long