/** * @param int $categoryId * @param array $settings * @return array */ private function fetchFiles($categoryId, array $settings) { if (!empty($categoryId)) { $files = $this->filesRepository->getAllByCategoryId((int) $categoryId, $this->date->getCurrentDateTime(), $settings['sidebar']); } else { $files = $this->filesRepository->getAll($this->date->getCurrentDateTime(), $settings['sidebar']); } return $files; }
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')); } }
/** * @return array */ public function fetchFeedItems() { $items = []; $results = $this->filesRepository->getAll($this->date->getCurrentDateTime(), 10); $cResults = count($results); for ($i = 0; $i < $cResults; ++$i) { $items[] = ['title' => $results[$i]['title'], 'date' => $this->date->timestamp($results[$i]['start']), 'description' => $this->formatter->shortenEntry($results[$i]['text'], 300, 0), 'link' => $this->router->route('files/index/details/id_' . $results[$i]['id'], true)]; } return $items; }
/** * @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(); }
/** * @param int $id * @return array * @throws Core\Controller\Exception\ResultNotExistsException */ public function execute($id) { if ($this->filesRepository->resultExists($id, $this->date->getCurrentDateTime()) === true) { $this->setCacheResponseCacheable($this->config->getSettings(Schema::MODULE_NAME)['cache_lifetime']); $file = $this->filesCache->getCache($id); $this->breadcrumb->append($this->translator->t('files', 'files'), 'files')->append($file['category_title'], 'files/index/files/cat_' . $file['category_id'])->append($file['title']); $settings = $this->config->getSettings(Files\Installer\Schema::MODULE_NAME); $file['text'] = $this->view->fetchStringAsTemplate($file['text']); return ['file' => $file, 'dateformat' => $settings['dateformat'], 'comments_allowed' => $settings['comments'] == 1 && $file['comments'] == 1]; } throw new Core\Controller\Exception\ResultNotExistsException(); }
/** * @param ModelSaveEvent $event */ public function execute(ModelSaveEvent $event) { if (!$event->isDeleteStatement()) { return; } $upload = new Upload($this->applicationPath, Schema::MODULE_NAME); foreach ($event->getEntryId() as $item) { $upload->removeUploadedFile($this->filesRepository->getFileById($item)); if ($this->commentsHelpers) { $this->commentsHelpers->deleteCommentsByModuleAndResult($this->modules->getModuleId(Schema::MODULE_NAME), $item); } $this->cache->getCacheDriver()->delete(Cache::CACHE_ID . $item); if ($this->uriAliasManager) { $this->uriAliasManager->deleteUriAlias(sprintf(Helpers::URL_KEY_PATTERN, $item)); } } }
/** * @param int $id * @return \Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response * @throws Core\Controller\Exception\ResultNotExistsException */ public function execute($id) { if ($this->filesRepository->resultExists($id, $this->date->getCurrentDateTime()) === true) { $file = $this->filesCache->getCache($id); $path = $this->appPath->getUploadsDir() . 'files/'; if (is_file($path . $file['file'])) { $ext = strrchr($file['file'], '.'); $filename = $this->stringFormatter->makeStringUrlSafe($file['title']) . $ext; $response = new BinaryFileResponse($path . $file['file']); $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $filename); return $response; } elseif (preg_match('/^([a-z]+):\\/\\//', $file['file'])) { // External file return $this->redirect()->toNewPage($file['file']); } } throw new Core\Controller\Exception\ResultNotExistsException(); }
/** * @param integer $fileId * * @return boolean */ public function saveCache($fileId) { return $this->cache->save(self::CACHE_ID . $fileId, $this->filesRepository->getOneById($fileId)); }