boxes_simple.inc

  1. nittany7 modules/contrib/boxes/plugins/boxes_simple.inc
  2. cis7 modules/contrib/boxes/plugins/boxes_simple.inc
  3. mooc7 modules/contrib/boxes/plugins/boxes_simple.inc

Classes

Namesort descending Description
boxes_simple Simple custom text box.

File

modules/contrib/boxes/plugins/boxes_simple.inc
View source
  1. <?php
  2. /**
  3. * Simple custom text box.
  4. */
  5. class boxes_simple extends boxes_box {
  6. /**
  7. * Implementation of boxes_box::options_defaults().
  8. */
  9. public function options_defaults() {
  10. return array(
  11. 'body' => array(
  12. 'value' => '',
  13. 'format' => filter_default_format(),
  14. ),
  15. );
  16. }
  17. /**
  18. * Implementation of boxes_box::options_form().
  19. */
  20. public function options_form(&$form_state) {
  21. $format = filter_format_load($this->options['body']['format']);
  22. if (filter_access($format)) {
  23. $form = array();
  24. $form['body'] = array(
  25. '#type' => 'text_format',
  26. '#base_type' => 'textarea',
  27. '#title' => t('Box body'),
  28. '#default_value' => $this->options['body']['value'],
  29. '#rows' => 6,
  30. '#format' => $this->options['body']['format'] ? $this->options['body']['format'] : NULL,
  31. '#description' => t('The content of the block as shown to the user.'),
  32. );
  33. return $form;
  34. }
  35. }
  36. /**
  37. * Implementation of boxes_box::render().
  38. */
  39. public function render() {
  40. $content = '';
  41. if (!empty($this->options['body']['value']) && isset($this->options['body']['format'])) {
  42. $content = check_markup($this->options['body']['value'], $this->options['body']['format'], $langcode = '' /* TODO Set this variable. */, FALSE);
  43. }
  44. $title = isset($this->title) ? $this->title : NULL;
  45. return array(
  46. 'delta' => $this->delta, // Crucial.
  47. 'title' => $title,
  48. 'subject' => check_plain($title),
  49. 'content' => $content,
  50. );
  51. }
  52. }