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

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

2.1.b with the good label

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