/**
  * Front-end display of widget.
  *
  * @see WP_Widget::widget()
  *
  * @param array $args Widget arguments.
  * @param array $instance Saved values from the database.
  */
 public function widget($args, $instance)
 {
     $title = apply_filters('widget_title', empty($instance['title']) ? ' ' : $instance['title'], $instance, $this->id_base);
     $out = $args['before_widget'];
     $out .= $args['before_title'] . $title . $args['after_title'];
     $out .= "<div class='ngg-media-rss-widget'>";
     $out .= "<a href='" . nggMediaRss::get_mrss_url() . "' title='" . $instance['mrss_title'] . "' class='ngg-media-rss-link'>";
     if ($instance['show_icon']) {
         $out .= '<span class="dashicons dashicons-rss" style="padding-right: 1.5em"></span>';
     }
     if ($instance['show_global_mrss']) {
         $out .= $instance['mrss_text'];
     }
     $out .= "</a></div>";
     $out .= $args['after_widget'];
     echo $out;
 }
 function widget($args, $instance)
 {
     extract($args);
     $ngg_options = nggGallery::get_option('ngg_options');
     $title = apply_filters('widget_title', empty($instance['title']) ? '&nbsp;' : $instance['title'], $instance, $this->id_base);
     $show_global_mrss = $instance['show_global_mrss'];
     $show_icon = $instance['show_icon'];
     $mrss_text = stripslashes($instance['mrss_text']);
     $mrss_title = strip_tags(stripslashes($instance['mrss_title']));
     echo $before_widget;
     echo $before_title . $title . $after_title;
     echo "<ul class='ngg-media-rss-widget'>\n";
     if ($show_global_mrss) {
         echo "  <li>";
         echo $this->get_mrss_link(nggMediaRss::get_mrss_url(), $show_icon, stripslashes($mrss_title), stripslashes($mrss_text), $ngg_options['usePicLens']);
         echo "</li>\n";
     }
     echo "</ul>\n";
     echo $after_widget;
 }
Beispiel #3
0
/**
 * Build a gallery output
 * 
 * @access internal
 * @param array $picturelist
 * @param bool $galleryID, if you supply a gallery ID, you can add a slideshow link
 * @param string $template (optional) name for a template file, look for gallery-$template
 * @param int $images (optional) number of images per page
 * @return the content
 */
