function render($options = array(), $added_assigns = array()) { if (is_string($options)) { $options = array('action' => $options); } if (isset($options['status'])) { require_once 'HTTP/Header.php'; $http = new HTTP_Header(); $http->sendStatusCode($options['status']); unset($http); } if (isset($options['nothing']) && $options['nothing']) { return ''; } if (isset($options['text'])) { $out = $options['text']; if ($options['layout']) { $this->renderLayout($options['layout'], $out); } return $out; } $return = isset($options['return']) ? (bool) $options['return'] : false; // non-default action might be passed $action = isset($options['action']) ? $options['action'] : $this->action; $filename = null; // look for specific file if (isset($options['file'])) { $filename = $options['file']; } if (!isset($filename) || !is_file($filename)) { // get the default filename $filename = $this->_getViewFileName(Inflector::underscore($action)); // var_dump($filename); } if (!$filename && !isset($options['layout'])) { // TODO: raise an error here - no file exists for the action/file specified return; } $out = ''; if ($filename) { $this->assign($this->_view_assigns); if (!$this->isCached($options)) { $this->assign('_EXTERNAL_CACHE_', defined('EXTERNAL_CACHE') && constant('EXTERNAL_CACHE') ? EXTERNAL_CACHE : false); $this->assign($added_assigns); } $out = $this->fetch($filename, $this->view_cache_name); } // check for a layout and render if one was passed if (isset($options['layout']) && (!$this->controller || (!isset($this->controller->params['bare']) || !$this->controller->params['bare']))) { $out = $this->renderLayout($options['layout'], $out, null, $return); } // return $out or print it if ($return) { return $out; } print $out; }