/** * Define singular name translatable * @return string Singular name */ public function singular_name() { if (_t('Tag.SINGULARNAME')) { return _t('Tag.SINGULARNAME'); } else { return parent::singular_name(); } }
function doDelete($data, $form) { try { $toDelete = $this->record; if (!$toDelete->canDelete()) { throw new ValidationException(_t('GridFieldDetailForm.DeletePermissionsFailure', "No delete permissions"), 0); } $toDelete->delete(); } catch (ValidationException $e) { $form->sessionMessage($e->getResult()->message(), 'bad'); return Controller::curr()->redirectBack(); } $message = sprintf(_t('GridFieldDetailForm.Deleted', 'Deleted %s %s'), $this->record->singular_name(), '<a href="' . $this->Link('edit') . '">"' . htmlspecialchars($this->record->Title, ENT_QUOTES) . '"</a>'); $form->sessionMessage($message, 'good'); //when an item is deleted, redirect to the revelant admin section without the action parameter $controller = Controller::curr(); $noActionURL = $controller->removeAction($data['url']); $controller->getRequest()->addHeader('X-Pjax', 'Content'); // Force a content refresh return $controller->redirect($noActionURL, 302); //redirect back to admin section }
/** * CMS-specific functionality: Passes through navigation breadcrumbs * to the template, and includes the currently edited record (if any). * see {@link LeftAndMain->Breadcrumbs()} for details. * * @param boolean $unlinked * @return ArrayData */ function Breadcrumbs($unlinked = false) { if (!$this->popupController->hasMethod('Breadcrumbs')) { return; } $items = $this->popupController->Breadcrumbs($unlinked); if ($this->record && $this->record->ID) { $items->push(new ArrayData(array('Title' => $this->record->Title, 'Link' => $this->Link()))); } else { $items->push(new ArrayData(array('Title' => sprintf(_t('GridField.NewRecord', 'New %s'), $this->record->singular_name()), 'Link' => false))); } return $items; }