示例#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
 /**
  * Assemble elements from the component and a Counter object and pass them along
  * to the view.
  */
 public function render()
 {
     $fields = $this->component->getFields();
     $selected = $fields->getVisibleFields()->getByQueryStringId($this->request->getQuery('group_field'));
     $counter = new Counter($selected, $fields, $this->component->getListing());
     $renderer = $this->view->csvCellRenderer();
     $this->component->setShouldRenderLayout(false);
     $this->view->assign(['title' => $this->component->getTitle(), 'selected' => $selected, 'fields' => $counter->buildRenderFields(), 'data' => $counter->fetchData($renderer), 'renderer' => $renderer]);
     return $this->renderView();
 }
示例#3
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();
 }
示例#4
0
 /**
  * Assemble elements from the component and a Counter object and pass them along
  * to the view.
  */
 public function render()
 {
     $fields = $this->component->getFields();
     $selected = null;
     $counter = null;
     $renderer = $this->view->tableCellRenderer();
     if ($this->request->getQuery('group_field')) {
         $selected = $fields->getVisibleFields()->getByQueryStringId($this->request->getQuery('group_field'));
         $counter = new Counter($selected, $fields, $this->component->getListing());
     }
     $this->view->assign(['title' => $this->component->getTitle(), 'model' => $this->component->getPrimaryModel(), 'fields' => $this->component->getFields(), 'listing' => $this->component->getListing(), 'renderer' => $renderer, 'selectedField' => $selected ? $selected->getQueryStringId() : null, 'countFields' => $counter ? $counter->buildRenderFields() : null, 'data' => $selected ? $counter->fetchData($renderer) : [], 'request' => $this->request]);
     return $this->renderView();
 }
示例#5
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();
 }
示例#6
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();
 }
示例#7
0
 /**
  * Save newly POSTed sort order for the listing.
  *
  * @param ResponseHelper $responseHelper
  */
 public function process(ResponseHelper $responseHelper)
 {
     if (!$this->request->isPost()) {
         $this->error = ['result' => 'error', 'message' => 'Must be POST.'];
         return;
     }
     if (!is_array($this->request->getPost('sort_order'))) {
         $this->error = ['result' => 'error', 'message' => 'sort_order array not available.'];
         return;
     }
     $listing = $this->component->getListing();
     $primaryKey = $listing->getPrimaryKey();
     $model = $primaryKey->getTable();
     $dbAdapter = $model->getAdapter();
     $sortField = $this->component->getSortField();
     foreach ($this->request->getPost('sort_order') as $index => $id) {
         try {
             $model->update(array($sortField->getName() => $index), $dbAdapter->quoteInto("{$primaryKey->getName()} = ?", $id));
         } catch (Exception $e) {
             $this->error = ['result' => 'error', 'message' => 'Failed to save.'];
         }
     }
 }
示例#8
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();
 }
示例#9
0
 public function renderAjaxResponse()
 {
     if (!$this->request->isPost() && !$this->request->isGet()) {
         return ['result' => 'error', 'message' => 'AJAX edit requests must be POST or GET'];
     } elseif ($this->request->isPost() && !$this->invalidSubmission) {
         return ['result' => 'success', 'id' => $this->component->getListing()->getPrimaryKey()->getValue(), 'data' => $this->getData()];
     } elseif ($this->request->isGet()) {
         return $this->renderAjaxForm();
     } else {
         $messages = [];
         foreach ($this->fields->getEditableFields() as $field) {
             $messages[$field->getHtmlId()] = $this->rowEditor->getMessages($field);
         }
         return ['result' => 'invalid', 'messages' => $messages];
     }
 }
 /**
  * Render a filter form for the provided CrudInterface admin component.
  *
  * @param CrudInterface $component
  * @return string
  */
 public function directWithComponent(CrudInterface $component)
 {
     return $this->directWithArgs($component->getFields()->getFilterableFields($component->getFieldGroupsFilter()), $component->getListing()->getSelectModifierByName('SelectFilter'), $component->getPrimaryModel()->getPluralTitle());
 }