/**
  * @param null $blockConfig
  */
 public function getBlockConfig($blockConfig = null)
 {
     $locales = $this->db->getRepository('\\Fraym\\Locale\\Entity\\Locale')->findAll();
     $this->view->assign('blockConfig', $blockConfig, false);
     $this->view->assign('locales', $locales);
     $this->view->render('BlockConfig');
 }
 /**
  * @param $xml
  * @return mixed
  */
 public function execBlock($xml)
 {
     $languageMenu = array();
     $currentLocale = $this->locale->getLocale()->id;
     $currentMenuItem = $this->route->getCurrentMenuItem();
     foreach ($currentMenuItem->translations as $translation) {
         $url = $translation->getUrl(true);
         $languageMenu[$translation->locale->id] = array('enable' => $translation->active, 'url' => $url, 'active' => $translation->locale->id === $currentLocale, 'name' => $translation->locale->name);
     }
     foreach ($languageMenu as $locale => $language) {
         if ($language['enable'] === false) {
             $menuItem = $currentMenuItem;
             do {
                 $menuItem = $menuItem->parent;
             } while ($menuItem->parent);
             $translation = $menuItem->getTranslation($locale);
             $languageMenu[$locale]['url'] = $translation ? $translation->url : '/';
         } else {
             $localeData = $this->db->getRepository('\\Fraym\\Locale\\Entity\\Locale')->findOneById($locale);
             $localeData = explode('_', strtolower($localeData->locale));
             $this->template->addHeadData('<link rel="alternate" hreflang="' . $localeData[0] . '" href="' . $language['url'] . '" />', 'hreflang_' . $localeData[0]);
         }
     }
     $this->languageMenuController->renderHtml($languageMenu);
 }
Example #3
0
 /**
  * @param $locale
  */
 public function setLocale($locale)
 {
     if (is_object($locale) === false) {
         $locale = $this->db->getRepository('\\Fraym\\Locale\\Entity\\Locale')->findOneById($locale);
     }
     $this->locale = $locale;
 }
Example #4
0
 /**
  * @param $xml
  * @return mixed
  */
 public function execBlock($xml)
 {
     $languageMenu = array();
     $currentLocale = $this->locale->getLocale()->id;
     $defaultLocale = $this->locale->getDefaultLocale();
     $currentMenuItem = $this->route->getCurrentMenuItem();
     $locales = $this->db->getRepository('\\Fraym\\Locale\\Entity\\Locale')->findAll();
     foreach ($currentMenuItem->translations as $translation) {
         $url = $translation->url === '' ? '/' : $translation->url;
         $languageMenu[$translation->locale->id] = array('url' => $url, 'active' => $translation->locale->id === $currentLocale, 'name' => $translation->locale->name);
     }
     foreach ($locales as $locale) {
         if (!isset($languageMenu[$locale->id])) {
             $menuItem = $currentMenuItem;
             do {
                 $m = $menuItem->parent;
                 if ($m) {
                     $menuItem = $m;
                 }
             } while ($m);
             foreach ($menuItem->translations as $mTranslation) {
                 if ($mTranslation->locale->id === $locale->id) {
                     $url = $mTranslation->url;
                     break;
                 } elseif ($mTranslation->locale->id === $defaultLocale->id) {
                     $url = $mTranslation->url;
                 }
             }
             $languageMenu[$locale->id] = array('url' => $url === '' ? '/' : $url, 'active' => $locale->id === $currentLocale, 'name' => $locale->name);
         }
     }
     $this->languageMenuController->renderHtml($languageMenu);
 }
 /**
  * @return bool|mixed
  */
 public function getContent()
 {
     if ($this->user->isAdmin() === false) {
         return false;
     }
     $currentEntity = false;
     $errors = false;
     $data = array();
     $formFields = array();
     $entities = array();
     $modelClass = false;
     $model = false;
     $modelName = $this->request->gp('model', false);
     $groupedModels = $this->db->getRepository('\\Fraym\\EntityManager\\Entity\\Group')->findAll();
     if ($modelName) {
         $model = $this->entityManager->getEntityByStringOrId($modelName);
         if ($model) {
             $modelClass = $model->className;
         }
     }
     if ($this->request->isXmlHttpRequest()) {
         return $this->createEntityFromSingleField($modelClass);
     }
     if ($modelClass && $this->request->isPost()) {
         $data = $this->request->getGPAsArray();
         $validation = $this->validation->setData($data)->getFormFieldValidation($modelClass);
         if ($id = $this->request->post('id')) {
             $currentEntity = $this->db->getRepository($modelClass)->findOneById($id);
             if (isset($data['cmd']) && $data['cmd'] == 'update' && $currentEntity && ($errors = $validation->check()) === true) {
                 $currentEntity->updateEntity($data);
             } elseif (isset($data['cmd']) && $data['cmd'] == 'remove' && $currentEntity) {
                 $this->db->remove($currentEntity);
                 $this->db->flush();
                 $data = array();
                 $currentEntity = false;
             } elseif (isset($data['cmd']) && $data['cmd'] == 'update') {
                 $currentEntity->updateEntity($data, false);
             }
         } else {
             if (isset($data['cmd']) && $data['cmd'] == 'new' && ($errors = $validation->check()) === true) {
                 $currentEntity = new $modelClass();
                 $currentEntity->updateEntity($data);
             }
         }
     }
     if ($modelClass && $model) {
         $entities = $this->db->getRepository($modelClass)->findAll();
         $formFields = $this->formField->setClassName($modelClass)->getFields();
     }
     $this->view->assign('locales', $this->locale->getLocales());
     $this->view->assign('data', $data);
     $this->view->assign('errors', $errors);
     $this->view->assign('currentEntity', $currentEntity);
     $this->view->assign('entities', $entities);
     $this->view->assign('groupedModels', $groupedModels);
     $this->view->assign('model', $model);
     $this->view->assign('formFields', $formFields);
     return $this->siteManagerController->getIframeContent($this->template->fetch('EntityView'));
 }
