/products/photocrati_nextgen/modules/nextgen_basic_gallery/package.module.nextgen_basic_gallery.php

  1. <?php 
  2. class A_NextGen_Basic_Gallery_Controller extends Mixin 
  3. public function index_action($displayed_gallery, $return = FALSE) 
  4. $retval = ''; 
  5. $call_parent = TRUE; 
  6. $show = $this->object->param('show'); 
  7. $pid = $this->object->param('pid'); 
  8. if (!empty($pid) && isset($displayed_gallery->display_settings['use_imagebrowser_effect']) && intval($displayed_gallery->display_settings['use_imagebrowser_effect'])) { 
  9. $show = NGG_BASIC_IMAGEBROWSER; 
  10. // Are we to display a different display type? 
  11. if (!empty($show)) { 
  12. $params = (array) $displayed_gallery->get_entity(); 
  13. $ds = $params['display_settings']; 
  14. if ((!empty($ds['show_slideshow_link']) || !empty($ds['show_thumbnail_link']) || !empty($ds['use_imagebrowser_effect'])) && $show != $this->object->context) { 
  15. // Render the new display type 
  16. $renderer = C_Displayed_Gallery_Renderer::get_instance(); 
  17. $displayed_gallery->original_display_type = $displayed_gallery->display_type; 
  18. $displayed_gallery->original_settings = $displayed_gallery->display_settings; 
  19. $displayed_gallery->display_type = $show; 
  20. $params = (array) $displayed_gallery->get_entity(); 
  21. $params['display_settings'] = array(); 
  22. $retval = $renderer->display_images($params, $return); 
  23. $call_parent = FALSE; 
  24. return $call_parent ? $this->call_parent('index_action', $displayed_gallery, $return) : $retval; 
  25. /** 
  26. * Returns a url to view the displayed gallery using an alternate display 
  27. * type 
  28. * @param C_Displayed_Gallery $displayed_gallery 
  29. * @param string $display_type 
  30. * @return string 
  31. */ 
  32. public function get_url_for_alternate_display_type($displayed_gallery, $display_type, $origin_url = FALSE) 
  33. if (!$origin_url && !empty($displayed_gallery->display_settings['original_display_type']) && !empty($_SERVER['ORIG_REQUEST_URI'])) { 
  34. $origin_url = $_SERVER['ORIG_REQUEST_URI']; 
  35. $url = $origin_url ? $origin_url : $this->object->get_routed_url(TRUE); 
  36. $url = $this->object->remove_param_for($url, 'show', $displayed_gallery->id()); 
  37. $url = $this->object->set_param_for($url, 'show', $display_type, $displayed_gallery->id()); 
  38. return $url; 
  39. /** 
  40. * Sets default values for the NextGen Basic Slideshow display type 
  41. */ 
  42. class A_NextGen_Basic_Gallery_Mapper extends Mixin 
  43. public function set_defaults($entity) 
  44. $this->call_parent('set_defaults', $entity); 
  45. if (isset($entity->name)) { 
  46. if ($entity->name == NGG_BASIC_SLIDESHOW) { 
  47. $this->set_slideshow_defaults($entity); 
  48. } else { 
  49. if ($entity->name == NGG_BASIC_THUMBNAILS) { 
  50. $this->set_thumbnail_defaults($entity); 
  51. public function set_slideshow_defaults($entity) 
  52. $settings = C_NextGen_Settings::get_instance(); 
  53. $this->object->_set_default_value($entity, 'settings', 'gallery_width', $settings->irWidth); 
  54. $this->object->_set_default_value($entity, 'settings', 'gallery_height', $settings->irHeight); 
  55. $this->object->_set_default_value($entity, 'settings', 'thumbnail_width', $settings->thumbwidth); 
  56. $this->object->_set_default_value($entity, 'settings', 'thumbnail_height', $settings->thumbheight); 
  57. $this->object->_set_default_value($entity, 'settings', 'cycle_interval', $settings->irRotatetime); 
  58. $this->object->_set_default_value($entity, 'settings', 'cycle_effect', $settings->slideFx); 
  59. $this->object->_set_default_value($entity, 'settings', 'effect_code', $settings->thumbCode); 
  60. $this->object->_set_default_value($entity, 'settings', 'show_thumbnail_link', $settings->galShowSlide ? 1 : 0); 
  61. $this->object->_set_default_value($entity, 'settings', 'thumbnail_link_text', $settings->galTextGallery); 
  62. $this->object->_set_default_value($entity, 'settings', 'template', ''); 
  63. // Part of the pro-modules 
  64. $this->object->_set_default_value($entity, 'settings', 'ngg_triggers_display', 'never'); 
  65. public function set_thumbnail_defaults($entity) 
  66. $settings = C_NextGen_Settings::get_instance(); 
  67. $this->object->_set_default_value($entity, 'settings', 'images_per_page', $settings->galImages); 
  68. $this->object->_set_default_value($entity, 'settings', 'number_of_columns', $settings->galColumns); 
  69. $this->object->_set_default_value($entity, 'settings', 'thumbnail_width', $settings->thumbwidth); 
  70. $this->object->_set_default_value($entity, 'settings', 'thumbnail_height', $settings->thumbheight); 
  71. $this->object->_set_default_value($entity, 'settings', 'show_all_in_lightbox', $settings->galHiddenImg); 
  72. $this->object->_set_default_value($entity, 'settings', 'ajax_pagination', $settings->galAjaxNav); 
  73. $this->object->_set_default_value($entity, 'settings', 'use_imagebrowser_effect', $settings->galImgBrowser); 
  74. $this->object->_set_default_value($entity, 'settings', 'template', ''); 
  75. $this->object->_set_default_value($entity, 'settings', 'display_no_images_error', 1); 
  76. // TODO: Should this be called enable pagination? 
  77. $this->object->_set_default_value($entity, 'settings', 'disable_pagination', 0); 
  78. // Alternative view support 
  79. $this->object->_set_default_value($entity, 'settings', 'show_slideshow_link', $settings->galShowSlide ? 1 : 0); 
  80. $this->object->_set_default_value($entity, 'settings', 'slideshow_link_text', $settings->galTextSlide); 
  81. // override thumbnail settings 
  82. $this->object->_set_default_value($entity, 'settings', 'override_thumbnail_settings', 0); 
  83. $this->object->_set_default_value($entity, 'settings', 'thumbnail_quality', '100'); 
  84. $this->object->_set_default_value($entity, 'settings', 'thumbnail_crop', 1); 
  85. $this->object->_set_default_value($entity, 'settings', 'thumbnail_watermark', 0); 
  86. // Part of the pro-modules 
  87. $this->object->_set_default_value($entity, 'settings', 'ngg_triggers_display', 'never'); 
  88. class A_NextGen_Basic_Gallery_Urls extends Mixin 
  89. public function create_parameter_segment($key, $value, $id = NULL, $use_prefix = FALSE) 
  90. if ($key == 'show') { 
  91. if ($value == NGG_BASIC_SLIDESHOW) { 
  92. $value = 'slideshow'; 
  93. } elseif ($value == NGG_BASIC_THUMBNAILS) { 
  94. $value = 'thumbnails'; 
  95. } elseif ($value == NGG_BASIC_IMAGEBROWSER) { 
  96. $value = 'imagebrowser'; 
  97. return $value; 
  98. } elseif ($key == 'nggpage') { 
  99. return 'page/' . $value; 
  100. } else { 
  101. return $this->call_parent('create_parameter_segment', $key, $value, $id, $use_prefix); 
  102. public function set_parameter_value($key, $value, $id = NULL, $use_prefix = FALSE, $url = FALSE) 
  103. $retval = $this->call_parent('set_parameter_value', $key, $value, $id, $use_prefix, $url); 
  104. return $this->_set_ngglegacy_page_parameter($retval, $key, $value, $id, $use_prefix); 
  105. public function remove_parameter($key, $id = NULL, $url = FALSE) 
  106. $retval = $this->call_parent('remove_parameter', $key, $id, $url); 
  107. $retval = $this->_set_ngglegacy_page_parameter($retval, $key); 
  108. // For some reason, we're not removing our parameters the way we should. Our routing system seems to be 
  109. // a bit broken and so I'm adding an exception here. 
  110. // TODO: Our parameter manipulations need to be flawless. Look into route cause 
  111. if ($key == 'show') { 
  112. $uri = explode('?', $retval); 
  113. $uri = $uri[0]; 
  114. $settings = C_NextGen_Settings::get_instance(); 
  115. $regex = '#/' . $settings->router_param_slug . '.*(/?(slideshow|thumbnails|imagebrowser)/?)#'; 
  116. if (preg_match($regex, $retval, $matches)) { 
  117. $retval = str_replace($matches[1], '', $retval); 
  118. return $retval; 
  119. public function _set_ngglegacy_page_parameter($retval, $key, $value = NULL, $id = NULL, $use_prefix = NULL) 
  120. // Get the settings manager 
  121. $settings = C_NextGen_Settings::get_instance(); 
  122. // Create regex pattern 
  123. $param_slug = preg_quote($settings->router_param_slug, '#'); 
  124. if ($key == 'nggpage') { 
  125. $regex = "#(/{$param_slug}/.*)(/?page/\\d+/?)(.*)#"; 
  126. if (preg_match($regex, $retval, $matches)) { 
  127. $new_segment = $value ? "/page/{$value}" : ''; 
  128. $retval = rtrim(str_replace($matches[0], rtrim($matches[1], '/') . $new_segment . ltrim($matches[3], '/'), $retval), '/'); 
  129. # Convert the nggpage parameter to a slug 
  130. if (preg_match("#(/{$param_slug}/.*)nggpage--(.*)#", $retval, $matches)) { 
  131. $retval = rtrim(str_replace($matches[0], rtrim($matches[1], '/') . '/page/' . ltrim($matches[2], '/'), $retval), '/'); 
  132. # Convert the show parameter to a slug 
  133. if (preg_match("#(/{$param_slug}/.*)show--(.*)#", $retval, $matches)) { 
  134. $retval = rtrim(str_replace($matches[0], rtrim($matches[1], '/') . '/' . $matches[2], $retval), '/'); 
  135. $retval = str_replace(NGG_BASIC_SLIDESHOW, 'slideshow', $retval); 
  136. $retval = str_replace(NGG_BASIC_THUMBNAILS, 'thumbnails', $retval); 
  137. $retval = str_replace(NGG_BASIC_IMAGEBROWSER, 'imagebrowser', $retval); 
  138. return $retval; 
  139. class A_NextGen_Basic_Gallery_Validation extends Mixin 
  140. public function validation() 
  141. if ($this->object->name == NGG_BASIC_THUMBNAILS) { 
  142. $this->object->validates_presence_of('thumbnail_width'); 
  143. $this->object->validates_presence_of('thumbnail_height'); 
  144. $this->object->validates_numericality_of('thumbnail_width'); 
  145. $this->object->validates_numericality_of('thumbnail_height'); 
  146. $this->object->validates_numericality_of('images_per_page'); 
  147. } else { 
  148. if ($this->object->name == NGG_BASIC_SLIDESHOW) { 
  149. $this->object->validates_presence_of('gallery_width'); 
  150. $this->object->validates_presence_of('gallery_height'); 
  151. $this->object->validates_numericality_of('gallery_width'); 
  152. $this->object->validates_numericality_of('gallery_height'); 
  153. return $this->call_parent('validation'); 
  154. class A_NextGen_Basic_Slideshow_Controller extends Mixin 
  155. /** 
  156. * Displays the ngglegacy thumbnail gallery. 
  157. * This method deprecates the use of the nggShowGallery() function. 
  158. * @param stdClass|C_Displayed_Gallery|C_DataMapper_Model $displayed_gallery 
  159. */ 
  160. public function index_action($displayed_gallery, $return = FALSE) 
  161. // Get the images to be displayed 
  162. $current_page = (int) $this->param('nggpage', 1); 
  163. if ($images = $displayed_gallery->get_included_entities()) { 
  164. // Get the gallery storage component 
  165. $storage = C_Gallery_Storage::get_instance(); 
  166. // Create parameter list for the view 
  167. $params = $displayed_gallery->display_settings; 
  168. $params['storage'] =& $storage; 
  169. $params['images'] =& $images; 
  170. $params['displayed_gallery_id'] = $displayed_gallery->id(); 
  171. $params['current_page'] = $current_page; 
  172. $params['effect_code'] = $this->object->get_effect_code($displayed_gallery); 
  173. $params['anchor'] = 'ngg-slideshow-' . $displayed_gallery->id() . '-' . rand(1, getrandmax()) . $current_page; 
  174. $gallery_width = $displayed_gallery->display_settings['gallery_width']; 
  175. $gallery_height = $displayed_gallery->display_settings['gallery_height']; 
  176. $params['aspect_ratio'] = $gallery_width / $gallery_height; 
  177. $params['placeholder'] = $this->object->get_static_url('photocrati-nextgen_basic_gallery#slideshow/placeholder.gif'); 
  178. // Are we to generate a thumbnail link? 
  179. if ($displayed_gallery->display_settings['show_thumbnail_link']) { 
  180. $params['thumbnail_link'] = $this->object->get_url_for_alternate_display_type($displayed_gallery, NGG_BASIC_THUMBNAILS); 
  181. $params = $this->object->prepare_display_parameters($displayed_gallery, $params); 
  182. $retval = $this->object->render_partial('photocrati-nextgen_basic_gallery#slideshow/index', $params, $return); 
  183. } else { 
  184. $retval = $this->object->render_partial('photocrati-nextgen_gallery_display#no_images_found', array(), $return); 
  185. return $retval; 
  186. /** 
  187. * Enqueues all static resources required by this display type 
  188. * @param C_Displayed_Gallery $displayed_gallery 
  189. */ 
  190. public function enqueue_frontend_resources($displayed_gallery) 
  191. wp_register_script('jquery-cycle', $this->get_static_url('photocrati-nextgen_basic_gallery#slideshow/jquery.cycle.all.js'), array('jquery'), NGG_SCRIPT_VERSION); 
  192. wp_enqueue_script('jquery-cycle'); 
  193. wp_enqueue_style('nextgen_basic_slideshow_style', $this->get_static_url('photocrati-nextgen_basic_gallery#slideshow/nextgen_basic_slideshow.css'), FALSE, NGG_SCRIPT_VERSION); 
  194. wp_enqueue_script('waitforimages', $this->get_static_url('photocrati-nextgen_basic_gallery#slideshow/jquery.waitforimages.js'), array('jquery'), NGG_SCRIPT_VERSION); 
  195. $this->call_parent('enqueue_frontend_resources', $displayed_gallery); 
  196. $this->enqueue_ngg_styles(); 
  197. /** 
  198. * Provides the url of the JavaScript library required for 
  199. * NextGEN Basic Slideshow to display 
  200. * @return string 
  201. */ 
  202. public function _get_js_lib_url() 
  203. return $this->get_static_url('photocrati-nextgen_basic_gallery#slideshow/nextgen_basic_slideshow.js'); 
  204. /** 
  205. * Provides the display settings form for the NextGen Basic Slideshow 
  206. */ 
  207. class A_NextGen_Basic_Slideshow_Form extends Mixin_Display_Type_Form 
  208. public function get_display_type_name() 
  209. return NGG_BASIC_SLIDESHOW; 
  210. public function enqueue_static_resources() 
  211. wp_enqueue_script('nextgen_basic_slideshow_settings-js', $this->get_static_url('photocrati-nextgen_basic_gallery#slideshow/nextgen_basic_slideshow_settings.js'), array('jquery.nextgen_radio_toggle'), NGG_SCRIPT_VERSION); 
  212. $atp = C_Attach_Controller::get_instance(); 
  213. if ($atp != null) { 
  214. $atp->mark_script('nextgen_basic_slideshow_settings-js'); 
  215. /** 
  216. * Returns a list of fields to render on the settings page 
  217. */ 
  218. public function _get_field_names() 
  219. return array('nextgen_basic_slideshow_gallery_dimensions', 'nextgen_basic_slideshow_cycle_effect', 'nextgen_basic_slideshow_cycle_interval', 'nextgen_basic_slideshow_show_thumbnail_link', 'nextgen_basic_slideshow_thumbnail_link_text'); 
  220. public function _render_nextgen_basic_slideshow_cycle_interval_field($display_type) 
  221. return $this->_render_number_field($display_type, 'cycle_interval', __('Interval', 'nggallery'), $display_type->settings['cycle_interval'], '', FALSE, __('# of seconds', 'nggallery'), 1); 
  222. public function _render_nextgen_basic_slideshow_cycle_effect_field($display_type) 
  223. return $this->_render_select_field($display_type, 'cycle_effect', 'Effect', array('fade' => 'fade', 'blindX' => 'blindX', 'cover' => 'cover', 'scrollUp' => 'scrollUp', 'scrollDown' => 'scrollDown', 'shuffle' => 'shuffle', 'toss' => 'toss', 'wipe' => 'wipe'), $display_type->settings['cycle_effect'], '', FALSE); 
  224. public function _render_nextgen_basic_slideshow_gallery_dimensions_field($display_type) 
  225. return $this->render_partial('photocrati-nextgen_basic_gallery#slideshow/nextgen_basic_slideshow_settings_gallery_dimensions', array('display_type_name' => $display_type->name, 'gallery_dimensions_label' => __('Maximum dimensions', 'nggallery'), 'gallery_dimensions_tooltip' => __('Certain themes may allow images to flow over their container if this setting is too large', 'nggallery'), 'gallery_width' => $display_type->settings['gallery_width'], 'gallery_height' => $display_type->settings['gallery_height']), True); 
  226. /** 
  227. * Renders the show_thumbnail_link settings field 
  228. * 
  229. * @param C_Display_Type $display_type 
  230. * @return string 
  231. */ 
  232. public function _render_nextgen_basic_slideshow_show_thumbnail_link_field($display_type) 
  233. return $this->_render_radio_field($display_type, 'show_thumbnail_link', __('Show thumbnail link', 'nggallery'), $display_type->settings['show_thumbnail_link']); 
  234. /** 
  235. * Renders the thumbnail_link_text settings field 
  236. * 
  237. * @param C_Display_Type $display_type 
  238. * @return string 
  239. */ 
  240. public function _render_nextgen_basic_slideshow_thumbnail_link_text_field($display_type) 
  241. return $this->_render_text_field($display_type, 'thumbnail_link_text', __('Thumbnail link text', 'nggallery'), $display_type->settings['thumbnail_link_text'], '', !empty($display_type->settings['show_thumbnail_link']) ? FALSE : TRUE); 
  242. class A_NextGen_Basic_Thumbnail_Form extends Mixin_Display_Type_Form 
  243. public function get_display_type_name() 
  244. return NGG_BASIC_THUMBNAILS; 
  245. /** 
  246. * Enqueues static resources required by this form 
  247. */ 
  248. public function enqueue_static_resources() 
  249. wp_enqueue_style('nextgen_basic_thumbnails_settings', $this->object->get_static_url('photocrati-nextgen_basic_gallery#thumbnails/nextgen_basic_thumbnails_settings.css'), FALSE, NGG_SCRIPT_VERSION); 
  250. wp_enqueue_script('nextgen_basic_thumbnails_settings', $this->object->get_static_url('photocrati-nextgen_basic_gallery#thumbnails/nextgen_basic_thumbnails_settings.js'), array('jquery.nextgen_radio_toggle'), NGG_SCRIPT_VERSION); 
  251. $atp = C_Attach_Controller::get_instance(); 
  252. if ($atp != null) { 
  253. $atp->mark_script('nextgen_basic_thumbnails_settings'); 
  254. /** 
  255. * Returns a list of fields to render on the settings page 
  256. */ 
  257. public function _get_field_names() 
  258. return array('thumbnail_override_settings', 'nextgen_basic_thumbnails_images_per_page', 'nextgen_basic_thumbnails_number_of_columns', 'nextgen_basic_thumbnails_ajax_pagination', 'nextgen_basic_thumbnails_hidden', 'nextgen_basic_thumbnails_imagebrowser_effect', 'nextgen_basic_thumbnails_show_slideshow_link', 'nextgen_basic_thumbnails_slideshow_link_text', 'nextgen_basic_templates_template'); 
  259. /** 
  260. * Renders the images_per_page settings field 
  261. * 
  262. * @param C_Display_Type $display_type 
  263. * @return string 
  264. */ 
  265. public function _render_nextgen_basic_thumbnails_images_per_page_field($display_type) 
  266. return $this->_render_number_field($display_type, 'images_per_page', __('Images per page', 'nggallery'), $display_type->settings['images_per_page'], __('0 will display all images at once', 'nggallery'), FALSE, '# of images', 0); 
  267. /** 
  268. * Renders the number_of_columns settings field 
  269. * 
  270. * @param C_Display_Type $display_type 
  271. * @return string 
  272. */ 
  273. public function _render_nextgen_basic_thumbnails_number_of_columns_field($display_type) 
  274. return $this->_render_number_field($display_type, 'number_of_columns', __('Number of columns to display', 'nggallery'), $display_type->settings['number_of_columns'], '', FALSE, __('# of columns', 'nggallery'), 0); 
  275. /** 
  276. * Renders the 'Add hidden images' settings field 
  277. * 
  278. * @param C_Display_Type $display_type 
  279. * @return string 
  280. */ 
  281. public function _render_nextgen_basic_thumbnails_hidden_field($display_type) 
  282. return $this->_render_radio_field($display_type, 'show_all_in_lightbox', __('Add Hidden Images', 'nggallery'), $display_type->settings['show_all_in_lightbox'], __('If pagination is used this option will show all images in the modal window (Thickbox, Lightbox etc.) This increases page load.', 'nggallery')); 
  283. public function _render_nextgen_basic_thumbnails_imagebrowser_effect_field($display_type) 
  284. return $this->_render_radio_field($display_type, 'use_imagebrowser_effect', __('Use imagebrowser effect', 'nggallery'), $display_type->settings['use_imagebrowser_effect'], __('When active each image in the gallery will link to an imagebrowser display and lightbox effects will not be applied.', 'nggallery')); 
  285. /** 
  286. * Renders the AJAX pagination settings field 
  287. * 
  288. * @param C_Display_Type $display_type 
  289. * @return string 
  290. */ 
  291. public function _render_nextgen_basic_thumbnails_ajax_pagination_field($display_type) 
  292. return $this->_render_radio_field($display_type, 'ajax_pagination', __('Enable AJAX pagination', 'nggallery'), $display_type->settings['ajax_pagination'], __('Browse images without reloading the page.', 'nggallery')); 
  293. /** 
  294. * Renders the show_slideshow_link settings field 
  295. * 
  296. * @param C_Display_Type $display_type 
  297. * @return string 
  298. */ 
  299. public function _render_nextgen_basic_thumbnails_show_slideshow_link_field($display_type) 
  300. return $this->_render_radio_field($display_type, 'show_slideshow_link', __('Show slideshow link', 'nggallery'), $display_type->settings['show_slideshow_link']); 
  301. /** 
  302. * Renders the slideshow_link_text settings field 
  303. * 
  304. * @param C_Display_Type $display_type 
  305. * @return string 
  306. */ 
  307. public function _render_nextgen_basic_thumbnails_slideshow_link_text_field($display_type) 
  308. return $this->_render_text_field($display_type, 'slideshow_link_text', __('Slideshow link text', 'nggallery'), $display_type->settings['slideshow_link_text'], '', !empty($display_type->settings['show_slideshow_link']) ? FALSE : TRUE); 
  309. class A_NextGen_Basic_Thumbnails_Controller extends Mixin 
  310. /** 
  311. * Adds framework support for thumbnails 
  312. */ 
  313. public function initialize() 
  314. $this->add_mixin('Mixin_NextGen_Basic_Pagination'); 
  315. /** 
  316. * Displays the ngglegacy thumbnail gallery. 
  317. * This method deprecates the use of the nggShowGallery() function. 
  318. * @param stdClass|C_Displayed_Gallery|C_DataMapper_Model $displayed_gallery 
  319. */ 
  320. public function index_action($displayed_gallery, $return = FALSE) 
  321. $display_settings = $displayed_gallery->display_settings; 
  322. $gallery_id = $displayed_gallery->id(); 
  323. if (!$display_settings['disable_pagination']) { 
  324. $current_page = (int) $this->param('nggpage', $gallery_id, 1); 
  325. } else { 
  326. $current_page = 1; 
  327. $offset = $display_settings['images_per_page'] * ($current_page - 1); 
  328. $storage = C_Gallery_Storage::get_instance(); 
  329. $total = $displayed_gallery->get_entity_count(); 
  330. // Get the images to be displayed 
  331. if ($display_settings['images_per_page'] > 0 && $display_settings['show_all_in_lightbox']) { 
  332. // the "Add Hidden Images" feature works by loading ALL images and then marking the ones not on this page 
  333. // as hidden (style="display: none") 
  334. $images = $displayed_gallery->get_included_entities(); 
  335. $i = 0; 
  336. foreach ($images as &$image) { 
  337. if ($i < $display_settings['images_per_page'] * ($current_page - 1)) { 
  338. $image->hidden = TRUE; 
  339. } elseif ($i >= $display_settings['images_per_page'] * $current_page) { 
  340. $image->hidden = TRUE; 
  341. $i++; 
  342. } else { 
  343. // just display the images for this page, as normal 
  344. $images = $displayed_gallery->get_included_entities($display_settings['images_per_page'], $offset); 
  345. if (in_array($displayed_gallery->source, array('random_images', 'recent_images'))) { 
  346. $display_settings['disable_pagination'] = TRUE; 
  347. // Are there images to display? 
  348. if ($images) { 
  349. // Create pagination 
  350. if ($display_settings['images_per_page'] && !$display_settings['disable_pagination']) { 
  351. $pagination_result = $this->object->create_pagination($current_page, $total, $display_settings['images_per_page'], urldecode($this->object->param('ajax_pagination_referrer'))); 
  352. $this->object->remove_param('ajax_pagination_referrer'); 
  353. $pagination_prev = $pagination_result['prev']; 
  354. $pagination_next = $pagination_result['next']; 
  355. $pagination = $pagination_result['output']; 
  356. } else { 
  357. list($pagination_prev, $pagination_next, $pagination) = array(NULL, NULL, NULL); 
  358. $thumbnail_size_name = 'thumbnail'; 
  359. if ($display_settings['override_thumbnail_settings']) { 
  360. $dynthumbs = C_Dynamic_Thumbnails_Manager::get_instance(); 
  361. if ($dynthumbs != null) { 
  362. $dyn_params = array('width' => $display_settings['thumbnail_width'], 'height' => $display_settings['thumbnail_height']); 
  363. if ($display_settings['thumbnail_quality']) { 
  364. $dyn_params['quality'] = $display_settings['thumbnail_quality']; 
  365. if ($display_settings['thumbnail_crop']) { 
  366. $dyn_params['crop'] = true; 
  367. if ($display_settings['thumbnail_watermark']) { 
  368. $dyn_params['watermark'] = true; 
  369. $thumbnail_size_name = $dynthumbs->get_size_name($dyn_params); 
  370. // Generate a slideshow link 
  371. $slideshow_link = ''; 
  372. if ($display_settings['show_slideshow_link']) { 
  373. // origin_url is necessary for ajax operations. slideshow_link_origin will NOT always exist. 
  374. $origin_url = $this->object->param('ajax_pagination_referrer'); 
  375. $slideshow_link = $this->object->get_url_for_alternate_display_type($displayed_gallery, NGG_BASIC_SLIDESHOW, $origin_url); 
  376. // This setting 1) points all images to an imagebrowser display & 2) disables the lightbox effect 
  377. if ($display_settings['use_imagebrowser_effect']) { 
  378. // // this hook *MUST* be removed later; it should not apply to galleries that may come after this one! 
  379. // $storage->add_post_hook( 
  380. // 'get_image_url',  
  381. // 'imagebrowser alternate url replacer',  
  382. // 'Hook_NextGen_Basic_Imagebrowser_Alt_URLs',  
  383. // 'get_image_url' 
  384. // ); 
  385. // $effect_code = ''; 
  386. $effect_code = 'class=\'use_imagebrowser_effect\''; 
  387. } else { 
  388. $effect_code = $this->object->get_effect_code($displayed_gallery); 
  389. // The render functions require different processing 
  390. if (!empty($display_settings['template']) && $display_settings['template'] != 'default') { 
  391. $this->object->add_mixin('A_NextGen_Basic_Template_Form'); 
  392. $this->object->add_mixin('Mixin_NextGen_Basic_Templates'); 
  393. $params = $this->object->prepare_legacy_parameters($images, $displayed_gallery, array('next' => empty($pagination_next) ? FALSE : $pagination_next, 'prev' => empty($pagination_prev) ? FALSE : $pagination_prev, 'pagination' => $pagination, 'slideshow_link' => $slideshow_link, 'effect_code' => $effect_code)); 
  394. $output = $this->object->legacy_render($display_settings['template'], $params, $return, 'gallery'); 
  395. } else { 
  396. $params = $display_settings; 
  397. $params['storage'] =& $storage; 
  398. $params['images'] =& $images; 
  399. $params['displayed_gallery_id'] = $gallery_id; 
  400. $params['current_page'] = $current_page; 
  401. $params['effect_code'] = $effect_code; 
  402. $params['pagination'] = $pagination; 
  403. $params['thumbnail_size_name'] = $thumbnail_size_name; 
  404. $params['slideshow_link'] = $slideshow_link; 
  405. $params = $this->object->prepare_display_parameters($displayed_gallery, $params); 
  406. $output = $this->object->render_view('photocrati-nextgen_basic_gallery#thumbnails/index', $params, $return); 
  407. return $output; 
  408. } else { 
  409. if ($display_settings['display_no_images_error']) { 
  410. return $this->object->render_partial('photocrati-nextgen_gallery_display#no_images_found', array(), $return); 
  411. /** 
  412. * Enqueues all static resources required by this display type 
  413. * @param C_Displayed_Gallery $displayed_gallery 
  414. */ 
  415. public function enqueue_frontend_resources($displayed_gallery) 
  416. $this->call_parent('enqueue_frontend_resources', $displayed_gallery); 
  417. wp_enqueue_style('nextgen_basic_thumbnails_style', $this->get_static_url('photocrati-nextgen_basic_gallery#thumbnails/nextgen_basic_thumbnails.css'), FALSE, NGG_SCRIPT_VERSION); 
  418. if ($displayed_gallery->display_settings['ajax_pagination']) { 
  419. wp_enqueue_script('nextgen-basic-thumbnails-ajax-pagination', $this->object->get_static_url('photocrati-nextgen_basic_gallery#thumbnails/ajax_pagination.js'), FALSE, NGG_SCRIPT_VERSION); 
  420. wp_enqueue_style('nextgen_pagination_style', $this->get_static_url('photocrati-nextgen_pagination#style.css'), FALSE, NGG_SCRIPT_VERSION); 
  421. $this->enqueue_ngg_styles(); 
  422. /** 
  423. * Provides the url of the JavaScript library required for 
  424. * NextGEN Basic Thumbnails to display 
  425. * @return string 
  426. */ 
  427. public function _get_js_lib_url() 
  428. return $this->object->get_static_url('photocrati-nextgen_basic_gallery#thumbnails/nextgen_basic_thumbnails.js'); 
.