1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Plugin to handle the 'page_site_name' content type which allows the
|
6 |
|
|
* site_name of the site to be embedded into a panel.
|
7 |
|
|
*/
|
8 |
|
|
|
9 |
|
|
/**
|
10 |
e4c061ad
|
Assos Assos
|
* Plugins are described by creating a $plugin array which will be used by the
|
11 |
|
|
* system that includes this file.
|
12 |
85ad3d82
|
Assos Assos
|
*/
|
13 |
|
|
$plugin = array(
|
14 |
|
|
'title' => t('Site name'),
|
15 |
|
|
'single' => TRUE,
|
16 |
|
|
'icon' => 'icon_page.png',
|
17 |
e4c061ad
|
Assos Assos
|
'description' => t('The name of the site, optionally links to the front page.'),
|
18 |
85ad3d82
|
Assos Assos
|
'category' => t('Page elements'),
|
19 |
|
|
'render last' => TRUE,
|
20 |
e4c061ad
|
Assos Assos
|
'defaults' => array(
|
21 |
|
|
'linked' => FALSE,
|
22 |
|
|
),
|
23 |
85ad3d82
|
Assos Assos
|
);
|
24 |
|
|
|
25 |
e4c061ad
|
Assos Assos
|
/**
|
26 |
|
|
* Settings form for the Site Name pane.
|
27 |
|
|
*/
|
28 |
|
|
function ctools_page_site_name_content_type_edit_form($form, &$form_state) {
|
29 |
|
|
$conf = $form_state['conf'];
|
30 |
|
|
|
31 |
|
|
$form['linked'] = array(
|
32 |
|
|
'#title' => t('Linked'),
|
33 |
|
|
'#description' => t('Link the site name to the home page.'),
|
34 |
|
|
'#type' => 'checkbox',
|
35 |
|
|
'#default_value' => isset($conf['linked']) ? $conf['linked'] : FALSE,
|
36 |
|
|
);
|
37 |
|
|
|
38 |
|
|
return $form;
|
39 |
|
|
}
|
40 |
|
|
|
41 |
|
|
/**
|
42 |
|
|
* The submit form stores the data in $conf.
|
43 |
|
|
*/
|
44 |
|
|
function ctools_page_site_name_content_type_edit_form_submit($form, &$form_state) {
|
45 |
|
|
foreach (array_keys($form_state['plugin']['defaults']) as $key) {
|
46 |
|
|
if (isset($form_state['values'][$key])) {
|
47 |
|
|
$form_state['conf'][$key] = $form_state['values'][$key];
|
48 |
|
|
}
|
49 |
|
|
}
|
50 |
|
|
}
|
51 |
|
|
|
52 |
85ad3d82
|
Assos Assos
|
/**
|
53 |
|
|
* Output function for the 'page_site_name' content type.
|
54 |
|
|
*
|
55 |
|
|
* Outputs the site_name for the current page.
|
56 |
|
|
*/
|
57 |
|
|
function ctools_page_site_name_content_type_render($subtype, $conf, $panel_args) {
|
58 |
|
|
$block = new stdClass();
|
59 |
e4c061ad
|
Assos Assos
|
|
60 |
85ad3d82
|
Assos Assos
|
$block->content = filter_xss_admin(variable_get('site_name', 'Drupal'));
|
61 |
|
|
|
62 |
e4c061ad
|
Assos Assos
|
// Optionally link the site name to the homepage.
|
63 |
|
|
if (!empty($conf['linked'])) {
|
64 |
|
|
$block->content = l($block->content, '<front>');
|
65 |
|
|
}
|
66 |
|
|
|
67 |
85ad3d82
|
Assos Assos
|
return $block;
|
68 |
|
|
} |