Example #6
0
 /**
  * @param null $blockId
  */
 public function getBlockConfig($blockId = null)
 {
     $configXml = null;
     if ($blockId) {
         $block = $this->db->getRepository('\\Fraym\\Block\\Entity\\Block')->findOneById($blockId);
         $configXml = $this->blockParser->getXMLObjectFromString($this->blockParser->wrapBlockConfig($block));
     }
     $this->imageController->getBlockConfig($configXml);
 }
Example #7
0
 /**
  * @param $modelClassNameOrId
  * @return mixed
  */
 public function getEntityByStringOrId($modelClassNameOrId)
 {
     if (!is_numeric($modelClassNameOrId)) {
         $entity = $this->db->getRepository('\\Fraym\\EntityManager\\Entity\\Entity')->findOneByClassName($modelClassNameOrId);
     } else {
         $entity = $this->db->getRepository('\\Fraym\\EntityManager\\Entity\\Entity')->findOneById($modelClassNameOrId);
     }
     return $entity;
 }
Example #8
0
 /**
  * @param null $blockConfig
  */
 public function getBlockConfig($blockConfig = null)
 {
     $newsListItems = $this->db->getRepository('\\Fraym\\Extension\\News\\Entity\\News')->findAll();
     $selectedNewsItems = isset($blockConfig->listItems) ? explode(',', $blockConfig->listItems) : [];
     $this->view->assign('selectedNewsItems', $selectedNewsItems);
     $this->view->assign('blockConfig', $blockConfig);
     $this->view->assign('newsListItems', $newsListItems);
     $this->view->render('NewsConfig');
 }
Example #9
0
 /**
  * @return array
  */
 public function getRteMenuItemArray()
 {
     $menuItems = [];
     $locales = $this->db->getRepository('\\Fraym\\Locale\\Entity\\Locale')->findAll();
     foreach ($locales as $locale) {
         foreach ($locale->menuItemTranslations as $menuItemTranslation) {
             $menuItems[] = [$menuItemTranslation->title . " ({$locale->name})", $menuItemTranslation->id];
         }
     }
     return json_encode($menuItems);
 }
