summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoachim Noreiko2013-04-21 08:36:08 (GMT)
committer Joachim Noreiko2013-04-21 08:36:08 (GMT)
commit7f60269be13eaef3dcd62d1eb79dc42a5deee5d5 (patch)
treec996e8dfe8476d8a08f19f3ddb0e524b72ba8675
parent8357b3a37b36249cf5d9afcb5478777aea79d997 (diff)
by joachim: Added support for secondary tabs.
-rw-r--r--entity_operations.api.php12
-rwxr-xr-xincludes/entity.operations.inc35
2 files changed, 45 insertions, 2 deletions
diff --git a/entity_operations.api.php b/entity_operations.api.php
index 46f5256..7a5f23f 100644
--- a/entity_operations.api.php
+++ b/entity_operations.api.php
@@ -74,6 +74,18 @@ function entity_operations_hook_entity_info() {
* one operation may be the default. This causes it to respond to the
* base URI of the entity, ie 'base_path/%wildcard'. For nodes, the
* 'view' operation would be the default.
+ * - 'default secondary': (optional) If the operation name contains a
+ * '/', the setting this to TRUE causes this operation to be the
+ * default in the secondary tab set implicitly formed by the first
+ * part of the name. For example, 'foo/bar' and 'foo/biz' form a
+ * secondary tab set at the subpath 'foo', and one of the two should
+ * be marked as default secondary, so that it is output at 'foo' (and
+ * thus there should be no operation defined for 'foo').
+ * Note that it is possible for one such secondary item to also be
+ * marked as 'default', in which case the entity URI will output it.
+ * - 'parent tab title': (optional) Can be set on a secondary-level
+ * operation which has 'default' set to define the tab title for the
+ * containing primary-level tab that is automatically created.
* - 'menu item': (optional) An array of properties suitable for
* hook_menu(), to use for this operation's menu item. These override
* those provided by the handler.
diff --git a/includes/entity.operations.inc b/includes/entity.operations.inc
index 80f1790..c09948d 100755
--- a/includes/entity.operations.inc
+++ b/includes/entity.operations.inc
@@ -79,7 +79,7 @@ class EntityOperationsDefaultUIController {
$menu_item += array(
'title' => $title,
- 'type' => isset($operation_definition['provision']['menu']['default']) ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK,
+ 'type' => MENU_LOCAL_TASK,
'load arguments' => array($this->entityType),
'weight' => $this->weight,
// Very rarely, handlers may wish to set this (such as 'add'), so we
@@ -97,14 +97,45 @@ class EntityOperationsDefaultUIController {
// Increase the weight for the next menu item.
$this->weight++;
+ // Handle default tabs.
// The default operation also gets to be the parent tab.
if (!empty($operation_definition['provision']['menu']['default'])) {
+ // Copy the item to make the base item.
$base_item = $menu_item;
- $base_item['title'] = 'View'; // Won't get used.
+
+ // The item itself is made the default tab.
+ $items[$path]['type'] = MENU_DEFAULT_LOCAL_TASK;
+
+ $base_item['title'] = 'View'; // Won't get used. TODO
$base_item['type'] = MENU_NORMAL_ITEM;
$items[$this->base_path] = $base_item;
}
+
+ // Secondary parent tabs, which are themselves a primary tab.
+ if (!empty($operation_definition['provision']['menu']['default secondary'])) {
+ // Copy the item to make the base item.
+ $base_item = $menu_item;
+
+ // The item itself is made the default tab.
+ $items[$path]['type'] = MENU_DEFAULT_LOCAL_TASK;
+
+ list($root, ) = explode('/', $operation_path);
+ $expected_parent_path = $this->base_path . '/' . $root;
+
+ // The parent item takes the default tab's title, unless something else
+ // is specified in the operation definition.
+ if (!empty($operation_definition['provision']['menu']['parent tab title'])) {
+ $base_item['title'] = $operation_definition['provision']['menu']['parent tab title'];
+ }
+
+ // The base item can itself be a default tab in the primary tabs.
+ if (!empty($operation_definition['provision']['menu']['default'])) {
+ $base_item['type'] = MENU_DEFAULT_LOCAL_TASK;
+ }
+
+ $items[$expected_parent_path] = $base_item;
+ }
}
return $items;