1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: Look_like_gbo2 |
---|
4 | Version: 2.5.A |
---|
5 | Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=251 |
---|
6 | Author: GBo |
---|
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 | 2.4.A Beta1 Compliance Piwigo 2.4 + jquery |
---|
11 | 2.4.B beta 2 Compliance with Theme Stripped and plugin Piwishak |
---|
12 | 2.4.C First version for official Piwigo 2.4 |
---|
13 | 2.4.D Compliance with Theme Simple + fix bug on option |
---|
14 | 2.4.F Improvement on frame management first size |
---|
15 | Frame available on SlideShow. |
---|
16 | 2.4.G Compliance with plugin RV MAP & EARTH |
---|
17 | -- 05-05-2013 |
---|
18 | 2.5.A Fix bug back to default values after deactivates / reactivates actions |
---|
19 | */ |
---|
20 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
21 | |
---|
22 | global $conf; |
---|
23 | define ('LLGBO_INFO_VERSION','2.5.A'); |
---|
24 | if (!defined('LLGBO_PATH')) |
---|
25 | {define('LLGBO_PATH' ,get_root_url().'plugins/'.basename(dirname(__FILE__)) . '/');} |
---|
26 | |
---|
27 | $conf['LLGBO_SETTINGS'] = explode("," , $conf['LLGBO']); |
---|
28 | $conf['LLGBO_TOOLTIP'] = explode(",",$conf['LLGBOTOOLTIP']); |
---|
29 | $conf['LLGBO_FRAME'] = explode (",",$conf['LLGBOFRAME']); |
---|
30 | $conf['LLGBO_HEADER'] = explode (",",$conf['LLGBOHEADER']); |
---|
31 | |
---|
32 | load_language('plugin.lang', LLGBO_PATH); |
---|
33 | |
---|
34 | /* Set the administration panel of the plugin */ |
---|
35 | function plugin_admin_menu($menu) |
---|
36 | { array_push($menu, |
---|
37 | array( |
---|
38 | 'NAME' => 'Look_like_GBo', |
---|
39 | 'URL' => get_admin_plugin_menu_link(dirname(__FILE__).'/admin/llgbo_admin.php') )); |
---|
40 | return $menu; } |
---|
41 | |
---|
42 | //------------------------------------------------------------- |
---|
43 | /* ALWAYS DISPLAY METADATA */ |
---|
44 | //------------------------------------------------------------- |
---|
45 | function llgbo_BeginPicture() |
---|
46 | {global $conf,$template; |
---|
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 | } |
---|
56 | |
---|
57 | function llgbo_beginheader() |
---|
58 | { global $page,$conf; |
---|
59 | If ($conf['LLGBO_SETTINGS'][2] == 'true' ) // reset nofollow, noindex |
---|
60 | { unset ($page['meta_robots']);} |
---|
61 | } |
---|
62 | //------------------------------------------------------------- |
---|
63 | // MANAGE H E A D E R |
---|
64 | //------------------------------------------------------------- |
---|
65 | function llgbo_endHeader() |
---|
66 | {global $template,$conf; |
---|
67 | $page_name = script_basename(); |
---|
68 | include_once(LLGBO_PATH.'include/manage_header.php'); |
---|
69 | } // end header |
---|
70 | //------------------------------------------------------------- |
---|
71 | //* IMPROVE FUNCTIONNALITIES --> PICTURE.TPL |
---|
72 | //------------------------------------------------------------- |
---|
73 | function llgbo_EndPicture() |
---|
74 | { global $template,$conf,$page; |
---|
75 | $infofile = $template->get_template_vars('INFO_FILE'); |
---|
76 | $current = $template->get_template_vars('current'); |
---|
77 | //---------------------------------------------------- |
---|
78 | /* HTML End frame on Picture.tpl */ |
---|
79 | //---------------------------------------------------- |
---|
80 | If (($conf['LLGBO_SETTINGS'] [0] == 'true') //Frame |
---|
81 | and ($conf['LLGBO_RENDERCONTENT'] == 'true') ) // $content ok for update |
---|
82 | { $target = 'picture'; |
---|
83 | if ($page['slideshow'] and $conf['light_slideshow']) |
---|
84 | { $target = 'slideshow';} |
---|
85 | $template->set_prefilter($target, 'LLGBO_prefilter_Picture_Frame'); |
---|
86 | |
---|
87 | If (isset($conf['LLGBO_SETTINGS'] ['rirs'])) |
---|
88 | { // Force javascript LlgboFr_Resize to Read MainImage Reel Size via URL |
---|
89 | // Must be used when html image is already resize by HTML (IE or Chrome) |
---|
90 | If ($conf['LLGBO_SETTINGS'] ['rirs'] == 'true') // Forcce javascript to read Image reel size |
---|
91 | {$template->append('llgbo', array('READIMGREELSIZE' => "ok"), true); } |
---|
92 | } |
---|
93 | // selected picture Size |
---|
94 | $PictSizeWH = $current['selected_derivative']->get_size(); |
---|
95 | $frame_width = $PictSizeWH[0]; |
---|
96 | $frame_height = $PictSizeWH[1]; |
---|
97 | $lastbrdpx = 0; |
---|
98 | $frame_begin =''; |
---|
99 | for ($x = 1 ;$x < 32 ; $x =$x +2) |
---|
100 | { if ((isset($conf['LLGBO_FRAME'][$x+1])) and ($conf['LLGBO_FRAME'][$x+1] > 0)) // boder value > 0 |
---|
101 | { $bordpx= $conf['LLGBO_FRAME'][$x+1]; |
---|
102 | $frame_width = $frame_width + ( 2* $lastbrdpx); |
---|
103 | $frame_height = $frame_height + ( 2* $lastbrdpx); |
---|
104 | $bordcolor = $conf['LLGBO_FRAME'][$x]; |
---|
105 | $frame_begin = '<div id="llgboframe'.$x.'" class="llgbo" style="border:'.$bordpx.'px solid '.$bordcolor.'">'."\n".$frame_begin; |
---|
106 | $lastbrdpx = $bordpx;} |
---|
107 | } |
---|
108 | $frame_width = $frame_width + ( 2* $lastbrdpx); |
---|
109 | $frame_height = $frame_height + ( 2* $lastbrdpx); |
---|
110 | $frame_size = 'style="border:0 ;width:'.$frame_width.'px; height:'.$frame_height.'px;"'; |
---|
111 | $template->append('llgbo', array( |
---|
112 | 'FRAME_SIZE' => $frame_size, |
---|
113 | 'FRAME_BEGIN' => $frame_begin), true); |
---|
114 | If (($conf['LLGBO_SETTINGS'] [5] == 'true' ) /* title on frame */ |
---|
115 | and ($conf['LLGBO_SETTINGS'] [0] == 'true' ) )// frame |
---|
116 | { $template->append('llgbo', array( |
---|
117 | 'TITLE_FRAME_COLOR' => $conf['LLGBO_FRAME'][0], |
---|
118 | 'TITLE_FRAME' => $current['name'] ), true); |
---|
119 | $template->assign('SHOW_PICTURE_NAME_ON_TITLE' , false); |
---|
120 | } |
---|
121 | } //end frame |
---|
122 | // ---- Metadata ---------- |
---|
123 | $pictExt = substr($infofile,-3); |
---|
124 | if (!in_array ( $pictExt,$conf['picture_ext'])) |
---|
125 | {$lang['Show file metadata'] = 'No Metadata';} |
---|
126 | else |
---|
127 | { |
---|
128 | if ($conf['show_exif'] == true) // No exif ? |
---|
129 | {$meta = ""; |
---|
130 | $u_metadata = $template->get_template_vars('U_METADATA'); |
---|
131 | $swt = ""; |
---|
132 | If ($conf['LLGBO_SETTINGS'] [2] == 'true' ) // exif under bt |
---|
133 | { $metadata = $template->get_template_vars('metadata'); |
---|
134 | if (is_array($metadata)) |
---|
135 | { if (isset($metadata[0]) and is_array($metadata[0])) |
---|
136 | {foreach($metadata[0] as $cle =>$tableau) |
---|
137 | { if(is_array($tableau)) |
---|
138 | { foreach($tableau as $cle=>$valeur) |
---|
139 | { $swt= $swt.$cle.' : '.$valeur.'||'; |
---|
140 | $meta = 1;} } } |
---|
141 | if ( pwg_get_session_var('show_metadata') == 1 ) |
---|
142 | { $lang['Show file metadata'] = 'EXIF Metadata'; |
---|
143 | if (isset($metadata[0] ['TITLE'])) // advanced meta |
---|
144 | {$lang['Show file metadata'] = $metadata [0] ['TITLE'];} |
---|
145 | if ($meta != 1 ) {$lang['Show file metadata'] = 'No Metadata';} |
---|
146 | } |
---|
147 | $template->assign( 'U_METADATA', $u_metadata.'" title="'.$lang['Show file metadata']."||".$swt); |
---|
148 | unset( $metadata[0]); |
---|
149 | $template->Clear_assign('metadata');// hide original metadata |
---|
150 | $template->assign('metadata',$metadata);} // original metadata item > 0 |
---|
151 | } |
---|
152 | else |
---|
153 | {if ( pwg_get_session_var('show_metadata') == 1 ) |
---|
154 | {$lang['Show file metadata'] = 'No Metadata'; |
---|
155 | $template->assign( 'U_METADATA', $u_metadata.'" title="'.$lang['Show file metadata']);} |
---|
156 | } |
---|
157 | } |
---|
158 | } |
---|
159 | } |
---|
160 | // Add llgbo requirement to ELEMENT_CONTENT |
---|
161 | $template->set_filenames( array('llgbo_content'=> dirname(__FILE__).'/template/llgbo_content.tpl') ); |
---|
162 | $template->concat('ELEMENT_CONTENT', $template->parse('llgbo_content', true)); |
---|
163 | } |
---|
164 | //----------------------------------------------------------------- |
---|
165 | /* ------ MANAGE PICTURE PAGE -------------- */ |
---|
166 | //----------------------------------------------------------------- |
---|
167 | function llgbo_RenderContent($content,$element_info ) |
---|
168 | {global $template,$conf,$user,$lang,$themeconf; |
---|
169 | $template->assign('LLGBO_PATH',LLGBO_PATH); |
---|
170 | include_once(LLGBO_PATH.'/css/sweettitles.css.php'); |
---|
171 | //----------------------------------------------------------------- |
---|
172 | // ----------- add CSS tooltip in footer -------------------- |
---|
173 | //----------------------------------------------------------------- |
---|
174 | If (($conf['LLGBO_SETTINGS'][1] == 'true' ) /* tooltip */ |
---|
175 | or ($conf['LLGBO_SETTINGS'] [2] == 'true' ) /* exif under bt */ ) |
---|
176 | { $template->append('footer_elements',$sweetcss); |
---|
177 | $template->append('llgbo', array( 'TOOLTIP' => 'ok' ), true);} |
---|
178 | |
---|
179 | /* If ($conf['LLGBO_SETTINGS'] [3] == 'true' ) switch free {} */ |
---|
180 | $conf['LLGBO_RENDERCONTENT'] = 'false'; |
---|
181 | //----------------------------------------------------------------- |
---|
182 | // AN OTHER PLUGIN IS WORKING -> GO BACK |
---|
183 | if ( !empty($content) ) { return $content; } |
---|
184 | // frame and navigation on picture are only available on picture extension |
---|
185 | $pictExt = substr($element_info['file'],-3); |
---|
186 | if (!in_array ( $pictExt,$conf['picture_ext'])) { return $content; ; } |
---|
187 | $conf['LLGBO_RENDERCONTENT'] = 'true'; // $content ok for update |
---|
188 | include_once(LLGBO_PATH.'include/manage_picture_content.php'); |
---|
189 | } //end --> llgbo_RenderContent |
---|
190 | |
---|
191 | function LLGBO_prefilter_Content_Frame($content, &$smarty) |
---|
192 | { // End frame picture_content TPL |
---|
193 | global $themeconf; |
---|
194 | $search = '{foreach from=$current.unique_derivatives'; |
---|
195 | $replacement = "\n".'{$llgbo.FRAME_END}'."\n"."</div> <!-- end GBO frame -->"."\n".$search; |
---|
196 | if (( strpos(strtoupper($themeconf['name']) , 'STRIPPED') === 0) ) |
---|
197 | {$search = 'class="hideTabs">'; |
---|
198 | $replacement = $search."\n".'{$llgbo.FRAME_END}'."\n"."</div> <!-- end GBO frame -->";} |
---|
199 | return str_replace($search, $replacement, $content); |
---|
200 | } |
---|
201 | |
---|
202 | function LLGBO_prefilter_Picture_Frame($content, &$smarty) |
---|
203 | { |
---|
204 | // ------------------------ |
---|
205 | // begin frame on picture TPL |
---|
206 | $search = '{$ELEMENT_CONTENT}'; |
---|
207 | $replacement = '{if isset($llgbo.TITLE_FRAME)}'."\n".'<span id="llgboh2" style ="background:transparent;z-index:3;color:{$llgbo.TITLE_FRAME_COLOR}">{$llgbo.TITLE_FRAME}</span>'; |
---|
208 | $replacement = $replacement."\n".'{/if}'."\n".'<div id="llgbo0" class="llgbo" {$llgbo.FRAME_SIZE}>'."\n".'{$llgbo.FRAME_BEGIN}'."\n".$search; |
---|
209 | // ------------------------ |
---|
210 | return str_replace($search, $replacement, $content); |
---|
211 | } |
---|
212 | |
---|
213 | /* trigger à intercepter */ |
---|
214 | add_event_handler('loc_begin_page_header', 'llgbo_beginheader'); |
---|
215 | add_event_handler('loc_end_page_header', 'llgbo_endHeader'); |
---|
216 | Add_event_handler( 'loc_begin_picture','llgbo_BeginPicture'); |
---|
217 | Add_event_handler( 'loc_end_picture', 'llgbo_EndPicture'); |
---|
218 | add_event_handler('render_element_content', 'llgbo_RenderContent', EVENT_HANDLER_PRIORITY_NEUTRAL-1, 20 ); |
---|
219 | add_event_handler('get_admin_plugin_menu_links', 'plugin_admin_menu' ); |
---|
220 | ?> |
---|