Beispiel #1
0
 /**
  * @return array
  */
 protected function buildCategoryData()
 {
     $pid = (int) $this->arguments['categoryPid'];
     if (!array_key_exists($pid, self::$categoryDataCache)) {
         self::$categoryDataCache[$pid] = $this->categoryRepository->findByPid($pid);
     }
     return self::$categoryDataCache[$pid];
 }
 /**
  * @return array|\TYPO3\CMS\Extbase\Persistence\QueryResultInterface
  */
 protected function getCategories()
 {
     $categories = $this->categoryService->getSubCategories($this->settings['categories']);
     $categories = GeneralUtility::removeArrayEntryByValue($categories, $this->settings['categories']);
     $query = $this->categoryRepository->createQuery();
     $query->getQuerySettings()->setRespectStoragePage(false);
     $constraints = [];
     $constraints[] = $query->in('uid', $categories);
     $query->matching($query->logicalAnd($constraints));
     return $query->execute();
 }
 /**
  * action list
  *
  * @return void
  */
 public function listAction()
 {
     $categories = $this->categoryRepository->findByParent((int) $this->settings['parentCategory']);
     $categoryAndLinksItems = [];
     $i = 0;
     foreach ($categories as $category) {
         /** @var $category \TYPO3\CMS\Extbase\Domain\Model\Category */
         $categoryAndLinksItems[$i]['category'] = $category;
         $categoryAndLinksItems[$i]['links'] = $this->linkRepository->findByCategory($category);
         $i++;
     }
     $this->view->assign('categoryAndLinksItems', $categoryAndLinksItems);
 }
 /**
  * Folder form
  *
  * @return void
  */
 public function formFolderAction()
 {
     $args = GeneralUtility::_GET('tx_ameos_filemanager');
     $editFolderUid = $args['newFolder'];
     // We are editing a folder
     if ($editFolderUid != '') {
         if ($newFolder = $this->folderRepository->findByUid($editFolderUid, $writeRight = true)) {
             $this->view->assign('folder', $newFolder);
             $this->view->assign('parentFolder', $newFolder->getParent()->getUid());
         } else {
             return LocalizationUtility::translate('accessDenied', 'ameos_filemanager');
         }
     } else {
         $folderUid = $args['folder'] ?: $this->settings['startFolder'];
         if ($folderParent = $this->folderRepository->findByUid($folderUid, $writeRight = true)) {
             $this->view->assign('parentFolder', $folderParent->getUid());
         } else {
             return LocalizationUtility::translate('accessDenied', 'ameos_filemanager');
         }
     }
     if ($this->authorizedCategories != '') {
         $categorieUids = explode(',', $this->authorizedCategories);
         $categories = Tools::getByUids($this->categoryRepository, $this->authorizedCategories);
     } else {
         $categories = $this->categoryRepository->findAll();
     }
     if ($this->authorizedGroups != '') {
         $feGroup = Tools::getByUids($this->feGroupRepository, $this->authorizedGroups)->toArray();
         if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList($this->authorizedGroups, -2)) {
             $temp = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Domain\\Model\\FrontendUserGroup');
             $temp->_setProperty('uid', -2);
             $temp->setTitle(LocalizationUtility::translate('LLL:EXT:lang/locallang_general.xlf:LGL.any_login', null));
             $feGroup[] = $temp;
         }
     } else {
         $feGroup = $this->feGroupRepository->findAll()->toArray();
         $temp = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Domain\\Model\\FrontendUserGroup');
         $temp->_setProperty('uid', -2);
         $temp->setTitle(LocalizationUtility::translate('LLL:EXT:lang/locallang_general.xlf:LGL.any_login', null));
         $feGroup[] = $temp;
     }
     if ($args['errors']) {
         $this->view->assign('errors', $args['errors']);
         $this->view->assign('folder', $args['currentState']);
         $this->view->assign('parentFolder', $args['currentState']['uidParent']);
     }
     $this->view->assign('categories', $categories);
     $this->view->assign('feGroup', $feGroup);
     $this->view->assign('returnFolder', $args['returnFolder']);
 }
 /**
  * Performs configurations from plugin settings (flexform)
  *
  * @return void
  */
 protected function performPluginConfigurations()
 {
     // Set ShowNavHiddenItems to TRUE
     $this->pageRepository->setShowNavHiddenItems($this->settings['showNavHiddenItems'] == '1');
     $this->pageRepository->setFilteredDokType(\TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $this->settings['showDoktypes'], TRUE));
     if ($this->settings['hideCurrentPage'] == '1') {
         $this->pageRepository->setIgnoreOfUid($this->currentPageUid);
     }
     if ($this->settings['ignoreUids']) {
         $ignoringUids = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $this->settings['ignoreUids'], TRUE);
         array_map(array($this->pageRepository, 'setIgnoreOfUid'), $ignoringUids);
     }
     if ($this->settings['categoriesList'] && $this->settings['categoryMode']) {
         $categories = array();
         foreach (\TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $this->settings['categoriesList'], TRUE) as $categoryUid) {
             $categories[] = $this->categoryRepository->findByUid($categoryUid);
         }
         switch ((int) $this->settings['categoryMode']) {
             case \PwTeaserTeam\PwTeaser\Domain\Repository\PageRepository::CATEGORY_MODE_OR:
             case \PwTeaserTeam\PwTeaser\Domain\Repository\PageRepository::CATEGORY_MODE_OR_NOT:
                 $isAnd = FALSE;
                 break;
             default:
                 $isAnd = TRUE;
         }
         switch ((int) $this->settings['categoryMode']) {
             case \PwTeaserTeam\PwTeaser\Domain\Repository\PageRepository::CATEGORY_MODE_AND_NOT:
             case \PwTeaserTeam\PwTeaser\Domain\Repository\PageRepository::CATEGORY_MODE_OR_NOT:
                 $isNot = TRUE;
                 break;
             default:
                 $isNot = FALSE;
         }
         $this->pageRepository->addCategoryConstraint($categories, $isAnd, $isNot);
     }
     if ($this->settings['source'] === 'custom') {
         $this->settings['pageMode'] = 'flat';
     }
     if ($this->settings['pageMode'] === 'nested') {
         $this->settings['recursionDepthFrom'] = 0;
         $this->settings['orderBy'] = 'uid';
         $this->settings['limit'] = 0;
     }
 }
