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

Last change on this file since 10838 was 10838, checked in by gbo, 13 years ago

2.2.c fix js bug with FF4.01

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