示例#1
0
 /**
  * Get the processed SQL statement from the Listing, pretty print it, and
  * pass it to our view script.
  */
 public function render()
 {
     $this->component->getPermissions()->haltIfNotAllowed('debug');
     $select = $this->component->getListing()->getModifiedSelect($this->component->getFields());
     $this->view->formattedSql = SqlFormatter::format((string) $select);
     return $this->renderView();
 }
示例#2
0
 /**
  * Pass all the component's fields to the view so we can render a grid
  * of information about them.
  */
 public function render()
 {
     $this->component->getPermissions()->haltIfNotAllowed('debug');
     $this->view->displayFields = new Fields();
     $this->view->componentFields = $this->component->getFields();
     return $this->renderView();
 }
示例#3
0
 /**
  * Ensure the component implements the SortableListingInterface and that the
  * user is allowed to access the listing for the component.
  *
  * @throws Exception
  */
 public function init()
 {
     $this->component->getPermissions()->haltIfNotAllowed('view-listing');
     if (!$this->component instanceof SortableListingInterface) {
         throw new Exception('Component must implement SortableListingInterface');
     }
 }
 /**
  * Ensure the user has permissions to work with notifications in this component
  * and setup Fields and RowEditor objects.
  */
 public function init()
 {
     $this->component->getPermissions()->haltIfNotAllowed('notifications');
     $gateway = new NotificationGateway($this->component->getDb());
     $this->fields = $gateway->buildFields($this->component->url('notification-edit'), $this->component->getFields());
     $this->rowEditor = new RowEditor($this->fields, $this->request);
     $this->rowEditor->linkByQueryString('dewdrop_notification_subscriptions', 'dewdrop_notification_subscription_id');
     $this->rowEditor->link();
 }
示例#5
0
 /**
  * Ensure permissions are correctly set and then pass the component
  * along to the view.
  */
 public function render()
 {
     $this->component->getPermissions()->haltIfNotAllowed('export');
     $filters = [];
     if ($this->enableVisibilityFilter) {
         $filters[] = $this->getVisibilityFilter();
     }
     $filters[] = $this->component->getFieldGroupsFilter();
     $this->view->assign('component', $this->component)->assign('filters', $filters);
     return $this->renderView();
 }
示例#6
0
 /**
  * Grab the selected visible columns from POST and save them back to
  * the visibility filter.
  *
  * @param ResponseHelper $responseHelper
  */
 public function process(ResponseHelper $responseHelper)
 {
     $this->component->getPermissions()->haltIfNotAllowed('adjust-columns');
     $selections = $this->request->getPost('visible_columns');
     $applyToAllUsers = (bool) $this->request->getPost('apply_to_all_users', false);
     if (is_array($selections)) {
         /* @var $filter VisibilityFilter */
         $filter = $this->component->getVisibilityFilter();
         $filter->save($this->component->getFields(), $selections, $applyToAllUsers);
     }
     $responseHelper->redirectToAdminPage('index');
 }
示例#7
0
 /**
  * Perform the actual tests using a ListingSortTest object and pass the
  * results to our view for rendering.
  */
 public function render()
 {
     $this->component->getPermissions()->haltIfNotAllowed('debug');
     $tester = new ListingSortTest($this->component->getFields(), $this->component->getListing());
     $reflection = new ReflectionClass($this->component);
     $this->view->namespace = $reflection->getNamespaceName();
     $this->view->component = $this->component;
     $this->view->results = $tester->run();
     $this->view->displayFields = new Fields();
     $this->view->componentFields = $this->component->getFields();
     return $this->renderView();
 }
 public function render()
 {
     $this->component->getPermissions()->haltIfNotAllowed('create');
     $renderer = $this->view->editControlRenderer();
     $rowEditor = $this->component->getRowEditor();
     $field = $this->component->getFields()->get($this->request->getQuery('field'));
     $value = $this->request->getQuery('value');
     $rowEditor->link();
     if ($field instanceof ManyToManyField) {
         $field->setValue([$value]);
     } else {
         $field->setValue($value);
     }
     $this->component->setShouldRenderLayout(false);
     return $renderer->getControlRenderer()->render($field, 0);
 }
示例#9
0
 /**
  * Ensure the user has permission to create or edit records on this CRUD
  * component.
  */
 protected function checkPermissions()
 {
     if ($this->isNew) {
         $this->component->getPermissions()->haltIfNotAllowed('create');
     } else {
         $this->component->getPermissions()->haltIfNotAllowed('edit');
     }
 }