Example #10
0
 /**
  * @param $key
  * @param $val
  * @return $this
  */
 public function set($key, $val)
 {
     $obj = null;
     if ($this->db->getEntityManager()) {
         $obj = $this->db->getRepository('\\Fraym\\Registry\\Entity\\Config')->findOneByName(strtoupper($key));
         if ($obj === null) {
             $obj = new \Fraym\Registry\Entity\Config();
             $obj->name = strtoupper($key);
             $this->db->persist($obj);
         }
         $obj->value = $val;
         $this->db->flush();
     }
     return $this;
 }
Example #11
0
 /**
  * @param $site
  * @return $this
  */
 protected function addMenuItems($site)
 {
     $pageRoot = $this->db->getRepository('\\Fraym\\Menu\\Entity\\MenuItem')->findOneById(1);
     /**
      * 404 Page
      */
     $newPage = new \Fraym\Menu\Entity\MenuItem();
     $newPage->site = $site;
     $newPage->caching = true;
     $newPage->https = false;
     $newPage->checkPermission = false;
     $newPage->is404 = true;
     $newPage->parent = $pageRoot;
     $newPageTranslation = new \Fraym\Menu\Entity\MenuItemTranslation();
     $newPageTranslation->menuItem = $newPage;
     $newPageTranslation->visible = false;
     $newPageTranslation->active = true;
     $newPageTranslation->title = $this->translation->autoTranslation('404 Page not found', 'en', $this->locale->getLocale()->locale);
     $newPageTranslation->subtitle = '';
     $newPageTranslation->url = '/' . $this->translation->autoTranslation('error', 'en', $this->locale->getLocale()->locale) . '-404';
     $newPageTranslation->description = $this->translation->autoTranslation('404 Page not found', 'en', $this->locale->getLocale()->locale);
     $newPageTranslation->externalUrl = false;
     $this->db->persist($newPageTranslation);
     $this->db->flush();
     $this->db->clear();
     return $this;
 }
Example #12
0
File: Route.php Project: fraym/core
 /**
  * @param null $menuItemTranslation
  */
 public function renderSite($menuItemTranslation = null)
 {
     $tpl = $this->template;
     if (is_object($menuItemTranslation)) {
         $this->loadRoutes();
         $menuItemTranslation = $this->db->getRepository('\\Fraym\\Menu\\Entity\\MenuItemTranslation')->findOneById($menuItemTranslation->id);
         // must set before check route, because the locale must be set
         $this->setupPage($menuItemTranslation);
         if (!$this->getCurrentDomain()) {
             $this->setCurrentDomain($this->getRequestDomain());
         }
         $virtualRouteContent = $this->getVirtualRouteContent();
         $this->sitefullRoute = $this->currentMenuItem->getUrl(true);
         if ($virtualRouteContent !== false) {
             // virtual route content
             $this->response->send($virtualRouteContent, true);
         }
         if ($this->currentMenuItem->checkPermission === true && $this->currentMenuItem->parent !== null && $this->user->isLoggedIn() === false) {
             return $this->menuItemNotFound();
         }
         if ($this->getFoundUri(false) === trim($this->getRequestRoute(false, false), '/') || $this->getVirtualRouteContent(true)) {
             $this->siteManager->addAdminPanel();
             $tpl->renderMainTemplate();
         } else {
             return $this->menuItemNotFound();
         }
         if ($this->template->isCachingDisabled() === false) {
             // cache page if cache enable
             $this->cache->setCacheContent();
         }
     } else {
         $this->menuItemNotFound();
     }
 }
 /**
  * @param null $blockConfig
  */
 public function getBlockConfig($blockConfig = null)
 {
     $locales = $this->db->getRepository('\\Fraym\\Locale\\Entity\\Locale')->findAll();
     $htmlData = array();
     if ($blockConfig !== null) {
         $result = $blockConfig->xpath('html');
         while (list(, $node) = each($result)) {
             $attr = $node->attributes();
             $locale = (string) $attr->locale;
             $htmlData[$locale] = (string) (string) $node;
         }
     }
     $this->view->assign('blockConfig', $htmlData);
     $this->view->assign('locales', $locales);
     $this->view->render('BlockConfig');
 }
