/** * @short Renders a view from a controller other than self. * @details This method renders a view from a controller other than self, * for example when embedding a view into another view. * * The <tt>params</tt> array has the same semantics of the <tt>render</tt> method, * with the following additions: * * <tt>controller</tt>: the name of the controller responsible for the view (defaults to self). * @param params Parameters defining how the rendering should be realized. */ public function render_component($params) { // Merge request and user parameters $_GET = array_merge($_GET, $params); // If a controller is not set, use current controller if (!isset($params['controller'])) { $controller_name = $this->name; } else { // Use the value stored in params as controller name $controller_name = basename($params['controller']); // Include the controller class file require_once dirname(__FILE__) . '/../controllers/' . $controller_name . '_controller.php'; // Load localization table Localization::add_strings_table($controller_name); } // Create class name $classname = joined_lower_to_camel_case($controller_name) . 'Controller'; // Instantiate controller $controller = new $classname(); // Unset controller key from params (why?) unset($params['controller']); // Set requested action if (isset($params['action'])) { $action = basename($params['action']); $controller->action = $action; } // Invoke action method $controller->{$action}(); // Request rendering with no layout $params['layout'] = FALSE; // Note that this could already have been called $controller->render($params); }