OptionsPropertyGroup.class.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Superclass for the Property Group classes.
  5. *
  6. * @package PhpMyAdmin
  7. */
  8. if (! defined('PHPMYADMIN')) {
  9. exit;
  10. }
  11. /* This class extends the OptionsPropertyItem class */
  12. require_once 'OptionsPropertyItem.class.php';
  13. /**
  14. * Parents group property items and provides methods to manage groups of
  15. * properties.
  16. *
  17. * @todo modify descriptions if needed, when the options are integrated
  18. * @package PhpMyAdmin
  19. */
  20. abstract class OptionsPropertyGroup extends OptionsPropertyItem
  21. {
  22. /**
  23. * Holds a group of properties (OptionsPropertyItem instances)
  24. *
  25. * @var array
  26. */
  27. private $_properties;
  28. /**
  29. * Adds a property to the group of properties
  30. *
  31. * @param OptionsPropertyItem $property the property instance to be added
  32. * to the group
  33. *
  34. * @return void
  35. */
  36. public function addProperty($property)
  37. {
  38. if (! $this->getProperties() == null
  39. && in_array($property, $this->getProperties(), true)
  40. ) {
  41. return;
  42. }
  43. $this->_properties [] = $property;
  44. }
  45. /**
  46. * Removes a property from the group of properties
  47. *
  48. * @param OptionsPropertyItem $property the property instance to be removed
  49. * from the group
  50. *
  51. * @return void
  52. */
  53. public function removeProperty($property)
  54. {
  55. $this->_properties = array_diff(
  56. $this->getProperties(),
  57. array($property)
  58. );
  59. }
  60. /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
  61. /**
  62. * Gets the instance of the class
  63. *
  64. * @return array
  65. */
  66. public function getGroup()
  67. {
  68. return $this;
  69. }
  70. /**
  71. * Gets the group of properties
  72. *
  73. * @return array
  74. */
  75. public function getProperties()
  76. {
  77. return $this->_properties;
  78. }
  79. /**
  80. * Gets the number of properties
  81. *
  82. * @return int
  83. */
  84. public function getNrOfProperties()
  85. {
  86. return count($this->_properties);
  87. }
  88. }
  89. ?>