public function indexAction(Request $request)
 {
     $data = array();
     $source = new Entity('OjsJournalBundle:Journal');
     $source->manipulateRow(function (Row $row) use($request) {
         /* @var Journal $entity */
         $entity = $row->getEntity();
         $entity->setDefaultLocale($request->getDefaultLocale());
         if (!is_null($entity)) {
             $row->setField('title', $entity->getTitle());
         }
         return $row;
     });
     $alias = $source->getTableAlias();
     $source->manipulateQuery(function (QueryBuilder $query) use($alias) {
         $query->andWhere($alias . '.status = :status')->setParameter('status', '0');
         return $query;
     });
     $grid = $this->get('grid')->setSource($source);
     $gridAction = $this->get('grid_action');
     $rowAction = array();
     $rowAction[] = $gridAction->editAction('ojs_admin_application_journal_edit', 'id');
     $rowAction[] = $gridAction->showAction('ojs_admin_application_journal_show', 'id');
     $rowAction[] = $gridAction->deleteAction('ojs_admin_application_journal_delete', 'id');
     $actionColumn = new ActionsColumn("actions", 'actions');
     $actionColumn->setRowActions($rowAction);
     $grid->addColumn($actionColumn);
     $data['grid'] = $grid;
     return $grid->getGridResponse('OjsAdminBundle:AdminApplication:journal.html.twig', $data);
 }
 /**
  * Lists all JournalSection entities.
  *
  */
 public function indexAction()
 {
     $journal = $this->get('ojs.journal_service')->getSelectedJournal();
     if (!$this->isGranted('VIEW', $journal, 'sections')) {
         throw new AccessDeniedException("You are not authorized for view this journal's sections!");
     }
     $source = new Entity('OjsJournalBundle:JournalSection');
     $source->addHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Gedmo\\Translatable\\Query\\TreeWalker\\TranslationWalker');
     $ta = $source->getTableAlias();
     $source->manipulateQuery(function (QueryBuilder $qb) use($journal, $ta) {
         $qb->where($qb->expr()->eq($ta . '.journalId', $journal->getId()));
         return $qb;
     });
     $source->manipulateRow(function (Row $row) {
         if ($row->getField("title") && strlen($row->getField('title')) > 20) {
             $row->setField('title', substr($row->getField('title'), 0, 20) . "...");
         }
         return $row;
     });
     $grid = $this->get('grid')->setSource($source);
     $gridAction = $this->get('grid_action');
     $actionColumn = new ActionsColumn("actions", 'actions');
     $rowAction[] = $gridAction->showAction('ojs_journal_section_show', ['id', 'journalId' => $journal->getId()]);
     if ($this->isGranted('EDIT', $this->get('ojs.journal_service')->getSelectedJournal(), 'sections')) {
         $rowAction[] = $gridAction->editAction('ojs_journal_section_edit', ['id', 'journalId' => $journal->getId()]);
     }
     if ($this->isGranted('DELETE', $this->get('ojs.journal_service')->getSelectedJournal(), 'sections')) {
         $rowAction[] = $gridAction->deleteAction('ojs_journal_section_delete', ['id', 'journalId' => $journal->getId()]);
     }
     $actionColumn->setRowActions($rowAction);
     $grid->addColumn($actionColumn);
     $data = [];
     $data['grid'] = $grid;
     return $grid->getGridResponse('OjsJournalBundle:JournalSection:index.html.twig', $data);
 }
