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

Last change on this file since 9091 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
RevLine 
[4292]1<?php 
2/*
3Plugin Name: Look_like_gbo2
[8867]4Version:  2.2.a
[4292]5Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=251
[8867]6Author: GBo
[4292]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 ......
[8867]10  2.2.a compliant 2.2 Piwigo
11*/
[4292]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 */
[4603]15global $conf; 
16
[8867]17define ('LLGBO_INFO_VERSION','2.2.a');
[4603]18if (!defined('LLGBO_PATH'))
[6549]19{define('LLGBO_PATH' ,get_root_url().'plugins/'.basename(dirname(__FILE__)) . '/');}
[4523]20         
21 $conf['LLGBO_SETTINGS'] =  explode("," , $conf['LLGBO']);
22 $conf['LLGBO_TOOLTIP'] = explode(",",$conf['LLGBOTOOLTIP']);
[4574]23 $conf['LLGBO_FRAME'] = explode (",",$conf['LLGBOFRAME']); 
24 $conf['LLGBO_HEADER'] = explode (",",$conf['LLGBOHEADER']);   
[6259]25 
[4523]26/////////////////////////////////////////////////////
[4713]27/*  PLUGIN CLASS  */
28/////////////////////////////////////////////////////
[4292]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',
[4523]35          'URL' => get_admin_plugin_menu_link(dirname(__FILE__).'/admin/llgbo_admin.php') ));
[4292]36    return $menu;  }
[4603]37
[4713]38//-------------------------------------------------------------
39/*       ALWAYS      DISPLAY      METADATA */
40//-------------------------------------------------------------
[4292]41function AutoDisplayMetadata()
[4523]42{global $conf;
43         If ($conf['LLGBO_SETTINGS'] [2]  == 'true' )  // exif under bt
44        {$_GET['metadata'] = 'O';}
[4603]45       
46        If ($conf['LLGBO_SETTINGS'][10]  == 'true' )  //always display metadata
47        {if ( pwg_get_session_var('show_metadata') == null )
[6234]48                {  pwg_set_session_var('show_metadata', 1 );
49                 }}
[4292]50}
[4713]51//-------------------------------------------------------------
52// RESET NOFOLLOW, NOINDEX
53//-------------------------------------------------------------
[4292]54function MyBeginheader()
[4523]55{ global $page,$conf;
56         If ($conf['LLGBO_SETTINGS'][2]  == 'true' ) // reset nofollow, noindex
57        { unset ($page['meta_robots']);}
[4292]58}
[4713]59//-------------------------------------------------------------
60//      MANAGE               H E A D E R
61//-------------------------------------------------------------
[4292]62function Myheader()
[4523]63{global $template,$conf;
[4574]64$page_name = script_basename();
[4578]65if (!isset($page_name)) {$page_name ='index';}
[4574]66if ($conf['LLGBO_SETTINGS'] [6] = 'true' ) 
67{$no_header = false;
[6549]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         
[4574]93        }
94        //print_r($_GET.'----'.$page_name );
[6549]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         }
[4574]106 if ($no_header == true)
[6704]107{$template->append('head_elements','<!-- llgbo -->'."\n".'<STYLE type="text/css">'."\n".'#theHeader{display: none}'."\n".'header_msgs {position:static}'."\n".'</STYLE>');}
[4574]108}       
109 
[4292]110}  // end header
[4713]111 
112//-------------------------------------------------------------
113//* IMPROVE FUNCTIONNALITIES --> PICTURE.TPL
114//-------------------------------------------------------------
[4292]115function  DisplayGboLook()
[6234]116{ global $template,$conf,$lang;
[6649]117$ThePicture = $template->get_template_vars('current'); 
118// 2.1.f fix notice with video
119if ($ThePicture['is_picture'] <> 1 ) 
[7891]120        {  $lang['Show file metadata'] =  'No Metadata';
[6649]121                return;}
122// ---------------------------         
[6234]123    $meta = "";
[4523]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');
[7891]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);
[6704]141                               
[7891]142                                 unset( $metadata[0]); 
[6704]143                                 $template->Clear_assign('metadata');// hide original metadata 
[7891]144                                 $template->assign('metadata',$metadata);//  original metadata item > 0
145                                }       
[6704]146                        } 
[7891]147                }
[4523]148               
[4292]149} 
[4713]150//-----------------------------------------------------------------
151/*  ------   MANAGE PICTURE PAGE----------------    */ 
152//-----------------------------------------------------------------
[4292]153function MyPictureOptions($content )
[4713]154{global $template,$conf,$user,$lang;   
[6549]155$llgbo_path = get_root_url().'plugins/'.basename(dirname(__FILE__)) . '/';
[4523]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>';
[4713]163//-----------------------------------------------------------------
164// -----------  add JS tooltip in footer --------------------
165//-----------------------------------------------------------------
[4574]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  */)
[6549]168            {  $javacss = '<script type="text/javascript" charset="utf-8"  src="'.$llgbo_path;
[4523]169              $sweetcss =  $sweetcss."\n".$javacss.'js/sweettitlesn.js"></script>'."\n"; 
[4713]170                  $template->append('footer_elements',$sweetcss); }
171//-----------------------------------------------------------------
[4292]172// Navigation improvement are always available
[4713]173//-----------------------------------------------------------------
[4292]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 ='';
[4713]183//----------------------------------------------------   
184//-------      Tooltip                        -------------     
185//----------------------------------------------------   
[4523]186If ($conf['LLGBO_SETTINGS'][1]  == 'true' )/*  tooltip  */ 
187        { $nextthumb_title = $next['TITLE'];
188        $prevthumb_title = $prev['TITLE'];
[4292]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        }       
[4713]198///// YOGA or SIMPLE /////////////////////     
[6234]199$tpl_name = "";
[6428]200$tpl_name =   $user['theme'] ;
[4292]201/////////////////////////////////////////////
[4713]202// AN OTHER PLUGIN IS WORKING -> GO BACK
203//   - - - - - - - - - - - - - - - - - - - -
[4292]204if ( !empty($content) )   {  return $content;  }       
205//////////////////////////////////////////////////////////////////////
206// frame and navigation on picture  are only available on picture extension
207/////////////////////////////////////////////////////////////////       
[4713]208if ($ThePicture['is_picture'] <> 1 )    {  return $content;  ; }       
[8867]209//echo  strpos(strtoupper($tpl_name) , 'GALLY');
[6234]210
[8867]211//if (( strpos(strtoupper($tpl_name) , 'GALLY') === 0) )
212//      {       return $content;  ; }   // Not compliant with Gally
[4523]213/////////////////////////////////////////////////////////////////       
214If (($conf['LLGBO_SETTINGS'] [1]  == 'true' )/*  tooltip display  */  or ($conf['LLGBO_SETTINGS'] [0] == 'true') /*  frame  */  )
[6549]215                        { $linkcss = '<link rel="stylesheet" type="text/css" href="'.$llgbo_path;
[4713]216                        $template->append('head_elements',$linkcss.'css/gbolook.css">');
[7891]217                         $template->append('head_elements',"\n".' <STYLE type="text/css">#theImage{margin:auto;overflow: hidden;}</STYLE>');
[6234]218                          }
[4713]219//----------------------------------------------------   
220//-------      Usemap   values         -------------     
221//----------------------------------------------------   
[4523]222If ($conf['LLGBO_SETTINGS'] [3]  == 'true' )  // usemap
[4729]223 {      $usemap = '  usemap="#prevnext"' ;
[4713]224        $imgw = $ThePicture['scaled_width'];
[4292]225                $imgh = $ThePicture['scaled_height'];   
226                $template->assign(array(
[4523]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'  );
[4292]236                                                               
[4523]237        If ($conf['LLGBO_SETTINGS'] [4]  === 'true' )  // usemap and Display Thumb
[4292]238                        { $template->assign(array('NEXTTHUMB'  => $swtimg.$next['THUMB_SRC'].'>"',
239                         'NEXTTHUMBTITLE'  => $nextthumb_title,
240                         'PREVTHUMB'  =>  $swtimg.$prev['THUMB_SRC'].'>"',
[4523]241                         'PREVTHUMBTITLE'  =>  $prevthumb_title));} 
[4713]242}  // end usemap
243
244//----------------------------------------------------   
245//                  improve alt
246//----------------------------------------------------   
[4728]247$alt = $conf['allow_html_descriptions'] ? $ThePicture['name'] : strip_tags($ThePicture['name']);
[6234]248
[6241]249/*
[4713]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);
[4728]255        }
[6549]256 $alt = $alt.' - ['.$related_cat.']'; */
[4713]257//-----------------------------------------------------------------
[4292]258$template->assign( array(
[4523]259           'SRC_IMG' => $ThePicture['image_url'],
[4292]260           'WIDTH_IMG' => $ThePicture['scaled_width'],
[4869]261           'HEIGHT_IMG' => $ThePicture['scaled_height'],           
[4729]262           'ALT_IMG' =>  $alt ,
263       'MAP_TO_USED' =>   $usemap         
[4292]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'] ,
[6234]271                                'UUID'   => $uuid,      ));
[6241]272                // compliance HD Shadowbox     
[6234]273                If ($conf['LLGBO_SETTINGS'] [9]  == 'true' )
[7891]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>'  );} 
[6234]279           else
[8867]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'".')"');}                 
[6234]281                       
282} 
[4292]283
[4523]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]);                 } 
[4869]287               
288// compatibility with extended description
289$comment = $template->get_template_vars('COMMENT_IMG');
290if (!isset($comment) )
291                {$template->assign( 'COMMENT_IMG' , $ThePicture['comment']);}
[4713]292//----------------------------------------------------   
293/*              HTML  frame                          */
294//----------------------------------------------------   
[4523]295If (($conf['LLGBO_SETTINGS'] [0] == 'true') )
[4591]296        {   $bds = 0; 
[4523]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     
[4591]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     
[4523]303                                $frame_end = $frame_end .' </div>';
304                        }
305                }
[4591]306                $frame_width = $ThePicture["scaled_width"] + (2 * $bds);
307                $frame_height = $ThePicture["scaled_height"] + (2 * $bds);
[4523]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
[4713]315        else 
316        // no frame
[4523]317{$template->clear_assign('FRAME_BEGIN') ;}
[4292]318
[6234]319$template->set_filenames( array('default_content'=> dirname(__FILE__).'/template/picture_content.tpl') );
320return $template->parse( 'default_content', true);
[4523]321} //end --> MyPictureOptions
[4292]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);
[4603]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    }
[4292]358?>
Note: See TracBrowser for help on using the repository browser.