Advertisement
Guest User

nggScrollGallery-1.8.2-patched Line 288 - 297

a guest
Jul 14th, 2014
967
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 41.43 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: NextGEN Scroll Gallery
  4. Plugin URI: http://software.bmo-design.de/scrollgallery/wordpress-plugin-nextgen-scroll-gallery.html
  5. Description: Awesome free JavaScript gallery. <a href="http://software.bmo-design.de/scrollgallery.html">BMo-Design's Mootools Javascript ScrollGallery</a> as a Plugin for the Wordpress NextGEN Gallery.
  6. Author: Benedikt Morschheuser
  7. Author URI: http://bmo-design.de/
  8. Version: 1.8.2
  9.  
  10. #################################################################
  11.  
  12. The current version used the ScrollGallery 1.10. with mobile extension
  13.                    
  14. #################################################################
  15. */
  16. // Restrictions
  17.   if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You are not allowed to call this page directly.'); }
  18.  
  19. //###############################################################
  20.  
  21.   define('SCROLLGALLERY_SITEBASE_URL'  , get_option('siteurl'));
  22.   define('SCROLLGALLERY_URL', get_option('siteurl').'/wp-content/plugins/' . dirname(plugin_basename(__FILE__))); // get_bloginfo('wpurl')
  23.  
  24. //###############################################################
  25.    
  26. class ScrollGallery {
  27.    
  28.      private $nggsgversion = "1.8.2"; //Version
  29.      
  30.      function nggScrollGalleryReplaceShortcode($atts, $content = '') { //new Version, see http://codex.wordpress.org/Shortcode_API
  31.         global $wpdb;
  32.        
  33.         if(!empty($atts[0]))//fallback to old Version
  34.             if(substr($atts[0], 0, 1)=="=")//falls erstes Zeichen ein = -> alte Version.
  35.                 return "[scrollGallery".$atts[0]."]";
  36.        
  37.         //neue Version:
  38.         $sgconfig = $this->get_SGConfiguration($atts);
  39.        
  40.         if( !is_numeric($sgconfig["galleryID"]) )
  41.             $id = $wpdb->get_var( $wpdb->prepare ("SELECT gid FROM $wpdb->nggallery WHERE name = '%s' ", $sgconfig["galleryID"]) );
  42.  
  43.         if( !empty($sgconfig["galleryID"]) )
  44.             $out = $this->nggSGShow($sgconfig);
  45.         else
  46.             $out = '[Gallery not found]';
  47.            
  48.         return $out.$content;
  49.      }
  50.      function nggScrollGalleryReplaceShortcode_thumbsSolo($atts, $content = '') { //new Version, see http://codex.wordpress.org/Shortcode_API
  51.         global $wpdb;
  52.        
  53.         //neue Version:
  54.         $sgconfig = $this->get_SGConfiguration($atts);
  55.        
  56.         if( !is_numeric($sgconfig["galleryID"]) )
  57.             $id = $wpdb->get_var( $wpdb->prepare ("SELECT gid FROM $wpdb->nggallery WHERE name = '%s' ", $sgconfig["galleryID"]) );
  58.  
  59.         if( !empty($sgconfig["galleryID"]) )
  60.             $out = $this->nggSGShow($sgconfig, null, true, false);
  61.         else
  62.             $out = '[Gallery not found]';
  63.            
  64.         return $out.$content;
  65.      }
  66.      function nggScrollGalleryReplaceShortcode_imagesSolo($atts, $content = '') { //new Version, see http://codex.wordpress.org/Shortcode_API
  67.         global $wpdb;
  68.        
  69.         //neue Version:
  70.         $sgconfig = $this->get_SGConfiguration($atts);
  71.        
  72.         if( !is_numeric($sgconfig["galleryID"]) )
  73.             $id = $wpdb->get_var( $wpdb->prepare ("SELECT gid FROM $wpdb->nggallery WHERE name = '%s' ", $sgconfig["galleryID"]) );
  74.  
  75.         if( !empty($sgconfig["galleryID"]) )
  76.             $out = $this->nggSGShow($sgconfig, null, false, true);
  77.         else
  78.             $out = '[Gallery not found]';
  79.            
  80.         return $out.$content;
  81.      }
  82.      
  83.      function nggScrollGalleryReplace($content) {//old version
  84.         global $wpdb;
  85.        
  86.         $splitContent = $this->nggSGFindStringBetween($content, "[scrollGallery", "]");
  87.         (array_key_exists(0, $splitContent) ? $begin  = $splitContent[0] :$begin="");
  88.         (array_key_exists(1, $splitContent) ? $middle = $splitContent[1] :$middle="");
  89.         (array_key_exists(2, $splitContent) ? $end    = $splitContent[2] :$end="");
  90.          
  91.         if ($begin == $content) return $content;   
  92.    
  93.         // New Way [smooth=id:; width:; height:; timed:; delay:; transition:; arrows:; info:; carousel:; text:; open:; links:;]
  94.         $middleValues = substr($middle, 0, -1); // Remove last brackets
  95.         $middleValues = explode("=", $middleValues);
  96.         $middleValues = explode(";", $middleValues[1]);
  97.    
  98.         $final = Array();
  99.         foreach($middleValues as $value) {
  100.             if(preg_match("/:/",$value)){
  101.                 list($key, $value) = explode(":", $value);
  102.          
  103.                  if (trim($key) != "")
  104.                     $final[trim(strtolower($key))] = trim($value);
  105.             }
  106.         }
  107.         $sgconfig = $this->get_SGConfiguration($final);
  108.        
  109.         $sgconfig["galleryID"] = $wpdb->get_var("SELECT gid FROM $wpdb->nggallery WHERE gid  = '".$sgconfig["galleryID"]."' ");
  110.         if (! $sgconfig["galleryID"])
  111.             $sgconfig["galleryID"] = $wpdb->get_var("SELECT gid FROM $wpdb->nggallery WHERE name = '".$sgconfig["galleryID"]."' ");
  112.         if (! $sgconfig["galleryID"])
  113.             return $begin . $middle . $end;
  114.    
  115.         if ($sgconfig["galleryID"]) {
  116.             $middle = $this->nggSGShow($sgconfig);
  117.         }
  118.    
  119.         return $this->nggScrollGalleryReplace($begin . $middle . $end); // More than one gallery per post
  120.       }
  121.       function nggSGFindStringBetween($text, $begin, $end) {
  122.         if ( ($posBegin = stripos($text, $begin         )) === false) return Array($text, "");
  123.         if ( ($posEnd   = stripos($text, $end, $posBegin)) === false) return Array($text, "");
  124.        
  125.         $textBegin  = (string) substr($text, 0, $posBegin);
  126.         $textMiddle = (string) substr($text, $posBegin, $posEnd - $posBegin + strlen($end) );
  127.         $textEnd    = (string) substr($text, $posEnd + strlen($end) , strlen($text));
  128.         return Array($textBegin, $textMiddle, $textEnd);
  129.       }
  130.       function get_SGConfiguration($final) {
  131.         //build sgconfig from parameter and options
  132.         $options = get_option("SG_Options");
  133.         $sgconfig = array();      
  134.         $sgconfig["galleryID"]        = (int)     ( (array_key_exists("id"        , $final))? $final["id"]                    :0 );
  135.         $sgconfig["start"]            = (int)     ( (array_key_exists("start"     , $final))? $final["start"]                 : $options["SG_start"] );
  136.         $sgconfig["area"]             = (int)     ( (array_key_exists("area"      , $final))? $final["area"]                  : $options["SG_area"] );
  137.         $sgconfig["thumbarea"]        = (string)  ( (array_key_exists("thumbarea" , $final))? $final["thumbarea"]             : $options["SG_thumbarea"] );
  138.         $sgconfig["imagearea"]        = (string)  ( (array_key_exists("imagearea" , $final))? $final["imagearea"]             : $options["SG_imagearea"] );
  139.         $sgconfig["speed"]            = (string)  ( (array_key_exists("speed"     , $final))? $final["speed"]                 : $options["SG_speed"] );
  140.         $sgconfig["clickable"]        = (bool)    ( (array_key_exists("clickable" , $final))?($final["clickable"] == 'false'?false:true): $options["SG_clickable"] );
  141.         $sgconfig["autoScroll"]       = (bool)    ( (array_key_exists("autoscroll", $final))?($final["autoscroll"] == 'false'?false:true):  $options["SG_autoScroll"] );
  142.         $sgconfig["enableSwipeMode"]       = (bool)    ( (array_key_exists("enableswipemode", $final))?($final["enableswipemode"] == 'false'?false:true):  $options["SG_enableSwipeMode"] );
  143.         $sgconfig["useCaptions"]      = (bool)    ( (array_key_exists("usecaptions", $final))?($final["usecaptions"] == 'false'?false:true):  $options["SG_useCaptions"] );
  144.         $sgconfig["useDesc"]          = (bool)    ( (array_key_exists("usedesc", $final))?($final["usedesc"] == 'false'?false:true):  $options["SG_useDesc"] );
  145.         $sgconfig["thumbsdown"]       = (bool)    ( (array_key_exists("thumbsdown", $final))?($final["thumbsdown"] == 'false'?false:true):  $options["SG_thumbsdown"] );
  146.         $sgconfig["diashow"]          = (bool)    ( (array_key_exists("diashow", $final))?($final["diashow"] == 'false'?false:true):  $options["SG_diashow"] );
  147.         $sgconfig["diashowDelay"]     = (int)     ( (array_key_exists("diashowdelay"      , $final))? $final["diashowdelay"]                  : $options["SG_diashowDelay"] );
  148.         $sgconfig["thumbOpacity"]     = (int)     ( (array_key_exists("thumbopacity"      , $final))? $final["thumbopacity"]                  : $options["SG_thumbOpacity"] );
  149.         $sgconfig["width"]            = (int)     ( (array_key_exists("width"     , $final))? $final["width"]                 : $options["SG_width"] );
  150.         $sgconfig["height"]           = (int)     ( (array_key_exists("height"    , $final))? $final["height"]                : $options["SG_height"] );
  151.         $sgconfig["adjustImagesize"]  = (bool)    ( (array_key_exists("adjustimagesize", $final))?($final["adjustimagesize"] == 'false'?false:true):  $options["SG_adjustImagesize"] );
  152.         //$sgconfig["design"]           = (string)  $options["SG_design"] ;//page should use only one design
  153.         //margins
  154.         $dimensions = array("px","em","%","pt");
  155.         $margins = explode(" ", trim(str_replace($dimensions,"",$options["SG_design_margin"])));//we only work with px
  156.         $sgconfig["margin_top"]     =$margins[0];
  157.         $sgconfig["margin_right"]   =$margins[1];
  158.         $sgconfig["margin_bottom"]  =$margins[2];
  159.         $sgconfig["margin_left"]    =$margins[3];
  160.        
  161.         return $sgconfig;
  162.       }
  163.       function nggSGHead() {
  164.         $options = get_option("SG_Options");
  165.         // As a precaution, deregister any previous 'mootools' registrations.
  166.         wp_deregister_script(array('mootools'));
  167.         wp_register_script( 'mootools', SCROLLGALLERY_URL.'/scrollGallery/js/mootools-core-1.3.2-full-compat.js', false, '1.3.2');
  168.         wp_deregister_script(array('scrollGallery'));
  169.         wp_register_script( 'scrollGallery', SCROLLGALLERY_URL.'/scrollGallery/js/scrollGallery.js', array('mootools'), '1.12');
  170.         wp_deregister_script(array('powertools'));
  171.         wp_register_script( 'powertools', SCROLLGALLERY_URL.'/scrollGallery/js/powertools-mobile-1.1.1.js', array('mootools'), '1.1.1');
  172.        
  173.         wp_register_style('scrollGallery', SCROLLGALLERY_URL.'/scrollGallery/css/scrollGallery.css',false,$this->nggsgversion,'screen');
  174.         wp_register_style('scrollGalleryDesign', SCROLLGALLERY_URL.'/scrollGallery/css/'.$options['SG_design'],array('scrollGallery'),$this->nggsgversion,'screen');
  175.            
  176.         echo ' <!-- nextgen scrollGallery '.$this->nggsgversion.' -->
  177.            ';
  178.               if (function_exists('wp_enqueue_style')) {
  179.                   wp_enqueue_style('scrollGallery');
  180.                   wp_enqueue_style('scrollGalleryDesign');
  181.               }
  182.               if (function_exists('wp_enqueue_script')) {
  183.                 wp_enqueue_script('mootools');
  184.                 wp_enqueue_script('scrollGallery');
  185.                 wp_enqueue_script('powertools');
  186.               }
  187.       }
  188.       function nggSGShow($sgconfig, $pictures = null, $buildThumbs = true, $buildImages = true) {  
  189.           global $wpdb;  
  190.          
  191.           extract($sgconfig);
  192.        
  193.           // Get the pictures
  194.           if ($galleryID) {
  195.             $ngg_options = get_option ('ngg_options'); //NextGenGallery Options
  196.             $pictures    = $wpdb->get_results("SELECT t.*, tt.* FROM $wpdb->nggallery AS t INNER JOIN $wpdb->nggpictures AS tt ON t.gid = tt.galleryid WHERE t.gid = '$galleryID' AND tt.exclude != 1 ORDER BY tt.$ngg_options[galSort] $ngg_options[galSortDir] ");
  197.                        
  198.             $final = array();    
  199.             foreach($pictures as $picture) {
  200.               $aux = array();
  201.               $aux["title"] = stripslashes($picture->alttext); // $picture->alttext;
  202.               $aux["desc"]  = $picture->description;
  203.               $aux["link"]  = SCROLLGALLERY_SITEBASE_URL . "/" . $picture->path ."/" . $picture->filename;
  204.               $aux["img"]   = SCROLLGALLERY_SITEBASE_URL . "/" . $picture->path ."/" . $picture->filename;
  205.               $aux["img_abs_path"]   = ABSPATH . $picture->path ."/" . $picture->filename;
  206.               $aux["thumb"] = SCROLLGALLERY_SITEBASE_URL . "/" . $picture->path ."/thumbs/thumbs_" . $picture->filename;
  207.               $serialized_data = unserialize($picture->meta_data);
  208.               $aux["width"]  = $serialized_data["width"];
  209.               $aux["height"]  = $serialized_data["height"];
  210.               $final[] = $aux;
  211.             }
  212.            
  213.             $pictures = $final;
  214.            
  215.           } else {
  216.             $galleryID = rand();//falls pictures als parameter übergeben werden
  217.           }
  218.          
  219.           if (empty($pictures)) return "";
  220.          
  221.           // Build the ScrollGallery HTML
  222.           $out = '<script type="text/javascript">
  223.                     window.addEvent(\'domready\', function() {
  224.                         var scrollGalleryObj'.$galleryID.' = new scrollGallery({';
  225.           if(is_numeric($start)) $out .= 'start:'.$start.',';
  226.           if($area) $out .= 'area:'.$area.',';
  227.           $out .= 'thumbarea:"'.$thumbarea.'_'.$galleryID.'",';
  228.           $out .= 'imagearea:"'.$imagearea.'_'.$galleryID.'",';
  229.           if($speed) $out .= 'speed:'.$speed.',';
  230.           if(!$clickable) $out .= 'clickable:false,';
  231.           if($autoScroll) $out .= 'autoScroll:'.$autoScroll.',';
  232.           if($enableSwipeMode) $out .= 'enableSwipeMode:'.$enableSwipeMode.',';
  233.           if($useCaptions||$adjustImagesize) $out .= 'toElementClass:".caption_container",';
  234.           if($diashow&&$diashowDelay) $out .= 'diashowDelay:'.$diashowDelay.',';
  235.           if($thumbOpacity<100&&$thumbOpacity>0) $out .= 'thumbOpacity:'.$thumbOpacity.',';
  236.           $out = substr($out, 0, -1); // Remove last ,
  237.           $out .= '            
  238.                         });
  239.                     });
  240.                 </script>';
  241.           if($useCaptions==true||$adjustImagesize){
  242.                  $out .= '
  243.                     <!--[if lte IE 7]>
  244.                     <style type="text/css">
  245.                     .scrollgallery .imageareaContent .caption_container{display:inline; position:static;}
  246.                     .scrollgallery .imageareaContent .caption_container div{display:none; position:relative;}</style>
  247.                     <![endif]-->
  248.                 ';
  249.           }
  250.          
  251.           $outT  = ''; //Thumbs out
  252.           if($buildThumbs==true){  
  253.               $outT .= '    <div id="'.$thumbarea.'_'.$galleryID.'" class="thumbarea">
  254.                                 <div class="thumbareaContent">';
  255.                                     foreach ($pictures as $picture){
  256.                                         if ($picture["img"]) {
  257.                                             $descMetaInfo=$this->nggSG_get_picdescmeta($picture["desc"]);
  258.                                             $picture["desc"] = preg_replace("/\[.*\]/U",'', $picture["desc"], -1);//delete [...] in desc
  259.                                             if($descMetaInfo['thumblink']!=NULL){
  260.                                                 $thumblink_start='<a href='.$descMetaInfo['thumblink'].' target='.$descMetaInfo['thumblink_target'].' title="'.stripslashes($picture["desc"]).'">';
  261.                                                 $thumblink_end='</a>';
  262.                                             }else{
  263.                                                 $thumblink_start='';
  264.                                                 $thumblink_end='';
  265.                                             }
  266.                                             $outT .= $thumblink_start.'<img  src="'.$picture["thumb"].'" alt="NextGen ScrollGallery thumbnail" />'.$thumblink_end;
  267.                                         }
  268.                                     }
  269.               $outT .= '
  270.                                 </div>
  271.                             </div>';
  272.           }
  273.                        
  274.           $outI  = ''; //Images out
  275.           if($buildImages==true){          
  276.               $outI .= '     <div id="'.$imagearea.'_'.$galleryID.'" class="imagearea">
  277.                                   <div class="imageareaContent">';
  278.                                         foreach ($pictures as $picture){
  279.                                             if ($picture["img"]) {
  280.                                                 if($useCaptions==true||$adjustImagesize==true){
  281.                                                      $outI .= '<div class="caption_container">';
  282.                                                      if($useCaptions==true&&$useDesc==false&&$picture["title"]!="")
  283.                                                         $outI .='<div>'.$picture["title"].'</div>';
  284.                                                      if($useCaptions==true&&$useDesc==true&&stripslashes($picture["desc"])!="")
  285.                                                         $outI .='<div>'.stripslashes($picture["desc"]).'</div>';
  286.                                                 }
  287.                                                 if($adjustImagesize==true){
  288.                                                     $imgwidth  = $picture["width"];
  289.                                                     $imgheight = $picture["height"];
  290.                                                    
  291.                                                     if ($imgwidth == null || $imgheight == null)
  292.                                                     {
  293.                                                         $imgsize   = @getimagesize($picture["img"]);//0=width 1=height
  294.                                                         $imgwidth  = $imgsize[0];
  295.                                                         $imgheight = $imgsize[1];
  296.                                                     }
  297.                                                    
  298.                                                     if($width>$height){//landscape
  299.                                                         //get new size
  300.                                                         $newimageheight=$height;
  301.                                                         $newimagewidth=($imgwidth/$imgheight)*$newimageheight;
  302.                                                         //check ob passt, sonst weiter verkleinern
  303.                                                         if($newimagewidth>$width){
  304.                                                             $newimagewidth2=$width;
  305.                                                             $newimageheight=($newimageheight/$newimagewidth)*$newimagewidth2;
  306.                                                             $newimagewidth=$newimagewidth2;
  307.                                                         }
  308.                                                     }else{//portrait
  309.                                                         //get new size
  310.                                                         $newimagewidth=$width;
  311.                                                         $newimageheight=($imgheight/$imgwidth)*$newimagewidth;
  312.                                                         //check ob passt, sonst weiter verkleinern
  313.                                                         if($newimageheight>$height){
  314.                                                             $newimageheight2=$height;
  315.                                                             $newimagewidth=($newimagewidth/$newimageheight)*$newimageheight2;
  316.                                                             $newimageheight=$newimageheight2;
  317.                                                         }
  318.                                                     }
  319.                                                     $style='width:'.($newimagewidth).'px; height:'.($newimageheight).'px; max-width:'.($newimagewidth).'px; ';
  320.                                                     //build Margins
  321.                                                     if($newimagewidth<$width){
  322.                                                         $style.='margin-left:'.(($width-$newimagewidth)/2+$margin_left).'px; ';
  323.                                                         $style.='margin-right:'.(($width-$newimagewidth)/2+$margin_right).'px; ';
  324.                                                     }else{
  325.                                                         $style.='margin-left:'.($margin_left).'px; ';
  326.                                                         $style.='margin-right:'.($margin_right).'px; ';
  327.                                                     }
  328.                                                     if($newimageheight<$height){
  329.                                                         $style.='margin-top:'.(($height-$newimageheight)/2+$margin_top).'px; ';
  330.                                                         $style.='margin-bottom:'.(($height-$newimageheight)/2+$margin_bottom).'px; ';
  331.                                                     }else{
  332.                                                         $style.='margin-top:'.($margin_top).'px; ';
  333.                                                         $style.='margin-bottom:'.($margin_bottom).'px; ';
  334.                                                     }
  335.                                                 }else{
  336.                                                     $style='width:'.($width).'px; height:'.($height).'px; max-width:'.($width).'px;';
  337.                                                 }
  338.                                                 $descMetaInfo=$this->nggSG_get_picdescmeta($picture["desc"]);
  339.                                                 $picture["desc"] = preg_replace("/\[.*\]/U",'', $picture["desc"], -1);//delete [...] in desc
  340.                                                 if($descMetaInfo['imglink']!=NULL){
  341.                                                     $imglink_start='<a href='.$descMetaInfo['imglink'].' target='.$descMetaInfo['imglink_target'].' title="'.stripslashes($picture["desc"]).'">';
  342.                                                     $imglink_end='</a>';
  343.                                                 }else{
  344.                                                     $imglink_start='';
  345.                                                     $imglink_end='';
  346.                                                 }
  347.                                            
  348.                                                 $outI .= $imglink_start.'<img  src="'.$picture["img"].'" alt="'.$picture["title"].'" style="'.$style.'"/>'.$imglink_end;
  349.                                                 if($useCaptions==true||$adjustImagesize==true){
  350.                                                      $outI .= '</div>';
  351.                                                 }
  352.                                             }
  353.                                         }
  354.               $outI .= '
  355.                                   </div>
  356.                               </div>';
  357.           }
  358.           //Build out with $thumbsdown==true or false?
  359.           $out .= '
  360.              <div id="scrollgallery_'.$galleryID.'" class="scrollgallery" style="width:'.($width+26).'px;">';
  361.                     if(!$thumbsdown==true){
  362.                         if($buildThumbs==true)
  363.                             $out .= '<div class="scrollGalleryHead">'.$outT.'</div>';
  364.                         if($buildImages==true)
  365.                             $out .= '<div class="scrollGalleryFoot">'.$outI.'</div>';
  366.                     }else{
  367.                         if($buildImages==true)
  368.                             $out .= '<div class="scrollGalleryHead">'.$outI.'</div>';
  369.                         if($buildThumbs==true)
  370.                             $out .= '<div class="scrollGalleryFoot">'.$outT.'</div>';
  371.                     }
  372.           $out .= '
  373.              </div>';
  374.                    
  375.                    
  376.                    
  377.           return $out;  
  378.       }
  379.       function nggSG_get_picdescmeta($picdescmeta){
  380.           //BSP [scrollGallery imglink="http://www.bla.com" thumblink="http://www.blub.com" imglink_target="_blank" thumblink_target="_blank"]
  381.           $metaArray = array("imglink_target"=>"'_self'","thumblink_target"=>"'_self'");
  382.           $splitContent = $this->nggSGFindStringBetween($picdescmeta, "[scrollGallery", "]");
  383.           (array_key_exists(0, $splitContent) ? $begin  = $splitContent[0] :$begin="");
  384.           (array_key_exists(1, $splitContent) ? $middle = $splitContent[1] :$middle="");
  385.           (array_key_exists(2, $splitContent) ? $end    = $splitContent[2] :$end="");
  386.           if ($begin == $picdescmeta) return NULL;  //nichts gefunden
  387.           $middleValues = substr($middle, 0, -1); // Remove last brackets
  388.           $middleValues = explode("[scrollGallery", $middleValues);
  389.           $middleValues = explode(" ",trim($middleValues[1]));
  390.           foreach($middleValues as $value) {
  391.              if(preg_match("/=/",$value)){
  392.                 list($key, $value) = explode("=", $value, 2);//2 damit nur erstes = geteilt wird
  393.          
  394.                  if (trim($key) != "")
  395.                     $metaArray[trim(strtolower($key))] = stripslashes(trim($value));
  396.              }
  397.           }
  398.           return $metaArray;
  399.       }
  400.       //admin
  401.       function admin_menu() {  
  402.         add_menu_page('ScrollGallery', 'ScrollGallery', 'manage_options', plugin_basename( dirname(__FILE__)), array($this, 'admin_general_page')); // add Admin Menu
  403.       }
  404.       function admin_general_page() {
  405.         global $wpdb;
  406.         ?>    
  407.         <div class="wrap">
  408.           <h2>NextGen ScrollGallery</h2>  
  409.            <form action="options.php" method="post" id="post" name="post">  
  410.            <div class="metabox-holder has-right-sidebar" id="poststuff">
  411.                 <div class="inner-sidebar" id="side-info-column">
  412.                     <?php  do_meta_boxes( plugin_basename( dirname(__FILE__)), 'side', NULL); ?>
  413.                 </div>
  414.                 <div id="post-body">
  415.                     <div id="post-body-content">
  416.                         <div id="normal-sortables" class="meta-box-sortables">
  417.                             <div id="scrollGallery_main_box" class="postbox ">
  418.                                 <?php settings_fields('nggSG_options'); ?>
  419.                                 <?php do_settings_sections('nggSG_options_section_el'); ?>
  420.                                 <div class="inside">
  421.                                     <p><input name="Submit" type="submit" value="<?php esc_attr_e('Save Changes'); ?>" style="margin-left:220px"/></p>
  422.                                     <p>&nbsp;</p>
  423.                                     <p>To add a gallery to your post/page <br/>enter the tag <table style="background-color:#6CF; padding:4px;"><tr><td>[scrollGallery id=xxx]</td></tr></table><br/> in your text. You have to replace xxx with your gallery id like all NextGen Gallerys.</p>
  424.                                     <p>The options can be overridden in the post/page tag. For example: <table style="background-color:#6CF; padding:4px;"><tr><td>[scrollGallery id=1 start=5 autoScroll=false thumbsdown=true]</td></tr></table></p>
  425.                      
  426.                                     <p>That's it ... Have fun</p>
  427.                                 </div>
  428.                             </div>
  429.                          </div>
  430.                      </div>
  431.                      <br class="clear"/>
  432.                 </div>
  433.           </div>
  434.           </form>
  435.         </div>
  436.         <div class="clear"></div>
  437.         <?php
  438.      }  
  439.      function admin_init() {
  440.         global $scrollGallery;
  441.         if ( !defined('NGGALLERY_ABSPATH') ) {//check if NGG Plugin is activated
  442.             add_action('admin_notices', array($scrollGallery, 'admin_notices'));
  443.         }
  444.         //admin Header  
  445.         wp_deregister_script(array('plusone'));
  446.         wp_register_script( 'plusone', 'https://apis.google.com/js/plusone.js');
  447.         if (function_exists('wp_enqueue_script')) {
  448.             wp_enqueue_script('plusone');
  449.          }
  450.         //meta boxes
  451.         add_meta_box('scrollGallery_meta_box', 'Do you like this Plugin?', array($this, 'nggSG_like_MetaBox'), plugin_basename( dirname(__FILE__)), 'side', 'core');//add_meta_box('scrollGallery_meta_box', 'Do you like this Plugin?', array($scrollGallery, 'nggSG_like_MetaBox'), 'nextgen-scrollgallery', 'right', 'core');
  452.         //form
  453.         register_setting( 'nggSG_options', 'SG_Options', array($scrollGallery,'nggSG_options_validate') );
  454.         add_settings_section('nggSG_options_section', 'ScrollGallery Options', array($scrollGallery,'nggSG_options_section_html'), 'nggSG_options_section_el');
  455.         add_settings_field('nggSG_options_field0', 'Gallery design, see plugin-folder scrollGallery/css/', array($scrollGallery,'nggSG_options_field_html_design'), 'nggSG_options_section_el', 'nggSG_options_section');
  456.         add_settings_field('nggSG_options_field1', 'start: (number) start at picture number ... the first picture is number 0', array($scrollGallery,'nggSG_options_field_html_start'), 'nggSG_options_section_el', 'nggSG_options_section');
  457.         add_settings_field('nggSG_options_field2', 'area: (number) width of the area to scroll left or right', array($scrollGallery,'nggSG_options_field_html_area'), 'nggSG_options_section_el', 'nggSG_options_section');
  458.         add_settings_field('nggSG_options_field3', 'thumbarea: (string) div class name for the thumbs', array($scrollGallery,'nggSG_options_field_html_thumbarea'), 'nggSG_options_section_el', 'nggSG_options_section');
  459.         add_settings_field('nggSG_options_field4', 'imagearea: (string) div class name for the images', array($scrollGallery,'nggSG_options_field_html_imagearea'), 'nggSG_options_section_el', 'nggSG_options_section');
  460.         add_settings_field('nggSG_options_field5', 'speed: (number) 0<=speed<=1 thumb scroll speed', array($scrollGallery,'nggSG_options_field_html_speed'), 'nggSG_options_section_el', 'nggSG_options_section');
  461.         add_settings_field('nggSG_options_field6', 'clickable: (boolean) images can be clicked', array($scrollGallery,'nggSG_options_field_html_clickable'), 'nggSG_options_section_el', 'nggSG_options_section');
  462.         add_settings_field('nggSG_options_field7', 'autoScroll: (boolean) autoscroll thumbs', array($scrollGallery,'nggSG_options_field_html_autoScroll'), 'nggSG_options_section_el', 'nggSG_options_section');
  463.         add_settings_field('nggSG_options_field8', 'enableSwipeMode: (boolean) enable Swipe-Mode on touchable devices', array($scrollGallery,'nggSG_options_field_html_enableSwipeMode'), 'nggSG_options_section_el', 'nggSG_options_section');
  464.         add_settings_field('nggSG_options_field9', 'useCaptions: (boolean) use captions or not (IE7 is not supported)', array($scrollGallery,'nggSG_options_field_html_useCaptions'), 'nggSG_options_section_el', 'nggSG_options_section');
  465.         add_settings_field('nggSG_options_field10', 'useDesc: (boolean) use the image description as caption', array($scrollGallery,'nggSG_options_field_html_useDesc'), 'nggSG_options_section_el', 'nggSG_options_section');
  466.         add_settings_field('nggSG_options_field11', 'thumbsdown: (boolean) set the thumbs under the images', array($scrollGallery,'nggSG_options_field_html_thumbsdown'), 'nggSG_options_section_el', 'nggSG_options_section');
  467.         add_settings_field('nggSG_options_field12', 'diashow: (boolean) activates the diashow option', array($scrollGallery,'nggSG_options_field_html_diashow'), 'nggSG_options_section_el', 'nggSG_options_section');
  468.         add_settings_field('nggSG_options_field13', 'diashowDelay: (number) delay in seconds, have to be more than 1', array($scrollGallery,'nggSG_options_field_html_diashowDelay'), 'nggSG_options_section_el', 'nggSG_options_section');
  469.         add_settings_field('nggSG_options_field14', 'thumbOpacity: (number) optional opacity level for the tumbs in percent, have to be more than 0', array($scrollGallery,'nggSG_options_field_html_thumbOpacity'), 'nggSG_options_section_el', 'nggSG_options_section');
  470.         add_settings_field('nggSG_options_field15', 'width: (number) gallery width', array($scrollGallery,'nggSG_options_field_html_w'), 'nggSG_options_section_el', 'nggSG_options_section');
  471.         add_settings_field('nggSG_options_field16', 'height: (number) gallery height', array($scrollGallery,'nggSG_options_field_html_h'), 'nggSG_options_section_el', 'nggSG_options_section');
  472.         add_settings_field('nggSG_options_field17', 'adjustImagesize: (boolean) adjust the imagesize', array($scrollGallery,'nggSG_options_field_html_adjustImagesize'), 'nggSG_options_section_el', 'nggSG_options_section');
  473.        
  474.        
  475.         //BMo Expo Banner
  476.         add_meta_box('scrollGallery_meta_box2', 'Recommendation', array($this, 'nggSG_recommendation_MetaBox'), plugin_basename( dirname(__FILE__)), 'side', 'core');
  477.      }
  478.      function nggSG_options_section_html() {
  479.       // echo '<p>Here you can change the global ScrollGallery options:</p>';
  480.      }
  481.      function nggSG_options_field_html_design() {
  482.         $options = get_option("SG_Options");
  483.         $act_cssfile = $options['SG_design'];
  484.         echo '<select name="SG_Options[SG_design]" onchange="this.form.submit();">';
  485.                 $csslist = $this->nggSG_get_cssfiles();
  486.                 foreach ($csslist as $key =>$a_cssfile) {
  487.                     $css_name = $a_cssfile['Name'];
  488.                     if ($key == $act_cssfile) {
  489.                         $file_show = $key;
  490.                         $selected = " selected='selected'";
  491.                         $act_css_description = $a_cssfile['Description'];
  492.                         $act_css_author = $a_cssfile['Author'];
  493.                         $act_css_version = $a_cssfile['Version'];
  494.                         $act_css_margin = $a_cssfile['ImgMargins'];//needed margins around the img
  495.                         $act_css_name = esc_attr($css_name);
  496.                     }
  497.                     else $selected = '';
  498.                     $css_name = esc_attr($css_name);
  499.                     echo "\n\t<option value=\"$key\" $selected>$css_name</option>";
  500.                 }
  501.            
  502.         echo "</select>
  503.        
  504.         <p><strong>Active design:</strong> $act_css_name<br/>
  505.         Autor: $act_css_author<br/>
  506.         Version: $act_css_version<br/>
  507.         Description: $act_css_description</p>";
  508.      }
  509.      function nggSG_options_field_html_start() {
  510.         $options = get_option("SG_Options");
  511.         echo "<input  name='SG_Options[SG_start]' size='4' type='text' value='{$options['SG_start']}' />";
  512.      }
  513.      function nggSG_options_field_html_area() {
  514.         $options = get_option("SG_Options");
  515.         echo "<input  name='SG_Options[SG_area]' size='4' type='text' value='{$options['SG_area']}' />";
  516.      }
  517.      function nggSG_options_field_html_thumbarea() {
  518.         $options = get_option("SG_Options");
  519.         echo "<input  name='SG_Options[SG_thumbarea]' size='10' type='text' value='{$options['SG_thumbarea']}' />";
  520.      }
  521.      function nggSG_options_field_html_imagearea() {
  522.         $options = get_option("SG_Options");
  523.         echo "<input  name='SG_Options[SG_imagearea]' size='10' type='text' value='{$options['SG_imagearea']}' />";
  524.      }
  525.      function nggSG_options_field_html_speed() {
  526.         $options = get_option("SG_Options");
  527.         echo "<input  name='SG_Options[SG_speed]' size='4' type='text' value='{$options['SG_speed']}' />";
  528.      }
  529.      function nggSG_options_field_html_clickable() {
  530.         $options = get_option("SG_Options");
  531.         echo "<input type='checkbox' name='SG_Options[SG_clickable]' value='1' ".($options["SG_clickable"]?"checked='checked'":"")."/>";
  532.      }
  533.      function nggSG_options_field_html_autoScroll() {
  534.         $options = get_option("SG_Options");
  535.         echo "<input type='checkbox' name='SG_Options[SG_autoScroll]' value='1' ".($options["SG_autoScroll"]?"checked='checked'":"")."/>";
  536.      }
  537.      function nggSG_options_field_html_enableSwipeMode() {
  538.         $options = get_option("SG_Options");
  539.         echo "<input type='checkbox' name='SG_Options[SG_enableSwipeMode]' value='1' ".($options["SG_enableSwipeMode"]?"checked='checked'":"")."/>";
  540.      }
  541.      function nggSG_options_field_html_useCaptions() {
  542.         $options = get_option("SG_Options");
  543.         echo "<input type='checkbox' name='SG_Options[SG_useCaptions]' value='1' ".($options["SG_useCaptions"]?"checked='checked'":"")."/>";
  544.      }
  545.      function nggSG_options_field_html_useDesc() {
  546.         $options = get_option("SG_Options");
  547.         echo "<input type='checkbox' name='SG_Options[SG_useDesc]' value='1' ".($options["SG_useDesc"]?"checked='checked'":"")."/>";
  548.      }
  549.      function nggSG_options_field_html_thumbsdown() {
  550.         $options = get_option("SG_Options");
  551.         echo "<input type='checkbox' name='SG_Options[SG_thumbsdown]' value='1' ".($options["SG_thumbsdown"]?"checked='checked'":"")."/>";
  552.      }
  553.      function nggSG_options_field_html_diashow() {
  554.         $options = get_option("SG_Options");
  555.         echo "<input type='checkbox' name='SG_Options[SG_diashow]' value='1' ".($options["SG_diashow"]?"checked='checked'":"")."/>";
  556.      }
  557.      function nggSG_options_field_html_diashowDelay() {
  558.         $options = get_option("SG_Options");
  559.         echo "<input  name='SG_Options[SG_diashowDelay]' size='4' type='text' value='{$options['SG_diashowDelay']}' />";
  560.      }
  561.      function nggSG_options_field_html_thumbOpacity() {
  562.         $options = get_option("SG_Options");
  563.         echo "<input  name='SG_Options[SG_thumbOpacity]' size='4' type='text' value='{$options['SG_thumbOpacity']}' />";
  564.      }
  565.      function nggSG_options_field_html_w() {
  566.         $options = get_option("SG_Options");
  567.         echo "<input  name='SG_Options[SG_width]' size='4' type='text' value='{$options['SG_width']}' />";
  568.      }
  569.      function nggSG_options_field_html_h() {
  570.         $options = get_option("SG_Options");
  571.         echo "<input  name='SG_Options[SG_height]' size='4' type='text' value='{$options['SG_height']}' />";
  572.      }
  573.      function nggSG_options_field_html_adjustImagesize() {
  574.         $options = get_option("SG_Options");
  575.         echo "<input type='checkbox' name='SG_Options[SG_adjustImagesize]' value='1' ".($options["SG_adjustImagesize"]?"checked='checked'":"")."/>";
  576.      }
  577.      function nggSG_options_validate($input) {
  578.        
  579.         $input['SG_design']  = (string) (isset( $input['SG_design'] ) ? htmlspecialchars(stripslashes($input['SG_design']), ENT_QUOTES, 'UTF-8') : "scrollGallery_greyDesign.css");
  580.         $input['SG_start']  = (int) (is_numeric( $input['SG_start'] ) ? $input['SG_start'] : 0);
  581.         $input['SG_area']  = (int) is_numeric( $input['SG_area'] ) ? $input['SG_area'] : 200;
  582.         $input['SG_thumbarea']  = (string) (isset( $input['SG_thumbarea'] ) ? htmlspecialchars(stripslashes($input['SG_thumbarea']), ENT_QUOTES, 'UTF-8') : "thumbarea");
  583.         $input['SG_imagearea']  = (string) (isset( $input['SG_imagearea'] ) ? htmlspecialchars(stripslashes($input['SG_imagearea']), ENT_QUOTES, 'UTF-8') : "imagearea");
  584.         $input['SG_speed']  = (string) (isset( $input['SG_speed'] ) ? htmlspecialchars(stripslashes($input['SG_speed']), ENT_QUOTES, 'UTF-8') : "0.1");
  585.         $input['SG_clickable']  = (bool) (isset( $input['SG_clickable'] ) ? 1 : 0);
  586.         $input['SG_autoScroll']  = (bool) (isset( $input['SG_autoScroll'] ) ? 1 : 0);
  587.         $input['SG_enableSwipeMode']  = (bool) (isset( $input['SG_enableSwipeMode'] ) ? 1 : 0);
  588.         $input['SG_useCaptions']  = (bool) (isset( $input['SG_useCaptions'] ) ? 1 : 0);
  589.         $input['SG_useDesc']  = (bool) (isset( $input['SG_useDesc'] ) ? 1 : 0);
  590.         $input['SG_thumbsdown']  = (bool) (isset( $input['SG_thumbsdown'] ) ? 1 : 0);
  591.         $input['SG_diashow']    = (bool) (isset( $input['SG_diashow'] ) ? 1 : 0);
  592.         $input['SG_diashowDelay']  = (int) is_numeric( $input['SG_diashowDelay'] ) ? $input['SG_diashowDelay'] : 4;
  593.         $input['SG_thumbOpacity']  = (int) is_numeric( $input['SG_thumbOpacity'] ) ? $input['SG_thumbOpacity'] : 100;
  594.         $input['SG_width']  = (int) (is_numeric( $input['SG_width'] ) ? $input['SG_width'] : 640);
  595.         $input['SG_height']  = (int) (is_numeric( $input['SG_height'] ) ? $input['SG_height'] : 480);
  596.         $input['SG_adjustImagesize']  = (bool) (isset( $input['SG_adjustImagesize'] ) ? 1 : 0);
  597.        
  598.         //save margins
  599.         $act_cssfile = $input['SG_design'];
  600.         $csslist = $this->nggSG_get_cssfiles();
  601.         foreach ($csslist as $key =>$a_cssfile) {
  602.             if ($key == $act_cssfile) {
  603.                 $input['SG_design_margin'] = (string) ((isset( $a_cssfile['ImgMargins'] )&&$a_cssfile['ImgMargins']!='') ?  htmlspecialchars(stripslashes($a_cssfile['ImgMargins'])) : "0px 0px 0px 0px");//needed margins around the img
  604.             }
  605.         }
  606.         return $input;
  607.      }
  608.      function admin_notices() {
  609.         if ( !defined('NGGALLERY_ABSPATH') ) {//check if NGG Plugin is activated
  610.             $this->show_message("In order to use the scrollGallery, you have to install and activate the plugin <strong><a href='http://wordpress.org/extend/plugins/nextgen-gallery/' target='_blank'>NextGEN Gallery</a></strong>!");
  611.         }
  612.      }
  613.      function show_error($message) {
  614.         echo '<div class="wrap"><h2></h2><div class="error" id="error"><p>' . $message . '</p></div></div>';
  615.      }
  616.      function show_message($message) {
  617.         echo '<div class="wrap"><h2></h2><div class="updated fade" id="message"><p>' . $message . '</p></div></div>';
  618.      }
  619.      /**********************************************************/
  620.      // ### Code from wordpress plugin NGG
  621.      // read in the css files
  622.      function nggSG_get_cssfiles() {
  623.        
  624.         global $cssfiles;
  625.        
  626.         if (isset ($cssfiles)) {
  627.             return $cssfiles;
  628.         }
  629.    
  630.         $cssfiles = array ();
  631.        
  632.         $plugin_root = ABSPATH.'wp-content/plugins/nextgen-scrollgallery/scrollGallery/css';
  633.         $plugins_dir = @ dir($plugin_root);
  634.        
  635.         if ($plugins_dir) {
  636.             while (($file = $plugins_dir->read()) !== false) {
  637.                 if (preg_match('|^\.+$|', $file))
  638.                     continue;
  639.                 if (is_dir($plugin_root.'/'.$file)) {
  640.                     $plugins_subdir = @ dir($plugin_root.'/'.$file);
  641.                     if ($plugins_subdir) {
  642.                         while (($subfile = $plugins_subdir->read()) !== false) {
  643.                             if (preg_match('|^\.+$|', $subfile))
  644.                                 continue;
  645.                             if (preg_match('|\.css$|', $subfile))
  646.                                 $plugin_files[] = "$file/$subfile";
  647.                         }
  648.                     }
  649.                 } else {
  650.                     if (preg_match('|\.css$|', $file))
  651.                         $plugin_files[] = $file;
  652.                 }
  653.             }
  654.         }
  655.         if ( !$plugins_dir || !$plugin_files )
  656.             return $cssfiles;
  657.    
  658.         foreach ( $plugin_files as $plugin_file ) {
  659.             if ( !is_readable("$plugin_root/$plugin_file"))
  660.                 continue;
  661.    
  662.             $plugin_data = $this->nggSG_get_cssfiles_data("$plugin_root/$plugin_file");
  663.    
  664.             if ( empty ($plugin_data['Name']) )
  665.                 continue;
  666.    
  667.             $cssfiles[plugin_basename($plugin_file)] = $plugin_data;
  668.         }
  669.    
  670.         uasort($cssfiles, create_function('$a, $b', 'return strnatcasecmp($a["Name"], $b["Name"]);'));
  671.    
  672.         return $cssfiles;
  673.      }
  674.      // parse the Header information
  675.      function nggSG_get_cssfiles_data($plugin_file) {
  676.         $plugin_data = implode('', file($plugin_file));
  677.         preg_match("|CSS Name:(.*)|i", $plugin_data, $plugin_name);
  678.         preg_match("|Description:(.*)|i", $plugin_data, $description);
  679.         preg_match("|Author:(.*)|i", $plugin_data, $author_name);
  680.         if (preg_match("|Version:(.*)|i", $plugin_data, $version))
  681.             $version = trim($version[1]);
  682.         else
  683.             $version = '';
  684.        
  685.         if (preg_match("|ImgMargins:(.*)|i", $plugin_data, $img_margins)){
  686.             $img_margins = preg_replace('/\\\s\\\s+/', ' ',trim($img_margins[1]));//delete more than one spaces
  687.             if (substr($img_margins, -1) == ';') { //and the ;
  688.                 $img_margins = substr($img_margins, 0, -1);
  689.             }  
  690.         }else{
  691.             $img_margins = '';
  692.         }
  693.         $description = wptexturize(trim($description[1]));
  694.         $name = trim($plugin_name[1]);
  695.         $author = trim($author_name[1]);
  696.    
  697.         return array ('Name' => $name, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'ImgMargins' => $img_margins );
  698.      }
  699.      function nggSG_like_MetaBox(){
  700.          echo '<p>This plugin is developed by <br/><a href="http://www.BMo-Design.de" target="_blank">Benedikt Morschheuser</a>.<br/>Any kind of contribution would be highly appreciated. Thank you!</p>
  701.          <ul>
  702.             <li>If you like it, please...</li>
  703.             <li><a href="http://wordpress.org/extend/plugins/nextgen-scrollgallery/" target="_blank">rate it at wordpress.org</a> &diams;</li>
  704.             <li><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4AWSR2J4DK2FU" target="_blank">donate my work</a> &hearts;</li>
  705.             <li><a href="http://bmo-design.de" target="_blank">set a link to my website</a> &rarr;</li>
  706.             <li>or give me a <g:plusone size="small"  href="http://software.bmo-design.de/scrollgallery/wordpress-plugin-nextgen-scroll-gallery.html"></g:plusone></li>
  707.             <li>&nbsp;</li>
  708.             <li>If you are a stylesheet-designer, send me your <a href="http://bmo-design.de/kontakt/" target="_blank">custom gallery css</a> &raquo;</li>
  709.             <li>&nbsp;</li>
  710.         </ul>';
  711.      }
  712.      function nggSG_recommendation_MetaBox(){
  713.           echo '<p><a target="_blank" href="http://wordpress.org/plugins/bmo-expo/"><img src="http://s.wordpress.org/plugins/bmo-expo/screenshot-1.png" width="100%"/></a></p>
  714.           <p>Thank you for downloading and using my plugin! The great success of the plugin has made me very happy. Due to the different scenarios in which the plugin was used I recognized some problems and optimization possibilities. Few months ago I decided to develop a completely new version from sketch.
  715. Based on jQuery, with a new HTML structure, better usability and more features.
  716. I am proudly present you the <a target="_blank" href="http://wordpress.org/plugins/bmo-expo/">BMo Expo</a>.<br/>
  717. I look forward to your downloads and feedback.<br/>
  718. <br/>
  719. Best regards<br/>
  720. Benedikt</p>';
  721.      }
  722.      function nggSGRegisterPluginLinks($links, $file) {
  723.         $plugin = plugin_basename(__FILE__);
  724.         if ($file == $plugin) {
  725.             return array_merge(
  726.                 $links,
  727.                 array( sprintf( '<a href="admin.php?page=%s">%s</a>', plugin_basename( dirname(__FILE__)), __('Settings') ), '<g:plusone size="small"  href="http://software.bmo-design.de/scrollgallery/wordpress-plugin-nextgen-scroll-gallery.html"></g:plusone>', 'Switch to my new gallery-plugin <a href="http://wordpress.org/plugins/bmo-expo/" target="_blank" >BMo-Expo</a>.' )
  728.             );
  729.         }
  730.         return $links;
  731.      }
  732.      //install
  733.      function activation() {
  734.         $options = array(
  735.             'SG_design'=>'scrollGallery_greyDesign.css',
  736.             'SG_design_margin'=>'0px 0px 0px 0px',
  737.             'SG_start'=>'0',
  738.             'SG_area'=>'200',
  739.             'SG_thumbarea'=>'thumbarea',
  740.             'SG_imagearea'=>'imagearea',
  741.             'SG_speed'=>'0.1',
  742.             'SG_clickable'=> true,
  743.             'SG_autoScroll'=> true,
  744.             'SG_enableSwipeMode'=> true,
  745.             'SG_useCaptions'=> false,
  746.             'SG_useDesc'=> false,
  747.             'SG_thumbsdown'=> false,
  748.             'SG_diashow'=> false,
  749.             'SG_diashowDelay'=> '4',
  750.             'SG_thumbOpacity'=>'100',
  751.             'SG_width'=>'640',
  752.             'SG_height'=>'480',
  753.             'SG_adjustImagesize'=> true,);
  754.         add_option("SG_Options",$options);//It does nothing if the option already exists.
  755.      }
  756.      function deactivation() {
  757.         wp_deregister_script(array('mootools'));
  758.         wp_deregister_script(array('scrollGallery'));
  759.      }
  760. }
  761.  
  762. $scrollGallery = new ScrollGallery();
  763.  
  764. if (isset($scrollGallery)) {
  765.     // Plugin installieren bei aktivate
  766.     register_activation_hook( __FILE__,  array($scrollGallery, 'activation'));
  767.     register_deactivation_hook(__FILE__, array($scrollGallery, 'deactivation'));
  768.    
  769.     add_action('admin_menu' , array($scrollGallery, 'admin_menu'));//add menu
  770.     add_action('admin_init', array($scrollGallery, 'admin_init'));//init settings for Admin Page
  771.     add_filter( 'plugin_row_meta', array($scrollGallery,'nggSGRegisterPluginLinks'), 10, 2 );
  772.     //
  773.     add_filter('the_content', array($scrollGallery, 'nggScrollGalleryReplace'));//replace content, old Version
  774.     add_shortcode('scrollGallery', array($scrollGallery, 'nggScrollGalleryReplaceShortcode'));//replace the shortcode, everywhere, new Version
  775.     add_shortcode('sG_thumbsSolo', array($scrollGallery, 'nggScrollGalleryReplaceShortcode_thumbsSolo'));
  776.     add_shortcode('sG_imagesSolo', array($scrollGallery, 'nggScrollGalleryReplaceShortcode_imagesSolo'));
  777.     //add_filter('the_excerpt', array($scrollGallery, 'nggScrollGalleryReplace'));//replace content in the_excerpt, Uncomment it on your own risk
  778.     // Hook wp_head to add css
  779.     add_action('wp_head'   , array($scrollGallery,'nggSGHead'),1);
  780. }
  781.  
  782. //Deinstall (outside Class)
  783. if ( function_exists('register_uninstall_hook') )
  784.     register_uninstall_hook(__FILE__, 'deinstall');
  785.  
  786. function deinstall() {
  787.     delete_option("SG_Options");
  788. }
  789. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement