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

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

fix bug on activation (reset parameter)

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