function Execute(rObjectRouter $router, WaxBlock $appblock, WaxBlock $ddmblock, array $view_args) { $view_name = $router->DetermineViewname(); $vr_ctx = new ViewRenderCtx(); /** * When extending the DDM block, the views are then looked for in the same block * as the child object (IE: Users extends DDM will look for Users/action, even though * we want it to load the DDM/action view). * * This try/catch here redirects the view request to the DDM views if it is not * found in the current block. */ $content_for_layout = ''; try { // Try finding the view in the application block $v = BlockManager::Lookup("views", $view_name); $content_for_layout = $vr_ctx->Execute(new View($v), $view_args); } catch (ResourceNotFoundException $vnfe) { try { // Try finding the view in the DDM block // IE: Admin/viewname // ACL/viewname $view_name = $router->DetermineViewname(); $content_for_layout = $vr_ctx->Execute(new View($view_name, $ddmblock), $view_args); } catch (ViewNotFoundException $vnfe) { // Try finding the view in the DDM block under the DDM object // Dynamic Models eventually end up here if there's no overrides $router->data['objectname'] = 'DDM'; $view_name = $router->DetermineViewname(); $content_for_layout = $vr_ctx->Execute(new View($view_name, $ddmblock), $view_args); } } return $content_for_layout; }
static function Render(rRenderableAttribute $self, $action, array $xtra_args) { // model getters are dynamic. // an attributenotfoundexception is thrown if one of these isn't found $type = $self->GetType(); $args = array("id" => $self->GetID(), "name" => $self->GetName(), "type" => $self->GetType(), "default" => $self->GetDefault(), "label" => $self->GetLabel(), "value" => $self->GetValue(), "options" => $self->GetOptions()); foreach ($xtra_args as $arg => $value) { if (!isset($args[$arg])) { $args[$arg] = $value; } else { trigger_error("Error-- {$arg} already set in args array"); } } $block = BlockManager::GetBlockFromContext(__FILE__); $view = new View("{$type}/{$action}", $block); $vrctx = new ViewRenderCtx(); // render the attributes views return $vrctx->Execute($view, $args); }
function Execute($layout_override = NULL, $target_override = NULL, $action_override = NULL, $view_override = NULL, $block_override = NULL) { // try the application block first $block = BlockManager::LoadBlockAt(getcwd()); $appblock = $block; if (!is_null($block_override) && $block_override instanceof WaxBlock) { // designate a different block as the holder of the necessary files $block = $block_override; } $router = new QueryString(); $route = $router->Analyze($_SERVER['QUERY_STRING']); $context_name = 'Default'; if (!is_null($target_override)) { $context_name = $target_override; } else { if (isset($route['context']) && !empty($route['context'])) { $context_name = $route['context']; unset($route['context']); } } $action = 'index'; if (!is_null($action_override)) { $action = $action_override; } else { if (isset($route['action']) && !empty($route['action'])) { $action = $route['action']; unset($route['action']); } } $context = $context_name . "Ctx"; // verify that the controllercontext is in the same block as the views if (!file_exists($block->GetBaseDir() . "/contexts/" . $context . ".php")) { throw new TargetContextNotFoundException($context); } else { if (class_exists($context)) { $ctrl = new $context(); if (!$ctrl instanceof ControllerCtx) { throw new InvalidContextException($context); } } else { throw new TargetContextNotFoundException($context); } } $data_for_view = $ctrl->Execute($action, $route); $view_ctx = new ViewRenderCtx(); $viewname = "{$context_name}/{$action}"; if (!is_null($view_override)) { $viewname = $view_override; } $content_for_layout = $view_ctx->Execute(new View($block, $viewname), $data_for_view); $layoutctx = new LayoutRenderCtx(); $layout = "layout"; if (!is_null($layout_override)) { $layout = $layout_override; } try { return $layoutctx->Execute(new View($block, $layout), $content_for_layout); } catch (ViewNotFoundException $vnfe) { return $layoutctx->Execute(new View($appblock, $layout), $content_for_layout); } }
function render_view(WaxBlock $block, $viewname, $args = array()) { $view = new View($block, $viewname); $vrctx = new ViewRenderCtx(); return $vrctx->Execute($view, $args); }