SproutCMS

This is the code documentation for the SproutCMS project

source of /sprout/Widgets/RichTextWidget.php

  1. <?php
  2. /*
  3.  * Copyright (C) 2017 Karmabunny Pty Ltd.
  4.  *
  5.  * This file is a part of SproutCMS.
  6.  *
  7.  * SproutCMS is free software: you can redistribute it and/or modify it under the terms
  8.  * of the GNU General Public License as published by the Free Software Foundation, either
  9.  * version 2 of the License, or (at your option) any later version.
  10.  *
  11.  * For more information, visit <http://getsproutcms.com>.
  12.  */
  13.  
  14. namespace Sprout\Widgets;
  15.  
  16. use Kohana;
  17.  
  18. use Sprout\Helpers\ContentReplace;
  19. use Sprout\Helpers\Form;
  20.  
  21.  
  22. /**
  23. * Spits out HTML code
  24. **/
  25. class RichTextWidget extends Widget
  26. {
  27. protected $friendly_name = "Text block";
  28. protected $friendly_desc = 'HTML text content which can include links and images';
  29.  
  30.  
  31. /**
  32.   * Return the front-end view of this widget
  33.   *
  34.   * @param int $orientation The orientation of the widget; see e.g. {@see WidgetArea::ORIENTATION_WIDE}
  35.   * @return string HTML to be displayed
  36.   */
  37. public function render($orientation)
  38. {
  39. return ContentReplace::html($this->settings['text']) . '<div class="clear"></div>';
  40. }
  41.  
  42.  
  43. /**
  44.   * Return the settings form for this widget
  45.   *
  46.   * @return string a richtext input field; its type is config-specified, with TinyMCE4 the default
  47.   */
  48. public function getSettingsForm()
  49. {
  50. $richtext_width = Kohana::config('sprout.admin_richtext_width');
  51. $richtext_height = Kohana::config('sprout.admin_richtext_height');
  52.  
  53. return Form::richtext('text', ['width' => $richtext_width, 'height' => $richtext_height]);
  54. }
  55. }
  56.