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
|
||||
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];
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?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];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue