page_site_name.inc 1.7 KB

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