function generate_image_size($image, $named_size, $params = NULL, $skip_defaults = FALSE)
 {
     $retval = $this->call_parent('generate_image_size', $image, $named_size, $params, $skip_defaults);
     // TODO: NGG should flush the displayed gallery cache after a user regenerates thumbnails
     // As of 2.0.78.5, it doesn't do this
     if (version_compare(NGG_PLUGIN_VERSION, '2.0.78.5', '<=')) {
         C_Photocrati_Cache::flush('displayed_gallery_rendering');
     }
     // TODO: This will generate a Retina-version of any other image created,
     // some of which don't need retina versions such as the IGW preview image
     // used in a post.
     //
     // We need to modify NGG so that parameters for dynamic images are stored in the database.
     // That way we could do a call like this:
     /*
     if ($retval) {
     	$params = $this->object->get_image_size_params($image, $named_size);
     	if (!isset($params['no_retina'])) $this->call_parent('generate_image_size', $image, M_NextGen_PictureFill::get_retina_named_size($image, $named_size));
     }
     */
     if ($retval) {
         $this->call_parent('generate_image_size', $image, M_NextGen_PictureFill::get_retina_named_size($image, $named_size));
     }
     return $retval;
 }
 static function update($reset = FALSE)
 {
     $global_settings = C_NextGen_Global_Settings::get_instance();
     $local_settings = C_NextGen_Settings::get_instance();
     $last_module_list = $reset ? array() : $global_settings->get('pope_module_list', array());
     $current_module_list = self::_generate_module_info();
     if (count($modules = array_diff($current_module_list, $last_module_list)) > 0) {
         // The cache should be flushed
         C_Photocrati_Cache::flush();
         // Delete auto-update cache
         update_option('photocrati_auto_update_admin_update_list', null);
         update_option('photocrati_auto_update_admin_check_date', '');
         foreach ($modules as $module_name) {
             if ($handler = self::get_handler_instance(array_shift(explode('|', $module_name)))) {
                 if (method_exists($handler, 'install')) {
                     $handler->install($reset);
                 }
             }
         }
         // Update the module list
         $global_settings->set('pope_module_list', $current_module_list);
         // Save any changes settings
         $global_settings->save();
         $local_settings->save();
     }
 }
예제 #3
0
 function reset_action()
 {
     global $wpdb;
     // Flush the cache
     C_Photocrati_Cache::flush('all');
     // Uninstall the plugin
     $settings = C_NextGen_Settings::get_instance();
     if (defined('NGG_PRO_PLUGIN_VERSION') || defined('NEXTGEN_GALLERY_PRO_VERSION')) {
         C_Photocrati_Installer::uninstall('photocrati-nextgen-pro');
     }
     C_Photocrati_Installer::uninstall('photocrati-nextgen');
     // removes all ngg_options entry in wp_options
     $settings->reset();
     $settings->destroy();
     // clear NextGEN's capabilities from the roles system
     $capabilities = array("NextGEN Gallery overview", "NextGEN Use TinyMCE", "NextGEN Upload images", "NextGEN Manage gallery", "NextGEN Manage others gallery", "NextGEN Manage tags", "NextGEN Edit album", "NextGEN Change style", "NextGEN Change options", "NextGEN Attach Interface");
     $roles = array("subscriber", "contributor", "author", "editor", "administrator");
     foreach ($roles as $role) {
         $role = get_role($role);
         foreach ($capabilities as $capability) {
             $role->remove_cap($capability);
         }
     }
     // Some installations of NextGen that upgraded from 1.9x to 2.0x have duplicates installed,
     // so for now (as of 2.0.21) we explicitly remove all display types and lightboxes from the
     // db as a way of fixing this.
     $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->posts} WHERE post_type = %s", 'display_type'));
     $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->posts} WHERE post_type = %s", 'lightbox_library'));
     // the installation will run on the next page load; so make our own request before reloading the browser
     wp_remote_get(admin_url('plugins.php'), array('timeout' => 180, 'blocking' => true, 'sslverify' => false));
     header('Location: ' . $_SERVER['REQUEST_URI']);
     throw new E_Clean_Exit();
 }
예제 #4
0
 function _load_non_pope()
 {
     // Load WordPress pluggables for plugin compatibility
     include_once path_join(ABSPATH, 'wp-includes/pluggable.php');
     // Load caching component
     include_once 'non_pope/class.photocrati_cache.php';
     C_Photocrati_Cache::$enabled = TRUE;
     if (isset($_REQUEST['ngg_flush'])) {
         C_Photocrati_Cache::flush('all');
         $_SERVER['QUERY_STRING'] = str_replace('ngg_flush=1', '', $_SERVER['QUERY_STRING']);
     } elseif (isset($_REQUEST['ngg_force_update'])) {
         C_Photocrati_Cache::$do_not_lookup = TRUE;
         C_Photocrati_Cache::$force_update = TRUE;
         $_SERVER['QUERY_STRING'] = str_replace('ngg_force_update=1', '', $_SERVER['QUERY_STRING']);
     }
     // Load Settings Manager
     include_once 'non_pope/class.photocrati_settings_manager.php';
     include_once 'non_pope/class.nextgen_settings.php';
     C_Photocrati_Global_Settings_Manager::$option_name = $this->_settings_option_name;
     C_Photocrati_Settings_Manager::$option_name = $this->_settings_option_name;
     // Load the installer
     include_once 'non_pope/class.photocrati_installer.php';
     // Load the resource manager
     include_once 'non_pope/class.photocrati_resource_manager.php';
     C_Photocrati_Resource_Manager::init();
     // Load the style manager
     include_once 'non_pope/class.nextgen_style_manager.php';
     // Load the shortcode manager
     include_once 'non_pope/class.nextgen_shortcode_manager.php';
 }
 function index_action()
 {
     $key = C_Photocrati_Cache::generate_key('nextgen_pro_upgrade_page');
     if ($html = C_Photocrati_Cache::get('nextgen_pro_upgrade_page', FALSE)) {
         echo $html;
     } else {
         // Get page content
         $template = 'photocrati-nextgen_pro_upgrade#plus';
         if (defined('NGG_PLUS_PLUGIN_BASENAME')) {
             $template = 'photocrati-nextgen_pro_upgrade#pro';
         }
         $description = 'Extend NextGEN Gallery with 8 new pro gallery displays, a full screen responsive pro lightbox, commenting / social sharing / deep linking for individual images, ecommerce, digital downloads, and pro email support.';
         $headline = 'Upgrade to NextGEN Plus or NextGEN Pro';
         if (defined('NGG_PLUS_PLUGIN_BASENAME')) {
             $description = 'NextGEN Pro now offers ecommerce! Extend NextGEN Gallery and NextGEN Plus with a complete solution for selling prints and digital downloads, including unlimited pricelists, PayPal and Stripe integration, and more.';
             $headline = 'Upgrade to NextGEN Pro with Ecommerce';
         }
         $params = array('description' => $description, 'headline' => $headline);
         $html = $this->render_view($template, $params, TRUE);
         // Cache it
         C_Photocrati_Cache::set($key, $html);
         // Render it
         echo $html;
     }
 }
 function _save_entity($entity)
 {
     $retval = $this->call_parent('_save_entity', $entity);
     if ($retval) {
         C_Photocrati_Cache::flush();
     }
     return $retval;
 }
예제 #7
0
 function _save_entity($entity)
 {
     $retval = $this->call_parent('_save_entity', $entity);
     if ($retval) {
         C_Photocrati_Cache::flush('displayed_gallery_rendering');
     }
     return $retval;
 }
 function _save_entity($entity)
 {
     // If successfully saved, then import metadata and
     $retval = $this->call_parent('_save_entity', $entity);
     if ($retval) {
         include_once NGGALLERY_ABSPATH . '/admin/functions.php';
         $image_id = $this->get_id($entity);
         nggAdmin::import_MetaData($image_id);
         C_Photocrati_Cache::flush();
     }
     return $retval;
 }
 function display_tab_js_action()
 {
     $url = C_Router::get_instance()->get_routed_app()->get_routed_url(TRUE);
     $key = C_Photocrati_Cache::generate_key($url);
     // Try fetching the contents from the cache
     if ($html = C_Photocrati_Cache::get($key, FALSE)) {
         echo $html;
     } else {
         $html = C_Attach_Controller::get_instance(FALSE)->display_tab_js_action(TRUE);
         C_Photocrati_Cache::set($key, $html);
         echo $html;
     }
 }
