Esempio n. 1
0
 public function getSingularTitle()
 {
     if (!$this->singularTitle) {
         $this->singularTitle = $this->component->getPrimaryModel()->getSingularTitle();
     }
     return $this->singularTitle;
 }
Esempio n. 2
0
 /**
  * Setup notification fields and pass various dependencies to the View.
  */
 public function render()
 {
     $gateway = new NotificationGateway($this->component->getDb());
     $select = $gateway->selectByComponent($this->component->getFullyQualifiedName());
     $fields = $gateway->buildFields($this->component->url('notification-edit'), $this->component->getFields());
     $this->view->assign(['fields' => $fields, 'listing' => new Listing($select, $gateway->field('dewdrop_notification_subscription_id')), 'component' => $this->component, 'componentModel' => $this->component->getPrimaryModel()]);
     return $this->renderView();
 }
Esempio n. 3
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();
 }
Esempio n. 4
0
 public function getPrimaryRowName()
 {
     if (!$this->primaryRowName) {
         $this->primaryRowName = $this->component->getPrimaryModel()->getTableName();
     }
     return $this->primaryRowName;
 }
Esempio n. 5
0
 protected function logActivity(RowEditor $rowEditor)
 {
     $model = $this->component->getPrimaryModel();
     $rows = $rowEditor->getRows();
     $id = null;
     /* @var $row \Dewdrop\Db\Row */
     foreach ($rows as $row) {
         if ($row->getTable() === $model) {
             $id = $row->get(current($model->getPrimaryKey()));
         }
     }
     if ($id) {
         /* @var $handler \Dewdrop\ActivityLog\Handler\CrudHandlerAbstract */
         $handler = $this->component->getActivityLogHandler();
         $handler->restore($id);
     }
 }
 /**
  * Render the nav for the provided component.
  *
  * @param ComponentAbstract $component
  * @return string
  */
 public function direct(ComponentAbstract $component, array $options = [])
 {
     if ($component instanceof CrudInterface) {
         $singularTitle = $component->getPrimaryModel()->getSingularTitle();
     } else {
         $singularTitle = $component->getTitle();
     }
     if ($component instanceof CrudInterface) {
         $pluralTitle = $component->getPrimaryModel()->getPluralTitle();
     } else {
         $pluralTitle = $component->getTitle();
     }
     if (!isset($options['createUrl'])) {
         $options['createUrl'] = null;
     }
     return $this->partial('admin-component-nav.phtml', array('permissions' => $component->getPermissions(), 'singularTitle' => $singularTitle, 'pluralTitle' => $pluralTitle, 'createUrl' => $options['createUrl']));
 }
Esempio n. 7
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();
 }
Esempio n. 8
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();
 }
Esempio n. 9
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();
 }
Esempio n. 10
0
 public function render()
 {
     $this->view->assign(['title' => $this->component->getTitle(), 'model' => $this->component->getPrimaryModel(), 'dataCopier' => $this->component->getDataCopier()]);
 }
Esempio n. 11
0
 /**
  * Pass dependencies into the View.
  */
 public function render()
 {
     $this->view->assign(['component' => $this->component, 'componentModel' => $this->component->getPrimaryModel(), 'fields' => $this->fields, 'rowEditor' => $this->rowEditor, 'breadcrumbTitle' => $this->rowEditor->isNew() ? 'Add' : 'Edit']);
     return $this->renderView();
 }
Esempio n. 12
0
 protected function getModel()
 {
     return $this->component->getPrimaryModel();
 }