public function showAction(Request $request) { $this->kernel = $this->container->get('kernel'); $pageTree = $this->container->get('red_kite_cms.page_tree'); $isSecure = null !== $this->get('security.context')->getToken() ? true : false; $this->factoryRepository = $this->container->get('red_kite_cms.factory_repository'); $this->languageRepository = $this->factoryRepository->createRepository('Language'); $this->pageRepository = $this->factoryRepository->createRepository('Page'); $this->seoRepository = $this->factoryRepository->createRepository('Seo'); $bootstrapVersion = $this->container->get('red_kite_cms.active_theme')->getThemeBootstrapVersion(); $params = array('template' => 'RedKiteCmsBundle:Cms:Welcome/welcome.html.twig', 'templateStylesheets' => null, 'templateJavascripts' => null, 'available_blocks' => null, 'internal_stylesheets' => null, 'internal_javascripts' => null, 'skin_path' => $this->getSkin(), 'is_secure' => $isSecure, 'page' => 0, 'language' => 0, 'available_languages' => $this->container->getParameter('red_kite_cms.available_languages'), 'frontController' => $this->getFrontcontroller($request)); if (null !== $pageTree) { $pageId = 0; $languageId = 0; $pageName = ''; $languageName = ''; $page = $pageTree->getPage(); $language = $pageTree->getLanguage(); if (null !== $page) { $pageId = $page->getId(); $pageName = $page->getPageName(); } if (null !== $language) { $languageId = $language->getId(); $languageName = $language->getLanguageName(); } $blocksAddedMenu = $this->container->get('red_kite_cms.blocks_adder_menu'); $template = $this->findTemplate($pageTree); $params = array_merge($params, array('metatitle' => $pageTree->getMetaTitle(), 'metadescription' => $pageTree->getMetaDescription(), 'metakeywords' => $pageTree->getMetaKeywords(), 'internal_stylesheets' => $pageTree->getInternalStylesheets(), 'internal_javascripts' => $pageTree->getInternalJavascripts(), 'template' => $template, 'pages' => ChoiceValues::getPages($this->pageRepository), 'languages' => ChoiceValues::getLanguages($this->languageRepository), 'permalinks' => ChoiceValues::getPermalinks($this->seoRepository, $languageId), 'page' => $pageId, 'language' => $languageId, 'page_name' => $pageName, 'language_name' => $languageName, 'base_template' => $this->container->getParameter('red_kite_labs_theme_engine.base_template'), 'templateStylesheets' => $pageTree->getExternalStylesheets(), 'templateJavascripts' => $this->fixAssets($pageTree->getExternalJavascripts()), 'available_blocks' => $blocksAddedMenu->build($this->container->get('red_kite_cms.block_manager_factory')->getBlocks()))); } else { $configuration = $this->container->get('red_kite_cms.configuration'); $cmsLanguage = $configuration->read('language'); $message = $this->container->get('translator')->trans('cms_controller_page_not_exists_for_given_language', array('%page%' => $request->get('page'), '%language%' => $request->get('_locale')), 'RedKiteCmsBundle', $cmsLanguage); $this->container->get('session')->getFlashBag()->add('notice', $message); } $response = $this->render(sprintf('RedKiteCmsBundle:Bootstrap:%s/Template/Cms/template.html.twig', $bootstrapVersion), $params); return $this->dispatchEvents($request, $response); }
protected function buildJSonHeader(Request $request, $message, $page = null) { $pages = $pagesList = $this->getPages(); unset($pagesList['none']); $permalinks = ChoiceValues::getPermalinks($this->createRepository('Seo'), $request->get('_locale')); $values = array(); $values[] = array("key" => "message", "value" => $message); $values[] = array("key" => "pages_list", "value" => $this->renderView('RedKiteCmsBundle:Pages:pages_list.html.twig', array('pages' => $pagesList, 'active_page' => $request->get('page'), 'languages' => ChoiceValues::getLanguages($this->createRepository('Language'), false)))); $values[] = array("key" => "permalinks", "value" => $this->renderView('RedKiteCmsBundle:Partials:_permalink_select.html.twig', array('permalinks' => $permalinks))); $values[] = array("key" => "pages", "value" => $this->renderView('RedKiteCmsBundle:Partials:_dropdown_menu.html.twig', array('id' => 'al_pages_navigator', 'type' => 'al_page_item', 'value' => null !== $page ? $page->getId() : 0, 'text' => $request->get('page'), 'items' => $pages))); $response = new Response(json_encode($values)); $response->headers->set('Content-Type', 'application/json'); return $response; }