Beispiel #3
0
 /**
  * Lists all Design entities.
  *
  * @param Request $request
  * @return Response
  */
 public function indexAction(Request $request)
 {
     $journal = $this->get('ojs.journal_service')->getSelectedJournal();
     if (!$this->isGranted('VIEW', $journal, 'design')) {
         throw new AccessDeniedException("You are not authorized for view this journal's designs!");
     }
     $source = new Entity('OjsJournalBundle:Design');
     $tableAlias = $source->getTableAlias();
     $source->manipulateQuery(function ($query) use($tableAlias, $journal) {
         $query->andWhere($tableAlias . '.owner = :journal')->setParameter('journal', $journal);
     });
     $source->manipulateRow(function (Row $row) use($request) {
         /* @var Design $entity */
         $entity = $row->getEntity();
         if (!is_null($entity)) {
             $entity->getOwner()->setDefaultLocale($request->getDefaultLocale());
             $row->setField('owner', $entity->getOwner()->getTitle());
         }
         return $row;
     });
     $grid = $this->get('grid')->setSource($source);
     $gridAction = $this->get('grid_action');
     $actionColumn = new ActionsColumn("actions", 'actions');
     $rowAction[] = $gridAction->showAction('ojs_journal_design_show', ['id', 'journalId' => $journal->getId()]);
     $rowAction[] = $gridAction->editAction('ojs_journal_design_edit', ['id', 'journalId' => $journal->getId()]);
     $rowAction[] = $gridAction->deleteAction('ojs_journal_design_delete', ['id', 'journalId' => $journal->getId()]);
     $actionColumn->setRowActions($rowAction);
     $grid->addColumn($actionColumn);
     $data = [];
     $data['grid'] = $grid;
     return $grid->getGridResponse('OjsJournalBundle:Design:index.html.twig', $data);
 }
 /**
  * Lists all SubmissionChecklist entities.
  *
  */
 public function indexAction()
 {
     $journal = $this->get('ojs.journal_service')->getSelectedJournal();
     if (!$this->isGranted('VIEW', $journal, 'checklist')) {
         throw new AccessDeniedException("You are not authorized for view this page!");
     }
     $source = new Entity('OjsJournalBundle:SubmissionChecklist');
     $source->addHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Gedmo\\Translatable\\Query\\TreeWalker\\TranslationWalker');
     if ($journal) {
         $ta = $source->getTableAlias();
         $source->manipulateQuery(function (QueryBuilder $qb) use($journal, $ta) {
             $qb->andWhere($qb->expr()->eq("{$ta}.journal_id", ':journal'))->setParameter('journal', $journal->getId());
         });
     }
     if (!$journal) {
         throw new NotFoundHttpException("Journal not found!");
     }
     $grid = $this->get('grid')->setSource($source);
     $gridAction = $this->get('grid_action');
     $actionColumn = new ActionsColumn("actions", 'actions');
     $rowAction[] = $gridAction->showAction('ojs_journal_checklist_show', ['id', 'journalId' => $journal->getId()]);
     $rowAction[] = $gridAction->editAction('ojs_journal_checklist_edit', ['id', 'journalId' => $journal->getId()]);
     $rowAction[] = $gridAction->deleteAction('ojs_journal_checklist_delete', ['id', 'journalId' => $journal->getId()]);
     $actionColumn->setRowActions($rowAction);
     $grid->addColumn($actionColumn);
     $data = [];
     $data['grid'] = $grid;
     $data['journal_id'] = $journal;
     return $grid->getGridResponse('OjsJournalBundle:SubmissionChecklist:index.html.twig', $data);
 }
 /**
  * Lists all PublisherThemes entities.
  *
  * @param integer $publisherId
  * @return Response
  */
 public function indexAction($publisherId)
 {
     $em = $this->getDoctrine()->getManager();
     $publisher = $em->getRepository('OjsJournalBundle:Publisher')->find($publisherId);
     $this->throw404IfNotFound($publisher);
     if (!$this->isGrantedForPublisher($publisher)) {
         throw new AccessDeniedException("You are not authorized for this page!");
     }
     $source = new Entity('OjsJournalBundle:PublisherTheme');
     $alias = $source->getTableAlias();
     $source->manipulateQuery(function (QueryBuilder $qb) use($publisher, $alias) {
         $qb->andWhere($alias . '.publisher = :publisher')->setParameter('publisher', $publisher);
     });
     $grid = $this->get('grid')->setSource($source);
     $gridAction = $this->get('grid_action');
     $actionColumn = new ActionsColumn("actions", 'actions');
     $rowAction[] = $gridAction->showAction('ojs_publisher_manager_theme_show', ['publisherId' => $publisher->getId(), 'id']);
     $rowAction[] = $gridAction->editAction('ojs_publisher_manager_theme_edit', ['publisherId' => $publisher->getId(), 'id']);
     $rowAction[] = $gridAction->deleteAction('ojs_publisher_manager_theme_delete', ['publisherId' => $publisher->getId(), 'id']);
     $actionColumn->setRowActions($rowAction);
     $grid->addColumn($actionColumn);
     $data = [];
     $data['grid'] = $grid;
     $data['publisher'] = $publisher;
     return $grid->getGridResponse('OjsJournalBundle:ManagerPublisherTheme:index.html.twig', $data);
 }
 public function indexAction(Request $request, $issueId)
 {
     $journal = $this->get('ojs.journal_service')->getSelectedJournal();
     $this->throw404IfNotFound($journal);
     if (!$this->isGranted('VIEW', $journal, 'issues')) {
         throw new AccessDeniedException("You not authorized for this page!");
     }
     $source = new Entity('OjsJournalBundle:IssueFile');
     $source->addHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Gedmo\\Translatable\\Query\\TreeWalker\\TranslationWalker');
     $issue = $this->getDoctrine()->getRepository('OjsJournalBundle:Issue')->find($issueId);
     $this->throw404IfNotFound($issue);
     $alias = $source->getTableAlias();
     $source->manipulateQuery(function (QueryBuilder $query) use($alias, $issueId) {
         $query->join($alias . '.issue', 'i')->where('i.id = :issueId')->setParameter('issueId', $issueId);
     });
     $grid = $this->get('grid')->setSource($source);
     $gridAction = $this->get('grid_action');
     $actionColumn = new ActionsColumn("actions", 'actions');
     $rowAction[] = $gridAction->showAction('ojs_journal_issue_file_show', ['id', 'journalId' => $journal->getId(), 'issueId' => $issueId]);
     $rowAction[] = $gridAction->editAction('ojs_journal_issue_file_edit', ['id', 'journalId' => $journal->getId(), 'issueId' => $issueId]);
     $rowAction[] = $gridAction->deleteAction('ojs_journal_issue_file_delete', ['id', 'journalId' => $journal->getId(), 'issueId' => $issueId]);
     $actionColumn->setRowActions($rowAction);
     $grid->addColumn($actionColumn);
     $data = [];
     $data['grid'] = $grid;
     $data['issue'] = $issue;
     return $grid->getGridResponse('OjsJournalBundle:IssueFile:index.html.twig', $data);
 }
 public function indexAction()
 {
     $data = array();
     $source = new Entity('OjsJournalBundle:Publisher', 'application');
     $tableAlias = $source->getTableAlias();
     $source->manipulateQuery(function (QueryBuilder $query) use($tableAlias) {
         $query->andWhere($tableAlias . ".status = :status")->setParameter('status', 0);
         return $query;
     });
     $grid = $this->get('grid')->setSource($source);
     $gridAction = $this->get('grid_action');
     $grid->getColumn('status')->manipulateRenderCell(function ($value) {
         return $this->get('translator')->trans(Publisher::$statuses[$value]);
     });
     $rowAction = array();
     $saveAction = new RowAction('<i class="fa fa-save"></i>', 'ojs_admin_application_publisher_save');
     $saveAction->setRouteParameters(['id']);
     $saveAction->setAttributes(['class' => 'btn btn-primary btn-xs', 'title' => $this->get('translator')->trans('institute.merge_as_new_institute')]);
     $rowAction[] = $saveAction;
     $rowAction[] = $gridAction->showAction('ojs_admin_application_publisher_show', 'id');
     $rowAction[] = $gridAction->editAction('ojs_admin_application_publisher_edit', 'id');
     $rowAction[] = $gridAction->deleteAction('ojs_admin_application_publisher_delete', 'id');
     $actionColumn = new ActionsColumn("actions", 'actions');
     $actionColumn->setRowActions($rowAction);
     $grid->addColumn($actionColumn);
     $data['grid'] = $grid;
     return $grid->getGridResponse('OjsAdminBundle:AdminApplication:publisher.html.twig', $data);
 }
Beispiel #8
0
 /**
  * Index view of content by type
  *
  * @param int $type
  * @return Response
  */
 public function typeAction($type)
 {
     $contentType = $this->get('opifer.content.content_type_manager')->getRepository()->find($type);
     if (!$contentType) {
         throw $this->createNotFoundException(sprintf('Content Type with ID %d could not be found.', $type));
     }
     $queryBuilder = $this->get('opifer.content.content_manager')->getRepository()->createValuedQueryBuilder('c');
     $source = new Entity($this->getParameter('opifer_content.content_class'));
     $source->initQueryBuilder($queryBuilder);
     $tableAlias = $source->getTableAlias();
     $source->manipulateQuery(function ($query) use($tableAlias, $contentType) {
         $query->andWhere($tableAlias . '.contentType = :contentType')->setParameter('contentType', $contentType);
     });
     $editAction = new RowAction('button.edit', 'opifer_content_contenteditor_design');
     $editAction->setRouteParameters(['id', 'type' => 'content']);
     //$deleteAction = new RowAction('button.delete', 'opifer_content_content_delete');
     //$deleteAction->setRouteParameters(['id']);
     /* @var $grid \APY\DataGridBundle\Grid\Grid */
     $grid = $this->get('grid');
     $grid->setId('content')->setSource($source)->addRowAction($editAction);
     //->addRowAction($deleteAction)
     foreach ($contentType->getSchema()->getAttributes() as $attribute) {
         $name = $attribute->getName();
         $column = new TextColumn(['id' => $name, 'field' => 'attributes.' . $attribute->getName() . '.value', 'title' => $attribute->getDisplayName()]);
         $column->manipulateRenderCell(function ($value, $row, $router) use($name) {
             $value = $row->getEntity()->getAttributes()[$name];
             return $value;
         });
         $grid->addColumn($column);
     }
     return $grid->getGridResponse($this->getParameter('opifer_content.content_type_view'), ['content_type' => $contentType, 'grid' => $grid]);
 }
