Advertisement
Guest User

photospace php

a guest
May 28th, 2012
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 26.99 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: Photospace
  4. Plugin URI: http://thriveweb.com.au/the-lab/wordpress-gallery-plugin-photospace-2/
  5. Description: A image gallery plugin for WordPress built using Galleriffic.
  6. <a href="http://www.twospy.com/galleriffic/>galleriffic</a>
  7. Author: Dean Oakley
  8. Author URI: http://deanoakley.com/
  9. Version: 2.2.5
  10. */
  11.  
  12. /*  Copyright 2010  Dean Oakley  (email : contact@deanoakley.com)
  13.  
  14.     This program is free software; you can redistribute it and/or modify
  15.     it under the terms of the GNU General Public License, version 2, as
  16.     published by the Free Software Foundation.
  17.  
  18.     This program is distributed in the hope that it will be useful,
  19.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  20.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21.     GNU General Public License for more details.
  22.  
  23.     You should have received a copy of the GNU General Public License
  24.     along with this program; if not, write to the Free Software
  25.     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  26. */
  27.  
  28. if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) {
  29.     die('Illegal Entry');  
  30. }
  31.  
  32. //============================== Photospace options ========================//
  33. class photospace_plugin_options {
  34.  
  35.     function PS_getOptions() {
  36.         $options = get_option('ps_options');
  37.        
  38.         if (!is_array($options)) {
  39.            
  40.             $options['use_paging'] = false;
  41.            
  42.             $options['enable_history'] = false;
  43.            
  44.             $options['num_thumb'] = '9';
  45.            
  46.             $options['use_hover'] = false;
  47.            
  48.             $options['show_captions'] = false;
  49.            
  50.             $options['show_download'] = false;
  51.            
  52.             $options['show_controls'] = false;
  53.            
  54.             $options['show_bg'] = false;
  55.            
  56.             $options['auto_play'] = false;         
  57.             $options['delay'] = 3500;
  58.            
  59.             $options['button_size'] = 50;
  60.            
  61.             $options['hide_thumbs'] = false;
  62.            
  63.             $options['reset_css'] = false;
  64.            
  65.             $options['thumbnail_margin'] = 10;
  66.            
  67.             $options['thumbnail_width'] = 50;
  68.             $options['thumbnail_height'] = 50;
  69.             $options['thumbnail_crop'] = false;
  70.            
  71.             $options['thumb_col_width'] = '181';   
  72.             $options['main_col_width'] = '400';
  73.             $options['main_col_height'] = '500';
  74.             $options['gallery_width'] = '600';
  75.            
  76.             $options['play_text'] = 'Play Slideshow';
  77.             $options['pause_text'] = 'Pause Slideshow';
  78.             $options['previous_text'] = '&lsaquo; Previous Photo';
  79.             $options['next_text'] = 'Next Photo &rsaquo;';
  80.             $options['download_text'] = 'Download Original';   
  81.                        
  82.            
  83.             update_option('ps_options', $options);
  84.         }
  85.         return $options;
  86.     }
  87.  
  88.     function update() {
  89.         if(isset($_POST['ps_save'])) {
  90.             $options = photospace_plugin_options::PS_getOptions();
  91.            
  92.             $options['num_thumb'] = stripslashes($_POST['num_thumb']);
  93.             $options['thumbnail_margin'] =  stripslashes($_POST['thumbnail_margin']);
  94.             $options['thumbnail_width'] = stripslashes($_POST['thumbnail_width']);
  95.             $options['thumbnail_height'] = stripslashes($_POST['thumbnail_height']);           
  96.            
  97.            
  98.             $options['thumb_col_width'] = stripslashes($_POST['thumb_col_width']);
  99.             $options['main_col_width'] = stripslashes($_POST['main_col_width']);
  100.             $options['main_col_height'] = stripslashes($_POST['main_col_height']);
  101.            
  102.             $options['gallery_width'] = stripslashes($_POST['gallery_width']);
  103.            
  104.             $options['delay'] = stripslashes($_POST['delay']);
  105.            
  106.             $options['button_size'] = stripslashes($_POST['button_size']);
  107.  
  108.             if ($_POST['enable_history']) {
  109.                 $options['enable_history'] = (bool)true;
  110.             } else {
  111.                 $options['enable_history'] = (bool)false;
  112.             }
  113.            
  114.             if ($_POST['use_paging']) {
  115.                 $options['use_paging'] = (bool)true;
  116.             } else {
  117.                 $options['use_paging'] = (bool)false;
  118.             }
  119.            
  120.             if ($_POST['thumbnail_crop']) {
  121.                 $options['thumbnail_crop'] = (bool)true;
  122.             } else {
  123.                 $options['thumbnail_crop'] = (bool)false;
  124.             }
  125.            
  126.             if ($_POST['show_controls']) {
  127.                 $options['show_controls'] = (bool)true;
  128.             } else {
  129.                 $options['show_controls'] = (bool)false;
  130.             }
  131.            
  132.             if ($_POST['show_download']) {
  133.                 $options['show_download'] = (bool)true;
  134.             } else {
  135.                 $options['show_download'] = (bool)false;
  136.             }
  137.            
  138.             if ($_POST['show_captions']) {
  139.                 $options['show_captions'] = (bool)true;
  140.             } else {
  141.                 $options['show_captions'] = (bool)false;
  142.             }
  143.            
  144.             if ($_POST['show_bg']) {
  145.                 $options['show_bg'] = (bool)true;
  146.             } else {
  147.                 $options['show_bg'] = (bool)false;
  148.             }
  149.                    
  150.             if ($_POST['use_hover']) {
  151.                 $options['use_hover'] = (bool)true;
  152.             } else {
  153.                 $options['use_hover'] = (bool)false;
  154.             }
  155.            
  156.             if ($_POST['auto_play']) {
  157.                 $options['auto_play'] = (bool)true;
  158.             } else {
  159.                 $options['auto_play'] = (bool)false;
  160.             }
  161.            
  162.             if ($_POST['hide_thumbs']) {
  163.                 $options['hide_thumbs'] = (bool)true;
  164.             } else {
  165.                 $options['hide_thumbs'] = (bool)false;
  166.             }
  167.            
  168.             if ($_POST['reset_css']) {
  169.                 $options['reset_css'] = (bool)true;
  170.             } else {
  171.                 $options['reset_css'] = (bool)false;
  172.             }
  173.            
  174.             $options['play_text'] = stripslashes($_POST['play_text']);
  175.             $options['pause_text'] = stripslashes($_POST['pause_text']);
  176.             $options['previous_text'] = stripslashes($_POST['previous_text']);
  177.             $options['next_text'] = stripslashes($_POST['next_text']);
  178.             $options['download_text'] = stripslashes($_POST['download_text']);
  179.            
  180.             update_option('ps_options', $options);
  181.  
  182.         } else {
  183.             photospace_plugin_options::PS_getOptions();
  184.         }
  185.  
  186.         add_menu_page('Photospace options', 'Photospace Gallery Options', 'edit_themes', basename(__FILE__), array('photospace_plugin_options', 'display'));
  187.     }
  188.    
  189.  
  190.     function display() {
  191.        
  192.         $options = photospace_plugin_options::PS_getOptions();
  193.         ?>
  194.        
  195.         <div class="wrap">
  196.        
  197.             <h2>Photospace Options</h2>
  198.            
  199.             <form method="post" action="#" enctype="multipart/form-data">              
  200.  
  201.                 <!-- Too buggy         
  202.                 <h3>Change photo on hover?</h3>
  203.                 <p><input name="use_hover" type="checkbox" value="checkbox" <?php if($options['use_hover']) echo "checked='checked'"; ?> /> Yes </p>
  204.                 <br />-->
  205.                
  206.                 <div class="wp-menu-separator" style="clear:both; padding-bottom:15px; border-bottom:solid 1px #e6e6e6" ></div>
  207.                
  208.                 <h3><label><input name="show_download" type="checkbox" value="checkbox" <?php if($options['show_download']) echo "checked='checked'"; ?> /> Show download link</label></h3>        
  209.                
  210.                 <h3><label><input name="show_controls" type="checkbox" value="checkbox" <?php if($options['show_controls']) echo "checked='checked'"; ?> /> Show controls (play slide show / Next Prev image links)</label></h3>           
  211.                
  212.                 <h3><label><input name="use_paging" type="checkbox" value="checkbox" <?php if($options['use_paging']) echo "checked='checked'"; ?> /> Use paging </label></h3>         
  213.                
  214.                 <h3><label><input name="enable_history" type="checkbox" value="checkbox" <?php if($options['enable_history']) echo "checked='checked'"; ?> /> Enable history </label></h3>         
  215.                
  216.                
  217.                 <h3><label><input name="show_captions" type="checkbox" value="checkbox" <?php if($options['show_captions']) echo "checked='checked'"; ?> /> Show Title / Caption / Desc under image</label></h3>
  218.                
  219.                 <h3><label><input name="reset_css" type="checkbox" value="checkbox" <?php if($options['reset_css']) echo "checked='checked'"; ?> /> Try to clear current theme image css / formatting</label></h3>
  220.  
  221.  
  222.                 <h3><label><input name="show_bg" type="checkbox" value="checkbox" <?php if($options['show_bg']) echo "checked='checked'"; ?> /> Show background colours for layout testing</label></h3>
  223.                
  224.                
  225.                
  226.                 <div style="clear:both; padding-bottom:15px; border-bottom:solid 1px #e6e6e6" ></div>
  227.                
  228.                 <div style="width:25%;float:left;">    
  229.                     <h3><label><input name="auto_play" type="checkbox" value="checkbox" <?php if($options['auto_play']) echo "checked='checked'"; ?> /> Auto play slide show</label></h3>
  230.                 </div>
  231.                 <div style="width:25%;float:left;">    
  232.                     <h3><label><input name="hide_thumbs" type="checkbox" value="checkbox" <?php if($options['hide_thumbs']) echo "checked='checked'"; ?> /> Hide thumbnails</label></h3>
  233.                 </div>
  234.                 <div style="width:25%;float:left;">    
  235.                     <h3>Slide delay in milliseconds</h3>
  236.                     <p><input type="text" name="delay" value="<?php echo($options['delay']); ?>" /></p>
  237.                 </div>
  238.                
  239.                 <div style="width:25%;float:left;">    
  240.                     <h3>Page button size</h3>
  241.                     <p><input type="text" name="button_size" value="<?php echo($options['button_size']); ?>" /></p>
  242.                 </div>                 
  243.  
  244.  
  245.                
  246.                 <div style="clear:both; padding-bottom:15px; border-bottom:solid 1px #e6e6e6" ></div>
  247.                
  248.                 <h3 style="font-style:italic; font-weight:normal; color:grey " >Images that are already on the server will not change size until you regenerate the thumbnails. Use <a title="http://wordpress.org/extend/plugins/ajax-thumbnail-rebuild/" href="http://wordpress.org/extend/plugins/ajax-thumbnail-rebuild/">AJAX thumbnail rebuild</a> or <a title="http://wordpress.org/extend/plugins/regenerate-thumbnails/" href="http://wordpress.org/extend/plugins/regenerate-thumbnails/">Regenerate Thumbnails</a> </h3>
  249.  
  250.                 <div style="width:25%;float:left;">            
  251.                     <h3>Thumbnail Width</h3>
  252.                     <p><input type="text" name="thumbnail_width" value="<?php echo($options['thumbnail_width']); ?>" /></p>
  253.                 </div>
  254.                
  255.                 <div style="width:25%; float:left;">               
  256.                     <h3>Thumbnail Height</h3>
  257.                     <p><input type="text" name="thumbnail_height" value="<?php echo($options['thumbnail_height']); ?>" /></p>
  258.                 </div>
  259.                
  260.                 <div style="width:25%; float:left">
  261.                     <h3>Main image width</h3>
  262.                     <p><input type="text" name="main_col_width" value="<?php echo($options['main_col_width']); ?>" /></p>
  263.                 </div>
  264.                
  265.                 <div style="width:25%; float:left">
  266.                     <h3>Main image height</h3>
  267.                     <p><input type="text" name="main_col_height" value="<?php echo($options['main_col_height']); ?>" /></p>
  268.                 </div>
  269.                
  270.                 <div style="width:25%; float:left;">
  271.                     <h3>Crop thumnails</h3>
  272.                     <h3><label><input name="thumbnail_crop" type="checkbox" value="checkbox" <?php if($options['thumbnail_crop']) echo "checked='checked'"; ?> /></label></h3>
  273.  
  274.                 </div>             
  275.  
  276.                 <div style="clear:both; padding-bottom:15px; border-bottom:solid 1px #e6e6e6" ></div>
  277.                
  278.                 <div style="width:25%;float:left;">    
  279.                     <h3>Number of thumbnails</h3>
  280.                     <p><input type="text" name="num_thumb" value="<?php echo($options['num_thumb']); ?>" /></p>
  281.                 </div>
  282.                    
  283.                
  284.                 <div style="width:25%; float:left;">               
  285.                     <h3>Thumbnail column width</h3>
  286.                     <p><input type="text" name="thumb_col_width" value="<?php echo($options['thumb_col_width']); ?>" /></p>
  287.                 </div>
  288.                
  289.                 <div style="width:25%; float:left;">               
  290.                     <h3>Thumbnail margin</h3>
  291.                     <p><input type="text" name="thumbnail_margin" value="<?php echo($options['thumbnail_margin']); ?>" /></p>
  292.                 </div>
  293.                
  294.                
  295.                 <div style="clear:both; padding-bottom:15px; border-bottom:solid 1px #e6e6e6" ></div>
  296.                
  297.                
  298.                
  299.                 <h3>Gallery width (at least Thumbnail column + Main image width)</h3>
  300.                 <p><input type="text" name="gallery_width" value="<?php echo($options['gallery_width']); ?>" /></p>
  301.                 <br />
  302.                
  303.                 <div style="clear:both; padding-bottom:15px; border-bottom:solid 1px #e6e6e6" ></div>
  304.                
  305.                                
  306.                 <div style="width:25%; float:left;">
  307.                     <h3>Play text</h3>             
  308.                     <p><input type="text" name="play_text" value="<?php echo($options['play_text']); ?>" /></p>
  309.                 </div>
  310.                
  311.                 <div style="width:25%; float:left;">
  312.                     <h3>Pause text</h3>                
  313.                     <p><input type="text" name="pause_text" value="<?php echo($options['pause_text']); ?>" /></p>
  314.                 </div>
  315.                
  316.                 <div style="width:25%; float:left;">               
  317.                     <h3>Previous text</h3> 
  318.                     <p><input type="text" name="previous_text" value="<?php echo($options['previous_text']); ?>" /></p>
  319.                 </div>
  320.  
  321.                 <div style="width:25%; float:left;">               
  322.                     <h3>Next text</h3> 
  323.                     <p><input type="text" name="next_text" value="<?php echo($options['next_text']); ?>" /></p>
  324.                 </div>
  325.                
  326.                 <div style="width:25%; float:left;">               
  327.                     <h3>Download link text</h3>
  328.                     <p><input type="text" name="download_text" value="<?php echo($options['download_text']); ?>" /></p>
  329.                 </div>
  330.  
  331.                 <div style="clear:both; padding-bottom:15px; border-bottom:solid 1px #e6e6e6" ></div>
  332.  
  333.            
  334.                 <p><input class="button-primary" type="submit" name="ps_save" value="Save Changes" /></p>
  335.            
  336.             </form>
  337.    
  338.         </div>
  339.        
  340.         <?php
  341.     }  
  342. }
  343.  
  344. function PS_getOption($option) {
  345.     global $mytheme;
  346.     return $mytheme->option[$option];
  347. }
  348.  
  349. // register functions
  350. add_action('admin_menu', array('photospace_plugin_options', 'update'));
  351.  
  352. $options = get_option('ps_options');
  353.  
  354. add_theme_support( 'post-thumbnails' );
  355. add_image_size('photospace_thumbnails', $options['thumbnail_width'], $options['thumbnail_height'], $options['thumbnail_crop']);
  356. add_image_size('photospace_full', $options['main_col_width'], $options['main_col_height']);
  357.  
  358. //============================== insert HTML header tag ========================//
  359.  
  360. function photospace_scripts_method() {
  361.     wp_enqueue_script('jquery');   
  362.     $photospace_wp_plugin_path = site_url()."/wp-content/plugins/photospace";  
  363.     wp_enqueue_style( 'photospace-styles',  $photospace_wp_plugin_path . '/gallery.css');
  364.     wp_enqueue_script( 'galleriffic',       $photospace_wp_plugin_path . '/jquery.galleriffic.js');
  365. }
  366. add_action('wp_enqueue_scripts', 'photospace_scripts_method');
  367.  
  368. function photospace_scripts_method_history() {                         
  369.     $photospace_wp_plugin_path = site_url()."/wp-content/plugins/photospace";                        
  370.     wp_enqueue_script( 'history',       $photospace_wp_plugin_path . '/jquery.history.js');
  371. }
  372. if ($options['enable_history']) {
  373.     add_action('wp_enqueue_scripts', 'photospace_scripts_method_history');
  374. }  
  375.  
  376. function photospace_wp_headers() {
  377.    
  378.     $options = get_option('ps_options');
  379.    
  380.     echo "<!--  photospace [ START ] --> \n";
  381.    
  382.     echo '<style type="text/css">';
  383.    
  384.     if($options['reset_css']){
  385.    
  386.         echo '
  387.             /* reset */
  388.             .photospace img,
  389.             .photospace ul.thumbs,
  390.             .photospace ul.thumbs li,
  391.             .photospace ul.thumbs li a{
  392.                 padding:0;
  393.                 margin:0;
  394.                 border:none !important;
  395.                 background:none !important;
  396.                 height:auto !important;
  397.                 width:auto !important;
  398.             }
  399.             .photospace span{
  400.                 padding:0;
  401.                 margin:0;
  402.                 border:none !important;
  403.                 background:none !important;
  404.             }
  405.             ';
  406.     }
  407.    
  408.     if(!empty($options['button_size']))
  409.         echo '
  410.             .photospace .thumnail_col a.pageLink {
  411.                 width:'.$options['button_size'] .'px;
  412.                 height:'.$options['button_size'] .'px;
  413.             }
  414.         ';     
  415.    
  416.     if(!empty($options['main_col_width']))
  417.         echo '  .photospace .gal_content,
  418.                 .photospace .loader,
  419.                 .photospace .slideshow a.advance-link{
  420.                     width:'. $options['main_col_width'] .'px;
  421.                 }
  422.         ';
  423.  
  424.     if(!empty($options['gallery_width']))
  425.         echo '  .photospace{
  426.                     width:'. $options['gallery_width'] .'px;
  427.                 }
  428.         ';
  429.        
  430.     if(!empty($options['main_col_height']))
  431.         echo '  .photospace{
  432.                     height:'. $options['main_col_height'] .'px;
  433.                 }
  434.         ';
  435.        
  436.     if(!empty($options['thumbnail_margin']))
  437.         echo '  .photospace ul.thumbs li {
  438.                     margin-bottom:'. $options['thumbnail_margin'] .'px !important;
  439.                     margin-right:'. $options['thumbnail_margin'] .'px !important;
  440.                 }
  441.         ';
  442.    
  443.     if(!empty($options['main_col_height']))
  444.         echo '  .photospace .loader {
  445.                     height: '. $options['main_col_height'] / 2 . 'px;
  446.                 }
  447.         ';
  448.        
  449.     if(!empty($options['main_col_width']))
  450.         echo '  .photospace .loader {
  451.                     width: '. $options['main_col_width'] . 'px;
  452.                 }
  453.         ';
  454.  
  455.     if(!empty($options['main_col_height']))
  456.         echo '  .photospace .slideshow a.advance-link,
  457.                 .photospace .slideshow span.image-wrapper {
  458.                     height:'. $options['main_col_height'] .'px;
  459.                 }
  460.         ';
  461.        
  462.     if(!empty($options['main_col_height']))
  463.         echo '  .photospace .slideshow-container {
  464.                     height:'. $options['main_col_height'] .'px;
  465.                 }
  466.         ';
  467.            
  468.     if($options['show_bg']){
  469.    
  470.         echo '
  471.             .photospace{
  472.                 background-color:#fbefd7;
  473.             }
  474.            
  475.             .photospace .thumnail_col {
  476.                 background-color:#e7cf9f;
  477.             }
  478.            
  479.             .photospace .gal_content,
  480.             .photospace .loader,
  481.             .photospace .slideshow a.advance-link {
  482.                 background-color:#e7cf9f;
  483.             }';
  484.     }
  485.    
  486.     if($options['hide_thumbs']){
  487.         echo '
  488.             .photospace .thumnail_col{
  489.                 display:none !important;
  490.             }
  491.         ';
  492.     }
  493.     if($options['use_paging']){
  494.         echo '
  495.             .pageLink{
  496.                 display:none !important;
  497.             }
  498.             .photospace{
  499.                 margin-top:43px;
  500.             }
  501.         ';
  502.     }
  503.  
  504.     echo '</style>';
  505.            
  506.     echo "<!--  photospace [ END ] --> \n";
  507. }
  508. add_action( 'wp_head', 'photospace_wp_headers', 10 );
  509.  
  510. add_shortcode( 'photospace', 'photospace_shortcode' );
  511. function photospace_shortcode( $atts ) {
  512.    
  513.     global $post;
  514.     $options = get_option('ps_options');
  515.    
  516.     extract(shortcode_atts(array(
  517.         'id'                => intval($post->ID),
  518.         'num_thumb'         => $options['num_thumb'],
  519.         'num_preload'       => $options['num_thumb'],
  520.         'show_captions'     => $options['show_captions'],
  521.         'show_download'     => $options['show_download'],
  522.         'show_controls'     => $options['show_controls'],
  523.         'auto_play'         => $options['auto_play'],
  524.         'delay'             => $options['delay'],
  525.         'hide_thumbs'       => $options['hide_thumbs'],
  526.         'use_paging'        => $options['use_paging'],
  527.         'horizontal_thumb'  => 0,
  528.         'include'    => '',
  529.         'exclude'    => '',
  530.         'sync_transitions'  => 1
  531.        
  532.     ), $atts));
  533.    
  534.     $post_id = intval($post->ID);
  535.  
  536.     if($hide_thumbs){
  537.         $hide_thumb_style = 'hide_me';
  538.     }
  539.    
  540.     $thumb_style_init = 'display:none';
  541.     $thumb_style_on  = "'display', 'block'";
  542.     $thumb_style_off  = "'display', 'none'";
  543.  
  544.    
  545.     $photospace_wp_plugin_path = site_url()."/wp-content/plugins/photospace";
  546.    
  547.     $output_buffer ='
  548.    
  549.         <div class="gallery_clear"></div>
  550.         <div id="gallery_'.$post_id.'" class="photospace">
  551.    
  552.             <!-- Start Advanced Gallery Html Containers -->
  553.             <div class="thumbs_wrap2">
  554.                 <div class="thumbs_wrap">
  555.                     <div id="thumbs_'.$post_id.'" class="thumnail_col '. $hide_thumb_style . '" >
  556.                         ';
  557.                        
  558.                         if($horizontal_thumb){     
  559.                                 $output_buffer .='<a class="pageLink prev" style="'. $thumb_style_init . '" href="#" title="Previous Page"></a>';
  560.                         }
  561.                        
  562.                         $output_buffer .='
  563.                         <ul class="thumbs noscript">               
  564.                         ';
  565.                                                    
  566.                         if ( !empty($include) ) {
  567.                             $include = preg_replace( '/[^0-9,]+/', '', $include );
  568.                             $_attachments = get_posts( array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order') );
  569.                    
  570.                             $attachments = array();
  571.                             foreach ( $_attachments as $key => $val ) {
  572.                                 $attachments[$val->ID] = $_attachments[$key];
  573.                             }
  574.                         } elseif ( !empty($exclude) ) {
  575.                             $exclude = preg_replace( '/[^0-9,]+/', '', $exclude );
  576.                             $attachments = get_children( array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order') );
  577.                         } else {
  578.                             $attachments = get_children( array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order') );
  579.                         }
  580.        
  581.                         if ( !empty($attachments) ) {
  582.                             foreach ( $attachments as $aid => $attachment ) {
  583.                                 $img = wp_get_attachment_image_src( $aid , 'photospace_full');
  584.                                 $thumb = wp_get_attachment_image_src( $aid , 'photospace_thumbnails');
  585.                                 $full = wp_get_attachment_image_src( $aid , 'full');
  586.                                 $_post = & get_post($aid);
  587.        
  588.                                 $image_title = attribute_escape($_post->post_title);
  589.                                 $image_alttext = get_post_meta($aid, '_wp_attachment_image_alt', true);
  590.                                 $image_caption = $_post->post_excerpt;
  591.                                 $image_description = $_post->post_content;                     
  592.                                                            
  593.                                 $output_buffer .='
  594.                                     <li><a class="thumb" href="' . $img[0] . '" title="' . $image_title . '" >                             
  595.                                             <img src="' . $thumb[0] . '" alt="' . $image_alttext . '" title="' . $image_title . '" />
  596.                                         </a>
  597.                                         ';
  598.        
  599.                                         $output_buffer .='
  600.                                         <div class="caption">
  601.                                             ';
  602.                                             if($show_captions){    
  603.                                                
  604.                                                 if($image_caption != ''){
  605.                                                     $output_buffer .='
  606.                                                         <div class="image-caption">' .  $image_caption . '</div>
  607.                                                     ';
  608.                                                 }
  609.                                                
  610.                                                 if($image_description != ''){
  611.                                                     $output_buffer .='
  612.                                                     <div class="image-desc">' .  $image_description . '</div>
  613.                                                     ';
  614.                                                 }
  615.                                             }
  616.                                            
  617.                                             if($show_download){        
  618.                                                 $output_buffer .='
  619.                                                 <div class="download"><a href="'.$full[0].'" title="'. $options["download_text"] .'" ><span>'. $options["download_text"] .'</span></a></div>
  620.                                                 ';
  621.                                             }
  622.                                            
  623.                                         $output_buffer .='
  624.                                         </div>
  625.                                         ';
  626.                                        
  627.                                        
  628.                                     $output_buffer .='
  629.                                     </li>
  630.                                 ';
  631.                                 }
  632.                             }
  633.                            
  634.                         $output_buffer .='
  635.                         </ul>';
  636.        
  637.                        
  638.                         if(!$horizontal_thumb){        
  639.                                 $output_buffer .='
  640.                                 <div class="photospace_clear"></div>
  641.                                 <a class="pageLink prev" style="'.$thumb_style_init.'" href="#" title="Previous Page"></a>';
  642.                         }
  643.                        
  644.                         $output_buffer .='
  645.                         <a class="pageLink next" style="'.$thumb_style_init.'" href="#" title="Next Page"></a>
  646.                     </div>
  647.                 </div>
  648.             </div>
  649.            
  650.             <!-- Start Advanced Gallery Html Containers -->
  651.             <div class="gal_content">
  652.                 ';
  653.                
  654.                 if($show_controls){
  655.                     $output_buffer .='<div id="controls_'.$post_id.'" class="controls"></div>';
  656.                 }
  657.                
  658.                 $output_buffer .='
  659.                 <div class="slideshow-container">
  660.                     <div id="loading_'.$post_id.'" class="loader"></div>
  661.                     <div id="slideshow_'.$post_id.'" class="slideshow"></div>
  662.                     <div id="caption_'.$post_id.'" class="caption-container"></div>
  663.                 </div>
  664.                
  665.             </div>
  666.    
  667.     </div>
  668.    
  669.     <div class="gallery_clear"></div>
  670.    
  671.     ';
  672.    
  673.     $output_buffer .= "
  674.    
  675.     <script type='text/javascript'>
  676.            
  677.             jQuery(document).ready(function($) {
  678.                
  679.                 // We only want these styles applied when javascript is enabled
  680.                 $('.gal_content').css('display', 'block');
  681.                 ";
  682.                
  683.                 if(!$horizontal_thumb){
  684.                     $output_buffer .= "$('.thumnail_col').css('width', '". $options['thumb_col_width'] . "px');";
  685.                 }
  686.                
  687.                 $output_buffer .= "
  688.                
  689.                 // Initialize Advanced Galleriffic Gallery
  690.                 var gallery = $('#thumbs_".$post_id."').galleriffic({
  691.                     delay:                     " . intval($delay) . ",
  692.                     numThumbs:                 " . intval($num_thumb) . ",
  693.                     preloadAhead:              " . intval($num_preload) . ",
  694.                     enableTopPager:            " . intval($use_paging) . ",
  695.                     enableBottomPager:         false,
  696.                     imageContainerSel:         '#slideshow_".$post_id."',
  697.                     controlsContainerSel:      '#controls_".$post_id."',
  698.                     captionContainerSel:       '#caption_".$post_id."',  
  699.                     loadingContainerSel:       '#loading_".$post_id."',
  700.                     renderSSControls:          true,
  701.                     renderNavControls:         true,
  702.                     playLinkText:              '". $options['play_text'] ."',
  703.                     pauseLinkText:             '". $options['pause_text'] ."',
  704.                     prevLinkText:              '". $options['previous_text'] ."',
  705.                     nextLinkText:              '". $options['next_text'] ."',
  706.                     nextPageLinkText:          '&rsaquo;',
  707.                     prevPageLinkText:          '&lsaquo;',
  708.                     enableHistory:              " . intval($options['enable_history']) . ",
  709.                     autoStart:                  " . intval($auto_play) . ",
  710.                     enableKeyboardNavigation:   true,
  711.                     syncTransitions:            " . intval($sync_transitions) . ",
  712.                     defaultTransitionDuration:  300,
  713.                        
  714.                     onTransitionOut:           function(slide, caption, isSync, callback) {
  715.                         slide.fadeTo(this.getDefaultTransitionDuration(isSync), 0.0, callback);
  716.                         caption.fadeTo(this.getDefaultTransitionDuration(isSync), 0.0);
  717.                     },
  718.                     onTransitionIn:            function(slide, caption, isSync) {
  719.                         var duration = this.getDefaultTransitionDuration(isSync);
  720.                         slide.fadeTo(duration, 1.0);
  721.    
  722.                         // Position the caption at the bottom of the image and set its opacity
  723.                         var slideImage = slide.find('img');
  724.                         caption.width(slideImage.width())
  725.                             .css({
  726.                                 //'bottom' : Math.floor((slide.height() - slideImage.outerHeight()) / 2 - 40),
  727.                                 'top' : slideImage.outerHeight(),
  728.                                 'left' : Math.floor((slide.width() - slideImage.width()) / 2) + slideImage.outerWidth() - slideImage.width()
  729.                             })
  730.                             .fadeTo(duration, 1.0);
  731.                        
  732.                     },
  733.                     onPageTransitionOut:       function(callback) {
  734.                         this.hide();
  735.                         setTimeout(callback, 100); // wait a bit
  736.                     },
  737.                     onPageTransitionIn:        function() {
  738.                         var prevPageLink = this.find('a.prev').css(".$thumb_style_off.");
  739.                         var nextPageLink = this.find('a.next').css(".$thumb_style_off.");
  740.                        
  741.                         // Show appropriate next / prev page links
  742.                         if (this.displayedPage > 0)
  743.                             prevPageLink.css(".$thumb_style_on.");
  744.        
  745.                         var lastPage = this.getNumPages() - 1;
  746.                         if (this.displayedPage < lastPage)
  747.                             nextPageLink.css(".$thumb_style_on.");
  748.        
  749.                         this.fadeTo('fast', 1.0);
  750.                     }
  751.                    
  752.                 });
  753.                
  754.                 ";
  755.                
  756.                 if ($options['enable_history']) {  
  757.                    
  758.                     $output_buffer .= "
  759.                        
  760.                         /**** Functions to support integration of galleriffic with the jquery.history plugin ****/
  761.          
  762.                         // PageLoad function
  763.                         // This function is called when:
  764.                         // 1. after calling $.historyInit();
  765.                         // 2. after calling $.historyLoad();
  766.                         // 3. after pushing Go Back button of a browser
  767.                         function pageload(hash) {
  768.                             // alert('pageload: ' + hash);
  769.                             // hash doesn't contain the first # character.
  770.                             if(hash) {
  771.                                 $.galleriffic.gotoImage(hash);
  772.                             } else {
  773.                                 gallery.gotoIndex(0);
  774.                             }
  775.                         }
  776.          
  777.                         // Initialize history plugin.
  778.                         // The callback is called at once by present location.hash.
  779.                         $.historyInit(pageload, 'advanced.html');
  780.          
  781.                         // set onlick event for buttons using the jQuery 1.3 live method
  782.                         $('a[rel=history]').live('click', function(e) {
  783.                             if (e.button != 0) return true;
  784.                            
  785.                             var hash = this.href;
  786.                             hash = hash.replace(/^.*#/, '');
  787.          
  788.                             // moves to a new page.
  789.                             // pageload is called at once.  
  790.                             $.historyLoad(hash);
  791.          
  792.                             return false;
  793.                         });
  794.          
  795.                         /****************************************************************************************/
  796.                        
  797.                        
  798.                         ";
  799.                 }
  800.                
  801.             if($use_hover){        
  802.          
  803.                 $output_buffer .= "
  804.                     gallery.find('a.thumb').hover(function(e) {
  805.                         gallery.clickHandler(e, this);
  806.                     });
  807.                 ";
  808.        
  809.             }
  810.                    
  811.                
  812.             $output_buffer .= "
  813.                
  814.                 /**************** Event handlers for custom next / prev page links **********************/
  815.        
  816.                 gallery.find('a.prev').click(function(e) {
  817.                     gallery.previousPage();
  818.                     e.preventDefault();
  819.                 });
  820.        
  821.                 gallery.find('a.next').click(function(e) {
  822.                     gallery.nextPage();
  823.                     e.preventDefault();
  824.                 });
  825.        
  826.             });
  827.         </script>
  828.        
  829.         ";
  830.        
  831.         return $output_buffer;
  832. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement