Mixin_Displayed_Gallery_Instance_Methods

Provides instance methods useful for working with the C_Displayed_Gallery model.

Defined (1)

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

/products/photocrati_nextgen/modules/nextgen_gallery_display/package.module.nextgen_gallery_display.php  
  1. class Mixin_Displayed_Gallery_Instance_Methods extends Mixin 
  2. function get_entity() 
  3. $entity = $this->call_parent('get_entity'); 
  4. unset($entity->post_author); 
  5. unset($entity->post_date); 
  6. unset($entity->post_date_gmt); 
  7. unset($entity->post_title); 
  8. unset($entity->post_excerpt); 
  9. unset($entity->post_status); 
  10. unset($entity->comment_status); 
  11. unset($entity->ping_status); 
  12. unset($entity->post_name); 
  13. unset($entity->to_ping); 
  14. unset($entity->pinged); 
  15. unset($entity->post_modified); 
  16. unset($entity->post_modified_gmt); 
  17. unset($entity->post_parent); 
  18. unset($entity->guid); 
  19. unset($entity->post_type); 
  20. unset($entity->post_mime_type); 
  21. unset($entity->comment_count); 
  22. unset($entity->filter); 
  23. unset($entity->post_content_filtered); 
  24. return $entity; 
  25. /** 
  26. * Gets the display type object used in this displayed gallery 
  27. * @return C_Display_Type 
  28. */ 
  29. function get_display_type() 
  30. return C_Display_Type_Mapper::get_instance()->find_by_name($this->object->display_type, TRUE); 
  31. /** 
  32. * Gets the corresponding source instance 
  33. * @return stdClass 
  34. */ 
  35. function get_source() 
  36. return C_Displayed_Gallery_Source_Manager::get_instance()->get($this->object->source); 
  37. /** 
  38. * Returns the galleries queries in this displayed gallery 
  39. * @return array 
  40. */ 
  41. function get_galleries() 
  42. $retval = array(); 
  43. if ($source = $this->object->get_source()) { 
  44. if (in_array('image', $source->returns)) { 
  45. $mapper = C_Gallery_Mapper::get_instance(); 
  46. $gallery_key = $mapper->get_primary_key_column(); 
  47. $mapper->select(); 
  48. if ($this->object->container_ids) { 
  49. $mapper->where(array("{$gallery_key} IN %s", $this->object->container_ids)); 
  50. $retval = $mapper->run_query(); 
  51. return $retval; 
  52. /** 
  53. * Gets albums queried in this displayed gallery 
  54. * @return array 
  55. */ 
  56. function get_albums() 
  57. $retval = array(); 
  58. if ($source = $this->object->get_source()) { 
  59. if (in_array('album', $source->returns)) { 
  60. $mapper = C_Album_Mapper::get_instance(); 
  61. $album_key = $mapper->get_primary_key_column(); 
  62. if ($this->object->container_ids) { 
  63. $mapper->select()->where(array("{$album_key} IN %s", $this->object->container_ids)); 
  64. $retval = $mapper->run_query(); 
  65. return $retval; 
  66. /** 
  67. * Returns a transient for the displayed gallery 
  68. * @return string 
  69. */ 
  70. function to_transient() 
  71. $params = $this->object->get_entity(); 
  72. unset($params->transient_id); 
  73. $key = C_Photocrati_Transient_Manager::create_key('displayed_galleries', $params); 
  74. if (is_null(C_Photocrati_Transient_Manager::fetch($key, NULL))) { 
  75. C_Photocrati_Transient_Manager::update($key, $params, NGG_DISPLAYED_GALLERY_CACHE_TTL); 
  76. $this->object->transient_id = $key; 
  77. if (!$this->object->id()) { 
  78. $this->object->id($key); 
  79. return $key; 
  80. /** 
  81. * Applies the values of a transient to this object 
  82. * @param string $transient_id 
  83. */ 
  84. function apply_transient($transient_id = NULL) 
  85. $retval = FALSE; 
  86. if (!$transient_id && isset($this->object->transient_id)) { 
  87. $transient_id = $this->object->transient_id; 
  88. if ($transient_id && ($transient = C_Photocrati_Transient_Manager::fetch($transient_id, FALSE))) { 
  89. // Ensure that the transient is an object, not array 
  90. if (is_array($transient)) { 
  91. $obj = new stdClass(); 
  92. foreach ($transient as $key => $value) { 
  93. $obj->{$key} = $value; 
  94. $transient = $obj; 
  95. $this->object->_stdObject = $transient; 
  96. // Ensure that the display settings are an array 
  97. $this->object->display_settings = $this->_object_to_array($this->object->display_settings); 
  98. // Ensure that we have the most accurate transient id 
  99. $this->object->transient_id = $transient_id; 
  100. if (!$this->object->id()) { 
  101. $this->object->id($transient_id); 
  102. $retval = TRUE; 
  103. } else { 
  104. unset($this->object->transient_id); 
  105. unset($this->object->_stdObject->transient_id); 
  106. $this->object->to_transient(); 
  107. return $retval; 
  108. public function _object_to_array($object) 
  109. $retval = $object; 
  110. if (is_object($retval)) { 
  111. $retval = get_object_vars($object); 
  112. if (is_array($retval)) { 
  113. foreach ($retval as $key => $val) { 
  114. if (is_object($val)) { 
  115. $retval[$key] = $this->_object_to_array($val); 
  116. return $retval;