/** * @ApiDoc( * section="Interface i18n", * description="Prints all possible language codes" * ) * * @Rest\Get("/admin/ui/languages") * * @return string javascript */ public function getPossibleLangAction() { $languages = LanguageQuery::create()->filterByVisible(true)->orderByCode()->find()->toArray('Code', null, TableMap::TYPE_CAMELNAME); if (0 === count($languages)) { $json = '{"en":{"code":"en","title":"English","langtitle":"English"}}'; } else { $json = json_encode($languages); } $response = new Response("window.jarves = window.jarves || {}; jarves.possibleLangs = " . $json . ';'); $response->headers->set('Content-Type', 'text/javascript'); return $response; }
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> </p><p><a href="http://www.jarves.io">Jarves cms Website</a></p><p> </p><p> </p><p>Go to <a href="jarves">administration</a> to manage your new website.</p><p> </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>© 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(); }
/** * @ApiDoc( * section="Backend", * description="Returns a array with settings for the administration interface" * ) * * items: * modules * configs * layouts * contents * navigations * themes * themeProperties * user * groups * langs * * Example: settings?keys[]=modules&keys[]=layouts * * @Rest\QueryParam(name="keys", map=true, requirements=".+", description="List of config keys to filter")) * * @Rest\Get("/admin/backend/settings") * * @param ParamFetcher $paramFetcher * * @return array */ public function getSettingsAction(ParamFetcher $paramFetcher) { $keys = $paramFetcher->get('keys'); $loadKeys = $keys; if (!$loadKeys) { $loadKeys = false; } $res = array(); if ($loadKeys == false || in_array('modules', $loadKeys)) { foreach ($this->jarves->getConfigs() as $config) { $res['bundles'][] = $config->getBundleName(); } } if ($loadKeys == false || in_array('configs', $loadKeys)) { $res['configs'] = $this->jarves->getConfigs()->toArray(); } if ($loadKeys == false || in_array('themes', $loadKeys)) { foreach ($this->jarves->getConfigs() as $key => $config) { if ($config->getThemes()) { foreach ($config->getThemes() as $themeTitle => $theme) { /** @var $theme \Jarves\Configuration\Theme */ $res['themes'][$theme->getId()] = $theme->toArray(); } } } } if ($loadKeys == false || in_array('upload_max_filesize', $loadKeys)) { $v = ini_get('upload_max_filesize'); $v2 = ini_get('post_max_size'); $b = $this->toBytes($v < $v2 ? $v : $v2); $res['upload_max_filesize'] = $b; } if ($loadKeys == false || in_array('groups', $loadKeys)) { $res['groups'] = GroupQuery::create()->find()->toArray(null, null, TableMap::TYPE_CAMELNAME); } if ($loadKeys == false || in_array('user', $loadKeys)) { $user = $this->pageStack->getUser(); if ($settings = $user->getSettings()) { if ($settings instanceof Properties) { $res['user'] = $settings->toArray(); } } if (!isset($res['user'])) { $res['user'] = array(); } } if ($loadKeys == false || in_array('system', $loadKeys)) { $system = clone $this->jarves->getSystemConfig(); $system->setDatabase(null); $system->setPasswordHashKey(''); $res['system'] = $system->toArray(); } if ($loadKeys == false || in_array('domains', $loadKeys)) { $res['domains'] = $this->container->get('jarves.objects')->getList('JarvesBundle:Domain', null, array('permissionCheck' => true)); } if ($loadKeys == false || in_array('langs', $loadKeys)) { $codes = Tools::listToArray($this->jarves->getSystemConfig()->getLanguages()); $query = LanguageQuery::create()->filterByCode($codes); $tlangs = $query->find()->toArray(null, null, TableMap::TYPE_CAMELNAME); $langs = []; foreach ($tlangs as $lang) { $langs[$lang['code']] = $lang; } #$langs = dbToKeyIndex($tlangs, 'code'); $res['langs'] = $langs; } return $res; }
/** * @ApiDoc( * section="System configuration", * description="Returns labels for the settings window" * ) * * @Rest\Get("/admin/system/config/labels") * * @return array['langs' => array[], 'timeozone' => string[]] */ public function getLabelsAction() { $res['langs'] = LanguageQuery::create()->orderByTitle()->find()->toArray(null, null, TableMap::TYPE_CAMELNAME); $res['timezones'] = timezone_identifiers_list(); return $res; }