diff --git a/includes/entity.ui.inc b/includes/entity.ui.inc index e30cff8..716fcf1 100644 --- a/includes/entity.ui.inc +++ b/includes/entity.ui.inc @@ -494,9 +494,7 @@ class EntityDefaultUIController { /** - * Controller for providing UI for entities with multiple bundles. - * - * Adds a bundle selection page to the entity/add path. + * Controller for providing UI for content entities. */ class EntityContentUIController extends EntityDefaultUIController { @@ -505,58 +503,54 @@ class EntityContentUIController extends EntityDefaultUIController { */ public function hook_menu() { $items = parent::hook_menu(); - $id_count = count(explode('/', $this->path)); - $wildcard = '%entity_object'; + $wildcard = isset($this->entityInfo['admin ui']['menu wildcard']) ? $this->entityInfo['admin ui']['menu wildcard'] : '%entity_object'; + + // Unset the manage entity path, as the provided UI is for admin entities. + unset($items[$this->path]); + $defaults = array( + 'file' => $this->entityInfo['admin ui']['file'], + 'file path' => isset($this->entityInfo['admin ui']['file path']) ? $this->entityInfo['admin ui']['file path'] : drupal_get_path('module', $this->entityInfo['module']), + ); + + // Add view, edit and delete menu items for content entities. $items[$this->path . '/' . $wildcard] = array( 'title callback' => 'entity_ui_get_page_title', - 'title arguments' => array('view', $this->entityType), + 'title arguments' => array('view', $this->entityType, $this->id_count), 'page callback' => 'entity_ui_entity_page_view', - 'page arguments' => array($id_count), + 'page arguments' => array($this->id_count), 'load arguments' => array($this->entityType), 'access callback' => 'entity_access', - 'access arguments' => array('view', $id_count), - 'file' => 'entity_ui.inc', - // todo: remove - // Copied over the following hack from user_menu() to avoid $path - // appearing in the breadcrumb: - // - // By assigning a different menu name, this item (and all registered - // child paths) are no longer considered as children of 'user'. When - // accessing the user account pages, the preferred menu link that is - // used to build the active trail (breadcrumb) will be found in this - // menu (unless there is more specific link), so the link to 'user' will - // not be in the breadcrumb. - 'menu_name' => 'navigation', - ); + 'access arguments' => array('view', $this->entityType, $this->id_count), + ) + $defaults; $items[$this->path . '/' . $wildcard . '/view'] = array( 'title' => 'View', 'type' => MENU_DEFAULT_LOCAL_TASK, 'load arguments' => array($this->entityType), 'weight' => -10, - ); + ) + $defaults; $items[$this->path . '/' . $wildcard . '/edit'] = array( 'page callback' => 'entity_ui_get_form', - 'page arguments' => array($this->entityType, $id_count), + 'page arguments' => array($this->entityType, $this->id_count), 'load arguments' => array($this->entityType), 'access callback' => 'entity_access', - 'access arguments' => array('edit', $id_count), + 'access arguments' => array('edit', $this->entityType), 'title' => 'Edit', 'type' => MENU_LOCAL_TASK, 'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE, - 'file' => 'entity_ui.inc', - ); + ) + $defaults; $items[$this->path . '/' . $wildcard . '/delete'] = array( 'page callback' => 'drupal_get_form', - 'page arguments' => array('profile2_page_delete_confirm_form', $id_count), + 'page arguments' => array($this->entityType . '_operation_form', $this->entityType, $this->id_count, 'delete'), 'load arguments' => array($this->entityType), 'access callback' => 'entity_access', - 'access arguments' => array('delete', $id_count), + 'access arguments' => array('delete', $this->entityType, $this->id_count), 'title' => 'Delete', 'type' => MENU_LOCAL_TASK, 'context' => MENU_CONTEXT_INLINE, - 'file' => 'entity_ui.inc', - ); + 'file' => $this->entityInfo['admin ui']['file'], + 'file path' => isset($this->entityInfo['admin ui']['file path']) ? $this->entityInfo['admin ui']['file path'] : drupal_get_path('module', $this->entityInfo['module']), + ) + $defaults; return $items; } @@ -673,6 +667,8 @@ function entity_ui_controller_form_submit($form, &$form_state) { function entity_ui_get_page_title($op, $entity_type, $entity = NULL) { $label = entity_label($entity_type, $entity); switch ($op) { + case 'view': + return $label; case 'edit': return t('Edit @label', array('@label' => $label)); case 'clone': @@ -741,7 +737,15 @@ function theme_entity_ui_overview_item($variables) { return $output; } - +/** + * Page callback for viewing an entity. + * + * @param Entity $entity + * The entity to be rendered. + * + * @return array + * A renderable array of the entity in full view mode. + */ function entity_ui_entity_page_view($entity) { return $entity->view('full'); }