Beispiel #6
0
 /**
  * @return mixed
  */
 protected function getCategoryRecords()
 {
     return $this->categoryRepository->findByPid($this->categoryPid);
 }
 /**
  * @param string|array $categories categories either string (comma separated) or list of uids as array (can be null)
  * @param string|integer $pid parent page id containing categories
  * @param string $as render as variable instead of returning array directly
  * @param boolean $firstOnly if true return only first record
  * @param boolean $titleOnly if true return titles only (either array or string if firstOnly set)
  * @return array|string|\TYPO3\CMS\Extbase\Domain\Model\Category array of categories (if as is set) or output or single entry
  */
 public function render($categories = NULL, $pid = NULL, $as = NULL, $firstOnly = FALSE, $titleOnly = FALSE)
 {
     if (!empty($categories)) {
         // explode if string
         if (is_string($categories)) {
             $categories = explode(',', $categories);
         }
     } else {
         $categories = NULL;
     }
     // page id
     if (!empty($pid)) {
         $pid = intval($pid);
     }
     // define contain array
     $contain = array();
     // get categories
     $query = $this->categoryRepository->createQuery();
     if (!empty($categories)) {
         $contain[] = $query->in('uid', $categories);
     }
     if (!empty($pid)) {
         $contain[] = $query->equals('pid', $pid);
     }
     if ($titleOnly) {
         $query->setLimit(1);
     }
     // any filters?
     if (!empty($contain)) {
         $query->matching($query->logicalAnd($contain));
     }
     // Ignore storage space
     $query->getQuerySettings()->setRespectStoragePage(false);
     $categoriesFound = $query->execute();
     // nothing found?
     if ($categoriesFound->count() == 0) {
         $categoriesFound = NULL;
     }
     if ($categoriesFound != null) {
         if ($firstOnly) {
             $categoriesFound = $categoriesFound->getFirst();
             // title only?
             /**
              * @var \TYPO3\CMS\Extbase\Domain\Model\Category $categoriesFound
              */
             if ($titleOnly) {
                 $categoriesFound = $categoriesFound->getTitle();
             }
         } elseif ($titleOnly) {
             $titles = array();
             /**
              * @var \TYPO3\CMS\Extbase\Domain\Model\Category $category
              */
             foreach ($categoriesFound as $category) {
                 $titles[] = $category->getTitle();
             }
             $categoriesFound = $titles;
         }
     }
     // return directly
     if (empty($as)) {
         return $categoriesFound;
     }
     $this->templateVariableContainer->add($as, $categoriesFound);
     $output = $this->renderChildren();
     $this->templateVariableContainer->remove($as);
     return $output;
 }