예제 #10
0
 function _save_entity($entity)
 {
     // If successfully saved, then import metadata and
     $retval = $this->call_parent('_save_entity', $entity);
     if ($retval) {
         include_once NGGALLERY_ABSPATH . '/admin/functions.php';
         $image_id = $this->get_id($entity);
         if (!isset($entity->meta_data['saved'])) {
             nggAdmin::import_MetaData($image_id);
         }
         C_Photocrati_Cache::flush('displayed_gallery_rendering');
     }
     return $retval;
 }
 function index_action()
 {
     $key = C_Photocrati_Cache::generate_key('nextgen_pro_upgrade_page');
     if ($html = C_Photocrati_Cache::get('nextgen_pro_upgrade_page', FALSE)) {
         echo $html;
     } else {
         // Get page content
         $params = array('btn_url' => $this->object->get_router()->get_static_url('photocrati-nextgen_pro_upgrade#button.png'), 'img_url' => $this->object->get_router()->get_static_url('photocrati-nextgen_pro_upgrade#proupgrade.gif'));
         $html = $this->render_view('photocrati-nextgen_pro_upgrade#index', $params, TRUE);
         // Cache it
         C_Photocrati_Cache::set($key, $html);
         // Render it
         echo $html;
     }
 }
 function save_action()
 {
     if ($settings = $this->object->param('misc_settings')) {
         // The Media RSS setting is actually a local setting, not a global one
         $local_settings = C_NextGen_Settings::get_instance();
         $local_settings->set('useMediaRSS', $settings['useMediaRSS']);
         unset($settings['useMediaRSS']);
         // If the router slug has changed, then flush the cache
         if ($settings['router_param_slug'] != $this->object->get_model()->router_param_slug) {
             C_Photocrati_Cache::flush();
         }
         // Save both setting groups
         $this->object->get_model()->set($settings)->save();
         $local_settings->save();
     }
 }
