Advertisement
Guest User

Untitled

a guest
Aug 11th, 2021
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. <?php
  2.  
  3. namespace Resource\GUI\Container;
  4. use Resource\GUI\Component;
  5. use Resource\GUI\Container;
  6. use Resource\GUI\GUIException;
  7. use Resource\GUI\Renderer\ListRenderer;
  8.  
  9. /**
  10. * The RadioList Class, extends from abstract GUI Container class.
  11. * It specifies a radio button list in which only one button can be selected.
  12. * @category Resource
  13. * @package GUI
  14. * @subpackage Container
  15. * @author Hall of Famer
  16. * @copyright Mysidia Inc
  17. * @link http://www.mysidiainc.com
  18. * @since 1.3.3
  19. * @todo Restructure the namespace
  20. *
  21. */
  22.  
  23. class RadioList extends Container{
  24.  
  25. /**
  26. * Constructor of RadioList Class, which assigns basic property to this list
  27. * @access public
  28. * @return Void
  29. */
  30. public function __construct($name = "", $components = "", $identity = ""){
  31. if(!empty($name)){
  32. $this->name = $name;
  33. $this->id = $name;
  34. }
  35. parent::__construct($components);
  36. if(!empty($identity)) $this->check($identity);
  37. $this->renderer = new ListRenderer($this);
  38. }
  39.  
  40. /**
  41. * The add method, sets a RadioButton Object to a specific index.
  42. * @param RadioButton $radio
  43. * @param int $index
  44. * @access public
  45. * @return void
  46. */
  47. public function add(Component $radio, $index = -1){
  48. if($radio->getName() != $this->name) throw new GUIException("Cannot add unrelated radiobuttons to a RadioList.");
  49. parent::add($radio, $index);
  50. }
  51.  
  52. /**
  53. * The check method, determines which radio button in this group should be set checked.
  54. * @param String $identity
  55. * @access public
  56. * @return void
  57. */
  58. public function check($identity){
  59. foreach($this->components as $components){
  60. if($components->getValue() == $identity) $components->setChecked(TRUE);
  61. }
  62. }
  63.  
  64. /**
  65. * Magic method __toString for RadioList class, it reveals that the object is a radiolist.
  66. * @access public
  67. * @return String
  68. */
  69. public function __toString(){
  70. return "This is an instance of Mysidia RadioList class.";
  71. }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement