A_NextGen_Album_Breadcrumbs

Class A_NextGen_Album_Breadcrumbs.

Defined (1)

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

/products/photocrati_nextgen/modules/nextgen_basic_album/package.module.nextgen_basic_album.php  
  1. class A_NextGen_Album_Breadcrumbs extends Mixin 
  2. public $breadcrumb_cache = array(); 
  3. function are_breadcrumbs_enabled($display_settings) 
  4. $retval = FALSE; 
  5. if (isset($display_settings['enable_breadcrumbs']) && $display_settings['enable_breadcrumbs']) { 
  6. $retval = TRUE; 
  7. } elseif (isset($display_settings['original_settings']) && $this->are_breadcrumbs_enabled($display_settings['original_settings'])) { 
  8. $retval = TRUE; 
  9. return $retval; 
  10. function get_original_album_entities($display_settings) 
  11. $retval = array(); 
  12. if (isset($display_settings['original_album_entities'])) { 
  13. $retval = $display_settings['original_album_entities']; 
  14. } elseif (isset($display_settings['original_settings']) && $this->get_original_album_entities($display_settings['original_settings'])) { 
  15. $retval = $this->get_original_album_entities($display_settings['original_settings']); 
  16. return $retval; 
  17. function render_object() 
  18. $root_element = $this->call_parent('render_object'); 
  19. if ($displayed_gallery = $this->object->get_param('displayed_gallery')) { 
  20. $ds = $displayed_gallery->display_settings; 
  21. if ($this->are_breadcrumbs_enabled($ds) && ($original_entities = $this->get_original_album_entities($ds))) { 
  22. $original_entities = $this->get_original_album_entities($ds); 
  23. if (!empty($ds['original_album_id'])) { 
  24. $ids = $ds['original_album_id']; 
  25. } else { 
  26. $ids = $displayed_gallery->container_ids; 
  27. $breadcrumbs = $this->object->generate_breadcrumb($ids, $original_entities); 
  28. foreach ($root_element->find('nextgen_gallery.gallery_container', TRUE) as $container) { 
  29. $container->insert($breadcrumbs); 
  30. return $root_element; 
  31. function render_legacy_template_breadcrumbs($displayed_gallery, $entities, $gallery_id = FALSE) 
  32. $ds = $displayed_gallery->display_settings; 
  33. if (!empty($entities) && !empty($ds['template']) && $this->are_breadcrumbs_enabled($ds)) { 
  34. if ($gallery_id) { 
  35. if (is_array($gallery_id)) { 
  36. $ids = $gallery_id; 
  37. } else { 
  38. $ids = array($gallery_id); 
  39. } elseif (!empty($ds['original_album_id'])) { 
  40. $ids = $ds['original_album_id']; 
  41. } else { 
  42. $ids = $displayed_gallery->container_ids; 
  43. if (!empty($ds['original_album_entities'])) { 
  44. $breadcrumb_entities = $ds['original_album_entities']; 
  45. } else { 
  46. $breadcrumb_entities = $entities; 
  47. return $this->object->generate_breadcrumb($ids, $breadcrumb_entities); 
  48. } else { 
  49. return ''; 
  50. function find_gallery_parent($gallery_id, $sortorder) 
  51. $map = C_Album_Mapper::get_instance(); 
  52. $found = array(); 
  53. foreach ($sortorder as $order) { 
  54. if (strpos($order, 'a') === 0) { 
  55. $album_id = ltrim($order, 'a'); 
  56. if (empty($this->breadcrumb_cache[$order])) { 
  57. $album = $map->find($album_id); 
  58. $this->breadcrumb_cache[$order] = $album; 
  59. if (in_array($gallery_id, $album->sortorder)) { 
  60. $found[] = $album; 
  61. break; 
  62. } else { 
  63. $found = $this->find_gallery_parent($gallery_id, $album->sortorder, $found); 
  64. if ($found) { 
  65. $found[] = $album; 
  66. break; 
  67. return $found; 
  68. function generate_breadcrumb($gallery_id = NULL, $entities) 
  69. $found = array(); 
  70. $router = C_Router::get_instance(); 
  71. $app = $router->get_routed_app(); 
  72. if (is_array($gallery_id)) { 
  73. $gallery_id = array_shift($gallery_id); 
  74. if (is_array($gallery_id)) { 
  75. $gallery_id = $gallery_id[0]; 
  76. foreach ($entities as $ndx => $entity) { 
  77. $tmpid = (isset($entity->albumdesc) ? 'a' : '') . $entity->{$entity->id_field}; 
  78. $this->breadcrumb_cache[$tmpid] = $entity; 
  79. if (isset($entity->albumdesc) && in_array($gallery_id, $entity->sortorder)) { 
  80. $found[] = $entity; 
  81. break; 
  82. if (empty($found)) { 
  83. foreach ($entities as $entity) { 
  84. if (!empty($entity->sortorder)) { 
  85. $found = $this->object->find_gallery_parent($gallery_id, $entity->sortorder); 
  86. if (!empty($found)) { 
  87. $found[] = $entity; 
  88. break; 
  89. $found = array_reverse($found); 
  90. if (strpos($gallery_id, 'a') === 0) { 
  91. $album_found = FALSE; 
  92. foreach ($found as $found_item) { 
  93. if ($found_item->{$found_item->id_field} == $gallery_id) { 
  94. $album_found = TRUE; 
  95. if (!$album_found) { 
  96. $album_id = ltrim($gallery_id, 'a'); 
  97. $album = C_Album_Mapper::get_instance()->find($album_id); 
  98. $found[] = $album; 
  99. $this->breadcrumb_cache[$gallery_id] = $album; 
  100. } else { 
  101. $gallery_found = FALSE; 
  102. foreach ($entities as $entity) { 
  103. if (isset($entity->is_gallery) && $entity->is_gallery && $gallery_id == $entity->{$entity->id_field}) { 
  104. $gallery_found = TRUE; 
  105. $found[] = $entity; 
  106. break; 
  107. if (!$gallery_found) { 
  108. $gallery = C_Gallery_Mapper::get_instance()->find($gallery_id); 
  109. if ($gallery != null) { 
  110. $found[] = $gallery; 
  111. $this->breadcrumb_cache[$gallery->{$gallery->id_field}] = $gallery; 
  112. $crumbs = array(); 
  113. if (!empty($found)) { 
  114. $end = end($found); 
  115. reset($found); 
  116. foreach ($found as $found_item) { 
  117. $type = isset($found_item->albumdesc) ? 'album' : 'gallery'; 
  118. $id = ($type == 'album' ? 'a' : '') . $found_item->{$found_item->id_field}; 
  119. $entity = $this->breadcrumb_cache[$id]; 
  120. $link = NULL; 
  121. if ($type == 'album') { 
  122. $name = $entity->name; 
  123. if ($entity->pageid > 0) { 
  124. $link = @get_page_link($entity->pageid); 
  125. if (empty($link) && $found_item !== $end) { 
  126. $link = $app->get_routed_url(); 
  127. $link = $app->strip_param_segments($link); 
  128. $link = $app->set_parameter_value('album', $entity->slug, NULL, FALSE, $link); 
  129. } else { 
  130. $name = $entity->title; 
  131. $crumbs[] = array('type' => $type, 'name' => $name, 'url' => $link); 
  132. // free this memory immediately 
  133. $this->breadcrumb_cache = array(); 
  134. $view = new C_MVC_View('photocrati-nextgen_basic_album#breadcrumbs', array('breadcrumbs' => $crumbs, 'divisor' => apply_filters('ngg_breadcrumb_separator', ' » '))); 
  135. return $view->render(TRUE);