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