From 81534f367e1a57d9985dcbac26a1fedf36184c5d Mon Sep 17 00:00:00 2001
From: Chris Skene <chris@xtfer.com>
Date: Wed, 20 Feb 2013 17:07:39 +1100
Subject: [PATCH] Issue #1922064 by xtfer: Fixed Export UI menu paths longer
 than one item fail.

---
 includes/export-ui.inc | 33 +++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)

diff --git a/includes/export-ui.inc b/includes/export-ui.inc
index 16e57d6..b18902b 100644
--- a/includes/export-ui.inc
+++ b/includes/export-ui.inc
@@ -109,6 +109,7 @@ function ctools_export_ui_process(&$plugin, $info) {
   );
   $base_path = ctools_export_ui_plugin_base_path($plugin);
   $prefix_count = count(explode('/', $plugin['menu']['menu prefix']));
+  $arg_count = $prefix_count + count(explode('/', $plugin['menu']['menu item'])) + 1;
 
   $plugin['menu'] += array(
     // Default menu items that should be declared.
@@ -162,10 +163,10 @@ function ctools_export_ui_process(&$plugin, $info) {
   $plugin['menu']['items']['edit callback'] += array(
     'path' => 'list/%ctools_export_ui',
     'page callback' => 'ctools_export_ui_switcher_page',
-    'page arguments' => array($plugin['name'], 'edit', $prefix_count + 2),
+    'page arguments' => array($plugin['name'], 'edit', $arg_count),
     'load arguments' => array($plugin['name']),
     'access callback' => 'ctools_export_ui_task_access',
-    'access arguments' => array($plugin['name'], 'edit', $prefix_count + 2),
+    'access arguments' => array($plugin['name'], 'edit', $arg_count),
     'type' => MENU_CALLBACK,
   );
 
@@ -173,10 +174,10 @@ function ctools_export_ui_process(&$plugin, $info) {
     'path' => 'list/%ctools_export_ui/edit',
     'title' => 'Edit',
     'page callback' => 'ctools_export_ui_switcher_page',
-    'page arguments' => array($plugin['name'], 'edit', $prefix_count + 2),
+    'page arguments' => array($plugin['name'], 'edit', $arg_count),
     'load arguments' => array($plugin['name']),
     'access callback' => 'ctools_export_ui_task_access',
-    'access arguments' => array($plugin['name'], 'edit', $prefix_count + 2),
+    'access arguments' => array($plugin['name'], 'edit', $arg_count),
     'type' => MENU_DEFAULT_LOCAL_TASK,
     'weight' => -10,
   );
@@ -200,10 +201,10 @@ function ctools_export_ui_process(&$plugin, $info) {
       'path' => 'list/%ctools_export_ui/export',
       'title' => 'Export',
       'page callback' => 'ctools_export_ui_switcher_page',
-      'page arguments' => array($plugin['name'], 'export', $prefix_count + 2),
+      'page arguments' => array($plugin['name'], 'export', $arg_count),
       'load arguments' => array($plugin['name']),
       'access callback' => 'ctools_export_ui_task_access',
-      'access arguments' => array($plugin['name'], 'export', $prefix_count + 2),
+      'access arguments' => array($plugin['name'], 'export', $arg_count),
       'type' => MENU_LOCAL_TASK,
     );
   }
@@ -215,10 +216,10 @@ function ctools_export_ui_process(&$plugin, $info) {
       'title' => 'Revert',
       'page callback' => 'ctools_export_ui_switcher_page',
       // Note: Yes, 'delete' op is correct.
-      'page arguments' => array($plugin['name'], 'delete', $prefix_count + 2),
+      'page arguments' => array($plugin['name'], 'delete', $arg_count),
       'load arguments' => array($plugin['name']),
       'access callback' => 'ctools_export_ui_task_access',
-      'access arguments' => array($plugin['name'], 'revert', $prefix_count + 2),
+      'access arguments' => array($plugin['name'], 'revert', $arg_count),
       'type' => MENU_CALLBACK,
     );
   }
@@ -229,10 +230,10 @@ function ctools_export_ui_process(&$plugin, $info) {
       'path' => 'list/%ctools_export_ui/delete',
       'title' => 'Delete',
       'page callback' => 'ctools_export_ui_switcher_page',
-      'page arguments' => array($plugin['name'], 'delete', $prefix_count + 2),
+      'page arguments' => array($plugin['name'], 'delete', $arg_count),
       'load arguments' => array($plugin['name']),
       'access callback' => 'ctools_export_ui_task_access',
-      'access arguments' => array($plugin['name'], 'delete', $prefix_count + 2),
+      'access arguments' => array($plugin['name'], 'delete', $arg_count),
       'type' => MENU_CALLBACK,
     );
   }
@@ -243,10 +244,10 @@ function ctools_export_ui_process(&$plugin, $info) {
       'path' => 'list/%ctools_export_ui/clone',
       'title' => 'Clone',
       'page callback' => 'ctools_export_ui_switcher_page',
-      'page arguments' => array($plugin['name'], 'clone', $prefix_count + 2),
+      'page arguments' => array($plugin['name'], 'clone', $arg_count),
       'load arguments' => array($plugin['name']),
       'access callback' => 'ctools_export_ui_task_access',
-      'access arguments' => array($plugin['name'], 'clone', $prefix_count + 2),
+      'access arguments' => array($plugin['name'], 'clone', $arg_count),
       'type' => MENU_CALLBACK,
     );
   }
@@ -257,10 +258,10 @@ function ctools_export_ui_process(&$plugin, $info) {
       'path' => 'list/%ctools_export_ui/enable',
       'title' => 'Enable',
       'page callback' => 'ctools_export_ui_switcher_page',
-      'page arguments' => array($plugin['name'], 'enable', $prefix_count + 2),
+      'page arguments' => array($plugin['name'], 'enable', $arg_count),
       'load arguments' => array($plugin['name']),
       'access callback' => 'ctools_export_ui_task_access',
-      'access arguments' => array($plugin['name'], 'enable', $prefix_count + 2),
+      'access arguments' => array($plugin['name'], 'enable', $arg_count),
       'type' => MENU_CALLBACK,
     );
   }
@@ -271,10 +272,10 @@ function ctools_export_ui_process(&$plugin, $info) {
       'path' => 'list/%ctools_export_ui/disable',
       'title' => 'Disable',
       'page callback' => 'ctools_export_ui_switcher_page',
-      'page arguments' => array($plugin['name'], 'disable', $prefix_count + 2),
+      'page arguments' => array($plugin['name'], 'disable', $arg_count),
       'load arguments' => array($plugin['name']),
       'access callback' => 'ctools_export_ui_task_access',
-      'access arguments' => array($plugin['name'], 'disable', $prefix_count + 2),
+      'access arguments' => array($plugin['name'], 'disable', $arg_count),
       'type' => MENU_CALLBACK,
     );
   }
-- 
1.7.11.1

