public function render($order) { $twig = new TwigUtil(); $this->params['formItems'] = $this->formItems; $this->params['id'] = $this->id; ValueBag::set($this->id, $this->jsParams); return $twig->renderTemplateToString("util/form.twig", $this->params); }
function render() { $twig = new TwigUtil(); $writableFlag = !$this->app->isReadOnly(); ValueBag::set("writable", $writableFlag); ValueBag::set("rowsPerPage", $this->rowsPerPage); return $twig->renderTemplateToString("pages/basicdata.twig", array('route' => new RouteGenerator(), 'page' => $this, 'writable' => $writableFlag, 'name' => $this->name)); }
public function handle_page_function() { $pageId = $this->url->get('page'); $this->page = $this->app->getPageById($pageId); $func = $this->url->get("func"); ValueBag::set("pageId", $this->page->getId()); $this->page->init(); if (method_exists($this->page, "handle_" . $func)) { return call_user_func(array($this->page, "handle_" . $func)); } else { throw new \Exception("Unknown method"); } }
function render() { if ($this->loginQueued) { FlashBag::add('success', "Login Success"); $this->doLogin(); return array('type' => 'redirect', 'url' => $this->route->root()); } return array('type' => 'template', 'template' => 'pages/login.twig', 'data' => ['staticRoot' => $this->app->getStaticRoot(), 'title' => $this->app->getAppName(), 'welcomeMessage' => $this->welcomeMessage, 'endpoint' => $this->route->root(), 'valueBag' => json_encode(ValueBag::getValues()), 'bodyclass' => 'login-page', 'error' => $this->error, 'username' => $this->url->get('username', '')]); }
public function handle() { $action = $this->url->get("action", "default"); $whoops = new \Whoops\Run(); if ($this->url->get("ajax", false)) { $whoops->pushHandler(new \Whoops\Handler\JsonResponseHandler()); } else { $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler()); } $whoops->register(); $result = null; if (method_exists($this, "handle_" . $action)) { $result = call_user_func(array($this, "handle_" . $action)); } else { throw new Exception("Unknown action"); } $output = ""; if (is_string($result)) { $newResult = array('type' => 'transclude', 'content' => $result); $result = $newResult; } switch ($result['type']) { case "template": $output = $this->twig->renderTemplateToString($result['template'], $result['data']); break; case "json": $this->app->setJsonResponse(true); $data = $result['data']; $data['flashbag'] = FlashBag::getFlashes(); $output = json_encode($data); break; case "redirect": $this->app->_requestRedirect($result['url']); return; break; case "transclude": $pageMap = []; /** @var BasePage $pageItem */ foreach ($this->app->getPages() as $pageItem) { $pageMap[] = array('id' => $pageItem->getId(), 'name' => $pageItem->getName()); } ValueBag::set("flashbag", FlashBag::getFlashes()); $data = array('valueBag' => json_encode(ValueBag::getValues()), 'staticRoot' => $this->app->getStaticRoot(), 'pageMap' => $pageMap, 'defaultUrl' => $this->routeGen->defaultRoute(), 'title' => $this->app->getAppName(), 'userParams' => $this->app->getUserParams(), 'pageTitle' => ''); if ($this->page !== null) { $data['page'] = $this->page; $data['currentId'] = $this->page->getId(); $data['pageTitle'] = $this->page->getName(); } else { $data['currentId'] = -1; } $data['page_content'] = $result['content']; $data['dev'] = false; // change to true to load unminified js $output = $this->twig->renderTemplateToString("main_page.twig", $data); break; default: throw new Exception("Unknown result type"); } return $output; }