Erweiterung der Funktionalität, erste Anbindung an Editoren, Einbinden von JS-Bibliotheken

This commit is contained in:
2016-10-05 15:27:09 +00:00
parent 5a1dd25023
commit f65b4db286
26 changed files with 31969 additions and 140 deletions

View File

@@ -9,15 +9,37 @@
namespace View;
use \Helper\Registry;
class StandardView
{
const TPL_PATH = PATH_TPL;
/**
* Pfad zur Template Datei
* @var string
*/
protected $template = '';
/**
* Das Daten-Array, das in die Inhaltsbereiche des Templates gerendert wird
* @var array
*/
protected $data = array();
/**
* Ist der Inhalt bearbeitbar
* @var bool
*/
protected $isEditable = false;
/**
* StandardView constructor.
* Setzt den Pfad zum Template und die Daten
*
* @param array $data
* @param $template
*/
public function __construct(array $data, $template)
{
$this->setTemplate($template);
@@ -25,22 +47,46 @@ class StandardView
}
private function setTemplate($template)
/**
* @param $isEditable
*/
public function setEditable($isEditable)
{
if (file_exists(static::TPL_PATH . mb_strtolower($template) . '.phtml'))
{
$this->template = static::TPL_PATH . mb_strtolower($template) . '.phtml';
}
$this->isEditable = $isEditable;
}
/**
* Setzt den Pfad zum Template
*
* @param $template
* @throws \Exception
*/
private function setTemplate($template)
{
$templateFile = PATH_TPL . mb_strtolower($template) . '.phtml';
if (!file_exists($templateFile))
{
throw new \Exception('Template file "' . $templateFile . '" does not exist!');
}
$this->template = $templateFile;
}
/**
* Gibt das befüllte Template als HTML zurück
*
* @return string
*/
public function render()
{
ob_start();
include($this->template);
$pageContent = ob_get_contents();
include_once($this->template);
$templateContent = ob_get_contents();
ob_end_clean();
return $pageContent;
return $templateContent;
}
}