예제 #13
0
 function reset_action()
 {
     global $wpdb;
     // Flush the cache
     C_Photocrati_Cache::flush('all');
     // Uninstall the plugin
     $settings = C_NextGen_Settings::get_instance();
     if (defined('NGG_PRO_PLUGIN_VERSION') || defined('NEXTGEN_GALLERY_PRO_VERSION')) {
         C_Photocrati_Installer::uninstall('photocrati-nextgen-pro');
     }
     C_Photocrati_Installer::uninstall('photocrati-nextgen');
     // removes all ngg_options entry in wp_options
     $settings->reset();
     $settings->destroy();
     // Some installations of NextGen that upgraded from 1.9x to 2.0x have duplicates installed,
     // so for now (as of 2.0.21) we explicitly remove all display types and lightboxes from the
     // db as a way of fixing this.
     $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->posts} WHERE post_type = %s", 'display_type'));
     $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->posts} WHERE post_type = %s", 'lightbox_library'));
     // the installation will run on the next page load; so make our own request before reloading the browser
     wp_remote_get(admin_url('plugins.php'), array('timeout' => 180, 'blocking' => true, 'sslverify' => false));
     header('Location: ' . $_SERVER['REQUEST_URI']);
     throw new E_Clean_Exit();
 }
 /**
  * Applies the values of a transient to this object
  * @param string $transient_id
  */
 function apply_transient($transient_id)
 {
     if ($transient = C_Photocrati_Cache::get($transient_id, 'displayed_galleries')) {
         $this->object->_stdObject = $transient;
     }
 }
 public static function flush()
 {
     $cache = C_Photocrati_Cache::get_instance(self::$group_name);
     $cache->flush(self::$group_name);
 }
 static function update($reset = FALSE)
 {
     $local_settings = C_NextGen_Settings::get_instance();
     $global_settings = C_NextGen_Global_Settings::get_instance();
     // This is a specific hack/work-around/fix and can probably be removed sometime after 2.0.20's release
     //
     // NextGen 2x was not multisite compatible until 2.0.18. Users that upgraded before this
     // will have nearly all of their settings stored globally (network wide) in wp_sitemeta. If
     // pope_module_list (which should always be a local setting) exists site-wide we wipe the current
     // global ngg_options and restore from defaults. This should only ever run once.
     if (is_multisite() && isset($global_settings->pope_module_list)) {
         // Setting this to TRUE will wipe current settings for display types, but also
         // allows the display type installer to run correctly
         $reset = TRUE;
         $settings_installer = new C_NextGen_Settings_Installer();
         $global_defaults = $settings_installer->get_global_defaults();
         // Preserve the network options we honor by restoring them after calling $global_settings->reset()
         $global_settings_to_keep = array();
         foreach ($global_defaults as $key => $val) {
             $global_settings_to_keep[$key] = $global_settings->{$key};
         }
         // Resets internal options to an empty array
         $global_settings->reset();
         // Restore the defaults, then our saved values. This must be done again later because
         // we've set $reset to TRUE.
         $settings_installer->install_global_settings();
         foreach ($global_settings_to_keep as $key => $val) {
             $global_settings->{$key} = $val;
         }
     }
     // Get last module list and current module list. Compare...
     $last_module_list = self::_get_last_module_list($reset);
     $current_module_list = self::_generate_module_info();
     $diff = array_diff($current_module_list, $last_module_list);
     $do_upgrade = count($diff) > 0 || count($last_module_list) != count($current_module_list);
     $can_upgrade = $do_upgrade ? self::can_do_upgrade() : FALSE;
     if ($can_upgrade && !$diff) {
         $diff = $current_module_list;
     }
     if ($can_upgrade) {
         // Clear APC cache
         if (function_exists('apc_clear_cache')) {
             @apc_clear_cache('opcode');
             apc_clear_cache();
         }
         // The cache should be flushed
         C_Photocrati_Cache::flush();
         C_Photocrati_Cache::flush('all');
         if (class_exists('C_Pope_Cache')) {
             C_Pope_Cache::get_instance()->flush();
         }
         // Remove all NGG created cron jobs
         self::refresh_cron();
         // Delete auto-update cache
         update_option('photocrati_auto_update_admin_update_list', null);
         update_option('photocrati_auto_update_admin_check_date', '');
         // Other Pope applications might be loaded, and therefore
         // all singletons should be destroyed, so that they can be
         // adapted as necessary. For now, we'll just assume that the factory
         // is the only singleton that will be used by other Pope applications
         C_Component_Factory::$_instances = array();
         foreach ($diff as $module_name) {
             if ($handler = self::get_handler_instance(array_shift(explode('|', $module_name)))) {
                 if (method_exists($handler, 'install')) {
                     $handler->install($reset);
                 }
             }
         }
         // NOTE & TODO: if the above section that declares $global_settings_to_keep is removed this should also
         // Since a hard-reset of the settings was forced we must again re-apply our previously saved values
         if (isset($global_settings_to_keep)) {
             foreach ($global_settings_to_keep as $key => $val) {
                 $global_settings->{$key} = $val;
             }
         }
         // Save any changes settings
         $global_settings->save();
         $local_settings->save();
     }
     // Another workaround to an issue caused by NextGen's lack of multisite compatibility. It's possible
     // the string substitation wasn't performed, so if a '%' symbol exists in gallerypath we reset it. It's
     // another db call, but again this should only ever run once.
     //
     // Remove this when removing the above reset-global-settings code
     if (strpos($local_settings->gallerypath, '%')) {
         $settings_installer = new C_NextGen_Settings_Installer();
         $local_settings->gallerypath = $settings_installer->gallerypath_replace($global_settings->gallerypath);
         $local_settings->save();
     }
     // Update the module list, and remove the update flag
     if ($can_upgrade) {
         update_option('pope_module_list', $current_module_list);
         self::done_upgrade();
     }
 }
 function destroy($image)
 {
     $retval = $this->call_parent('destroy', $image);
     C_Photocrati_Cache::flush();
     return $retval;
 }
 /**
  * Uninstalls this module
  */
 function uninstall($hard = FALSE)
 {
     // Flush displayed gallery cache
     C_Photocrati_Cache::flush();
     C_Photocrati_Cache::flush('displayed_galleries');
     C_Photocrati_Cache::flush('displayed_gallery_rendering');
     $this->uninstall_display_types();
     $this->uninstall_displayed_gallery_sources();
     // TODO temporary Don't remove galleries on uninstall
     //if ($hard) $this->uninstall_displayed_galleries();
 }
