cleaned project, repaired router

This commit is contained in:
Logsol 2013-07-08 22:52:36 +02:00
parent 2156d3f5c6
commit bffe0f1660
16 changed files with 1172 additions and 1440 deletions

View file

@ -1,101 +1,73 @@
<?php
/**
* Katharsis View
* Controls anything related to the display level
*
* @author Karl Pannek <info@katharsis.in>
* @version 0.5.2
* @package Katharsis
*/
class Katharsis_View
{
/**
* @var Katharsis_View
*/
protected static $_instance = null;
/**
* @var array
*/
protected $_params = array();
/**
* Singleton. Returns the same instance every time
*
* @return Katharsis_View
*/
public static function getInstance()
{
if(self::$_instance === null)
{
self::$_instance = new self();
}
return self::$_instance;
}
/**
* Sets base application path
*
* @return void
*/
protected function __construct()
{
$base = preg_replace('/(.+)\/[^\/]+/', '\1', $_SERVER['SCRIPT_NAME']);
$this->_params['base'] = $base != $_SERVER['SCRIPT_NAME'] ? $base : '';
}
/**
* Magical get method, gets specific param
*
* @param string $name
* @return string
*/
public function __get($name)
{
if(array_key_exists($name, $this->_params))
{
return $this->_params[$name];
}
return null;
}
/**
* Magical set method, sets specific param
*
* @param string name
* @param string value
*/
public function __set($name, $value)
{
$this->_params[$name] = $value;
}
/**
* Template rendering method
*
* @param string $template
* @return string
*/
public function render($template)
{
ob_start();
if(file_exists('application/view/' . $template . '.phtml'))
{
include('application/view/' . $template . '.phtml');
}
$output = ob_get_contents();
ob_end_clean();
return $output;
}
/**
* Sets Request params into View params
*
* @return void
*/
public function requestHook()
{
$this->_params['params'] = Katharsis_Request::getParams();
}
}
<?php
class Katharsis_View
{
protected static $_instance = null;
protected $_items = array();
public static function getInstance()
{
if(self::$_instance === null)
{
self::$_instance = new self();
}
return self::$_instance;
}
protected function __construct()
{
$base = preg_replace('/(.+)\/[^\/]+/', '\1', $_SERVER['SCRIPT_NAME']);
$this->_items['base'] = $base != $_SERVER['SCRIPT_NAME'] ? $base : '';
}
public function __get($name)
{
if(array_key_exists($name, $this->_items))
{
if(is_array($this->_items[$name]))
{
return (array) $this->_items[$name];
}
return $this->_items[$name];
}
return null;
}
public function __set($name, $value)
{
$this->_items[$name] = $value;
}
public function render($template)
{
ob_start();
if(file_exists('application/view/' . $template . '.phtml'))
{
include('application/view/' . $template . '.phtml');
}
$output = ob_get_contents();
ob_end_clean();
return $output;
}
public function requestHook()
{
}
public function _getParam($key)
{
$params = Katharsis_Request::getParams();
if(array_key_exists($key,$params))
{
return $params[$key];
}
return null;
}
public function formatDate($date)
{
$date = explode("-", $date);
return $date[2] . '.' . $date[1] . '.' . $date[0];
}
}
?>