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

Last change on this file since 12536 was 12536, checked in by gbo, 12 years ago

version 2.3.a new language

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