Ignore:
Timestamp:
Jul 15, 2009, 10:19:03 PM (15 years ago)
Author:
tiico
Message:

Correct button style (thks mistic100)
Up to date AddThis options
Correct icons mode (disable on image.php because not working)
Update version to v 0.0.3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/addThis/include/AddThis.class.php

    r3411 r3596  
    22/*
    33 * Plugin Name: AddThis
    4  * Version: 0.0.1
     4 * Version: 0.0.3
    55 * Description: AddThis activation
    66 * Plugin URI: http://fr.piwigo.org/ext/extension_view.php?eid=293
     
    1919            global $template, $page, $user;
    2020
    21                         if (  (isset($page['page']) && ($page['page']) == 'plugin')
    22                                 &&(isset($page['body_id']) && isset($page['section']) && ($page['section']) == 'theAdminPage'))
    23                                         $cssfile = '<link href="./plugins/AddThis/js/addthis.css" rel="stylesheet" type="text/css" />';
    24                         else
    25                         {
    26                                 if (isset($page['section']) && ($page['section']) == 'categories')
    27                                 {                       
    28                                         // Selection du mode 'icones'
    29                                         if (    (isset($page['image_id']) && $this->my_config['ImageButton'] == 8)
    30                                                  ||     (empty($page['category']) && $this->my_config['HomeButton'] == 8)
    31                                                  ||     (isset($page['category']) && $this->my_config['CategoryButton'] == 8)
    32                                                 )
    33                                                 $cssfile = '<link href="./plugins/AddThis/js/addthis.css" rel="stylesheet" type="text/css" />';
    34                                 }
    35                         }
    36                         if (isset($cssfile))           
    37                                 $template->append('head_elements',$cssfile);           
     21        if (isset($page['section']) && ($page['section']) == 'categories')
     22        {                       
     23            // Selection du mode 'icones'
     24            if (        (isset($page['image_id']) && $this->my_config['ImageButton'] == 8)
     25                 ||     (empty($page['category']) && $this->my_config['HomeButton'] == 8)
     26                 ||     (isset($page['category']) && $this->my_config['CategoryButton'] == 8)
     27                )
     28//                                              $cssfile = '<link href="./plugins/AddThis/js/addthis.css" rel="stylesheet" type="text/css" />';
     29                $cssfile = '<link href="'.ADDTHIS_JS_PATH.'addthis.css" rel="stylesheet" type="text/css" />';
     30        }
     31        if (isset($cssfile))           
     32            $template->append('head_elements',$cssfile);               
    3833           
    3934        }
     
    6964                                                );
    7065
     66                // Taille des boutons
     67                $addthis_img_size = array(
     68                        '',
     69                        '125',
     70                        '83',
     71                        '123',
     72                        '83',
     73                        '125',
     74                        '16',
     75                        '');                                   
    7176                $addthis_option = '';
    7277                $addthis_img = 0;
     
    8994                }
    9095                // pas d'affichage sur selection = 'desactive' ou si selection = 'icones'
    91                 if ($addthis_img > 0 && $addthis_img < 8)
     96                if ($addthis_img > 0 && $addthis_img < 9)
    9297                {
    9398                        foreach ($this->my_config['addthis_options'] as $key => $value)
     
    102107                                                                 
    103108
    104                                 $tpl_code = (isset($page['image_id']) ? "\n".'<p align="left">' :"\n<li>")
    105                                 .'<script type="text/javascript">'
    106                                 .(strlen($addthis_option) != 0 ? 'var addthis_options = \''.$addthis_option.'\'': '')
    107                                 .(strlen($this->my_config['addthis_pub']) != 0 ? "\n".'var addthis_pub = "'.$this->my_config['addthis_pub'].'";' : '')
    108                                 .(strlen($this->my_config['addthis_brand']) != 0 ? "\n".'var addthis_brand = "'.$this->my_config['addthis_brand'].'";' : '')
    109                                 .(strlen($this->my_config['addthis_header_color']) != 0 ? "\n".'var addthis_header_color = "'.$this->my_config['addthis_header_color'].'";' : '')
    110                                 .(strlen($this->my_config['addthis_header_background']) != 0 ? "\n".'var addthis_header_background = "'.$this->my_config['addthis_header_background'].'";' : '')
    111 
    112                                 .(strlen($this->my_config['addthis_offset_top']) != 0 ? "\n".'var addthis_offset_top = '.$this->my_config['addthis_offset_top'].';' : '')
    113                                 .(strlen($this->my_config['addthis_offset_left']) != 0 ? "\n".'var addthis_offset_left = '.$this->my_config['addthis_offset_left'].';' : '')
    114                                 .(strlen($this->my_config['addthis_hover_delay']) != 0 ? "\n".'var addthis_hover_delay = '.$this->my_config['addthis_hover_delay'].';' : '')
    115                                 .(strlen($this->my_config['addthis_language']) != 0 ? "\n".'var addthis_language = "'.$this->my_config['addthis_language'].'";' : '')
    116 
    117                                 .'</script>
    118                                 <a href="http://www.addthis.com/bookmark.php?v=20" onmouseover="return addthis_open(this, \'\', \'[URL]\', \'[TITLE]\')" onmouseout="addthis_close()" onclick="return addthis_sendto()">'
     109            $tpl_code = (isset($page['image_id']) ? "\n" :"\n<li>")
     110            .'<script type="text/javascript">'
     111            .(strlen($this->my_config['addthis_pub']) != 0 ? "\n".'var addthis_pub = "'.$this->my_config['addthis_pub'].'";' : '')
     112            .(strlen($this->my_config['addthis_brand']) != 0 ? "\n".'var addthis_brand = "'.$this->my_config['addthis_brand'].'";' : '')
     113            .(strlen($this->my_config['addthis_header_color']) != 0 ? "\n".'var addthis_header_color = "'.$this->my_config['addthis_header_color'].'";' : '')
     114            .(strlen($this->my_config['addthis_header_background']) != 0 ? "\n".'var addthis_header_background = "'.$this->my_config['addthis_header_background'].'";' : '')
     115            .(strlen($this->my_config['addthis_offset_top']) != 0 ? "\n".'var addthis_offset_top = '.$this->my_config['addthis_offset_top'].';' : '')
     116            .(strlen($this->my_config['addthis_offset_left']) != 0 ? "\n".'var addthis_offset_left = '.$this->my_config['addthis_offset_left'].';' : '')
     117            .(strlen($this->my_config['addthis_hover_delay']) != 0 ? "\n".'var addthis_hover_delay = '.$this->my_config['addthis_hover_delay'].';' : '')
     118            .(strlen($this->my_config['addthis_language']) != 0 ? "\n".'var addthis_language = "'.$this->my_config['addthis_language'].'";' : '')
     119             ."\n" ;
     120               
     121            if ($addthis_img > 0 && $addthis_img < 8)
     122            {
     123                $tpl_code.=(strlen($addthis_option) != 0 ? 'var addthis_options = \''.$addthis_option.'\'': '')
     124                ."\n"
     125                .'</script>';
     126
     127               
     128                                $tpl_code .= '<a style="padding:4px;'.(isset($addthis_img_size[$addthis_img]) ? 'width:'.$addthis_img_size[$addthis_img].'px;' : '').'" href="http://www.addthis.com/bookmark.php?v=250" onmouseover="return addthis_open(this, \'\', \'[URL]\', \'[TITLE]\')" onmouseout="addthis_close()" onclick="return addthis_sendto()">'
     129                 ."\n"
    119130                                .$addthis_img_src[$addthis_img]
     131                 ."\n"
    120132                                // si selection du 7
    121133                                .($addthis_img == 7 ? (strlen($this->my_config['addthis_icon_text']) != 0 ? $this->my_config['addthis_icon_text'] : 'Share' ) : '')
    122                                 .'</a><script type="text/javascript" src="http://s7.addthis.com/js/200/addthis_widget.js"></script>'
    123                                 .(isset($page['image_id']) ? '</p>' :'</li>');
    124 
    125                 }
    126                 else if ($addthis_img == 8)
    127                 {
    128 
    129                         $tpl_code = '
    130                         <script type="text/javascript">
    131                         addthis_title   = document.title;
    132                         addthis_url     = window.location.href;
    133                         addthis_clickout= true;'
    134                         .(strlen($this->my_config['addthis_pub']) != 0 ? "\n".'addthis_id = \''.$this->my_config['addthis_pub'].'\';' : '')
    135                         .'</script>'
    136                         ."\n";
    137                         $nb_icons = 1;
    138                         foreach ($this->my_config['addthis_options'] as $key => $value)
    139                         {
    140                                 if ($nb_icons <= $this->my_config['addthis_icon_nb'])
    141                                 {
    142                                         if ($value == true)
    143                                         {               
    144                                                 $nb_icons++;
    145 
    146                                                 $tpl_code .= (isset($page['image_id']) ? '' : '<li>')
    147                                                 .'<a href="/" title="'.$key.'" onclick="return addthis_invoke(\''.$key.'\', addthis_url, addthis_title, addthis_id);" class="at15t at15t_'.$key.'"> &nbsp;'.$key.'</span></a>'
    148                                                 .(isset($page['image_id']) ? '' : '</li>')
    149                                                 ."\n"; 
    150 
    151 //                                              $tpl_code .= '<td width="10"></td><td class="c1"><a href="javascript:sets(\''.$key.'\');" class="c1a" onclick="return omc(\''.$key.'\')"><span class="at15t at15t_'.$key.'"></span></a></td>';
    152 //                                      $tpl_code .= '<li class="at15t at15t_'.$key.'"><a  href="/" title="'.$key.'" onclick="return addthis_invoke(\''.$key.'\', addthis_url, addthis_title, addthis_id);" ></a></li>';                                       
    153                                         }
    154                                 }
    155                         }
    156                         $tpl_code .= '<script type="text/javascript" src="http://s7.addthis.com/js/200/addthis_widget.js"></script>'."\n";
    157 
    158                 }
    159                        
     134                                ."\n"
     135                .'</a><script type="text/javascript" src="'.ADDTHIS_JS_PATH.'addthis_widget.js"></script>'
     136                                ."\n"
     137                .(isset($page['image_id']) ? '' :'</li>');
     138            }
     139
     140            else if ($addthis_img == 8)
     141            {
     142                $tpl_code .= '</script>';
     143
     144                $tpl_code .= '
     145                <script type="text/javascript">
     146                addthis_title   = document.title;
     147                addthis_url     = window.location.href;
     148                addthis_clickout= true;'
     149                .(strlen($this->my_config['addthis_pub']) != 0 ? 'addthis_id = \''.$this->my_config['addthis_pub'].'\';' : '')
     150                ."\n"
     151                .'</script>'
     152                ."\n";
     153               
     154                $nb_icons = 1;
     155
     156                $tpl_code .= (isset($page['image_id']) ? '' : '<li>');
     157
     158                $tpl_code .= '<div class="addthis_toolbox addthis_default_style">';
     159
     160                foreach ($this->my_config['addthis_options'] as $key => $value)
     161                {
     162                    if ($nb_icons <= $this->my_config['addthis_icon_nb'])
     163                    {
     164                        if ($value == true)
     165                        {               
     166                            $nb_icons++;
     167                            if ($key == "more")
     168                            {
     169                                                        $tpl_code .='<span class="addthis_separator" style="padding:1px;">|</span>';
     170                                $tpl_code .='<a href="http://www.addthis.com/bookmark.php?v=250" class="addthis_button_compact""></a>';
     171                            }
     172                            else
     173                                $tpl_code .='<a class="addthis_button_'.$key.'" ></a>';
     174
     175                        }
     176                    }
     177                }
     178//                $tpl_code .= '<script type="text/javascript" src="http://s7.addthis.com/js/200/addthis_widget.js"></script>'."\n";
     179                $tpl_code .= '<script type="text/javascript" src="'.ADDTHIS_JS_PATH.'addthis_widget.js"></script>'."\n";
     180                        $tpl_code .= (isset($page['image_id']) ? '' : '</li>');
     181
     182               
     183            }
     184
     185                }
    160186                if (isset($tpl_code))
    161187                {
    162188                        if (isset($page['image_id']))
    163 //                              $template->concat('PLUGIN_PICTURE_BEFORE', $tpl_code);
    164189                                $template->concat('PLUGIN_PICTURE_ACTIONS', $tpl_code);
    165190                        else
     
    170195
    171196
    172         // Add piclens pics to start slideshow
    173         // Another thanks to P@t
    174197
    175198        /* Loading of the configuration file - If not exist -> load default values */
     
    222245        }
    223246       
    224                  
    225         function add_AddThis_action()
    226         {
    227                 global $template, $page;
    228 
    229                         $tpl_code = '<script type="text/javascript">var addthis_pub="4a0c1f674d14de33";</script>
    230 <a href="http://www.addthis.com/bookmark.php?v=20" onmouseover="return addthis_open(this, \'\', \'[URL]\', \'[TITLE]\')" onmouseout="addthis_close()" onclick="return addthis_sendto()" class="button"><img src="http://s7.addthis.com/static/btn/lg-share-en.gif" width="125" height="16" alt="Bookmark and Share" ></a><script type="text/javascript" src="http://s7.addthis.com/js/200/addthis_widget.js"></script>';
    231 
    232                 if (isset($tpl_code))
    233                 {
    234 //                      $template->concat('PLUGIN_INDEX_ACTIONS', $tpl_code);
    235                         $template->concat('PLUGIN_PICTURE_BEFORE', $tpl_code);
    236        
    237                 }
    238         }
    239 
    240247       
    241248        function AddThis_admin_menu($menu)
Note: See TracChangeset for help on using the changeset viewer.