当前位置: 首页>>代码示例>>PHP>>正文


PHP C_Gallery_Mapper类代码示例

本文整理汇总了PHP中C_Gallery_Mapper的典型用法代码示例。如果您正苦于以下问题:PHP C_Gallery_Mapper类的具体用法?PHP C_Gallery_Mapper怎么用?PHP C_Gallery_Mapper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了C_Gallery_Mapper类的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;
 }
开发者ID:tleonard2,项目名称:durablegbFeb,代码行数:29,代码来源:package.module.attach_to_post.php

示例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);
     }
 }
开发者ID:radscheit,项目名称:unicorn,代码行数:14,代码来源:package.module.cache.php

示例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}`)");
 }
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:17,代码来源:package.module.cache.php

示例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;
             }
         }
     }
 }
开发者ID:igitur,项目名称:NextGen-Public-Uploader,代码行数:50,代码来源:class.npu_uploader.php

示例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;
 }
开发者ID:CodeNoEvil,项目名称:mbp_web_infrastructure,代码行数:16,代码来源:mixin.nextgen_pro_album_controller.php

示例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']}");
     }
 }
开发者ID:radscheit,项目名称:unicorn,代码行数:26,代码来源:module.wpcli.php

示例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 '';
 }
开发者ID:albinmartinsson91,项目名称:ux_blog,代码行数:27,代码来源:sitemap.php

示例8: post_processor_images


//.........这里部分代码省略.........
         }
     }
     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;
                     case 'delete_tags':
                         // Delete tags
                         $oldtags = wp_get_object_terms($pic_id, 'ngg_tag', 'fields=names');
                         // get the slugs, to vaoid  case sensitive problems
                         $slugarray = array_map('sanitize_title', $taglist);
                         $oldtags = array_map('sanitize_title', $oldtags);
                         // compare them and return the diff
                         $newtags = array_diff($oldtags, $slugarray);
                         wp_set_object_terms($pic_id, $newtags, 'ngg_tag');
                         break;
                 }
             }
             nggGallery::show_message(__('Tags changed', 'nggallery'));
         }
     }
     if (isset($_POST['updatepictures'])) {
         // Update pictures
         check_admin_referer('ngg_updategallery');
         if (nggGallery::current_user_can('NextGEN Edit gallery options') && !isset($_GET['s'])) {
             $tags = array('<a>', '<abbr>', '<acronym>', '<address>', '<b>', '<base>', '<basefont>', '<big>', '<blockquote>', '<br>', '<br/>', '<caption>', '<center>', '<cite>', '<code>', '<col>', '<colgroup>', '<dd>', '<del>', '<dfn>', '<dir>', '<div>', '<dl>', '<dt>', '<em>', '<fieldset>', '<font>', '<h1>', '<h2>', '<h3>', '<h4>', '<h5>', '<h6>', '<hr>', '<i>', '<ins>', '<label>', '<legend>', '<li>', '<menu>', '<noframes>', '<noscript>', '<ol>', '<optgroup>', '<option>', '<p>', '<pre>', '<q>', '<s>', '<samp>', '<select>', '<small>', '<span>', '<strike>', '<strong>', '<sub>', '<sup>', '<table>', '<tbody>', '<td>', '<tfoot>', '<th>', '<thead>', '<tr>', '<tt>', '<u>', '<ul>');
             $fields = array('title', 'galdesc');
             // Sanitize fields
             foreach ($fields as $field) {
                 $html = $_POST[$field];
                 $html = preg_replace('/\\s+on\\w+=(["\']).*?\\1/i', '', $html);
                 $html = preg_replace('/(<\\/[^>]+?>)(<[^>\\/][^>]*?>)/', '$1 $2', $html);
                 $html = strip_tags($html, implode('', $tags));
                 $_POST[$field] = $html;
             }
             // Update the gallery
             $mapper = C_Gallery_Mapper::get_instance();
             if ($entity = $mapper->find($this->gid)) {
                 foreach ($_POST as $key => $value) {
                     $entity->{$key} = $value;
                 }
                 $mapper->save($entity);
             }
             wp_cache_delete($this->gid, 'ngg_gallery');
         }
         $this->update_pictures();
         //hook for other plugin to update the fields
         do_action('ngg_update_gallery', $this->gid, $_POST);
         nggGallery::show_message(__('Update successful', 'nggallery'));
     }
     if (isset($_POST['scanfolder'])) {
         // Rescan folder
         check_admin_referer('ngg_updategallery');
         $gallerypath = $wpdb->get_var("SELECT path FROM {$wpdb->nggallery} WHERE gid = '{$this->gid}' ");
         nggAdmin::import_gallery($gallerypath, $this->gid);
     }
     // Add a new page
     if (isset($_POST['addnewpage'])) {
         check_admin_referer('ngg_updategallery');
         $parent_id = esc_attr($_POST['parent_id']);
         $gallery_title = esc_attr($_POST['title']);
         $mapper = C_Gallery_Mapper::get_instance();
         $gallery = $mapper->find($this->gid);
         $gallery_name = $gallery->name;
         // Create a WP page
         global $user_ID;
         $page['post_type'] = 'page';
         $page['post_content'] = apply_filters('ngg_add_page_shortcode', '[nggallery id="' . $this->gid . '"]');
         $page['post_parent'] = $parent_id;
         $page['post_author'] = $user_ID;
         $page['post_status'] = 'publish';
         $page['post_title'] = $gallery_title == '' ? $gallery_name : $gallery_title;
         $page = apply_filters('ngg_add_new_page', $page, $this->gid);
         $gallery_pageid = wp_insert_post($page);
         if ($gallery_pageid != 0) {
             $gallery->pageid = $gallery_pageid;
             $mapper->save($gallery);
             nggGallery::show_message(__('New gallery page ID', 'nggallery') . ' ' . $gallery_pageid . ' -> <strong>' . $gallery_title . '</strong> ' . __('created', 'nggallery'));
         }
         do_action('ngg_gallery_addnewpage', $this->gid);
     }
 }
开发者ID:vadia007,项目名称:frg,代码行数:101,代码来源:manage.php

示例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;
		}
//.........这里部分代码省略.........
开发者ID:albinmartinsson91,项目名称:ux_blog,代码行数:101,代码来源:manage-galleries.php

示例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;
 }
开发者ID:kixortillan,项目名称:dfosashworks,代码行数:10,代码来源:album.php

示例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;
//.........这里部分代码省略.........
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:101,代码来源:package.module.nextgen_basic_templates.php

示例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);
             }
         }
     }
 }
开发者ID:kixortillan,项目名称:dfosashworks,代码行数:20,代码来源:functions.php

示例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);
     }
 }
开发者ID:simeont9,项目名称:stoneopen,代码行数:91,代码来源:package.module.nextgen_basic_album.php

示例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']) ? '&nbsp;' : $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);
 }
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:45,代码来源:package.module.widget.php

示例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);
 }
开发者ID:CodeNoEvil,项目名称:mbp_web_infrastructure,代码行数:83,代码来源:class.nextgen_pro_lightbox_controller.php


注:本文中的C_Gallery_Mapper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。