Beispiel #9
0
 /**
  * Lists all ArticleFile entities.
  * @param   Integer $articleId
  * @return  Response
  */
 public function indexAction($articleId)
 {
     $journal = $this->get('ojs.journal_service')->getSelectedJournal();
     $article = $this->getDoctrine()->getRepository('OjsJournalBundle:Article')->find($articleId);
     $this->throw404IfNotFound($article);
     if (!$this->isGranted('VIEW', $journal, 'articles')) {
         throw new AccessDeniedException("You not authorized for this page!");
     }
     $source = new Entity('OjsJournalBundle:ArticleFile');
     $tableAlias = $source->getTableAlias();
     $source->manipulateQuery(function (QueryBuilder $qb) use($article, $tableAlias) {
         return $qb->where($tableAlias . '.article = :article')->setParameter('article', $article);
     });
     $grid = $this->get('grid')->setSource($source);
     $gridAction = $this->get('grid_action');
     $actionColumn = new ActionsColumn("actions", 'actions');
     $rowAction[] = $gridAction->showAction('ojs_journal_article_file_show', ['id', 'journalId' => $journal->getId(), 'articleId' => $articleId]);
     $rowAction[] = $gridAction->editAction('ojs_journal_article_file_edit', ['id', 'journalId' => $journal->getId(), 'articleId' => $articleId]);
     $rowAction[] = $gridAction->deleteAction('ojs_journal_article_file_delete', ['id', 'journalId' => $journal->getId(), 'articleId' => $articleId]);
     $actionColumn->setRowActions($rowAction);
     $grid->addColumn($actionColumn);
     $data = [];
     $data['grid'] = $grid;
     $data['article'] = $article;
     return $grid->getGridResponse('OjsJournalBundle:ArticleFile:index.html.twig', $data);
 }
 /**
  * Returns setupFinished == false journals
  *
  * @param Request $request
  * @return Response
  */
 public function notFinishedAction(Request $request)
 {
     if (!$this->isGranted('VIEW', new Journal())) {
         throw new AccessDeniedException("You not authorized for list journals!");
     }
     $source = new Entity('OjsJournalBundle:Journal');
     $tableAlias = $source->getTableAlias();
     $source->manipulateQuery(function (QueryBuilder $query) use($tableAlias) {
         $query->andWhere($tableAlias . '.setupFinished = 0');
     });
     $source->manipulateRow(function (Row $row) use($request) {
         /* @var Journal $entity */
         $entity = $row->getEntity();
         $entity->setDefaultLocale($request->getDefaultLocale());
         if (!is_null($entity)) {
             $row->setField('title', $entity->getTitle());
             $row->setField('subtitle', $entity->getSubtitle());
             $row->setField('description', $entity->getDescription());
         }
         return $row;
     });
     $grid = $this->get('grid')->setSource($source);
     $gridAction = $this->get('grid_action');
     $actionColumn = new ActionsColumn("actions", 'actions');
     $rowAction[] = $gridAction->showAction('ojs_admin_journal_show', 'id');
     $rowAction[] = $gridAction->editAction('ojs_journal_settings_index', 'id')->setRouteParametersMapping(['id' => 'journalId']);
     $rowAction[] = $gridAction->cmsAction();
     $rowAction[] = $gridAction->deleteAction('ojs_admin_journal_delete', 'id');
     $rowAction[] = (new RowAction('Manage', 'ojs_journal_dashboard_index'))->setRouteParameters('id')->setRouteParametersMapping(array('id' => 'journalId'))->setAttributes(array('class' => 'btn btn-success btn-xs', 'data-toggle' => 'tooltip', 'title' => "Manage"));
     $actionColumn->setRowActions($rowAction);
     $grid->addColumn($actionColumn);
     $data = [];
     $data['grid'] = $grid;
     return $grid->getGridResponse('OjsAdminBundle:AdminJournal:index.html.twig', $data);
 }
