コード例 #1
0
ファイル: Index.php プロジェクト: acp3/module-comments
 /**
  * @return array
  */
 public function execute()
 {
     /** @var Core\Helpers\DataGrid $dataGrid */
     $dataGrid = $this->get('core.helpers.data_grid');
     $dataGrid->setResults($this->commentRepository->getCommentsGroupedByModule())->setRecordsPerPage($this->resultsPerPage->getResultsPerPage(Schema::MODULE_NAME))->setIdentifier('#acp-table')->setResourcePathDelete('admin/comments/index/delete')->setResourcePathEdit('admin/comments/details/index');
     $this->addDataGridColumns($dataGrid);
     return ['grid' => $dataGrid->render(), 'show_mass_delete_button' => $dataGrid->countDbResults() > 0];
 }
コード例 #2
0
ファイル: Delete.php プロジェクト: acp3/module-comments
 /**
  * @param string $action
  *
  * @return mixed
  * @throws \ACP3\Core\Controller\Exception\ResultNotExistsException
  */
 public function execute($action = '')
 {
     return $this->actionHelper->handleDeleteAction($action, function (array $items) {
         $bool = false;
         foreach ($items as $item) {
             $bool = $this->commentRepository->delete($item, 'module_id');
         }
         Core\Cache\Purge::doPurge($this->appPath->getCacheDir() . 'http');
         return $bool;
     });
 }
コード例 #3
0
ファイル: Delete.php プロジェクト: acp3/module-comments
 /**
  * @param int $id
  * @param string $action
  *
  * @return array|\Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\RedirectResponse
  * @throws \ACP3\Core\Controller\Exception\ResultNotExistsException
  */
 public function execute($id, $action = '')
 {
     return $this->actionHelper->handleCustomDeleteAction($action, function (array $items) use($id) {
         $result = $this->commentsModel->delete($items);
         // If there are no comments for the given module, redirect to the general comments admin panel page
         if ($this->commentRepository->countAll($id) == 0) {
             $redirectUrl = 'acp/comments';
         } else {
             $redirectUrl = 'acp/comments/details/index/id_' . $id;
         }
         return $this->redirectMessages()->setMessage($result, $this->translator->t('system', $result !== false ? 'delete_success' : 'delete_error'), $redirectUrl);
     }, 'acp/comments/details/delete/id_' . $id, 'acp/comments/details/index/id_' . $id);
 }
コード例 #4
0
ファイル: Index.php プロジェクト: acp3/module-comments
 /**
  * @param int $id
  *
  * @return array
  * @throws \ACP3\Core\Controller\Exception\ResultNotExistsException
  */
 public function execute($id)
 {
     $comments = $this->commentRepository->getAllByModuleInAcp($id);
     if (empty($comments) === false) {
         $moduleName = $this->systemModuleRepository->getModuleNameById($id);
         $this->breadcrumb->append($this->translator->t($moduleName, $moduleName));
         /** @var Core\Helpers\DataGrid $dataGrid */
         $dataGrid = $this->get('core.helpers.data_grid');
         $dataGrid->setResults($comments)->setRecordsPerPage($this->resultsPerPage->getResultsPerPage(Schema::MODULE_NAME))->setIdentifier('#acp-table')->setResourcePathDelete('admin/comments/details/delete/id_' . $id)->setResourcePathEdit('admin/comments/details/edit');
         $this->addDataGridColumns($dataGrid);
         return ['grid' => $dataGrid->render(), 'module_id' => $id, 'show_mass_delete_button' => $dataGrid->countDbResults() > 0];
     }
     throw new Core\Controller\Exception\ResultNotExistsException();
 }
コード例 #5
0
ファイル: Index.php プロジェクト: acp3/module-comments
 /**
  * @param string $module
  * @param int $entryId
  *
  * @return array
  */
 public function execute($module, $entryId)
 {
     $this->setCacheResponseCacheable($this->config->getSettings(Schema::MODULE_NAME)['cache_lifetime']);
     $resultsPerPage = $this->resultsPerPage->getResultsPerPage(Comments\Installer\Schema::MODULE_NAME);
     $this->pagination->setResultsPerPage($resultsPerPage)->setTotalResults($this->commentRepository->countAllByModule($this->modules->getModuleId($module), $entryId));
     $comments = $this->commentRepository->getAllByModule($this->modules->getModuleId($module), $entryId, $this->pagination->getResultsStartOffset(), $resultsPerPage);
     $cComments = count($comments);
     for ($i = 0; $i < $cComments; ++$i) {
         if (empty($comments[$i]['name'])) {
             $comments[$i]['name'] = $this->translator->t('users', 'deleted_user');
         }
         if ($this->emoticonsActive === true && $this->emoticonsHelpers) {
             $comments[$i]['message'] = $this->emoticonsHelpers->emoticonsReplace($comments[$i]['message']);
         }
     }
     return ['comments' => $comments, 'dateformat' => $this->commentsSettings['dateformat'], 'pagination' => $this->pagination->render()];
 }
コード例 #6
0
ファイル: Helpers.php プロジェクト: acp3/module-comments
 /**
  * @param int $moduleId
  * @param int $resultId
  *
  * @return int
  */
 public function deleteCommentsByModuleAndResult($moduleId, $resultId)
 {
     return $this->commentRepository->delete(['module_id' => $moduleId, 'entry_id' => $resultId]);
 }