function nggCreateGallery($picturelist, $galleryID = false, $template = '', $images = false)
{
    global $nggRewrite;
    require_once dirname(__FILE__) . '/lib/media-rss.php';
    $ngg_options = nggGallery::get_option('ngg_options');
    //the shortcode parameter will override global settings, TODO: rewrite this to a class
    $ngg_options['galImages'] = $images === false ? $ngg_options['galImages'] : (int) $images;
    $current_pid = false;
    // $_GET from wp_query
    $nggpage = get_query_var('nggpage');
    $pageid = get_query_var('pageid');
    $pid = get_query_var('pid');
    // in case of permalinks the pid is a slug, we need the id
    if (!is_numeric($pid) && !empty($pid)) {
        $picture = nggdb::find_image($pid);
        $pid = $picture->pid;
    }
    // we need to know the current page id
    $current_page = get_the_ID() == false ? 0 : get_the_ID();
    if (!is_array($picturelist)) {
        $picturelist = array($picturelist);
    }
    // Populate galleries values from the first image
    $first_image = current($picturelist);
    $gallery = new stdclass();
    $gallery->ID = (int) $galleryID;
    $gallery->show_slideshow = false;
    $gallery->show_piclens = false;
    $gallery->name = stripslashes($first_image->name);
    $gallery->title = stripslashes($first_image->title);
    $gallery->description = html_entity_decode(stripslashes($first_image->galdesc));
    $gallery->pageid = $first_image->pageid;
    $gallery->anchor = 'ngg-gallery-' . $galleryID . '-' . $current_page;
    reset($picturelist);
    $maxElement = $ngg_options['galImages'];
    $thumbwidth = $ngg_options['thumbwidth'];
    $thumbheight = $ngg_options['thumbheight'];
    // fixed width if needed
    $gallery->columns = intval($ngg_options['galColumns']);
    $gallery->imagewidth = $gallery->columns > 0 ? 'style="width:' . floor(100 / $gallery->columns) . '%;"' : '';
    // obsolete in V1.4.0, but kept for compat reason
    // pre set thumbnail size, from the option, later we look for meta data.
    $thumbsize = $ngg_options['thumbfix'] ? $thumbsize = 'width="' . $thumbwidth . '" height="' . $thumbheight . '"' : '';
    // show slideshow link
    if ($galleryID) {
        if ($ngg_options['galShowSlide']) {
            $gallery->show_slideshow = true;
            $gallery->slideshow_link = $nggRewrite->get_permalink(array('show' => 'slide'));
            $gallery->slideshow_link_text = nggGallery::i18n($ngg_options['galTextSlide']);
        }
        if ($ngg_options['usePicLens']) {
            $gallery->show_piclens = true;
            $gallery->piclens_link = "javascript:PicLensLite.start({feedUrl:'" . htmlspecialchars(nggMediaRss::get_gallery_mrss_url($gallery->ID)) . "'});";
        }
    }
    // check for page navigation
    if ($maxElement > 0) {
        if (!is_home() || $pageid == $current_page) {
            $page = !empty($nggpage) ? (int) $nggpage : 1;
        } else {
            $page = 1;
        }
        $start = $offset = ($page - 1) * $maxElement;
        $total = count($picturelist);
        //we can work with display:hidden for some javascript effects
        if (!$ngg_options['galHiddenImg']) {
            // remove the element if we didn't start at the beginning
            if ($start > 0) {
                array_splice($picturelist, 0, $start);
            }
            // return the list of images we need
            array_splice($picturelist, $maxElement);
        }
        $nggNav = new nggNavigation();
        $navigation = $nggNav->create_navigation($page, $total, $maxElement);
    } else {
        $navigation = '<div class="ngg-clear"></div>';
    }
    //we cannot use the key as index, cause it's filled with the pid
    $index = 0;
    foreach ($picturelist as $key => $picture) {
        //needed for hidden images (THX to Sweigold for the main idea at : http://wordpress.org/support/topic/228743/ )
        $picturelist[$key]->hidden = false;
        $picturelist[$key]->style = $gallery->imagewidth;
        if ($maxElement > 0 && $ngg_options['galHiddenImg']) {
            if ($index < $start || $index > $start + $maxElement - 1) {
                $picturelist[$key]->hidden = true;
                $picturelist[$key]->style = $gallery->columns > 0 ? 'style="width:' . floor(100 / $gallery->columns) . '%;display: none;"' : 'style="display: none;"';
            }
            $index++;
        }
        // get the effect code
        if ($galleryID) {
            $thumbcode = $ngg_options['galImgBrowser'] ? '' : $picture->get_thumbcode('set_' . $galleryID);
        } else {
            $thumbcode = $ngg_options['galImgBrowser'] ? '' : $picture->get_thumbcode(get_the_title());
        }
        // create link for imagebrowser and other effects
        $args['nggpage'] = empty($nggpage) || $template != 'carousel' ? false : $nggpage;
        // only needed for carousel mode
        $args['pid'] = $ngg_options['usePermalinks'] ? $picture->image_slug : $picture->pid;
        $picturelist[$key]->pidlink = $nggRewrite->get_permalink($args);
        // generate the thumbnail size if the meta data available
        if (isset($picturelist[$key]->meta_data['thumbnail']) && is_array($size = $picturelist[$key]->meta_data['thumbnail'])) {
            $thumbsize = 'width="' . $size['width'] . '" height="' . $size['height'] . '"';
        }
        // choose link between imagebrowser or effect
        $link = $ngg_options['galImgBrowser'] ? $picturelist[$key]->pidlink : $picture->imageURL;
        // bad solution : for now we need the url always for the carousel, should be reworked in the future
        $picturelist[$key]->url = $picture->imageURL;
        // add a filter for the link
        $picturelist[$key]->imageURL = apply_filters('ngg_create_gallery_link', $link, $picture);
        $picturelist[$key]->thumbnailURL = $picture->thumbURL;
        $picturelist[$key]->size = $thumbsize;
        $picturelist[$key]->thumbcode = $thumbcode;
        $picturelist[$key]->caption = empty($picture->description) ? '&nbsp;' : html_entity_decode(stripslashes(nggGallery::i18n($picture->description, 'pic_' . $picture->pid . '_description')));
        $picturelist[$key]->description = empty($picture->description) ? ' ' : htmlspecialchars(stripslashes(nggGallery::i18n($picture->description, 'pic_' . $picture->pid . '_description')));
        $picturelist[$key]->alttext = empty($picture->alttext) ? ' ' : htmlspecialchars(stripslashes(nggGallery::i18n($picture->alttext, 'pic_' . $picture->pid . '_alttext')));
        // filter to add custom content for the output
        $picturelist[$key] = apply_filters('ngg_image_object', $picturelist[$key], $picture->pid);
        //check if $pid is in the array
        if ($picture->pid == $pid) {
            $current_pid = $picturelist[$key];
        }
    }
    reset($picturelist);
    //for paged galleries, take the first image in the array if it's not in the list
    $current_pid = empty($current_pid) ? current($picturelist) : $current_pid;
    // look for gallery-$template.php or pure gallery.php
    $filename = empty($template) ? 'gallery' : 'gallery-' . $template;
    //filter functions for custom addons
    $gallery = apply_filters('ngg_gallery_object', $gallery, $galleryID);
    $picturelist = apply_filters('ngg_picturelist_object', $picturelist, $galleryID);
    //additional navigation links
    $next = empty($nggNav->next) ? false : $nggNav->next;
    $prev = empty($nggNav->prev) ? false : $nggNav->prev;
    // create the output
    $out = nggGallery::capture($filename, array('gallery' => $gallery, 'images' => $picturelist, 'pagination' => $navigation, 'current' => $current_pid, 'next' => $next, 'prev' => $prev));
    // apply a filter after the output
    $out = apply_filters('ngg_gallery_output', $out, $picturelist);
    return $out;
}
 function load_scripts()
 {
     // if you don't want that NGG load the scripts, add this constant
     if (defined('NGG_SKIP_LOAD_SCRIPTS')) {
         return;
     }
     //	activate Thickbox
     if ($this->options['thumbEffect'] == 'thickbox') {
         wp_enqueue_script('thickbox');
         // Load the thickbox images after all other scripts
         add_action('wp_footer', array(&$this, 'load_thickbox_images'), 11);
     }
     // activate modified Shutter reloaded if not use the Shutter plugin
     if ($this->options['thumbEffect'] == "shutter" && !function_exists('srel_makeshutter')) {
         wp_register_script('shutter', NGGALLERY_URLPATH . 'shutter/shutter-reloaded.js', false, '1.3.3');
         wp_localize_script('shutter', 'shutterSettings', array('msgLoading' => __('L O A D I N Ghello', 'nggallery'), 'msgClose' => __('Click to Close', 'nggallery'), 'imageCount' => '1'));
         wp_enqueue_script('shutter');
     }
     // required for the slideshow
     if (NGGALLERY_IREXIST == true && $this->options['enableIR'] == '1' && nggGallery::detect_mobile_phone() === false) {
         wp_enqueue_script('swfobject', NGGALLERY_URLPATH . 'admin/js/swfobject.js', FALSE, '2.2');
     } else {
         wp_register_script('jquery-cycle', NGGALLERY_URLPATH . 'js/jquery.cycle.all.min.js', array('jquery'), '2.9995');
         wp_enqueue_script('ngg-slideshow', NGGALLERY_URLPATH . 'js/ngg.slideshow.min.js', array('jquery-cycle'), '1.06');
     }
     // Load AJAX navigation script, works only with shutter script as we need to add the listener
     if ($this->options['galAjaxNav']) {
         if ($this->options['thumbEffect'] == "shutter" || function_exists('srel_makeshutter')) {
             wp_enqueue_script('ngg_script', NGGALLERY_URLPATH . 'js/ngg.js', array('jquery'), '2.1');
             wp_localize_script('ngg_script', 'ngg_ajax', array('path' => NGGALLERY_URLPATH, 'callback' => trailingslashit(home_url()) . 'index.php?callback=ngg-ajax', 'loading' => __('loading', 'nggallery')));
         }
     }
     // If activated, add PicLens/Cooliris javascript to footer
     if ($this->options['usePicLens']) {
         nggMediaRss::add_piclens_javascript();
     }
 }