Beispiel #11
0
 /**
  * Lists all Citation entities.
  *
  * @param   Request $request
  * @param   Integer $articleId
  * @return  Response
  */
 public function indexAction(Request $request, $articleId)
 {
     $journal = $this->get('ojs.journal_service')->getSelectedJournal();
     $this->throw404IfNotFound($journal);
     if (!$this->isGranted('VIEW', $journal, 'articles')) {
         throw new AccessDeniedException("You not authorized for this page!");
     }
     $article = $this->getDoctrine()->getRepository('OjsJournalBundle:Article')->find($articleId);
     $this->throw404IfNotFound($article);
     $source = new Entity('OjsJournalBundle:Citation');
     if ($articleId !== null) {
         $alias = $source->getTableAlias();
         $source->manipulateQuery(function (QueryBuilder $query) use($alias, $articleId) {
             $query->join($alias . '.articles', 'a')->where('a.id = :articleId')->setParameter('articleId', $articleId);
         });
     }
     $grid = $this->get('grid')->setSource($source);
     $gridAction = $this->get('grid_action');
     $actionColumn = new ActionsColumn("actions", 'actions');
     $rowAction[] = $gridAction->showAction('ojs_journal_citation_show', ['id', 'journalId' => $journal->getId(), 'articleId' => $articleId]);
     $rowAction[] = $gridAction->editAction('ojs_journal_citation_edit', ['id', 'journalId' => $journal->getId(), 'articleId' => $articleId]);
     $rowAction[] = $gridAction->deleteAction('ojs_journal_citation_delete', ['id', 'journalId' => $journal->getId(), 'articleId' => $articleId]);
     $actionColumn->setRowActions($rowAction);
     $grid->addColumn($actionColumn);
     return $grid->getGridResponse('OjsJournalBundle:Citation:index.html.twig');
 }
 /**
  * List all brands.
  *
  * @throws AccessDeniedException If authenticate user is not allowed to access to this resource (minimum ROLE_ADMIN)
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function listAction()
 {
     $this->get('event_dispatcher')->dispatch(ProductEvents::LIST_BRANDS, new Event());
     // Set Datagrid source
     $source = new Entity($this->getParameter('asf_product.brand.entity'));
     $tableAlias = $source->getTableAlias();
     $source->manipulateQuery(function ($query) use($tableAlias) {
         $query instanceof QueryBuilder;
         if (count($query->getDQLPart('orderBy')) == 0) {
             $query->orderBy($tableAlias . '.name', 'ASC');
         }
     });
     // Get Grid instance
     $grid = $this->get('grid');
     $grid instanceof Grid;
     // Attach the source to the grid
     $grid->setSource($source);
     $grid->setId('asf_brands_list');
     // Columns configuration
     $editAction = new RowAction('btn_edit', 'asf_product_brand_edit');
     $editAction->setRouteParameters(array('id'));
     $grid->addRowAction($editAction);
     $deleteAction = new RowAction('btn_delete', 'asf_product_brand_delete', true);
     $deleteAction->setRouteParameters(array('id'))->setConfirmMessage($this->get('translator')->trans('asf.product.msg.delete.confirm', array('%name%' => $this->get('translator')->trans('asf.product.default_value.this_brand'))));
     $grid->addRowAction($deleteAction);
     $grid->setNoDataMessage($this->get('translator')->trans('asf.product.msg.list.no_brand'));
     return $grid->getGridResponse('ASFProductBundle:Brand:list.html.twig');
 }
 /**
  * Returns setupStatus == false journals
  * @return Response
  */
 public function notFinishedAction()
 {
     if (!$this->isGranted('VIEW', new Journal())) {
         throw new AccessDeniedException("You not authorized for list journals!");
     }
     $source = new Entity('OjsJournalBundle:Journal');
     $tableAlias = $source->getTableAlias();
     $source->manipulateQuery(function ($query) use($tableAlias) {
         $query->andWhere($tableAlias . '.setup_status = 0');
     });
     $source->addHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Gedmo\\Translatable\\Query\\TreeWalker\\TranslationWalker');
     $grid = $this->get('grid')->setSource($source);
     $gridAction = $this->get('grid_action');
     $actionColumn = new ActionsColumn("actions", 'actions');
     $rowAction[] = $gridAction->showAction('ojs_admin_journal_show', 'id');
     $rowAction[] = $gridAction->editAction('ojs_admin_journal_edit', 'id');
     $rowAction[] = $gridAction->cmsAction();
     $rowAction[] = $gridAction->deleteAction('ojs_admin_journal_delete', 'id');
     $rowAction[] = (new RowAction('Manage', 'change_selected_journal'))->setRouteParameters('id')->setRouteParametersMapping(array('id' => 'journal_id'))->setAttributes(array('class' => 'btn btn-success btn-xs', 'data-toggle' => 'tooltip', 'title' => "Manage"));
     $actionColumn->setRowActions($rowAction);
     $grid->addColumn($actionColumn);
     $data = [];
     $data['grid'] = $grid;
     return $grid->getGridResponse('OjsAdminBundle:AdminJournal:index.html.twig', $data);
 }
 public function indexAction(Request $request)
 {
     $data = array();
     $source = new Entity('OjsJournalBundle:Journal');
     $source->manipulateRow(function (Row $row) use($request) {
         /* @var Journal $entity */
         $entity = $row->getEntity();
         $entity->setDefaultLocale($request->getDefaultLocale());
         if (!is_null($entity)) {
             $row->setField('title', $entity->getTitle());
         }
         return $row;
     });
     $alias = $source->getTableAlias();
     $source->manipulateQuery(function (QueryBuilder $query) use($alias) {
         $query->andWhere($alias . '.status = :status')->setParameter('status', JournalStatuses::STATUS_PREPARING);
         return $query;
     });
     $grid = $this->get('grid')->setSource($source);
     $gridAction = $this->get('grid_action');
     $saveAction = new RowAction('<i class="fa fa-save"></i>', 'ojs_admin_application_journal_save');
     $saveAction->setRouteParameters(['id']);
     $saveAction->setAttributes(['class' => 'btn btn-primary btn-xs', 'title' => $this->get('translator')->trans('journal.merge_as_new_journal')]);
     $rowAction = array();
     $rowAction[] = $saveAction;
     $rowAction[] = $gridAction->editAction('ojs_admin_application_journal_edit', 'id');
     $rowAction[] = $gridAction->showAction('ojs_admin_application_journal_show', 'id');
     $rowAction[] = $gridAction->deleteAction('ojs_admin_application_journal_delete', 'id');
     $actionColumn = new ActionsColumn("actions", 'actions');
     $actionColumn->setRowActions($rowAction);
     $grid->addColumn($actionColumn);
     $data['grid'] = $grid;
     return $grid->getGridResponse('OjsAdminBundle:AdminApplication:journal.html.twig', $data);
 }
 /**
  * List all website config
  *
  * @throws AccessDeniedException If authenticate user is not allowed to access to this resource (minimum ROLE_ADMIN)
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function listAction()
 {
     if (false === $this->get('security.authorization_checker')->isGranted('ROLE_ADMIN')) {
         throw new AccessDeniedException();
     }
     // Set Datagrid source
     $source = new Entity($this->get('asf_website.config.manager')->getClassName());
     $tableAlias = $source->getTableAlias();
     $source->manipulateQuery(function ($query) use($tableAlias) {
         $query instanceof QueryBuilder;
         if (count($query->getDQLPart('orderBy')) == 0) {
             $query->orderBy($tableAlias . '.name', 'ASC');
         }
     });
     // Get Grid instance
     $grid = $this->get('grid');
     $grid instanceof Grid;
     // Attach the source to the grid
     $grid->setSource($source);
     $grid->setId('asf_website_config_list');
     // Columns configuration
     $grid->hideColumns(array('id'));
     $grid->getColumn('name')->setTitle($this->get('translator')->trans('Config name', array(), 'asf_website'))->setDefaultOperator('like')->setOperatorsVisible(false);
     $editAction = new RowAction('btn_edit', 'asf_website_config_edit');
     $editAction->setRouteParameters(array('id'));
     $grid->addRowAction($editAction);
     $deleteAction = new RowAction('btn_delete', 'asf_website_config_delete', true);
     $deleteAction->setRouteParameters(array('id'))->setConfirmMessage($this->get('translator')->trans('Do you want to delete this config?', array(), 'asf_website'));
     $grid->addRowAction($deleteAction);
     $grid->setNoDataMessage($this->get('translator')->trans('No config was found.', array(), 'asf_website'));
     return $grid->getGridResponse('ASFWebsiteBundle:Config:list.html.twig');
 }
 /**
  * @Template()
  * @Route("/", name="ticket.ticket.index")
  * @Security("has_role('ROLE_USER')")
  * @param Request $request
  * @return array
  */
 public function indexAction(Request $request)
 {
     $user = $this->getUser();
     $source = new Entity('DreamlexTicketBundle:Ticket');
     $source->addHint(\Doctrine\ORM\Query::HINT_CUSTOM_OUTPUT_WALKER, 'Gedmo\\Translatable\\Query\\TreeWalker\\TranslationWalker');
     $prefixTitle = 'ticket.label.grid.';
     $translator = $this->get('translator');
     $tableAlias = $source->getTableAlias();
     $source->manipulateQuery(function ($query) use($tableAlias, $user) {
         /** @var QueryBuilder $query */
         $query->andWhere($tableAlias . '.user = :user')->setParameter('user', $user);
     });
     $source->manipulateRow(function ($row) use($user) {
         /** @var Row $row */
         if ($row->getField('lastUser.id') != $user->getId() && !$row->getField('isRead')) {
             $row->setClass('warning');
         }
         return $row;
     });
     $grid = $this->get('grid');
     $grid->setSource($source);
     $grid->setLimits(10);
     $grid->setPrefixTitle($prefixTitle);
     $grid->setId('ticket');
     $grid->setNoDataMessage($translator->trans('ticket.message.no_tickets'));
     $replyAction = new RowAction('ticket.button.reply', 'ticket.ticket.show', false, '_self', ['class' => 'btn btn-success', 'icon' => 'fa fa-reply']);
     $grid->addRowAction($replyAction);
     $grid->isReadyForRedirect();
     return $grid->getGridResponse();
 }