예제 #19
0
 function destroy($image)
 {
     $retval = $this->call_parent('destroy', $image);
     C_Photocrati_Cache::flush('displayed_gallery_rendering');
     return $retval;
 }
예제 #20
0
파일: nggallery.php 프로젝트: JeffreyBue/jb
 /**
  * Flush all expires transients created by the plugin
  */
 function delete_expired_transients()
 {
     C_Photocrati_Cache::flush('displayed_galleries', TRUE);
 }
예제 #21
0
 /**
  * Flushes POPE code cache
  */
 function flush_pope_cache($args, $assoc_args)
 {
     C_Photocrati_Cache::flush('all', TRUE);
     WP_CLI::success('Flushed all expired items from the cache');
 }
예제 #22
0
 /**
  * Applies the values of a transient to this object
  * @param string $transient_id
  */
 function apply_transient($transient_id = NULL)
 {
     $retval = FALSE;
     if (!$transient_id && isset($this->object->transient_id)) {
         $transient_id = $this->object->transient_id;
     }
     if ($transient_id && ($transient = C_Photocrati_Cache::get($transient_id, FALSE, 'displayed_galleries'))) {
         $this->object->_stdObject = $transient;
         $this->object->transient_id = $transient_id;
         if (!$this->object->id()) {
             $this->object->id($transient_id);
         }
         $retval = TRUE;
     }
     return $retval;
 }
예제 #23
0
 /**
  * Applies the values of a transient to this object
  * @param string $transient_id
  */
 function apply_transient($transient_id)
 {
     $retval = FALSE;
     if ($transient = C_Photocrati_Cache::get($transient_id, FALSE, 'displayed_galleries')) {
         $this->object->_stdObject = $transient;
         $retval = TRUE;
     }
     return $retval;
 }
