Mixin_Page_Manager

The NextGEN Gallery Mixin Page 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_Page_Manager extends Mixin 
  2. function add($slug, $properties = array()) 
  3. if (!isset($properties['adapter'])) { 
  4. $properties['adapter'] = NULL; 
  5. if (!isset($properties['parent'])) { 
  6. $properties['parent'] = NULL; 
  7. if (!isset($properties['add_menu'])) { 
  8. $properties['add_menu'] = TRUE; 
  9. if (!isset($properties['before'])) { 
  10. $properties['before'] = NULL; 
  11. if (!isset($properties['url'])) { 
  12. $properties['url'] = NULL; 
  13. $this->object->_pages[$slug] = $properties; 
  14. function move_page($slug, $other_slug, $after = false) 
  15. $page_list = $this->object->_pages; 
  16. if (isset($page_list[$slug]) && isset($page_list[$other_slug])) { 
  17. $slug_list = array_keys($page_list); 
  18. $item_list = array_values($page_list); 
  19. $slug_idx = array_search($slug, $slug_list); 
  20. $item = $page_list[$slug]; 
  21. unset($slug_list[$slug_idx]); 
  22. unset($item_list[$slug_idx]); 
  23. $slug_list = array_values($slug_list); 
  24. $item_list = array_values($item_list); 
  25. $other_idx = array_search($other_slug, $slug_list); 
  26. array_splice($slug_list, $other_idx, 0, array($slug)); 
  27. array_splice($item_list, $other_idx, 0, array($item)); 
  28. $this->object->_pages = array_combine($slug_list, $item_list); 
  29. function remove($slug) 
  30. unset($this->object->_pages[$slug]); 
  31. function get_all() 
  32. return $this->object->_pages; 
  33. function setup() 
  34. $registry = $this->get_registry(); 
  35. $controllers = array(); 
  36. foreach ($this->object->_pages as $slug => $properties) { 
  37. $page_title = "Unnamed Page"; 
  38. $menu_title = "Unnamed Page"; 
  39. $permission = NULL; 
  40. $callback = NULL; 
  41. // There's two type of pages we can have. Some are powered by our controllers, and others 
  42. // are powered by WordPress, such as a custom post type page. 
  43. // Is this powered by a controller? If so, we expect an adapter 
  44. if ($properties['adapter']) { 
  45. $controllers[$slug] = $registry->get_utility('I_NextGen_Admin_Page', $slug); 
  46. $menu_title = $controllers[$slug]->get_page_heading(); 
  47. $page_title = $controllers[$slug]->get_page_title(); 
  48. $permission = $controllers[$slug]->get_required_permission(); 
  49. $callback = array(&$controllers[$slug], 'index_action'); 
  50. } elseif ($properties['url']) { 
  51. $slug = $properties['url']; 
  52. if (isset($properties['menu_title'])) { 
  53. $menu_title = $properties['menu_title']; 
  54. if (isset($properties['permission'])) { 
  55. $permission = $properties['permission']; 
  56. // Are we to add a menu? 
  57. if ($properties['add_menu'] && current_user_can($permission)) { 
  58. add_submenu_page($properties['parent'], $page_title, $menu_title, $permission, $slug, $callback); 
  59. if ($properties['before']) { 
  60. global $submenu; 
  61. if (empty($submenu[$properties['parent']])) { 
  62. $parent = null; 
  63. } else { 
  64. $parent = $submenu[$properties['parent']]; 
  65. $item_index = -1; 
  66. $before_index = -1; 
  67. if ($parent != null) { 
  68. foreach ($parent as $index => $menu) { 
  69. // under add_submenu_page, $menu_slug is index 2 
  70. // $submenu[$parent_slug][] = array ( $menu_title, $capability, $menu_slug, $page_title ); 
  71. if ($menu[2] == $slug) { 
  72. $item_index = $index; 
  73. } else { 
  74. if ($menu[2] == $properties['before']) { 
  75. $before_index = $index; 
  76. if ($item_index > -1 && $before_index > -1) { 
  77. $item = $parent[$item_index]; 
  78. unset($parent[$item_index]); 
  79. $parent = array_values($parent); 
  80. if ($item_index < $before_index) { 
  81. $before_index--; 
  82. array_splice($parent, $before_index, 0, array($item)); 
  83. $submenu[$properties['parent']] = $parent;