commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-old / ctools / plugins / content_types / page / page_site_name.inc
1 <?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 * Plugins are described by creating a $plugin array which will be used by the
11 * system that includes this file.
12 */
13 $plugin = array(
14 'title' => t('Site name'),
15 'single' => TRUE,
16 'icon' => 'icon_page.png',
17 'description' => t('The name of the site, optionally links to the front page.'),
18 'category' => t('Page elements'),
19 'render last' => TRUE,
20 'defaults' => array(
21 'linked' => FALSE,
22 ),
23 );
24
25 /**
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 /**
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
60 $block->content = filter_xss_admin(variable_get('site_name', 'Drupal'));
61
62 // Optionally link the site name to the homepage.
63 if (!empty($conf['linked'])) {
64 $block->content = l($block->content, '<front>');
65 }
66
67 return $block;
68 }