예제 #24
0
 /**
  * Flush all expires transients created by the plugin
  */
 function delete_expired_transients()
 {
     C_Photocrati_Cache::flush('all', TRUE);
 }
 /**
  * Renders a displayed gallery on the frontend
  * @param C_Displayed_Gallery|stdClass $displayed_gallery
  */
 function render($displayed_gallery, $return = FALSE, $mode = null)
 {
     $retval = '';
     $lookup = TRUE;
     $cache = C_Photocrati_Cache::get_instance('displayed_gallery_rendering');
     // Simply throwing our rendered gallery into a feed will most likely not work correctly.
     // The MediaRSS option in NextGEN is available as an alternative.
     if (!C_NextGen_Settings::get_instance()->galleries_in_feeds && is_feed()) {
         return '';
     }
     if ($mode == null) {
         $mode = 'normal';
     }
     // Save the displayed gallery as a transient if it hasn't already. Allows for ajax operations
     // to add or modify the gallery without losing a retrievable ID
     if (!$displayed_gallery->apply_transient()) {
         $displayed_gallery->to_transient();
     }
     // Get the display type controller
     $controller = $this->get_registry()->get_utility('I_Display_Type_Controller', $displayed_gallery->display_type);
     // Get routing info
     $router = $url = C_Router::get_instance();
     $url = $router->get_url($router->get_request_uri(), TRUE);
     // Should we lookup in cache?
     if (is_array($displayed_gallery->container_ids) && in_array('All', $displayed_gallery->container_ids)) {
         $lookup = FALSE;
     } elseif ($displayed_gallery->source == 'albums' && $controller->param('gallery') or $controller->param('album')) {
         $lookup = FALSE;
     } elseif ($controller->param('show')) {
         $lookup = FALSE;
     } elseif ($controller->cachable === FALSE) {
         $lookup = FALSE;
     }
     // Enqueue any necessary static resources
     if (!defined('NGG_SKIP_LOAD_SCRIPTS') || !NGG_SKIP_LOAD_SCRIPTS) {
         $controller->enqueue_frontend_resources($displayed_gallery);
     }
     // Try cache lookup, if we're to do so
     $key = null;
     $html = FALSE;
     if ($lookup) {
         // The display type may need to output some things
         // even when serving from the cache
         if ($controller->has_method('cache_action')) {
             $retval = $controller->cache_action($displayed_gallery);
         }
         // Output debug message
         $retval .= $this->debug_msg("Lookup!");
         // Some settings affect display types
         $settings = C_NextGen_Settings::get_instance();
         $key_params = apply_filters('ngg_displayed_gallery_cache_params', array($displayed_gallery->get_entity(), $url, $mode, $settings->activateTags, $settings->appendType, $settings->maxImages, $settings->thumbEffect, $settings->thumbCode, $settings->galSort, $settings->galSortDir));
         // Any displayed gallery links on the home page will need to be regenerated if the permalink structure
         // changes
         if (is_home() or is_front_page()) {
             $key_params[] = get_option('permalink_structure');
         }
         // Try getting the rendered HTML from the cache
         $key = $cache->generate_key($key_params);
         $html = $cache->lookup($key, FALSE);
         // Output debug messages
         if ($html) {
             $retval .= $this->debug_msg("HIT!");
         } else {
             $retval .= $this->debug_msg("MISS!");
         }
         // TODO: This is hack. We need to figure out a more uniform way of detecting dynamic image urls
         if (strpos($html, C_Photocrati_Settings_Manager::get_instance()->dynamic_thumbnail_slug . '/') !== FALSE) {
             $html = FALSE;
             // forces the cache to be re-generated
         }
     } else {
         $retval .= $this->debug_msg("Not looking up in cache as per rules");
     }
     // If we're displaying a variant, I want to know it
     if (isset($displayed_gallery->variation) && is_numeric($displayed_gallery->variation) && $displayed_gallery->variation > 0) {
         $retval .= $this->debug_msg("Using variation #{$displayed_gallery->variation}!");
     }
     // If a cached version doesn't exist, then create the cache
     if (!$html) {
         $retval .= $this->debug_msg("Rendering displayed gallery");
         $current_mode = $controller->get_render_mode();
         $controller->set_render_mode($mode);
         $html = $controller->index_action($displayed_gallery, TRUE);
         if ($key != null) {
             $cache->update($key, $html, NGG_RENDERING_CACHE_TTL);
         }
         $controller->set_render_mode($current_mode);
     }
     $retval .= $html;
     if (!$return) {
         echo $retval;
     }
     return $retval;
 }
 /**
  * Renders a displayed gallery on the frontend
  * @param C_Displayed_Gallery|stdClass $displayed_gallery
  */
 function render($displayed_gallery, $return = FALSE, $mode = null)
 {
     // Simply throwing our rendered gallery into a feed will most likely not work correctly.
     // The MediaRSS option in NextGEN is available as an alternative.
     if (is_feed()) {
         return '';
     }
     if ($mode == null) {
         $mode = 'normal';
     }
     // Save the displayed gallery as a transient if it hasn't already. Allows for ajax operations
     // to add or modify the gallery without losing a retrievable ID
     if (empty($displayed_gallery->transient_id)) {
         $displayed_gallery->transient_id = $displayed_gallery->to_transient();
     }
     // Get the display type controller
     $controller = $this->get_registry()->get_utility('I_Display_Type_Controller', $displayed_gallery->display_type);
     // Enqueue any necessary static resources
     $controller->enqueue_frontend_resources($displayed_gallery);
     // Get routing info
     $router = $url = C_Router::get_instance();
     $url = $router->get_url($router->get_request_uri(), TRUE);
     // Should we lookup in cache?
     $lookup = TRUE;
     if ($displayed_gallery->source == 'random_images') {
         $lookup = FALSE;
     } elseif (is_array($displayed_gallery->container_ids) && in_array('All', $displayed_gallery->container_ids)) {
         $lookup = FALSE;
     } elseif ($displayed_gallery->source == 'albums' && $controller->param('gallery') or $controller->param('album')) {
         $lookup = FALSE;
     } elseif (!$controller->cachable) {
         $lookup = FALSE;
     }
     // Try cache lookup, if we're to do so
     $key = null;
     $html = FALSE;
     if ($lookup) {
         // Some settings affect display types
         $settings = C_NextGen_Settings::get_instance();
         $key_params = apply_filters('ngg_displayed_gallery_cache_params', array($displayed_gallery->get_entity(), $url, $mode, $settings->activateTags, $settings->appendType, $settings->maxImages, $settings->thumbEffect, $settings->thumbCode, $settings->galSort, $settings->galSortDir));
         // Try getting the rendered HTML from the cache
         $key = C_Photocrati_Cache::generate_key($key_params);
         $html = C_Photocrati_Cache::get($key, FALSE);
         // TODO: This is hack. We need to figure out a more uniform way of detecting dynamic image urls
         if (strpos($html, C_Photocrati_Settings_Manager::get_instance()->dynamic_thumbnail_slug) !== FALSE) {
             $html = FALSE;
             // forces the cache to be re-generated
         }
     }
     // If a cached version doesn't exist, then create the cache
     if (!$html) {
         $current_mode = $controller->get_render_mode();
         $controller->set_render_mode($mode);
         $html = $controller->index_action($displayed_gallery, TRUE);
         if ($key != null) {
             C_Photocrati_Cache::set($key, $html);
         }
         $controller->set_render_mode($current_mode);
         // Compress the html to avoid wpautop problems
         $html = $this->compress_html($html);
     }
     if (!$return) {
         echo $html;
     }
     return $html;
 }
