1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* The 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
|
* Implements hook_get_pane_links_alter().
|
41
|
*/
|
42
|
function ctools_custom_content_get_pane_links_alter(&$links, $pane, $content_type) {
|
43
|
if ($pane->type == 'custom') {
|
44
|
if (!isset($pane->configuration['name'])) {
|
45
|
$name_of_pane = $pane->subtype;
|
46
|
}
|
47
|
else {
|
48
|
$name_of_pane = $pane->configuration['name'];
|
49
|
}
|
50
|
|
51
|
$links['top']['edit_custom_content'] = array(
|
52
|
'title' => t('Edit custom content pane'),
|
53
|
'href' => url('admin/structure/ctools-content/list/' . $name_of_pane . '/edit', array('absolute' => TRUE)),
|
54
|
'attributes' => array('target' => array('_blank')),
|
55
|
);
|
56
|
}
|
57
|
}
|
58
|
|
59
|
/**
|
60
|
* Create callback for creating a new CTools custom content type.
|
61
|
*
|
62
|
* This ensures we get proper defaults from the plugin for its settings.
|
63
|
*/
|
64
|
function ctools_content_type_new($set_defaults) {
|
65
|
$item = ctools_export_new_object('ctools_custom_content', $set_defaults);
|
66
|
ctools_include('content');
|
67
|
$plugin = ctools_get_content_type('custom');
|
68
|
$item->settings = ctools_content_get_defaults($plugin, array());
|
69
|
return $item;
|
70
|
}
|
71
|
|
72
|
/**
|
73
|
* Implementation of hook_panels_dashboard_blocks().
|
74
|
*
|
75
|
* Adds page information to the Panels dashboard.
|
76
|
*/
|
77
|
function ctools_custom_content_panels_dashboard_blocks(&$vars) {
|
78
|
$vars['links']['ctools_custom_content'] = array(
|
79
|
'title' => l(t('Custom content'), 'admin/structure/ctools-content/add'),
|
80
|
'description' => t('Custom content panes are basic HTML you enter that can be reused in all of your panels.'),
|
81
|
);
|
82
|
|
83
|
// Load all mini panels and their displays.
|
84
|
ctools_include('export');
|
85
|
$items = ctools_export_crud_load_all('ctools_custom_content');
|
86
|
$count = 0;
|
87
|
$rows = array();
|
88
|
|
89
|
foreach ($items as $item) {
|
90
|
$rows[] = array(
|
91
|
check_plain($item->admin_title),
|
92
|
array(
|
93
|
'data' => l(t('Edit'), "admin/structure/ctools-content/list/$item->name/edit"),
|
94
|
'class' => 'links',
|
95
|
),
|
96
|
);
|
97
|
|
98
|
// Only show 10.
|
99
|
if (++$count >= 10) {
|
100
|
break;
|
101
|
}
|
102
|
}
|
103
|
|
104
|
if ($rows) {
|
105
|
$content = theme('table', array('rows' => $rows, 'attributes' => array('class' => 'panels-manage')));
|
106
|
}
|
107
|
else {
|
108
|
$content = '<p>' . t('There are no custom content panes.') . '</p>';
|
109
|
}
|
110
|
|
111
|
$vars['blocks']['ctools_custom_content'] = array(
|
112
|
'title' => t('Manage custom content'),
|
113
|
'link' => l(t('Go to list'), 'admin/structure/ctools-content'),
|
114
|
'content' => $content,
|
115
|
'class' => 'dashboard-content',
|
116
|
'section' => 'right',
|
117
|
);
|
118
|
}
|