Mixin_Form_Manager

The NextGEN Gallery Mixin Form Manager class.

Defined (1)

The class is defined in the following location(s).

/products/photocrati_nextgen/modules/nextgen_admin/package.module.nextgen_admin.php  
  1. class Mixin_Form_Manager extends Mixin 
  2. /** 
  3. * Adds one or more 
  4. * @param type $type 
  5. * @param type $form_names 
  6. * @return type 
  7. */ 
  8. function add_form($type, $form_names) 
  9. if (!isset($this->object->_forms[$type])) { 
  10. $this->object->_forms[$type] = array(); 
  11. if (!is_array($form_names)) { 
  12. $form_names = array($form_names); 
  13. foreach ($form_names as $form) { 
  14. $this->object->_forms[$type][] = $form; 
  15. return $this->object->get_form_count($type); 
  16. /** 
  17. * Alias for add_form() method 
  18. * @param string $type 
  19. * @param string|array $form_names 
  20. * @return int 
  21. */ 
  22. function add_forms($type, $form_names) 
  23. return $this->object->add_form($type, $form_names); 
  24. /** 
  25. * Removes one or more forms of a particular type 
  26. * @param string $type 
  27. * @param string|array $form_names 
  28. * @return int number of forms remaining for the type 
  29. */ 
  30. function remove_form($type, $form_names) 
  31. $retval = 0; 
  32. if (isset($this->object->_forms[$type])) { 
  33. foreach ($form_names as $form) { 
  34. if ($index = array_search($form, $this->object->_forms[$type])) { 
  35. unsset($this->object->_forms[$type][$index]); 
  36. $retval = $this->object->get_form_count($type); 
  37. return $retval; 
  38. /** 
  39. * Alias for remove_form() method 
  40. * @param string $type 
  41. * @param string|array $form_names 
  42. * @return int 
  43. */ 
  44. function remove_forms($type, $form_names) 
  45. return $this->object->remove_form($type, $form_names); 
  46. /** 
  47. * Gets known form types 
  48. * @return type 
  49. */ 
  50. function get_known_types() 
  51. return array_keys($this->object->_forms); 
  52. /** 
  53. * Gets forms of a particular type 
  54. * @param string $type 
  55. * @return array 
  56. */ 
  57. function get_forms($type, $instantiate = FALSE) 
  58. $retval = array(); 
  59. if (isset($this->object->_forms[$type])) { 
  60. if (!$instantiate) { 
  61. $retval = $this->object->_forms[$type]; 
  62. } else { 
  63. foreach ($this->object->_forms[$type] as $context) { 
  64. $retval[] = $this->get_registry()->get_utility('I_Form', $context); 
  65. return $retval; 
  66. /** 
  67. * Gets the number of forms registered for a particular type 
  68. * @param string $type 
  69. * @return int 
  70. */ 
  71. function get_form_count($type) 
  72. $retval = 0; 
  73. if (isset($this->object->_forms[$type])) { 
  74. $retval = count($this->object->_forms[$type]); 
  75. return $retval; 
  76. /** 
  77. * Gets the index of a particular form 
  78. * @param string $type 
  79. * @param string $name 
  80. * @return FALSE|int 
  81. */ 
  82. function get_form_index($type, $name) 
  83. $retval = FALSE; 
  84. if ($this->object->get_form_count($type) > 0) { 
  85. $retval = array_search($name, $this->object->_forms[$type]); 
  86. return $retval; 
  87. /** 
  88. * Adds one or more forms before a form already registered 
  89. * @param string $type 
  90. * @param string $before 
  91. * @param string|array $form_names 
  92. * @param int $offset 
  93. * @return int 
  94. */ 
  95. function add_form_before($type, $before, $form_names, $offset = 0) 
  96. $retval = 0; 
  97. $index = FALSE; 
  98. $use_add = FALSE; 
  99. // Append the forms 
  100. if ($this->object->get_form_count($type) == 0) { 
  101. $use_add = TRUE; 
  102. } else { 
  103. if (($index = $this->object->get_form_index($type, $name)) == FALSE) { 
  104. $use_add = FALSE; 
  105. if ($use_add) { 
  106. $this->object->add_forms($type, $form_names); 
  107. } else { 
  108. $before = array_slice($this->object->get_forms($type), 0, $offset); 
  109. $after = array_slice($this->object->get_forms($type), $offset); 
  110. $this->object->_forms[$type] = array_merge($before, $form_names, $after); 
  111. $retval = $this->object->get_form_count($type); 
  112. return $retval; 
  113. /** 
  114. * Adds one or more forms after an existing form 
  115. * @param string $type 
  116. * @param string $after 
  117. * @param string|array $form_names 
  118. * @return int 
  119. */ 
  120. function add_form_after($type, $after, $form_names) 
  121. return $this->object->add_form_before($type, $after, $form_names, 1);