Advertisement
Guest User

jj_ngg_jquery_slider.php

a guest
Sep 25th, 2011
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 40.87 KB | None | 0 0
  1. <?php
  2.  
  3. class JJ_NGG_JQuery_Slider extends WP_Widget
  4. {
  5.  
  6.   function JJ_NGG_JQuery_Slider()
  7.   {
  8.     $widget_ops = array('classname' => 'jj-nexgen-jquery_slider', 'description' => "Allows you to pick a gallery from the 'NextGen Gallery' plugin to use as a 'JQuery Nivo Slider'.");
  9.     $this->WP_Widget('jj-nexgen-jquery_slider', 'JJ NextGEN JQuery Slider', $widget_ops);
  10.   }
  11.  
  12.   function widget($args, $instance)
  13.   {
  14.     global $wpdb;
  15.     extract($args);
  16.  
  17.     // Set params
  18.     $title = apply_filters('widget_title', $instance['title']);
  19.     $html_id = $this->get_val($instance, 'html_id', 'slider');
  20.     $width = $this->get_val_numeric($instance, 'width');
  21.     $height = $this->get_val_numeric($instance, 'height');
  22.     $order = $this->get_val($instance, 'order', 'asc', false);
  23.     $tags = $this->get_val($instance, 'tags');
  24.     $shuffle = $this->get_val($instance, 'shuffle');
  25.     $limit = $this->get_val_numeric($instance, 'max_pictures');
  26.     $center = $this->get_val($instance, 'center');
  27.     $gallery = $this->get_val_numeric($instance, 'gallery');
  28.     $shortcode = $this->get_val($instance, 'shortcode');
  29.    
  30.     // Set nivo params
  31.     $effect = $this->get_val($instance, 'effect');
  32.     $slices = $this->get_val($instance, 'slices');
  33.     $boxcols = $this->get_val($instance, 'boxcols');
  34.     $boxrows = $this->get_val($instance, 'boxrows');
  35.     $animspeed = $this->get_val($instance, 'animspeed');
  36.     $pausetime = $this->get_val($instance, 'pausetime');
  37.     $startslide = $this->get_val($instance, 'startslide');
  38.     $directionnav = $this->get_val($instance, 'directionnav');
  39.     $directionnavhide = $this->get_val($instance, 'directionnavhide');
  40.     $controlnav = $this->get_val($instance, 'controlnav');
  41.     $controlnavthumbs = $this->get_val($instance, 'controlnavthumbs');    
  42.     $thumbswidth = $this->get_val_numeric($instance, 'thumbswidth');
  43.     $thumbsheight = $this->get_val_numeric($instance, 'thumbsheight');
  44.     $thumbscontainerheight = $this->get_val_numeric($instance, 'thumbscontainerheight');
  45.     $thumbsgap = $this->get_val_numeric($instance, 'thumbsgap');    
  46.     $controlnavthumbsfromrel = $this->get_val($instance, 'controlnavthumbsfromrel');
  47.     $controlnavthumbssearch = $this->get_val($instance, 'controlnavthumbssearch');
  48.     $controlnavthumbsreplace = $this->get_val($instance, 'controlnavthumbsreplace');
  49.     $keyboardnav = $this->get_val($instance, 'keyboardnav');
  50.     $pauseonhover = $this->get_val($instance, 'pauseonhover');
  51.     $manualadvance = $this->get_val($instance, 'manualadvance');
  52.     $captionopacity = $this->get_val($instance, 'captionopacity');
  53.     $disablecaptions = $this->get_val($instance, 'disablecaptions');
  54.     $beforechange = $this->get_val($instance, 'beforechange', '', false);
  55.     $afterchange = $this->get_val($instance, 'afterchange', '', false);
  56.     $slideshowend = $this->get_val($instance, 'slideshowend', '', false);
  57.     $lastslide = $this->get_val($instance, 'lastslide', '', false);
  58.     $afterload = $this->get_val($instance, 'afterload', '', false);
  59.  
  60.     // SQL defaults
  61.     $sql_order = '';
  62.     $sql_where = ' WHERE exclude = 0';
  63.     $sql_limit = '';
  64.    
  65.     // Set SQL order
  66.     if($order == 'random')
  67.     {
  68.       $sql_order = 'RAND()';
  69.     }
  70.     elseif($order == 'asc')
  71.     {
  72.        $sql_order = 'galleryid ASC';
  73.     }        
  74.     elseif($order == 'desc')
  75.     {
  76.       $sql_order = 'galleryid DESC';
  77.     }
  78.     elseif($order == 'sortorder')
  79.     {
  80.       $sql_order = 'sortorder ASC';
  81.     }
  82.     else
  83.     {
  84.       $sql_order = 'galleryid ASC';
  85.     }
  86.  
  87.     if($gallery != '')
  88.     {
  89.       $sql_where .= ' AND galleryid = ' . $gallery;
  90.     }
  91.    
  92.     // Set limit defaults only it tags are not being used
  93.     $num_limit = -1;
  94.     if(is_numeric($limit))
  95.     {
  96.       $num_limit = (int)$limit;
  97.       if($tags == '')
  98.       {
  99.         $sql_limit = ' LIMIT 0, ' . $limit;
  100.       }
  101.     }        
  102.  
  103.     $results = $wpdb->get_results("SELECT * FROM $wpdb->nggpictures" . $sql_where . " ORDER BY " . $sql_order . $sql_limit);
  104.     $p_size = 0;
  105.     if(is_array($results))
  106.     {          
  107.       // Filter by tag if entered
  108.       if($tags != '')
  109.       {
  110.         $tagged_images = nggTags::find_images_for_tags($tags);
  111.      
  112.         if($tagged_images)
  113.         {
  114.           $tagged_image_ids = array();
  115.           foreach($tagged_images as $image)
  116.           {
  117.             $tagged_image_ids[] = $image->pid;
  118.           }
  119.          
  120.           if(sizeof($tagged_image_ids) > 0)
  121.           {      
  122.             $filtered_results = array();
  123.             $tagged_count = 0;
  124.             foreach($results as $result)
  125.             {    
  126.               if($num_limit != -1 && $tagged_count >= $num_limit)
  127.               {  
  128.                 break;
  129.               }
  130.               else
  131.               {      
  132.                 if(in_array($result->pid, $tagged_image_ids))
  133.                 {
  134.                   $filtered_results[] = $result;
  135.                   $tagged_count += 1;
  136.                 }
  137.               }
  138.             }        
  139.             $results = $filtered_results;
  140.           }
  141.         }
  142.         else
  143.         {
  144.           $results = array();
  145.         }
  146.       }
  147.      
  148.       $p_size = count($results);              
  149.     }
  150.    
  151.     $output = ''; $js_output = ''; $css_output = ''; $output_dir = dirname(__FILE__)."/../output/";
  152.     if($p_size > 0)
  153.     {    
  154.       $has_control_nav = ($controlnav == '' || $controlnav == 'true');
  155.       $has_thumbs = ($controlnavthumbs == 'true' || $controlnavthumbs == 'nextgen_thumbs' || $controlnavthumbs == 'nextgen_original');
  156.       $has_center = $center == '1' && $width != '';
  157.      
  158.       if($width != '' || $height != '')
  159.       {
  160.         $width_s = '';
  161.         $height_s = '';
  162.         if($width != '') { $width_s = "width: " . $width . "px !important;"; }
  163.         if($height != '') { $height_s = "height: " . $height . "px !important;"; }
  164.         $css_output .= "<style type=\"text/css\">";    
  165.         if($width_s != '' || $height_s != '')
  166.         {
  167.           $css_output .= "\n  div#" . $html_id . " { " . $width_s . $height_s . " }";
  168.         }
  169.         if($width_s != '')
  170.         {
  171.           $css_output .= "\n  div#" . $html_id . "_container .nivo_slider .nivo-controlNav { " . $width_s . " }";  
  172.         }  
  173.         if($has_control_nav && $has_thumbs)
  174.         {
  175.           if($thumbscontainerheight != '')
  176.           {
  177.             $css_output .= "\n  div#" . $html_id . "_container { padding-bottom: " . $thumbscontainerheight . "px; }";
  178.             $css_output .= "\n  div#" . $html_id . "_container .nivo-controlNav { bottom: -" . $thumbscontainerheight . "px; }";
  179.           }
  180.           if($thumbsgap != '' || $thumbswidth != '' || $thumbsheight != '')
  181.           {
  182.             $css_output .= "\n  div#" . $html_id . "_container .nivo-controlNav img { ";
  183.             if($thumbsgap != '')
  184.             {
  185.               $css_output .= "margin-right: " . $thumbsgap . "px;";
  186.             }
  187.             if($thumbswidth != '')
  188.             {
  189.               $css_output .= "width: " . $thumbswidth . "px ;";
  190.             }  
  191.             if($thumbsheight != '')
  192.             {
  193.               $css_output .= "height: " . $thumbsheight . "px;";
  194.             }                    
  195.             $css_output .= " }";
  196.           }
  197.           if($has_center && $thumbsgap != '')
  198.           {
  199.             $css_output .= "\n  div#" . $html_id . "_container .nivo-controlNav img.first_thumb { margin-left: " . $thumbsgap . "px; }";
  200.           }
  201.         }        
  202.         $css_output .= "\n</style>";        
  203.       }
  204.      
  205.       //  add_action( 'wp_head', function() { echo $css_output; } );
  206.       //  $output .= "<!--[css_output]-->".$css_output."<!--[/css_output]-->";
  207.       //  $output .= $css_output."<!--[output]-->";
  208.       $temp = fopen($output_dir.$html_id.".css","w");
  209.       $css_output = str_replace(array("<style type=\"text/css\">\n","\n</style>"),array('',''),$css_output);
  210.       if (fwrite($temp, $css_output)) {
  211.         fclose($temp);
  212.       }
  213.       $css_link  = WPJJNGGJ_SLIDER_plugin_url( 'output/'.$html_id.'.css' );
  214.       //  wp_enqueue_style( 'jquery-plugins-slider-style'.$html_id, $css_link, array(), '', 'all' );
  215.      
  216.       if($title != '')
  217.       {      
  218.         if($shortcode != '1')
  219.         {      
  220.           $output .= "\n" . $before_title . $title . $after_title;
  221.         }
  222.         else
  223.         {
  224.           $output .= "\n<h3>" . $title . "</h3>";
  225.         }
  226.       }
  227.      
  228.       $container_class = '';      
  229.       if($has_center)
  230.       {
  231.         $container_class = ' nivo_slider_center';
  232.       }
  233.       if($has_control_nav)
  234.       {
  235.         if($has_thumbs)
  236.         {
  237.           $container_class .= ' nivo_slider_controlNavImages';  
  238.         }
  239.         else
  240.         {
  241.           $container_class .= ' nivo_slider_controlNavText';
  242.         }
  243.       }
  244.      
  245.       $output .= "\n<div id=\"" . $html_id . "_container\" class=\"nivo_slider_container" . $container_class . "\">";      
  246.       $output .= "\n  <div id=\"" . $html_id . "\" class=\"nivo_slider\">";
  247.       $image_alt = null;
  248.       $image_description = null;
  249.       foreach($results as $result)
  250.       {
  251.         $gallery = $wpdb->get_row("SELECT * FROM $wpdb->nggallery WHERE gid = '" . $result->galleryid . "'");
  252.         foreach($gallery as $key => $value)
  253.         {
  254.             $result->$key = $value;
  255.         }        
  256.         $image = new nggImage($result);
  257.                
  258.         $image_alt = trim($image->alttext);  
  259.         $image_description = trim($image->description);                  
  260.        
  261.         $output .= "\n    ";
  262.        
  263.         // check that alt is url with a simple validation
  264.         $use_url = false;        
  265.         if($image_alt != '' && (substr($image_alt, 0, 1) == '/' || substr($image_alt, 0, 4) == 'http' || substr($image_alt, 0, 3) == 'ftp'))
  266.         {
  267.           $use_url = true;
  268.         }
  269.                
  270.         if($use_url != '')
  271.         {
  272.           $output .= "<a href=\"" . esc_attr($image_alt) . "\">";
  273.         }
  274.        
  275.         if($disablecaptions != '1' && $image_description != '')
  276.         {
  277.           $image_description = "title=\"" . $this->quote_fix($image_description) . "\" ";
  278.         }
  279.         else
  280.         {
  281.           $image_description = '';
  282.         }
  283.          
  284.         $output .= "<img src=\"" . $image->imageURL . "\" " . $image_description . "class=\"nivo_image\" alt=\"nivo slider image\" />";
  285.        
  286.         if($use_url != '')
  287.         {
  288.           $output .= "</a>";
  289.         }          
  290.       }
  291.       $output .= "\n  </div>";
  292.       $output .= "\n</div>";
  293.     }    
  294.    
  295.     // Nivo arguments
  296.     $javascript_args = array();
  297.    
  298.     // Modifications if only 1 picture
  299.     if($p_size <= 1)
  300.     {
  301.       $startslide = '0';
  302.       $directionnav = 'false';
  303.       $controlnav = 'false';
  304.       $keyboardnav = 'false';
  305.       $pauseonhover = 'false';
  306.       $manualadvance = 'false';    
  307.       $beforechange = '';
  308.       $afterchange = '';
  309.       $slideshowend = '';
  310.       $lastslide = '';
  311.       $afterload  = '';
  312.     }
  313.  
  314.     if($effect != "") { $javascript_args[] = "effect: '" . $effect . "'"; }
  315.     if($slices != "") { $javascript_args[] = "slices: " . $slices . ""; }
  316.     if($boxcols != "") { $javascript_args[] = "boxCols: " . $boxcols . ""; }
  317.     if($boxrows != "") { $javascript_args[] = "boxRows: " . $boxrows . ""; }
  318.     if($animspeed != "") { $javascript_args[] = "animSpeed: " . $animspeed; }
  319.     if($pausetime != "") { $javascript_args[] = "pauseTime: " . $pausetime; }
  320.     if($startslide != "") { $javascript_args[] = "startSlide: " . $startslide; }
  321.     if($directionnav != "") { $javascript_args[] = "directionNav: " . $directionnav; }
  322.     if($directionnavhide != "") { $javascript_args[] = "directionNavHide: " . $directionnavhide; }
  323.     if($controlnav != "") { $javascript_args[] = "controlNav: " . $controlnav; }
  324.     if($controlnavthumbs != "") { $javascript_args[] = "controlNavThumbs: " . ($has_thumbs ? 'true' : 'false'); }
  325.     if($controlnavthumbsfromrel != "") { $javascript_args[] = "controlNavThumbsFromRel: " . $controlnavthumbsfromrel; }
  326.     if($controlnavthumbssearch != "") { $javascript_args[] = "controlNavThumbsSearch: '" . $controlnavthumbssearch . "'"; }
  327.     if($controlnavthumbsreplace != "") { $javascript_args[] = "controlNavThumbsReplace: '" . $controlnavthumbsreplace . "'"; }
  328.     if($keyboardnav != "") { $javascript_args[] = "keyboardNav: " . $keyboardnav; }
  329.     if($pauseonhover != "") { $javascript_args[] = "pauseOnHover: " . $pauseonhover; }
  330.     if($manualadvance != "") { $javascript_args[] = "manualAdvance: " . $manualadvance; }
  331.     if($captionopacity != "") { $javascript_args[] = "captionOpacity: " . $captionopacity; }
  332.     if($beforechange != "") { $javascript_args[] = "beforeChange: " . $beforechange; }
  333.     if($afterchange != "") { $javascript_args[] = "afterChange: " . $afterchange; }
  334.     if($slideshowend != "") { $javascript_args[] = "slideshowEnd: " . $slideshowend; }
  335.     if($lastslide != "") { $javascript_args[] = "lastSlide: " . $lastslide; }
  336.     if($afterload != "") { $javascript_args[] = "afterLoad: " . $afterload; }  
  337.    
  338.     // Add javascript
  339.     $js_output .= "\n<script type=\"text/javascript\">";
  340.     $js_output .= "\n  jQuery(window).load(function() {";
  341.    
  342.     $js_output .= "\n    jQuery('head').append('<link rel=\"stylesheet\" href=\"".$css_link."\" type=\"text/css\" />');";
  343.    
  344.     // Shuffle results on random order so even if page is cached the order will be different each time
  345.     if($order == 'random' && $shuffle == 'true')
  346.     {
  347.       $js_output .= "\n    jQuery('div#" . $html_id . "').jj_ngg_shuffle();";
  348.     }
  349.     $js_output .= "\n    jQuery('div#" . $html_id . "').nivoSlider(";
  350.     if(count($javascript_args) > 0)
  351.     {
  352.       $js_output .= "{" . implode(",", $javascript_args) . "}";
  353.     }
  354.     $js_output .= ");";
  355.     if($has_control_nav && $has_thumbs)
  356.     {
  357.       if($controlnavthumbs == 'nextgen_thumbs' || $controlnavthumbs == 'nextgen_original')
  358.       {
  359.         $js_output .= "\n    JJNGGUtils.wordpressThumbs('" . $html_id . "', " . ($controlnavthumbs == 'nextgen_thumbs' ? 'true' : 'false') . ");";
  360.       }
  361.       if($has_center && $thumbsgap != '')
  362.       {
  363.         $js_output .= "\n    JJNGGUtils.wordpressThumbsCenterFix('" . $html_id . "');";
  364.       }
  365.       $js_output .= "\n    jQuery('div#" . $html_id . " div.nivo-controlNav').css('visibility', 'visible');";
  366.     }
  367.     $js_output .= "\n  });";  
  368.     $js_output .= "\n</script>\n";
  369.    
  370. //  add_action( 'wp_head', function() { echo $js_output; } );
  371.     $output .= "<!--[js_output]-->".$js_output."<!--[/js_output]-->";
  372. /*
  373.     $temp = fopen($output_dir.$html_id.".js","w");
  374.     $js_output = str_replace(array("\n<script type=\"text/javascript\">\n","\n</script>\n"),array('',''),$js_output);
  375.     if (fwrite($temp, $js_output)) {
  376.         fclose($temp);
  377.     }
  378.     wp_enqueue_script( 'jquery-jjnggutils-'.$html_id, WPJJNGGJ_SLIDER_plugin_url( 'output/'.$html_id.'.js' ), array('jquery'), '', true );  
  379. */
  380.  
  381.     if($shortcode != '1')
  382.     {
  383.       echo $before_widget . "\n<ul class=\"ul_jj_slider\">\n    <li class=\"li_jj_slider\">" . $output . "\n    </li>\n  </ul>\n" . $after_widget;    
  384.     }
  385.     else
  386.     {
  387.       echo $output;
  388.     }
  389.    
  390.   }
  391.  
  392.   function get_val($instance, $key, $default = '', $escape = true)
  393.   {
  394.     $val = '';
  395.     if(isset($instance[$key]))
  396.     {
  397.       $val = trim($instance[$key]);
  398.     }
  399.     if($val == '')
  400.     {
  401.       $val = $default;
  402.     }
  403.     if($escape)
  404.     {
  405.       $val = esc_attr($val);
  406.     }
  407.     return $val;
  408.   }
  409.  
  410.   function get_val_numeric($instance, $key, $default = '')
  411.   {
  412.     $val = $this->get_val($instance, $key, $default, false);
  413.     if($val != '' && !is_numeric($val))
  414.     {
  415.       $val = '';
  416.     }
  417.     return $val;
  418.   }
  419.  
  420.   function quote_fix($phrase) {
  421.     return str_replace(array('"', '\"', "\'"), array("'", "'", "'"), $phrase);              
  422.   }
  423.  
  424.   function form($instance)
  425.   {
  426.     global $wpdb;
  427.     $instance = wp_parse_args((array) $instance, array(
  428.       'title' => '',
  429.       'gallery' => '',
  430.       'html_id' => 'slider',
  431.       'width' => '',
  432.       'height' => '',
  433.       'order' => 'random',
  434.       'tags' => '',
  435.       'shuffle' => 'false',
  436.       'max_pictures' => '',
  437.       'center' => '',
  438.      
  439.       // nivo settings
  440.       'effect' => '',
  441.       'slices' => '',
  442.       'boxcols' => '',
  443.       'boxrows' => '',
  444.       'animspeed' => '',
  445.       'pausetime' => '',
  446.       'startslide' => '',
  447.       'directionnav' => '',
  448.       'directionnavhide' => '',
  449.       'controlnav' => '',
  450.       'controlnavthumbs' => '',
  451.       'thumbswidth' => '',
  452.       'thumbsheight' => '',
  453.       'thumbscontainerheight' => '',
  454.       'thumbsgap' => '',
  455.       'controlnavthumbsfromrel' => '',
  456.       'controlnavthumbssearch' => '',
  457.       'controlnavthumbsreplace' => '',
  458.       'keyboardnav' => '',
  459.       'pauseonhover' => '',
  460.       'manualadvance' => '',
  461.       'captionopacity' => '',
  462.       'beforechange' => '',
  463.       'afterchange' => '',
  464.       'slideshowend' => '',
  465.       'lastslide' => '',
  466.       'afterload' => ''
  467.     ));
  468.     $order_values = array('random' => 'Random', 'asc' => 'Latest First', 'desc' => 'Oldest First', 'sortorder' => 'NextGen Sortorder');
  469.     $galleries = $wpdb->get_results("SELECT * FROM $wpdb->nggallery ORDER BY name ASC");
  470. ?>
  471.   <p>
  472.     <label for="<?php echo $this->get_field_id('title'); ?>"><strong>Widget title:</strong></label><br />
  473.     <input type="text" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo $instance['title']; ?>"  class="widefat" />
  474.   </p>
  475.   <p>
  476.     <label><strong>Select a gallery to use:</strong></label><br />
  477.     <?php if(is_array($galleries) && count($galleries) > 0) { ?>
  478.       <select id="<?php echo $this->get_field_id('gallery'); ?>" name="<?php echo $this->get_field_name('gallery'); ?>" class="widefat">
  479.         <option value="">All images</option>
  480.         <?php
  481.           $gallery_selected = '';        
  482.           foreach($galleries as $gallery)
  483.           {      
  484.             if($gallery->gid == $instance['gallery'])
  485.             {
  486.               $gallery_selected = " selected=\"selected\"";
  487.             }
  488.             else
  489.             {
  490.               $gallery_selected = "";
  491.             }
  492.             echo "<option value=\"" . $gallery->gid . "\"" . $gallery_selected . ">" . $gallery->name . "</option>";
  493.         } ?>
  494.       </select>
  495.     <?php }else{ ?>
  496.       No galleries found
  497.     <?php } ?>
  498.   </p>  
  499.   <p>
  500.     <label for="<?php echo $this->get_field_id('order'); ?>"><strong>Order:</strong></label><br />
  501.     <select id="<?php echo $this->get_field_id('order'); ?>" name="<?php echo $this->get_field_name('order'); ?>" class="widefat">
  502.       <?php
  503.         $order_selected = '';        
  504.         foreach($order_values as $key => $value)
  505.         {      
  506.           if($key == $instance['order'])
  507.           {
  508.             $order_selected = " selected=\"selected\"";
  509.           }
  510.           else
  511.           {
  512.             $order_selected = "";
  513.           }
  514.           echo "<option value=\"" . $key . "\"" . $order_selected . ">" . $value . "</option>";
  515.       } ?>
  516.     </select>
  517.   </p>
  518.   <p>
  519.     <label for="<?php echo $this->get_field_id('tags'); ?>"><strong>Only display images tagged:</strong></label><br /><small>comma separated list</small><br />
  520.     <input type="text" id="<?php echo $this->get_field_id('tags'); ?>" name="<?php echo $this->get_field_name('tags'); ?>" value="<?php echo $instance['tags']; ?>" class="widefat" />
  521.   </p>  
  522.   <p>
  523.     <label><strong>Shuffle:</strong> <small>(Only for random order)</small></label><br />
  524.     <input type="radio" id="<?php echo $this->get_field_id('shuffle'); ?>_true" name="<?php echo $this->get_field_name('shuffle'); ?>" value="true" style="vertical-align: middle;"<?php if($instance['shuffle'] == 'true') { echo " checked=\"checked\""; } ?> /><label for="<?php echo $this->get_field_id('shuffle'); ?>_true" style="vertical-align: middle;">true</label>
  525.     <input type="radio" id="<?php echo $this->get_field_id('shuffle'); ?>_false" name="<?php echo $this->get_field_name('shuffle'); ?>" value="false" style="vertical-align: middle;"<?php if($instance['shuffle'] == 'false') { echo " checked=\"checked\""; } ?> /><label for="<?php echo $this->get_field_id('shuffle'); ?>_false" style="vertical-align: middle;">false</label>          
  526.   </p>  
  527.   <p>
  528.     <label for="<?php echo $this->get_field_id('max_pictures'); ?>"><strong>Max pictures:</strong> <small>(Leave blank for all)</small></label><br />
  529.     <input type="text" id="<?php echo $this->get_field_id('max_pictures'); ?>" name="<?php echo $this->get_field_name('max_pictures'); ?>" value="<?php echo $instance['max_pictures']; ?>" size="3" />
  530.   </p>
  531.   <p>
  532.     <label for="<?php echo $this->get_field_id('html_id'); ?>"><strong>HTML id:</strong></label><br />
  533.     <input type="text" id="<?php echo $this->get_field_id('html_id'); ?>" name="<?php echo $this->get_field_name('html_id'); ?>" value="<?php echo $instance['html_id']; ?>" class="widefat" />
  534.   </p>
  535.   <p>
  536.     <label for="<?php echo $this->get_field_id('width'); ?>"><strong>Width:</strong>  <small>(Leave blank for auto)</small></label><br />
  537.     <input type="text" id="<?php echo $this->get_field_id('width'); ?>" name="<?php echo $this->get_field_name('width'); ?>" value="<?php echo $instance['width']; ?>" size="3" />
  538.   </p>
  539.   <p>
  540.     <label for="<?php echo $this->get_field_id('height'); ?>"><strong>Height:</strong> <small>(Leave blank for auto)</small></label><br />
  541.     <input type="text" id="<?php echo $this->get_field_id('height'); ?>" name="<?php echo $this->get_field_name('height'); ?>" value="<?php echo $instance['height']; ?>" size="3" />
  542.   </p>    
  543.   <p>
  544.     <input type="checkbox" id="<?php echo $this->get_field_id('center'); ?>" style="vertical-align: middle;" name="<?php echo $this->get_field_name('center'); ?>" value="1"<?php if($instance['center'] == '1') { echo " checked=\"checked\""; } ?> />
  545.     <label for="<?php echo $this->get_field_id('center'); ?>" style="vertical-align: middle;"><strong>Center content</strong></label><br />
  546.   </p>
  547.   <div class="javascript_settings" style="display: none; border: 1px solid #cccccc; background-color: #f0f0f0;">
  548.     <div style="padding: 10px;">
  549.       <p><a href="http://nivo.dev7studios.com/#usage" target="jj_nextgen_jquery">Visit Nivo configuration page</a></p>
  550.       <p>Leave blank to use defaults.</p>
  551.       <p>
  552.         <label for="<?php echo $this->get_field_id('effect'); ?>"><strong>effect:</strong> <small>(Leave blank for all)</small></label><br />
  553.         <input type="text" id="<?php echo $this->get_field_id('effect'); ?>" name="<?php echo $this->get_field_name('effect'); ?>" value="<?php echo $instance['effect']; ?>" class="widefat" />
  554.       </p>
  555.       <p>
  556.         <label for="<?php echo $this->get_field_id('slices'); ?>"><strong>slices:</strong></label>
  557.         <input type="text" id="<?php echo $this->get_field_id('slices'); ?>" name="<?php echo $this->get_field_name('slices'); ?>" value="<?php echo $instance['slices']; ?>" size="3" />
  558.       </p>      
  559.       <p>
  560.         <label for="<?php echo $this->get_field_id('boxcols'); ?>"><strong>boxCols:</strong></label>
  561.         <input type="text" id="<?php echo $this->get_field_id('boxcols'); ?>" name="<?php echo $this->get_field_name('boxcols'); ?>" value="<?php echo $instance['boxcols']; ?>" size="3" />
  562.       </p>
  563.       <p>
  564.         <label for="<?php echo $this->get_field_id('boxrows'); ?>"><strong>boxRows:</strong></label>
  565.         <input type="text" id="<?php echo $this->get_field_id('boxrows'); ?>" name="<?php echo $this->get_field_name('boxrows'); ?>" value="<?php echo $instance['boxrows']; ?>" size="3" />
  566.       </p>                              
  567.       <p>      
  568.         <label for="<?php echo $this->get_field_id('animspeed'); ?>"><strong>animSpeed:</strong></label>
  569.         <input type="text" id="<?php echo $this->get_field_id('animspeed'); ?>" name="<?php echo $this->get_field_name('animspeed'); ?>" value="<?php echo $instance['animspeed']; ?>" size="3" />
  570.       </p>
  571.       <p>
  572.         <label for="<?php echo $this->get_field_id('pausetime'); ?>"><strong>pauseTime:</strong></label>
  573.         <input type="text" id="<?php echo $this->get_field_id('pausetime'); ?>" name="<?php echo $this->get_field_name('pausetime'); ?>" value="<?php echo $instance['pausetime']; ?>" size="3" />
  574.       </p>
  575.       <p>
  576.         <label for="<?php echo $this->get_field_id('startslide'); ?>"><strong>startSlide:</strong></label>
  577.         <input type="text" id="<?php echo $this->get_field_id('startslide'); ?>" name="<?php echo $this->get_field_name('startslide'); ?>" value="<?php echo $instance['startslide']; ?>" size="3" />
  578.       </p>                  
  579.       <p>
  580.         <label><strong>directionNav:</strong></label><br />
  581.         <input type="radio" id="<?php echo $this->get_field_id('directionnav'); ?>_default" name="<?php echo $this->get_field_name('directionnav'); ?>" value="" style="vertical-align: middle;"<?php if($instance['directionnav'] == '') { echo " checked=\"checked\""; } ?> /><label for="<?php echo $this->get_field_id('directionnav'); ?>_default" style="vertical-align: middle;">default</label>
  582.         <input type="radio" id="<?php echo $this->get_field_id('directionnav'); ?>_true" name="<?php echo $this->get_field_name('directionnav'); ?>" value="true" style="vertical-align: middle;"<?php if($instance['directionnav'] == 'true') { echo " checked=\"checked\""; } ?> /><label for="<?php echo $this->get_field_id('directionnav'); ?>_true" style="vertical-align: middle;">true</label>
  583.         <input type="radio" id="<?php echo $this->get_field_id('directionnav'); ?>_false" name="<?php echo $this->get_field_name('directionnav'); ?>" value="false" style="vertical-align: middle;"<?php if($instance['directionnav'] == 'false') { echo " checked=\"checked\""; } ?> /><label for="<?php echo $this->get_field_id('directionnav'); ?>_false" style="vertical-align: middle;">false</label>          
  584.       </p>      
  585.       <p>
  586.         <label><strong>directionNavHide:</strong></label><br />
  587.         <input type="radio" id="<?php echo $this->get_field_id('directionnavhide'); ?>_default" name="<?php echo $this->get_field_name('directionnavhide'); ?>" value="" style="vertical-align: middle;"<?php if($instance['directionnavhide'] == '') { echo " checked=\"checked\""; } ?> /><label for="<?php echo $this->get_field_id('directionnavhide'); ?>_default" style="vertical-align: middle;">default</label>
  588.         <input type="radio" id="<?php echo $this->get_field_id('directionnavhide'); ?>_true" name="<?php echo $this->get_field_name('directionnavhide'); ?>" value="true" style="vertical-align: middle;"<?php if($instance['directionnavhide'] == 'true') { echo " checked=\"checked\""; } ?> /><label for="<?php echo $this->get_field_id('directionnavhide'); ?>_true" style="vertical-align: middle;">true</label>
  589.         <input type="radio" id="<?php echo $this->get_field_id('directionnavhide'); ?>_false" name="<?php echo $this->get_field_name('directionnavhide'); ?>" value="false" style="vertical-align: middle;"<?php if($instance['directionnavhide'] == 'false') { echo " checked=\"checked\""; } ?> /><label for="<?php echo $this->get_field_id('directionnavhide'); ?>_false" style="vertical-align: middle;">false</label>          
  590.       </p>
  591.       <p>
  592.         <label><strong>controlNav:</strong></label><br />
  593.         <input type="radio" id="<?php echo $this->get_field_id('controlnav'); ?>_default" name="<?php echo $this->get_field_name('controlnav'); ?>" value="" style="vertical-align: middle;"<?php if($instance['controlnav'] == '') { echo " checked=\"checked\""; } ?> /><label for="<?php echo $this->get_field_id('controlnav'); ?>_default" style="vertical-align: middle;">default</label>
  594.         <input type="radio" id="<?php echo $this->get_field_id('controlnav'); ?>_true" name="<?php echo $this->get_field_name('controlnav'); ?>" value="true" style="vertical-align: middle;"<?php if($instance['controlnav'] == 'true') { echo " checked=\"checked\""; } ?> /><label for="<?php echo $this->get_field_id('controlnav'); ?>_true" style="vertical-align: middle;">true</label>
  595.         <input type="radio" id="<?php echo $this->get_field_id('controlnav'); ?>_false" name="<?php echo $this->get_field_name('controlnav'); ?>" value="false" style="vertical-align: middle;"<?php if($instance['controlnav'] == 'false') { echo " checked=\"checked\""; } ?> /><label for="<?php echo $this->get_field_id('controlnav'); ?>_false" style="vertical-align: middle;">false</label>          
  596.       </p>
  597.       <p>
  598.         <label><strong>controlNavThumbs:</strong></label><br />
  599.         <input type="radio" id="<?php echo $this->get_field_id('controlnavthumbs'); ?>_default" name="<?php echo $this->get_field_name('controlnavthumbs'); ?>" value="" style="vertical-align: middle;"<?php if($instance['controlnavthumbs'] == '') { echo " checked=\"checked\""; } ?> /><label for="<?php echo $this->get_field_id('controlnavthumbs'); ?>_default" style="vertical-align: middle;">default</label>
  600.         <input type="radio" id="<?php echo $this->get_field_id('controlnavthumbs'); ?>_true" name="<?php echo $this->get_field_name('controlnavthumbs'); ?>" value="true" style="vertical-align: middle;"<?php if($instance['controlnavthumbs'] == 'true') { echo " checked=\"checked\""; } ?> /><label for="<?php echo $this->get_field_id('controlnavthumbs'); ?>_true" style="vertical-align: middle;">true</label>
  601.         <input type="radio" id="<?php echo $this->get_field_id('controlnavthumbs'); ?>_false" name="<?php echo $this->get_field_name('controlnavthumbs'); ?>" value="false" style="vertical-align: middle;"<?php if($instance['controlnavthumbs'] == 'false') { echo " checked=\"checked\""; } ?> /><label for="<?php echo $this->get_field_id('controlnavthumbs'); ?>_false" style="vertical-align: middle;">false</label>          
  602.         <br /><input type="radio" id="<?php echo $this->get_field_id('controlnavthumbs'); ?>_nextgen_thumbs" name="<?php echo $this->get_field_name('controlnavthumbs'); ?>" value="nextgen_thumbs" style="vertical-align: middle;"<?php if($instance['controlnavthumbs'] == 'nextgen_thumbs') { echo " checked=\"checked\""; } ?> /><label for="<?php echo $this->get_field_id('controlnavthumbs'); ?>_nextgen_thumbs" style="vertical-align: middle;">nextgen thumbs</label>                    
  603.         <br /><small>(auto link to NextGen thumbs)</small>
  604.         <br /><input type="radio" id="<?php echo $this->get_field_id('controlnavthumbs'); ?>_nextgen_original" name="<?php echo $this->get_field_name('controlnavthumbs'); ?>" value="nextgen_original" style="vertical-align: middle;"<?php if($instance['controlnavthumbs'] == 'nextgen_original') { echo " checked=\"checked\""; } ?> /><label for="<?php echo $this->get_field_id('controlnavthumbs'); ?>_nextgen_original" style="vertical-align: middle;">nextgen original</label>                    
  605.         <br /><small>(auto link to original image)</small>        
  606.       </p>      
  607.       <p>
  608.         <label for="<?php echo $this->get_field_id('thumbswidth'); ?>"><strong>thumbsWidth:</strong></label>
  609.         <input type="text" id="<?php echo $this->get_field_id('thumbswidth'); ?>" name="<?php echo $this->get_field_name('thumbswidth'); ?>" value="<?php echo $instance['thumbswidth']; ?>" size="3" />
  610.       </p>
  611.       <p>
  612.         <label for="<?php echo $this->get_field_id('thumbsheight'); ?>"><strong>thumbsHeight:</strong></label>
  613.         <input type="text" id="<?php echo $this->get_field_id('thumbsheight'); ?>" name="<?php echo $this->get_field_name('thumbsheight'); ?>" value="<?php echo $instance['thumbsheight']; ?>" size="3" />
  614.       </p>
  615.       <p>
  616.         <label for="<?php echo $this->get_field_id('thumbscontainerheight'); ?>"><strong>thumbsContainerHeight:</strong></label>
  617.         <input type="text" id="<?php echo $this->get_field_id('thumbscontainerheight'); ?>" name="<?php echo $this->get_field_name('thumbscontainerheight'); ?>" value="<?php echo $instance['thumbscontainerheight']; ?>" size="3" />
  618.         <br /><small>(eg, image rows x thumb height)</small>
  619.       </p>
  620.       <p>
  621.         <label for="<?php echo $this->get_field_id('thumbsgap'); ?>"><strong>thumbsGap:</strong></label>
  622.         <input type="text" id="<?php echo $this->get_field_id('thumbsgap'); ?>" name="<?php echo $this->get_field_name('thumbsgap'); ?>" value="<?php echo $instance['thumbsgap']; ?>" size="3" />
  623.       </p>                          
  624.       <p>
  625.         <label><strong>controlNavThumbsFromRel:</strong></label><br />
  626.         <input type="radio" id="<?php echo $this->get_field_id('controlnavthumbsfromrel'); ?>_default" name="<?php echo $this->get_field_name('controlnavthumbsfromrel'); ?>" value="" style="vertical-align: middle;"<?php if($instance['controlnavthumbsfromrel'] == '') { echo " checked=\"checked\""; } ?> /><label for="<?php echo $this->get_field_id('controlnavthumbsfromrel'); ?>_default" style="vertical-align: middle;">default</label>
  627.         <input type="radio" id="<?php echo $this->get_field_id('controlnavthumbsfromrel'); ?>_true" name="<?php echo $this->get_field_name('controlnavthumbsfromrel'); ?>" value="true" style="vertical-align: middle;"<?php if($instance['controlnavthumbsfromrel'] == 'true') { echo " checked=\"checked\""; } ?> /><label for="<?php echo $this->get_field_id('controlnavthumbsfromrel'); ?>_true" style="vertical-align: middle;">true</label>
  628.         <input type="radio" id="<?php echo $this->get_field_id('controlnavthumbsfromrel'); ?>_false" name="<?php echo $this->get_field_name('controlnavthumbsfromrel'); ?>" value="false" style="vertical-align: middle;"<?php if($instance['controlnavthumbsfromrel'] == 'false') { echo " checked=\"checked\""; } ?> /><label for="<?php echo $this->get_field_id('controlnavthumbsfromrel'); ?>_false" style="vertical-align: middle;">false</label>          
  629.       </p>
  630.       <p>        
  631.         <label for="<?php echo $this->get_field_id('controlnavthumbssearch'); ?>"><strong>controlNavThumbsSearch:</strong></label><br />
  632.         <input type="text" id="<?php echo $this->get_field_id('controlnavthumbssearch'); ?>" name="<?php echo $this->get_field_name('controlnavthumbssearch'); ?>" value="<?php echo $instance['controlnavthumbssearch']; ?>" class="widefat" />
  633.       </p>
  634.       <p>
  635.         <label for="<?php echo $this->get_field_id('controlnavthumbsreplace'); ?>"><strong>controlNavThumbsReplace:</strong></label><br />
  636.         <input type="text" id="<?php echo $this->get_field_id('controlnavthumbsreplace'); ?>" name="<?php echo $this->get_field_name('controlnavthumbsreplace'); ?>" value="<?php echo $instance['controlnavthumbsreplace']; ?>" class="widefat" />
  637.       </p>
  638.       <p>
  639.         <label><strong>keyboardNav:</strong></label><br />
  640.         <input type="radio" id="<?php echo $this->get_field_id('keyboardnav'); ?>_default" name="<?php echo $this->get_field_name('keyboardnav'); ?>" value="" style="vertical-align: middle;"<?php if($instance['keyboardnav'] == '') { echo " checked=\"checked\""; } ?> /><label for="<?php echo $this->get_field_id('keyboardnav'); ?>_default" style="vertical-align: middle;">default</label>
  641.         <input type="radio" id="<?php echo $this->get_field_id('keyboardnav'); ?>_true" name="<?php echo $this->get_field_name('keyboardnav'); ?>" value="true" style="vertical-align: middle;"<?php if($instance['keyboardnav'] == 'true') { echo " checked=\"checked\""; } ?> /><label for="<?php echo $this->get_field_id('keyboardnav'); ?>_true" style="vertical-align: middle;">true</label>
  642.         <input type="radio" id="<?php echo $this->get_field_id('keyboardnav'); ?>_false" name="<?php echo $this->get_field_name('keyboardnav'); ?>" value="false" style="vertical-align: middle;"<?php if($instance['keyboardnav'] == 'false') { echo " checked=\"checked\""; } ?> /><label for="<?php echo $this->get_field_id('keyboardnav'); ?>_false" style="vertical-align: middle;">false</label>          
  643.       </p>
  644.       <p>
  645.         <label><strong>pauseOnHover:</strong></label><br />
  646.         <input type="radio" id="<?php echo $this->get_field_id('pauseonhover'); ?>_default" name="<?php echo $this->get_field_name('pauseonhover'); ?>" value="" style="vertical-align: middle;"<?php if($instance['pauseonhover'] == '') { echo " checked=\"checked\""; } ?> /><label for="<?php echo $this->get_field_id('pauseonhover'); ?>_default" style="vertical-align: middle;">default</label>
  647.         <input type="radio" id="<?php echo $this->get_field_id('pauseonhover'); ?>_true" name="<?php echo $this->get_field_name('pauseonhover'); ?>" value="true" style="vertical-align: middle;"<?php if($instance['pauseonhover'] == 'true') { echo " checked=\"checked\""; } ?> /><label for="<?php echo $this->get_field_id('pauseonhover'); ?>_true" style="vertical-align: middle;">true</label>
  648.         <input type="radio" id="<?php echo $this->get_field_id('pauseonhover'); ?>_false" name="<?php echo $this->get_field_name('pauseonhover'); ?>" value="false" style="vertical-align: middle;"<?php if($instance['pauseonhover'] == 'false') { echo " checked=\"checked\""; } ?> /><label for="<?php echo $this->get_field_id('pauseonhover'); ?>_false" style="vertical-align: middle;">false</label>          
  649.       </p>
  650.       <p>
  651.         <label><strong>manualAdvance:</strong></label><br />
  652.         <input type="radio" id="<?php echo $this->get_field_id('manualadvance'); ?>_default" name="<?php echo $this->get_field_name('manualadvance'); ?>" value="" style="vertical-align: middle;"<?php if($instance['manualadvance'] == '') { echo " checked=\"checked\""; } ?> /><label for="<?php echo $this->get_field_id('manualadvance'); ?>_default" style="vertical-align: middle;">default</label>
  653.         <input type="radio" id="<?php echo $this->get_field_id('manualadvance'); ?>_true" name="<?php echo $this->get_field_name('manualadvance'); ?>" value="true" style="vertical-align: middle;"<?php if($instance['manualadvance'] == 'true') { echo " checked=\"checked\""; } ?> /><label for="<?php echo $this->get_field_id('manualadvance'); ?>_true" style="vertical-align: middle;">true</label>
  654.         <input type="radio" id="<?php echo $this->get_field_id('manualadvance'); ?>_false" name="<?php echo $this->get_field_name('manualadvance'); ?>" value="false" style="vertical-align: middle;"<?php if($instance['manualadvance'] == 'false') { echo " checked=\"checked\""; } ?> /><label for="<?php echo $this->get_field_id('manualadvance'); ?>_false" style="vertical-align: middle;">false</label>          
  655.       </p>
  656.       <p>
  657.         <input type="checkbox" id="<?php echo $this->get_field_id('disablecaptions'); ?>" style="vertical-align: middle;" name="<?php echo $this->get_field_name('disablecaptions'); ?>" value="1"<?php if($instance['disablecaptions'] == '1') { echo " checked=\"checked\""; } ?> />
  658.         <label for="<?php echo $this->get_field_id('disablecaptions'); ?>" style="vertical-align: middle;"><strong>Disable captions</strong></label><br />
  659.       </p>      
  660.       <p>
  661.         <label for="<?php echo $this->get_field_id('captionopacity'); ?>"><strong>captionOpacity:</strong></label>
  662.         <input type="text" id="<?php echo $this->get_field_id('captionopacity'); ?>" name="<?php echo $this->get_field_name('captionopacity'); ?>" value="<?php echo $instance['captionopacity']; ?>" size="3" />
  663.       </p>
  664.       <p>
  665.         <label for="<?php echo $this->get_field_id('beforechange'); ?>"><strong>beforeChange:</strong></label><br />
  666.         <input type="text" id="<?php echo $this->get_field_id('beforechange'); ?>" name="<?php echo $this->get_field_name('beforechange'); ?>" value="<?php echo $instance['beforechange']; ?>" class="widefat" />
  667.       </p>
  668.       <p>
  669.         <label for="<?php echo $this->get_field_id('afterchange'); ?>"><strong>afterChange:</strong></label><br />
  670.         <input type="text" id="<?php echo $this->get_field_id('afterchange'); ?>" name="<?php echo $this->get_field_name('afterchange'); ?>" value="<?php echo $instance['afterchange']; ?>" class="widefat" />
  671.       </p>
  672.       <p>
  673.         <label for="<?php echo $this->get_field_id('slideshowend'); ?>"><strong>slideshowEnd:</strong></label><br />
  674.         <input type="text" id="<?php echo $this->get_field_id('slideshowend'); ?>"" name="<?php echo $this->get_field_name('slideshowend'); ?>" value="<?php echo $instance['slideshowend']; ?>" class="widefat"" />
  675.       </p>
  676.       <p>
  677.         <label for="<?php echo $this->get_field_id('lastslide'); ?>"><strong>lastSlide:</strong></label><br />
  678.         <input type="text" id="<?php echo $this->get_field_id('lastslide'); ?>" name="<?php echo $this->get_field_name('lastslide'); ?>" value="<?php echo $instance['lastslide']; ?>" class="widefat" />
  679.       </p>
  680.       <p>
  681.         <label for="<?php echo $this->get_field_id('afterload'); ?>"><strong>afterLoad:</strong></label><br />
  682.         <input type="text" id="<?php echo $this->get_field_id('afterload'); ?>" name="<?php echo $this->get_field_name('afterload'); ?>" value="<?php echo $instance['afterload']; ?>" class="widefat" />
  683.       </p>                                                                              
  684.     </div>
  685.   </div>  
  686.   <p><a href="#" onclick="jQuery(this).parent().prev('div.javascript_settings').toggle();return false;">Nivo Slider Settings</a></p>    
  687. <?php
  688.   }
  689.  
  690.   function update($new_instance, $old_instance)
  691.   {
  692.     $new_instance['title'] = esc_attr($new_instance['title']);
  693.     return $new_instance;
  694.   }
  695. }
  696.  
  697. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement