ctools_custom_content.module

Tracking 6.x-1.x branch
  1. drupal
    1. 6 contributions/ctools/ctools_custom_content/ctools_custom_content.module
    2. 7 contributions/ctools/ctools_custom_content/ctools_custom_content.module

ctools_custom_content module

This module allows styles to be created and managed on behalf of modules that implement styles.

The ctools_custom_content tool allows recolorable styles to be created via a miniature scripting language. Panels utilizes this to allow administrators to add styles directly to any panel display.

Functions & methods

NameDescription
ctools_content_type_newCreate callback for creating a new CTools custom content type.
ctools_custom_content_ctools_plugin_directoryImplementation of hook_ctools_plugin_directory() to let the system know we implement task and task_handler plugins.
ctools_custom_content_panels_dashboard_blocksImplementation of hook_panels_dashboard_blocks().
ctools_custom_content_permImplementation of hook_perm()

File

View source
  1. <?php
  2. /**
  3. * @file
  4. * ctools_custom_content module
  5. *
  6. * This module allows styles to be created and managed on behalf of modules
  7. * that implement styles.
  8. *
  9. * The ctools_custom_content tool allows recolorable styles to be created via a miniature
  10. * scripting language. Panels utilizes this to allow administrators to add
  11. * styles directly to any panel display.
  12. */
  13. /**
  14. * Implementation of hook_perm()
  15. */
  16. function ctools_custom_content_perm() {
  17. return array(
  18. 'administer custom content',
  19. );
  20. }
  21. /**
  22. * Implementation of hook_ctools_plugin_directory() to let the system know
  23. * we implement task and task_handler plugins.
  24. */
  25. function ctools_custom_content_ctools_plugin_directory($module, $plugin) {
  26. // Most of this module is implemented as an export ui plugin, and the
  27. // rest is in ctools/includes/ctools_custom_content.inc
  28. if ($module == 'ctools' && $plugin == 'export_ui') {
  29. return 'plugins/' . $plugin;
  30. }
  31. }
  32. /**
  33. * Create callback for creating a new CTools custom content type.
  34. *
  35. * This ensures we get proper defaults from the plugin for its settings.
  36. */
  37. function ctools_content_type_new($set_defaults) {
  38. $item = ctools_export_new_object('ctools_custom_content', $set_defaults);
  39. ctools_include('content');
  40. $plugin = ctools_get_content_type('custom');
  41. $item->settings = ctools_content_get_defaults($plugin, array());
  42. return $item;
  43. }
  44. /**
  45. * Implementation of hook_panels_dashboard_blocks().
  46. *
  47. * Adds page information to the Panels dashboard.
  48. */
  49. function ctools_custom_content_panels_dashboard_blocks(&$vars) {
  50. $vars['links']['ctools_custom_content'] = array(
  51. 'title' => l(t('Custom content'), 'admin/build/ctools-content/add'),
  52. 'description' => t('Custom content panes are basic HTML you enter that can be reused in all of your panels.'),
  53. );
  54. // Load all mini panels and their displays.
  55. ctools_include('export');
  56. $items = ctools_export_crud_load_all('ctools_custom_content');
  57. $count = 0;
  58. $rows = array();
  59. foreach ($items as $item) {
  60. $rows[] = array(
  61. check_plain($item->admin_title),
  62. array(
  63. 'data' => l(t('Edit'), "admin/build/ctools-content/list/$item->name/edit"),
  64. 'class' => 'links',
  65. ),
  66. );
  67. // Only show 10.
  68. if (++$count >= 10) {
  69. break;
  70. }
  71. }
  72. if ($rows) {
  73. $content = theme('table', array(), $rows, array('class' => 'panels-manage'));
  74. }
  75. else {
  76. $content = '<p>' . t('There are no custom content panes.') . '</p>';
  77. }
  78. $vars['blocks']['ctools_custom_content'] = array(
  79. 'title' => t('Manage custom content'),
  80. 'link' => l(t('Go to list'), 'admin/build/ctools-content'),
  81. 'content' => $content,
  82. 'class' => 'dashboard-content',
  83. 'section' => 'right',
  84. );
  85. }