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

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

compliance Piwigo 2.2rc1

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