function index_action()
 {
     $router = C_Router::get_instance();
     $lightbox_library = C_Lightbox_Library_Manager::get_instance()->get_selected();
     // retrieve by transient id
     $transient_id = $this->object->param('id');
     // get the displayed gallery to display
     $displayed_gallery = $this->get_displayed_gallery($transient_id);
     $this->object->enqueue_static_resources($displayed_gallery, $lightbox_library);
     // 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 = $lightbox_library;
         $handler->enqueue_static_resources();
         $component_markup[] = $handler->render();
     }
     // Set dynamic display properties
     $lightbox_settings = $lightbox_library->values['nplModalSettings'];
     $lightbox_settings['load_images_url'] = $router->get_url('/nextgen-pro-lightbox-load-images/' . $displayed_gallery->transient_id, TRUE, 'root');
     $lightbox_settings['image_protect'] = !empty(C_NextGen_Settings::get_instance()->protect_images) ? TRUE : FALSE;
     $params = array('displayed_gallery_id' => $displayed_gallery->id(), 'component_markup' => implode("\n", $component_markup), 'lightbox_settings' => $lightbox_settings);
     return $this->object->render_view('photocrati-nextgen_pro_lightbox#index', $params, FALSE);
 }
 function register_lightbox()
 {
     $router = C_Router::get_instance();
     $settings = C_NextGen_Settings::get_instance()->get('ngg_pro_lightbox', array());
     $lightboxes = C_Lightbox_Library_Manager::get_instance();
     // Define the Pro Lightbox
     $lightbox = new stdClass();
     $lightbox->title = __('NextGEN Pro Lightbox', 'nextgen-gallery-pro');
     $lightbox->code = "class='nextgen_pro_lightbox' data-nplmodal-gallery-id='%PRO_LIGHTBOX_GALLERY_ID%'";
     $lightbox->styles = array('photocrati-nextgen_pro_lightbox#style.css', 'photocrati-nextgen_pro_lightbox#theme/galleria.nextgen_pro_lightbox.css');
     $lightbox->scripts = array('wordpress#underscore', 'wordpress#backbone', 'photocrati-nextgen_pro_lightbox#velocity.min.js', 'photocrati-galleria#galleria-1.4.2.min.js', 'photocrati-nextgen_pro_lightbox#nextgen_pro_lightbox.js', 'photocrati-nextgen_pro_lightbox#theme/galleria.nextgen_pro_lightbox.js');
     // Set lightbox display properties
     $settings['is_front_page'] = is_front_page() ? 1 : 0;
     $settings['share_url'] = $router->get_url('/nextgen-share/{gallery_id}/{image_id}/{named_size}', TRUE, 'root');
     $settings['wp_site_url'] = $router->get_base_url('site');
     $settings['protect_images'] = !empty(C_NextGen_Settings::get_instance()->protect_images) ? TRUE : FALSE;
     $settings['style'] = str_replace('.css', '', $settings['style']);
     // this once (~2.1.4) referenced files
     // provide the current language so ajax requests can request translations in the same locale
     if (defined('ICL_LANGUAGE_CODE')) {
         $settings['lang'] = $router->param('lang', NULL, FALSE) ? $router->param('lang') : ICL_LANGUAGE_CODE;
     }
     $settings['i18n'] = array('toggle_social_sidebar' => __('Toggle social sidebar', 'nextgen-gallery-pro'), 'play_pause' => __('Play / Pause', 'nextgen-gallery-pro'), 'toggle_fullscreen' => __('Toggle fullscreen', 'nextgen-gallery-pro'), 'toggle_image_info' => __('Toggle image info', 'nextgen-gallery-pro'), 'close_window' => __('Close window', 'nextgen-gallery-pro'), 'share' => array('twitter' => __('Share on Twitter', 'nextgen-gallery-pro'), 'googlep' => __('Share on Google+', 'nextgen-gallery-pro'), 'facebook' => __('Share on Facebook', 'nextgen-gallery-pro'), 'pinterest' => __('Share on Pinterest', 'nextgen-gallery-pro')));
     $lightbox->values = array('nplModalSettings' => $settings);
     $lightboxes->register(NGG_PRO_LIGHTBOX, $lightbox);
 }
 /**
  * Registers hooks for the WordPress framework
  */
 function _register_hooks()
 {
     if (!is_admin()) {
         add_action('wp_enqueue_scripts', array(C_Lightbox_Library_Manager::get_instance(), 'maybe_enqueue'));
     }
     add_action('init', array(&$this, '_register_custom_post_type'));
 }
 static function get_instance()
 {
     if (!isset(self::$_instance)) {
         $klass = get_class();
         self::$_instance = new $klass();
     }
     return self::$_instance;
 }
 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');
     }
 }
 function get_effect_code($displayed_gallery)
 {
     // Swap the gallery placeholder
     $retval = $this->call_parent('get_effect_code', $displayed_gallery);
     $retval = str_replace('%PRO_LIGHTBOX_GALLERY_ID%', $displayed_gallery->id(), $retval);
     $lightbox = C_Lightbox_Library_Manager::get_instance()->get(NGG_PRO_LIGHTBOX);
     if ($lightbox && $lightbox->values['nplModalSettings']['enable_comments'] && $lightbox->values['nplModalSettings']['display_comments']) {
         $retval .= ' data-nplmodal-show-comments="1"';
     }
     return $retval;
 }
 function save_action()
 {
     $settings = $this->object->get_model();
     // Ensure that a lightbox library was selected
     if ($id = $this->object->param('lightbox_library_id')) {
         $lightboxes = C_Lightbox_Library_Manager::get_instance();
         if (!$lightboxes->get($id)) {
             $settings->add_error('Invalid lightbox effect selected');
         } else {
             $settings->thumbEffect = $id;
         }
     }
     // Get thumb effect context
     if ($thumbEffectContext = $this->object->param('thumbEffectContext')) {
         $settings->thumbEffectContext = $thumbEffectContext;
     }
     $settings->save();
     // Save other forms
     $form_manager = C_Form_Manager::get_instance();
     $form_manager->add_form(NGG_LIGHTBOX_OPTIONS_SLUG, 'custom_lightbox');
     foreach ($form_manager->get_forms(NGG_LIGHTBOX_OPTIONS_SLUG, TRUE) as $form) {
         if ($form->has_method('save_action')) {
             $form->save_action();
         }
     }
 }
 /**
  * Register Fancybox.
  *
  * Provides front-end, in-memory lightbox registration in NextGEN 2.0.7+.
  *
  * This is required on the front-end in order to dynamically load the
  * required lightbox CSS and JS files without touching the database, but is
  * also required in the admin, in order to populate the lightbox select
  * menu at Gallery -> Other Options -> Lightbox Effects.
  *
  * @wp-hook		void
  * @ngg-hook	ngg_registered_default_lightboxes
  * @uses			void
  * @since			2.1
  * @return 		void
  */
 function register_fancybox()
 {
     // First check if the "C_Lightbox_Library_Manager" class exists.
     // This avoids creating a potential fatal error (which would cause us to not be able to deactivate the plugin) if this class is ever removed in a future NextGEN version.
     if (!class_exists('C_Lightbox_Library_Manager')) {
         return;
     }
     // Also check the "register()" method exists, should any changes occur in a future version.
     if (!method_exists('C_Lightbox_Library_Manager', 'register')) {
         return;
     }
     // Get instance of C_Lightbox_Library_Manager for lightbox integration in NextGEN 2.0.71+.
     $lightbox_library_manager = C_Lightbox_Library_Manager::get_instance();
     // Register our Enhanced Fancybox Lightbox in NextGEN 2.0.71+.
     $enhanced_fancybox_lightbox = new stdClass();
     $enhanced_fancybox_lightbox->title = __('Enhanced Fancybox Lightbox [NextGEN Gallery Optimizer Basic]', 'nggallery');
     $enhanced_fancybox_lightbox->code = 'class=\'nggobasic-fancybox\' rel=\'%GALLERY_NAME%\'';
     $enhanced_fancybox_lightbox->styles = array($this->plugin_dir_url . 'fancybox/' . $this->prefix . '.jquery.fancybox-' . $this->fancybox_version . '.css');
     $enhanced_fancybox_lightbox->scripts = array($this->plugin_dir_url . 'fancybox/' . $this->prefix . '.jquery.fancybox-' . $this->fancybox_version . '.pack.js');
     $lightbox_library_manager->register($this->fancybox_handle, $enhanced_fancybox_lightbox);
 }
 /**
  * Returns the effect HTML code for the displayed gallery
  * @param type $displayed_gallery
  */
 public function get_effect_code($displayed_gallery)
 {
     $retval = '';
     if ($lightbox = C_Lightbox_Library_Manager::get_instance()->get_selected()) {
         $retval = $lightbox->code;
         $retval = str_replace('%GALLERY_ID%', $displayed_gallery->id(), $retval);
         $retval = str_replace('%GALLERY_NAME%', $displayed_gallery->id(), $retval);
         global $post;
         if ($post && isset($post->ID) && $post->ID) {
             $retval = str_replace('%PAGE_ID%', $post->ID, $retval);
         }
     }
     // allow for customization
     $retval = apply_filters('ngg_effect_code', $retval, $displayed_gallery);
     return $retval;
 }
 static function get_pro_lightbox()
 {
     return C_Lightbox_Library_Manager::get_instance()->get(NGG_PRO_LIGHTBOX);
 }
 function save_action()
 {
     // TODO: Add validation
     if ($updates = $this->object->param(NGG_PRO_LIGHTBOX)) {
         $settings = C_NextGen_Settings::get_instance();
         $settings->set('ngg_pro_lightbox', $updates);
         $settings->save();
         // There's some sort of caching going on that requires all lightboxes
         // to be flushed after we make changes to the Pro Lightbox
         C_Lightbox_Library_Manager::get_instance()->deregister_all();
     }
 }