示例#1
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()->createQueryBuilder('c')->select('c', 'vs', 'v', 'a')->leftJoin('c.valueSet', 'vs')->leftJoin('vs.values', 'v')->leftJoin('v.attribute', 'a');
     $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);
     });
     $designAction = new RowAction('button.design', 'opifer_content_contenteditor_design');
     $designAction->setRouteParameters(['id', 'owner' => 'content']);
     $designAction->setRouteParametersMapping(['id' => 'ownerId']);
     $detailsAction = new RowAction('button.details', 'opifer_content_content_edit');
     $detailsAction->setRouteParameters(['id']);
     //$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($detailsAction)->addRowAction($designAction);
     //->addRowAction($deleteAction)
     foreach ($contentType->getSchema()->getAttributes() as $attribute) {
         $name = $attribute->getName();
         $column = new AttributeColumn(['id' => $name, 'field' => 'valueSet.values.value', 'title' => $attribute->getDisplayName(), 'visible' => false, 'attribute' => $name, 'source' => true]);
         $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]);
 }
示例#2
0
 /**
  * @return Response
  */
 public function indexAction()
 {
     $source = new Entity('OpiferContentBundle:Template');
     $editAction = new RowAction('button.edit', 'opifer_cms_template_edit');
     $editAction->setRouteParameters(['id']);
     $deleteAction = new RowAction('button.delete', 'opifer_cms_template_delete');
     $deleteAction->setRouteParameters(['id']);
     $designAction = new RowAction('button.design', 'opifer_content_contenteditor_design');
     $designAction->setRouteParameters(['owner' => 'template', 'id']);
     $designAction->setRouteParametersMapping(['id' => 'ownerId']);
     $grid = $this->get('grid');
     /* @var $grid \APY\DataGridBundle\Grid\Grid */
     $grid->setId('templates')->setSource($source)->addRowAction($editAction)->addRowAction($deleteAction)->addRowAction($designAction);
     return $grid->getGridResponse('OpiferCmsBundle:Backend/Template:index.html.twig');
 }
示例#3
0
 /**
  * @param string $route
  * @param $key
  * @param  null      $role
  * @return RowAction
  */
 public function submissionResumeAction($route, $key = 'id')
 {
     $rowAction = new RowAction('<i class="fa fa-reply"></i>', $route);
     $rowAction->setAttributes(['class' => 'btn btn-warning btn-xs  ', 'data-toggle' => 'tooltip', 'title' => $this->translator->trans('ojs.back_and_edit')]);
     $rowAction->setRouteParameters($key);
     $rowAction->setRouteParametersMapping(['id' => 'id']);
     return $rowAction;
 }
示例#4
0
文件: GridAction.php 项目: ojs/ojs
 /**
  * @param string $route
  * @param $key
  * @return RowAction
  */
 public function filesAction($route, $key = 'id')
 {
     $rowAction = new RowAction('<i class="fa fa-files-o"></i>', $route);
     $rowAction->setAttributes(['class' => 'btn btn-primary btn-xs ', 'data-toggle' => 'tooltip', 'title' => $this->translator->trans('title.issue_files')]);
     $rowAction->setRouteParameters($key);
     $rowAction->setRouteParametersMapping(['id' => 'issueId']);
     return $rowAction;
 }