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