Mixin_Attach_To_Post_Display_Tab

Provides the "Display Tab" for the Attach To Post interface/controller.

Defined (1)

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

/products/photocrati_nextgen/modules/attach_to_post/package.module.attach_to_post.php  
  1. class Mixin_Attach_To_Post_Display_Tab extends Mixin 
  2. function _display_type_list_sort($type_1, $type_2) 
  3. $order_1 = $type_1->view_order; 
  4. $order_2 = $type_2->view_order; 
  5. if ($order_1 == null) { 
  6. $order_1 = NGG_DISPLAY_PRIORITY_BASE; 
  7. if ($order_2 == null) { 
  8. $order_2 = NGG_DISPLAY_PRIORITY_BASE; 
  9. if ($order_1 > $order_2) { 
  10. return 1; 
  11. if ($order_1 < $order_2) { 
  12. return -1; 
  13. return 0; 
  14. /** 
  15. * Gets a list of tabs to render for the "Display" tab 
  16. */ 
  17. function _get_display_tabs() 
  18. // The ATP requires more memmory than some applications, somewhere around 60MB. 
  19. // Because it's such an important feature of NextGEN Gallery, we temporarily disable 
  20. // any memory limits 
  21. if (!extension_loaded('suhosin')) { 
  22. @ini_set('memory_limit', -1); 
  23. return array($this->object->_render_display_types_tab(), $this->object->_render_display_source_tab(), $this->object->_render_display_settings_tab(), $this->object->_render_preview_tab()); 
  24. /** 
  25. * Renders the accordion tab, "What would you like to display?" 
  26. */ 
  27. function _render_display_source_tab() 
  28. return $this->object->render_partial('photocrati-attach_to_post#accordion_tab', array('id' => 'source_tab', 'title' => __('What would you like to display?', 'nggallery'), 'content' => $this->object->_render_display_source_tab_contents()), TRUE); 
  29. /** 
  30. * Renders the contents of the source tab 
  31. * @return string 
  32. */ 
  33. function _render_display_source_tab_contents() 
  34. return $this->object->render_partial('photocrati-attach_to_post#display_tab_source', array(), TRUE); 
  35. /** 
  36. * Renders the accordion tab for selecting a display type 
  37. * @return string 
  38. */ 
  39. function _render_display_types_tab() 
  40. return $this->object->render_partial('photocrati-attach_to_post#accordion_tab', array('id' => 'display_type_tab', 'title' => __('Select a display type', 'nggallery'), 'content' => $this->object->_render_display_type_tab_contents()), TRUE); 
  41. /** 
  42. * Renders the contents of the display type tab 
  43. */ 
  44. function _render_display_type_tab_contents() 
  45. return $this->object->render_partial('photocrati-attach_to_post#display_tab_type', array(), TRUE); 
  46. /** 
  47. * Renders the display settings tab for the Attach to Post interface 
  48. * @return type 
  49. */ 
  50. function _render_display_settings_tab() 
  51. return $this->object->render_partial('photocrati-attach_to_post#accordion_tab', array('id' => 'display_settings_tab', 'title' => __('Customize the display settings', 'nggallery'), 'content' => $this->object->_render_display_settings_contents()), TRUE); 
  52. /** 
  53. * If editing an existing displayed gallery, retrieves the name 
  54. * of the display type 
  55. * @return string 
  56. */ 
  57. function _get_selected_display_type_name() 
  58. $retval = ''; 
  59. if ($this->object->_displayed_gallery) { 
  60. $retval = $this->object->_displayed_gallery->display_type; 
  61. return $retval; 
  62. /** 
  63. * Is the displayed gallery that's being edited using the specified display 
  64. * type? 
  65. * @param string $name name of the display type 
  66. * @return bool 
  67. */ 
  68. function is_displayed_gallery_using_display_type($name) 
  69. $retval = FALSE; 
  70. if ($this->object->_displayed_gallery) { 
  71. $retval = $this->object->_displayed_gallery->display_type == $name; 
  72. return $retval; 
  73. /** 
  74. * Renders the contents of the display settings tab 
  75. * @return string 
  76. */ 
  77. function _render_display_settings_contents() 
  78. $retval = array(); 
  79. // Get all display setting forms 
  80. $form_manager = C_Form_Manager::get_instance(); 
  81. $forms = $form_manager->get_forms(NGG_DISPLAY_SETTINGS_SLUG, TRUE); 
  82. // Display each form 
  83. foreach ($forms as $form) { 
  84. // Enqueue the form's static resources 
  85. $form->enqueue_static_resources(); 
  86. // Determine which classes to use for the form's "class" attribute 
  87. $model = $form->get_model(); 
  88. $current = $this->object->is_displayed_gallery_using_display_type($model->name); 
  89. $css_class = $current ? 'display_settings_form' : 'display_settings_form hidden'; 
  90. // If this form is used to provide the display settings for the current 
  91. // displayed gallery, then we need to override the forms settings 
  92. // with the displayed gallery settings 
  93. if ($current) { 
  94. $settings = $this->array_merge_assoc($model->settings, $this->object->_displayed_gallery->display_settings, TRUE); 
  95. $model->settings = $settings; 
  96. // Output the display settings form 
  97. $retval[] = $this->object->render_partial('photocrati-attach_to_post#display_settings_form', array('settings' => $form->render(), 'display_type_name' => $model->name, 'css_class' => $css_class), TRUE); 
  98. // In addition, we'll render a form that will be displayed when no 
  99. // display type has been selected in the Attach to Post interface 
  100. // Render the default "no display type selected" view 
  101. $css_class = $this->object->_get_selected_display_type_name() ? 'display_settings_form hidden' : 'display_settings_form'; 
  102. $retval[] = $this->object->render_partial('photocrati-attach_to_post#no_display_type_selected', array('no_display_type_selected' => __('No display type selected', 'nggallery'), 'css_class' => $css_class), TRUE); 
  103. // Return all display setting forms 
  104. return implode("\n", $retval); 
  105. /** 
  106. * Renders the tab used to preview included images 
  107. * @return string 
  108. */ 
  109. function _render_preview_tab() 
  110. return $this->object->render_partial('photocrati-attach_to_post#accordion_tab', array('id' => 'preview_tab', 'title' => __('Sort or Exclude Images', 'nggallery'), 'content' => $this->object->_render_preview_tab_contents()), TRUE); 
  111. /** 
  112. * Renders the contents of the "Preview" tab. 
  113. * @return string 
  114. */ 
  115. function _render_preview_tab_contents() 
  116. return $this->object->render_partial('photocrati-attach_to_post#preview_tab', array(), TRUE);