Mixin_Display_Type_Mapper

Provides instance methods for the display type mapper.

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_Display_Type_Mapper extends Mixin 
  2. /** 
  3. * Locates a Display Type by names 
  4. * @param string $name 
  5. */ 
  6. function find_by_name($name, $model = FALSE) 
  7. $retval = NULL; 
  8. $this->object->select(); 
  9. $this->object->where(array('name = %s', $name)); 
  10. $results = $this->object->run_query(FALSE, $model); 
  11. if (!$results) { 
  12. foreach ($this->object->find_all(FALSE, $model) as $entity) { 
  13. if ($entity->name == $name || isset($entity->aliases) && is_array($entity->aliases) && in_array($name, $entity->aliases)) { 
  14. $retval = $entity; 
  15. break; 
  16. } else { 
  17. $retval = $results[0]; 
  18. return $retval; 
  19. /** 
  20. * Finds display types used to display specific types of entities 
  21. * @param string|array $entity_type e.g. image, gallery, album 
  22. * @return array 
  23. */ 
  24. function find_by_entity_type($entity_type, $model = FALSE) 
  25. $find_entity_types = is_array($entity_type) ? $entity_type : array($entity_type); 
  26. $retval = NULL; 
  27. foreach ($this->object->find_all(FALSE, $model) as $display_type) { 
  28. foreach ($find_entity_types as $entity_type) { 
  29. if (isset($display_type->entity_types) && in_array($entity_type, $display_type->entity_types)) { 
  30. $retval[] = $display_type; 
  31. break; 
  32. return $retval; 
  33. /** 
  34. * Uses the title attribute as the post title 
  35. * @param stdClass $entity 
  36. * @return string 
  37. */ 
  38. function get_post_title($entity) 
  39. return $entity->title; 
  40. /** 
  41. * Sets default values needed for display types 
  42. */ 
  43. function set_defaults($entity) 
  44. if (!isset($entity->settings)) { 
  45. $entity->settings = array(); 
  46. $this->_set_default_value($entity, 'preview_image_relpath', ''); 
  47. $this->_set_default_value($entity, 'default_source', ''); 
  48. $this->_set_default_value($entity, 'view_order', NGG_DISPLAY_PRIORITY_BASE); 
  49. $this->_set_default_value($entity, 'settings', 'use_lightbox_effect', TRUE); 
  50. $this->_set_default_value($entity, 'hidden_from_ui', FALSE); 
  51. // todo remove later 
  52. $this->_set_default_value($entity, 'hidden_from_igw', FALSE); 
  53. $this->_set_default_value($entity, 'aliases', array()); 
  54. return $this->call_parent('set_defaults', $entity);