Beispiel #17
0
 /**
  * Lists all Board entities.
  *
  */
 public function indexAction()
 {
     $journal = $this->get('ojs.journal_service')->getSelectedJournal();
     if (!$this->isGranted('VIEW', $journal, 'boards')) {
         throw new AccessDeniedException("You not authorized for view this journal's boards!");
     }
     $source = new Entity('OjsJournalBundle:Board');
     $ta = $source->getTableAlias();
     $source->manipulateQuery(function (QueryBuilder $query) use($ta, $journal) {
         $query->andWhere($ta . '.journal = :journal')->setParameter('journal', $journal);
     });
     $grid = $this->get('grid')->setSource($source);
     $gridAction = $this->get('grid_action');
     $actionColumn = new ActionsColumn("actions", 'actions');
     $rowAction[] = $gridAction->showAction('ojs_journal_board_show', ['id', 'journalId' => $journal->getId()]);
     if ($this->isGranted('EDIT', $journal, 'boards')) {
         $rowAction[] = $gridAction->editAction('ojs_journal_board_edit', ['id', 'journalId' => $journal->getId()]);
         $rowAction[] = $gridAction->deleteAction('ojs_journal_board_delete', ['id', 'journalId' => $journal->getId()]);
     }
     $actionColumn->setRowActions($rowAction);
     $grid->addColumn($actionColumn);
     $data = [];
     $data['grid'] = $grid;
     return $grid->getGridResponse('OjsJournalBundle:Board:index.html.twig', $data);
 }
 /**
  * Lists all new Article submissions entities.
  * @param  bool $all
  * @return Response
  */
 public function indexAction($all = false)
 {
     $translator = $this->get('translator');
     /** @var Journal $currentJournal */
     $currentJournal = $this->get('ojs.journal_service')->getSelectedJournal();
     if ($all && !$this->isGranted('VIEW', $currentJournal, 'articles') || !$all && !$this->isGranted('CREATE', $currentJournal, 'articles')) {
         return $this->redirect($this->generateUrl('ojs_user_index'));
     }
     $user = $this->getUser();
     $source1 = new Entity('OjsJournalBundle:Article', 'submission');
     $source1TableAlias = $source1->getTableAlias();
     $source2 = new Entity('OjsJournalBundle:ArticleSubmissionProgress');
     $source2TableAlias = $source2->getTableAlias();
     if ($all) {
         $source1->manipulateQuery(function (QueryBuilder $qb) use($source1TableAlias, $currentJournal) {
             $qb->where($source1TableAlias . '.status = 0');
             $qb->andWhere($source1TableAlias . '.journalId = ' . $currentJournal->getId());
             return $qb;
         });
         $source2->manipulateQuery(function (QueryBuilder $qb) use($source2TableAlias, $currentJournal) {
             $qb->where($source2TableAlias . '.submitted = 0');
             $qb->andWhere($source2TableAlias . '.journalId = ' . $currentJournal->getId());
             return $qb;
         });
     } else {
         $source1->manipulateQuery(function (QueryBuilder $qb) use($source1TableAlias, $user, $currentJournal) {
             $qb->where($qb->expr()->andX($qb->expr()->eq($source1TableAlias . '.submitterId', $user->getId())));
             $qb->andWhere($source1TableAlias . '.journalId = ' . $currentJournal->getId());
             return $qb;
         });
         $source2->manipulateQuery(function (QueryBuilder $qb) use($source2TableAlias, $user, $currentJournal) {
             $qb->where($source2TableAlias . '.submitted = 0');
             $qb->andWhere($source2TableAlias . '.journalId = ' . $currentJournal->getId());
             $qb->andWhere($source2TableAlias . '.userId = ' . $user->getId());
             return $qb;
         });
     }
     $gridManager = $this->get('grid.manager');
     $submissionsGrid = $gridManager->createGrid('submission');
     $drafts = $gridManager->createGrid('drafts');
     $source1->manipulateRow(function ($row) use($translator) {
         $row->setField('status', $translator->trans(ArticleParams::statusText($row->getField('status'))));
         return $row;
     });
     $submissionsGrid->setSource($source1);
     $drafts->setSource($source2);
     /** @var GridAction $gridAction */
     $gridAction = $this->get('grid_action');
     $submissionsGrid->addRowAction($gridAction->showAction('ojs_journal_article_show', ['id', 'journalId' => $currentJournal->getId()]));
     $submissionsGrid->addRowAction($gridAction->editAction('ojs_journal_article_edit', ['id', 'journalId' => $currentJournal->getId()]));
     $submissionsGrid->addRowAction($gridAction->deleteAction('ojs_journal_article_delete', ['id', 'journalId' => $currentJournal->getId()]));
     $rowAction = [];
     $actionColumn = new ActionsColumn("actions", 'actions');
     $rowAction[] = $gridAction->submissionResumeAction('article_submission_resume', 'id');
     $rowAction[] = $gridAction->deleteAction('article_submission_cancel', 'id');
     $actionColumn->setRowActions($rowAction);
     $drafts->addColumn($actionColumn);
     $data = ['page' => 'submission', 'submissions' => $submissionsGrid, 'drafts' => $drafts, 'all' => $all];
     return $gridManager->getGridManagerResponse('OjsJournalBundle:ArticleSubmission:index.html.twig', $data);
 }
 /**
  * Lists all new Article submissions entities.
  *
  * @param  Request                   $request
  * @param  bool                      $all
  * @return RedirectResponse|Response
  */
 public function indexAction(Request $request, $all = false)
 {
     $translator = $this->get('translator');
     /** @var Journal $currentJournal */
     $currentJournal = $this->get('ojs.journal_service')->getSelectedJournal();
     if ($all && !$this->isGranted('VIEW', $currentJournal, 'articles') || !$all && !$this->isGranted('CREATE', $currentJournal, 'articles')) {
         return $this->redirect($this->generateUrl('ojs_user_index'));
     }
     $user = $this->getUser();
     $source1 = new Entity('OjsJournalBundle:Article', 'submission');
     $source2 = new Entity('OjsJournalBundle:Article', 'submission');
     $source1TableAlias = $source1->getTableAlias();
     $source2TableAlias = $source2->getTableAlias();
     $source1->manipulateQuery(function (QueryBuilder $qb) use($source1TableAlias, $user, $currentJournal, $all) {
         $qb->andWhere($source1TableAlias . '.status IN (:notDraftStatuses)')->setParameter('notDraftStatuses', [ArticleStatuses::STATUS_REJECTED, ArticleStatuses::STATUS_UNPUBLISHED, ArticleStatuses::STATUS_INREVIEW, ArticleStatuses::STATUS_PUBLISHED]);
         if (!$all) {
             $qb->andWhere($source1TableAlias . '.submitterUser = :user')->setParameter('user', $user);
         }
         return $qb;
     });
     $source2->manipulateQuery(function (QueryBuilder $qb) use($source2TableAlias, $user, $currentJournal, $all) {
         $qb->andWhere($source2TableAlias . '.status = :status')->setParameter('status', ArticleStatuses::STATUS_NOT_SUBMITTED);
         if (!$all) {
             $qb->andWhere($source2TableAlias . '.submitterUser = :user')->setParameter('user', $user);
         }
     });
     $gridManager = $this->get('grid.manager');
     $submissionsGrid = $gridManager->createGrid('submission');
     $drafts = $gridManager->createGrid('drafts');
     $source1->manipulateRow(function (Row $row) use($translator, $currentJournal) {
         /** @var Article $entity */
         $entity = $row->getEntity();
         $entity->setDefaultLocale($currentJournal->getMandatoryLang()->getCode());
         $row->setField('status', $translator->trans($entity->getStatusText()));
         $row->setField('title', $entity->getTitle());
         return $row;
     });
     $source2->manipulateRow(function (Row $row) use($translator, $request) {
         $entity = $row->getEntity();
         /** @var Article $entity */
         $entity->setDefaultLocale($request->getDefaultLocale());
         $row->setField('status', $translator->trans($entity->getStatusText()));
         $row->setField('title', $entity->getTitle());
         return $row;
     });
     $submissionsGrid->setSource($source1);
     $drafts->setSource($source2);
     /** @var GridAction $gridAction */
     $gridAction = $this->get('grid_action');
     $rowAction = [];
     $actionColumn = new ActionsColumn("actions", 'actions');
     $rowAction[] = $gridAction->submissionResumeAction('ojs_journal_submission_edit', ['journalId' => $currentJournal->getId(), 'id']);
     $rowAction[] = $gridAction->submissionCancelAction('ojs_journal_submission_cancel', ['journalId' => $currentJournal->getId(), 'id']);
     $actionColumn->setRowActions($rowAction);
     $drafts->addColumn($actionColumn);
     $data = ['page' => 'submission', 'submissions' => $submissionsGrid, 'drafts' => $drafts, 'all' => $all];
     return $gridManager->getGridManagerResponse('OjsJournalBundle:ArticleSubmission:index.html.twig', $data);
 }
 /**
  * This action is used to show all receive notifications of current user
  *
  * @Route("/" , name = "show-receive")
  * @Route("/{code}" , name = "show-receive-with-code")
  * @Template()
  */
 public function showReceiveAction($code = null)
 {
     $user = $this->getUser();
     // get current user
     if (!$user) {
         throw $this->createNotFoundException("User Not Found, You must authenticate first ");
     }
     // use grid
     $noteGrid = $this->container->getParameter('tmcycyit_notification.note_grid');
     if ($noteGrid) {
         // adding actions
         $tr = $this->get('translator');
         // Creates a simple grid based on your entity (ORM)
         $source = new Entity('TmcycyitNotificationBundle:NotificationStatus');
         // create query
         $entity = $source->getTableAlias();
         $source->manipulateQuery(function ($query) use($entity, $user) {
             $query->andWhere($entity . '.toUser = '******'grid');
         // add checkbox with delete action
         $grid->addMassAction(new DeleteMassAction());
         $grid->setDefaultOrder('id', 'desc');
         $rowAction = new RowAction($tr->trans('delete', array(), 'note'), 'delete');
         $grid->addRowAction($rowAction);
         // Attach the source to the grid
         $grid->setSource($source);
         // adding exports
         $grid->addExport(new CSVExport('CSV', 'place_list'));
         $grid->addExport(new ExcelExport('Excel', 'place_list'));
         $grid->addExport(new PHPExcelPDFExport('PDF', 'place_list'));
         return $grid->getGridResponse('TmcycyitNotificationBundle:Main:showReceive.html.twig', array('noteGrid' => $noteGrid));
     } else {
         $em = $this->getDoctrine()->getManager();
         //get entity manager
         if ($code) {
             // return all receives notes, or null
             $receives = $em->getRepository(self::ENTITY)->findAllReceiveByUserIdAndCode($user->getId(), $code);
         } else {
             // return all receives notes, or null
             $receives = $em->getRepository(self::ENTITY)->findAllReceiveByUserId($user->getId());
         }
         // get pagination
         $paginator = $this->get('knp_paginator');
         //get count off notes in page
         $per_page = $this->container->getParameter('tmcycyit_notification.item_notes_page');
         //number of pages
         $pagination = $paginator->paginate($receives, $this->get('request')->query->get('page', 1), $per_page);
         //get note`s count, and set it in twig global
         $this->getNoteCount();
         $templates = $this->container->getParameter('tmcycyit_notification.templates.showReceive');
         // get templates name
         return $this->render($templates, array('receives' => $pagination));
     }
 }
Beispiel #21
0
 /**
  * @param Request $request
  * @param         $id
  *
  * @return Response
  */
 public function subscriptionsAction(Request $request, $id)
 {
     $list = $this->getDoctrine()->getRepository('OpiferMailingListBundle:MailingList')->find($id);
     $source = new Entity('OpiferMailingListBundle:Subscription');
     $tableAlias = $source->getTableAlias();
     $source->manipulateQuery(function ($qb) use($tableAlias, $id) {
         $qb->innerJoin($tableAlias . '.mailingList', 'm')->andWhere('m.id = :list_id')->setParameter('list_id', $id);
     });
     /* @var $grid \APY\DataGridBundle\Grid\Grid */
     $grid = $this->get('grid');
     $grid->setId('subscriptions_' . $id)->setSource($source);
     return $grid->getGridResponse('OpiferMailingListBundle:MailingList:subscriptions.html.twig', ['list' => $list]);
 }
 /**
  * List all identities
  *
  * @return Symfony\Component\HttpFoundation\Response
  */
 public function listAction()
 {
     if ($this->getParameter('asf_contact.secure_controller') !== false && false === $this->get('security.authorization_checker')->isGranted($this->getParameter('asf_contact.secure_controller'))) {
         throw new AccessDeniedException('You don\'t have permission to access this resource.');
     }
     // Initialize variables
     $view_options = array();
     $identityManager = $this->get('asf_contact.identity.manager');
     // Set Datagrid source
     $source = new Entity($identityManager->getClassName());
     $tableAlias = $source->getTableAlias();
     $source->manipulateQuery(function ($query) use($tableAlias) {
         $query instanceof QueryBuilder;
         if (count($query->getDQLPart('orderBy')) == 0) {
             $query->orderBy($tableAlias . '.name', 'ASC');
         }
     });
     // Get Grid instance
     $grid = $this->get('grid');
     $grid instanceof Grid;
     // Attach the source to the grid
     $grid->setSource($source);
     $grid->setId('asf_contact_identity');
     // Columns configuration
     $grid->hideColumns(array('id', 'updatedAt', 'createdAt'));
     $nameColumn = $grid->getColumn('name');
     $nameColumn->setTitle($this->get('translator')->trans('Name', array(), 'asf_contact'))->setDefaultOperator('like')->setOperatorsVisible(false);
     $emailColumn = $grid->getColumn('emailCanonical');
     $emailColumn->setTitle($this->get('translator')->trans('E-mail', array(), 'asf_contact'))->setDefaultOperator('like')->setOperatorsVisible(false);
     $stateColumn = $grid->getColumn('state');
     $stateColumn->setTitle($this->get('translator')->trans('State', array(), 'asf_contact'))->setSize(100)->setFilterType('select')->setDefaultOperator('like')->setOperatorsVisible(false)->setSelectFrom('values')->setValues(array(IdentityModel::STATE_ENABLED => $this->get('translator')->trans('Activated', array(), 'asf_contact'), IdentityModel::STATE_DISABLED => $this->get('translator')->trans('Deactivated', array(), 'asf_contact')));
     $editAction = new RowAction('btn_edit', 'asf_contact_identity_edit');
     $editAction->setRouteParameters(array('id'));
     $grid->addRowAction($editAction);
     $deleteAction = new RowAction('btn_delete', 'asf_contact_identity_delete', true);
     $deleteAction->setRouteParameters(array('id'))->setConfirmMessage($this->get('translator')->trans('Do you want to delete this identity ?', array(), 'asf_contact'));
     $grid->addRowAction($deleteAction);
     $typeColumn = $grid->getColumn('type');
     $typeColumn->setTitle($this->get('translator')->trans('Type', array(), 'asf_contact'))->setFilterType('select')->setDefaultOperator('eq')->setOperatorsVisible(false)->setSelectFrom('values')->setValues(array(IdentityModel::TYPE_PERSON => $this->get('translator')->trans('Person', array(), 'asf_contact'), IdentityModel::TYPE_ORGANIZATION => $this->get('translator')->trans('Organization', array(), 'asf_contact')))->manipulateRenderCell(function ($value, $row, $router) {
         if ($value == IdentityModel::TYPE_PERSON) {
             return $this->get('translator')->trans('Person', array(), 'asf_contact');
         } elseif ($value == IdentityModel::TYPE_ORGANIZATION) {
             return $this->get('translator')->trans('Organization', array(), 'asf_contact');
         }
     });
     $grid->setNoDataMessage($this->get('translator')->trans('No contact in the address book.', array(), 'asf_contact'));
     // Display grid
     return $grid->getGridResponse('ASFContactBundle:Identity:list.html.twig', $view_options);
 }
 /**
  * Lists all EventLogs
  *
  * @return mixed
  */
 public function indexAction()
 {
     $logTypes = EventLogParams::adminLevelEventLogs();
     $source = new Entity('OjsUserBundle:EventLog');
     $source->addHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Gedmo\\Translatable\\Query\\TreeWalker\\TranslationWalker');
     $tableAlias = $source->getTableAlias();
     $source->manipulateQuery(function (QueryBuilder $qb) use($tableAlias, $logTypes) {
         $expression = $qb->expr()->in($tableAlias . '.eventInfo', ':logTypes');
         $qb->andWhere($expression)->setParameters(['logTypes' => $logTypes]);
         return $qb;
     });
     $grid = $this->get('grid')->setSource($source);
     $gridAction = $this->get('grid_action');
     $actionColumn = new ActionsColumn("actions", "actions");
     $actionColumn->setRowActions([$gridAction->showAction('ojs_admin_event_log_show', 'id')]);
     $grid->addColumn($actionColumn);
     return $grid->getGridResponse('OjsAdminBundle:AdminEventLog:index.html.twig', ['grid' => $grid]);
 }
Beispiel #24
0
 /**
  * Lists all MailTemplate entities.
  *
  */
 public function indexAction()
 {
     $source = new Entity('OjsJournalBundle:MailTemplate');
     $tableAlias = $source->getTableAlias();
     $source->manipulateQuery(function ($query) use($tableAlias) {
         $query->andWhere($tableAlias . '.journal IS NULL');
     });
     $grid = $this->get('grid')->setSource($source);
     $gridAction = $this->get('grid_action');
     $actionColumn = new ActionsColumn("actions", 'actions');
     $rowAction[] = $gridAction->showAction('ojs_admin_mail_template_show', 'id');
     $rowAction[] = $gridAction->editAction('ojs_admin_mail_template_edit', 'id');
     $actionColumn->setRowActions($rowAction);
     $grid->addColumn($actionColumn);
     $data = [];
     $data['grid'] = $grid;
     return $grid->getGridResponse('OjsAdminBundle:AdminMailTemplate:index.html.twig', $data);
 }
 /**
  * Lists all MailTemplate entities.
  *
  * @return Response
  */
 public function indexAction()
 {
     $journal = $this->get('ojs.journal_service')->getSelectedJournal();
     if (!$this->isGranted('VIEW', $journal, 'mailTemplate')) {
         throw new AccessDeniedException("You are not authorized for view this page!");
     }
     $source = new Entity('OjsJournalBundle:MailTemplate');
     $source->addHint(Query::HINT_CUSTOM_OUTPUT_WALKER, 'Gedmo\\Translatable\\Query\\TreeWalker\\TranslationWalker');
     $source->manipulateRow(function (Row $row) {
         if ($row->getField("title") && strlen($row->getField('title')) > 20) {
             $row->setField('title', substr($row->getField('title'), 0, 20) . "...");
         }
         return $row;
     });
     $ta = $source->getTableAlias();
     $source->manipulateQuery(function (QueryBuilder $qb) use($journal, $ta) {
         return $qb->andWhere($ta . '.journal = :journal')->setParameter('journal', $journal);
     });
     $grid = $this->get('grid.manager');
     $gridAction = $this->get('grid_action');
     $db_templates = $grid->createGrid('db_templates');
     $db_templates->setSource($source);
     $actionColumn = new ActionsColumn("actions", 'actions');
     $rowAction = [];
     $rowAction[] = $gridAction->showAction('ojs_journal_mail_template_show', ['id', 'journalId' => $journal->getId()]);
     $rowAction[] = $gridAction->editAction('ojs_journal_mail_template_edit', ['id', 'journalId' => $journal->getId()]);
     $rowAction[] = $gridAction->deleteAction('ojs_journal_mail_template_delete', ['id', 'journalId' => $journal->getId()]);
     $actionColumn->setRowActions($rowAction);
     $db_templates->addColumn($actionColumn);
     $data = [];
     $data['db_templates'] = $db_templates;
     $yamlParser = new Parser();
     $defaultTemplates = $yamlParser->parse(file_get_contents($this->container->getParameter('kernel.root_dir') . '/../src/Ojs/JournalBundle/Resources/data/mailtemplates.yml'));
     $source = new Vector($defaultTemplates, [new NumberColumn(['id' => 'id', 'field' => 'id', 'title' => 'ID', 'source' => true]), new TextColumn(['id' => 'subject', 'field' => 'subject', 'title' => 'mailtemplate.subject', 'source' => true]), new TextColumn(['id' => 'lang', 'field' => 'lang', 'title' => 'mailtemplate.language', 'source' => true]), new TextColumn(['id' => 'type', 'field' => 'type', 'title' => 'mailtemplate.title', 'source' => true]), new TextColumn(['id' => 'template', 'field' => 'template', 'title' => 'mailtemplate.template', 'source' => true, 'visible' => false])]);
     $defaultTemplates = $grid->createGrid('default_templates');
     $defaultTemplates->setSource($source);
     $actionColumn = new ActionsColumn("actions", 'actions');
     $rowAction = [];
     $rowAction[] = $gridAction->copyAction('ojs_journal_mail_template_copy', ['id', 'journalId' => $journal->getId()]);
     $actionColumn->setRowActions($rowAction);
     $defaultTemplates->addColumn($actionColumn);
     $data['default_templates'] = $defaultTemplates;
     return $grid->getGridManagerResponse('OjsJournalBundle:MailTemplate:index.html.twig', $data);
 }
 /**
  * List all categories.
  *
  * @throws AccessDeniedException If authenticate user is not allowed to access to this resource (minimum ROLE_ADMIN)
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function listAction()
 {
     $this->get('event_dispatcher')->dispatch(ProductEvents::LIST_CATEGORIES, new Event());
     // Set Datagrid source
     $source = new Entity($this->getParameter('asf_product.category.entity'));
     $tableAlias = $source->getTableAlias();
     $user = $this->getUser();
     $source->manipulateQuery(function ($query) use($tableAlias, $user) {
         $query instanceof QueryBuilder;
         $states = array(CategoryModel::STATE_DRAFT, CategoryModel::STATE_WAITING, CategoryModel::STATE_PUBLISHED);
         if (in_array(UserRole::ROLE_SUPERADMIN, $user->getRoles())) {
             $states[] = CategoryModel::STATE_DELETED;
         }
         $query->add('where', $query->expr()->in($tableAlias . '.state', $states));
         if (count($query->getDQLPart('orderBy')) == 0) {
             $query->orderBy($tableAlias . '.name', 'ASC');
         }
     });
     // Get Grid instance
     $grid = $this->get('grid');
     $grid instanceof Grid;
     // Attach the source to the grid
     $grid->setSource($source);
     $grid->setId('asf_categories_list');
     $source->manipulateRow(function ($row) {
         if (CategoryModel::STATE_DELETED === $row->getField('state')) {
             $row->setClass('danger');
         } elseif (CategoryModel::STATE_WAITING === $row->getField('state')) {
             $row->setClass('info');
         } elseif (CategoryModel::STATE_DRAFT === $row->getField('state')) {
             $row->setClass('warning');
         }
         return $row;
     });
     // Columns configuration
     $editAction = new RowAction('btn_edit', 'asf_product_category_edit');
     $editAction->setRouteParameters(array('id'));
     $grid->addRowAction($editAction);
     $deleteAction = new RowAction('btn_delete', 'asf_product_category_delete', true);
     $deleteAction->setRouteParameters(array('id'))->setConfirmMessage($this->get('translator')->trans('asf.product.msg.delete.confirm', array('%name%' => $this->get('translator')->trans('asf.product.default_value.this_category'))));
     $grid->addRowAction($deleteAction);
     $grid->setNoDataMessage($this->get('translator')->trans('asf.product.msg.list.no_category', array(), 'asf_product'));
     return $grid->getGridResponse('ASFProductBundle:Category:list.html.twig');
 }
 /**
  * index.
  *
  * @param int $formId
  *
  * @return Response
  */
 public function indexAction($formId)
 {
     $form = $this->get('opifer.form.form_manager')->getRepository()->find($formId);
     if (!$form) {
         return $this->createNotFoundException();
     }
     $source = new Entity('OpiferCmsBundle:Post');
     $tableAlias = $source->getTableAlias();
     $source->manipulateQuery(function ($query) use($tableAlias, $form) {
         $query->andWhere($tableAlias . '.form = :form')->setParameter('form', $form);
     });
     $viewAction = new RowAction('view', 'opifer_form_post_view');
     $viewAction->setRouteParameters(['id']);
     $deleteAction = new RowAction('delete', 'opifer_form_post_delete');
     $deleteAction->setRouteParameters(['id']);
     $grid = $this->get('grid');
     $grid->setId('posts')->setSource($source)->addRowAction($viewAction)->addRowAction($deleteAction);
     return $grid->getGridResponse('OpiferCmsBundle:Backend/Post:index.html.twig', ['form' => $form]);
 }
 public function indexAction(Request $request)
 {
     $source = new Entity('OjsJournalBundle:Journal');
     $alias = $source->getTableAlias();
     $source->manipulateQuery(function (QueryBuilder $query) use($alias) {
         $query->andWhere($alias . '.status = :status')->setParameter('status', JournalStatuses::STATUS_APPLICATION);
         return $query;
     });
     $grid = $this->get('grid')->setSource($source);
     $gridAction = $this->get('grid_action');
     $rowAction = array();
     $rowAction[] = $gridAction->editAction('ojs_admin_application_journal_edit', 'id');
     $rowAction[] = $gridAction->showAction('ojs_admin_application_journal_show', 'id');
     $rowAction[] = $gridAction->contactsAction('ojs_journal_journal_contact_index');
     $actionColumn = new ActionsColumn("actions", 'actions');
     $actionColumn->setRowActions($rowAction);
     $grid->addColumn($actionColumn);
     $data['grid'] = $grid;
     return $grid->getGridResponse('OjsAdminBundle:AdminApplication:journal.html.twig', $data);
 }
Beispiel #29
0
 /**
  * {@inheritdoc}
  */
 public function sharedAction()
 {
     $this->getDoctrine()->getManager()->getFilters()->disable('draft');
     $source = new Entity('OpiferContentBundle:Block');
     $tableAlias = $source->getTableAlias();
     $source->manipulateQuery(function ($query) use($tableAlias) {
         $query->andWhere("{$tableAlias}.shared = 1")->andWhere("{$tableAlias}.content IS NULL")->andWhere("{$tableAlias}.template IS NULL");
     });
     //
     //        $idColumn = new NumberColumn(array('id' => 'id', 'field' => 'id', 'title' => 'label.id'));
     //        $nameColumn = new TextColumn(array('id' => 'name', 'field' => 'sharedName', 'title' => 'label.name'));
     //        $displayNameColumn = new TextColumn(array('id' => 'display_name', 'field' => 'sharedDisplayName', 'title' => 'label.display_name'));
     $editAction = new RowAction('button.edit', 'opifer_content_block_shared_edit');
     $editAction->setRouteParameters(['id']);
     $deleteAction = new RowAction('button.delete', 'opifer_content_block_delete');
     $deleteAction->setRouteParameters(['id']);
     /* @var $grid \APY\DataGridBundle\Grid\Grid */
     $grid = $this->get('grid');
     $grid->setId('blocks')->setSource($source)->setVisibleColumns(['id', 'sharedName', 'sharedDisplayName'])->addRowAction($editAction)->addRowAction($deleteAction);
     return $grid->getGridResponse('OpiferCmsBundle:Backend/Block:shared.html.twig');
 }
 /**
  * @Route("/contacts", name="contact_index")
  */
 public function indexAction(Request $request)
 {
     $source = new Entity('DashboardBundle:Contact');
     $grid = $this->get('grid');
     $grid->hideColumns(array('id'));
     $grid->addMassAction(new DeleteMassAction());
     $grid->setLimits($this->container->getParameter('admin.paginator.limits.config'));
     $tableAlias = $source->getTableAlias();
     $source->manipulateQuery(function ($query) use($tableAlias) {
         $idUser = $this->getUserAuthenticated()->getId();
         $query->leftJoin($tableAlias . '.user', 'u')->andWhere('u.id = ' . $idUser)->addOrderBy($tableAlias . '.id', 'DESC');
     });
     $grid->setSource($source);
     if ($request->isXmlHttpRequest()) {
         return $grid->getGridResponse('DashboardBundle:Contact:indexAjax.html.twig');
     }
     if ($grid->isReadyForRedirect()) {
         return new RedirectResponse($grid->getRouteUrl());
     }
     return $grid->getGridResponse('DashboardBundle:Contact:index.html.twig');
 }