/**
  * @inheritdoc
  */
 public function isValid($data, $field = '', array $extra = [])
 {
     if (is_array($data) && array_key_exists($field, $data)) {
         return $this->isValid($data[$field], $field, $extra);
     }
     $params = array_merge(['module_id' => 0, 'category_id' => ''], $extra);
     return !$this->categoryRepository->resultIsDuplicate($data, $params['module_id'], $params['category_id']);
 }
 /**
  * @inheritdoc
  */
 public function validate(array $formData)
 {
     $this->validator->addConstraint(Core\Validation\ValidationRules\FormTokenValidationRule::class)->addConstraint(Core\Validation\ValidationRules\NotEmptyValidationRule::class, ['data' => $formData, 'field' => 'title', 'message' => $this->translator->t('categories', 'title_to_short')])->addConstraint(Core\Validation\ValidationRules\NotEmptyValidationRule::class, ['data' => $formData, 'field' => 'description', 'message' => $this->translator->t('categories', 'description_to_short')])->addConstraint(Core\Validation\ValidationRules\PictureValidationRule::class, ['data' => $this->file, 'field' => 'picture', 'message' => $this->translator->t('categories', 'invalid_image_selected'), 'extra' => ['width' => $this->settings['width'], 'height' => $this->settings['height'], 'filesize' => $this->settings['filesize'], 'required' => false]])->addConstraint(DuplicateCategoryValidationRule::class, ['data' => $formData, 'field' => 'title', 'message' => $this->translator->t('categories', 'category_already_exists'), 'extra' => ['module_id' => empty($this->categoryId) ? $formData['module'] : $this->categoryRepository->getModuleIdByCategoryId($this->categoryId), 'category_id' => $this->categoryId]]);
     if (empty($categoryId)) {
         $this->validator->addConstraint(Core\Validation\ValidationRules\NotEmptyValidationRule::class, ['data' => $formData, 'field' => 'module', 'message' => $this->translator->t('categories', 'select_module')]);
     }
     $this->validator->validate();
 }
 /**
  * @inheritdoc
  */
 public function isValid($data, $field = '', array $extra = [])
 {
     if (is_array($data) && is_array($field)) {
         $categoryId = reset($field);
         $createCategory = next($field);
         return !empty($data[$createCategory]) || $this->categoryRepository->resultExists($data[$categoryId]);
     }
     return false;
 }
 public function fetchSitemapUrls()
 {
     $this->addUrl('files/index/index');
     foreach ($this->categoryRepository->getAllByModuleName(Schema::MODULE_NAME) as $category) {
         $this->addUrl('files/index/files/cat_' . $category['id']);
     }
     foreach ($this->filesRepository->getAll($this->date->getCurrentDateTime()) as $result) {
         $this->addUrl(sprintf(Helpers::URL_KEY_PATTERN, $result['id']), $this->date->format($result['updated_at'], 'Y-m-d'));
     }
 }
示例#5
0
 /**
  * Erzeugt eine neue Kategorie und gibt ihre ID zurück
  *
  * @param string $title
  * @param string $module
  *
  * @return integer
  */
 public function categoriesCreate($title, $module)
 {
     $moduleInfo = $this->modules->getModuleInfo($module);
     if ($this->categoryRepository->resultIsDuplicate($title, $moduleInfo['id'], '') === false) {
         $insertValues = ['id' => '', 'title' => $this->secureHelper->strEncode($title), 'picture' => '', 'description' => '', 'module_id' => $moduleInfo['id']];
         $result = $this->categoryRepository->insert($insertValues);
         $this->categoriesCache->saveCache($module);
         return $result;
     }
     return $this->categoryRepository->getOneByTitleAndModule($title, $module)['id'];
 }
 /**
  * @param ModelSaveEvent $event
  */
 public function execute(ModelSaveEvent $event)
 {
     if ($event->isDeleteStatement()) {
         return;
     }
     foreach ($event->getEntryId() as $entryId) {
         $category = $this->categoryRepository->getCategoryDeleteInfosById($entryId);
         $upload = new Upload($this->appPath, Schema::MODULE_NAME);
         $upload->removeUploadedFile($category['picture']);
     }
 }
示例#7
0
 /**
  * @param int $cat
  *
  * @return array
  * @throws \ACP3\Core\Controller\Exception\ResultNotExistsException
  */
 public function execute($cat)
 {
     if ($this->categoryRepository->resultExists($cat) === true) {
         $this->setCacheResponseCacheable($this->config->getSettings(Schema::MODULE_NAME)['cache_lifetime']);
         $category = $this->categoryRepository->getOneById($cat);
         $this->breadcrumb->append($this->translator->t('files', 'files'), 'files')->append($category['title']);
         $settings = $this->config->getSettings(FilesModule\Installer\Schema::MODULE_NAME);
         return ['dateformat' => $settings['dateformat'], 'files' => $this->filesRepository->getAllByCategoryId($cat, $this->date->getCurrentDateTime())];
     }
     throw new Core\Controller\Exception\ResultNotExistsException();
 }
示例#8
0
 /**
  * @param int $cat
  */
 protected function addBreadcrumbStep($cat)
 {
     if ($cat !== 0 && $this->newsSettings['category_in_breadcrumb'] == 1) {
         if ($this->metaStatements instanceof MetaStatements) {
             $this->metaStatements->setCanonicalUri($this->router->route('news'));
         }
         $this->breadcrumb->append($this->translator->t('news', 'news'), 'news');
         $category = $this->categoryRepository->getTitleById($cat);
         if (!empty($category)) {
             $this->breadcrumb->append($category);
         }
     }
 }
示例#9
0
 /**
  * Erstellt den Cache für die Kategorien eines Moduls
  *
  * @param string $moduleName
  *  Das Modul, für welches der Kategorien-Cache erstellt werden soll
  *
  * @return boolean
  */
 public function saveCache($moduleName)
 {
     return $this->cache->save($moduleName, $this->categoryRepository->getAllByModuleName($moduleName));
 }
 /**
  * @param ModelSaveEvent $event
  */
 public function execute(ModelSaveEvent $event)
 {
     $this->cache->saveCache($this->categoryRepository->getModuleNameFromCategoryId($event->getEntryId()));
 }