SproutCMS

This is the code documentation for the SproutCMS project

source of /sprout/Widgets/HelloWorldWidget.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 Sprout\Helpers\Enc;
  17. use Sprout\Helpers\Form;
  18. use Sprout\Helpers\WidgetArea;
  19.  
  20.  
  21. /**
  22. * Basically just a test widget
  23. **/
  24. class HelloWorldWidget extends Widget
  25. {
  26. protected $friendly_name = "Hello world";
  27. protected $friendly_desc = "This is a test widget";
  28.  
  29.  
  30. /**
  31.   * Return the front-end view of this widget
  32.   *
  33.   * @param int $orientation The orientation of the widget.
  34.   **/
  35. public function render($orientation)
  36. {
  37. $out = '<p>' . Enc::html($this->settings['message']);
  38.  
  39. if ($orientation == WidgetArea::ORIENTATION_TALL) {
  40. $out .= '<br>Orientation: Tall</p>';
  41.  
  42. } else if ($orientation == WidgetArea::ORIENTATION_WIDE) {
  43. $out .= '<br>Orientation: Wide</p>';
  44. }
  45.  
  46. return $out;
  47. }
  48.  
  49.  
  50. /**
  51.   * Return the settings form for this widget
  52.   **/
  53. public function getSettingsForm()
  54. {
  55. return Form::text('message');
  56. }
  57.  
  58. }
  59.