1. <?php
  2. /*
  3. Plugin Name: Folder Gallery
  4. Version: 1.3
  5. Plugin URI: http://www.jalby.org/wordpress/
  6. Author: Vincent Jalby
  7. Author URI: http://www.jalby.org
  8. Description: DO NOT UPDATE THIS PLUGIN AUTOMATICALLY. There were changes made to the style.css and foldergallery.php files and these changes will be removed if you update automatically. DO NOT UPDATE THIS PLUGIN AUTOMATICALLY.
  9. Tags: gallery, folder, lightbox, lightview
  10. Requires: 3.5
  11. License: GPLv2
  12. License URI: http://www.gnu.org/licenses/gpl-2.0.html
  13. Text Domain: foldergallery
  14. Domain Path: /languages
  15. */
  16.  
  17. /*  Copyright 2013  Vincent Jalby  (wordpress /at/ jalby /dot/ org)
  18.  
  19.     This program is free software; you can redistribute it and/or modify
  20.     it under the terms of the GNU General Public License, version 2, as
  21.     published by the Free Software Foundation.
  22.  
  23.     This program is distributed in the hope that it will be useful,
  24.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  25.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  26.     GNU General Public License for more details.
  27.  
  28.     You should have received a copy of the GNU General Public License
  29.     along with this program; if not, write to the Free Software
  30.     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  31. */
  32.  
  33. new foldergallery();
  34.  
  35. class foldergallery{
  36.  
  37.     function foldergallery() {     
  38.         add_action( 'admin_menu', array( $this, 'fg_menu' ) ); 
  39.         add_action( 'admin_init', array( $this, 'fg_settings_init' ) );
  40.         add_action('plugins_loaded', array( $this, 'fg_init' ) );
  41.         add_action( 'wp_enqueue_scripts', array( $this, 'fg_styles' ) );
  42.         add_shortcode( 'foldergallery', array( $this, 'fg_gallery' ) );
  43.         add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'fg_plugin_action_links' ) );
  44.     }
  45.  
  46.     function fg_init() {
  47.         load_plugin_textdomain( 'foldergallery', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
  48.         $fg_options = get_option( 'FolderGallery' );
  49.         if ( empty( $fg_options ) ) {
  50.             update_option( 'FolderGallery', $this->fg_settings_default() );
  51.         }
  52.         if ( ! isset( $fg_options['engine'] ) ) {
  53.             $fg_options['engine'] = 'lightbox2';
  54.             update_option( 'FolderGallery', $fg_options );
  55.         }
  56.         if ( 'lightview' == $fg_options['engine'] ) {
  57.             if ( ! is_dir( plugin_dir_path( __FILE__ ) . 'lightview' ) ) {
  58.                 $fg_options['engine'] = 'lightbox2';
  59.                 update_option( 'FolderGallery', $fg_options );
  60.             }
  61.         }
  62.         if ( ! isset( $fg_options['thumbnails'] ) ) { // 1.1 update
  63.             $fg_options['thumbnails'] = 'all';
  64.             update_option( 'FolderGallery', $fg_options );
  65.         }
  66.         if ( ! isset( $fg_options['fb_title'] ) ) { // 1.2 update
  67.             $fg_options['fb_title'] = 'float';
  68.             update_option( 'FolderGallery', $fg_options );
  69.         }
  70.         if ( ! isset( $fg_options['fb_speed'] ) ) { // 1.3 update
  71.             $fg_options['subtitle'] = 'default';
  72.             $fg_options['fb_speed'] = 0;
  73.             update_option( 'FolderGallery', $fg_options );
  74.         }
  75.     }
  76.  
  77.     function fg_styles(){
  78.         $fg_options = get_option( 'FolderGallery' );
  79.         wp_enqueue_style( 'fg-style', plugins_url( '/css/style.css', __FILE__ ) );
  80.         switch ( $fg_options['engine'] ) {
  81.             case 'lightbox2' :
  82.                 wp_enqueue_style( 'fg-lightbox-style', plugins_url( '/css/lightbox.css', __FILE__ ) );
  83.             break;
  84.             case 'fancybox2' :
  85.                 wp_enqueue_style( 'fancybox-style', plugins_url( '/fancybox/source/jquery.fancybox.css', __FILE__ ) );
  86.             break;
  87.             case 'lightview' :
  88.                 wp_enqueue_style( 'lightview-style', plugins_url( '/lightview/css/lightview/lightview.css', __FILE__ ) );      
  89.             break;
  90.             case 'none' :
  91.                 // do nothing for now
  92.             break;
  93.         }
  94.     }
  95.  
  96.     function fg_scripts(){
  97.         static $firstcall = 1;
  98.         $fg_options = get_option( 'FolderGallery' );   
  99.         switch ( $fg_options['engine'] ) {
  100.             case 'lightbox2' :
  101.                 wp_enqueue_script( 'fg-lightbox-script', plugins_url( '/js/fg-lightbox.js', __FILE__ ), array( 'jquery' ) );
  102.                 if ( $firstcall ) {
  103.                     wp_localize_script( 'fg-lightbox-script', 'FGtrans', array(
  104.                         'labelImage' => __( 'Image', 'foldergallery' ),
  105.                         'labelOf'    => __( 'of', 'foldergallery' ),
  106.                         )
  107.                     );
  108.                     $firstcall = 0;
  109.                 }
  110.             break;
  111.             case 'fancybox2' :
  112.                 wp_enqueue_script( 'fancybox-script', plugins_url( '/fancybox/source/jquery.fancybox.pack.js', __FILE__ ), array( 'jquery' ) );
  113.                 wp_enqueue_script( 'fg-fancybox-script', plugins_url( '/js/fg-fancybox.js', __FILE__ ), array( 'jquery' ) );
  114.                 if ( $firstcall ) {
  115.                     wp_localize_script( 'fg-fancybox-script', 'FancyBoxGalleryOptions', array(
  116.                         'title' => $fg_options['fb_title'],
  117.                         'speed' => $fg_options['fb_speed'],
  118.                         )
  119.                     );
  120.                     $firstcall = 0;
  121.                 }
  122.             break;
  123.             case 'lightview' :
  124.                 global $is_IE;
  125.                 if ( $is_IE ) {
  126.                     wp_enqueue_script( 'excanvas', plugins_url( '/lightview/js/excanvas/excanvas.js', __FILE__  ), array( 'jquery' ) );
  127.                 }
  128.                 wp_enqueue_script( 'lightview_spinners', plugins_url( '/lightview/js/spinners/spinners.min.js', __FILE__ ), array( 'jquery' ) );
  129.                 wp_enqueue_script( 'lightview-script', plugins_url( '/lightview/js/lightview/lightview.js', __FILE__ ) );          
  130.             break;
  131.             case 'none' :
  132.                 // Do nothing for now
  133.             break;
  134.         }      
  135.     }
  136.  
  137.     /* --------- Folder Gallery Main Functions --------- */
  138.  
  139.     function save_thumbnail( $path, $savepath, $th_width, $th_height ) { // Save thumbnail
  140.         $image = wp_get_image_editor( $path );
  141.         if ( ! is_wp_error( $image ) ) {
  142.             if ( 0 == $th_height ) { // 0 height => auto
  143.                 $size = $image->get_size();
  144.                 $width = $size['width'];
  145.                 $height = $size['height'];
  146.                 $th_height = floor( $height * ( $th_width / $width ) );
  147.             }
  148.             $image->resize( $th_width, $th_height, true );
  149.             $image->save( $savepath );
  150.         }
  151.     }
  152.  
  153.     function file_array( $directory ) { // List all JPG & PNG files in $directory
  154.         $files = array();
  155.         if( $handle = opendir( $directory ) ) {
  156.             while ( false !== ( $file = readdir( $handle ) ) ) {
  157.                 $ext = strtolower( pathinfo( $file, PATHINFO_EXTENSION ) );
  158.                 if ( 'jpg' == $ext || 'png' == $ext ) {
  159.                     $files[] = $file;
  160.                 }
  161.             }
  162.             closedir( $handle );
  163.         }
  164.         sort( $files );
  165.         return $files;
  166.     }
  167.  
  168.     function filename_without_extension ( $filename ) {
  169.         $info = pathinfo($filename);
  170.         return basename($filename,'.'.$info['extension']);
  171.     }
  172.                
  173.     function fg_gallery( $atts ) { // Generate gallery
  174.         $fg_options = get_option( 'FolderGallery' );
  175.         extract( shortcode_atts( array(
  176.             'folder'  => 'wp-content/uploads/',
  177.             'title'   => 'My Gallery',
  178.             'width'   => $fg_options['thumbnails_width'],
  179.             'height'  => $fg_options['thumbnails_height'],
  180.             'columns' => $fg_options['columns'],
  181.             'margin'  => $fg_options['margin'],
  182.             'padding' => $fg_options['padding'],
  183.             'border'  => $fg_options['border'],
  184.             'thumbnails' => $fg_options['thumbnails'],
  185.             'options' => $fg_options['lw_options'],
  186.             'subtitle'=> $fg_options['subtitle'],
  187.         ), $atts ) );
  188.  
  189.         $folder = rtrim( $folder, '/' ); // Remove trailing / from path
  190.  
  191.         if ( !is_dir( $folder ) ) {
  192.             return '<p style="color:red;"><strong>' . __( 'Folder Gallery Error:', 'foldergallery' ) . '</strong> ' .
  193.                 sprintf( __( 'Unable to find the directory %s.', 'foldergallery' ), $folder ) . '</p>';
  194.         }
  195.  
  196.         $pictures = $this->file_array( $folder );
  197.  
  198.         $NoP = count( $pictures );     
  199.         if ( 0 == $NoP ) {
  200.             return '<p style="color:red;"><strong>' . __( 'Folder Gallery Error:', 'foldergallery' ) . '</strong> ' .
  201.                 sprintf( __( 'No picture available inside %s.', 'foldergallery' ), $folder ) . '</p>';
  202.         }
  203.    
  204.         $cache_folder = $folder . '/cache_' . $width . 'x' . $height;
  205.         if ( ! is_dir( $cache_folder ) ) {
  206.                 @mkdir( $cache_folder, 0777 );
  207.         }
  208.         if ( ! is_dir( $cache_folder ) ) {
  209.             return '<p style="color:red;"><strong>' . __( 'Folder Gallery Error:', 'foldergallery' ) . '</strong> ' .
  210.                 sprintf( __( 'Unable to create the thumbnails directory inside %s.', 'foldergallery' ), $folder ) . ' ' .
  211.                 __( 'Verify that this directory is writable (chmod 777).', 'foldergallery' ) . '</p>';
  212.         }
  213.            
  214.         $imgstyle = "margin:0px {$margin}px {$margin}px 0px;";
  215.         $imgstyle .= "padding:{$padding}px;";
  216.         $imgstyle .= "border-width:{$border}px;";
  217.  
  218.         //if ( 'all' != $thumbnails ) $columns = 0; // Moved below
  219.            
  220.         $this->fg_scripts();           
  221.         $lightbox_id = uniqid(); //md5( $folder . );
  222.         $gallery_code = '<div class="fg_gallery">';
  223.        
  224.         // If first picture == !!! then skip it (but use it as 'single' thumbnail).
  225.         if ( $this->filename_without_extension( $pictures[ 0 ] ) == '!!!' ) {
  226.             $start_idx = 1 ;       
  227.         } else {
  228.             $start_idx = 0 ;
  229.         }
  230.         // Trick to display only the first thumbnails.     
  231.         if ( intval($thumbnails) > 1 ) { // 1 = single should not be used
  232.             $max_thumbnails_idx = intval($thumbnails) - 1 + $start_idx;
  233.             $thumbnails = 'all';
  234.         } else {
  235.             $max_thumbnails_idx = $NoP - 1 + $start_idx;
  236.         }
  237.         // (single) thumbnail idx set as thumbnails=-n shortcode attribute
  238.         $thumbnail_idx = 0;
  239.         if ( intval($thumbnails) < 0 ) {
  240.             $thumbnail_idx = - intval($thumbnails) -1;
  241.             $thumbnails = 'single';
  242.         }
  243.        
  244.         for ( $idx = $start_idx ; $idx < $NoP ; $idx++ ) {
  245.             // Set the thumbnail to use, depending of thumbnails option.
  246.             if ( 'all' == $thumbnails ) {
  247.                 $thumbnail_idx = $idx; 
  248.             }
  249.             $thumbnail = $cache_folder . '/' . strtolower($pictures[ $thumbnail_idx ]);
  250.             // Generate thumbnail
  251.             if ( ! file_exists( $thumbnail ) ) {
  252.                 $this->save_thumbnail( $folder . '/' . $pictures[ $thumbnail_idx ], $thumbnail, $width, $height );
  253.             }
  254.             if ( ( $idx > $start_idx && 'all' != $thumbnails ) || $idx > $max_thumbnails_idx ) {
  255.                 $linkstyle = ' style="display:none;"';
  256.                 $columns = 0;
  257.             } else {
  258.                 $linkstyle ='';
  259.             }
  260.             // Set the Picture subtitle
  261.             switch ( $subtitle ) {
  262.                 case 'none' :
  263.                     $thesubtitle = '';
  264.                 break;
  265.                 case 'filename' :
  266.                     $thesubtitle = $pictures[ $idx ];
  267.                 break;
  268.                 case 'filenamewithoutextension' :
  269.                     $thesubtitle = $this->filename_without_extension( $pictures[ $idx ] );
  270.                 break;
  271.                 default :
  272.                     //$thesubtitle = ( 'all' == $thumbnails || $idx > 0 ) ? $title . ' (' . ($idx+1) . '/' . $NoP . ')' : $title;
  273.                     $thesubtitle = $title ;
  274.                     if ( 'lightbox2' != $fg_options['engine'] ) $thesubtitle .= ' (' . ($idx+1-$start_idx) . '/' . ($NoP-$start_idx) . ')' ;
  275.             }      
  276.             // Let's start
  277.             $gallery_code .= "\n";
  278.  
  279.             // Set the thumbnail/title  
  280.             if ( 'none' == $thumbnails ) {
  281.                 if ( $idx == $start_idx ) {
  282.                     $gallery_code .= '<span class="fg_title_link">' . $title . '</span></a>';
  283.                 } else {
  284.                     $gallery_code .= '</a>';
  285.                 }
  286.             } elseif ( 'single' == $thumbnails ) {
  287.                 if ( $idx == $start_idx ) {
  288.                     $gallery_code .= '<img src="' . home_url( '/' ) . $thumbnail . '" style="' . $imgstyle . '" alt="' . $title . '" /></a>';
  289.                     if ( $title != '' ) {
  290.                         $gallery_code .= '<br style="clear:both" /><span class="fg_title" style="margin:0 auto;">' . $title . '</span>';
  291.                     }
  292.                 } else {
  293.                     $gallery_code .= '</a>';
  294.                 }
  295.             } elseif ( $idx > $max_thumbnails_idx ) {
  296.                 $gallery_code .= '</a>';
  297.             } else {
  298.                 $gallery_code .= '<div class="fg-wrapper"><div class="fg-img"><div class="fg-subtitle">' . $thesubtitle . '</div><a title="' . $thesubtitle . '" href="' . home_url( '/' ) . $folder . '/' . $pictures[ $idx ] . '" data-lightbox="' . $lightbox_id . '"' . $linkstyle . '><img src="' . home_url( '/' ) . $thumbnail . '" style="' . $imgstyle . '" alt="' . $thesubtitle . '" /></a></div></div>';
  299.             }
  300.  
  301.             if ( $columns > 0 ) {
  302.                 if ( ( $idx + 1 ) % $columns == 0 ) $gallery_code .= "\n" . '<br style="clear: both" />';
  303.             }
  304.         }
  305.         $gallery_code .= "\n</div>\n";
  306.         if ( 'all' == $thumbnails ) $gallery_code .= '<br style="clear: both" />';
  307.         return $gallery_code;
  308.     }
  309.  
  310.     /* --------- Folder Gallery Settings --------- */
  311.  
  312.     function fg_menu() {
  313.         add_options_page( 'Folder Gallery Settings', 'Folder Gallery', 'manage_options', 'folder-gallery', array( $this, 'fg_settings' ) );
  314.     }
  315.  
  316.     function fg_settings_init() {
  317.         register_setting( 'FolderGallery', 'FolderGallery', array( $this, 'fg_settings_validate' ) );
  318.     }
  319.  
  320.     function fg_plugin_action_links( $links ) {
  321.         // Add a link to this plugin's settings page
  322.         $settings_link = '<a href="' . admin_url( 'options-general.php?page=folder-gallery' ) . '">' . __('Settings') . '</a>';
  323.         array_unshift( $links, $settings_link );
  324.         return $links;
  325.     }
  326.    
  327.    
  328.  
  329.     function fg_settings_validate( $input ) {
  330.         $input['columns']    = intval( $input['columns'] );
  331.         $input['thumbnails_width']  = intval( $input['thumbnails_width'] );
  332.             if ( 0 == $input['thumbnails_width'] ) $input['thumbnails_width'] = 150;
  333.         $input['thumbnails_height'] = intval( $input['thumbnails_height'] );
  334.         $input['border']            = intval( $input['border'] );
  335.         $input['padding']           = intval( $input['padding'] );
  336.         $input['margin']            = intval( $input['margin'] );
  337.         if ( ! in_array( $input['thumbnails'], array( 'all','none','single' ) ) ) $input['thumbnails'] = 'all';
  338.         if ( ! in_array( $input['fb_title'], array( 'inside','outside','float','over','null' ) ) ) $input['fb_title'] = 'all';
  339.         if ( ! in_array( $input['subtitle'], array( 'default','none','filename','filenamewithoutextension' ) ) ) $input['subtitle'] = 'default';
  340.         $input['fb_speed']            = intval( $input['fb_speed'] );
  341.         return $input;
  342.     }
  343.  
  344.     function fg_settings_default() {
  345.         $defaults = array(
  346.             'engine'            => 'lightbox2',
  347.             'border'            => 1,
  348.             'padding'           => 2,
  349.             'margin'            => 5,
  350.             'columns'           => 0,
  351.             'thumbnails_width'  => 160,
  352.             'thumbnails_height' => 0,
  353.             'lw_options'        => '',
  354.             'thumbnails'        => 'all',
  355.             'subtitle'          => 'default',
  356.             'fb_title'          => 'float',
  357.             'fb_speed'          => 0,
  358.         );
  359.         return $defaults;
  360.     }
  361.  
  362.     function fg_option_field( $field, $label, $extra = 'px' ) {
  363.         $fg_options = get_option( 'FolderGallery' );
  364.         echo '<tr valign="top">' . "\n";
  365.         echo '<th scope="row"><label for="' . $field . '">' . $label . "</label></th>\n";
  366.         echo '<td><input id="' . $field . '" name="FolderGallery[' . $field . ']" type="text" value="' . $fg_options["$field"] . '" class="small-text"> ' . $extra . "</td>\n";
  367.         echo "</tr>\n";
  368.     }
  369.  
  370.     function fg_settings()
  371.     {
  372.         $fg_options = get_option( 'FolderGallery' );
  373.         echo '<div class="wrap">' . "\n";
  374.         screen_icon();
  375.         echo '<h2>' . __( 'Folder Gallery Settings', 'foldergallery' ) . "</h2>\n";
  376.         echo '<form method="post" action="options.php">' . "\n";
  377.         settings_fields( 'FolderGallery' );
  378.         echo "\n" . '<table class="form-table"><tbody>' . "\n";
  379.        
  380.         echo '<tr valign="top">' . "\n";
  381.         echo '<th scope="row"><label for="engine">' . __( 'Gallery Engine', 'foldergallery' ) . '</label></th>' . "\n";
  382.         echo '<td><select name="FolderGallery[engine]" id="FolderGallery[engine]">' . "\n";
  383.        
  384.         echo "\t" . '<option value="lightbox2"';
  385.         if ( 'lightbox2' == $fg_options['engine'] ) echo ' selected="selected"';
  386.         echo '>Lightbox 2 (default)</option>' . "\n";
  387.        
  388.         echo "\t" . '<option value="fancybox2"';
  389.         if ( 'fancybox2' == $fg_options['engine'] ) echo ' selected="selected"';
  390.         echo '>Fancybox 2 (free for non commercial site)</option>' . "\n";
  391.  
  392.         if ( is_dir( plugin_dir_path( __FILE__ ) . 'lightview' ) ) {
  393.             echo "\t" . '<option value="lightview"';
  394.             if ( 'lightview' == $fg_options['engine'] ) echo ' selected="selected"';
  395.             echo '>Lightview 3 (free for non commercial site)</option>' . "\n";
  396.         }
  397.        
  398.         echo "\t" . '<option value="none"';
  399.         if ( 'none' == $fg_options['engine'] ) echo ' selected="selected"';
  400.         echo '>' . __( 'None', 'foldergallery') . '</option>' . "\n";
  401.  
  402.         echo "</select>\n";
  403.  
  404.         switch ( $fg_options['engine'] ) {
  405.             case 'lightbox2' :
  406.                 echo '<p><a href="http://lokeshdhakar.com/projects/lightbox2/" target="_blank">Lightbox</a> is completely free to use. ';
  407.                 echo 'If you are using Lightbox on a commercial project and feeling generous, consider a <a href="http://lokeshdhakar.com/projects/lightbox2/#donate" target="_blank">donation</a>. ';
  408.                 echo 'All donations are sincerely appreciated. Thanks!</p>';
  409.             break;
  410.             case 'fancybox2' :
  411.                 echo '<p><a href="http://fancyapps.com/fancybox/" target="_blank">Fancybox 2</a> is licensed under <a href="http://creativecommons.org/licenses/by-nc/3.0/" target="_blank">Creative Commons Attribution-NonCommercial 3.0 license</a>. ';
  412.                 echo 'You are free to use fancyBox for your personal or non-profit website projects.<br />';
  413.                 echo 'See <a href="http://fancyapps.com/fancybox/#license" target="_blank">http://fancyapps.com/fancybox</a> for details.</p>';
  414.             break;
  415.             case 'lightview' :
  416.                 echo '<p><a href="http://projects.nickstakenburg.com/lightview" target="_blank">Lightview</a> is licensed under the terms of the <a href="http://projects.nickstakenburg.com/lightview/license" target="_blank">Lightview License</a>. ';
  417.                 echo 'You are free to use it on non-commercial websites. Licenses are available for commercial use.</p>';
  418.             break;
  419.         }
  420.         echo "</td>\n</tr>\n";
  421.  
  422.         echo '<tr valign="top">' . "\n";
  423.         echo '<th scope="row"><label for="thumbnails">' . __( 'Display Thumbnails', 'foldergallery' ) . '</label></th>' . "\n";
  424.         echo '<td><select name="FolderGallery[thumbnails]" id="FolderGallery[thumbnails]">' . "\n";
  425.        
  426.         echo "\t" . '<option value="all"';
  427.         if ( 'all' == $fg_options['thumbnails'] ) echo ' selected="selected"';
  428.         echo '>' . __( 'All', 'foldergallery' ) . '</option>' . "\n";
  429.        
  430.         echo "\t" . '<option value="single"';
  431.         if ( 'single' == $fg_options['thumbnails'] ) echo ' selected="selected"';
  432.         echo '>' . __( 'Single', 'foldergallery' ) . '</option>' . "\n";
  433.  
  434.         echo "\t" . '<option value="none"';
  435.         if ( 'none' == $fg_options['thumbnails'] ) echo ' selected="selected"';
  436.         echo '>' . __( 'None', 'foldergallery' ) . '</option>' . "\n";
  437.         echo "</select>\n";
  438.         echo "</td>\n</tr>\n";
  439.  
  440.         $this->fg_option_field( 'columns', __( 'Columns', 'foldergallery' ), __( '(0 = auto)', 'foldergallery' ) );
  441.         $this->fg_option_field( 'thumbnails_width', __( 'Thumbnails Width', 'foldergallery' ) );
  442.         $this->fg_option_field( 'thumbnails_height', __( 'Thumbnails Height', 'foldergallery' ), ' px ' . __( '(0 = auto)', 'foldergallery' ) );
  443.         $this->fg_option_field( 'border', __( 'Picture Border', 'foldergallery' ) );
  444.         $this->fg_option_field( 'padding', __( 'Padding', 'foldergallery' ) );
  445.         $this->fg_option_field( 'margin', __( 'Margin', 'foldergallery' ) );
  446.         // Subtitle
  447.         echo '<tr valign="top">' . "\n";
  448.         echo '<th scope="row"><label for="subtitle">' . __( 'Picture Subtitle', 'foldergallery' ) . '</label></th>' . "\n";
  449.         echo '<td><select name="FolderGallery[subtitle]" id="FolderGallery[subtitle]">' . "\n";    
  450.         echo "\t" . '<option value="default"';
  451.         if ( 'default' == $fg_options['subtitle'] ) echo ' selected="selected"';
  452.         echo '>'. __('Default (Title + Picture Number)', 'foldergallery') . '</option>' . "\n";
  453.         echo "\t" . '<option value="filename"';
  454.         if ( 'filename' == $fg_options['subtitle'] ) echo ' selected="selected"';
  455.         echo '>' . __('Filename', 'foldergallery') . '</option>' . "\n";
  456.         echo "\t" . '<option value="filenamewithoutextension"';
  457.         if ( 'filenamewithoutextension' == $fg_options['subtitle'] ) echo ' selected="selected"';
  458.         echo '>' . __('Filename without extension', 'foldergallery') . '</option>' . "\n";     
  459.         echo "\t" . '<option value="none"';
  460.         if ( 'none' == $fg_options['subtitle'] ) echo ' selected="selected"';
  461.         echo '>' . __( 'None', 'foldergallery') . '</option>' . "\n";
  462.         echo "</select>\n";
  463.         echo "</td>\n</tr>\n";
  464.         // Lightview       
  465.         if ( 'lightview' == $fg_options['engine'] ) {          
  466.             echo '<tr valign="top">' . "\n";
  467.             echo '<th scope="row"><label for="lw_options">' . __( 'Lightview Options', 'foldergallery' ) . '</label></th>' . "\n";
  468.             echo '<td><textarea id="lw_options" rows="5" cols="50" name="FolderGallery[lw_options]" class="large-text code">' . $fg_options['lw_options'] . "</textarea>\n";
  469.             echo '<p class="description">' . __( 'Lightview default options, comma-separated.', 'foldergallery' );
  470.             echo " E.g., <code>controls: { slider: false }, skin: 'mac'</code>. ";
  471.             echo __( 'For details, see:', 'foldergallery' );
  472.             echo ' <a href="http://projects.nickstakenburg.com/lightview/documentation/options" target="_blank">http://projects.nickstakenburg.com/lightview</a>.</p>' . "\n";
  473.             echo "</td>\n";
  474.             echo "</tr>\n";
  475.         } else {
  476.             echo '<input type="hidden" name="FolderGallery[lw_options]" id="lw_options" value="' . $fg_options['lw_options'] . '" />';
  477.         }      
  478.         // Fancybox 2 options
  479.         if ( 'fancybox2' == $fg_options['engine'] ) {
  480.             echo '<tr valign="top">' . "\n";
  481.             echo '<th scope="row"><label for="fb_title">' . __( 'Fancybox Subtitle Style', 'foldergallery' ) . '</label></th>' . "\n";
  482.             echo '<td><select name="FolderGallery[fb_title]" id="FolderGallery[fb_title]">' . "\n";
  483.        
  484.             echo "\t" . '<option value="inside"';
  485.             if ( 'inside' == $fg_options['fb_title'] ) echo ' selected="selected"';
  486.             echo '>' . __( 'Inside', 'foldergallery' ) . '</option>' . "\n";
  487.        
  488.             echo "\t" . '<option value="outside"';
  489.             if ( 'outside' == $fg_options['fb_title'] ) echo ' selected="selected"';
  490.             echo '>' . __( 'Outside', 'foldergallery' ) . '</option>' . "\n";
  491.            
  492.             echo "\t" . '<option value="over"';
  493.             if ( 'over' == $fg_options['fb_title'] ) echo ' selected="selected"';
  494.             echo '>' . __( 'Over', 'foldergallery' ) . '</option>' . "\n";
  495.            
  496.             echo "\t" . '<option value="float"';
  497.             if ( 'float' == $fg_options['fb_title'] ) echo ' selected="selected"';
  498.             echo '>' . __( 'Float', 'foldergallery' ) . '</option>' . "\n";
  499.  
  500.             echo "\t" . '<option value="null"';
  501.             if ( 'null' == $fg_options['fb_title'] ) echo ' selected="selected"';
  502.             echo '>' . __( 'None', 'foldergallery' ) . '</option>' . "\n";
  503.             echo "</select>\n";
  504.             echo "</td>\n</tr>\n";
  505.            
  506.             $this->fg_option_field( 'fb_speed', __( 'Autoplay Speed', 'foldergallery' ), ' seconds ' . __( '(0 = off)', 'foldergallery' ) );
  507.            
  508.         } else {
  509.             echo '<input type="hidden" name="FolderGallery[fb_title]" id="fb_title" value="' . $fg_options['fb_title'] . '" />';
  510.             echo '<input type="hidden" name="FolderGallery[fb_speed]" id="fb_speed" value="' . $fg_options['fb_speed'] . '" />';
  511.         }
  512.         echo "</tbody></table>\n";
  513.         submit_button();
  514.         echo "</form></div>\n";
  515.     }
  516.        
  517. } //End Of Class
  518.  
  519. ?>