merged view
This commit is contained in:
parent
f96b0d64dc
commit
91aa15d253
1 changed files with 72 additions and 73 deletions
|
@ -1,73 +1,72 @@
|
||||||
<?php
|
<?php
|
||||||
class Katharsis_View
|
class Katharsis_View
|
||||||
{
|
{
|
||||||
protected static $_instance = null;
|
protected static $_instance = null;
|
||||||
protected $_items = array();
|
protected $_items = array();
|
||||||
|
|
||||||
public static function getInstance()
|
public static function getInstance()
|
||||||
{
|
{
|
||||||
if(self::$_instance === null)
|
if(self::$_instance === null)
|
||||||
{
|
{
|
||||||
self::$_instance = new self();
|
self::$_instance = new self();
|
||||||
}
|
}
|
||||||
return self::$_instance;
|
return self::$_instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function __construct()
|
protected function __construct()
|
||||||
{
|
{
|
||||||
$base = preg_replace('/(.+)\/[^\/]+/', '\1', $_SERVER['SCRIPT_NAME']);
|
$base = preg_replace('/(.+)\/[^\/]+/', '\1', $_SERVER['SCRIPT_NAME']);
|
||||||
$this->_items['base'] = $base != $_SERVER['SCRIPT_NAME'] ? $base : '';
|
$this->_items['base'] = $base != $_SERVER['SCRIPT_NAME'] ? $base : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __get($name)
|
public function __get($name)
|
||||||
{
|
{
|
||||||
if(array_key_exists($name, $this->_items))
|
if(array_key_exists($name, $this->_items))
|
||||||
{
|
{
|
||||||
if(is_array($this->_items[$name]))
|
if(is_array($this->_items[$name]))
|
||||||
{
|
{
|
||||||
return (array) $this->_items[$name];
|
return (array) $this->_items[$name];
|
||||||
}
|
}
|
||||||
return $this->_items[$name];
|
return $this->_items[$name];
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __set($name, $value)
|
public function __set($name, $value)
|
||||||
{
|
{
|
||||||
$this->_items[$name] = $value;
|
$this->_items[$name] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function render($template)
|
public function render($template)
|
||||||
{
|
{
|
||||||
ob_start();
|
ob_start();
|
||||||
if(file_exists('application/view/' . $template . '.phtml'))
|
if(file_exists('application/view/' . $template . '.phtml'))
|
||||||
{
|
{
|
||||||
include('application/view/' . $template . '.phtml');
|
include('application/view/' . $template . '.phtml');
|
||||||
}
|
}
|
||||||
$output = ob_get_contents();
|
$output = ob_get_contents();
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function requestHook()
|
public function requestHook()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function _getParam($key)
|
public function _getParam($key)
|
||||||
{
|
{
|
||||||
$params = Katharsis_Request::getParams();
|
$params = Katharsis_Request::getParams();
|
||||||
if(array_key_exists($key,$params))
|
if(array_key_exists($key,$params))
|
||||||
{
|
{
|
||||||
return $params[$key];
|
return $params[$key];
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function formatDate($date)
|
public function formatDate($date)
|
||||||
{
|
{
|
||||||
$date = explode("-", $date);
|
$date = explode("-", $date);
|
||||||
return $date[2] . '.' . $date[1] . '.' . $date[0];
|
return $date[2] . '.' . $date[1] . '.' . $date[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue