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

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

Version 2.0.i

  • Property svn:eol-style set to LF
File size: 10.4 KB
Line 
1<?php 
2/*
3Plugin Name: Look_like_gbo2
4Version:  2.0.I
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.h new languages PL, ES, HU */ 
15 /* 2.0.i Manage tab for tooltip and frame settings */
16if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
17/* création d'une instance de la classe   */
18$obj = new look_like_gbo(); /* class loading */
19global $conf,$ttvalues,$plugvalues,$frvalues; 
20define ('LLGBO_INFO_VERSION','2.0.I');
21define('LLGBO_PATH' , PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/');
22         
23 $conf['LLGBO_SETTINGS'] =  explode("," , $conf['LLGBO']);
24 $conf['LLGBO_TOOLTIP'] = explode(",",$conf['LLGBOTOOLTIP']);
25 $conf['LLGBO_FRAME'] = explode (",",$conf['LLGBOFRAME']);   
26/////////////////////////////////////////////////////
27/*  plugin Class  */
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/* always display metadata */
38function AutoDisplayMetadata()
39{global $conf;
40         If ($conf['LLGBO_SETTINGS'] [2]  == 'true' )  // exif under bt
41        {$_GET['metadata'] = 'O';}
42}
43 
44 // reset nofollow, noindex
45function MyBeginheader()
46{ global $page,$conf;
47        // echo '-10-'.$conf['LLGBO_SETTINGS',10];
48         If ($conf['LLGBO_SETTINGS'][2]  == 'true' ) // reset nofollow, noindex
49        { unset ($page['meta_robots']);}
50}
51//   manage H E A D E R
52function Myheader()
53{global $template,$conf;
54        $Page_body = $template->get_template_vars('BODY_ID');   
55        $Categories = $template->get_template_vars('U_MODE_FLAT'); // Home page
56 if ((isset ($Page_body)) )// pb with redirect.tpl
57        {If ($conf['LLGBO_SETTINGS'][6]  == 'true' )  //display Header on home page
58                { if (strpos( $Categories ,'categories') === False )
59                        { $exclu =  strtoupper($Page_body);     /*  maintain header on user  define  page */     
60                                if (strpos( strtoupper($conf['LLGBO_SETTINGS'] [7]),$exclu) === False)
61                                        {$template->append('head_elements',"\n".' <STYLE type="text/css">#theHeader{display: none}</STYLE>');}
62                        }       
63                }
64
65        //
66        If ($conf['LLGBO_SETTINGS'] [9]  == 'true' and $Page_body == 'thePicturePage')
67                {$template->append('head_elements',"\n".' <STYLE type="text/css">.navThumb{display: none} </STYLE>');}
68 }
69}  // end header
70
71//* improve functionnalities --> picture.tpl
72function  DisplayGboLook()
73{ global $template,$conf;
74        $u_metadata = $template->get_template_vars('U_METADATA');
75        $swt =   ' swttips="'; 
76         If ($conf['LLGBO_SETTINGS'] [2]  == 'true' )  // exif under bt
77                {  $metadata = $template->get_template_vars('metadata');
78                if(is_array($metadata))
79                {foreach($metadata[0] as $cle =>$tableau)
80                         { if(is_array($tableau))
81                         {foreach($tableau as $cle=>$valeur)
82                        {   $swt= $swt.$cle.' : '.$valeur.'<br>'; }
83                        }       }
84                        $template->assign( 'U_METADATA', $u_metadata.'"'.$swt);
85                $template->clear_assign('metadata');
86        } // hide original metadata
87                }
88               
89} 
90
91/*  ------   Manage picture page----------------    */ 
92function MyPictureOptions($content )
93{global $template,$conf,$user; 
94$sweetcss = ' <! --- LLGBO tooltip css-->
95<style type="text/css"> 
96div#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}
97div#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}
98div#toolTip p em {display:block;margin-top:3px;font-style:normal;font-weight:bold;text-align:left}
99div#toolTip p.title {color:'.$conf['LLGBO_TOOLTIP'][4].';text-align:center;padding:0 0 3px 0;}
100</style>';
101// -----------  add JS tooltip in header ----------------------
102 If (($conf['LLGBO'][1]  == 'true' ) /*  tooltip  */  or  ($conf['LLGBO_SETTINGS'] [2]  == 'true' )  /* exif under bt */ )
103            {  $javacss = '<script type="text/javascript" charset="utf-8"  src="'.LLGBO_PATH;   
104                  $linkcss = '<link rel="stylesheet" type="text/css" href="'.LLGBO_PATH;
105              $sweetcss =  $sweetcss."\n".$javacss.'js/sweettitlesn.js"></script>'."\n"; 
106                   $template->append('head_elements',$sweetcss); }
107
108// Navigation improvement are always available
109$ThePicture = $template->get_template_vars('current');
110$next  = $template->get_template_vars('next');
111$prev = $template->get_template_vars('previous');
112$last = $template->get_template_vars('last');
113$first = $template->get_template_vars('first');
114$swtimg =   ' swttips="<center><img src=';     
115$nextthumb_title = $next['TITLE'];
116$prevthumb_title = $prev['TITLE'];     
117$usemap ='';
118If ($conf['LLGBO_SETTINGS'][1]  == 'true' )/*  tooltip  */ 
119        { $nextthumb_title = $next['TITLE'];
120        $prevthumb_title = $prev['TITLE'];
121        if (isset($first)){$template->assign('first',  array('TITLE' =>  $first['TITLE'].'"'.$swtimg.$first['THUMB_SRC'].'>',
122                                                                                'U_IMG' =>  $first['U_IMG']));}
123          if (isset($prev)){$template->assign('previous',  array('TITLE' =>  $prev['TITLE'].'"'.$swtimg.$prev['THUMB_SRC'].'>',
124                                                                                'U_IMG' =>  $prev['U_IMG'], 'THUMB_SRC' => $prev['THUMB_SRC'])); }
125          if (isset($next)){$template->assign('next',  array('TITLE' =>  $next['TITLE'].'"'.$swtimg.$next['THUMB_SRC'].'>',
126                                                                                'U_IMG' =>  $next['U_IMG'], 'THUMB_SRC' => $next['THUMB_SRC']));}
127          if (isset($last)){$template->assign('last',  array('TITLE' =>  $last['TITLE'].'"'.$swtimg.$last['THUMB_SRC'].'>',
128                                                                        'U_IMG' =>  $last['U_IMG']));}
129        }       
130/////////////////////////////////////////////
131// an other plugin is working -> go back
132if ( !empty($content) )   {  return $content;  }       
133//////////////////////////////////////////////////////////////////////
134// frame and navigation on picture  are only available on picture extension
135/////////////////////////////////////////////////////////////////       
136if ($ThePicture['is_picture'] <> 1 )    {  return  ; } 
137/////////////////////////////////////////////////////////////////       
138If (($conf['LLGBO_SETTINGS'] [1]  == 'true' )/*  tooltip display  */  or ($conf['LLGBO_SETTINGS'] [0] == 'true') /*  frame  */  )
139                        {$linkcss = '<link rel="stylesheet" type="text/css" href="'.LLGBO_PATH;
140                        $template->append('head_elements',$linkcss.'css/gbolook.css">');}
141
142If ($conf['LLGBO_SETTINGS'] [3]  == 'true' )  // usemap
143 {      $usemap = '" usemap="#prevnext' ;
144        $imgw = $ThePicture['scaled_width'];
145                $imgh = $ThePicture['scaled_height'];   
146                $template->assign(array(
147                        /* left --> Prev */     'LEFT_X1'  => 0,  'LEFT_Y1'  => 0, 
148                                                'LEFT_X2'  => round($imgw * 0.24), 'LEFT_Y2'  => $imgh ,
149                        /* up */                'UP_X1'  => round($imgw * 0.24) ,  'UP_Y1'  => 0,
150                                                'UP_X2'  => round($imgw * 0.76), 'UP_Y2'  => round($imgh * 0.50),
151                        /* high */              'HIGH_X1'  => round($imgw * 0.24) , 'HIGH_Y1'  => round($imgh * 0.50) ,
152                                                'HIGH_X2'  => round($imgw * 0.76), 'HIGH_Y2'  => $imgh,
153                        /* right -> next */     'RIGHT_X1'  => round($imgw * 0.76) , 'RIGHT_Y1'  => 0,
154                                                'RIGHT_X2'  =>  $imgw  , 'RIGHT_Y2'  => $imgh ));
155                $template->assign( 'USEMAP', 'ok'  );
156                                                               
157        If ($conf['LLGBO_SETTINGS'] [4]  === 'true' )  // usemap and Display Thumb
158                        { $template->assign(array('NEXTTHUMB'  => $swtimg.$next['THUMB_SRC'].'>"',
159                         'NEXTTHUMBTITLE'  => $nextthumb_title,
160                         'PREVTHUMB'  =>  $swtimg.$prev['THUMB_SRC'].'>"',
161                         'PREVTHUMBTITLE'  =>  $prevthumb_title));} 
162}  // end usemap               
163$alt = $conf['allow_html_descriptions'] ? $ThePicture['name'] : strip_tags($ThePicture['name']);
164$template->assign( array(
165           'SRC_IMG' => $ThePicture['image_url'],
166           'WIDTH_IMG' => $ThePicture['scaled_width'],
167           'HEIGHT_IMG' => $ThePicture['scaled_height'],
168           'COMMENT_IMG' => $conf['allow_html_descriptions'] ? $ThePicture['comment'] : strip_tags($ThePicture['comment']),       
169           'ALT_IMG' =>  $alt.$usemap             
170           )); 
171
172If (isset($ThePicture['has_high'])and isset($ThePicture['high_url']))
173                {  $uuid = uniqid(rand());
174                 $template->assign(
175                 'high', array(
176                                'U_HIGH' => $ThePicture['high_url'] ,
177                                'UUID'   => $uuid,      ));} 
178
179If (($conf['LLGBO_SETTINGS'] [5]  == 'true' )  /* title on frame */ and ($conf['LLGBO_SETTINGS'] [0]  == 'true' )) // display frame
180         { $template->assign('SHOW_PICTURE_NAME_ON_TITLE', false);     
181                $template->assign('TITLE_FRAME_COLOR', $conf['LLGBO_FRAME'][0]);                 } 
182         
183 /* HTML  frame  */
184If (($conf['LLGBO_SETTINGS'] [0] == 'true') )
185        {   $bd = 0; 
186                $frame_begin ='';
187                $frame_end='';
188                for ($x = 1   ;$x < 32  ; $x =$x +2)
189                {       if ((isset($conf['LLGBO_FRAME'][$x+1])) and  ($conf['LLGBO_FRAME'][$x+1] > 0))  // boder value > 0     
190                          {$frame_begin = '<div style="border: '.$conf['LLGBO_FRAME'][$x+1].'px solid '.$conf['LLGBO_FRAME'][$x].'">'."\n".$frame_begin;
191                                $bd =  $bd + $conf['LLGBO_FRAME'][$x+1];        //define border sum     
192                                $frame_end = $frame_end .' </div>';
193                        }
194                }
195                $frame_width = $ThePicture["scaled_width"] + (2 * $bd);
196                $frame_height = $ThePicture["scaled_height"] + (2 * $bd);
197        $template->assign('FRAME_SIZE','style="width:'.$frame_width .'px; height:'.$frame_height.'px;"');
198        $template->assign('FRAME_BEGIN', $frame_begin);
199        $template->assign('FRAME_END', $frame_end); 
200// title on frame       
201    If ($conf['LLGBO_SETTINGS'] [5]  == 'true' )  // title on frame
202                {$template->assign( array( 'TITLE_FRAME' => $ThePicture['name'] )); }   
203        }       // end frame
204        else  // no frame
205{$template->clear_assign('FRAME_BEGIN') ;}
206
207$template->set_filenames( array('gbo_content'=> dirname(__FILE__).'/template/picture_content.tpl') );
208return $template->parse( 'gbo_content', true);
209} //end --> MyPictureOptions
210} // End class
211       
212/* trigger à intercepter                                   */ 
213add_event_handler('loc_begin_page_header', array(&$obj, 'MyBeginheader'));
214add_event_handler('loc_end_page_header', array(&$obj, 'Myheader'));
215Add_event_handler( 'loc_begin_picture', array(&$obj, 'AutoDisplayMetadata'));
216Add_event_handler( 'loc_end_picture', array(&$obj, 'DisplayGboLook'));
217add_event_handler('render_element_content',
218  array(&$obj,'MyPictureOptions'),  EVENT_HANDLER_PRIORITY_NEUTRAL-1,  2  );
219add_event_handler('get_admin_plugin_menu_links', array(&$obj, 'plugin_admin_menu') );
220set_plugin_data($plugin['id'], $obj);
221?>
Note: See TracBrowser for help on using the repository browser.