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

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

daily correction for 2.1

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