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

Last change on this file since 7249 was 6704, checked in by gbo, 14 years ago

Improve header message

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