I wanted to know how I can improve it. I mainly want to look at speed and performance, but if there are any improvements please give a suggestion.
<?php
defined("SECURE") or exit('Please define SECURE keyword to continue.');
class template
{
private $templateParams;
public function __construct()
{
$templateParams = array();
}
public function loadTemplate($configClass)
{
$this->organiseParams($configClass);
$this->displayContent($configClass);
}
private function organiseParams($configClass)
{
$values = $configClass->getAll();
while(list($title, $value) = each($values))
$this->addParameter('[config ' . $title . ']', $value);
}
private function displayContent($configClass)
{
if (strlen($_GET['page']) >= 1)
{
ob_start();
if (file_exists(ROOT . $configClass->getConfig("style.folder") . '/' . $configClass->getConfig("style.name") . '/' . $_GET['page'] . '/public_html/content.php'))
include ROOT . $configClass->getConfig("style.folder") . '/' . $configClass->getConfig("style.name") . '/' . $_GET['page'] . '/public_html/content.php';
else
include ROOT . $configClass->getConfig("style.folder") . '/' . $configClass->getConfig("style.name") . '/error/public_html/content.php';
$htmlOutput = ob_get_contents();
ob_end_clean();
while (list($paramTitle, $paramValue) = each($this->templateParams)) {
$htmlOutput = str_replace($paramTitle, $paramValue, $htmlOutput);
}
echo $htmlOutput;
}
else
{
header("location: " . $configClass->getConfig("website.url") . "/index");
}
}
private function addParameter($title, $value)
{
$this->templateParams[$title] = $value;
}
}
?>