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

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

LLGBO2 - Version K fix warning since version J

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