diff --git a/plugins/content_types/service_links/service_links.inc b/plugins/content_types/service_links/service_links.inc new file mode 100644 index 0000000..2b90f22 --- /dev/null +++ b/plugins/content_types/service_links/service_links.inc @@ -0,0 +1,126 @@ + TRUE, + 'title' => t('Service links panel pane'), + 'defaults' => array( + 'service_links_style' => 'service_links', + 'service_links_block_style' => '' + ), + 'icon' => 'icon_node.png', + 'description' => t('Service links'), + 'category' => t('Miscellaneous'), +); + +/** + * Render the custom content type. + */ +function service_links_service_links_content_type_render($subtype, $conf, $panel_args, $context) { + $content = NULL; + if (user_access('access service links')) { + $node = menu_get_object('node'); + $style = $conf['service_links_block_style']; + + if (isset($node)) { + if (service_links_show($node)) { + switch ($conf['service_links_style']) { + case 'service_links': + $content = theme('service_links_block_format', array( + 'items' => service_links_render($node, FALSE, $style), + 'style' => $style) + ); + break; + case 'service_links_fisheye': + $content = theme('service_links_fisheye_format', array( + 'items' => service_links_render($node, FALSE, SERVICE_LINKS_STYLE_FISHEYE)) + ); + break; + } + } + } + elseif (!isset($node)) { + switch ($conf['service_links_style']) { + case 'service_links': + $options = array( + 'style' => $style, + 'link_to_front' => variable_get('service_links_block_not_node_front', FALSE), + ); + $content = theme('service_links_block_format', array( + 'items' => service_links_render(NULL, FALSE, $options), + 'style' => $style, + )); + break; + case 'service_links_fisheye': + $content = theme('service_links_fisheye_format', array( + 'items' => service_links_render(NULL, FALSE, SERVICE_LINKS_STYLE_FISHEYE)) + ); + break; + } + } + } + + // Build the content type block. + $block = new stdClass(); + $block->content = $content; + + return $block; +} + +/** + * Returns an edit form for custom content type settings. + */ +function service_links_service_links_content_type_edit_form($form, &$form_state) { + // Get the default values. + $conf = $form_state['conf']; + + $form['service_links_style'] = array( + '#type' => 'select', + '#title' => t('Service link icon style'), + '#options' => array( + 'service_links' => t('Normal service links display'), + 'service_links_fisheye' => t('Service links with FishEye effect'), + ), + '#default_value' => isset($conf['service_links_style']) ? $conf['service_links_style']: TRUE, + ); + + $form['service_links_block_style'] = array( + '#type' => 'select', + '#title' => t('Service link display'), + '#options' => array( + 1 => t('Only text'), + 2 => t('Only icon'), + 3 => t('Icon and text'), + ), + '#default_value' => isset($conf['service_links_block_style']) ? $conf['service_links_block_style']: TRUE, + '#states' => array( + 'invisible' => array ( + ':input[name="service_links_style"]' => array( + 'value' => 'service_links_fisheye' + ) + ) + ), + ); + + return $form; +} + +/** + * Submit handler. + */ +function service_links_service_links_content_type_edit_form_submit($form, &$form_state) { + // Copy everything from our defaults. + foreach (array_keys($form_state['plugin']['defaults']) as $key) { + $form_state['conf'][$key] = $form_state['values'][$key]; + } +} + +/** + * Returns the administrative title for a type. + */ +function service_links_service_links_content_type_admin_title($subtype, $conf, $context) { + return t('Service links'); +} diff --git a/service_links.module b/service_links.module index 035642b..49fc9c1 100644 --- a/service_links.module +++ b/service_links.module @@ -475,3 +475,15 @@ function _service_links_show($node) { return $links_show; } + +/** + * Implementation of hook_ctools_plugin_directory() to let the system know + * we implement task and task_handler plugins. + */ +function service_links_ctools_plugin_directory($module, $plugin) { + // Safety: go away if CTools is not at an appropriate version. + if (!module_invoke('ctools', 'api_version', PANELS_REQUIRED_CTOOLS_API)) { + return; + } + return 'plugins/' . $plugin; +}