本文整理汇总了PHP中C_Gallery_Mapper::get_instance方法的典型用法代码示例。如果您正苦于以下问题:PHP C_Gallery_Mapper::get_instance方法的具体用法?PHP C_Gallery_Mapper::get_instance怎么用?PHP C_Gallery_Mapper::get_instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类C_Gallery_Mapper
的用法示例。
在下文中一共展示了C_Gallery_Mapper::get_instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_existing_galleries_action
/**
* Gets existing galleries
* @return array
*/
public function get_existing_galleries_action()
{
$this->debug = TRUE;
$response = array();
if ($this->object->validate_ajax_request('nextgen_edit_displayed_gallery')) {
$limit = $this->object->param('limit');
$offset = $this->object->param('offset');
// We return the total # of galleries, so that the client can make
// pagination requests
$mapper = C_Gallery_Mapper::get_instance();
$response['total'] = $mapper->count();
$response['limit'] = $limit = $limit ? $limit : 0;
$response['offset'] = $offset = $offset ? $offset : 0;
// Get the galleries
$mapper->select();
if ($limit) {
$mapper->limit($limit, $offset);
}
$response['items'] = $mapper->run_query();
} else {
$response['error'] = 'insufficient access';
}
$this->debug = FALSE;
return $response;
}
示例2: flush_galleries
/**
* Flushes cache from all available galleries
*
* @param array $galleries When provided only the requested galleries' cache is flushed
*/
public function flush_galleries($galleries = array())
{
if (empty($galleries)) {
$galleries = C_Gallery_Mapper::get_instance()->find_all();
}
foreach ($galleries as $gallery) {
C_Gallery_Storage::get_instance()->flush_cache($gallery);
}
}
示例3: flush_galleries
/**
* Flushes cache from all available galleries
*
* @param array $galleries When provided only the requested galleries' cache is flushed
*/
public function flush_galleries($galleries = array())
{
global $wpdb;
if (empty($galleries)) {
$galleries = C_Gallery_Mapper::get_instance()->find_all();
}
foreach ($galleries as $gallery) {
C_Gallery_Storage::get_instance()->flush_cache($gallery);
}
// Remove images still in the DB whose gallery no longer exists
$wpdb->query("DELETE FROM `{$wpdb->nggpictures}` WHERE `galleryid` NOT IN (SELECT `gid` FROM `{$wpdb->nggallery}`)");
}
示例4: upload_images
function upload_images()
{
$storage = C_Gallery_Storage::get_instance();
$image_mapper = C_Image_Mapper::get_instance();
$gallery_mapper = C_Gallery_Mapper::get_instance();
// Get Gallery ID
$galleryID = absint($_POST['galleryselect']);
if (0 == $galleryID) {
$galleryID = get_option('npu_default_gallery');
if (empty($galleryID)) {
self::show_error(__('No gallery selected.', 'nextgen-public-uploader'));
return;
}
}
// Get the Gallery
$gallery = $gallery_mapper->find($galleryID);
if (!$gallery->path) {
self::show_error(__('Failure in database, no gallery path set.', 'nextgen-public-uploader'));
return;
}
// Read Image List
foreach ($_FILES as $key => $value) {
if (0 == $_FILES[$key]['error']) {
try {
if ($storage->is_image_file($_FILES[$key]['tmp_name'])) {
$image = $storage->object->upload_base64_image($gallery, file_get_contents($_FILES[$key]['tmp_name']), $_FILES[$key]['name']);
if (get_option('npu_exclude_select')) {
$image->exclude = 1;
$image_mapper->save($image);
}
// Add to Image and Dir List
$this->arrImgNames[] = $image->filename;
$this->arrImageIds[] = $image->id();
$this->strGalleryPath = $gallery->path;
} else {
unlink($_FILES[$key]['tmp_name']);
$error_msg = sprintf(__('<strong>%s</strong> is not a valid file.', 'nextgen-public-uploader'), $_FILES[$key]['name']);
self::show_error($error_msg);
continue;
}
} catch (E_NggErrorException $ex) {
self::show_error('<strong>' . $ex->getMessage() . '</strong>');
continue;
} catch (Exception $ex) {
self::show_error('<strong>' . $ex->getMessage() . '</strong>');
continue;
}
}
}
}
示例5: _render_gallery
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;
}
示例6: import_image
/**
* Import an image from the filesystem into NextGen
*
* @synopsis --filename=<absolute-path> --gallery=<gallery-id>
*/
function import_image($args, $assoc_args)
{
$mapper = C_Gallery_Mapper::get_instance();
$storage = C_Gallery_Storage::get_instance();
if ($gallery = $mapper->find($assoc_args['gallery'], TRUE)) {
$file_data = @file_get_contents($assoc_args['filename']);
$file_name = M_I18n::mb_basename($assoc_args['filename']);
if (empty($file_data)) {
WP_CLI::error('Could not load file');
}
$image = $storage->upload_base64_image($gallery, $file_data, $file_name);
$image_id = $image->{$image->id_field};
if (!$image) {
WP_CLI::error('Could not import image');
} else {
WP_CLI::success("Imported image with id #{$image_id}");
}
} else {
WP_CLI::error("Gallery not found (with id #{$assoc_args['gallery']}");
}
}
示例7: add_gallery
/**
* Parse the gallery/imagebrowser/slideshow shortcode and return all images into an array
*
* @param string $atts
* @return
*/
function add_gallery($atts)
{
global $wpdb;
extract(shortcode_atts(array('id' => 0), $atts));
$gallery_mapper = C_Gallery_Mapper::get_instance();
if (!is_numeric($id)) {
if ($gallery = array_shift($gallery_mapper->select()->where(array('name = %s', $id))->limit(1)->run_query())) {
$id = $gallery->{$gallery->id_field};
} else {
$id = NULL;
}
}
if ($id) {
$gallery_storage = C_Gallery_Storage::get_instance();
$image_mapper = C_Image_Mapper::get_instance();
foreach ($image_mapper->find_all_for_gallery($id) as $image) {
$this->images[] = array('src' => $gallery_storage->get_image_url($image), 'title' => $image->title, 'alt' => $image->alttext);
}
}
return '';
}
示例8: post_processor_images
function post_processor_images()
{
global $wpdb, $ngg, $nggdb;
// bulk update in a single gallery
if (isset($_POST['bulkaction']) && isset($_POST['doaction'])) {
check_admin_referer('ngg_updategallery');
switch ($_POST['bulkaction']) {
case 'no_action':
break;
case 'rotate_cw':
nggAdmin::do_ajax_operation('rotate_cw', $_POST['doaction'], __('Rotate images', 'nggallery'));
break;
case 'rotate_ccw':
nggAdmin::do_ajax_operation('rotate_ccw', $_POST['doaction'], __('Rotate images', 'nggallery'));
break;
case 'recover_images':
nggAdmin::do_ajax_operation('recover_image', $_POST['doaction'], __('Recover from backup', 'nggallery'));
break;
case 'set_watermark':
nggAdmin::do_ajax_operation('set_watermark', $_POST['doaction'], __('Set watermark', 'nggallery'));
break;
case 'delete_images':
if (is_array($_POST['doaction'])) {
foreach ($_POST['doaction'] as $imageID) {
$image = $nggdb->find_image($imageID);
if ($image) {
if ($ngg->options['deleteImg']) {
$storage = C_Gallery_Storage::get_instance();
$storage->delete_image($image->pid);
}
do_action('ngg_delete_picture', $image->pid);
$delete_pic = C_Image_Mapper::get_instance()->destroy($image->pid);
}
}
if ($delete_pic) {
nggGallery::show_message(__('Pictures deleted successfully ', 'nggallery'));
}
}
break;
case 'import_meta':
nggAdmin::do_ajax_operation('import_metadata', $_POST['doaction'], __('Import metadata', 'nggallery'));
break;
}
}
if (isset($_POST['TB_bulkaction']) && isset($_POST['TB_ResizeImages'])) {
check_admin_referer('ngg_thickbox_form');
//save the new values for the next operation
$ngg->options['imgWidth'] = (int) $_POST['imgWidth'];
$ngg->options['imgHeight'] = (int) $_POST['imgHeight'];
update_option('ngg_options', $ngg->options);
$pic_ids = explode(',', $_POST['TB_imagelist']);
nggAdmin::do_ajax_operation('resize_image', $pic_ids, __('Resize images', 'nggallery'));
}
if (isset($_POST['TB_bulkaction']) && isset($_POST['TB_NewThumbnail'])) {
check_admin_referer('ngg_thickbox_form');
// save the new values for the next operation
$settings = C_NextGen_Settings::get_instance();
$settings->thumbwidth = (int) $_POST['thumbwidth'];
$settings->thumbheight = (int) $_POST['thumbheight'];
$settings->thumbfix = isset($_POST['thumbfix']) ? TRUE : FALSE;
$settings->save();
ngg_refreshSavedSettings();
$pic_ids = explode(',', $_POST['TB_imagelist']);
nggAdmin::do_ajax_operation('create_thumbnail', $pic_ids, __('Create new thumbnails', 'nggallery'));
}
if (isset($_POST['TB_bulkaction']) && isset($_POST['TB_SelectGallery'])) {
check_admin_referer('ngg_thickbox_form');
$pic_ids = explode(',', $_POST['TB_imagelist']);
$dest_gid = (int) $_POST['dest_gid'];
switch ($_POST['TB_bulkaction']) {
case 'copy_to':
C_Gallery_Storage::get_instance()->copy_images($pic_ids, $dest_gid);
break;
case 'move_to':
C_Gallery_Storage::get_instance()->move_images($pic_ids, $dest_gid);
break;
}
}
if (isset($_POST['TB_bulkaction']) && isset($_POST['TB_EditTags'])) {
// do tags update
check_admin_referer('ngg_thickbox_form');
// get the images list
$pic_ids = explode(',', $_POST['TB_imagelist']);
$taglist = explode(',', $_POST['taglist']);
$taglist = array_map('trim', $taglist);
if (is_array($pic_ids)) {
foreach ($pic_ids as $pic_id) {
// which action should be performed ?
switch ($_POST['TB_bulkaction']) {
case 'no_action':
// No action
break;
case 'overwrite_tags':
// Overwrite tags
wp_set_object_terms($pic_id, $taglist, 'ngg_tag');
break;
case 'add_tags':
// Add / append tags
wp_set_object_terms($pic_id, $taglist, 'ngg_tag', TRUE);
break;
//.........这里部分代码省略.........
示例9: nggallery_manage_gallery_main
function nggallery_manage_gallery_main()
{
global $ngg, $nggdb, $wp_query;
//Build the pagination for more than 25 galleries
$_GET['paged'] = isset($_GET['paged']) && $_GET['paged'] > 0 ? absint($_GET['paged']) : 1;
$items_per_page = apply_filters('ngg_manage_galleries_items_per_page', 25);
$start = ($_GET['paged'] - 1) * $items_per_page;
if (!empty($_GET['order']) && in_array($_GET['order'], array('DESC', 'ASC'))) {
$order = $_GET['order'];
} else {
$order = apply_filters('ngg_manage_galleries_items_order', 'ASC');
}
if (!empty($_GET['orderby']) && in_array($_GET['orderby'], array('gid', 'title', 'author'))) {
$orderby = $_GET['orderby'];
} else {
$orderby = apply_filters('ngg_manage_galleries_items_orderby', 'gid');
}
$mapper = C_Gallery_Mapper::get_instance();
$total_number_of_galleries = $mapper->count();
$gallerylist = $mapper->select()->order_by($orderby, $order)->limit($items_per_page, $start)->run_query();
// Need for upgrading from 2.0.40 to 2.0.52 or later.
// For some reason, the installer doesn't always run.
// TODO: Remove in 2.1
if (!$gallerylist) {
global $wpdb;
if ($wpdb->get_results("SELECT gid FROM {$wpdb->nggallery} LIMIT 1")) {
$installer = new C_NggLegacy_Installer();
$installer->install();
$gallerylist = $mapper->select()->order_by($orderby, $order)->limit($items_per_page, $start)->run_query();
}
}
$wp_list_table = new _NGG_Galleries_List_Table('nggallery-manage-gallery');
?>
<script type="text/javascript">
<!--
// Listen for frame events
jQuery(function($){
if ($(this).data('ready')) return;
if (window.Frame_Event_Publisher) {
// If a new gallery is added, refresh the page
Frame_Event_Publisher.listen_for('attach_to_post:new_gallery attach_to_post:manage_images attach_to_post:images_added',function(){
window.location.href = window.location.href;
});
}
$(this).data('ready', true);
});
function checkAll(form)
{
for (i = 0, n = form.elements.length; i < n; i++) {
if(form.elements[i].type == "checkbox") {
if(form.elements[i].name == "doaction[]") {
if(form.elements[i].checked == true)
form.elements[i].checked = false;
else
form.elements[i].checked = true;
}
}
}
}
function getNumChecked(form)
{
var num = 0;
for (i = 0, n = form.elements.length; i < n; i++) {
if(form.elements[i].type == "checkbox") {
if(form.elements[i].name == "doaction[]")
if(form.elements[i].checked == true)
num++;
}
}
return num;
}
// this function check for a the number of selected images, sumbmit false when no one selected
function checkSelected() {
if (typeof document.activeElement == "undefined" && document.addEventListener) {
document.addEventListener("focus", function (e) {
document.activeElement = e.target;
}, true);
}
if ( document.activeElement.name == 'post_paged' )
return true;
var numchecked = getNumChecked(document.getElementById('editgalleries'));
if(numchecked < 1) {
alert('<?php
echo esc_js(__('No images selected', 'nggallery'));
?>
');
return false;
}
//.........这里部分代码省略.........
示例10: _get_gallery
function _get_gallery($id)
{
$retval = NULL;
if (isset($this->galleries[$id])) {
$retval = $this->galleries[$id];
} else {
$retval = C_Gallery_Mapper::get_instance()->find($id);
}
return $retval;
}
示例11: prepare_legacy_parameters
/**
* Returns the parameter objects necessary for legacy template rendering (legacy_render())
*
* @param $images
* @param $displayed_gallery
* @param array $params
*
* @return array
*/
function prepare_legacy_parameters($images, $displayed_gallery, $params = array())
{
// setup
$image_map = C_Image_Mapper::get_instance();
$gallery_map = C_Gallery_Mapper::get_instance();
$image_key = $image_map->get_primary_key_column();
$gallery_key = $gallery_map->get_primary_key_column();
$gallery_id = $displayed_gallery->id();
$pid = $this->object->param('pid');
// because picture_list implements ArrayAccess any array-specific actions must be taken on
// $picture_list->container or they won't do anything
$picture_list = new C_Image_Wrapper_Collection();
$current_pid = NULL;
// begin processing
$current_page = @get_the_ID() == FALSE ? 0 : @get_the_ID();
// determine what the "current image" is; used mostly for carousel
if (!is_numeric($pid) && !empty($pid)) {
$picture = $image_map->find_first(array('image_slug = %s', $pid));
$pid = $picture->{$image_key};
}
// create our new wrappers
foreach ($images as &$image) {
if ($image && isset($params['effect_code'])) {
if (is_object($image)) {
$image->thumbcode = $params['effect_code'];
} elseif (is_array($image)) {
$image['thumbcode'] = $params['effect_code'];
}
}
$new_image = new C_Image_Wrapper($image, $displayed_gallery);
if ($pid == $new_image->{$image_key}) {
$current_pid = $new_image;
}
$picture_list[] = $new_image;
}
reset($picture_list->container);
// assign current_pid
$current_pid = is_null($current_pid) ? current($picture_list->container) : $current_pid;
foreach ($picture_list as &$image) {
if (isset($image->hidden) && $image->hidden) {
$tmp = $displayed_gallery->display_settings['number_of_columns'];
$image->style = $tmp > 0 ? 'style="width:' . floor(100 / $tmp) . '%;display: none;"' : 'style="display: none;"';
}
}
// find our gallery to build the new one on
$orig_gallery = $gallery_map->find(current($picture_list->container)->galleryid);
// create the 'gallery' object
$gallery = new stdclass();
$gallery->ID = $displayed_gallery->id();
$gallery->name = stripslashes($orig_gallery->name);
$gallery->title = stripslashes($orig_gallery->title);
$gallery->description = html_entity_decode(stripslashes($orig_gallery->galdesc));
$gallery->pageid = $orig_gallery->pageid;
$gallery->anchor = 'ngg-gallery-' . $gallery_id . '-' . $current_page;
$gallery->displayed_gallery =& $displayed_gallery;
$gallery->columns = @intval($displayed_gallery->display_settings['number_of_columns']);
$gallery->imagewidth = $gallery->columns > 0 ? 'style="width:' . floor(100 / $gallery->columns) . '%;"' : '';
if (!empty($displayed_gallery->display_settings['show_slideshow_link'])) {
$gallery->show_slideshow = TRUE;
$gallery->slideshow_link = $params['slideshow_link'];
$gallery->slideshow_link_text = $displayed_gallery->display_settings['slideshow_link_text'];
} else {
$gallery->show_slideshow = FALSE;
}
$gallery = apply_filters('ngg_gallery_object', $gallery, 4);
// build our array of things to return
$return = array('registry' => C_Component_Registry::get_instance(), 'gallery' => $gallery);
// single_image is an internally added flag
if (!empty($params['single_image'])) {
$return['image'] = $picture_list[0];
} else {
$return['current'] = $current_pid;
$return['images'] = $picture_list->container;
}
// this is expected to always exist
if (!empty($params['pagination'])) {
$return['pagination'] = $params['pagination'];
} else {
$return['pagination'] = NULL;
}
if (!empty($params['next'])) {
$return['next'] = $params['next'];
} else {
$return['next'] = FALSE;
}
if (!empty($params['prev'])) {
$return['prev'] = $params['prev'];
} else {
$return['prev'] = FALSE;
}
return $return;
//.........这里部分代码省略.........
示例12: set_gallery_preview
/**
* nggAdmin::set_gallery_preview() - define a preview pic after the first upload, can be changed in the gallery settings
*
* @class nggAdmin
* @param int $galleryID
* @return void
*/
static function set_gallery_preview($galleryID)
{
$gallery_mapper = C_Gallery_Mapper::get_instance();
if ($gallery = $gallery_mapper->find($galleryID)) {
if (!$gallery->previewpic) {
$image_mapper = C_Image_Mapper::get_instance();
if ($image = $image_mapper->select()->where(array('galleryid = %d', $galleryID))->where(array('exclude != 1'))->order_by($image_mapper->get_primary_key_column())->limit(1)->run_query()) {
$gallery->previewpic = $image->{$image->id_field};
$gallery_mapper->save($gallery);
}
}
}
}
示例13: index_action
/**
* 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);
}
}
示例14: widget
function widget($args, $instance)
{
$router = C_Router::get_instance();
wp_enqueue_style('nextgen_widgets_style', $router->get_static_url('photocrati-widget#widgets.css'), FALSE, NGG_SCRIPT_VERSION);
wp_enqueue_style('nextgen_basic_thumbnails_style', $router->get_static_url('photocrati-nextgen_basic_gallery#thumbnails/nextgen_basic_thumbnails.css'), FALSE, NGG_SCRIPT_VERSION);
// these are handled by extract() but I want to silence my IDE warnings that these vars don't exist
$before_widget = NULL;
$before_title = NULL;
$after_widget = NULL;
$after_title = NULL;
$widget_id = NULL;
extract($args);
$title = apply_filters('widget_title', empty($instance['title']) ? ' ' : $instance['title'], $instance, $this->id_base);
$renderer = C_Displayed_Gallery_Renderer::get_instance();
$factory = C_Component_Factory::get_instance();
$view = $factory->create('mvc_view', '');
// IE8 webslice support if needed
if (!empty($instance['webslice'])) {
$before_widget .= '<div class="hslice" id="ngg-webslice">';
$before_title = str_replace('class="', 'class="entry-title ', $before_title);
$after_widget = '</div>' . $after_widget;
}
$source = $instance['type'] == 'random' ? 'random_images' : 'recent';
$template = !empty($instance['template']) ? $instance['template'] : $view->get_template_abspath('photocrati-widget#display_gallery');
$params = array('slug' => 'widget-' . $args['widget_id'], 'source' => $source, 'display_type' => NGG_BASIC_THUMBNAILS, 'images_per_page' => $instance['items'], 'maximum_entity_count' => $instance['items'], 'template' => $template, 'image_type' => $instance['show'] == 'original' ? 'full' : 'thumb', 'show_all_in_lightbox' => FALSE, 'show_slideshow_link' => FALSE, 'show_thumbnail_link' => FALSE, 'use_imagebrowser_effect' => FALSE, 'disable_pagination' => TRUE, 'image_width' => $instance['width'], 'image_height' => $instance['height'], 'ngg_triggers_display' => 'never', 'widget_setting_title' => $title, 'widget_setting_before_widget' => $before_widget, 'widget_setting_before_title' => $before_title, 'widget_setting_after_widget' => $after_widget, 'widget_setting_after_title' => $after_title, 'widget_setting_width' => $instance['width'], 'widget_setting_height' => $instance['height'], 'widget_setting_show_setting' => $instance['show'], 'widget_setting_widget_id' => $widget_id);
switch ($instance['exclude']) {
case 'all':
break;
case 'denied':
$mapper = C_Gallery_Mapper::get_instance();
$gallery_ids = array();
$list = explode(',', $instance['list']);
foreach ($mapper->find_all() as $gallery) {
if (!in_array($gallery->{$gallery->id_field}, $list)) {
$gallery_ids[] = $gallery->{$gallery->id_field};
}
}
$params['container_ids'] = implode(',', $gallery_ids);
break;
case 'allow':
$params['container_ids'] = $instance['list'];
break;
}
echo $renderer->display_images($params);
}
示例15: index_action
function index_action()
{
$factory = C_Component_Factory::get_instance();
$router = C_Router::get_instance();
$gallery_mapper = C_Gallery_Mapper::get_instance();
$lightbox_mapper = $this->object->get_registry()->get_utility('I_Lightbox_Library_Mapper');
// retrieve by transient id
$transient_id = $this->object->param('id');
// ! denotes a non-nextgen gallery -- skip processing them
if ($transient_id !== '!') {
$displayed_gallery = $factory->create('displayed_gallery', array(), $gallery_mapper);
if (!$displayed_gallery->apply_transient($transient_id)) {
$response = array();
// if the transient does not exist we make an HTTP request to the referer to rebuild the transient
if (!empty($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], home_url()) !== FALSE) {
$referrer = $_SERVER['HTTP_REFERER'];
if (strpos($referrer, '?') === FALSE) {
$referrer .= '?ngg_no_resources=1';
} else {
$referrer .= '&ngg_no_resources=1';
}
$response = wp_remote_get($referrer);
}
// WP has cached the results of our last get_transient() calls and must be flushed
global $wp_object_cache;
$wp_object_cache->flush();
// and try again to retrieve the transient
if (!$displayed_gallery->apply_transient($transient_id)) {
$displayed_gallery->id($transient_id);
}
}
$displayed_gallery_id = $displayed_gallery->id();
} else {
$displayed_gallery_id = '!';
}
// TODO: (possibly?) find a better solution, This feels too hackish.
// Remove all currently enqueued CSS & JS. Resources needed by the pro-lightbox incidentally happen
// to be enqueued after this particular code is run anyway.
global $wp_styles;
global $wp_scripts;
$wp_styles->queue = array();
$wp_scripts->queue = array();
// our only necessary script
wp_enqueue_script('galleria', $this->object->get_static_url('photocrati-galleria#galleria-1.2.9.min.js'), array('jquery'), FALSE, FALSE);
wp_enqueue_script('pro-lightbox-galleria-init', $this->object->get_static_url('photocrati-nextgen_pro_lightbox_legacy#galleria_init.js'), array('galleria'), FALSE, FALSE);
if (!wp_style_is('fontawesome', 'registered')) {
C_Display_Type_Controller::get_instance()->enqueue_displayed_gallery_trigger_buttons_resources();
}
wp_enqueue_style('fontawesome');
wp_enqueue_script('velocity', $this->object->get_static_url('photocrati-nextgen_pro_lightbox_legacy#jquery.velocity.min.js'));
// retrieve and add some fields to the lightbox settings
$library = $lightbox_mapper->find_by_name(NGG_PRO_LIGHTBOX, TRUE);
$ls =& $library->display_settings;
$ls['theme'] = $this->object->get_static_url('photocrati-nextgen_pro_lightbox_legacy#theme/galleria.nextgen_pro_lightbox.js');
$ls['load_images_url'] = $router->get_url('/nextgen-pro-lightbox-load-images/' . $transient_id, TRUE, 'root');
$ls['gallery_url'] = $router->get_url('/nextgen-pro-lightbox-gallery/{gallery_id}/', TRUE, 'root');
$ls['share_url'] = $router->get_url('/nextgen-share/{gallery_id}/{image_id}/{named_size}', TRUE, 'root');
$ls['wp_site_url'] = $router->get_base_url();
$ls['image_protect'] = !empty(C_NextGen_Settings::get_instance()->protect_images) ? TRUE : FALSE;
if (!empty($ls['style'])) {
wp_enqueue_style('nextgen_pro_lightbox_user_style', $router->get_static_url('photocrati-nextgen_pro_lightbox_legacy#styles/' . $ls['style']));
}
// this should come after all other enqueue'ings
$settings = C_NextGen_Settings::get_instance();
if ((!is_multisite() || is_multisite() && $settings->wpmuStyle) && $settings->activateCSS) {
wp_enqueue_style('nggallery', C_NextGen_Style_Manager::get_instance()->get_selected_stylesheet_url());
}
// The Pro Lightbox can be extended with components that enqueue their own resources
// and render some markup
$component_markup = array();
foreach ($this->object->_components as $name => $handler) {
$handler = new $handler();
$handler->name = $name;
if (!empty($displayed_gallery)) {
$handler->displayed_gallery = $displayed_gallery;
}
$handler->lightbox_library = $library;
$handler->enqueue_static_resources();
$component_markup[] = $handler->render();
}
$params = array('displayed_gallery_id' => $displayed_gallery_id, 'lightbox_settings' => $library->display_settings, 'component_markup' => implode("\n", $component_markup));
return $this->object->render_view('photocrati-nextgen_pro_lightbox_legacy#index', $params, FALSE);
}