A_NextGen_Album_Descriptions

Class A_NextGen_Album_Descriptions.

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_Descriptions extends Mixin 
  2. // When viewing a child gallery the album controller's add_description_to_legacy_templates() method will be 
  3. // called for the gallery and then again for the root album; we only want to run once 
  4. public static $_description_added_once = FALSE; 
  5. function are_descriptions_enabled($display_settings) 
  6. $retval = FALSE; 
  7. if (isset($display_settings['enable_descriptions']) && $display_settings['enable_descriptions']) { 
  8. $retval = TRUE; 
  9. } elseif (isset($display_settings['original_settings']) && $this->are_descriptions_enabled($display_settings['original_settings'])) { 
  10. $retval = TRUE; 
  11. return $retval; 
  12. function render_object() 
  13. $root_element = $this->call_parent('render_object'); 
  14. if ($displayed_gallery = $this->object->get_param('displayed_gallery')) { 
  15. $ds = $displayed_gallery->display_settings; 
  16. if ($this->are_descriptions_enabled($ds)) { 
  17. $description = $this->object->generate_description($displayed_gallery); 
  18. foreach ($root_element->find('nextgen_gallery.gallery_container', TRUE) as $container) { 
  19. // Determine where (to be compatible with breadcrumbs) in the container to insert 
  20. $pos = 0; 
  21. foreach ($container->_list as $ndx => $item) { 
  22. if (is_string($item)) { 
  23. $pos = $ndx; 
  24. } else { 
  25. break; 
  26. $container->insert($description, $pos); 
  27. return $root_element; 
  28. function render_legacy_template_description($displayed_gallery) 
  29. if (!empty($displayed_gallery->display_settings['template']) && $this->are_descriptions_enabled($displayed_gallery->display_settings)) { 
  30. return $this->object->generate_description($displayed_gallery); 
  31. } else { 
  32. return ''; 
  33. function generate_description($displayed_gallery) 
  34. if (self::$_description_added_once) { 
  35. return ''; 
  36. self::$_description_added_once = TRUE; 
  37. $description = $this->get_description($displayed_gallery); 
  38. $view = new C_MVC_View('photocrati-nextgen_basic_album#descriptions', array('description' => $description)); 
  39. return $view->render(TRUE); 
  40. function get_description($displayed_gallery) 
  41. $description = ''; 
  42. // Important: do not array_shift() $displayed_gallery->container_ids as it will affect breadcrumbs 
  43. $container_ids = $displayed_gallery->container_ids; 
  44. if ($displayed_gallery->source == 'galleries') { 
  45. $gallery_id = array_shift($container_ids); 
  46. $gallery = C_Gallery_Mapper::get_instance()->find($gallery_id); 
  47. if ($gallery && !empty($gallery->galdesc)) { 
  48. $description = $gallery->galdesc; 
  49. } else { 
  50. if ($displayed_gallery->source == 'albums') { 
  51. $album_id = array_shift($container_ids); 
  52. $album = C_Album_Mapper::get_instance()->find($album_id); 
  53. if ($album && !empty($album->albumdesc)) { 
  54. $description = $album->albumdesc; 
  55. return $description;