function enqueue_pro_lightbox_resources($displayed_gallery = FALSE)
 {
     $settings = C_NextGen_Settings::get_instance();
     if ($settings->thumbEffect == NGG_PRO_LIGHTBOX) {
         $router = C_Router::get_instance();
         if (!self::$run_once) {
             // ensure the gallery exists
             if ($displayed_gallery && $displayed_gallery->id()) {
                 $this->object->_add_script_data('ngg_common', 'galleries.gallery_' . $displayed_gallery->id() . '.wordpress_page_root', get_permalink(), FALSE);
             }
             wp_enqueue_script('underscore');
             wp_enqueue_script('backbone');
             wp_enqueue_script('velocity', $router->get_static_url('photocrati-nextgen_pro_lightbox_legacy#velocity.min.js'));
             wp_enqueue_script('galleria', $router->get_static_url('photocrati-galleria#galleria-1.4.2.min.js'));
             wp_enqueue_style('ngg_pro_lightbox_theme_css', $router->get_static_url('photocrati-nextgen_pro_lightbox_legacy#theme/galleria.nextgen_pro_lightbox.css'));
             wp_enqueue_script('ngg_pro_lightbox_theme_js', $router->get_static_url('photocrati-nextgen_pro_lightbox_legacy#theme/galleria.nextgen_pro_lightbox.js'), 'galleria');
             if (!wp_style_is('fontawesome', 'registered')) {
                 C_Display_Type_Controller::get_instance()->enqueue_displayed_gallery_trigger_buttons_resources();
             }
             wp_enqueue_style('fontawesome');
             // retrieve the lightbox so we can examine its settings
             $mapper = C_Lightbox_Library_Mapper::get_instance();
             $library = $mapper->find_by_name(NGG_PRO_LIGHTBOX, TRUE);
             $library->display_settings += array('is_front_page' => is_front_page() ? 1 : 0, 'share_url' => $router->get_url('/nextgen-share/{gallery_id}/{image_id}/{named_size}', TRUE, 'root'), 'protect_images' => !empty($settings->protect_images) ? TRUE : FALSE, 'style' => str_replace('.css', '', $library->display_settings['style']), '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'))));
             // provide the current language so ajax requests can request translations in the same locale
             if (defined('ICL_LANGUAGE_CODE')) {
                 $library->display_settings['lang'] = $router->param('lang', NULL, FALSE) ? $router->param('lang') : ICL_LANGUAGE_CODE;
             }
             wp_localize_script('photocrati_ajax', 'nplModalSettings', $library->display_settings);
         }
         self::$run_once = TRUE;
     }
 }
 function enqueue_resources($displayed_gallery)
 {
     $router = C_Router::get_instance();
     $enqueue = FALSE;
     if (!wp_style_is('fontawesome', 'registered')) {
         $enqueue = C_Display_Type_Controller::get_instance()->enqueue_displayed_gallery_trigger_buttons_resources($displayed_gallery);
     }
     if ($enqueue !== FALSE) {
         if (!wp_style_is('ngg-trigger-buttons', 'registered')) {
             wp_register_style('ngg-trigger-buttons', $router->get_static_url('photocrati-nextgen_pro_lightbox#trigger_buttons.css'), false);
             wp_enqueue_style('ngg-trigger-buttons');
         }
     }
 }
 function enqueue_backend_resources()
 {
     parent::enqueue_backend_resources();
     $router = C_Router::get_instance();
     if (!wp_script_is('sprintf')) {
         wp_register_script('sprintf', $router->get_static_url('photocrati-nextgen_pro_ecommerce#sprintf.js'));
     }
     wp_enqueue_script('sprintf');
     wp_enqueue_script('jquery.number');
     // Enqueue fontawesome
     if (method_exists('M_Gallery_Display', 'enqueue_fontawesome')) {
         M_Gallery_Display::enqueue_fontawesome();
     } else {
         C_Display_Type_Controller::get_instance()->enqueue_displayed_gallery_trigger_buttons_resources();
     }
     wp_enqueue_style('fontawesome');
 }
 function enqueue_static_resources()
 {
     M_NextGen_Pro_Ecommerce::enqueue_cart_resources();
     // Enqueue fontawesome
     if (method_exists('M_Gallery_Display', 'enqueue_fontawesome')) {
         M_Gallery_Display::enqueue_fontawesome();
     } else {
         C_Display_Type_Controller::get_instance()->enqueue_displayed_gallery_trigger_buttons_resources();
     }
     wp_enqueue_style('fontawesome');
     wp_enqueue_style('ngg-pro-checkout', $this->get_static_url('photocrati-nextgen_pro_ecommerce#checkout.css'));
     foreach ($this->object->get_checkout_buttons() as $btn) {
         $method = "enqueue_{$btn}_resources";
         if ($this->object->has_method($method)) {
             $this->object->{$method}();
         }
     }
 }
 public function generate_thumbnail($image, $params = null, $skip_defaults = false)
 {
     $retval = $this->call_parent('generate_thumbnail', $image, $params, $skip_defaults);
     if (is_admin() && ($image = C_Image_Mapper::get_instance()->find($image))) {
         $controller = C_Display_Type_Controller::get_instance();
         $storage = C_Gallery_Storage::get_instance();
         $app = C_Router::get_instance()->get_routed_app();
         $image->thumb_url = $controller->set_param_for($app->get_routed_url(TRUE), 'timestamp', time(), NULL, $storage->get_thumb_url($image));
         $event = new stdClass();
         $event->pid = $image->{$image->id_field};
         $event->id_field = $image->id_field;
         $event->thumb_url = $image->thumb_url;
         C_Frame_Event_Publisher::get_instance('attach_to_post')->add_event(array('event' => 'thumbnail_modified', 'image' => $event));
     }
     return $retval;
 }
 function enqueue_frontend_resources($displayed_gallery)
 {
     $router = C_Router::get_instance();
     $displayed_gallery->display_settings['theme'] = $router->get_static_url('photocrati-nextgen_pro_slideshow#theme/galleria.nextgen_pro_slideshow.js');
     return C_Display_Type_Controller::get_instance(NGG_PRO_GALLERIA)->enqueue_frontend_resources($displayed_gallery);
 }
 /**
  * Get the thumbnail code (to add effects on thumbnail click)
  *
  * Applies the filter 'ngg_get_thumbcode'
  */
 public function get_thumbcode($gallery_name = '')
 {
     if (empty($this->_displayed_gallery)) {
         $effect_code = C_NextGen_Settings::get_instance()->thumbCode;
         $effect_code = str_replace('%GALLERY_ID%', $gallery_name, $effect_code);
         $effect_code = str_replace('%GALLERY_NAME%', $gallery_name, $effect_code);
         $retval = $effect_code;
     } else {
         $controller = C_Display_Type_Controller::get_instance();
         $retval = $controller->get_effect_code($this->_displayed_gallery);
         // This setting requires that we disable the effect code
         $ds = $this->_displayed_gallery->display_settings;
         if (isset($ds['use_imagebrowser_effect']) && $ds['use_imagebrowser_effect']) {
             $retval = '';
         }
     }
     $retval = apply_filters('ngg_get_thumbcode', $retval, $this);
     // ensure some additional data- fields are added; provides Pro-Lightbox compatibility
     $retval .= ' data-image-id="' . $this->__get('id') . '"';
     $retval .= ' data-src="' . $this->__get('imageURL') . '"';
     $retval .= ' data-thumbnail="' . $this->__get('thumbnailURL') . '"';
     $retval .= ' data-title="' . esc_attr($this->__get('alttext')) . '"';
     $retval .= ' data-description="' . esc_attr($this->__get('description')) . '"';
     $this->_cache['thumbcode'] = $retval;
     return $retval;
 }
Example #8
0
<div class="ngg-related-gallery">
    <?php 
foreach ($images as $image) {
    $controller = C_Display_Type_Controller::get_instance();
    $effect_code = $controller->get_effect_code($gallery->displayed_gallery);
    ?>
        <a href="<?php 
    echo $image->imageURL;
    ?>
"
           title="<?php 
    echo stripslashes(M_I18N::translate($image->description, 'pic_' . $image->pid . '_description'));
    ?>
"
           <?php 
    echo $effect_code;
    ?>
>
            <img title="<?php 
    echo stripslashes(M_I18N::translate($image->alttext, 'pic_' . $image->pid . '_alttext'));
    ?>
"
                 alt="<?php 
    echo stripslashes(M_I18N::translate($image->alttext, 'pic_' . $image->pid . '_alttext'));
    ?>
"
                 data-image-id="<?php 
    echo esc_attr($image->{$image->id_field});
    ?>
"
                 src="<?php 
 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);
 }