'widget_slideshow', 'description' => __( 'Show a NextGEN Gallery Slideshow', 'nggallery') ); $this->WP_Widget('slideshow', __('NextGEN Slideshow', 'nggallery'), $widget_ops); } function widget( $args, $instance ) { extract( $args ); $title = apply_filters('widget_title', empty( $instance['title'] ) ? __('Slideshow', 'nggallery') : $instance['title'], $instance, $this->id_base); $out = $this->render_slideshow($instance['galleryid'] , $instance['width'] , $instance['height']); if ( !empty( $out ) ) { echo $before_widget; if ( $title) echo $before_title . $title . $after_title; ?>
classname = 'ngg-widget-slideshow'; $swfobject->message = __('Get the Flash Player to see the slideshow.', 'nggallery'); $swfobject->add_params('wmode', 'opaque'); $swfobject->add_params('bgcolor', $ngg_options['irScreencolor'], 'FFFFFF', 'string', '#'); $swfobject->add_attributes('styleclass', 'slideshow-widget'); // adding the flash parameter $swfobject->add_flashvars( 'file', urlencode( trailingslashit( home_url() ) . 'index.php?callback=imagerotator&gid=' . $galleryID ) ); $swfobject->add_flashvars( 'shownavigation', 'false', 'true', 'bool'); $swfobject->add_flashvars( 'shuffle', $ngg_options['irShuffle'], 'true', 'bool'); $swfobject->add_flashvars( 'showicons', $ngg_options['irShowicons'], 'true', 'bool'); $swfobject->add_flashvars( 'overstretch', $ngg_options['irOverstretch'], 'false', 'string'); $swfobject->add_flashvars( 'rotatetime', $ngg_options['irRotatetime'], 5, 'int'); $swfobject->add_flashvars( 'transition', $ngg_options['irTransition'], 'random', 'string'); $swfobject->add_flashvars( 'backcolor', $ngg_options['irBackcolor'], 'FFFFFF', 'string', '0x'); $swfobject->add_flashvars( 'frontcolor', $ngg_options['irFrontcolor'], '000000', 'string', '0x'); $swfobject->add_flashvars( 'lightcolor', $ngg_options['irLightcolor'], '000000', 'string', '0x'); $swfobject->add_flashvars( 'screencolor', $ngg_options['irScreencolor'], '000000', 'string', '0x'); $swfobject->add_flashvars( 'width', $irWidth, '260'); $swfobject->add_flashvars( 'height', $irHeight, '320'); // create the output $out = $swfobject->output(); // add now the script code $out .= "\n".''; $out = apply_filters('ngg_show_slideshow_widget_content', $out, $galleryID, $irWidth, $irHeight); return $out; } function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = strip_tags($new_instance['title']); $instance['galleryid'] = (int) $new_instance['galleryid']; $instance['height'] = (int) $new_instance['height']; $instance['width'] = (int) $new_instance['width']; return $instance; } function form( $instance ) { global $wpdb; //Defaults $instance = wp_parse_args( (array) $instance, array( 'title' => 'Slideshow', 'galleryid' => '0', 'height' => '120', 'width' => '160') ); $title = esc_attr( $instance['title'] ); $height = esc_attr( $instance['height'] ); $width = esc_attr( $instance['width'] ); $tables = $wpdb->get_results("SELECT * FROM $wpdb->nggallery ORDER BY 'name' ASC "); ?>

'ngg_images', 'description' => __( 'Add recent or random images from the galleries', 'nggallery') ); $this->WP_Widget('ngg-images', __('NextGEN Widget', 'nggallery'), $widget_ops); } function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = strip_tags($new_instance['title']); $instance['items'] = (int) $new_instance['items']; $instance['type'] = $new_instance['type']; $instance['show'] = $new_instance['show']; $instance['width'] = (int) $new_instance['width']; $instance['height'] = (int) $new_instance['height']; $instance['exclude'] = $new_instance['exclude']; $instance['list'] = $new_instance['list']; $instance['webslice']= (bool) $new_instance['webslice']; return $instance; } function form( $instance ) { //Defaults $instance = wp_parse_args( (array) $instance, array( 'title' => 'Gallery', 'items' => '4', 'type' => 'random', 'show' => 'thumbnail', 'height' => '50', 'width' => '75', 'exclude' => 'all', 'list' => '', 'webslice' => true ) ); $title = esc_attr( $instance['title'] ); $items = intval ( $instance['items'] ); $height = esc_attr( $instance['height'] ); $width = esc_attr( $instance['width'] ); ?>



x (px)

id_base); global $wpdb; $items = $instance['items']; $exclude = $instance['exclude']; $list = $instance['list']; $webslice = $instance['webslice']; $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->nggpictures WHERE exclude != 1 "); if ($count < $instance['items']) $instance['items'] = $count; $exclude_list = ''; // THX to Kay Germer for the idea & addon code if ( (!empty($list)) && ($exclude != 'all') ) { $list = explode(',',$list); // Prepare for SQL $list = "'" . implode("', '", $list ) . "'"; if ($exclude == 'denied') $exclude_list = "AND NOT (t.gid IN ($list))"; if ($exclude == 'allow') $exclude_list = "AND t.gid IN ($list)"; // Limit the output to the current author, can be used on author template pages if ($exclude == 'user_id' ) $exclude_list = "AND t.author IN ($list)"; } if ( $instance['type'] == 'random' ) $imageList = $wpdb->get_results("SELECT t.*, tt.* FROM $wpdb->nggallery AS t INNER JOIN $wpdb->nggpictures AS tt ON t.gid = tt.galleryid WHERE tt.exclude != 1 $exclude_list ORDER by rand() limit {$items}"); else $imageList = $wpdb->get_results("SELECT t.*, tt.* FROM $wpdb->nggallery AS t INNER JOIN $wpdb->nggpictures AS tt ON t.gid = tt.galleryid WHERE tt.exclude != 1 $exclude_list ORDER by pid DESC limit 0,$items"); // IE8 webslice support if needed if ( $webslice ) { $before_widget .= "\n" . '
' . "\n"; //the headline needs to have the class enty-title $before_title = str_replace( 'class="' , 'class="entry-title ', $before_title); $after_widget = '
'."\n" . $after_widget; } echo $before_widget . $before_title . $title . $after_title; echo "\n" . '
'. "\n"; if (is_array($imageList)){ foreach($imageList as $image) { // get the URL constructor $image = new nggImage($image); // get the effect code $thumbcode = $image->get_thumbcode( $widget_id ); // enable i18n support for alttext and description $alttext = htmlspecialchars( stripslashes( nggGallery::i18n($image->alttext, 'pic_' . $image->pid . '_alttext') )); $description = htmlspecialchars( stripslashes( nggGallery::i18n($image->description, 'pic_' . $image->pid . '_description') )); //TODO:For mixed portrait/landscape it's better to use only the height setting, if widht is 0 or vice versa $out = ''; // Typo fix for the next updates (happend until 1.0.2) $instance['show'] = ( $instance['show'] == 'orginal' ) ? 'original' : $instance['show']; if ( $instance['show'] == 'original' ) $out .= ''.$alttext.''; else $out .= ''.$alttext.''; echo $out . ''."\n"; } } echo '
'."\n"; echo $after_widget; } }// end widget class // register it add_action('widgets_init', create_function('', 'return register_widget("nggWidget");')); /** * nggSlideshowWidget($galleryID, $width, $height) * Function for templates without widget support * * @param integer $galleryID * @param string $width * @param string $height * @return echo the widget content */ function nggSlideshowWidget($galleryID, $width = '', $height = '') { echo nggSlideshowWidget::render_slideshow($galleryID, $width, $height); } /** * nggDisplayRandomImages($number,$width,$height,$exclude,$list,$show) * Function for templates without widget support * * @return echo the widget content */ function nggDisplayRandomImages($number, $width = '75', $height = '50', $exclude = 'all', $list = '', $show = 'thumbnail') { $options = array( 'title' => false, 'items' => $number, 'show' => $show , 'type' => 'random', 'width' => $width, 'height' => $height, 'exclude' => $exclude, 'list' => $list, 'webslice' => false ); $ngg_widget = new nggWidget(); $ngg_widget->widget($args = array( 'widget_id'=> 'sidebar_1' ), $options); } /** * nggDisplayRecentImages($number,$width,$height,$exclude,$list,$show) * Function for templates without widget support * * @return echo the widget content */ function nggDisplayRecentImages($number, $width = '75', $height = '50', $exclude = 'all', $list = '', $show = 'thumbnail') { $options = array( 'title' => false, 'items' => $number, 'show' => $show , 'type' => 'recent', 'width' => $width, 'height' => $height, 'exclude' => $exclude, 'list' => $list, 'webslice' => false ); $ngg_widget = new nggWidget(); $ngg_widget->widget($args = array( 'widget_id'=> 'sidebar_1' ), $options); } ?>