Beispiel #5
0
 /**
  * Get the XML <rss> node
  */
 function get_mrss_root_node($title, $description, $link, $prev_link, $next_link, $images)
 {
     if ($prev_link != '' || $next_link != '') {
         $out = "<rss version='2.0' xmlns:media='http://search.yahoo.com/mrss/' xmlns:atom='http://www.w3.org/2005/Atom'>\n";
     } else {
         $out = "<rss version='2.0' xmlns:media='http://search.yahoo.com/mrss/'>\n";
     }
     $out .= "\t<channel>\n";
     $out .= nggMediaRss::get_generator_mrss_node();
     $out .= nggMediaRss::get_title_mrss_node($title);
     $out .= nggMediaRss::get_description_mrss_node($description);
     $out .= nggMediaRss::get_link_mrss_node($link);
     if ($prev_link != '' || $next_link != '') {
         $out .= nggMediaRss::get_self_node(nggMediaRss::get_mrss_url());
     }
     if ($prev_link != '') {
         $out .= nggMediaRss::get_previous_link_mrss_node($prev_link);
     }
     if ($next_link != '') {
         $out .= nggMediaRss::get_next_link_mrss_node($next_link);
     }
     foreach ($images as $image) {
         $out .= nggMediaRss::get_image_mrss_node($image);
     }
     $out .= "\t</channel>\n";
     $out .= "</rss>\n";
     return $out;
 }
