public function getSingularTitle() { if (!$this->singularTitle) { $this->singularTitle = $this->component->getPrimaryModel()->getSingularTitle(); } return $this->singularTitle; }
/** * 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(); }
/** * 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(); }
public function getPrimaryRowName() { if (!$this->primaryRowName) { $this->primaryRowName = $this->component->getPrimaryModel()->getTableName(); } return $this->primaryRowName; }
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); } }
/** * 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(); }
/** * 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(); }
/** * 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(); }
/** * Register a number of permissions that we make available on CrudInterface * components. * * @param CrudInterface $component * @return $this */ public function registerAndSetDefaultsForCrudInterface(CrudInterface $component) { $plural = strtolower($component->getPrimaryModel()->getPluralTitle()); $singular = strtolower($component->getPrimaryModel()->getSingularTitle()); $crudPermissions = array('adjust-columns' => 'Adjust the columns that are visible on the main listing', 'create' => "Create new {$plural}", 'delete' => "Delete {$plural}", 'custom-views' => 'Create and edit custom views', 'debug' => 'Use debugging tools', 'edit' => "Edit existing {$plural}", 'export' => 'Export data to a file', 'filter' => "Filter {$plural}", 'import' => 'Import data from a file', 'count-fields' => "Count {$plural} while grouping by fields", 'restore' => "Restore deleted {$plural}", 'sort-fields' => "Sort and group {$singular} fields", 'notifications' => "Subscribe to be notified when {$plural} are added or updated", 'view' => "See an individual {$singular} in detail", 'view-activity' => 'View recent activity', 'view-listing' => "See the full {$plural} listing"); foreach ($crudPermissions as $name => $description) { $this->register($name, $description)->set($name, true); } // These features are disabled by default. Can be turned on whenever they're wanted. $this->set('count-fields', false); $this->set('import', false); $this->set('restore', false); $this->set('view-activity', false); // @ todo Re-enable these pages once they're complete $this->set('custom-views', false); $this->set('notifications', false); $this->set('debug', $this->debug); return $this; }
public function render() { $this->view->assign(['title' => $this->component->getTitle(), 'model' => $this->component->getPrimaryModel(), 'dataCopier' => $this->component->getDataCopier()]); }
/** * 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(); }
/** * 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()); }
protected function getModel() { return $this->component->getPrimaryModel(); }