From eccd46882296932d5a5aa112b8dab06a76a4ce90 Mon Sep 17 00:00:00 2001 From: William Hearn Date: Mon, 21 Dec 2015 12:15:59 -0500 Subject: [PATCH] CTools content type widget for deploy_overview_page(). Signed-off-by: William Hearn --- deploy_plus.module | 7 +++ plugins/content_types/deploy/deploy.inc | 108 ++++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+) create mode 100644 plugins/content_types/deploy/deploy.inc diff --git a/deploy_plus.module b/deploy_plus.module index d9cb88e..2885155 100644 --- a/deploy_plus.module +++ b/deploy_plus.module @@ -106,6 +106,13 @@ function deploy_plus_theme($existing, $type, $theme, $path) { } /** + * Implements hook_ctools_plugin_directory(). + */ +function deploy_plus_ctools_plugin_directory($module, $plugin) { + return 'plugins/' . $plugin; +} + +/** * Implements hook_action_info(). */ function deploy_plus_action_info() { diff --git a/plugins/content_types/deploy/deploy.inc b/plugins/content_types/deploy/deploy.inc new file mode 100644 index 0000000..1640d98 --- /dev/null +++ b/plugins/content_types/deploy/deploy.inc @@ -0,0 +1,108 @@ + TRUE, + 'render last' => TRUE, + 'title' => t('Deploy'), + 'description' => t('Deploy Plus overview form.'), + 'render callback' => 'deploy_plus_deploy_content_type_render', + 'edit form' => 'deploy_plus_deploy_edit_form', + 'category' => t('Deployment'), +); + +/** + * Admin title callback for the content type. + */ +function deploy_plus_deploy_content_type_admin_title($subtype = NULL, $conf = NULL, $context = NULL) { + return t('Deploy Plus'); +} + +/** + * Admin info callback for the content type. + */ +function deploy_plus_deploy_content_type_admin_info($subtype = NULL, $conf = NULL, $context = NULL) { + $block = new stdClass(); + $block->title = t('Deploy Plus'); + + return $block; +} + +/** + * Run-time rendering of the body of the block. + */ +function deploy_plus_deploy_content_type_render($subtype, $conf, $panel_args, &$context) { + $block = new stdClass(); + $block->title = t('Deploy Plus'); + + $plans = deploy_plan_load_all_enabled(); + $blocks = array(); + + // Iterate over all plans. + foreach ($plans as $plan) { + $info = array(); + + // Get the entity keys from the aggregator. + $entity_keys = $plan->getEntities(); + foreach ($entity_keys as $entity_key) { + // Get the entity info and all entities of this type. + $entity_info = entity_get_info($entity_key['type']); + + if (!empty($entity_info['entity keys']['revision']) && !empty($entity_key['revision_id'])) { + $entity = entity_revision_load($entity_key['type'], $entity_key['revision_id']); + } + else { + $entity = entity_load_single($entity_key['type'], $entity_key['id']); + } + + $title = "{$entity_key['type']}:{$entity_key['id']}"; + $label = entity_label($entity_key['type'], $entity); + if ($label) { + $title = $label; + } + + if ($entity_info['entity keys']['revision'] && !empty($entity_key['revision_id'])) { + $title = t('@title (rev:@rev_id)', array('@title' => $title, '@rev_id' => $entity_key['revision_id'])); + } + + $uri = entity_uri($entity_key['type'], $entity); + if ($uri) { + $title = l($title, $uri['path'], $uri['options']); + } + // Construct a usable array for the theme function. + $info[] = array( + 'title' => $title, + 'type' => $entity_info['label'], + ); + } + + // Construct a usable array for the theme function. + $blocks[] = array( + 'plan_name' => check_plain($plan->name), + 'plan_title' => check_plain($plan->title), + 'plan_description' => check_plain($plan->description), + 'content' => theme('deploy_ui_overview_plan_content', array('info' => $info)), + 'fetch_only' => $plan->fetch_only, + 'status' => deploy_plan_get_status($plan->name), + ); + } + + $block->content = theme('deploy_plus_overview', array('blocks' => $blocks)); + return $block; + +} + +/** + * Edit callback edit form for the content type. + */ +function deploy_plus_deploy_edit_form($form, &$form_state) { + + return $form; +} -- 2.3.8 (Apple Git-58)