Example #14
0
 /**
  * @return bool
  */
 protected function checkLogoutRedirectConfig()
 {
     if ($this->user->isLoggedIn() === false && isset($this->xml->onLogoutSuccessful) && isset($this->xml->onLogoutSuccessful->redirectTo)) {
         if (isset($this->xml->onLogoutSuccessful->redirectTo->attributes()->type)) {
             $type = $this->xml->onLogoutSuccessful->redirectTo->attributes()->type;
             $redirectToData = (string) $this->xml->onLogoutSuccessful->redirectTo;
             switch ($type) {
                 case 'id':
                     $redirectMenuItem = $this->db->getRepository('\\Fraym\\Menu\\Entity\\MenuItem')->findOneById($redirectToData);
                     if ($redirectMenuItem) {
                         $this->route->redirectToUrl($redirectMenuItem->getUrl(true));
                     }
                     break;
                 case 'url':
                     $this->route->redirectToUrl((string) $this->xml->onLogoutSuccessful->redirectTo);
                     break;
             }
             return true;
         }
     } elseif ($this->user->isLoggedIn() === false) {
         $this->route->redirectToUrl($this->route->getSiteBaseURI());
         return true;
     }
     return false;
 }
Example #15
0
 /**
  * Paste copied block
  */
 private function pasteBlock()
 {
     $blockId = $this->request->gp('blockId');
     $op = $this->request->gp('op', 'copy') == 'copy' ? 'copy' : 'cut';
     $byRef = $this->request->gp('byRef', false) === 'true' ? true : false;
     $menuId = $this->request->gp('menuId', false);
     $contentId = $this->request->gp('contentId', false);
     if ($contentId && $blockId && ($block = $this->db->getRepository('\\Fraym\\Block\\Entity\\Block')->findOneById($blockId))) {
         if ($op === 'copy') {
             $copiedBlock = clone $block;
             $copiedBlock->id = null;
             $copiedBlock->contentId = $contentId;
             $copiedBlock->menuItem = $this->db->getRepository('\\Fraym\\Menu\\Entity\\MenuItem')->findOneById($menuId);
             if ($byRef === true) {
                 $copiedBlock->config = null;
                 if ($block->byRef) {
                     $block = $block->byRef;
                     $copiedBlock->byRef = $block;
                 }
                 $copiedBlock->byRef = $block;
             }
             $this->db->persist($copiedBlock);
             $block = $copiedBlock;
         } else {
             $block->menuItem = $this->db->getRepository('\\Fraym\\Menu\\Entity\\MenuItem')->findOneById($menuId);
             $block->contentId = $contentId;
             $this->db->persist($block);
         }
         $this->db->flush();
         $this->response->sendAsJson(array('success' => true, 'data' => $this->prepareBlockOutput($block)));
     }
     $this->response->sendAsJson(array('success' => false, 'message' => $this->translation->getTranslation('Paste error, please copy again')));
 }
Example #16
0
 /**
  * @return mixed
  */
 public function getAdminPanel()
 {
     $extensions = $this->db->getRepository('\\Fraym\\SiteManager\\Entity\\Extension')->findBy(array('active' => 1), array('sorter' => 'asc'));
     $extensionSorted = array();
     foreach ($extensions as $extension) {
         if (!isset($extensionSorted[$extension->id])) {
             $extensionSorted[$extension->id] = array();
         }
         $extensionSorted[$extension->id] = array('name' => $this->translation->getTranslation($extension->name, 'SITE_EXT_' . strtoupper(str_ireplace(' ', '_', $extension->name))), 'iconCssClass' => $extension->iconCssClass);
     }
     uasort($extensionSorted, function ($a, $b) {
         return strcasecmp($a['name'], $b['name']);
     });
     $this->view->assign('extensions', $extensionSorted);
     $this->view->assign('inEditMode', $this->block->inEditMode());
     return $this->getIframeContent($this->view->fetch('AdminPanelContent'), array('cssClass' => 'admin-panel'));
 }