示例#10
0
 /**
  * Pass a bunch of dependencies to the View.
  */
 public function render()
 {
     $listing = $this->component->getListing();
     $id = $this->request->getQuery($listing->getPrimaryKey()->getName());
     $fields = $this->component->getFields()->getVisibleFields();
     $data = $this->component->getListing()->fetchRow($fields, $id);
     $primaryKey = $this->component->getPrimaryModel()->getPrimaryKey();
     $params = array();
     foreach ($primaryKey as $field) {
         $params[$field] = $this->request->getQuery($field);
     }
     $this->view->assign(['params' => $params, 'fields' => $fields, 'singularTitle' => $this->component->getPrimaryModel()->getSingularTitle(), 'data' => $data, 'id' => $id, 'groupingFilter' => $this->component->getFieldGroupsFilter(), 'permissions' => $this->component->getPermissions(), 'isAjax' => $this->request->isAjax()]);
     // When requested over XHR, turn off the layout (admin shell chrome)
     if ($this->request->isAjax()) {
         $this->component->setShouldRenderLayout(false);
     }
     return $this->renderView();
 }
示例#11
0
 /**
  * Pass a whole log of stuff into the view.
  */
 public function render()
 {
     $fields = $this->component->getFields();
     $listing = $this->component->getListing();
     $filter = $this->component->getVisibilityFilter();
     $this->view->assign(['component' => $this->component, 'permissions' => $this->component->getPermissions(), 'singularTitle' => $this->component->getPrimaryModel()->getSingularTitle(), 'pluralTitle' => $this->component->getPrimaryModel()->getPluralTitle(), 'listing' => $listing, 'visibilityFilter' => $filter, 'groupingFilter' => $this->component->getFieldGroupsFilter(), 'fields' => $fields, 'debug' => Pimple::getResource('debug'), 'isSortable' => $this->component instanceof SortableListingInterface, 'page' => $this, 'createUrl' => $this->getCreateUrl()]);
     if ($this->component instanceof BulkActionProcessorInterface) {
         $this->view->assign(['bulkActions' => $this->component->getBulkActions(), 'bulkActionFailureMessage' => $this->bulkActionFailureMessage]);
     }
     return $this->renderView();
 }
示例#12
0
 /**
  * Ensure the user has permission to create or edit records on this CRUD
  * component.
  */
 protected function checkPermissions()
 {
     if ($this->isNew) {
         $this->component->getPermissions()->haltIfNotAllowed('create');
     } else {
         $this->component->getPermissions()->haltIfNotAllowed('edit');
     }
     if ($this->rowEditor->isDeleted()) {
         $this->component->getPermissions()->haltIfNotAllowed('restore');
     }
 }
示例#13
0
 /**
  * Pass a bunch of dependencies to the View.
  */
 public function render()
 {
     $listing = $this->component->getListing();
     $id = $this->request->getQuery($listing->getPrimaryKey()->getName());
     $fields = $this->component->getFields()->getVisibleFields();
     if ($this->component->getPermissions()->can('restore') && $listing->hasSelectModifier('SelectDeletedRecords')) {
         /* @var $deletedRecordsModifier \Dewdrop\Fields\Helper\SelectDeletedRecords */
         $deletedRecordsModifier = $listing->getSelectModifierByName('SelectDeletedRecords');
         $deletedRecordsModifier->disable();
     }
     $data = $listing->fetchRow($fields, $id);
     $primaryKey = $this->component->getPrimaryModel()->getPrimaryKey();
     $params = array();
     foreach ($primaryKey as $field) {
         $params[$field] = $this->request->getQuery($field);
     }
     $this->view->assign(['params' => $params, 'fields' => $fields, 'singularTitle' => $this->component->getPrimaryModel()->getSingularTitle(), 'data' => $data, 'id' => $id, 'groupingFilter' => $this->component->getFieldGroupsFilter(), 'permissions' => $this->component->getPermissions(), 'isAjax' => $this->request->isAjax()]);
     // When requested over XHR, turn off the layout (admin shell chrome)
     if ($this->request->isAjax()) {
         $this->component->setShouldRenderLayout(false);
     }
     return $this->renderView();
 }
示例#14
0
 /**
  * Ensure the user has permission to access the counts page on this component.
  */
 public function init()
 {
     $this->component->getPermissions()->haltIfNotAllowed('count-fields');
 }
示例#15
0
 /**
  * Ensure the user has the permission to delete records in this component.
  */
 public function init()
 {
     $this->component->getPermissions()->haltIfNotAllowed('restore');
 }
示例#16
0
 /**
  * Ensure the user is allowed to use the notifications feature on this
  * component.
  */
 public function init()
 {
     $this->component->getPermissions()->haltIfNotAllowed('notifications');
 }
示例#17
0
 /**
  * Ensure the user is allowed to sort fields on this component.
  */
 public function init()
 {
     $this->component->getPermissions()->haltIfNotAllowed('sort-fields');
     $this->filter = $this->component->getFieldGroupsFilter();
 }