コード例 #1
0
 /**
  * Boots the factory
  *
  * @param \RedKiteCms\Configuration\ConfigurationHandler $configurationHandler
  */
 public static function boot(ConfigurationHandler $configurationHandler)
 {
     $pluginDirs = $configurationHandler->pluginFolders();
     foreach ($pluginDirs as $pluginDir) {
         self::$blocks += self::parse($pluginDir);
     }
 }
コード例 #2
0
 private static function initRouter(ConfigurationHandler $configurationHandler)
 {
     if ($configurationHandler->isProduction()) {
         return new RoutingFrontend($configurationHandler);
     }
     return new RoutingBackend($configurationHandler);
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  */
 public function loadUserByUsername($username)
 {
     $json = FilesystemTools::readFile(sprintf('%s/users/users.json', $this->configurationHandler->siteDir()));
     $users = json_decode($json, true);
     if (array_key_exists($username, $users)) {
         $userData = $users[$username];
         return new User($username, $userData["password"], $userData["salt"], $userData["roles"]);
     }
     throw new UsernameNotFoundException(sprintf('Username "%s" does not exist.', $username));
 }
コード例 #4
0
 /**
  * Generated the site map
  *
  * @param  string $websiteUrl
  * @return string
  */
 protected function generateSiteMap()
 {
     $urls = array();
     $siteName = $this->configurationHandler->siteName();
     foreach ($this->pagesCollectionParser->pages() as $page) {
         foreach ($page["seo"] as $seo) {
             $urls[] = array('href' => $siteName . '/' . $seo["permalink"], 'frequency' => $seo["sitemap_frequency"], 'priority' => $seo["sitemap_priority"]);
         }
     }
     return $this->twig->render('RedKiteCms/Resources/views/Sitemap/sitemap.html.twig', array('urls' => $urls));
 }
コード例 #5
0
 /**
  * Returns the current signed in user
  * @param \Symfony\Component\Security\Core\SecurityContextInterface $security
  * @param \RedKiteCms\Configuration\ConfigurationHandler $configurationHandler
  *
  * @return \RedKiteCms\Bridge\Security\User
  */
 public function fetchUser(SecurityContextInterface $security, ConfigurationHandler $configurationHandler)
 {
     $user = null;
     if ($configurationHandler->isTheme()) {
         return $user;
     }
     $token = $security->getToken();
     if (null !== $token) {
         $user = $token->getUser();
     }
     return $user;
 }
コード例 #6
0
 /**
  * Implements the action to show the user dashboard interface
  * @param array $options
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function show(array $options)
 {
     $resolver = new OptionsResolver();
     $this->configureOptions($resolver);
     $this->options = $resolver->resolve($options);
     $userName = "******";
     $templateAssets = $this->options["template_assets"];
     $templateAssets->boot('dashboard');
     $template = 'RedKiteCms/Resources/views/Dashboard/user.html.twig';
     return $options["twig"]->render($template, array("template_assets_manager" => $templateAssets, "user" => $userName, "version" => ConfigurationHandler::getVersion()));
 }
コード例 #7
0
 /**
  * Implements the action to render the CMS dashboard
  * @param array $options
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function show(array $options)
 {
     $resolver = new OptionsResolver();
     $this->configureOptions($resolver);
     $this->options = $resolver->resolve($options);
     $this->options["template_assets"]->boot('dashboard');
     $backRoute = $this->options["request"]->getSession()->get('last_route');
     if (!in_array($backRoute, $this->options["routes"]["pages"])) {
         $backRoute = $this->options["routes"]["homepage"];
     }
     $template = 'RedKiteCms/Resources/views/Dashboard/home.html.twig';
     return $options["twig"]->render($template, array("template_assets_manager" => $this->options["template_assets"], "version" => ConfigurationHandler::getVersion(), "back_route" => $backRoute));
 }
 /**
  * Implements the action to show the page collection dashboard interface
  * @param array $options
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function show(array $options)
 {
     $resolver = new OptionsResolver();
     $this->configureOptions($resolver);
     $this->options = $resolver->resolve($options);
     $pagesParser = $this->options["pages_collection_parser"];
     $pages = $pagesParser->contributor($this->options["username"])->parse()->pages();
     $this->options["template_assets"]->boot('dashboard');
     $templates = $this->options["theme"]->templates();
     $formFactory = $this->options['form_factory'];
     $form = $formFactory->create(new PageType(array_combine($templates, $templates)));
     $pageForm = $form->createView();
     $form = $formFactory->create(new SeoType());
     $seoForm = $form->createView();
     $template = 'RedKiteCms/Resources/views/Dashboard/pages.html.twig';
     $languages = $this->options["configuration_handler"]->languages();
     return $options["twig"]->render($template, array("template_assets_manager" => $this->options["template_assets"], "pages" => rawurlencode(json_encode($pages)), "pageForm" => $pageForm, "seoForm" => $seoForm, "version" => ConfigurationHandler::getVersion(), "home_template" => $this->options["theme"]->homepageTemplate(), "languages" => $languages));
 }
コード例 #9
0
 /**
  * Implements the action to show the themes dashboard interface
  * @param array $options
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function show(array $options)
 {
     $resolver = new OptionsResolver();
     $this->configureOptions($resolver);
     $this->options = $resolver->resolve($options);
     $templateAssets = $this->options["template_assets"];
     $templateAssets->boot('dashboard');
     $themes = array();
     $themePlugins = $this->options["plugin_manager"]->getThemePlugins();
     foreach ($themePlugins as $themePlugin) {
         if ($themePlugin->getName() == $this->options["configuration_handler"]->theme()) {
             $themes["active_theme"] = $themePlugin;
             continue;
         }
         $themes["available_themes"][] = $themePlugin;
     }
     $template = 'RedKiteCms/Resources/views/Dashboard/themes.html.twig';
     return $options["twig"]->render($template, array("template_assets_manager" => $templateAssets, "themes" => $themes, "isTheme" => $this->options["configuration_handler"]->isTheme(), "version" => ConfigurationHandler::getVersion()));
 }
コード例 #10
0
 public function testConfigurationOptions()
 {
     $this->init();
     $configurationHandler = new ConfigurationHandler(vfsStream::url('RedKiteCMS'), 'redkitecms.com', 'vendor/redkitecms-framework');
     $configurationHandler->setConfigurationOptions(array('web_dir' => 'public_folder', 'uploads_dir' => '/files'));
     $configurationHandler->boot();
     $this->assertEquals('public_folder', $configurationHandler->webDirname());
     $this->assertEquals('vfs://RedKiteCMS/public_folder/files/redkitecms.com/backend', $configurationHandler->uploadAssetsDir());
     $this->assertEquals('vfs://RedKiteCMS/public_folder/files/redkitecms.com/production', $configurationHandler->uploadAssetsDirProduction());
 }