Beispiel #6
0
 /**
  * Load scripts depending options defined
  * 20150106: Added js for Qunit
  * 20150107: jquery is almost mandatory... Should it be enqueued only when lightbox is activated?
  */
 function load_scripts()
 {
     // if you want to prevent Nextcellent load the scripts (for testing or development purposes), add this constant
     if (defined('NGG_SKIP_LOAD_SCRIPTS')) {
         return;
     }
     //	activate Thickbox
     if ($this->options['thumbEffect'] == 'thickbox') {
         wp_enqueue_script('thickbox');
         // Load the thickbox images after all other scripts
         add_action('wp_footer', array(&$this, 'load_thickbox_images'), 11);
     }
     // activate jquery.lightbox
     if ($this->options['thumbEffect'] == 'lightbox') {
         wp_enqueue_script('jquery');
     }
     // activate modified Shutter reloaded if not use the Shutter plugin
     if ($this->options['thumbEffect'] == "shutter" && !function_exists('srel_makeshutter')) {
         wp_register_script('shutter', NGGALLERY_URLPATH . 'shutter/shutter-reloaded.js', false, '1.3.3');
         wp_localize_script('shutter', 'shutterSettings', array('msgLoading' => __('L O A D I N G', 'nggallery'), 'msgClose' => __('Click to Close', 'nggallery'), 'imageCount' => '1'));
         wp_enqueue_script('shutter');
     }
     // required for the slideshow
     if (NGGALLERY_IREXIST == true && $this->options['enableIR'] == '1' && nggGallery::detect_mobile_phone() === false) {
         wp_enqueue_script('swfobject');
     } else {
         wp_enqueue_script('owl', NGGALLERY_URLPATH . 'js/owl.carousel.min.js', array('jquery'), '2');
     }
     // Load AJAX navigation script, works only with shutter script as we need to add the listener
     if ($this->options['galAjaxNav']) {
         if ($this->options['thumbEffect'] == "shutter" || function_exists('srel_makeshutter')) {
             wp_enqueue_script('ngg_script', NGGALLERY_URLPATH . 'js/ngg.js', array('jquery', 'jquery-ui-tooltip'), '2.1');
             wp_localize_script('ngg_script', 'ngg_ajax', array('path' => NGGALLERY_URLPATH, 'callback' => trailingslashit(home_url()) . 'index.php?callback=ngg-ajax', 'loading' => __('loading', 'nggallery')));
         }
     }
     // If activated, add PicLens/Cooliris javascript to footer
     if ($this->options['usePicLens']) {
         nggMediaRss::add_piclens_javascript();
     }
     // Added Qunit for javascript unit testing
     $nxc = isset($_GET['nextcellent']) ? $_GET['nextcellent'] : "";
     if ($nxc) {
         wp_enqueue_script("qunit-init", NGGALLERY_URLPATH . "js/nxc.main.js", array('jquery'));
         //main q-unit call
         wp_enqueue_script("qunit", NGGALLERY_URLPATH . "js/qunit-1.16.0.js", array('jquery'));
         //qunit core
         wp_enqueue_script("nextcellent-test", NGGALLERY_URLPATH . "js/nxc.test.js", array('jquery'));
         //unit testing specific for nextcellent
     }
 }
            $next_gallery = next($galleries);
        }
        $rss = nggMediaRss::get_gallery_mrss($gallery, $prev_gallery, $next_gallery);
    } else {
        if ($mode == 'album') {
            // Get additional parameters
            $aid = isset($_GET['aid']) ? (int) $_GET['aid'] : 0;
            if ($aid == 0) {
                header('content-type:text/plain;charset=utf-8');
                _e("No album ID has been provided as parameter", "nggallery");
                exit;
            }
            // Get the album object
            $album = nggdb::find_album($aid);
            if (!isset($album) || $album == null) {
                header('content-type:text/plain;charset=utf-8');
                echo sprintf(__("The album ID=%s does not exist.", "nggallery"), intval($aid));
                exit;
            }
            $rss = nggMediaRss::get_album_mrss($album);
        } else {
            header('content-type:text/plain;charset=utf-8');
            echo __('Invalid MediaRSS command', 'nggallery');
            exit;
        }
    }
}
// Output header for media RSS
header("content-type:text/xml;charset=utf-8");
echo "<?xml version='1.0' encoding='UTF-8' standalone='yes'?>\n";
echo $rss;
Beispiel #8
0
/**
 * Build a gallery output
 * 
 * @access internal
 * @param array $picturelist
 * @param bool $galleryID, if you supply a gallery ID, you can add a slideshow link
 * @param string $template (optional) name for a template file, look for gallery-$template
 * @return the content
 */
