function install_pro_lightbox_settings(C_Photocrati_Settings_Manager $settings, $reset = FALSE) { $defaults = array('background_color' => 1, 'enable_routing' => 1, 'icon_color' => '', 'icon_background' => '', 'icon_background_enabled' => 0, 'icon_background_rounded' => 1, 'overlay_icon_color' => '', 'sidebar_button_color' => '', 'sidebar_button_background' => '', 'router_slug' => 'gallery', 'carousel_background_color' => '', 'carousel_text_color' => '', 'enable_comments' => 1, 'enable_sharing' => 1, 'display_comments' => 0, 'display_captions' => 0, 'display_carousel' => 1, 'image_crop' => 'false', 'image_pan' => 0, 'interaction_pause' => 1, 'sidebar_background_color' => '', 'slideshow_speed' => 5, 'style' => '', 'touch_transition_effect' => 'slide', 'transition_effect' => 'slide', 'transition_speed' => 0.4); // Create settings array if (!$settings->exists('ngg_pro_lightbox')) { $settings->set('ngg_pro_lightbox', array()); } $ngg_pro_lightbox = $settings->get('ngg_pro_lightbox'); // Need migration logic from custom post type global $wpdb; $row = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->posts} WHERE post_type = 'lightbox_library' AND post_title = %s", NGG_PRO_LIGHTBOX)); if ($row) { $row->post_content = M_DataMapper::unserialize($row->post_content); $ngg_pro_lightbox = $row->post_content['display_settings']; @wp_delete_post($row->ID, TRUE); } // Set defaults foreach ($defaults as $key => $value) { if (!array_key_exists($key, $ngg_pro_lightbox)) { $ngg_pro_lightbox[$key] = $value; } } // Save the data $settings->set('ngg_pro_lightbox', $ngg_pro_lightbox); }
function validation() { // Valid sources $this->object->validates_presence_of('source'); // Valid display type? $this->object->validates_presence_of('display_type'); if ($display_type = $this->object->get_display_type()) { $display_type->settings = $this->object->display_settings; if (!$display_type->validate()) { foreach ($display_type->get_errors() as $property => $errors) { foreach ($errors as $error) { $this->object->add_error($error, $property); } } } // Is the display type compatible with the source? E.g., if we're // using a display type that expects images, we can't be feeding it // galleries and albums if ($source = $this->object->get_source()) { if (!$display_type->is_compatible_with_source($source)) { $this->object->add_error(_('Source not compatible with selected display type'), 'display_type'); } } // If no maximum_entity_count has been given, then set a maximum if (!isset($this->object->maximum_entity_count)) { $this->object->maximum_entity_count = C_Photocrati_Settings_Manager::get('maximum_entity_count', 500); } } else { $this->object->add_error('Invalid display type', 'display_type'); } return $this->object->is_valid(); }
static function get_instance() { if (is_multisite()) { return C_Photocrati_Global_Settings_Manager::get_instance(); } else { return C_Photocrati_Settings_Manager::get_instance(); } }
public static function get_instance() { if (is_null(self::$_instance)) { $klass = get_class(); self::$_instance = new $klass(); } return self::$_instance; }
function _load_non_pope() { // Load caching component include_once 'non_pope/class.photocrati_cache.php'; C_Photocrati_Cache::get_instance(); C_Photocrati_Cache::get_instance('displayed_galleries'); C_Photocrati_Cache::get_instance('displayed_gallery_rendering'); C_Photocrati_Cache::$enabled = PHOTOCRATI_CACHE; if (isset($_REQUEST['ngg_flush'])) { C_Photocrati_Cache::flush('all'); die("Flushed all caches"); } 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']); } elseif (isset($_REQUEST['ngg_flush_expired'])) { C_Photocrati_Cache::flush('all', TRUE); die("Flushed all expired items from the cache"); } // 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'; }
/** * 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; }
function _load_non_pope() { // Load caching component include_once 'non_pope/class.photocrati_transient_manager.php'; if (isset($_REQUEST['ngg_flush']) or isset($_REQUEST['ngg_flush_expired'])) { C_Photocrati_Transient_Manager::flush(); die("Flushed all caches"); } // 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 _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'; }
/** * 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; }