A_NextGen_Basic_Template_Form

Class A_NextGen_Basic_Template_Form.

Defined (1)

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

/products/photocrati_nextgen/modules/nextgen_basic_templates/package.module.nextgen_basic_templates.php  
  1. class A_NextGen_Basic_Template_Form extends Mixin 
  2. /** 
  3. * Renders 'template' settings field 
  4. * @param $display_type 
  5. * @return mixed 
  6. */ 
  7. function _render_nextgen_basic_templates_template_field($display_type) 
  8. switch ($display_type->name) { 
  9. case 'photocrati-nextgen_basic_singlepic': 
  10. $prefix = 'singlepic'; 
  11. break; 
  12. case 'photocrati-nextgen_basic_thumbnails': 
  13. $prefix = 'gallery'; 
  14. break; 
  15. case 'photocrati-nextgen_basic_slideshow': 
  16. $prefix = 'gallery'; 
  17. break; 
  18. case 'photocrati-nextgen_basic_imagebrowser': 
  19. $prefix = 'imagebrowser'; 
  20. break; 
  21. case NGG_BASIC_COMPACT_ALBUM: 
  22. $prefix = 'album'; 
  23. break; 
  24. case NGG_BASIC_EXTENDED_ALBUM: 
  25. $prefix = 'album'; 
  26. break; 
  27. default: 
  28. $prefix = FALSE; 
  29. break; 
  30. // ensure the current file is in the list 
  31. $templates = $this->object->_get_available_templates($prefix); 
  32. if (!isset($templates[$display_type->settings['template']])) { 
  33. $templates[$display_type->settings['template']] = $display_type->settings['template']; 
  34. // add <default> template that acts the same way as having no template specified 
  35. $templates['default'] = __('Default', 'nggallery'); 
  36. return $this->object->render_partial('photocrati-nextgen_basic_templates#nextgen_basic_templates_settings_template', array('display_type_name' => $display_type->name, 'template_label' => __('Template', 'nggallery'), 'template_text' => __('Use a legacy template when rendering (not recommended).', 'nggallery'), 'chosen_file' => $display_type->settings['template'], 'templates' => $templates), True); 
  37. /** 
  38. * Retrieves listing of available templates 
  39. * Override this function to modify or add to the available templates listing, array format 
  40. * is array(file_abspath => label) 
  41. * @return array 
  42. */ 
  43. function _get_available_templates($prefix = FALSE) 
  44. $templates = array(); 
  45. foreach (C_Legacy_Template_Locator::get_instance()->find_all($prefix) as $label => $files) { 
  46. foreach ($files as $file) { 
  47. $tmp = explode(DIRECTORY_SEPARATOR, $file); 
  48. $templates[$file] = "{$label}: " . end($tmp); 
  49. asort($templates); 
  50. return $templates; 
  51. /** 
  52. * Returns the parameter objects necessary for legacy template rendering (legacy_render()) 
  53. * @param $images 
  54. * @param $displayed_gallery 
  55. * @param array $params 
  56. * @return array 
  57. */ 
  58. function prepare_legacy_parameters($images, $displayed_gallery, $params = array()) 
  59. // setup 
  60. $image_map = C_Image_Mapper::get_instance(); 
  61. $gallery_map = C_Gallery_Mapper::get_instance(); 
  62. $image_key = $image_map->get_primary_key_column(); 
  63. $gallery_key = $gallery_map->get_primary_key_column(); 
  64. $gallery_id = $displayed_gallery->id(); 
  65. $pid = $this->object->param('pid'); 
  66. // because picture_list implements ArrayAccess any array-specific actions must be taken on 
  67. // $picture_list->container or they won't do anything 
  68. $picture_list = new C_Image_Wrapper_Collection(); 
  69. $current_pid = NULL; 
  70. // begin processing 
  71. $current_page = @get_the_ID() == FALSE ? 0 : @get_the_ID(); 
  72. // determine what the "current image" is; used mostly for carousel 
  73. if (!is_numeric($pid) && !empty($pid)) { 
  74. $picture = $image_map->find_first(array('image_slug = %s', $pid)); 
  75. $pid = $picture->{$image_key}; 
  76. // create our new wrappers 
  77. foreach ($images as &$image) { 
  78. if ($image && isset($params['effect_code'])) { 
  79. if (is_object($image)) { 
  80. $image->thumbcode = $params['effect_code']; 
  81. } elseif (is_array($image)) { 
  82. $image['thumbcode'] = $params['effect_code']; 
  83. $new_image = new C_Image_Wrapper($image, $displayed_gallery); 
  84. if ($pid == $new_image->{$image_key}) { 
  85. $current_pid = $new_image; 
  86. $picture_list[] = $new_image; 
  87. reset($picture_list->container); 
  88. // assign current_pid 
  89. $current_pid = is_null($current_pid) ? current($picture_list->container) : $current_pid; 
  90. foreach ($picture_list as &$image) { 
  91. if (isset($image->hidden) && $image->hidden) { 
  92. $tmp = $displayed_gallery->display_settings['number_of_columns']; 
  93. $image->style = $tmp > 0 ? 'style="width:' . floor(100 / $tmp) . '%;display: none;"' : 'style="display: none;"'; 
  94. // find our gallery to build the new one on 
  95. $orig_gallery = $gallery_map->find(current($picture_list->container)->galleryid); 
  96. // create the 'gallery' object 
  97. $gallery = new stdclass(); 
  98. $gallery->ID = $displayed_gallery->id(); 
  99. $gallery->name = stripslashes($orig_gallery->name); 
  100. $gallery->title = stripslashes($orig_gallery->title); 
  101. $gallery->description = html_entity_decode(stripslashes($orig_gallery->galdesc)); 
  102. $gallery->pageid = $orig_gallery->pageid; 
  103. $gallery->anchor = 'ngg-gallery-' . $gallery_id . '-' . $current_page; 
  104. $gallery->displayed_gallery =& $displayed_gallery; 
  105. $gallery->columns = @intval($displayed_gallery->display_settings['number_of_columns']); 
  106. $gallery->imagewidth = $gallery->columns > 0 ? 'style="width:' . floor(100 / $gallery->columns) . '%;"' : ''; 
  107. if (!empty($displayed_gallery->display_settings['show_slideshow_link'])) { 
  108. $gallery->show_slideshow = TRUE; 
  109. $gallery->slideshow_link = $params['slideshow_link']; 
  110. $gallery->slideshow_link_text = $displayed_gallery->display_settings['slideshow_link_text']; 
  111. } else { 
  112. $gallery->show_slideshow = FALSE; 
  113. $gallery = apply_filters('ngg_gallery_object', $gallery, 4); 
  114. // build our array of things to return 
  115. $return = array('registry' => C_Component_Registry::get_instance(), 'gallery' => $gallery); 
  116. // single_image is an internally added flag 
  117. if (!empty($params['single_image'])) { 
  118. $return['image'] = $picture_list[0]; 
  119. } else { 
  120. $return['current'] = $current_pid; 
  121. $return['images'] = $picture_list->container; 
  122. // this is expected to always exist 
  123. if (!empty($params['pagination'])) { 
  124. $return['pagination'] = $params['pagination']; 
  125. } else { 
  126. $return['pagination'] = NULL; 
  127. if (!empty($params['next'])) { 
  128. $return['next'] = $params['next']; 
  129. } else { 
  130. $return['next'] = FALSE; 
  131. if (!empty($params['prev'])) { 
  132. $return['prev'] = $params['prev']; 
  133. } else { 
  134. $return['prev'] = FALSE; 
  135. return $return; 
  136. function enqueue_static_resources() 
  137. wp_enqueue_style('ngg_template_settings', $this->get_static_url('photocrati-nextgen_basic_templates#ngg_template_settings.css'), FALSE, NGG_SCRIPT_VERSION); 
  138. wp_enqueue_script('ngg_template_settings', $this->get_static_url('photocrati-nextgen_basic_templates#ngg_template_settings.js'), array('ngg_select2'), NGG_SCRIPT_VERSION, TRUE); 
  139. wp_localize_script('ngg_template_settings', 'ngg_template_settings', array('placeholder_text' => __('No template selected'))); 
  140. $atp = C_Attach_Controller::get_instance(); 
  141. if ($atp != null) { 
  142. $atp->mark_script('ngg_template_settings');