예제 #27
0
/**
 * @author Alex Rabe
 *
 */
function nggallery_sortorder($galleryID = 0)
{
    global $wpdb, $ngg, $nggdb;
    if ($galleryID == 0) {
        return;
    }
    $galleryID = (int) $galleryID;
    if (isset($_POST['updateSortorder'])) {
        check_admin_referer('ngg_updatesortorder');
        // get variable new sortorder
        parse_str($_POST['sortorder']);
        if (is_array($sortArray)) {
            $neworder = array();
            foreach ($sortArray as $pid) {
                $neworder[] = (int) $pid;
            }
            $sortindex = 1;
            foreach ($neworder as $pic_id) {
                $wpdb->query("UPDATE {$wpdb->nggpictures} SET sortorder = '{$sortindex}' WHERE pid = {$pic_id}");
                $sortindex++;
            }
            C_Photocrati_Cache::flush('displayed_gallery_rendering');
            do_action('ngg_gallery_sort', $galleryID);
            nggGallery::show_message(__('Sort order changed', 'nggallery'));
        }
    }
    // look for presort args
    $presort = isset($_GET['presort']) ? $_GET['presort'] : false;
    $dir = isset($_GET['dir']) && $_GET['dir'] == 'DESC' ? 'DESC' : 'ASC';
    $sortitems = array('pid', 'filename', 'alttext', 'imagedate');
    // ensure that nobody added some evil sorting :-)
    if (in_array($presort, $sortitems)) {
        $picturelist = $nggdb->get_gallery($galleryID, $presort, $dir, false);
    } else {
        $picturelist = $nggdb->get_gallery($galleryID, 'sortorder', $dir, false);
    }
    //this is the url without any presort variable
    $clean_url = 'admin.php?page=nggallery-manage-gallery&amp;mode=sort&amp;gid=' . $galleryID;
    //if we go back , then the mode should be edit
    $back_url = 'admin.php?page=nggallery-manage-gallery&amp;mode=edit&amp;gid=' . $galleryID;
    // In the case somebody presort, then we take this url
    if (isset($_GET['dir']) || isset($_GET['presort'])) {
        $base_url = $_SERVER['REQUEST_URI'];
    } else {
        $base_url = $clean_url;
    }
    ?>
	<script type="text/javascript">
		jQuery(document).ready(function($) {
			if ($(this).data('ready')) return;

			// Enable sorting
			$(".jqui-sortable").sortable({items: 'div.imageBox'});

			$('#sortGallery').submit(function(e){
				var serial = "";
				var $images = $('div.imageBox');
				for (var i=0; i<$images.length; i++) {
					var image_id = $images[i].id.split('-').pop();
					if (serial.length > 0) serial = serial + '&';
					serial = serial + "sortArray[]=" + image_id;
				}
				$('input[name=sortorder]').val(serial);
			});

			// Listen for events in other frames
			if (window.Frame_Event_Publisher) {
				Frame_Event_Publisher.listen_for('attach_to_post:manage_galleries attach_to_post:manage_images', function(){
					window.location.href = window.location.href;
				});
			}

			$(this).data('ready', true);
		});


	</script>
	<div class="wrap">
		<form id="sortGallery" method="POST" action="<?php 
    echo $clean_url;
    ?>
" accept-charset="utf-8">
			<h2><?php 
    _e('Sort Gallery', 'nggallery');
    ?>
</h2>
			<div class="tablenav">
				<div class="alignleft actions">
					<?php 
    wp_nonce_field('ngg_updatesortorder');
    ?>
					<input class="button-primary action" type="submit" name="updateSortorder" value="<?php 
    _e('Update Sort Order', 'nggallery');
    ?>
" />
				</div>
				<div class="alignright actions">
					<a href="<?php 
    echo nextgen_esc_url($back_url);
    ?>
" class="button"><?php 
    _e('Back to gallery', 'nggallery');
    ?>
</a>
				</div>
			</div>
			<input name="sortorder" type="hidden" />
			<ul class="subsubsub">
				<li><?php 
    _e('Presort', 'nggallery');
    ?>
 :</li>
				<li><a href="<?php 
    echo esc_attr(remove_query_arg('presort', $base_url));
    ?>
" <?php 
    if ($presort == '') {
        echo 'class="current"';
    }
    ?>
><?php 
    _e('Unsorted', 'nggallery');
    ?>
</a> |</li>
				<li><a href="<?php 
    echo esc_attr(add_query_arg('presort', 'pid', $base_url));
    ?>
" <?php 
    if ($presort == 'pid') {
        echo 'class="current"';
    }
    ?>
><?php 
    _e('Image ID', 'nggallery');
    ?>
</a> |</li>
				<li><a href="<?php 
    echo esc_attr(add_query_arg('presort', 'filename', $base_url));
    ?>
" <?php 
    if ($presort == 'filename') {
        echo 'class="current"';
    }
    ?>
><?php 
    _e('Filename', 'nggallery');
    ?>
</a> |</li>
				<li><a href="<?php 
    echo esc_attr(add_query_arg('presort', 'alttext', $base_url));
    ?>
" <?php 
    if ($presort == 'alttext') {
        echo 'class="current"';
    }
    ?>
><?php 
    _e('Alt/Title text', 'nggallery');
    ?>
</a> |</li>
				<li><a href="<?php 
    echo esc_attr(add_query_arg('presort', 'imagedate', $base_url));
    ?>
" <?php 
    if ($presort == 'imagedate') {
        echo 'class="current"';
    }
    ?>
><?php 
    _e('Date/Time', 'nggallery');
    ?>
</a> |</li>
				<li><a href="<?php 
    echo esc_attr(add_query_arg('dir', 'ASC', $base_url));
    ?>
" <?php 
    if ($dir == 'ASC') {
        echo 'class="current"';
    }
    ?>
><?php 
    _e('Ascending', 'nggallery');
    ?>
</a> |</li>
				<li><a href="<?php 
    echo esc_attr(add_query_arg('dir', 'DESC', $base_url));
    ?>
" <?php 
    if ($dir == 'DESC') {
        echo 'class="current"';
    }
    ?>
><?php 
    _e('Descending', 'nggallery');
    ?>
</a></li>
			</ul>
		</form>
		<div id="debug" style="clear:both"></div>
		<div class='jqui-sortable'>
			<?php 
    if ($picturelist) {
        foreach ($picturelist as $picture) {
            ?>
					<div class="imageBox" id="pid-<?php 
            echo $picture->pid;
            ?>
">
						<div class="imageBox_theImage" style="background-image:url('<?php 
            echo nextgen_esc_url($picture->thumbURL);
            ?>
')"></div>
						<div class="imageBox_label"><span><?php 
            echo esc_html(stripslashes($picture->alttext));
            ?>
</span></div>
					</div>
					<?php 
        }
    }
    ?>
		</div>
	</div>

<?php 
}
예제 #28
0
 public function cache_lookups()
 {
     C_Photocrati_Cache::set('get_static_url', self::$_lookups, 'MVC');
 }