public function getTitle() { if (!$this->title) { $this->title = $this->component->getTitle(); } return $this->title; }
/** * On POST requests, save the new settings to the filter, set a success * message and redirect back to the component's listing. * * @param ResponseHelper $responseHelper */ public function process(ResponseHelper $responseHelper) { if ($this->request->isPost()) { $responseHelper->run('save', function () { $this->filter->save(json_decode($this->request->getPost('sorted_fields'), true)); }); $responseHelper->setSuccessMessage("Successfully sorted and grouped {$this->component->getTitle()} fields")->redirectToAdminPage('index'); } }
/** * 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(); }
/** * 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(); }
/** * Provide the component that these permissions should be applied to. * * @param mixed $component * @param null|bool $debug * @throws Exception */ public function __construct($component, $debug = null) { if (!$component instanceof ComponentInterface && !$component instanceof CrudInterface) { throw new Exception('Component must be CopmonentInterface or implement CrudInterface'); } $this->component = $component; $this->debug = null === $debug ? Pimple::getResource('debug') : $debug; $this->register('access', 'Allow access to the ' . $this->component->getTitle() . ' component')->set('access', true); $this->register('display-menu', 'Show the ' . $this->component->getTitle() . ' component in the menu')->set('display-menu', true); if ($this->component instanceof CrudInterface) { $this->registerAndSetDefaultsForCrudInterface($this->component); } }
public function render() { $handler = $this->component->getActivityLogHandler(); $currentPage = $this->request->getQuery('listing-page', 1); $criteria = ['handlers' => $handler, 'limit' => $this->pageSize, 'offset' => ($currentPage - 1) * $this->pageSize]; if ($this->request->getQuery('id')) { $entity = $handler->createEntity($this->request->getQuery('id')); $criteria['entities'] = $entity; $this->view->assign('entity', $entity); } $entries = $this->getActivityLog()->getEntries($criteria); $this->view->assign('entries', $entries)->assign('title', $this->component->getTitle())->assign('entryCount', $entries->getTotalCount())->assign('pageSize', $this->pageSize)->assign('currentPage', $currentPage); }
/** * 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'])); }
public function render() { $this->view->assign(['title' => $this->component->getTitle(), 'model' => $this->component->getPrimaryModel(), 'dataCopier' => $this->component->getDataCopier()]); }
/** * Registering a component in WordPress means registering a handler * for a hook. Typically, add_object_page is used, but that implies * an entry in the top-level admin menu. Because we want to support * components that don't appear in the menu, we check the display-menu * permission here and then use add_submenu_page() with no slug to * get our callback over to WP without displaying anything in the * menu. * * @param ComponentAbstract $component * @throws \Dewdrop\Exception */ protected function registerComponentHandlingCallback(ComponentAbstract $component) { if ($component->getPermissions()->can('display-menu')) { $this->addObjectPage($component->getTitle(), $component->getTitle(), 'add_users', $component->getSlug(), function () use($component) { $this->renderOutputIntoShell($component); }, $component->getIcon(), $component->getMenuPosition()); } else { $this->addSubmenuPage(null, $component->getTitle(), $component->getTitle(), 'add_users', $component->getSlug(), function () use($component) { $this->renderOutputIntoShell($component); }); } }