OptionsPropertyGroup.class.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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_udiff(
  56. $this->getProperties(),
  57. array($property),
  58. // for PHP 5.2 compability
  59. create_function(
  60. '$a, $b',
  61. 'return ($a === $b ) ? 0 : 1'
  62. )
  63. );
  64. }
  65. /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
  66. /**
  67. * Gets the instance of the class
  68. *
  69. * @return array
  70. */
  71. public function getGroup()
  72. {
  73. return $this;
  74. }
  75. /**
  76. * Gets the group of properties
  77. *
  78. * @return array
  79. */
  80. public function getProperties()
  81. {
  82. return $this->_properties;
  83. }
  84. /**
  85. * Gets the number of properties
  86. *
  87. * @return int
  88. */
  89. public function getNrOfProperties()
  90. {
  91. return count($this->_properties);
  92. }
  93. }
  94. ?>