本文整理汇总了PHP中C_Gallery_Storage::get_instance方法的典型用法代码示例。如果您正苦于以下问题:PHP C_Gallery_Storage::get_instance方法的具体用法?PHP C_Gallery_Storage::get_instance怎么用?PHP C_Gallery_Storage::get_instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类C_Gallery_Storage
的用法示例。
在下文中一共展示了C_Gallery_Storage::get_instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_digital_downloads
/**
* Gets all digital downloads for the pricelist
* @param null $image_id
* @return mixed
*/
function get_digital_downloads($image_id = NULL)
{
// Find digital download items
$mapper = C_Pricelist_Item_Mapper::get_instance();
$conditions = array(array("pricelist_id = %d", $this->object->id()), array("source IN %s", array(NGG_PRO_DIGITAL_DOWNLOADS_SOURCE)));
$items = $mapper->select()->where($conditions)->order_by('ID', 'ASC')->run_query();
// Filter by image resolutions
if ($image_id) {
$image = is_object($image_id) ? $image_id : C_Image_Mapper::get_instance()->find($image_id);
if ($image) {
$retval = array();
$storage = C_Gallery_Storage::get_instance();
foreach ($items as $item) {
$source_width = $image->meta_data['width'];
$source_height = $image->meta_data['height'];
// the downloads themselves come from the backup as source so if possible only filter images
// whose backup file doesn't have sufficient dimensions
$backup_abspath = $storage->get_backup_abspath($image);
if (@file_exists($backup_abspath)) {
$dimensions = @getimagesize($backup_abspath);
$source_width = $dimensions[0];
$source_height = $dimensions[1];
}
if (isset($item->resolution) && $item->resolution >= 0 && ($source_height >= $item->resolution or $source_width >= $item->resolution)) {
$retval[] = $item;
}
}
$items = $retval;
}
}
return $items;
}
示例2: protect_gallery
function protect_gallery($gallery, $force = false)
{
$retval = $this->object->is_gallery_protected($gallery);
if ($force || !$retval) {
$storage = C_Gallery_Storage::get_instance();
$gallery_path = $storage->get_gallery_abspath($gallery);
if ($gallery_path != null && file_exists($gallery_path)) {
$protector_files = $this->_get_protector_list();
foreach ($protector_files as $name => $protector) {
$path = $protector['path'];
$full_path = path_join($gallery_path, $path);
$full = null;
if (file_exists($full_path)) {
$full = file_get_contents($full_path);
$result = $this->_find_protector_content($full, $protector);
if ($result != null) {
$full = substr_replace($full, $protector['content'], $result['start'], $result['size']);
}
} else {
$full = $protector['tag-start'] . $protector['content'] . $protector['tag-end'];
}
file_put_contents($full_path, $full);
$retval = true;
}
}
}
return $retval;
}
示例3: add_image
function add_image($image_id, $image_props)
{
// Get the items associated with the image
$items = array();
if (is_array($image_props)) {
unset($image_props['item_ids']);
if (isset($image_props['items'])) {
$items = $image_props['items'];
}
} else {
unset($image_props->item_ids);
if (isset($image_props->items)) {
$items = $image_props->items;
}
}
// Does the image exist?
if ($image = C_Image_Mapper::get_instance()->find($image_id)) {
$storage = C_Gallery_Storage::get_instance();
$image->thumbnail_url = $storage->get_thumbnail_url($image);
$image->dimensions = $storage->get_thumbnail_dimensions($image);
$image->width = $image->dimensions['width'];
$image->height = $image->dimensions['height'];
$this->_state[$image_id] = $image;
foreach ($items as $item_id => $item_props) {
if (is_numeric($item_id)) {
$this->add_item($image_id, $item_id, $item_props);
}
}
}
}
示例4: index_action
function index_action()
{
$this->enqueue_static_resources();
$settings = C_NextGen_Settings::get_instance();
$retval = $settings->proofing_user_confirmation_not_found;
if ($proof = C_NextGen_Pro_Proofing_Mapper::get_instance()->find_by_hash($this->param('proof'), TRUE)) {
$image_mapper = C_Image_Mapper::get_instance();
$images = array();
foreach ($proof->proofed_gallery['image_list'] as $image_id) {
$images[] = $image_mapper->find($image_id);
}
$message = $settings->proofing_user_confirmation_template;
if (preg_match_all('/%%(\\w+)%%/', $settings->proofing_user_confirmation_template, $matches, PREG_SET_ORDER) > 0) {
foreach ($matches as $match) {
switch ($match[1]) {
case 'user_name':
$message = str_replace('%%user_name%%', $proof->customer_name, $message);
break;
case 'user_email':
$message = str_replace('%%user_email%%', $proof->email, $message);
break;
case 'proof_link':
$message = str_replace('%%proof_link%%', $proof->referer, $message);
break;
case 'proof_details':
$imagehtml = $this->object->render_partial('photocrati-nextgen_pro_proofing#confirmation', array('images' => $images, 'storage' => C_Gallery_Storage::get_instance()), TRUE);
$message = str_replace('%%proof_details%%', $imagehtml, $message);
break;
}
}
$retval = $message;
}
}
return $retval;
}
示例5: index_action
function index_action($displayed_gallery, $return = FALSE)
{
// The HTML id of the gallery
$id = 'displayed_gallery_' . $displayed_gallery->id();
$image_size_name = 'full';
$display_settings = $displayed_gallery->display_settings;
if ($display_settings['override_image_settings']) {
$dynthumbs = C_Dynamic_Thumbnails_Manager::get_instance();
$dyn_params = array();
if ($display_settings['image_quality']) {
$dyn_params['quality'] = $display_settings['image_quality'];
}
if ($display_settings['image_crop']) {
$dyn_params['crop'] = true;
}
if ($display_settings['image_watermark']) {
$dyn_params['watermark'] = true;
}
$image_size_name = $dynthumbs->get_size_name($dyn_params);
}
$params = array('images' => $displayed_gallery->get_included_entities(), 'storage' => C_Gallery_Storage::get_instance(), 'effect_code' => $this->object->get_effect_code($displayed_gallery), 'id' => $id, 'image_size_name' => $image_size_name, 'image_display_size' => $displayed_gallery->display_settings['image_display_size'], 'border_size' => $displayed_gallery->display_settings['border_size']);
$params = $this->object->prepare_display_parameters($displayed_gallery, $params);
// Render view/template
return $this->render_view('photocrati-nextgen_pro_blog_gallery#nextgen_pro_blog', $params, $return);
}
示例6: render_displayed_gallery
/**
* Renders a feed for a displayed gallery
*/
public function render_displayed_gallery()
{
$displayed_gallery = NULL;
$mapper = C_Displayed_Gallery_Mapper::get_instance();
$template = $this->object->param('template');
if (!in_array($template, array('mediarss_feed', 'playlist_feed'))) {
$template = 'mediarss_feed';
}
$template = 'photocrati-mediarss#' . $template;
// Find the displayed gallery by it's database id
if ($id = $this->object->param('id')) {
$displayed_gallery = $mapper->find($id, TRUE);
} elseif ($transient_id = $this->object->param('transient_id')) {
// retrieve by transient id
$factory = C_Component_Factory::get_instance();
$displayed_gallery = $factory->create('displayed_gallery', NULL, $mapper);
$displayed_gallery->apply_transient($transient_id);
} elseif ($params = $this->object->param('params')) {
// Create the displayed gallery based on the URL parameters
$factory = C_Component_Factory::get_instance();
$displayed_gallery = $factory->create('displayed_gallery', json_decode($params), $mapper);
}
// Assuming we have a displayed gallery, display it!
if ($displayed_gallery) {
$storage = C_Gallery_Storage::get_instance();
$this->render_view($template, array('storage' => $storage, 'images' => $displayed_gallery->get_included_entities(), 'feed_title' => $this->object->_get_feed_title($displayed_gallery), 'feed_description' => $this->object->_get_feed_description($displayed_gallery), 'feed_link' => $this->object->_get_feed_link($displayed_gallery), 'generator' => $this->object->_get_feed_generator($displayed_gallery), 'copyright' => $this->object->_get_feed_copyright($displayed_gallery)));
} else {
$this->object->http_error('Invalid ID', 404);
}
}
示例7: get_storage
function get_storage()
{
if (!$this->storage) {
$this->storage = C_Gallery_Storage::get_instance();
}
return $this->storage;
}
示例8: 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);
}
}
示例9: index_action
function index_action()
{
wp_dequeue_script('photocrati_ajax');
wp_dequeue_script('frame_event_publisher');
wp_dequeue_script('jquery');
wp_dequeue_style('nextgen_gallery_related_images');
$img_mapper = C_Image_Mapper::get_instance();
$image_id = $this->param('image_id');
if ($image = $img_mapper->find($image_id)) {
$displayed_gallery_id = $this->param('displayed_gallery_id');
// Template parameters
$params = array('img' => $image);
// Get the url & dimensions
$named_size = $this->param('named_size');
$storage = C_Gallery_Storage::get_instance();
$dimensions = $storage->get_image_dimensions($image, $named_size);
$image->url = $storage->get_image_url($image, $named_size, TRUE);
$image->width = $dimensions['width'];
$image->height = $dimensions['height'];
// Generate the lightbox url
$router = $this->get_router();
$lightboxes = C_Lightbox_Library_Manager::get_instance();
$lightbox = $lightboxes->get(NGG_PRO_LIGHTBOX);
$uri = urldecode($this->param('uri'));
$lightbox_slug = $lightbox->values['nplModalSettings']['router_slug'];
$qs = $this->get_querystring();
if ($qs) {
$lightbox_url = $router->get_url('/', FALSE, 'root');
$lightbox_url .= "?" . $qs;
} else {
$lightbox_url = $router->get_url($uri, FALSE, 'root');
$lightbox_url .= '/';
}
// widget galleries shouldn't have a url specific to one image
if (FALSE !== strpos($displayed_gallery_id, 'widget-ngg-images-')) {
$image_id = '!';
}
$params['lightbox_url'] = "{$lightbox_url}#{$lightbox_slug}/{$displayed_gallery_id}/{$image_id}";
// Add the blog name
$params['blog_name'] = get_bloginfo('name');
if ($lightbox->values['nplModalSettings']['enable_twitter_cards']) {
$params['enable_twitter_cards'] = $lightbox->values['nplModalSettings']['enable_twitter_cards'];
$params['twitter_username'] = $lightbox->values['nplModalSettings']['twitter_username'];
}
// Add routed url
$protocol = $router->is_https() ? 'https://' : 'http://';
$params['routed_url'] = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
// Render the opengraph metadata
$this->expires('+1 day');
$this->render_view("photocrati-nextgen_pro_lightbox#opengraph", $params);
} else {
header(__('Status: 404 Image not found', 'nextgen-gallery-pro'));
echo __('Image not found', 'nextgen-gallery-pro');
}
}
示例10: 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}`)");
}
示例11: get_image_file_action
/**
* Read an image file into memory and display it
*
* This is necessary for htaccess or server-side protection that blocks access to filenames ending with "_backup"
* At the moment it only supports the backup or full size image.
*/
function get_image_file_action()
{
$order_id = $this->param('order_id', FALSE);
$image_id = $this->param('image_id', FALSE);
$bail = FALSE;
if (!$order_id || !$image_id) {
$bail = TRUE;
}
$order = C_Order_Mapper::get_instance()->find_by_hash($order_id);
if (!in_array($image_id, $order->cart['image_ids'])) {
$bail = TRUE;
}
if ($order->status != 'verified') {
$bail = TRUE;
}
if ($bail) {
header('HTTP/1.1 404 Not found');
exit;
}
$storage = C_Gallery_Storage::get_instance();
if (version_compare(NGG_PLUGIN_VERSION, '2.0.66.99') <= 0) {
// Pre 2.0.67 didn't fallback to the original path if the backup file didn't exist
$imagemapper = C_Image_Mapper::get_instance();
$fs = C_Fs::get_instance();
$image = $imagemapper->find($image_id);
$gallery_path = $storage->get_gallery_abspath($image->galleryid);
$abspath = $fs->join_paths($gallery_path, $image->filename . '_backup');
if (!@file_exists($abspath)) {
$abspath = $storage->get_image_abspath($image_id, 'full');
}
} else {
$abspath = $storage->get_image_abspath($image_id, 'backup');
}
$mimetype = 'application/octet';
if (function_exists('finfo_buffer')) {
$finfo = new finfo(FILEINFO_MIME);
$mimetype = @$finfo->file($abspath);
} elseif (function_exists('mime_content_type')) {
$mimetype = @mime_content_type($abspath);
}
header('Content-Description: File Transfer');
header('Content-Disposition: attachment; filename=' . basename($storage->get_image_abspath($image_id, 'full')));
header("Content-type: " . $mimetype);
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . @filesize($abspath));
readfile($abspath);
exit;
}
示例12: 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;
}
}
}
}
示例13: index_action
function index_action($displayed_gallery, $return = FALSE)
{
$id = $displayed_gallery->id();
$display_settings = $displayed_gallery->display_settings;
$current_page = (int) $this->param('nggpage', $displayed_gallery->id(), 1);
if (!isset($display_settings['images_per_page'])) {
$display_settings['images_per_page'] = C_NextGen_Settings::get_instance()->images_per_page;
}
$offset = $display_settings['images_per_page'] * ($current_page - 1);
$total = $displayed_gallery->get_entity_count();
$images = $displayed_gallery->get_included_entities($display_settings['images_per_page'], $offset);
if (in_array($displayed_gallery->source, array('random', 'recent'))) {
$display_settings['disable_pagination'] = TRUE;
}
if ($images) {
if ($display_settings['images_per_page'] && !$display_settings['disable_pagination']) {
$pagination_result = $this->object->create_pagination($current_page, $total, $display_settings['images_per_page']);
}
}
$pagination = !empty($pagination_result['output']) ? $pagination_result['output'] : NULL;
// Get named size of thumbnail images
$thumbnail_size_name = 'thumbnail';
if ($display_settings['override_thumbnail_settings']) {
$dynthumbs = C_Dynamic_Thumbnails_Manager::get_instance();
$dyn_params = array('width' => $display_settings['thumbnail_width'], 'height' => $display_settings['thumbnail_height']);
if ($display_settings['thumbnail_quality']) {
$dyn_params['quality'] = $display_settings['thumbnail_quality'];
}
if ($display_settings['thumbnail_crop']) {
$dyn_params['crop'] = true;
}
if ($display_settings['thumbnail_watermark']) {
$dyn_params['watermark'] = true;
}
$thumbnail_size_name = $dynthumbs->get_size_name($dyn_params);
}
// Calculate image statistics
$stats = $this->object->get_entity_statistics($images, $thumbnail_size_name, TRUE);
$images = $stats['entities'];
$display_settings['longest'] = $stats['longest'];
$display_settings['widest'] = $stats['widest'];
// Enqueue dynamic stylesheet
$dyn_styles = C_Dynamic_Stylesheet_Controller::get_instance('all');
$dyn_styles->enqueue('nextgen_pro_film', $this->array_merge_assoc($display_settings, array('id' => $id)));
$params = array('images' => $images, 'storage' => C_Gallery_Storage::get_instance(), 'thumbnail_size_name' => $thumbnail_size_name, 'effect_code' => $this->object->get_effect_code($displayed_gallery), 'id' => $id, 'pagination' => $pagination);
$params = $this->object->prepare_display_parameters($displayed_gallery, $params);
// Render view/template
return preg_replace('~>\\s*\\n\\s*<~', '><', $this->render_view('photocrati-nextgen_pro_film#nextgen_pro_film', $params, $return));
}
示例14: index_action
function index_action($displayed_gallery, $return = FALSE)
{
$storage = C_Gallery_Storage::get_instance();
$list = $displayed_gallery->get_included_entities();
$thumbnail_size_name = 'thumbnail';
$ds = $displayed_gallery->display_settings;
if (!empty($ds['override_thumbnail_settings']) && $ds['override_thumbnail_settings']) {
$dynthumbs = C_Dynamic_Thumbnails_Manager::get_instance();
$dyn_params = array('width' => $ds['thumbnail_width'], 'height' => $ds['thumbnail_height'], 'crop' => true);
$thumbnail_size_name = $dynthumbs->get_size_name($dyn_params);
}
$params = array('images' => $list, 'displayed_gallery_id' => $displayed_gallery->id(), 'storage' => $storage, 'custom_css_rules' => $this->object->get_custom_css_rules($displayed_gallery), 'thumbnail_size_name' => $thumbnail_size_name);
$params = $this->object->prepare_display_parameters($displayed_gallery, $params);
return $this->object->render_view('photocrati-galleria#galleria', $params, $return);
}
示例15: index_action
/**
* Renders the front-end display for the masonry display type
*
* @param C_Displayed_Gallery $displayed_gallery
* @param bool $return
* @return string
*/
function index_action($displayed_gallery, $return = FALSE)
{
$images = $displayed_gallery->get_included_entities();
if (!$images) {
return $this->object->render_partial("photocrati-nextgen_gallery_display#no_images_found", array(), $return);
} else {
$params = $displayed_gallery->display_settings;
$params['images'] = $images;
$params['storage'] = C_Gallery_Storage::get_instance();
$params['effect_code'] = $this->object->get_effect_code($displayed_gallery);
$params['displayed_gallery_id'] = $displayed_gallery->id();
$params['thumbnail_size_name'] = C_Dynamic_Thumbnails_Manager::get_instance()->get_size_name(array('width' => $params['size'], 'crop' => FALSE));
$params = $this->object->prepare_display_parameters($displayed_gallery, $params);
return $this->object->render_view('photocrati-nextgen_pro_masonry#index', $params, $return);
}
}
开发者ID:CodeNoEvil,项目名称:mbp_web_infrastructure,代码行数:23,代码来源:adapter.nextgen_pro_masonry_controller.php