Example #17
0
 /**
  * @param $xml
  */
 public function render($xml)
 {
     foreach ($xml as $field => $val) {
         $val = (string) $val;
         if ($field === 'image_link') {
             if (is_numeric($val)) {
                 $menuItem = $this->db->getRepository('\\Fraym\\Menu\\Entity\\MenuItem')->findOneById($val);
                 if ($menuItem) {
                     $val = $menuItem->getUrl(true);
                 } else {
                     $val = null;
                 }
             }
         }
         $this->view->assign($field, $val);
     }
     $this->view->setTemplate('Block');
 }
Example #18
0
 /**
  * @param bool $routeInit
  * @param null $menuItemTranslation
  */
 public function renderSite($routeInit = true, $menuItemTranslation = null)
 {
     $tpl = $this->template;
     if (is_object($menuItemTranslation)) {
         $this->loadVirtualRoutes();
         $menuItemTranslation = $this->db->getRepository('\\Fraym\\Menu\\Entity\\MenuItemTranslation')->findOneById($menuItemTranslation->id);
         if (!$this->getCurrentDomain()) {
             $this->setCurrentDomain($this->getRequestDomain());
         }
         // must set before check route, because the locale must be set
         $this->setupPage($menuItemTranslation);
         $virtualRouteContent = $this->checkVirtualRoute();
         if ($virtualRouteContent === false && $this->request->isXmlHttpRequest() === false && $this->isHTTPS() === false && $this->currentMenuItem->https === true) {
             $this->redirectToURL('https://' . $this->getRequestRoute());
         }
         $this->sitefullRoute = rtrim($this->buildFullUrl($this->currentMenuItem), '/');
         if ($routeInit == true) {
             if ($virtualRouteContent !== false) {
                 // virtual route content
                 $this->response->send($virtualRouteContent, true);
             }
             if ($this->currentMenuItem->checkPermission === true && $this->currentMenuItem->parent !== null && $this->user->isLoggedIn() === false) {
                 return $this->menuItemNotFound();
             }
             // read the template content
             $mainTemplateString = $menuItemTranslation->menuItem->template ? $menuItemTranslation->menuItem->template->html : $this->getDefaultMenuItemTemplate();
             if ($this->getFoundURI(false) != trim($this->getRequestRoute(false, false), '/')) {
                 $this->blockParser->setCheckRouteError(true);
                 $tpl->setTemplate('string:' . $mainTemplateString);
                 $content = $tpl->prepareTemplate();
                 $routeExistModules = $this->blockParser->moduleRouteExist($content);
                 if ($routeExistModules === false) {
                     return $this->menuItemNotFound();
                 } else {
                     if ($this->request->isXmlHttpRequest() === true) {
                         // only exec modules where we find the route
                         $this->core->response->send($this->blockParser->parse($routeExistModules));
                     } else {
                         $this->siteManager->addAdminPanel();
                         echo $this->blockParser->parse($content);
                     }
                 }
             } else {
                 $this->siteManager->addAdminPanel();
                 $tpl->renderString($mainTemplateString);
             }
             // cache page if cache enable
             $this->cache->setCacheContent();
         } else {
             $tpl->renderString($menuItemTranslation->menuItem->template->html);
         }
     } else {
         $this->menuItemNotFound();
     }
 }
Example #19
0
 /**
  * Get a entity with parameters
  *
  * @param $className
  * @param $entryData
  * @return mixed
  */
 protected function getEntity($className, $entryData)
 {
     foreach ($entryData as $k => &$data) {
         if (is_array($data)) {
             $subEntryData = reset($data);
             $subEntryClassName = key($data);
             $data = $this->db->getRepository($subEntryClassName)->findOneBy($subEntryData);
         }
     }
     return $this->db->getRepository($className)->findOneBy($entryData);
 }
Example #20
0
 /**
  * @param $blockId
  * @param bool $undo
  */
 public function deployBlock($blockId, $undo = false)
 {
     $block = $this->db->getRepository('\\Fraym\\Block\\Entity\\Block')->findOneById($blockId);
     if ($block) {
         if ($undo) {
             $this->undoBlock($block);
         } else {
             $this->deploy($block);
         }
     }
 }
