1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: Look_like_gbo2 |
---|
4 | Version: 2.0.h |
---|
5 | Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=251 |
---|
6 | Author: Ex-Ftb |
---|
7 | Author URI: http://www.photos.bouteyron.fr/ |
---|
8 | Description: Display thumbnail under button. Add navigation on picture look like GBo Gallery |
---|
9 | Add a border around picture ...... |
---|
10 | */ |
---|
11 | /* 2.0.c2 fix null value in js <> in IE,FF, chrome*/ |
---|
12 | /* 2.0.d fix notice when HD picture is desactivate*/ |
---|
13 | /* 2.0.e fix notice with redirect.tpl */ |
---|
14 | /* 2.0.f always display metadata + maintain IPTC */ |
---|
15 | /* 2.0.h new languages PL, ES, HU */ |
---|
16 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
17 | /* création d'une instance de la classe */ |
---|
18 | $obj = new look_like_gbo(); /* class loading */ |
---|
19 | global $conf,$conf_LLGBO; |
---|
20 | |
---|
21 | define ('LLGBO_INFO_VERSION','2.0.h'); |
---|
22 | define('LLGBO_PATH' , PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/'); |
---|
23 | $conf_LLGBO = explode("," , $conf['LLGBO']); |
---|
24 | //print_r ($conf_LLGBO); |
---|
25 | $conf_LLGBO['fsize'] = getimagesize(LLGBO_PATH.'pictures/chg_25.png');/* width of a cormer*/ |
---|
26 | // |
---|
27 | /* plugin Class */ |
---|
28 | class 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 | ) |
---|
36 | ); |
---|
37 | return $menu; } |
---|
38 | |
---|
39 | /* always display metadata */ |
---|
40 | function AutoDisplayMetadata() |
---|
41 | {global $conf_LLGBO; |
---|
42 | If ($conf_LLGBO[10] == 'true' ) //always display metadata |
---|
43 | {if ( pwg_get_session_var('show_metadata') == null ) |
---|
44 | { pwg_set_session_var('show_metadata', 1 ); } |
---|
45 | } |
---|
46 | } |
---|
47 | |
---|
48 | // reset nofollow, noindex |
---|
49 | function MyBeginheader() |
---|
50 | { global $page,$conf_LLGBO; |
---|
51 | If ($conf_LLGBO[10] == 'true' ) // reset nofollow, noindex |
---|
52 | { unset ($page['meta_robots']);} |
---|
53 | } |
---|
54 | // manage H E A D E R |
---|
55 | function Myheader() |
---|
56 | { global $template,$conf_LLGBO; |
---|
57 | $Page_body = $template->get_template_vars('BODY_ID'); |
---|
58 | $Categories = $template->get_template_vars('U_MODE_FLAT'); // Home page |
---|
59 | |
---|
60 | |
---|
61 | If ($conf_LLGBO[6] == 'true' ) //display Header on home page |
---|
62 | { if (strpos( $Categories ,'categories') === False ) |
---|
63 | { $exclu = strtoupper($Page_body); /* maintain header on user define page */ |
---|
64 | if ($exclu == '') {$exclu = '¤¤¤¤¤¤';} // Pb with redirect.tpl |
---|
65 | if (strpos( strtoupper($conf_LLGBO[7]),$exclu) === False) |
---|
66 | {$template->append('head_elements',"\n".' <STYLE type="text/css">#theHeader{display: none}</STYLE>'); |
---|
67 | } |
---|
68 | } |
---|
69 | } |
---|
70 | if ( $Page_body == 'thePicturePage') |
---|
71 | { If (($conf_LLGBO[1] == 'true' )/* tooltip */ or ($conf_LLGBO[0] == 'true') /* frame */ ) |
---|
72 | {$linkcss = '<link rel="stylesheet" type="text/css" href="'.LLGBO_PATH; |
---|
73 | $template->append('head_elements',$linkcss.'css/gbolook.css">');} |
---|
74 | } |
---|
75 | |
---|
76 | //-------------------------------------- |
---|
77 | // |
---|
78 | If ($conf_LLGBO[9] == 'true' and $Page_body == 'thePicturePage') |
---|
79 | {$template->append('head_elements',"\n".' <STYLE type="text/css">.navThumb{display: none} </STYLE>');} |
---|
80 | } // end header |
---|
81 | |
---|
82 | //* improve functionnalities --> picture.tpl |
---|
83 | function DisplayGboLook() |
---|
84 | { global $template,$conf_LLGBO; |
---|
85 | $u_metadata = $template->get_template_vars('U_METADATA'); |
---|
86 | $swt = ' swttips="'; |
---|
87 | If ($conf_LLGBO[2] == 'true' ) // exif under bt |
---|
88 | { $metadata = $template->get_template_vars('metadata'); |
---|
89 | if(is_array($metadata)) |
---|
90 | {foreach($metadata[0] as $cle =>$tableau) |
---|
91 | { if(is_array($tableau)) |
---|
92 | {foreach($tableau as $cle=>$valeur) |
---|
93 | { $swt= $swt.$cle.' : '.$valeur.'<br>'; } |
---|
94 | } } |
---|
95 | /* IPTC |
---|
96 | foreach($metadata[1] as $cle =>$tableau) |
---|
97 | { if(is_array($tableau)) |
---|
98 | {foreach($tableau as $cle=>$valeur) |
---|
99 | { $swt= $swt.$cle.' : '.'<br>'.$valeur.'<br>'; } |
---|
100 | } } */ |
---|
101 | $template->assign( 'U_METADATA', $u_metadata.'"'.$swt); |
---|
102 | unset ($metadata[0]); |
---|
103 | $template-> assign('metadata', $metadata);} // keep iptc under picture |
---|
104 | } |
---|
105 | // compatibility with extended description |
---|
106 | $ThePicture = $template->get_template_vars('current'); |
---|
107 | $comment = $template->get_template_vars('COMMENT_IMG'); |
---|
108 | if (!isset($comment) ) |
---|
109 | {$template->assign( 'COMMENT_IMG' , $ThePicture['comment']);} |
---|
110 | } |
---|
111 | /* ------ Manage frame ---------------- */ |
---|
112 | function MyPictureOptions($content ) |
---|
113 | {global $template,$conf_LLGBO,$conf,$user; |
---|
114 | // ----------- add JS tooltip in header ---------------------- |
---|
115 | If (($conf_LLGBO[1] == 'true' ) /* tooltip */ or ($conf_LLGBO[2] == 'true' ) /* exif under bt */ ) |
---|
116 | { $javacss = '<script type="text/javascript" charset="utf-8" src="'.LLGBO_PATH; |
---|
117 | $linkcss = '<link rel="stylesheet" type="text/css" href="'.LLGBO_PATH; |
---|
118 | $sweetcss = "\n".$linkcss.'css/sweettitles.css">'."\n".$javacss.'js/sweettitlesn.js"></script>'."\n"; |
---|
119 | $template->append('head_elements',$sweetcss); } |
---|
120 | $template->assign('PLUG_REL_PATH', LLGBO_PATH); |
---|
121 | // Navigation improvement are always available |
---|
122 | $ThePicture = $template->get_template_vars('current'); |
---|
123 | $next = $template->get_template_vars('next'); |
---|
124 | $prev = $template->get_template_vars('previous'); |
---|
125 | $last = $template->get_template_vars('last'); |
---|
126 | $first = $template->get_template_vars('first'); |
---|
127 | $swtimg = ' swttips="<center><img src='; |
---|
128 | $nextthumb_title = $next['TITLE']; |
---|
129 | $prevthumb_title = $prev['TITLE']; |
---|
130 | $usemap =''; |
---|
131 | If ($conf_LLGBO[1] == 'true' )/* tooltip */ |
---|
132 | { |
---|
133 | if (isset($first)){$template->assign('first', array('TITLE' => $first['TITLE'].'"'.$swtimg.$first['THUMB_SRC'].'>', |
---|
134 | 'U_IMG' => $first['U_IMG']));} |
---|
135 | if (isset($prev)){$template->assign('previous', array('TITLE' => $prev['TITLE'].'"'.$swtimg.$prev['THUMB_SRC'].'>', |
---|
136 | 'U_IMG' => $prev['U_IMG'], 'THUMB_SRC' => $prev['THUMB_SRC'])); } |
---|
137 | if (isset($next)){$template->assign('next', array('TITLE' => $next['TITLE'].'"'.$swtimg.$next['THUMB_SRC'].'>', |
---|
138 | 'U_IMG' => $next['U_IMG'], 'THUMB_SRC' => $next['THUMB_SRC']));} |
---|
139 | if (isset($last)){$template->assign('last', array('TITLE' => $last['TITLE'].'"'.$swtimg.$last['THUMB_SRC'].'>', |
---|
140 | 'U_IMG' => $last['U_IMG']));} |
---|
141 | } |
---|
142 | |
---|
143 | ///////////////////////////////////////////// |
---|
144 | // an other plugin is working -> go back |
---|
145 | if ( !empty($content) ) { return $content; } |
---|
146 | ////////////////////////////////////////////////////////////////////// |
---|
147 | // frame and navigation on picture are only available on picture extension |
---|
148 | ///////////////////////////////////////////////////////////////// |
---|
149 | if ($ThePicture['is_picture'] <> 1 ) { return ; } |
---|
150 | ///////////////////////////////////////////////////////////////// |
---|
151 | If (($conf_LLGBO[0] == 'true') /* frame */ ) |
---|
152 | { $template->assign('FRAME', 'ok'); |
---|
153 | $template->assign(array( |
---|
154 | 'WIDTH_GBO' => $ThePicture['scaled_width'] + ( 2 * $conf_LLGBO['fsize'][0] /* frame width*/ ), |
---|
155 | 'WIDTH_FRAME' => $conf_LLGBO['fsize'][0], |
---|
156 | 'HEIGHT_FRAME' => $conf_LLGBO['fsize'][1]/* frame height*/ )); |
---|
157 | If ($conf_LLGBO[5] == 'true' ) // title on frame |
---|
158 | {$template->assign( array( 'TITLE_FRAME' => $ThePicture['name'] )); } |
---|
159 | }// end frame |
---|
160 | else // no frame |
---|
161 | {$template->clear_assign('FRAME') ;} |
---|
162 | If ($conf_LLGBO[3] == 'true' ) // usemap |
---|
163 | { $usemap = '" usemap="#prevnext' ; |
---|
164 | $imgw = $ThePicture['scaled_width']; |
---|
165 | $imgh = $ThePicture['scaled_height']; |
---|
166 | $dummy = round($imgw /15); |
---|
167 | $template->assign(array( |
---|
168 | /* left --> Prev */ |
---|
169 | 'LEFT_X1' => 0, 'LEFT_Y1' => 0, |
---|
170 | 'LEFT_X2' => round($imgw * 0.22), 'LEFT_Y2' => $imgh , |
---|
171 | /* up */ |
---|
172 | 'UP_X1' => round($imgw * 0.22) + $dummy, 'UP_Y1' => 0, |
---|
173 | 'UP_X2' => round($imgw * 0.78), 'UP_Y2' => round($imgh * 0.50), |
---|
174 | /* high */ |
---|
175 | 'HIGH_X1' => round($imgw * 0.22) + $dummy, 'HIGH_Y1' => round($imgh * 0.50) + $dummy, |
---|
176 | 'HIGH_X2' => round($imgw * 0.78), 'HIGH_Y2' => $imgh, |
---|
177 | /* right -> next */ |
---|
178 | 'RIGHT_X1' => round($imgw * 0.78) + $dummy, 'RIGHT_Y1' => 0, |
---|
179 | 'RIGHT_X2' => $imgw , 'RIGHT_Y2' => $imgh )); |
---|
180 | $template->assign( 'USEMAP', 'ok' ); |
---|
181 | |
---|
182 | If ($conf_LLGBO[4] === 'true' ) // usemap and Display Thumb |
---|
183 | { $template->assign(array('NEXTTHUMB' => $swtimg.$next['THUMB_SRC'].'>"', |
---|
184 | 'NEXTTHUMBTITLE' => $nextthumb_title, |
---|
185 | 'PREVTHUMB' => $swtimg.$prev['THUMB_SRC'].'>"', |
---|
186 | 'PREVTHUMBTITLE' => $prevthumb_title));} |
---|
187 | |
---|
188 | } // end usemap |
---|
189 | $alt = $conf['allow_html_descriptions'] ? $ThePicture['name'] : strip_tags($ThePicture['name']); |
---|
190 | $template->assign( array( |
---|
191 | 'SRC_IMG' => $ThePicture['image_url'], |
---|
192 | 'WIDTH_IMG' => $ThePicture['scaled_width'], |
---|
193 | 'HEIGHT_IMG' => $ThePicture['scaled_height'], |
---|
194 | 'ALT_IMG' => $alt.$usemap |
---|
195 | )); |
---|
196 | |
---|
197 | If (isset($ThePicture['has_high'])and isset($ThePicture['high_url'])) |
---|
198 | { $uuid = uniqid(rand()); |
---|
199 | $template->assign( |
---|
200 | 'high', array( |
---|
201 | 'U_HIGH' => $ThePicture['high_url'] , |
---|
202 | 'UUID' => $uuid, ));} |
---|
203 | |
---|
204 | |
---|
205 | If (($conf_LLGBO[5] == 'true' ) /* title on frame */ and ($conf_LLGBO[0] == 'true' )) // display frame |
---|
206 | { $template->assign('SHOW_PICTURE_NAME_ON_TITLE', false); } |
---|
207 | |
---|
208 | If ($conf_LLGBO[8] == 'off' ) /* less infos*/ |
---|
209 | { /* enregistrer le filtre de pr?-compilation */} |
---|
210 | |
---|
211 | $template->set_filenames( array('gbo_content'=> dirname(__FILE__).'/template/picture_content.tpl') ); |
---|
212 | return $template->parse( 'gbo_content', true); |
---|
213 | } |
---|
214 | |
---|
215 | } // End class |
---|
216 | |
---|
217 | /* trigger à intercepter */ |
---|
218 | add_event_handler('loc_begin_page_header', array(&$obj, 'MyBeginheader')); |
---|
219 | add_event_handler('loc_end_page_header', array(&$obj, 'Myheader')); |
---|
220 | Add_event_handler( 'loc_begin_picture', array(&$obj, 'AutoDisplayMetadata')); |
---|
221 | Add_event_handler( 'loc_end_picture', array(&$obj, 'DisplayGboLook')); |
---|
222 | add_event_handler('render_element_content', |
---|
223 | array(&$obj,'MyPictureOptions'), EVENT_HANDLER_PRIORITY_NEUTRAL-1, 2 ); |
---|
224 | add_event_handler('get_admin_plugin_menu_links', array(&$obj, 'plugin_admin_menu') ); |
---|
225 | set_plugin_data($plugin['id'], $obj); |
---|
226 | function afficher_tableau($tableau) |
---|
227 | { |
---|
228 | // on fait une boucle qui lit les éléments du tableau |
---|
229 | foreach ($tableau as $cle=>$valeur) |
---|
230 | { |
---|
231 | // si l'un des éléments est lui même un tableau |
---|
232 | // alors on applique la fonction à ce tableau |
---|
233 | if(is_array($valeur)) |
---|
234 | { |
---|
235 | // on affiche le nom de la clé et |
---|
236 | // le début d'une liste pour |
---|
237 | // décaler le contenu vers la droite |
---|
238 | print_r ($cle); |
---|
239 | echo ' : <ul>'; |
---|
240 | |
---|
241 | // ici se réalise la récursivité |
---|
242 | // c'est à dire qu'on applique la fonction |
---|
243 | // à l'élément en cours car c'est lui aussi un tableau |
---|
244 | afficher_tableau($valeur); |
---|
245 | |
---|
246 | // on ferme la liste |
---|
247 | echo '</ul>'; |
---|
248 | } |
---|
249 | } |
---|
250 | } |
---|
251 | |
---|
252 | ?> |
---|