C_NextGEN_Wizard_Manager

Class C_NextGEN_Wizard_Manager.

Defined (1)

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

/products/photocrati_nextgen/modules/nextgen_admin/package.module.nextgen_admin.php  
  1. class C_NextGEN_Wizard_Manager extends C_Component 
  2. static $_instances = array(); 
  3. var $_active = false; 
  4. var $_wizards = array(); 
  5. var $_wizards_data = array(); 
  6. var $_starter = null; 
  7. var $_handled_query = false; 
  8. /** 
  9. * Returns an instance of the wizard manager 
  10. * @returns C_NextGEN_Wizard_Manager 
  11. */ 
  12. static function get_instance($context = FALSE) 
  13. if (!isset(self::$_instances[$context])) { 
  14. $klass = get_class(); 
  15. self::$_instances[$context] = new $klass($context); 
  16. return self::$_instances[$context]; 
  17. /** 
  18. * Defines the instance 
  19. * @param mixed $context 
  20. */ 
  21. function define($context = FALSE) 
  22. parent::define($context); 
  23. $this->implement('I_NextGEN_Wizard_Manager'); 
  24. $this->_wizards_data = get_option('ngg_wizards'); 
  25. function add_wizard($id, $active = false, $priority = 100) 
  26. $wizard = new C_NextGEN_Wizard($id); 
  27. $wizard->set_active($active); 
  28. $wizard->set_priority($priority); 
  29. if (isset($this->_wizards_data[$id])) { 
  30. $wizard->_set_data($this->_wizards_data[$id]); 
  31. $this->_wizards[$id] = $wizard; 
  32. return $wizard; 
  33. function remove_wizard($id) 
  34. if (isset($this->_wizards[$id])) { 
  35. unset($this->_wizards[$id]); 
  36. function get_wizard($id) 
  37. if (isset($this->_wizards[$id])) { 
  38. return $this->_wizards[$id]; 
  39. return null; 
  40. function _sort_wizards($wizard1, $wizard2) 
  41. $diff = $wizard1->get_priority() - $wizard2->get_priority(); 
  42. if ($diff == 0) { 
  43. $wizard_ids = array_keys($this->_wizards); 
  44. $index1 = array_search($wizard1->get_id(), $wizard_ids, true); 
  45. $index2 = array_search($wizard2->get_id(), $wizard_ids, true); 
  46. if ($index1 !== false && $index2 !== false) { 
  47. $diff = $index1 - $index2; 
  48. return $diff; 
  49. function get_next_wizard() 
  50. if (!$this->is_active()) { 
  51. return null; 
  52. $wizards = $this->_wizards; 
  53. if (count($wizards) > 0) { 
  54. if (count($wizards) > 1) { 
  55. uasort($wizards, array($this, '_sort_wizards')); 
  56. foreach ($wizards as $id => $wizard) { 
  57. if ($wizard->is_active()) { 
  58. return $wizard; 
  59. return null; 
  60. function get_running_wizard() 
  61. if (!$this->is_active()) { 
  62. return null; 
  63. $wizards = $this->_wizards; 
  64. if (count($wizards) > 0) { 
  65. if (count($wizards) > 1) { 
  66. uasort($wizards, array($this, '_sort_wizards')); 
  67. foreach ($wizards as $id => $wizard) { 
  68. if ($wizard->is_active() && $wizard->get_current_step() != null) { 
  69. return $wizard; 
  70. return null; 
  71. function get_starter() 
  72. return $this->_starter; 
  73. function set_starter($starter) 
  74. $this->_starter = $starter; 
  75. function is_active() 
  76. return $this->_active; 
  77. function set_active($active) 
  78. $this->_active = $active; 
  79. function generate_wizard_query($wizard, $action, $params = array()) 
  80. function handle_wizard_query($parameters = NULL, $force = false) 
  81. if ($this->_handled_query && !$force) { 
  82. return; 
  83. if ($parameters == null) { 
  84. $parameters = $_REQUEST; 
  85. // determine if we're currently in the middle of a wizard (i.e. wizard that involves multiple pages) 
  86. // if so then determine the current step 
  87. if (isset($parameters['ngg_wizard'])) { 
  88. $wizard = $this->get_wizard($parameters['ngg_wizard']); 
  89. if ($wizard != null) { 
  90. $wizard->set_active(true); 
  91. $steps = $wizard->get_step_list(); 
  92. $count = count($steps); 
  93. $current_step = isset($parameters['ngg_wizard_step']) ? $parameters['ngg_wizard_step'] : null; 
  94. if ($current_step != null) { 
  95. $idx = array_search($current_step, $steps); 
  96. if ($idx !== false) { 
  97. $idx++; 
  98. if ($idx < $count) { 
  99. $wizard->set_current_step($steps[$idx]); 
  100. } else { 
  101. if ($count > 0) { 
  102. $wizard->set_current_step($steps[0]); 
  103. $this->_handled_query = true;