Example #21
0
 /**
  * @param null $blockId
  */
 public function getBlockConfig($blockId = null)
 {
     $configXml = null;
     $config = [];
     if ($blockId) {
         $block = $this->db->getRepository('\\Fraym\\Block\\Entity\\Block')->findOneById($blockId);
         $configXml = $this->blockParser->getXmlObjectFromString($this->blockParser->wrapBlockConfig($block));
         $config = json_decode($configXml->mailformOptions, true);
     }
     $this->mailformController->getBlockConfig($config);
 }
Example #22
0
 private function createBlock($contentId, $menuItemId, $extension, $config)
 {
     $block = new \Fraym\Block\Entity\Block();
     $block->extension = $extension;
     $block->contentId = $contentId;
     $block->menuItem = $this->db->getRepository('\\Fraym\\Menu\\Entity\\MenuItem')->findOneById($menuItemId);
     $block->site = $this->site;
     $block->config = $config;
     $this->db->persist($block);
     $this->db->flush();
 }
Example #23
0
 /**
  * @param $blockHtml
  * @return mixed
  */
 public function replaceLinkTags($blockHtml)
 {
     $callback = function ($matches) {
         $id = trim(trim($matches[1], '"'), "'");
         if (is_numeric($id)) {
             $menuItemTranslation = $this->db->getRepository('\\Fraym\\Menu\\Entity\\MenuItemTranslation')->findOneById($id);
             if ($menuItemTranslation) {
                 return ' href="' . $this->route->buildFullUrl($menuItemTranslation->menuItem, true) . '"';
             }
         }
         return $matches[0];
     };
     return preg_replace_callback('#\\s*(?i)href\\s*=\\s*(\\"([^"]*\\")|\'[^\']*\'|([^\'">\\s]+))#si', $callback, $blockHtml);
 }
Example #24
0
 /**
  * @param null $blockId
  */
 public function getBlockConfig($blockId = null)
 {
     $configXml = null;
     if ($blockId) {
         $block = $this->db->getRepository('\\Fraym\\Block\\Entity\\Block')->findOneById($blockId);
         if ($block->changeSets->count()) {
             $block = $block->changeSets->last();
         }
         $configXml = $this->blockParser->getXmlObjectFromString($this->blockParser->wrapBlockConfig($block));
     }
     $files = $this->getTemplateFiles();
     $selectOptions = $this->buildSelectOptions($files);
     $this->dynamicTemplateController->getBlockConfig($selectOptions, $configXml);
 }
Example #25
0
 private function setupMenuItemTemplate()
 {
     /**
      * set default layout template
      */
     $tpl = $this->db->getRepository('\\Fraym\\Template\\Entity\\Template')->findOneById(1);
     if (!$tpl) {
         throw new \Exception('No default theme found! Please add a theme extension.');
     }
     $menuItems = $this->db->getRepository('\\Fraym\\Menu\\Entity\\MenuItem')->findAll();
     foreach ($menuItems as $menuItem) {
         $menuItem->template = $tpl;
     }
     return $this;
 }
Example #26
0
 /**
  * Checks if the current user can do a block action
  *
  * @param $permission
  * @param $extension_id
  * @return bool
  */
 public function permissionAllowed($permission, $extension_id)
 {
     //TODO: Implement this function
     $user = $this->user;
     if (!$user) {
         return false;
     }
     $extension = $this->db->getRepository('\\Fraym\\Block\\Entity\\BlockExtension')->findOneById($extension_id);
     if ($extension && count($extension->permissions)) {
         $identifiers = $user->getIdentifiersFromGroups();
         $identifiers[] = $user->identifier;
         $result = $this->db->createQueryBuilder()->select("perm")->from('\\Fraym\\Block\\Entity\\Permission', 'perm')->where("perm.extension = :id AND perm.identifier IN ('" . implode("','", $identifiers) . "') AND perm.permission LIKE :permission")->setParameter('id', $extension_id)->setParameter('permission', "%{$permission}%")->getQuery()->getOneOrNullResult();
         return $result ? true : false;
     }
     return true;
 }
