/micromvc4/Class/Core/View.php
PHP | 68 lines | 31 code | 9 blank | 28 comment | 0 complexity | 4c7b5250d5736d950604fd4dee0ec596 MD5 | raw file
Possible License(s): MIT, BSD-3-Clause, Apache-2.0, LGPL-2.1, LGPL-3.0, BSD-2-Clause
- <?php
- /**
- * View
- *
- * Provides fetching of HTML template files
- *
- * @package MicroMVC
- * @author http://github.com/tweetmvc/tweetmvc-app
- * @copyright (c) 2011 MicroMVC Framework
- * @license http://micromvc.com/license
- ********************************** 80 Columns *********************************
- */
- namespace Core;
- class View
- {
- private $__view = NULL;
- /**
- * Returns a new view object for the given view.
- *
- * @param string $file the view file to load
- * @param string $module name (blank for current theme)
- */
- public function __construct($file)
- {
- $this->__view = $file;
- }
- /**
- * Set an array of values
- *
- * @param array $array of values
- */
- public function set($array)
- {
- foreach($array as $k => $v)
- {
- $this->$k = $v;
- }
- }
- /**
- * Return the view's HTML
- *
- * @return string
- */
- public function __toString()
- {
- try {
- ob_start();
- extract((array) $this);
- require SP . "View/" . $this->__view . EXT;
- return ob_get_clean();
- }
- catch(\Exception $e)
- {
- Error::exception($e);
- return '';
- }
- }
- }
- // END