SproutCMS

This is the code documentation for the SproutCMS project

source of /sprout/Helpers/RefineWidget.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\Helpers;
  15.  
  16.  
  17. /**
  18.  * Base class for widgets included in a {@see RefineBar}
  19.  */
  20. abstract class RefineWidget {
  21. protected $name;
  22.  
  23.  
  24. public function __construct($name, $label)
  25. {
  26. $this->name = $name;
  27. $this->label = $label;
  28. }
  29.  
  30. public final function setName ($name) {
  31. $this->name = $name;
  32. }
  33.  
  34. public final function getName () {
  35. return $this->name;
  36. }
  37.  
  38.  
  39. public final function setLabel ($label) {
  40. $this->label = $label;
  41. }
  42.  
  43. public final function getLabel () {
  44. return $this->label;
  45. }
  46.  
  47.  
  48.  
  49. /**
  50.   * Returns the current value for this refine widget
  51.   **/
  52. public final function getValue() {
  53. return @$_GET[$this->name];
  54. }
  55.  
  56. /**
  57.   * Draws the widget.
  58.   * @return string The HTML for the widget.
  59.   **/
  60. public abstract function render();
  61.  
  62. }
  63.  
  64.  
  65.