Subversion Repositories PHPX

Compare Revisions

Last modification

Ignore whitespace Rev 51 → Rev 29

/trunk/View.php
1,7 → 1,5
<?php
 
namespace PointedEars\PHPX;
 
require_once __DIR__ . '/Application.php';
require_once __DIR__ . '/AbstractModel.php';
 
18,7 → 16,7
* @var string
*/
protected $_template = '';
 
/**
* Content that can be inserted in the template
*
25,7 → 23,7
* @var string
*/
protected $_content = '';
 
/**
* Template variables. The variable name serves as item key, the item's value
* is the variable value.
33,7 → 31,7
* @var array
*/
protected $_template_vars = array();
 
/**
* Creates a new view
*
44,7 → 42,7
{
$this->_template = $template;
}
 
/**
* Magic setter method used for defining template variables
*
68,7 → 66,7
{
return $this->_template_vars[$name];
}
 
/**
* Returns <var>$v</var> with occurences of '&' (ampersand), '"' (double quote),
* "'" (single quote), '<' (less than), and '>' (greater than) replaced by their
93,7 → 91,7
$value->$varName = self::escape($value->$varName);
}
}
 
return $value;
}
else
107,11 → 105,11
}
return htmlspecialchars($value, ENT_QUOTES, $encoding);
}
 
return $value;
}
}
 
/**
* Assigns a value to a template variable
*
136,7 → 134,7
$this->$name = $value;
return $value;
}
 
/**
* Renders the view by including a template
*
147,7 → 145,7
*/
public function render($template = null, $content = null)
{
if (!is_null($content))
if (!is_null($content))
{
ob_start();
require_once $content;
154,7 → 152,7
$this->_content = ob_get_contents();
ob_end_clean();
}
 
if (!is_null($template))
{
require $template;
168,7 → 166,7
throw new Exception('No template defined');
}
}
 
/**
* Returns the content for insertion into the template
*/
176,7 → 174,7
{
return $this->_content;
}
 
/**
* @param string[optional] $controller
* @param string[optional] $action