function index_action($displayed_gallery, $return = FALSE) { $retval = ''; $call_parent = TRUE; $show = $this->object->param('show'); $pid = $this->object->param('pid'); if (!empty($pid) && isset($displayed_gallery->display_settings['use_imagebrowser_effect']) && intval($displayed_gallery->display_settings['use_imagebrowser_effect'])) { $show = NGG_BASIC_IMAGEBROWSER; } // Are we to display a different display type? if (!empty($show)) { $params = (array) $displayed_gallery->get_entity(); $ds = $params['display_settings']; if ((!empty($ds['show_slideshow_link']) || !empty($ds['show_thumbnail_link']) || !empty($ds['use_imagebrowser_effect'])) && $show != $this->object->context) { // Render the new display type $renderer = C_Displayed_Gallery_Renderer::get_instance(); $displayed_gallery->original_display_type = $displayed_gallery->display_type; $displayed_gallery->original_settings = $displayed_gallery->display_settings; $displayed_gallery->display_type = $show; $params = (array) $displayed_gallery->get_entity(); $params['display_settings'] = array(); $retval = $renderer->display_images($params, $return); $call_parent = FALSE; } } return $call_parent ? $this->call_parent('index_action', $displayed_gallery, $return) : $retval; }
/** * Displays the 'tagcloud' display type * * @param stdClass|C_Displayed_Gallery|C_DataMapper_Model $displayed_gallery */ public function index_action($displayed_gallery, $return = FALSE) { $display_settings = $displayed_gallery->display_settings; $application = C_Router::get_instance()->get_routed_app(); $tag = urldecode($this->param('gallerytag')); // we're looking at a tag, so show images w/that tag as a thumbnail gallery if (!is_home() && !empty($tag)) { return C_Displayed_Gallery_Renderer::get_instance()->display_images(array('source' => 'tags', 'container_ids' => array(esc_attr($tag)), 'display_type' => $display_settings['display_type'], 'original_display_type' => $displayed_gallery->display_type, 'original_settings' => $display_settings)); } $defaults = array('exclude' => '', 'format' => 'list', 'include' => $displayed_gallery->get_term_ids_for_tags(), 'largest' => 22, 'link' => 'view', 'number' => $display_settings['number'], 'order' => 'ASC', 'orderby' => 'name', 'smallest' => 8, 'taxonomy' => 'ngg_tag', 'unit' => 'pt'); $args = wp_parse_args('', $defaults); // Always query top tags $tags = get_terms($args['taxonomy'], array_merge($args, array('orderby' => 'count', 'order' => 'DESC'))); foreach ($tags as $key => $tag) { $tags[$key]->link = $this->object->set_param_for($application->get_routed_url(TRUE), 'gallerytag', $tag->slug); $tags[$key]->id = $tag->term_id; } $params = $display_settings; $params['inner_content'] = $displayed_gallery->inner_content; $params['storage'] =& $storage; $params['tagcloud'] = wp_generate_tag_cloud($tags, $args); $params['displayed_gallery_id'] = $displayed_gallery->id(); $params = $this->object->prepare_display_parameters($displayed_gallery, $params); return $this->object->render_partial('photocrati-nextgen_basic_tagcloud#nextgen_basic_tagcloud', $params, $return); }
function render_displayed_gallery_action() { $retval = array(); // this must run ONLY twice if (isset($_POST['ajax_referrer']) && $this->_run_count <= 1) { // set the router & routed app to use the uri provided in ajax_referrer $parsed_url = parse_url($_POST['ajax_referrer']); $url = $parsed_url['path']; if (!empty($parsed_url['query'])) { $url .= '?' . $parsed_url['query']; } $_SERVER['REQUEST_URI'] = $url; $_SERVER['PATH_INFO'] = $parsed_url['path']; $this->_run_count++; C_Router::$_instances = array(); $router = C_Router::get_instance(); $router->serve_request(); } if (isset($_POST['displayed_gallery_id'])) { $displayed_gallery = new C_Displayed_Gallery(); $displayed_gallery->apply_transient($_POST['displayed_gallery_id']); $renderer = C_Displayed_Gallery_Renderer::get_instance(); $retval['html'] = $renderer->render($displayed_gallery, TRUE); } return $retval; }
function render_singlepic($params, $inner_content = NULL) { $params['display_type'] = $this->_get_param('display_type', NGG_BASIC_SINGLEPIC, $params); $params['image_ids'] = $this->_get_param('id', NULL, $params); unset($params['id']); $renderer = C_Displayed_Gallery_Renderer::get_instance(); return $renderer->display_images($params, $inner_content); }
/** * Short-cut for rendering a thumbnail gallery based on tags * @param array $params * @param null $inner_content * @return string */ function render_shortcode($params, $inner_content = NULL) { $params['tagcloud'] = $this->_get_param('tagcloud', 'yes', $params); $params['source'] = $this->_get_param('source', 'tags', $params); $params['display_type'] = $this->_get_param('display_type', NGG_BASIC_TAGCLOUD, $params); $renderer = C_Displayed_Gallery_Renderer::get_instance(); return $renderer->display_images($params, $inner_content); }
/** * Renders the shortcode for rendering an album * @param array $params * @param null $inner_content * @return string */ function ngglegacy_shortcode($params, $inner_content = NULL) { $params['source'] = $this->_get_param('source', 'albums', $params); $params['container_ids'] = $this->_get_param('id', NULL, $params); $params['display_type'] = $this->_get_param('display_type', NGG_BASIC_COMPACT_ALBUM, $params); unset($params['id']); $renderer = C_Displayed_Gallery_Renderer::get_instance(); return $renderer->display_images($params, $inner_content); }
function render_shortcode($params, $inner_content = NULL) { $params['gallery_ids'] = $this->_get_param('id', NULL, $params); $params['source'] = $this->_get_param('source', 'galleries', $params); $params['display_type'] = $this->_get_param('display_type', NGG_BASIC_IMAGEBROWSER, $params); unset($params['id']); $renderer = C_Displayed_Gallery_Renderer::get_instance(); return $renderer->display_images($params, $inner_content); }
function render_displayed_gallery_action() { $retval = array(); if (isset($_POST['ajax_referrer'])) { $_SERVER['REQUEST_URI'] = $_POST['ajax_referrer']; C_Router::get_instance()->serve_request(); } if (isset($_POST['displayed_gallery_id'])) { $displayed_gallery = new C_Displayed_Gallery(); $displayed_gallery->apply_transient($_POST['displayed_gallery_id']); $renderer = C_Displayed_Gallery_Renderer::get_instance(); $retval['html'] = $renderer->render($displayed_gallery, TRUE); } return $retval; }
function _render_gallery($display_type, $original_display_type, $original_settings, $original_entities, $return = FALSE) { // Try finding the gallery by slug first. If nothing is found, we assume that // the user passed in a gallery id instead $gallery = $gallery_slug = $this->object->param('gallery'); $mapper = C_Gallery_Mapper::get_instance(); $result = reset($mapper->select()->where(array('slug = %s', $gallery))->limit(1)->run_query()); if ($result) { $gallery = $result->{$result->id_field}; } add_filter('ngg_displayed_gallery_rendering', array($this, 'add_breadcrumbs_to_legacy_templates'), 10, 2); $renderer = C_Displayed_Gallery_Renderer::get_instance(); $output = $renderer->display_images(array('source' => 'galleries', 'container_ids' => array($gallery), 'display_type' => $display_type, 'original_display_type' => $original_display_type, 'original_settings' => $original_settings, 'original_album_entities' => $original_entities), $return); remove_filter('ngg_displayed_gallery_rendering', array($this, 'add_breadcrumbs_to_legacy_templates')); return $output; }
/** * Substitutes the gallery placeholder content with the gallery type frontend * view, returns a list of static resources that need to be loaded * @param string $content */ function substitute_placeholder_imgs($content) { $content = $this->fix_preview_images($content); // To match ATP entries we compare the stored url against a generic path; entries MUST have a gallery ID if (preg_match_all("#<img.*http(s)?://(.*)?" . NGG_ATTACH_TO_POST_SLUG . "(=|/)preview(/|&|&)id(=|--)(\\d+).*?>#mi", $content, $matches, PREG_SET_ORDER)) { $mapper = C_Displayed_Gallery_Mapper::get_instance(); foreach ($matches as $match) { // Find the displayed gallery $displayed_gallery_id = $match[6]; $displayed_gallery = $mapper->find($displayed_gallery_id, TRUE); // Get the content for the displayed gallery $retval = '<p>' . _('Invalid Displayed Gallery') . '</p>'; if ($displayed_gallery) { $retval = ''; $renderer = C_Displayed_Gallery_Renderer::get_instance(); if (defined('NGG_SHOW_DISPLAYED_GALLERY_ERRORS') && NGG_SHOW_DISPLAYED_GALLERY_ERRORS && $displayed_gallery->is_invalid()) { $retval .= var_export($displayed_gallery->get_errors(), TRUE); } if (self::$substitute_placeholders) { $retval .= $renderer->render($displayed_gallery, TRUE); } } $content = str_replace($match[0], $retval, $content); } } return $content; }
/** * Provides the [display_images] shortcode * @param array $params * @param string $inner_content * @return string */ function display_images($params, $inner_content = NULL) { $renderer = C_Displayed_Gallery_Renderer::get_instance(); return $renderer->display_images($params, $inner_content); }
function render_slideshow($galleryID, $irWidth = '', $irHeight = '', $limit = 10, $args) { $registry = C_Component_Registry::get_instance(); $renderer = C_Displayed_Gallery_Renderer::get_instance(); $params = array('container_ids' => $galleryID, 'display_type' => 'photocrati-nextgen_basic_slideshow', 'gallery_width' => $irWidth, 'gallery_height' => $irHeight, 'source' => 'galleries', 'slug' => 'widget-' . $args['widget_id'], 'entity_types' => array('image'), 'show_thumbnail_link' => FALSE, 'show_slideshow_link' => FALSE, 'use_imagebrowser_effect' => FALSE, 'ngg_triggers_display' => 'never'); if (0 === $galleryID) { $params['source'] = 'random_images'; $params['maximum_entity_count'] = $limit; unset($params['container_ids']); } $retval = $renderer->display_images($params, NULL); $retval = apply_filters('ngg_show_slideshow_widget_content', $retval, $galleryID, $irWidth, $irHeight); return $retval; }
/** * Captures an section of user display code. * * @autor John Godley * @param string $template_name Name of the template file (without extension) * @param string $vars Array of variable name=>value that is available to the display code (optional) * @deprecated Use C_Displayed_Gallery_Renderer class * @return void **/ static function capture($template_name, $vars = array()) { $vars['template'] = $template_name; return C_Displayed_Gallery_Renderer::get_instance()->display_images($vars); }
/** * Renders the front-end for the NextGen Basic Album display type * * @param $displayed_gallery * @param bool $return */ public function index_action($displayed_gallery, $return = FALSE) { // Ensure that the open_gallery_in_lightbox setting is present if (!array_key_exists('open_gallery_in_lightbox', $displayed_gallery->display_settings)) { $displayed_gallery->display_settings['open_gallery_in_lightbox'] = 0; } $display_settings = $displayed_gallery->display_settings; // We need to fetch the album containers selected in the Attach // to Post interface. We need to do this, because once we fetch the // included entities, we need to iterate over each entity and assign it // a parent_id, which is the album that it belongs to. We need to do this // because the link to the gallery, is not /nggallery/gallery--id, but // /nggallery/album--id/gallery--id $parent_albums = $displayed_gallery->get_albums(); // Are we to display a gallery? Ensure our 'gallery' isn't just a paginated album view $gallery = $gallery_slug = $this->param('gallery'); if ($gallery && strpos($gallery, 'nggpage--') !== 0) { // basic albums only support one per post if (isset($GLOBALS['nggShowGallery'])) { return; } $GLOBALS['nggShowGallery'] = TRUE; // Try finding the gallery by slug first. If nothing is found, we assume that // the user passed in a gallery id instead $mapper = C_Gallery_Mapper::get_instance(); $tmp = $mapper->select()->where(array('slug = %s', $gallery))->limit(1)->run_query(); $result = reset($tmp); unset($tmp); if ($result) { $gallery = $result->{$result->id_field}; } $renderer = C_Displayed_Gallery_Renderer::get_instance('inner'); $gallery_params = array('source' => 'galleries', 'container_ids' => array($gallery), 'display_type' => $display_settings['gallery_display_type'], 'original_display_type' => $displayed_gallery->display_type, 'original_settings' => $display_settings, 'original_album_entities' => $parent_albums); if (!empty($display_settings['gallery_display_template'])) { $gallery_params['template'] = $display_settings['gallery_display_template']; } add_filter('ngg_displayed_gallery_rendering', array($this, 'add_description_to_legacy_templates'), 8, 2); add_filter('ngg_displayed_gallery_rendering', array($this, 'add_breadcrumbs_to_legacy_templates'), 9, 2); $output = $renderer->display_images($gallery_params, $return); remove_filter('ngg_displayed_gallery_rendering', array($this, 'add_breadcrumbs_to_legacy_templates')); remove_filter('ngg_displayed_gallery_rendering', array($this, 'add_description_to_legacy_templates')); return $output; } else { if ($album = $this->param('album')) { $mapper = C_Album_Mapper::get_instance(); $result = $mapper->select()->where(array('slug = %s', $album))->limit(1)->run_query(); $result = array_pop($result); $album_sub = $result ? $result->{$result->id_field} : null; if ($album_sub != null) { $album = $album_sub; } $displayed_gallery->entity_ids = array(); $displayed_gallery->sortorder = array(); $displayed_gallery->container_ids = ($album === '0' or $album === 'all') ? array() : array($album); $displayed_gallery->display_settings['original_album_id'] = 'a' . $album_sub; $displayed_gallery->display_settings['original_album_entities'] = $parent_albums; } } // Get the albums // TODO: This should probably be moved to the elseif block above $this->albums = $displayed_gallery->get_albums(); // None of the above: Display the main album. Get the settings required for display $current_page = (int) $this->param('page', $displayed_gallery->id(), 1); $offset = $display_settings['galleries_per_page'] * ($current_page - 1); $entities = $displayed_gallery->get_included_entities($display_settings['galleries_per_page'], $offset); // If there are entities to be displayed if ($entities) { $pagination_result = $this->object->create_pagination($current_page, $displayed_gallery->get_entity_count(), $display_settings['galleries_per_page'], urldecode($this->object->param('ajax_pagination_referrer'))); if (!empty($display_settings['template']) && $display_settings['template'] != 'default') { // Add additional parameters $this->object->remove_param('ajax_pagination_referrer'); $display_settings['current_page'] = $current_page; $display_settings['entities'] =& $entities; $display_settings['pagination_prev'] = $pagination_result['prev']; $display_settings['pagination_next'] = $pagination_result['next']; $display_settings['pagination'] = $pagination_result['output']; // Legacy templates lack a good way of injecting content at the right time $this->object->add_mixin('A_NextGen_Album_Breadcrumbs'); $this->object->add_mixin('A_NextGen_Album_Descriptions'); $breadcrumbs = $this->object->render_legacy_template_breadcrumbs($displayed_gallery, $entities); $description = $this->object->render_legacy_template_description($displayed_gallery); // Render legacy template $this->object->add_mixin('Mixin_NextGen_Basic_Templates'); $display_settings = $this->prepare_legacy_album_params($displayed_gallery->get_entity(), $display_settings); $retval = $this->object->legacy_render($display_settings['template'], $display_settings, $return, 'album'); if (!empty($description)) { $retval = $description . $retval; } if (!empty($breadcrumbs)) { $retval = $breadcrumbs . $retval; } return $retval; } else { $params = $display_settings; $albums = $this->prepare_legacy_album_params($displayed_gallery->get_entity(), array('entities' => $entities)); $params['pagination'] = $pagination_result['output']; $params['image_gen_params'] = $albums['image_gen_params']; $params['galleries'] = $albums['galleries']; foreach ($params['galleries'] as &$gallery) { $gallery->entity_type = isset($gallery->is_gallery) && intval($gallery->is_gallery) ? 'gallery' : 'album'; // If we're to open a gallery in a lightbox, we need to expose it to the lightbox // as a displayed gallery if (isset($params['open_gallery_in_lightbox']) && $gallery->entity_type == 'gallery') { $gallery->displayed_gallery = new C_Displayed_Gallery(); $gallery->displayed_gallery->container_ids = array($gallery->{$gallery->id_field}); $gallery->displayed_gallery->display_settings = $displayed_gallery->display_settings; $gallery->displayed_gallery->returns = 'included'; $gallery->displayed_gallery->source = 'galleries'; $gallery->displayed_gallery->images_list_count = $gallery->displayed_gallery->get_entity_count(); $gallery->displayed_gallery->is_album_gallery = TRUE; $gallery->displayed_gallery->to_transient(); if ($this->does_lightbox_support_displayed_gallery($displayed_gallery)) { $gallery->displayed_gallery->effect_code = $this->object->get_effect_code($gallery->displayed_gallery); } // Add "galleries.gallery_1 = {};" $this->object->_add_script_data('ngg_common', 'galleries.gallery_' . $gallery->displayed_gallery->id(), (array) $gallery->displayed_gallery->get_entity(), FALSE); $this->object->_add_script_data('ngg_common', 'galleries.gallery_' . $gallery->displayed_gallery->id() . '.wordpress_page_root', get_permalink(), FALSE); } } $params['displayed_gallery'] = $displayed_gallery; $params = $this->object->prepare_display_parameters($displayed_gallery, $params); switch ($displayed_gallery->display_type) { case NGG_BASIC_COMPACT_ALBUM: $template = 'compact'; break; case NGG_BASIC_EXTENDED_ALBUM: $template = 'extended'; break; } return $this->object->render_view("photocrati-nextgen_basic_album#{$template}", $params, $return); } } else { return $this->object->render_partial('photocrati-nextgen_gallery_display#no_images_found', array(), $return); } }
function _load_displayed_gallery() { $mapper = C_Displayed_Gallery_Mapper::get_instance(); // Fetch the displayed gallery by ID if ($id = $this->object->param('id')) { $this->object->_displayed_gallery = $mapper->find($id, TRUE); } else { if (isset($_REQUEST['shortcode'])) { $params = str_replace('ngg_images', '', base64_decode($_REQUEST['shortcode'])); $params = stripslashes($params); $params = str_replace(array('[', ']'), array('[', ']'), $params); $params = shortcode_parse_atts($params); $this->object->_displayed_gallery = C_Displayed_Gallery_Renderer::get_instance()->params_to_displayed_gallery($params); } } // If all else fails, then create fresh with a new displayed gallery if (empty($this->object->_displayed_gallery)) { $this->object->_displayed_gallery = $mapper->create(); } }
/** * Renders the front-end for the NextGen Basic Album display type * * @param $displayed_gallery * @param bool $return */ public function index_action($displayed_gallery, $return = FALSE) { $display_settings = $displayed_gallery->display_settings; // We need to fetch the album containers selected in the Attach // to Post interface. We need to do this, because once we fetch the // included entities, we need to iterate over each entity and assign it // a parent_id, which is the album that it belongs to. We need to do this // because the link to the gallery, is not /nggallery/gallery--id, but // /nggallery/album--id/gallery--id // Are we to display a gallery? if ($gallery = $gallery_slug = $this->param('gallery')) { // basic albums only support one per post if (isset($GLOBALS['nggShowGallery'])) { return; } $GLOBALS['nggShowGallery'] = TRUE; // Try finding the gallery by slug first. If nothing is found, we assume that // the user passed in a gallery id instead $mapper = C_Gallery_Mapper::get_instance(); $result = reset($mapper->select()->where(array('slug = %s', $gallery))->limit(1)->run_query()); if ($result) { $gallery = $result->{$result->id_field}; } $renderer = C_Displayed_Gallery_Renderer::get_instance('inner'); $gallery_params = array('source' => 'galleries', 'container_ids' => array($gallery), 'display_type' => $display_settings['gallery_display_type'], 'original_display_type' => $displayed_gallery->display_type, 'original_settings' => $display_settings); if (!empty($display_settings['gallery_display_template'])) { $gallery_params['template'] = $display_settings['gallery_display_template']; } return $renderer->display_images($gallery_params, $return); } else { if ($album = $this->param('album')) { $mapper = C_Album_Mapper::get_instance(); $result = array_pop($mapper->select()->where(array('slug = %s', $album))->limit(1)->run_query()); $album_sub = $result ? $result->{$result->id_field} : null; if ($album_sub != null) { $album = $album_sub; } $displayed_gallery->entity_ids = array(); $displayed_gallery->sortorder = array(); $displayed_gallery->container_ids = ($album === '0' or $album === 'all') ? array() : array($album); } } // Get the albums // TODO: This should probably be moved to the elseif block above $this->albums = $displayed_gallery->get_albums(); // None of the above: Display the main album. Get the settings required for display $current_page = (int) $this->param('nggpage', 1); $offset = $display_settings['galleries_per_page'] * ($current_page - 1); $entities = $displayed_gallery->get_included_entities($display_settings['galleries_per_page'], $offset); // If there are entities to be displayed if ($entities) { if (!empty($display_settings['template'])) { // Add additional parameters $pagination_result = $this->object->create_pagination($current_page, $displayed_gallery->get_entity_count(), $display_settings['galleries_per_page'], urldecode($this->object->param('ajax_pagination_referrer'))); $this->object->remove_param('ajax_pagination_referrer'); $display_settings['current_page'] = $current_page; $display_settings['entities'] =& $entities; $display_settings['pagination_prev'] = $pagination_result['prev']; $display_settings['pagination_next'] = $pagination_result['next']; $display_settings['pagination'] = $pagination_result['output']; // Render legacy template $this->object->add_mixin('Mixin_NextGen_Basic_Templates'); $display_settings = $this->prepare_legacy_album_params($displayed_gallery->get_entity(), $display_settings); return $this->object->legacy_render($display_settings['template'], $display_settings, $return, 'album'); } else { $params = $display_settings; $albums = $this->prepare_legacy_album_params($displayed_gallery->get_entity(), array('entities' => $entities)); $params['image_gen_params'] = $albums['image_gen_params']; $params['galleries'] = $albums['galleries']; $params['displayed_gallery'] = $displayed_gallery; $params = $this->object->prepare_display_parameters($displayed_gallery, $params); switch ($displayed_gallery->display_type) { case NGG_BASIC_COMPACT_ALBUM: $template = 'compact'; break; case NGG_BASIC_EXTENDED_ALBUM: $template = 'extended'; break; } return $this->object->render_view("photocrati-nextgen_basic_album#{$template}", $params, $return); } } else { return $this->object->render_partial('photocrati-nextgen_gallery_display#no_images_found', array(), $return); } }
function render_slideshow($params, $inner_content = NULL) { $params['gallery_ids'] = $this->_get_param('id', NULL, $params); $params['display_type'] = $this->_get_param('display_type', NGG_BASIC_SLIDESHOW, $params); $params['gallery_width'] = $this->_get_param('w', NULL, $params); $params['gallery_height'] = $this->_get_param('h', NULL, $params); unset($params['id'], $params['w'], $params['h']); $renderer = C_Displayed_Gallery_Renderer::get_instance(); return $renderer->display_images($params, $inner_content); }
/** * Returns the rendered HTML of a gallery based on the provided tag * * @param string $tag * @return string */ public function index_action($tag) { $renderer = C_Displayed_Gallery_Renderer::get_instance(); $output = $renderer->display_images(array('source' => 'tags', 'container_ids' => $tag, 'slug' => $tag, 'display_type' => NGG_BASIC_THUMBNAILS)); // This strips extra whitespace and strips newlines. For some reason this is especially // necessary on Wordpress taxonomy pages. return trim(preg_replace('/\\s\\s+/', ' ', $output)); }