source: extensions/LLGBO2/main.inc.php @ 6548

Last change on this file since 6548 was 6450, checked in by EXFTB, 14 years ago

2.1.d fix bug with IE6 & IE8

  • Property svn:eol-style set to LF
File size: 17.0 KB
Line 
1<?php 
2/*
3Plugin Name: Look_like_gbo2
4Version:  2.1.d
5Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=251
6Author: Ex-Ftb 
7Author URI: http://www.photos.bouteyron.fr/
8Description:  Display thumbnail under button. Add navigation on picture look like GBo Gallery
9Add a border around  picture ......
10  2.1.a compliant 2.1 Piwigo
11  2.1.b fix minor bugs in administration
12  2.1.c compatibility with simple
13  2.1.d bug Css with IE6 & IE8   */
14
15if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
16/* création d'une instance de la classe   */
17$obj = new look_like_gbo(); /* class loading */
18global $conf; 
19
20define ('LLGBO_INFO_VERSION','2.1.d');
21if (!defined('LLGBO_PATH'))
22{define('LLGBO_PATH' , PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/');}
23         
24 $conf['LLGBO_SETTINGS'] =  explode("," , $conf['LLGBO']);
25 $conf['LLGBO_TOOLTIP'] = explode(",",$conf['LLGBOTOOLTIP']);
26 $conf['LLGBO_FRAME'] = explode (",",$conf['LLGBOFRAME']); 
27 $conf['LLGBO_HEADER'] = explode (",",$conf['LLGBOHEADER']);   
28 
29/////////////////////////////////////////////////////
30/*  PLUGIN CLASS  */
31/////////////////////////////////////////////////////
32class look_like_gbo
33{/* Set the administration panel of the plugin */
34  function plugin_admin_menu($menu)
35  {    array_push($menu,
36        array(
37          'NAME' => 'Look_like_GBo',
38          'URL' => get_admin_plugin_menu_link(dirname(__FILE__).'/admin/llgbo_admin.php') ));
39    return $menu;  }
40
41//-------------------------------------------------------------
42/*       ALWAYS      DISPLAY      METADATA */
43//-------------------------------------------------------------
44function AutoDisplayMetadata()
45{global $conf;
46         If ($conf['LLGBO_SETTINGS'] [2]  == 'true' )  // exif under bt
47        {$_GET['metadata'] = 'O';}
48       
49        If ($conf['LLGBO_SETTINGS'][10]  == 'true' )  //always display metadata
50        {if ( pwg_get_session_var('show_metadata') == null )
51                {  pwg_set_session_var('show_metadata', 1 );
52                 }}
53}
54//-------------------------------------------------------------
55// RESET NOFOLLOW, NOINDEX
56//-------------------------------------------------------------
57function MyBeginheader()
58{ global $page,$conf;
59         If ($conf['LLGBO_SETTINGS'][2]  == 'true' ) // reset nofollow, noindex
60        { unset ($page['meta_robots']);}
61}
62//-------------------------------------------------------------
63//      MANAGE               H E A D E R
64//-------------------------------------------------------------
65function Myheader()
66{global $template,$conf;
67$page_name = script_basename();
68if (!isset($page_name)) {$page_name ='index';}
69if ($conf['LLGBO_SETTINGS'] [6] = 'true' ) 
70{$no_header = false;
71if  (  $page_name == 'index')
72        {//  print_r($_GET.'----'.$page_name );
73        if ((count ($_GET)) == 0   and ($conf['LLGBO_HEADER'][0] == 'false')) {$no_header = true;}// home
74         foreach($_GET as $cle =>$valeur)
75                {//print_r($cle.'_'.$valeur); 
76                        if ((strpos( $cle ,'categories') == true ) and ($conf['LLGBO_HEADER'][0] == 'false')) {$no_header = true;}// categories
77                        if ((strpos( $cle ,'category') == true ) and ($conf['LLGBO_HEADER'][1] == 'false')) {$no_header = true;break;}
78                        if ((strpos( $cle ,'filter=') == true ) and ($conf['LLGBO_HEADER'][2] == 'false')) {$no_header = true;break;}
79                        if ((strpos( $cle ,'categories/flat') == true ) and ($conf['LLGBO_HEADER'][3] == 'false')) {$no_header = true;break;}
80                        if ((strpos( $cle ,'categories/posted-monthly-list') == true ) and ($conf['LLGBO_HEADER'][4] == 'false')) {$no_header = true;break;}
81                        if ((strpos( $cle ,'additional_page') == true ) and ($conf['LLGBO_HEADER'][6] == 'false')) {$no_header = true;break;}
82                        if ((strpos( $cle ,'most_visited') == true ) and ($conf['LLGBO_HEADER'][7] == 'false')) {$no_header = true;break;}
83                        if ((strpos( $cle ,'best_rated') == true ) and ($conf['LLGBO_HEADER'][8] == 'false')) {$no_header = true;break;}
84                        if ((strpos( $cle ,'list') == true ) and ($conf['LLGBO_HEADER'][9] == 'false')) {$no_header = true;break;}
85                        if ((strpos( $cle ,'recent_pics') == true ) and ($conf['LLGBO_HEADER'][10] == 'false')) {$no_header = true;break;}
86                        if ((strpos( $cle ,'tags') == true ) and ($conf['LLGBO_HEADER'][11] == 'false')) {$no_header = true;break;}
87                        if ((strpos( $cle ,'created-monthly-list') == true ) and ($conf['LLGBO_HEADER'][12] == 'false')) {$no_header = true;break;}
88                        if ((strpos( $cle ,'favorites') == true ) and ($conf['LLGBO_HEADER'][19] == 'false')) {$no_header = true;break;}
89                    if ((strpos( $cle ,'recent_cats') == true ) and ($conf['LLGBO_HEADER'][20] == 'false')) {$no_header = true;break;} 
90                 }
91        }
92        //print_r($_GET.'----'.$page_name );
93 if ( $page_name == 'picture' and  $conf['LLGBO_HEADER'][5] == 'false')  {$no_header = true;}//picture page
94 if ( $page_name == 'tags' and  $conf['LLGBO_HEADER'][11] == 'false')  {$no_header = true;}//tags
95 if ( $page_name == 'search' and  $conf['LLGBO_HEADER'][13] == 'false')  {$no_header = true;}//search   
96 if ( $page_name == 'comments' and  $conf['LLGBO_HEADER'][14] == 'false')  {$no_header = true;}//comments
97 if ( $page_name == 'about' and  $conf['LLGBO_HEADER'][15] == 'false')  {$no_header = true;}//about     
98 if ( $page_name == 'notification' and  $conf['LLGBO_HEADER'][16] == 'false')  {$no_header = true;}//notification       
99 if ( $page_name == 'register' and  $conf['LLGBO_HEADER'][17] == 'false')  {$no_header = true;} //notification   
100 if ( $page_name == 'identification' and  $conf['LLGBO_HEADER'][18] == 'false')  {$no_header = true;}//about     
101 if ($no_header == true)
102{$template->append('head_elements',"\n".' <STYLE type="text/css">#theHeader{display: none}</STYLE>');}
103}       
104 
105
106 
107}  // end header
108 
109//-------------------------------------------------------------
110//* IMPROVE FUNCTIONNALITIES --> PICTURE.TPL
111//-------------------------------------------------------------
112function  DisplayGboLook()
113{ global $template,$conf,$lang;
114    $meta = "";
115        $u_metadata = $template->get_template_vars('U_METADATA');
116        $swt =   ' swttips="'; 
117         If ($conf['LLGBO_SETTINGS'] [2]  == 'true' )  // exif under bt
118                {  $metadata = $template->get_template_vars('metadata');
119                if(is_array($metadata))
120                {foreach($metadata[0] as $cle =>$tableau)
121                         { if(is_array($tableau))
122                         {   foreach($tableau as $cle=>$valeur)
123                                {   $swt= $swt.$cle.' : '.$valeur.'<br>';
124                                        $meta = 1;}
125                        }       }
126                        if  ( pwg_get_session_var('show_metadata') == 1 )
127                        {       $lang['Show file metadata'] =  'EXIF Metadata';
128                            if ($meta  != 1 ) {$lang['Show file metadata'] =  'No Metadata';}}
129                       
130                        $template->assign( 'U_METADATA', $u_metadata.'"'.$swt);
131                        $template->Clear_assign('metadata');
132                       
133        } // hide original metadata
134                }
135               
136} 
137//-----------------------------------------------------------------
138/*  ------   MANAGE PICTURE PAGE----------------    */ 
139//-----------------------------------------------------------------
140function MyPictureOptions($content )
141{global $template,$conf,$user,$lang;   
142$sweetcss = ' <! --- LLGBO tooltip css-->
143<style type="text/css"> 
144div#toolTip {position:absolute;z-index:1000;width:'.$conf['LLGBO_TOOLTIP'][0].'px;background:'.$conf['LLGBO_TOOLTIP'][3].';color:'.$conf['LLGBO_TOOLTIP'][5].';border:'.$conf['LLGBO_TOOLTIP'][1].'px solid '.$conf['LLGBO_TOOLTIP'][2].';padding:5px;min-height:1em;-moz-border-radius:5px}
145div#toolTip p {margin:0;padding:0;color:'.$conf['LLGBO_TOOLTIP'][5].';font-size:0.8em;font-family:Verdana,Arial,Helvetica,sans-serif;text-align:left}
146div#toolTip p em {display:block;margin-top:3px;font-style:normal;font-weight:bold;text-align:left}
147div#toolTip p.title {color:'.$conf['LLGBO_TOOLTIP'][4].';text-align:center;padding:0 0 3px 0;}
148</style>';
149//-----------------------------------------------------------------
150// -----------  add JS tooltip in footer --------------------
151//-----------------------------------------------------------------
152 If (($conf['LLGBO'][1]  == 'true' ) /*  tooltip  */  or  ($conf['LLGBO_SETTINGS'] [2]  == 'true' )  /* exif under bt */ 
153 or  ($conf['LLGBO_SETTINGS'] [4]  === 'true' ) /* usemap and Display Thumb  */)
154            {  $javacss = '<script type="text/javascript" charset="utf-8"  src="'.LLGBO_PATH;   
155                  $linkcss = '<link rel="stylesheet" type="text/css" href="'.LLGBO_PATH;
156              $sweetcss =  $sweetcss."\n".$javacss.'js/sweettitlesn.js"></script>'."\n"; 
157                  $template->append('footer_elements',$sweetcss); }
158//-----------------------------------------------------------------
159// Navigation improvement are always available
160//-----------------------------------------------------------------
161$ThePicture = $template->get_template_vars('current');
162$next  = $template->get_template_vars('next');
163$prev = $template->get_template_vars('previous');
164$last = $template->get_template_vars('last');
165$first = $template->get_template_vars('first');
166$swtimg =   ' swttips="<center><img src=';     
167$nextthumb_title = $next['TITLE'];
168$prevthumb_title = $prev['TITLE'];     
169$usemap ='';
170//----------------------------------------------------   
171//-------      Tooltip                        -------------     
172//----------------------------------------------------   
173If ($conf['LLGBO_SETTINGS'][1]  == 'true' )/*  tooltip  */ 
174        { $nextthumb_title = $next['TITLE'];
175        $prevthumb_title = $prev['TITLE'];
176        if (isset($first)){$template->assign('first',  array('TITLE' =>  $first['TITLE'].'"'.$swtimg.$first['THUMB_SRC'].'>',
177                                                                                'U_IMG' =>  $first['U_IMG']));}
178          if (isset($prev)){$template->assign('previous',  array('TITLE' =>  $prev['TITLE'].'"'.$swtimg.$prev['THUMB_SRC'].'>',
179                                                                                'U_IMG' =>  $prev['U_IMG'], 'THUMB_SRC' => $prev['THUMB_SRC'])); }
180          if (isset($next)){$template->assign('next',  array('TITLE' =>  $next['TITLE'].'"'.$swtimg.$next['THUMB_SRC'].'>',
181                                                                                'U_IMG' =>  $next['U_IMG'], 'THUMB_SRC' => $next['THUMB_SRC']));}
182          if (isset($last)){$template->assign('last',  array('TITLE' =>  $last['TITLE'].'"'.$swtimg.$last['THUMB_SRC'].'>',
183                                                                        'U_IMG' =>  $last['U_IMG']));}
184        }       
185///// YOGA or SIMPLE /////////////////////     
186$tpl_name = "";
187$tpl_name =   $user['theme'] ;
188/////////////////////////////////////////////
189// AN OTHER PLUGIN IS WORKING -> GO BACK
190//   - - - - - - - - - - - - - - - - - - - -
191if ( !empty($content) )   {  return $content;  }       
192//////////////////////////////////////////////////////////////////////
193// frame and navigation on picture  are only available on picture extension
194/////////////////////////////////////////////////////////////////       
195if ($ThePicture['is_picture'] <> 1 )    {  return $content;  ; }       
196//echo  strpos(strtoupper($tpl_name) , 'GALLY');
197
198if (( strpos(strtoupper($tpl_name) , 'GALLY') === 0) )
199        {       return $content;  ; }   // Not compliant with Gally
200/////////////////////////////////////////////////////////////////       
201If (($conf['LLGBO_SETTINGS'] [1]  == 'true' )/*  tooltip display  */  or ($conf['LLGBO_SETTINGS'] [0] == 'true') /*  frame  */  )
202                        {$linkcss = '<link rel="stylesheet" type="text/css" href="'.LLGBO_PATH;
203                        $template->append('head_elements',$linkcss.'css/gbolook.css">');
204                         $template->append('head_elements',"\n".' <STYLE type="text/css">#theImage{margin:auto;overflow: hidden;}</STYLE>');
205                          }
206//----------------------------------------------------   
207//-------      Usemap   values         -------------     
208//----------------------------------------------------   
209If ($conf['LLGBO_SETTINGS'] [3]  == 'true' )  // usemap
210 {      $usemap = '  usemap="#prevnext"' ;
211        $imgw = $ThePicture['scaled_width'];
212                $imgh = $ThePicture['scaled_height'];   
213                $template->assign(array(
214                        /* left --> Prev */     'LEFT_X1'  => 0,  'LEFT_Y1'  => 0, 
215                                                'LEFT_X2'  => round($imgw * 0.24), 'LEFT_Y2'  => $imgh ,
216                        /* up */                'UP_X1'  => round($imgw * 0.24) ,  'UP_Y1'  => 0,
217                                                'UP_X2'  => round($imgw * 0.76), 'UP_Y2'  => round($imgh * 0.50),
218                        /* high */              'HIGH_X1'  => round($imgw * 0.24) , 'HIGH_Y1'  => round($imgh * 0.50) ,
219                                                'HIGH_X2'  => round($imgw * 0.76), 'HIGH_Y2'  => $imgh,
220                        /* right -> next */     'RIGHT_X1'  => round($imgw * 0.76) , 'RIGHT_Y1'  => 0,
221                                                'RIGHT_X2'  =>  $imgw  , 'RIGHT_Y2'  => $imgh ));
222                $template->assign( 'USEMAP', 'ok'  );
223                                                               
224        If ($conf['LLGBO_SETTINGS'] [4]  === 'true' )  // usemap and Display Thumb
225                        { $template->assign(array('NEXTTHUMB'  => $swtimg.$next['THUMB_SRC'].'>"',
226                         'NEXTTHUMBTITLE'  => $nextthumb_title,
227                         'PREVTHUMB'  =>  $swtimg.$prev['THUMB_SRC'].'>"',
228                         'PREVTHUMBTITLE'  =>  $prevthumb_title));} 
229}  // end usemap
230
231//----------------------------------------------------   
232//                  improve alt
233//----------------------------------------------------   
234$alt = $conf['allow_html_descriptions'] ? $ThePicture['name'] : strip_tags($ThePicture['name']);
235
236/*
237$related_cats =   $template->get_template_vars('related_categories');
238if (isset($related_cats))
239        {$related_cat = strip_tags($related_cats[0]);
240        $related_cat = str_replace('&nbsp;'," ",$related_cat);
241        $related_cat = str_replace($conf['level_separator'],"-",$related_cat);
242        }
243 $alt = $alt.' - ['.$related_cat.']';*/
244//-----------------------------------------------------------------
245$template->assign( array(
246           'SRC_IMG' => $ThePicture['image_url'],
247           'WIDTH_IMG' => $ThePicture['scaled_width'],
248           'HEIGHT_IMG' => $ThePicture['scaled_height'],           
249           'ALT_IMG' =>  $alt ,
250       'MAP_TO_USED' =>   $usemap         
251           )); 
252
253If (isset($ThePicture['has_high'])and isset($ThePicture['high_url']))
254                {  $uuid = uniqid(rand());
255                 $template->assign(
256                 'high', array(
257                                'U_HIGH' => $ThePicture['high_url'] ,
258                                'UUID'   => $uuid,      ));
259                // compliance HD Shadowbox     
260                If ($conf['LLGBO_SETTINGS'] [9]  == 'true' )
261                        {$template->assign('HDHREF', ' href="'.$ThePicture['high_url'].'"'.' title= " HD --> '.$ThePicture['name'].'"');
262                          $template->append('head_elements', "\n".'<script type="text/javascript">
263                                window.onload = function() {
264                        Shadowbox.setup(document.getElementById("prevnext").getElementsByTagName("area")[3]);
265                                        }
266                        </script>'  );} 
267           else
268           {$template->assign('HDHREF','title="'.$lang['Click on the picture to see it in high definition'].'" href="javascript:phpWGOpenWindow('."'".$ThePicture['high_url']."','".$uuid."','"."scrollbars=yes,toolbar=no,status=no,resizable=yes'".')"');}               
269                       
270} 
271
272If (($conf['LLGBO_SETTINGS'] [5]  == 'true' )  /* title on frame */ and ($conf['LLGBO_SETTINGS'] [0]  == 'true' )) // display frame
273         { $template->assign('SHOW_PICTURE_NAME_ON_TITLE', false);     
274                $template->assign('TITLE_FRAME_COLOR', $conf['LLGBO_FRAME'][0]);                 } 
275               
276// compatibility with extended description
277$comment = $template->get_template_vars('COMMENT_IMG');
278if (!isset($comment) )
279                {$template->assign( 'COMMENT_IMG' , $ThePicture['comment']);}
280//----------------------------------------------------   
281/*              HTML  frame                          */
282//----------------------------------------------------   
283If (($conf['LLGBO_SETTINGS'] [0] == 'true') )
284        {   $bds = 0; 
285                $frame_begin ='';
286                $frame_end='';
287                for ($x = 1   ;$x < 32  ; $x =$x +2)
288                {       if ((isset($conf['LLGBO_FRAME'][$x+1])) and  ($conf['LLGBO_FRAME'][$x+1] > 0))  // boder value > 0     
289                          {$frame_begin = '<div id ="llgboframe'.$x.'" style="border: '.$conf['LLGBO_FRAME'][$x+1].'px solid '.$conf['LLGBO_FRAME'][$x].'">'."\n".$frame_begin;
290                                $bds =  $bds + $conf['LLGBO_FRAME'][$x+1];      //define border sum     
291                                $frame_end = $frame_end .' </div>';
292                        }
293                }
294                $frame_width = $ThePicture["scaled_width"] + (2 * $bds);
295                $frame_height = $ThePicture["scaled_height"] + (2 * $bds);
296        $template->assign('FRAME_SIZE','style="width:'.$frame_width .'px; height:'.$frame_height.'px;"');
297        $template->assign('FRAME_BEGIN', $frame_begin);
298        $template->assign('FRAME_END', $frame_end); 
299// title on frame       
300    If ($conf['LLGBO_SETTINGS'] [5]  == 'true' )  // title on frame
301                {$template->assign( array( 'TITLE_FRAME' => $ThePicture['name'] )); }   
302        }       // end frame
303        else 
304        // no frame
305{$template->clear_assign('FRAME_BEGIN') ;}
306
307$template->set_filenames( array('default_content'=> dirname(__FILE__).'/template/picture_content.tpl') );
308return $template->parse( 'default_content', true);
309} //end --> MyPictureOptions
310} // End class
311       
312/* trigger à intercepter                                   */ 
313add_event_handler('loc_begin_page_header', array(&$obj, 'MyBeginheader'));
314add_event_handler('loc_end_page_header', array(&$obj, 'Myheader'));
315Add_event_handler( 'loc_begin_picture', array(&$obj, 'AutoDisplayMetadata'));
316Add_event_handler( 'loc_end_picture', array(&$obj, 'DisplayGboLook'));
317add_event_handler('render_element_content',
318  array(&$obj,'MyPictureOptions'),  EVENT_HANDLER_PRIORITY_NEUTRAL-1,  2  );
319add_event_handler('get_admin_plugin_menu_links', array(&$obj, 'plugin_admin_menu') );
320set_plugin_data($plugin['id'], $obj);
321function afficher_tableau($tableau) 
322    {
323    // on fait une boucle qui lit les éléments du tableau
324    foreach ($tableau as $cle=>$valeur) 
325        {
326        // si l'un des éléments est lui même un tableau
327        // alors on applique la fonction à ce tableau
328        if(is_array($valeur)) 
329            {
330            // on affiche le nom de la clé et
331            // le début d'une liste pour
332            //  décaler le contenu vers la droite
333            print_r ($cle);
334                         echo  ' : <ul>'; 
335           
336            // ici se réalise la récursivité
337            // c'est à dire qu'on applique la fonction
338            // à l'élément en cours car c'est lui aussi un tableau
339            afficher_tableau($valeur); 
340           
341            // on ferme la liste
342            echo '</ul>'; 
343            }
344        } 
345    }
346?>
Note: See TracBrowser for help on using the repository browser.