Example #1
0
 public function installDemoData()
 {
     \Jarves\Model\DomainQuery::create()->deleteAll();
     \Jarves\Model\NodeQuery::create()->deleteAll();
     \Jarves\Model\ContentQuery::create()->deleteAll();
     \Jarves\Model\AppLockQuery::create()->deleteAll();
     \Jarves\Model\AclQuery::create()->deleteAll();
     $domainName = $this->getDomain();
     $domainName = explode(':', $domainName)[0];
     $domain = new Domain();
     $domain->setDomain($domainName);
     $path = $this->getPath();
     $domain->setPath($path);
     $domain->setTitleFormat('%title% | Node title - My Website - change me under domain settings.');
     $domain->setMaster(1);
     $domain->setLang('en');
     $domain->setResourceCompression(0);
     $domain->setTheme('jarvesDemoTheme');
     $domain->setSearchIndexKey(md5(time() . '-' . rand()));
     $domain->save();
     $root = new Node();
     $root->setDomainId($domain->getId());
     $root->makeRoot();
     $root->setTitle('root');
     $root->setUrn('');
     $root->save();
     //setup live workspace
     WorkspaceQuery::create()->deleteAll();
     $workspace = new Workspace();
     $workspace->setTitle('LIVE');
     $workspace->setCreated(time());
     $workspace->save();
     $id = $workspace->getId();
     if ($id != 1) {
         WorkspaceQuery::create()->filterById($id)->update(array('Id' => 1));
     }
     $defaultLayout = 'default';
     $defaultContentTemplate = 'JarvesBundle:Default:content.html.twig';
     $Nodes = array(array(0, 'Blog', $defaultLayout, 'home', '', array('1' => array(array('text', 'Jarves cms has been installed!', $defaultContentTemplate, '<p>Jarves cms has been installed correctly.</p><p>&nbsp;</p><p><a href="http://www.jarves.io">Jarves cms Website</a></p><p>&nbsp;</p><p>&nbsp;</p><p>Go to <a href="jarves">administration</a> to manage your new website.</p><p>&nbsp;</p><p><strong>Default login:</strong></p><p><strong><br /></strong></p><p style="padding-left: 10px;">Username: admin</p><p style="padding-left: 10px;">Password: admin</p>'), array('plugin', '', $defaultContentTemplate, '{"bundle":"JarvesPublicationBundle","plugin":"listing","options":{"itemsPerPage":10,"maxPages":10,"detailPage":"","template":"default.html.twig","categoryId":[],"enableRss":false}}')), '2' => array(array('plugin', '» CATEGORIES', $defaultContentTemplate, '{"bundle":"JarvesPublicationBundle","plugin":"categoryList","options":{"listNode":"1","template":"default.html.twig","category_rsn":[]}}'))), array(array(1, 'Article', $defaultLayout, 'article', '', array(), array(), 0))), array(0, 'Links', $defaultLayout, 'links', '', array('1' => array(array('text', 'Links', $defaultContentTemplate, 'Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi.')), '2' => array(array('text', '» About', $defaultContentTemplate, 'hoho'))), array(array(1, 'Jarves cms Official Website', $defaultLayout, 'www-jarves-org', 'http://www.jarves.io/'), array(1, 'Jarves cms Documentation', $defaultLayout, 'docu-jarves-org', 'http://docu.jarves.io/'), array(1, 'Jarves cms Extensions', $defaultLayout, 'www-jarves-org-extensions', 'http://www.jarves.io/extensions'))), array(0, 'About me', $defaultLayout, 'about-me', '', array('1' => array(array('text', 'About me', $defaultContentTemplate, 'Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi.')), '2' => array(array('text', 'Hi, my Name is', $defaultContentTemplate, 'John Doe and I\'m a creative dude living in Springfield. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt...'))), array(array(0, 'Sublink 1', $defaultLayout, 'sublink-1', '', array('1' => array(array('text', 'Sublink 1', $defaultContentTemplate, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.')))), array(0, 'Sublink 2', $defaultLayout, 'sublink-2', '', array('1' => array(array('text', 'Sublink 1', $defaultContentTemplate, 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.<br/><br/><h3>Lorem ...</h3>ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.')))))), array(2, 'Footer Navigation', '', '', '', array(), array(array(0, 'Sitemap', $defaultLayout, 'sitemap', '', array('1' => array(array('plugin', 'Sitemap', $defaultContentTemplate, 'todo')))), array(0, 'Contact', $defaultLayout, 'contact', '', array('1' => array(array('plugin', 'Contact form', $defaultContentTemplate, 'todo')))), array(0, 'Impress', $defaultLayout, 'impress', '', array('1' => array(array('text', 'Impress', $defaultContentTemplate, 'Owner: <b>Name</b><br/>Street, Nr<br/>Country<br/>')))))), array(3, 'Footer text', '', '', '', array('1' => array(array('text', '', $defaultContentTemplate, '<p>&copy; my Node | <a href="http://www.jarves.io/">CMS</a> powered by Jarves cms - simply different</p>'))), array()));
     /*
      * 0: type
      * 1: Title
      * 2: layout
      * 3: url
      * 4: link target
      * 5: contents
      * 6: children
      * 7: visible
      */
     foreach ($Nodes as $Node) {
         $oNode = new Node();
         $oNode->setDomainId($domain->getId());
         $oNode->setType($Node[0]);
         $oNode->setTitle($Node[1]);
         $oNode->setLayout($Node[2]);
         $oNode->setUrn($Node[3]);
         $oNode->insertAsLastChildOf($root);
         if (isset($Node[7])) {
             $oNode->setVisible($Node[7]);
         } else {
             $oNode->setVisible(1);
         }
         $oNode->save();
         if ($Node[4]) {
             $oNode->setLink($Node[4]);
         }
         if ($Node[5]) {
             $this->installContents($oNode, $Node[5]);
         }
         if ($Node[6]) {
             $this->installNodes($oNode, $Node[6]);
         }
     }
     $startNode = NodeQuery::create()->filterByDomainId($domain->getId())->findOneByLft(2);
     $domain->setStartnodeId($startNode->getId());
     $domain->save();
     LanguageQuery::create()->deleteAll();
     $h = fopen(__DIR__ . '/Resources/package/ISO_639-1_codes.csv', 'r');
     if ($h) {
         while (($data = fgetcsv($h, 1000, ",")) !== false) {
             $lang = new Language();
             $lang->setCode($data[0]);
             $lang->setTitle($data[1]);
             $lang->setLangtitle($data[2]);
             $lang->save();
         }
     }
     LanguageQuery::create()->filterByCode('en')->update(array('Visible' => 1));
     //search footer id
     $footerNavi = NodeQuery::create()->findOneByTitle('Footer Navigation');
     $footerText = NodeQuery::create()->findOneByTitle('Footer text');
     $domainThemeProperties = ['footerNavigation' => $footerNavi->getId(), 'footerTray' => $footerText->getId()];
     $domain->setThemeOptions($domainThemeProperties);
     $domain->save();
     SessionQuery::create()->deleteAll();
     UserGroupQuery::create()->deleteAll();
     UserQuery::create()->deleteAll();
     GroupQuery::create()->deleteAll();
     AclQuery::create()->deleteAll();
     $groupGuest = new Group();
     $groupGuest->setName('Guest');
     $groupGuest->setDescription('All anonymous user');
     $groupGuest->save();
     $id = $groupGuest->getId();
     GroupQuery::create()->filterById($id)->update(array('Id' => 0));
     $groupAdmin = new Group();
     $groupAdmin->setName('Admin');
     $groupAdmin->setDescription('Super user');
     $groupAdmin->save();
     $id = $groupAdmin->getId();
     GroupQuery::create()->filterById($id)->update(array('Id' => 1));
     $groupAdmin->setId(1);
     $groupUsers = new Group();
     $groupUsers->setName('Users');
     $groupUsers->setDescription('Registered user');
     $groupUsers->save();
     $admin = new User();
     $admin->setUsername('admin');
     $admin->setFirstName('Admini');
     $admin->setLastName('strator');
     $admin->setEmail('admin@localhost');
     $admin->setActivate(1);
     $encoderFactory = $this->container->get('security.encoder_factory');
     $encoder = $encoderFactory->getEncoder($admin);
     $admin->setPassword($encoder->encodePassword('admin', null));
     $liveWorkspace = WorkspaceQuery::create()->findOneById(1);
     $admin->addWorkspace($liveWorkspace);
     $settings = new \Jarves\Properties(array('userBg' => '/admin/images/userBgs/defaultImages/color-blue.jpg', 'adminLanguage' => 'en'));
     $admin->setSettings($settings);
     $admin->save();
     $id = $admin->getId();
     UserQuery::create()->filterById($id)->update(array('Id' => 1));
     $admin->setId(1);
     $admin->addGroup($groupAdmin);
     $admin->save();
 }
Example #2
0
 public function registerPluginRoutes(Node $page)
 {
     $domain = $this->pageStack->getDomain($page->getDomainId());
     $this->stopwatch->start('Register Plugin Routes');
     //add all router to current router and fire sub-request
     $cacheKey = 'core/node/plugins-' . $page->getId();
     $plugins = $this->cacher->getDistributedCache($cacheKey);
     if (null === $plugins) {
         $plugins = ContentQuery::create()->filterByNodeId($page->getId())->filterByType('plugin')->find();
         $this->cacher->setDistributedCache($cacheKey, serialize($plugins));
     } else {
         $plugins = unserialize($plugins);
     }
     /** @var $plugins Content[] */
     foreach ($plugins as $plugin) {
         if (!$plugin->getContent()) {
             continue;
         }
         $data = json_decode($plugin->getContent(), true);
         if (!$data) {
             $this->logger->alert(sprintf('On page `%s` [%d] is a invalid plugin `%d`.', $page->getTitle(), $page->getId(), $plugin->getId()));
             continue;
         }
         $bundleName = isset($data['module']) ? $data['module'] : @$data['bundle'];
         $config = $this->jarves->getConfig($bundleName);
         if (!$config) {
             $this->logger->alert(sprintf('Bundle `%s` for plugin `%s` on page `%s` [%d] does not not exist.', $bundleName, @$data['plugin'], $page->getTitle(), $page->getId()));
             continue;
         }
         $pluginDefinition = $config->getPlugin(@$data['plugin']);
         if (!$pluginDefinition) {
             $this->logger->alert(sprintf('In bundle `%s` the plugin `%s` on page `%s` [%d] does not not exist.', $bundleName, @$data['plugin'], $page->getTitle(), $page->getId()));
             continue;
         }
         if ($pluginRoutes = $pluginDefinition->getRoutes()) {
             foreach ($pluginRoutes as $idx => $route) {
                 $controller = $pluginDefinition->getController();
                 $defaults = array('_controller' => $route->getController() ?: $controller, '_jarves_is_plugin' => true, '_content' => $plugin, '_title' => sprintf('%s: %s', $bundleName, $pluginDefinition->getLabel()), 'options' => isset($data['options']) && is_array($data['options']) ? $data['options'] : [], 'jarvesFrontend' => true, 'nodeId' => $page->getId());
                 if ($route->getDefaults()) {
                     $defaults = array_merge($defaults, $route->getArrayDefaults());
                 }
                 $url = $this->pageStack->getRouteUrl($page->getId());
                 $this->routes->add('jarves_frontend_plugin_' . ($route->getId() ?: $plugin->getId()) . '_' . $idx, new SyRoute($url . '/' . $route->getPattern(), $defaults, $route->getArrayRequirements() ?: array(), [], '', [], $route->getMethods() ?: []));
             }
         }
     }
     $this->stopwatch->stop('Register Plugin Routes');
 }