diff --git a/plugins/content_types/scheduler_form_pane.inc b/plugins/content_types/scheduler_form_pane.inc new file mode 100644 index 0000000..3705c12 --- /dev/null +++ b/plugins/content_types/scheduler_form_pane.inc @@ -0,0 +1,54 @@ + TRUE, + 'edit form' => 'scheduler_form_pane_node_form_menu_content_type_edit_form', + 'render callback' => 'scheduler_form_pane_content_type_render', + 'title' => t('Node form scheduler'), + 'icon' => drupal_get_path('module', 'ctools') . '/plugins/content_types/node_form/icon_node_form.png', + 'description' => t('Scheduler date options on the Node form.'), + 'required context' => new ctools_context_required(t('Form'), 'node_form'), + 'category' => t('Form'), +); + +/** + * Content type render callback. + */ +function scheduler_form_pane_content_type_render($subtype, $conf, $panel_args, &$context) { + $block = new stdClass(); + $block->module = t('node_form'); + $block->title = t('Scheduler options'); + $block->delta = 'scheduler-options'; + + if (isset($context->form)) { + if (isset($context->form['scheduler_settings'])) { + // Lift the form elements from the original form and make sure it renders. + $block->content['scheduler_settings'] = $context->form['scheduler_settings']; + unset($block->content['scheduler_settings']['#pre_render']); + unset($block->content['scheduler_settings']['#theme_wrappers']); + $block->content['scheduler_settings']['#type'] = ''; + + // Deny access on the original form element rather than removing so that + // vertical tabs doesn't clone it. I think this is due to references. + $context->form['scheduler_settings']['#access'] = FALSE; + } + } + else { + // Display placeholder information. + $block->content = t('Scheduler options'); + } + return $block; +} + +/** + * Content type form callback. + */ +function scheduler_form_pane_node_form_menu_content_type_edit_form($form, &$form_state) { + return $form; +} diff --git a/scheduler.module b/scheduler.module index 5339efd..911412c 100644 --- a/scheduler.module +++ b/scheduler.module @@ -1047,3 +1047,11 @@ function scheduler_set_target($source, $node, $target, $value) { } } +/** + * Implements hook_ctools_plugin_directory(). + */ +function scheduler_ctools_plugin_directory($owner, $plugin_type) { + if ($owner == 'ctools' && $plugin_type == 'content_types') { + return 'plugins/content_types'; + } +}