function widget($args, $instance)
 {
     extract($args);
     $ngg_options = get_option('ngg_options');
     //$title = apply_filters('widget_title', empty( $instance['title'] ) ? __('Slideshow', 'nggallery-oslide') : $instance['title'], $instance, $this->id_base);
     $render = oSlide::getNGG($instance, $args[widget_id]);
     //$render = nggShow_oSlide($instance,$args[widget_id]);
     echo $before_widget;
     if ($title) {
         echo $before_title . $title . $after_title;
     }
     echo $render;
     echo $after_widget;
 }
Beispiel #2
0
    static function getNGG($args = 0, $id = "", $class = "oSlide")
    {
        // if NextGenGallery is not present -> exit
        if (!class_exists(nggdb)) {
            return false;
        }
        $images = nggdb::get_gallery($args["galleryid"]);
        // if gallery has no images
        if (empty($images)) {
            return false;
        }
        // the id of the oslide div
        if ($id != false) {
            $id = 'oSlide-' . $id;
        } else {
            $id = time();
        }
        $options = oSlide::extendDefaultOptions($args);
        // the string including oslide
        $return = "";
        $return .= '<div id="' . $id . '"  class = "' . $class . '"  style="width:' . $options["width"] . '; height:' . $options["height"] . '"> </div>' . "\n" . '
					<script type="text/javascript">' . "\n" . '
					var Photos_' . str_replace("-", "_", $id) . '=[' . "\n";
        foreach ($images as $image) {
            $return .= "\n" . '{ "url": "' . $image->imageURL . '" } ,';
        }
        // remove the last ','
        $return = substr($return, 0, -1);
        $return .= "\n" . ']' . "\n";
        // starting the Slide
        $return .= '
				jQuery(document).ready(function($){' . "\n" . '		
				$("#' . $id . '").oSlide({' . "\n" . '
					enableCaptions:false,
					fade_time:' . $options['fadetime'] . ',
					sleep:' . $options['sleeptime'] . ',
					enableNavigationBar: false,
				';
        if ($options["printcontrols"] == true) {
            $return .= '	enableNavigationControls: true,' . "\n";
        } else {
            $return .= '	enableNavigationControls: false,' . "\n";
        }
        $return .= '
					animation:"' . $options['animation'] . '",' . "\n" . '	
					allowZoom: false,' . "\n" . '	
					images: Photos_' . str_replace("-", "_", $id) . ', 		// an array containing all data to the images' . "\n" . '	
				});' . "\n";
        // Since height multiplicator is NOT Jet implemented in oSlide, i make it afterwards
        if ($options["multiplicator"] != 0) {
            $return .= '
				var ßproporcionDePeso = ' . $options["multiplicator"] . '
				var ßsliderHeight = $("#' . $id . '").height();
				var ßsliderHeightReudciotn = Math.round( ( (ßsliderHeight /100)*3)*ßproporcionDePeso);
				ßsliderHeight = ßsliderHeight - ßsliderHeightReudciotn;
	
				var ßsumHeight = Math.round(  $("#' . $id . '").width() * (ßproporcionDePeso/100));
				$("#' . $id . '").height(ßsliderHeight + ßsumHeight );

				$(window).resize();
				$(window).resize(function(){
					var ßsumHeight = Math.round($("#' . $id . '").width() * (ßproporcionDePeso/100));
					$("#' . $id . '").height(ßsliderHeight + ßsumHeight );
				})';
        }
        $return .= '});' . "\n";
        $return .= '</script>';
        return $return;
    }