function nggCreateGallery($picturelist, $galleryID = false, $template = '')
{
    global $nggRewrite;
    $ngg_options = nggGallery::get_option('ngg_options');
    // $_GET from wp_query
    $nggpage = get_query_var('nggpage');
    $pageid = get_query_var('pageid');
    if (!is_array($picturelist)) {
        $picturelist = array($picturelist);
    }
    $gallery = new stdclass();
    $gallery->ID = (int) $galleryID;
    $gallery->show_slideshow = false;
    $maxElement = $ngg_options['galImages'];
    $thumbwidth = $ngg_options['thumbwidth'];
    $thumbheight = $ngg_options['thumbheight'];
    // set thumb size
    $thumbsize = '';
    if ($ngg_options['thumbfix']) {
        $thumbsize = 'width="' . $thumbwidth . '" height="' . $thumbheight . '"';
    }
    if ($ngg_options['thumbcrop']) {
        $thumbsize = 'width="' . $thumbwidth . '" height="' . $thumbwidth . '"';
    }
    // show slideshow link
    if ($galleryID) {
        if ($ngg_options['galShowSlide'] and NGGALLERY_IREXIST) {
            $gallery->show_slideshow = true;
            $gallery->slideshow_link = $nggRewrite->get_permalink(array('show' => "slide"));
            $gallery->slideshow_link_text = $ngg_options['galTextSlide'];
        }
        if ($ngg_options['usePicLens']) {
            $gallery->show_piclens = true;
            $gallery->piclens_link = "javascript:PicLensLite.start({feedUrl:'" . htmlspecialchars(nggMediaRss::get_gallery_mrss_url($gallery->ID)) . "'});";
        }
    }
    // check for page navigation
    if ($maxElement > 0) {
        if (!is_home() || $pageid == get_the_ID()) {
            if (!empty($nggpage)) {
                $page = (int) $nggpage;
            } else {
                $page = 1;
            }
        } else {
            $page = 1;
        }
        $start = $offset = ($page - 1) * $maxElement;
        $total = count($picturelist);
        // remove the element if we didn't start at the beginning
        if ($start > 0) {
            array_splice($picturelist, 0, $start);
        }
        // return the list of images we need
        array_splice($picturelist, $maxElement);
        $navigation = nggGallery::create_navigation($page, $total, $maxElement);
    } else {
        $navigation = '<div class="ngg-clear">&nbsp;</div>';
    }
    //var_dump($picturelist);
    foreach ($picturelist as $key => $picture) {
        // choose link between imagebrowser or effect
        $link = $ngg_options['galImgBrowser'] ? $nggRewrite->get_permalink(array('pid' => $picture->pid)) : $picture->imageURL;
        // get the effect code
        if ($galleryID) {
            $thumbcode = $ngg_options['galImgBrowser'] ? '' : $picture->get_thumbcode($picturelist[0]->name);
        } else {
            $thumbcode = $ngg_options['galImgBrowser'] ? '' : $picture->get_thumbcode(get_the_title());
        }
        // add a filter for the link
        $picturelist[$key]->imageURL = apply_filters('ngg_create_gallery_link', $link, $picture);
        $picturelist[$key]->thumbnailURL = $picture->thumbURL;
        $picturelist[$key]->size = $thumbsize;
        $picturelist[$key]->thumbcode = $thumbcode;
        $picturelist[$key]->description = empty($picture->description) ? ' ' : stripslashes($picture->description);
        $picturelist[$key]->alttext = empty($picture->alttext) ? ' ' : stripslashes($picture->alttext);
    }
    // look for gallery-$template.php or pure gallery.php
    $filename = empty($template) ? 'gallery' : 'gallery-' . $template;
    // create the output
    $out = nggGallery::capture($filename, array('gallery' => $gallery, 'images' => $picturelist, 'pagination' => $navigation));
    // apply a filter after the output
    $out = apply_filters('ngg_gallery_output', $out, $picturelist);
    return $out;
}
Beispiel #9
0
 /**
  * Function to render the widget
  */
 function render_widget($args, $widget_args = 1)
 {
     global $ngg_mrssw_plugin;
     $ngg_options = nggGallery::get_option('ngg_options');
     // Get the options
     extract($args, EXTR_SKIP);
     if (is_numeric($widget_args)) {
         $widget_args = array('number' => $widget_args);
     }
     $widget_args = wp_parse_args($widget_args, array('number' => -1));
     extract($widget_args, EXTR_SKIP);
     $title = empty($this->options[$number]['widget_title']) ? __('Media RSS', 'nggallery') : $this->options[$number]['widget_title'];
     $show_global_mrss = $this->options[$number]['show_global_mrss'];
     $show_icon = $this->options[$number]['show_icon'];
     // Compat reason for settings pre V1.4.X
     $show_icon = empty($this->options[$number]['mrss_icon_url']) ? $show_icon : true;
     $mrss_text = stripslashes($this->options[$number]['mrss_text']);
     $mrss_title = strip_tags(stripslashes($this->options[$number]['mrss_title']));
     echo '<!-- NextGen Gallery Media RSS -->';
     echo $before_widget;
     echo $before_title . $title . $after_title;
     echo "<ul class='ngg-media-rss-widget'>\n";
     if ($show_global_mrss) {
         echo "  <li>";
         echo $this->get_mrss_link(nggMediaRss::get_mrss_url(), $show_icon, stripslashes($mrss_title), stripslashes($mrss_text), $ngg_options['usePicLens']);
         echo "</li>\n";
     }
     echo "</ul>\n";
     echo $after_widget;
     echo '<!-- /NextGen Gallery Media RSS -->';
 }
Beispiel #10
0
<?php

echo $before_widget . $before_title . $title . $after_title;
?>
<ul class='ngg-media-rss-widget'>
    <?php 
if ($instance['show_global_mrss']) {
    ?>
        <li>
            <?php 
    echo $self->get_mrss_link(nggMediaRss::get_mrss_url(), $instance['show_icon'], strip_tags(stripslashes($instance['mrss_title'])), stripslashes($instance['mrss_text']), $settings->usePicLens);
    ?>
        </li>
    <?php 
}
?>
</ul>
<?php 
echo $after_widget;