Example #27
0
 /**
  * @param \SimpleXMLElement $obj
  * @param null $parent
  * @return \Doctrine\Common\Collections\ArrayCollection
  */
 protected function getItems(\SimpleXMLElement $obj, $parent = null)
 {
     $returnChildren = new \Doctrine\Common\Collections\ArrayCollection();
     foreach ($obj->children() as $objData) {
         $id = $this->blockParser->getXmlAttr($objData, 'id');
         $menuItemTranslation = $this->db->createQueryBuilder()->select("menu, translation")->from('\\Fraym\\Menu\\Entity\\MenuItemTranslation', 'translation')->join('translation.menuItem', 'menu')->where('menu.id = :id AND translation.locale = :localeId AND translation.active = 1')->setParameter('id', $id)->setParameter('localeId', $this->route->getCurrentMenuItemTranslation()->locale->id)->getQuery()->getOneOrNullResult();
         $this->db->free();
         if ($menuItemTranslation) {
             $menuItem = clone $this->db->getRepository('\\Fraym\\Menu\\Entity\\MenuItem')->findOneById($menuItemTranslation->menuItem->id);
             $children = $this->getItems($objData, $menuItem);
             $menuItem->parent = $parent;
             $menuItem->children = $children;
             $returnChildren->set($menuItem->id, $menuItem);
         }
     }
     return $returnChildren;
 }
Example #28
0
 /**
  * @return bool|mixed|string
  */
 public function repositorySearch()
 {
     $searchTerm = $this->request->post('term', '');
     $extensions = $this->registryManager->searchPackage($searchTerm);
     $availableExtensions = new \Doctrine\Common\Collections\ArrayCollection();
     $unregisteredExtensions = $this->registryManager->getUnregisteredExtensions();
     $installedExtensions = $this->db->getRepository('\\Fraym\\Registry\\Entity\\Registry')->findBy([], ['name' => 'asc']);
     foreach ($installedExtensions as $installedExtension) {
         $availableExtensions->set($installedExtension->repositoryKey, $installedExtension);
     }
     foreach ($unregisteredExtensions as $unregisteredExtension) {
         $availableExtensions->set($unregisteredExtension['repositoryKey'], $unregisteredExtension);
     }
     $this->view->assign('availableExtensions', $availableExtensions);
     $this->view->assign('extensions', $extensions ?: []);
     return $this->view->fetch('RepositorySearch');
 }
 /**
  * @return bool|mixed|string
  */
 public function repositorySearch()
 {
     $searchTerm = $this->request->post('term', '');
     $availableExtensions = new \Doctrine\Common\Collections\ArrayCollection();
     $unregisteredExtensions = $this->registryManager->getUnregisteredExtensions();
     $installedExtensions = $this->db->getRepository('\\Fraym\\Registry\\Entity\\Registry')->findBy(array(), array('name' => 'asc'));
     $extensions = $this->registryManager->repositoryRequest('listModules', array('searchTerm' => $searchTerm, 'offset' => 0, 'limit' => 20));
     foreach ($installedExtensions as $installedExtension) {
         $availableExtensions->set($installedExtension->repositoryKey, $installedExtension);
     }
     foreach ($unregisteredExtensions as $unregisteredExtension) {
         $availableExtensions->set($unregisteredExtension['repositoryKey'], $unregisteredExtension);
     }
     $this->view->assign('availableExtensions', $availableExtensions);
     $this->view->assign('extensions', $extensions ?: array());
     return $this->template->fetch('RepositorySearch');
 }
Example #30
0
 /**
  *
  */
 private function editMenuItem()
 {
     $menu = $this->request->post('menu');
     if ($menu !== null) {
         $newMenuItem = $this->db->getRepository('\\Fraym\\Menu\\Entity\\MenuItem')->findOneById($menu['id']);
         try {
             foreach ($menu['translations'] as $k => $translation) {
                 if (empty($translation['title'])) {
                     unset($menu['translations'][$k]);
                 }
             }
             $newMenuItem->updateEntity($menu);
             $this->response->sendAsJson(array('error' => false, 'menuId' => $newMenuItem->id, 'translations' => array()));
         } catch (\Exception $e) {
             $this->response->sendAsJson(array('error' => true, 'message' => $e->getMessage()));
         }
     }
 }