Mixin_Display_Type_Form

Class Mixin_Display_Type_Form.

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_Form extends Mixin 
  2. var $_model = null; 
  3. function initialize() 
  4. $this->object->implement('I_Display_Type_Form'); 
  5. /** 
  6. * Returns the name of the display type. Sub-class should override 
  7. * @throws Exception 
  8. * @returns string 
  9. */ 
  10. function get_display_type_name() 
  11. throw new Exception(__METHOD__ . " not implemented"); 
  12. /** 
  13. * Returns the model (display type) used in the form 
  14. * @return stdClass 
  15. */ 
  16. function get_model() 
  17. if ($this->_model == null) { 
  18. $mapper = C_Display_Type_Mapper::get_instance(); 
  19. $this->_model = $mapper->find_by_name($this->object->get_display_type_name(), TRUE); 
  20. return $this->_model; 
  21. /** 
  22. * Returns the title of the form, which is the title of the display type 
  23. * @returns string 
  24. */ 
  25. function get_title() 
  26. return __($this->object->get_model()->title, 'nggallery'); 
  27. /** 
  28. * Saves the settings for the display type 
  29. * @param array $attributes 
  30. * @return boolean 
  31. */ 
  32. function save_action($attributes = array()) 
  33. return $this->object->get_model()->save(array('settings' => $attributes)); 
  34. /** 
  35. * Renders the AJAX pagination settings field 
  36. * @param C_Display_Type $display_type 
  37. * @return string 
  38. */ 
  39. function _render_ajax_pagination_field($display_type) 
  40. return $this->object->_render_radio_field($display_type, 'ajax_pagination', __('Enable AJAX pagination', 'nggallery'), isset($display_type->settings['ajax_pagination']) ? $display_type->settings['ajax_pagination'] : FALSE, __('Browse images without reloading the page.', 'nggallery')); 
  41. function _render_thumbnail_override_settings_field($display_type) 
  42. $hidden = !(isset($display_type->settings['override_thumbnail_settings']) ? $display_type->settings['override_thumbnail_settings'] : FALSE); 
  43. $override_field = $this->_render_radio_field($display_type, 'override_thumbnail_settings', __('Override thumbnail settings', 'nggallery'), isset($display_type->settings['override_thumbnail_settings']) ? $display_type->settings['override_thumbnail_settings'] : FALSE, __("This does not affect existing thumbnails; overriding the thumbnail settings will create an additional set of thumbnails. To change the size of existing thumbnails please visit 'Manage Galleries' and choose 'Create new thumbnails' for all images in the gallery.", 'nggallery')); 
  44. $dimensions_field = $this->object->render_partial('photocrati-nextgen_gallery_display#thumbnail_settings', array('display_type_name' => $display_type->name, 'name' => 'thumbnail_dimensions', 'label' => __('Thumbnail dimensions', 'nggallery'), 'thumbnail_width' => isset($display_type->settings['thumbnail_width']) ? intval($display_type->settings['thumbnail_width']) : 0, 'thumbnail_height' => isset($display_type->settings['thumbnail_height']) ? intval($display_type->settings['thumbnail_height']) : 0, 'hidden' => $hidden ? 'hidden' : '', 'text' => ''), TRUE); 
  45. /** 
  46. $qualities = array(); 
  47. for ($i = 100; $i > 40; $i -= 5) { $qualities[$i] = "{$i}%"; } 
  48. $quality_field = $this->_render_select_field( 
  49. $display_type,  
  50. 'thumbnail_quality',  
  51. __('Thumbnail quality', 'nggallery'),  
  52. $qualities,  
  53. isset($display_type->settings['thumbnail_quality']) ? $display_type->settings['thumbnail_quality'] : 100,  
  54. '',  
  55. $hidden 
  56. ); 
  57. */ 
  58. $crop_field = $this->_render_radio_field($display_type, 'thumbnail_crop', __('Thumbnail crop', 'nggallery'), isset($display_type->settings['thumbnail_crop']) ? $display_type->settings['thumbnail_crop'] : FALSE, '', $hidden); 
  59. /** 
  60. $watermark_field = $this->_render_radio_field( 
  61. $display_type,  
  62. 'thumbnail_watermark',  
  63. __('Thumbnail watermark', 'nggallery'),  
  64. isset($display_type->settings['thumbnail_watermark']) ? $display_type->settings['thumbnail_watermark'] : FALSE,  
  65. '',  
  66. $hidden 
  67. ); 
  68. */ 
  69. $everything = $override_field . $dimensions_field . $crop_field; 
  70. return $everything; 
  71. /** 
  72. * Renders the thumbnail override settings field(s) 
  73. * @param C_Display_Type $display_type 
  74. * @return string 
  75. */ 
  76. function _render_image_override_settings_field($display_type) 
  77. $hidden = !(isset($display_type->settings['override_image_settings']) ? $display_type->settings['override_image_settings'] : FALSE); 
  78. $override_field = $this->_render_radio_field($display_type, 'override_image_settings', __('Override image settings', 'nggallery'), isset($display_type->settings['override_image_settings']) ? $display_type->settings['override_image_settings'] : 0, __('Overriding the image settings will create an additional set of images', 'nggallery')); 
  79. $qualities = array(); 
  80. for ($i = 100; $i > 40; $i -= 5) { 
  81. $qualities[$i] = "{$i}%"; 
  82. $quality_field = $this->_render_select_field($display_type, 'image_quality', __('Image quality', 'nggallery'), $qualities, $display_type->settings['image_quality'], '', $hidden); 
  83. $crop_field = $this->_render_radio_field($display_type, 'image_crop', __('Image crop', 'nggallery'), $display_type->settings['image_crop'], '', $hidden); 
  84. $watermark_field = $this->_render_radio_field($display_type, 'image_watermark', __('Image watermark', 'nggallery'), $display_type->settings['image_watermark'], '', $hidden); 
  85. $everything = $override_field . $quality_field . $crop_field . $watermark_field; 
  86. return $everything; 
  87. /** 
  88. * Renders a field for selecting a template 
  89. * @param C_Display_Type $display_type 
  90. * @return string 
  91. */ 
  92. function _render_display_type_view_field($display_type) 
  93. $display_type_views = $this->get_available_display_type_views($display_type); 
  94. return $this->object->_render_select_field($display_type, 'display_type_view', __('Select Template', 'nggallery'), $display_type_views, $display_type->settings['display_type_view'], '', FALSE); 
  95. /** 
  96. * Gets available templates 
  97. * @param C_Display_Type $display_type 
  98. * @return array 
  99. */ 
  100. function get_available_display_type_views($display_type) 
  101. /** Set up templates array */ 
  102. $views = array('default' => __('Default Template', 'nggallery')); 
  103. /** Fetch array of directories to scan */ 
  104. $dirs = M_Gallery_Display::get_display_type_view_dirs($display_type); 
  105. /** Populate the views array by scanning each directory for relevant templates */ 
  106. foreach ($dirs as $dir_name => $dir) { 
  107. /** Confirm directory exists */ 
  108. if (!file_exists($dir) || !is_dir($dir)) { 
  109. continue; 
  110. /** Scan for template files and create array */ 
  111. $files = scandir($dir); 
  112. $template_files = preg_grep('/^.+\\-template.php$/i', $files); 
  113. $template_files = array_combine($template_files, $template_files); 
  114. /** For custom templates only, append directory name placeholder */ 
  115. foreach ($template_files as $key => $value) { 
  116. if ($dir_name !== 'default') { 
  117. $template_files[$dir_name . DIRECTORY_SEPARATOR . $key] = $dir_name . DIRECTORY_SEPARATOR . $value; 
  118. unset($template_files[$key]); 
  119. $views = array_merge($views, $template_files); 
  120. return $views;