diff --git a/README.txt b/README.txt index e1b52dc..5b2850b 100644 --- a/README.txt +++ b/README.txt @@ -1,7 +1,7 @@ -Fieldable Panel Panes support multiple bundles, but at this time there is no -UI to create bundles. +Fieldable Panel Panes supports multiple bundles, which may be managed at +admin/structure/fieldable-panels-panes. -Bundles can be created in a module via hook_entity_info_alter(). The code +Bundles can also be created in a module via hook_entity_info_alter(). The code will look something like this: function MYMODULE_entity_info_alter(&$entity_info) { @@ -11,7 +11,7 @@ function MYMODULE_entity_info_alter(&$entity_info) { 'pane top level' => FALSE, // set to true to make this show as a top level icon 'pane icon' => '/path/to/custom/icon/for/this/pane.png', 'admin' => array( - 'path' => 'admin/structure/fieldable-panels-panes/manage/%fieldable_panels_panes_type', + 'path' => 'admin/structure/fieldable-panels-panes/manage/%fieldable_panels_pane_type', 'bundle argument' => 4, // Note that this has all _ replaced with - from the bundle name. 'real path' => 'admin/structure/fieldable-panels-panes/manage/my-bundle-name', @@ -25,4 +25,6 @@ Display Fields tabs in the UI. You can use this hook to rename or remove the default bundle but remember that doing so will break any content currently using that bundle. If you do this -be sure to also fix any content already using it. +be sure to also fix any content already using it. It is recommended that you +use the bundle management UI in admin/structure/fieldable-panels-panes so you +don't have to maintain this yourself. diff --git a/fieldable_panels_panes.info b/fieldable_panels_panes.info index fae4488..77126ca 100644 --- a/fieldable_panels_panes.info +++ b/fieldable_panels_panes.info @@ -4,6 +4,7 @@ package = "Panels" core = "7.x" dependencies[] = "panels" dependencies[] = "views" + configure = admin/structure/fieldable-panels-panes files[] = includes/PanelsPaneController.class.php diff --git a/fieldable_panels_panes.install b/fieldable_panels_panes.install index f17d3fe..3988d67 100644 --- a/fieldable_panels_panes.install +++ b/fieldable_panels_panes.install @@ -5,6 +5,29 @@ */ /** + * Implements hook_install(). + */ +function fieldable_panels_panes_install() { + ctools_include('export'); + + $item = ctools_export_crud_new('fieldable_panels_pane_type'); + $item->name = 'fieldable_panels_pane'; + $item->title = t('Panels Pane'); + ctools_export_crud_save('fieldable_panels_pane_type', $item); +} + + +/** + * Implements hook_uninstall(). + */ +function fieldable_panels_panes_uninstall() { + $results = db_query('SELECT name FROM {fieldable_panels_pane_type}'); + foreach ($results as $type) { + field_attach_delete_bundle('fieldable_panels_pane', $type->name); + } +} + +/** * Implements hook_schema(). */ function fieldable_panels_panes_schema() { @@ -162,6 +185,45 @@ function fieldable_panels_panes_schema() { ), ); + $schema['fieldable_panels_pane_type'] = array( + 'description' => 'Entity bundle table for panel pane content.', + 'fields' => array( + 'name' => array( + 'description' => 'The machine-readable name of this type.', + 'type' => 'varchar', + 'length' => 32, + 'not null' => TRUE, + 'default' => '', + ), + 'title' => array( + 'description' => 'The human-readable name of this type.', + 'type' => 'varchar', + 'length' => 255, + 'not null' => TRUE, + 'default' => '', + 'translatable' => TRUE, + ), + 'description' => array( + 'description' => 'A brief description of this type.', + 'type' => 'text', + 'size' => 'big', + 'not null' => TRUE, + ), + ), + 'export' => array( + 'admin_title' => 'title', + 'admin_description' => 'description', + 'api' => array( + 'owner' => 'fieldable_panels_panes', + 'api' => 'fieldable_panels_pane_type', + 'minimum_version' => 1, + 'current_version' => 1, + ), + ), + 'primary key' => array('name'), + ); + + // Optional cache table for entitycache support. $schema['cache_entity_fieldable_panels_pane'] = drupal_get_schema_unprocessed('system', 'cache'); $schema['cache_entity_fieldable_panels_pane']['description'] = 'Cache table used to store fieldable_panels_pane entity records.'; @@ -169,9 +231,9 @@ function fieldable_panels_panes_schema() { return $schema; } - /** - * Add UUID support. - */ +/** + * Add UUID support. + */ function fieldable_panels_panes_update_7101(&$sandbox) { // Make sure to add UUID field @@ -248,3 +310,87 @@ function fieldable_panels_panes_update_7107() { db_create_table('cache_entity_fieldable_panels_pane', $schema); } } + +/** + * Adding Fieldable Panels Panes Type table and saving existing bundles to + * database. + */ +function fieldable_panels_panes_update_7108() { + ctools_include('export'); + $messages = array(); + + // Copied from fieldable_panels_panes_schema() because the schema should not + // be directly used during hook_update_N. + $schema['fieldable_panels_pane_type'] = array( + 'description' => 'Entity bundle table for panel pane content.', + 'fields' => array( + 'name' => array( + 'description' => 'The machine-readable name of this type.', + 'type' => 'varchar', + 'length' => 32, + 'not null' => TRUE, + 'default' => '', + ), + 'title' => array( + 'description' => 'The human-readable name of this type.', + 'type' => 'varchar', + 'length' => 255, + 'not null' => TRUE, + 'default' => '', + 'translatable' => TRUE, + ), + 'description' => array( + 'description' => 'A brief description of this type.', + 'type' => 'text', + 'size' => 'big', + 'not null' => TRUE, + ), + ), + 'export' => array( + 'admin_title' => 'title', + 'admin_description' => 'description', + 'api' => array( + 'owner' => 'fieldable_panels_panes', + 'api' => 'fieldable_panels_pane_type', + 'minimum_version' => 1, + 'current_version' => 1, + ), + ), + 'primary key' => array('name'), + ); + + + // Add the new table for storing bundles. + db_create_table('fieldable_panels_pane_type', $schema['fieldable_panels_pane_type']); + + // Store possible existing bundles provided by other modules. + $bundles = array(); + $entity_info = entity_get_info('fieldable_panels_pane'); + + // No bundles defined. This could happen if the module was updated and cache + // cleared before update was run as entity info's cache will no longer + // contain the old default. + $t = get_t(); + if (empty($entity_info['bundles'])) { + $entity_info['bundles'] = array( + 'fieldable_panels_pane' => array( + 'label' => $t('Panels pane'), + ), + ); + } + + foreach ($entity_info['bundles'] as $bundle_name => $bundle_info) { + $bundles[] = $bundle_info['label']; + + $item = ctools_export_crud_new('fieldable_panels_pane_type'); + $item->name = $bundle_name; + $item->title = $bundle_info['label']; + ctools_export_crud_save('fieldable_panels_pane_type', $item); + } + + if (!empty($bundles)) { + $messages[] = format_plural(count($bundles), 'Added existing bundle %bundle_names to database.', 'Added existing bundles %bundle_names to database.', array('%bundle_names' => implode(', ', $bundles))); + } + + return implode('
', $messages); +} diff --git a/fieldable_panels_panes.module b/fieldable_panels_panes.module index e666152..e8dd043 100644 --- a/fieldable_panels_panes.module +++ b/fieldable_panels_panes.module @@ -15,6 +15,21 @@ function fieldable_panels_panes_entity_info() { $info = array(); + ctools_include('export'); + $bundles = array(); + + foreach (ctools_export_crud_load_all('fieldable_panels_pane_type') as $type) { + $bundles[$type->name] = array( + 'label' => $type->title, + 'admin' => array( + 'path' => 'admin/structure/fieldable-panels-panes/%ctools_export_ui', + 'bundle argument' => 3, + 'real path' => 'admin/structure/fieldable-panels-panes/' . $type->name, + 'access arguments' => array('administer fieldable panels panes'), + ), + ); + } + $info['fieldable_panels_pane'] = array( 'label' => t('Fieldable panel pane'), 'controller class' => 'PanelsPaneController', @@ -31,20 +46,8 @@ function fieldable_panels_panes_entity_info() { 'uuid' => 'uuid', 'revision uuid' => 'vuuid', ), - 'bundles' => array( - // @todo We need to store the possible bundles and create a UI. - // to allow for more bundles. For now, hook_panels_panes_entity_info_alter - // will work. - 'fieldable_panels_pane' => array( - 'label' => t('Panels pane'), - 'admin' => array( - 'path' => 'admin/structure/fieldable-panels-panes/manage/%fieldable_panels_panes_type', - 'bundle argument' => 4, - 'real path' => 'admin/structure/fieldable-panels-panes/manage/fieldable-panels-pane', - 'access arguments' => array('administer fieldable panels panes'), - ), - ), - ), + 'bundles' => $bundles, + 'bundle keys' => array('bundle' => 'name'), 'view modes' => array( // @todo we should support view modes. 'full' => array( @@ -102,7 +105,40 @@ function fieldable_panels_panes_entity_info() { } /** - * Implements hook_fied_extra_fields(). + * Implements hook_module_implements_alter(). + */ +function fieldable_panels_panes_module_implements_alter(&$implementations, $hook) { + if ($hook == 'entity_info_alter') { + // Fieldable Panels Panes will do a bit of clean-up to prevent issues with + // obsolete paths found in legacy bundles that are provided by modules via + // hook_entity_info_alter(), but we need to make sure that our + // implementation is called last. + $group = $implementations['fieldable_panels_panes']; + unset($implementations['fieldable_panels_panes']); + $implementations['fieldable_panels_panes'] = $group; + } +} + +/** + * Implements hook_entity_info_alter(). + */ +function fieldable_panels_panes_entity_info_alter(&$info) { + $old_base_path = 'admin/structure/panels/entity/manage'; + $new_base_path = 'admin/structure/fieldable-panels-panes/manage'; + + if (is_array($info) && !empty($info)) { + foreach ($info['fieldable_panels_pane']['bundles'] as $name => &$bundle) { + if (strpos($bundle['admin']['path'], $old_base_path) !== FALSE) { + $bundle['admin']['path'] = str_replace($old_base_path, $new_base_path, $bundle['admin']['path']); + $bundle['admin']['real path'] = str_replace($old_base_path, $new_base_path, $bundle['admin']['real path']); + $bundle['admin']['bundle argument'] = $bundle['admin']['bundle argument'] - 1; + } + } + } +} + +/** + * Implements hook_field_extra_fields(). */ function fieldable_panels_panes_field_extra_fields() { $extra = array(); @@ -141,19 +177,7 @@ function fieldable_panels_panes_menu() { 'file' => 'includes/admin.inc', ); - - $items['admin/structure/fieldable-panels-panes'] = array( - 'title' => 'Fieldable Panels Panes', - 'description' => 'Manage pane content types.', - 'page callback' => 'fieldable_panels_panes_entities_page', - ) + $base; - - $items['admin/structure/fieldable-panels-panes/list'] = array( - 'title' => 'List', - 'type' => MENU_DEFAULT_LOCAL_TASK, - 'weight' => -10, - ) + $base; - + // Legacy paths to support the old method of providing bundles via entity_hook_info(). $items['admin/structure/fieldable-panels-panes/view/%fieldable_panels_panes'] = array( 'title callback' => 'fieldable_panels_panes_entity_title', 'title arguments' => array(4), @@ -318,20 +342,20 @@ function fieldable_panels_panes_menu() { ); } - $items['admin/structure/fieldable-panels-panes/manage/%fieldable_panels_panes_type'] = array( + $items['admin/structure/fieldable-panels-panes/manage/%fieldable_panels_pane_type'] = array( 'title callback' => 'fieldable_panels_panes_entities_title', 'title arguments' => array(4), 'page callback' => 'fieldable_panels_panes_entities_list_page', 'page arguments' => array(4), ) + $base; - $items['admin/structure/fieldable-panels-panes/manage/%fieldable_panels_panes_type/list'] = array( + $items['admin/structure/fieldable-panels-panes/manage/%fieldable_panels_pane_type/list'] = array( 'title' => 'List', 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10, ); - $items['admin/structure/fieldable-panels-panes/manage/%fieldable_panels_panes_type/add'] = array( + $items['admin/structure/fieldable-panels-panes/manage/%fieldable_panels_pane_type/add'] = array( 'title' => 'Add fieldable panel pane', 'page callback' => 'fieldable_panels_panes_entities_add_page', 'page arguments' => array(4), @@ -391,16 +415,16 @@ function fieldable_panels_panes_theme() { function fieldable_panels_panes_admin_menu_map() { $map = array(); - $bundles = array(); + $bundle_keys = array(); $info = entity_get_info('fieldable_panels_pane'); foreach ($info['bundles'] as $bundle_name => $bundle_info) { - $bundles[] = strtr($bundle_name, '_', '-'); + $bundle_keys[] = $bundle_name; } - $map['admin/structure/fieldable-panels-panes/manage/%fieldable_panels_panes_type'] = array( + $map['admin/structure/fieldable-panels-panes/%ctools_export_ui'] = array( 'parent' => 'admin/structure/fieldable-panels-panes', 'arguments' => array( - array('%fieldable_panels_panes_type' => $bundles), + array('%ctools_export_ui' => $bundle_keys), ), ); @@ -439,7 +463,7 @@ function fieldable_panels_panes_admin_menu_map_alter(array &$map) { if (!empty($fields)) { $map["$admin_path/fields/%field_ui_menu"]['parent'] = "$admin_path/fields"; $map["$admin_path/fields/%field_ui_menu"]['arguments'][] = array( - '%fieldable_panels_panes_type' => array($bundle_name), + '%ctools_export_ui' => array($bundle_name), '%field_ui_menu' => $fields, ); } @@ -458,24 +482,23 @@ function fieldable_panels_panes_flush_caches() { * Implementation of hook_panels_dashboard_blocks(). */ function fieldable_panels_panes_panels_dashboard_blocks(&$vars) { + ctools_include('export'); + $vars['links']['fieldable_panels_panes'] = array( 'title' => l(t('Fieldable Panels Panes'), 'admin/structure/fieldable-panels-panes'), 'description' => t('Fieldable Panels Panes are fieldable entities that can be created directly in the Panels UI or created in a separate administrative UI to reuse later in a panel pane.'), ); - $entity_info = entity_get_info('fieldable_panels_pane'); $count = 0; $rows = array(); - foreach ($entity_info['bundles'] as $bundle => $info) { - $type_url_str = str_replace('_', '-', $bundle); - + foreach (ctools_export_crud_load_all('fieldable_panels_pane_type') as $type) { $rows[] = array( - check_plain($info['label']), - l(t('List'), 'admin/structure/fieldable-panels-panes/manage/' . $type_url_str), - l(t('Add'), 'admin/structure/fieldable-panels-panes/manage/' . $type_url_str . '/add'), - l(t('Manage Fields'), 'admin/structure/fieldable-panels-panes/manage/' . $type_url_str . '/fields'), - l(t('Manage Display'), 'admin/structure/fieldable-panels-panes/manage/' . $type_url_str . '/display'), + $type->title, + l(t('List'), 'admin/structure/fieldable-panels-panes/' . $type->name), + l(t('Add'), 'admin/structure/fieldable-panels-panes/' . $type->name . '/add'), + l(t('Manage Fields'), 'admin/structure/fieldable-panels-panes/' . $type->name . '/fields'), + l(t('Manage Display'), 'admin/structure/fieldable-panels-panes/' . $type->name . '/display'), ); // Only display 10. @@ -499,7 +522,6 @@ function fieldable_panels_panes_panels_dashboard_blocks(&$vars) { 'class' => 'dashboard-fieldable-panels-panes', 'section' => 'right', ); - } // ------------------------------------------------------------------------- @@ -508,7 +530,7 @@ function fieldable_panels_panes_panels_dashboard_blocks(&$vars) { /** * Properly format the type from the URL version to the internal version. */ -function fieldable_panels_panes_type_load($type) { +function fieldable_panels_pane_type_load($type) { $type = str_replace('-', '_', $type); $entity_info = entity_get_info('fieldable_panels_pane'); @@ -518,6 +540,15 @@ function fieldable_panels_panes_type_load($type) { } /** + * @depricated Backwards compatability layer. + * + * @see fieldable_panels_pane_type_load(). + */ +function fieldable_panels_panes_type_load($type) { + return fieldable_panels_pane_type_load($type); +} + +/** * Provide a safe title for an entity pane type based upon the URL. */ function fieldable_panels_panes_entities_title($type) { @@ -530,6 +561,16 @@ function fieldable_panels_panes_entities_title($type) { } /** + * Title callback for fieldable panels panes exportable items. + * + * @param $item + * A %ctools_export_ui object. + */ +function fieldable_panels_pane_type_title($item) { + return $item->title; +} + +/** * Ensure an entity can be accessed via URL. * * This requires only administrative access. @@ -575,6 +616,10 @@ function fieldable_panels_panes_entity_make_current_access($entity) { * Implements hook_ctools_plugin_directory() */ function fieldable_panels_panes_ctools_plugin_directory($owner, $plugin_type) { + if ($owner == 'ctools' && $plugin_type == 'export_ui') { + return 'plugins/' . $plugin_type; + } + if ($owner == 'ctools' && $plugin_type == 'content_types') { return 'plugins/' . $plugin_type; } diff --git a/includes/admin.inc b/includes/admin.inc index 9aaf400..d0e8911 100644 --- a/includes/admin.inc +++ b/includes/admin.inc @@ -6,62 +6,6 @@ */ /** - * List all bundles and administrative options for entity panes. - */ -function fieldable_panels_panes_entities_page() { - $entity_info = entity_get_info('fieldable_panels_pane'); - - $header = array(t('Name'), array('data' => t('Operations'), 'colspan' => 2)); - $rows = array(); - - foreach ($entity_info['bundles'] as $bundle => $info) { - $type_url_str = str_replace('_', '-', $bundle); - - $row = array(); - - $label = check_plain($info['label']); - $label .= ' ' . t('(Machine name: @type)', array('@type' => $bundle)) . ''; - - $row[] = $label; - - $operations = array(); - - $operations['list'] = array( - 'title' => t('list'), - 'href' => 'admin/structure/fieldable-panels-panes/manage/' . $type_url_str, - ); - - $operations['add'] = array( - 'title' => t('add'), - 'href' => 'admin/structure/fieldable-panels-panes/manage/' . $type_url_str . '/add', - ); - - $operations['fields'] = array( - 'title' => t('manage fields'), - 'href' => 'admin/structure/fieldable-panels-panes/manage/' . $type_url_str . '/fields', - ); - - $operations['display'] = array( - 'title' => t('manage display'), - 'href' => 'admin/structure/fieldable-panels-panes/manage/' . $type_url_str . '/display', - ); - - $ops = theme('links', array('links' => $operations, 'attributes' => array('class' => array('links', 'inline')))); - - $row[] = $ops; - $rows[] = $row; - } - - $build['panes_table'] = array( - '#theme' => 'table', - '#header' => $header, - '#rows' => $rows, - ); - - return $build; -} - -/** * List all entities for the given type. */ function fieldable_panels_panes_entities_list_page($type) { diff --git a/plugins/content_types/fieldable_panels_pane.inc b/plugins/content_types/fieldable_panels_pane.inc index 88f2a4f..f55ad01 100644 --- a/plugins/content_types/fieldable_panels_pane.inc +++ b/plugins/content_types/fieldable_panels_pane.inc @@ -13,7 +13,6 @@ * caching and if this .inc file is loaded before the plugin is * requested, the $plugin = array() notation doesn't work. */ - function fieldable_panels_panes_fieldable_panels_pane_ctools_content_types() { return array( 'title' => t('Fielded custom content'), diff --git a/plugins/entity/FieldablePanelsPaneEntity.class.php b/plugins/entity/FieldablePanelsPaneEntity.class.php index 404b3d9..c40a9e1 100644 --- a/plugins/entity/FieldablePanelsPaneEntity.class.php +++ b/plugins/entity/FieldablePanelsPaneEntity.class.php @@ -11,8 +11,8 @@ */ class FieldablePanelsPaneEntity extends PanelizerEntityDefault { // @todo this path is too deep to handle. -// public $entity_admin_root = 'admin/structure/fieldable-panels-panes/manage/%'; -// public $entity_admin_bundle = 5; +// public $entity_admin_root = 'admin/structure/fieldable-panels-panes/%'; +// public $entity_admin_bundle = 4; public $views_table = 'fieldable_panels_panes'; public function entity_access($op, $entity) { diff --git a/plugins/export_ui/fieldable_panels_pane.class.php b/plugins/export_ui/fieldable_panels_pane.class.php new file mode 100644 index 0000000..3252eca --- /dev/null +++ b/plugins/export_ui/fieldable_panels_pane.class.php @@ -0,0 +1,205 @@ +plugin); + $name = $item->{$this->plugin['export']['key']}; + + $operations['list'] = array( + 'title' => t('List'), + 'href' => $base_path . '/' . $name . '/list', + ); + + $operations['add_entity'] = array( + 'title' => t('Add Entity'), + 'href' => $base_path . '/' . $name . '/add', + ); + + $operations += parent::build_operations($item); + + $operations['field'] = array( + 'title' => t('Manage Fields'), + 'href' => $base_path . '/' . $name . '/fields', + ); + + $operations['display'] = array( + 'title' => t('Manage Display'), + 'href' => $base_path . '/' . $name . '/display', + ); + + return $operations; + } + + /** + * Allow users to jump right into adding fields. + */ + function edit_form(&$form, &$form_state) { + parent::edit_form($form, $form_state); + + if (module_exists('field_ui')) { + $form['buttons']['save_continue'] = array( + '#type' => 'submit', + '#value' => t('Save and add fields'), + '#access' => $form_state['op'] == 'add' || $form_state['op'] == 'clone', + ); + } + } + + /** + * Update the form state "op" so we can properly redirect. + */ + function edit_form_submit(&$form, &$form_state) { + parent::edit_form_submit($form, $form_state); + + if ($form_state['triggering_element']['#parents'][0] == 'save_continue') { + $form_state['op'] = 'save_continue'; + } + } + + /** + * Ensure menu gets rebuild after saving a new type. + */ + function edit_save_form($form_state) { + parent::edit_save_form($form_state); + + entity_info_cache_clear(); + menu_rebuild(); + + if ($form_state['op'] === 'save_continue') { + $this->plugin['redirect']['save_continue'] = $this->field_admin_path($form_state['values']['name'], 'fields'); + } + } + + /** + * Remove fields associated to bundles that are being deleted. + */ + function delete_form_submit(&$form_state) { + parent::delete_form_submit($form_state); + + if ($form_state['op'] == 'delete') { + field_attach_delete_bundle('fieldable_panels_pane', $form_state['item']->name); + entity_info_cache_clear(); + } + } + + /** + * List entities page. + */ + function list_entities_page($js, $input, $item, $step = NULL) { + drupal_set_title($this->get_page_title('list_entity', $item)); + + return views_embed_view('fieldable_pane_entities', 'default', $item->name); + } + + /** + * Add entity page. + */ + function add_entity_page($js, $input, $item, $step = NULL) { + drupal_set_title($this->get_page_title('add_entity', $item)); + + $form_state = array( + 'entity' => fieldable_panels_panes_create(array('bundle' => $item->name)), + 'add submit' => TRUE, + 'plugin' => $this->plugin, + 'object' => &$this, + 'ajax' => $js, + 'item' => $item, + 'op' => 'add_entity', + 'no_redirect' => TRUE, + 'rerender' => TRUE, + 'step' => $step, + 'function args' => func_get_args(), + ); + + // Default these to reusable. + $form_state['entity']->reusable = TRUE; + $output = drupal_build_form('fieldable_panels_panes_entity_edit_form', $form_state); + if (!empty($form_state['executed'])) { + $this->redirect($form_state['op'], $form_state['item']); + } + + return $output; + } + + /** + * List footer. + */ + function list_footer($form_state) { + ctools_include('export'); + $items = ctools_export_crud_load_all('fieldable_panels_pane_type'); + $entity_info = entity_get_info('fieldable_panels_pane'); + + $header = array(t('Name'), array('data' => t('Operations'), 'colspan' => 2)); + $rows = array(); + + foreach ($entity_info['bundles'] as $bundle => $info) { + // Filter out bundles that already exist as ctools exportable objects. + if (isset($items[$bundle])) { + continue; + } + + $row = array(); + + $label = check_plain($info['label']); + $label .= ' ' . t('(Machine name: @type)', array('@type' => $bundle)) . ''; + + $row[] = $label; + + $operations = array(); + + $operations['list'] = array( + 'title' => t('list'), + 'href' => 'admin/structure/fieldable-panels-panes/manage/' . $bundle, + ); + + $operations['add'] = array( + 'title' => t('add'), + 'href' => 'admin/structure/fieldable-panels-panes/manage/' . $bundle . '/add', + ); + + $operations['fields'] = array( + 'title' => t('manage fields'), + 'href' => $this->field_admin_path($bundle, 'fields'), + ); + + $operations['display'] = array( + 'title' => t('manage display'), + 'href' => $this->field_admin_path($bundle, 'display'), + ); + + $ops = theme('links', array('links' => $operations, 'attributes' => array('class' => array('links', 'inline')))); + + $row[] = $ops; + $rows[] = $row; + } + + if (!empty($rows)) { + $variables = array( + 'caption' => t('Legacy bundles that are not managed by the bundle administrative UI are listed here.'), + 'header' => $header, + 'rows' => $rows, + ); + + return theme('table', $variables); + } + } + + /** + * Helper method to derive paths to field ui operations. + */ + function field_admin_path($name, $op) { + return _field_ui_bundle_admin_path('fieldable_panels_pane', $name) . '/' . $op; + } +} diff --git a/plugins/export_ui/fieldable_panels_pane.inc b/plugins/export_ui/fieldable_panels_pane.inc new file mode 100644 index 0000000..452cfa7 --- /dev/null +++ b/plugins/export_ui/fieldable_panels_pane.inc @@ -0,0 +1,119 @@ + 'fieldable_panels_pane', + 'schema' => 'fieldable_panels_pane_type', + 'access' => 'administer fieldable panels panes', + 'handler' => array('class' => 'fieldable_panels_pane'), + + 'title singular' => t('fieldable panels panes type'), + 'title singular proper' => t('Fieldable Panels Panes Type'), + 'title plural' => t('fieldable panels panes types'), + 'title plural proper' => t('Fieldable Panels Panes Types'), + ); + + $plugin['menu'] = array( + 'menu prefix' => 'admin/structure', + 'menu item' => 'fieldable-panels-panes', + 'menu title' => 'Fieldable Panels Panes', + 'menu description' => 'Create and manage fieldable panels pane types.', + ); + + $plugin['allowed operations'] = array( + 'clone' => FALSE, + ); + + $base_path = ctools_export_ui_plugin_base_path($plugin); + $prefix_count = count(explode('/', $plugin['menu']['menu prefix'])); + + $plugin['menu']['items'] = array( + 'list callback' => array('type' => MENU_NORMAL_ITEM), + 'edit callback' => array( + 'path' => '%ctools_export_ui', + 'title callback' => 'fieldable_panels_pane_type_title', + 'title arguments' => array($prefix_count + 1), + 'page arguments' => array($plugin['name'], 'list_entities', $prefix_count + 1), + 'access arguments' => array($plugin['name'], 'list_entities', $prefix_count + 1), + 'type' => MENU_NORMAL_ITEM, + ), + 'list_entities' => array( + 'path' => '%ctools_export_ui/list', + 'title' => 'List', + 'access callback' => 'ctools_export_ui_task_access', + 'access arguments' => array($plugin['name'], 'list_entities'), + 'type' => MENU_DEFAULT_LOCAL_TASK, + 'weight' => -10, + ), + 'add_entity' => array( + 'path' => '%ctools_export_ui/add', + 'title' => 'Add entity', + 'page callback' => 'ctools_export_ui_switcher_page', + 'page arguments' => array($plugin['name'], 'add_entity', $prefix_count + 1), + 'load arguments' => array($plugin['name']), + 'access callback' => 'ctools_export_ui_task_access', + 'access arguments' => array($plugin['name'], 'add_entity'), + 'type' => MENU_LOCAL_TASK, + 'weight' => -9, + ), + 'edit' => array( + 'path' => '%ctools_export_ui/edit', + 'page arguments' => array($plugin['name'], 'edit', $prefix_count + 1), + 'access arguments' => array($plugin['name'], 'edit', $prefix_count + 1), + 'type' => MENU_LOCAL_TASK, + 'weight' => -8, + ), + 'export' => array( + 'path' => '%ctools_export_ui/export', + 'page arguments' => array($plugin['name'], 'export', $prefix_count + 1), + 'access arguments' => array($plugin['name'], 'export', $prefix_count + 1), + ), + 'revert' => array( + 'path' => '%ctools_export_ui/revert', + 'page arguments' => array($plugin['name'], 'delete', $prefix_count + 1), + 'access arguments' => array($plugin['name'], 'delete', $prefix_count + 1), + ), + 'delete' => array( + 'path' => '%ctools_export_ui/delete', + 'page arguments' => array($plugin['name'], 'delete', $prefix_count + 1), + 'access arguments' => array($plugin['name'], 'delete', $prefix_count + 1), + ), + 'enable' => array( + 'path' => '%ctools_export_ui/enable', + 'page arguments' => array($plugin['name'], 'enable', $prefix_count + 1), + 'access arguments' => array($plugin['name'], 'enable', $prefix_count + 1), + ), + 'disable' => array( + 'path' => '%ctools_export_ui/disable', + 'page arguments' => array($plugin['name'], 'disable', $prefix_count + 1), + 'access arguments' => array($plugin['name'], 'disable', $prefix_count + 1), + ), + ); + + $plugin['redirect'] = array( + 'add_entity' => $base_path . '/%ctools_export_ui', + ); + + $plugin['strings'] = array( + 'title' => array( + 'add_entity' => t('Add fieldable panels pane of type %title'), + 'list_entity' => t('List %title entities'), + ), + 'confirmation' => array( + 'save_continue' => array( + 'success' => t('%title has been created.'), + 'fail' => t('%title could not be created.'), + ), + ), + ); + + return $plugin; +}