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

Last change on this file since 28990 was 28990, checked in by gbo, 10 years ago

Release 27..A new admin part

  • Property svn:eol-style set to LF
File size: 10.5 KB
Line 
1<?php 
2/*
3Plugin Name: Look_like_gbo2
4Version: 2.7.A
5Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=251
6Author: GBo
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        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        2.5.B Fix bug  back to default values after  deactivates / reactivates actions (with API)
20        2.5.C Fix bug  notice with $lang
21-- 30-12-2013   
22                2.6.A Compliance Piwigo 2.6     and automatic size
23-- 01-07-2014   
24                2.7.A Compliance Piwigo 2.7     new administration management
25 */
26if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
27
28
29// +-----------------------------------------------------------------------+
30// | Plugin constants                                               |
31// +-----------------------------------------------------------------------+
32define('LLGBO_VERSION', '2.7.A');
33define('LLGBO_ID',       basename(dirname(__FILE__)));
34define('LLGBO_PATH' ,    PHPWG_PLUGINS_PATH . LLGBO_ID . '/');
35define('LLGBO_ADMIN',    get_root_url() . 'admin.php?page=plugin-' . LLGBO_ID);
36// +-----------------------------------------------------------------------+
37/*                               Set the administration panel of the plugin */
38// +-----------------------------------------------------------------------+
39function llgbo_admin_menu($menu)
40  { 
41        $menu[] = array(
42                'NAME' => 'Look like Gbo',
43                'URL' => LLGBO_ADMIN,
44    );
45  return $menu;
46        }
47// +-----------------------------------------------------------------------+
48// | Plugin initialization                                                 |
49// +-----------------------------------------------------------------------+
50function llgbo_init()
51{
52        global $conf,$CF_LLGBO;
53        Load_language('plugin.lang', LLGBO_PATH);
54
55        $CF_LLGBO2settings =  unserialize($conf['LLGBO2settings']);
56        $CF_LLGBO2tooltip = unserialize($conf['LLGBO2tooltip']);
57        $CF_LLGBO2frame = unserialize($conf['LLGBO2frame']);
58        $CF_LLGBO2header = unserialize($conf['LLGBO2header']);
59        $CF_LLGBO =array_merge((array)$CF_LLGBO2settings, (array)$CF_LLGBO2tooltip,(array) $CF_LLGBO2frame,(array) $CF_LLGBO2header);
60}
61
62
63/******************************************************************/
64/*       ALWAYS      DISPLAY      METADATA */
65/******************************************************************/
66function llgbo_BeginPicture()
67/******************************************************************/
68{global $CF_LLGBO,$template;
69        If ($CF_LLGBO['exifunderbt'])  // exif under bt
70                {$_GET['metadata'] = 'O';}
71               
72        If ($CF_LLGBO['alwaysdisplayexif'])  //always display metadata
73                {if ( pwg_get_session_var('show_metadata') == null )
74                        {  pwg_set_session_var('show_metadata', 1 );     }
75                }
76}// --------------- end begin picture
77
78/******************************************************************/
79//      MANAGE     BEGIN          H E A D E R
80/******************************************************************/
81function llgbo_beginheader()
82/******************************************************************/
83{ global $page,$CF_LLGBO;
84        If ($CF_LLGBO['exifunderbt'] ) // reset nofollow, noindex
85        { unset ($page['meta_robots']);}
86}
87/******************************************************************/
88//      MANAGE               H E A D E R
89/******************************************************************/
90function llgbo_endHeader()
91/******************************************************************/
92{global $template,$conf,$CF_LLGBO;
93        $page_name = script_basename();
94        include_once(LLGBO_PATH.'include/manage_header.php');
95}  // --------------- end header
96
97
98/******************************************************************/
99//* IMPROVE FUNCTIONNALITIES --> PICTURE.TPL
100/******************************************************************/
101function  llgbo_EndPicture()
102/******************************************************************/
103{ global $template,$CF_LLGBO,$conf,$page,$lang;
104        //----------------------------------------------------   
105        /*       HTML End  frame   on Picture.tpl       */
106        //---------------------------------------------------- 
107                       
108        If (($CF_LLGBO['frame'])    //Frame
109                 and ($CF_LLGBO['rendercontent'])       )// $content ok for update
110                {       $target = 'picture';
111                        if ($page['slideshow'] and $conf['light_slideshow'])
112                        { $target = 'slideshow';}
113                        $template->set_prefilter($target, 'LLGBO_prefilter_Picture_Frame');
114                 //$PictSizeWH is not already defined by auto_size     
115                  $current= $template->get_template_vars('current'); 
116                  if (empty($CF_LLGBO['PictSizeWH']))
117                                {$CF_LLGBO['PictSizeWH'] =  $current['selected_derivative']->get_size();}
118                        $PictSizeWH = $CF_LLGBO['PictSizeWH'];         
119                        $frame_width  = $PictSizeWH[0];
120                        $frame_height = $PictSizeWH[1];
121                        $frame_begin ='';
122                         foreach ($CF_LLGBO['FR-sizes'] as $cle  => $value) 
123                                { if ( $value > 0)      // boder value > 0     
124                                         {      $frame_width = $frame_width + ( 2 * $value);                             
125                                                $frame_height = $frame_height + ( 2* $value); 
126                                                $frame_begin = '<div class="llgboFR" style="border:'.$value.'px solid '.$CF_LLGBO['FR-colors'][$cle].'">'."\n".$frame_begin;
127                                                } 
128                                }
129                               
130                        $frame_size = "\n".'<!-- Begin LLGBO frame -->'."\n".'<div   id="llgbo0" class="llgbo" style="border:0 ;width:'.$frame_width.'px; height:'.$frame_height.'px;">';
131                        $template->append('llgbo', array(
132                                 'FRAME_SIZE' => $frame_size ,
133                                 'FRAME_BEGIN' => $frame_begin), true); 
134                                 
135                If ($CF_LLGBO['titleframe'] ) 
136                         {  $template->append('llgbo', array(
137                                         'TITLE_FRAME_COLOR' => $CF_LLGBO['FR-titlecolor'],
138                                         'TITLE_FRAME' => $current['name'] ), true);
139                                $template->assign('SHOW_PICTURE_NAME_ON_TITLE' , false); 
140                                }                       
141                } //--------------- end frame
142               
143       
144        // ---- Metadata ----------     
145        $ext = get_extension($current['path']);
146        if (!in_array($ext, $conf['picture_ext'])) 
147                {$lang['Show file metadata'] =  'No Metadata';}
148                else
149                {if ($conf['show_exif']) // No exif ?
150                        {$meta = "";
151                        $u_metadata = $template->get_template_vars('U_METADATA');
152                        $swt = "";
153                         If ($CF_LLGBO['exifunderbt'])  // exif under bt
154                                {  $metadata = $template->get_template_vars('metadata');
155                                if (is_array($metadata)) 
156                                  {  if (isset($metadata[0]) and is_array($metadata[0]))
157                                                {foreach($metadata[0] as $cle =>$tableau)
158                                                        { if(is_array($tableau))
159                                                         {   foreach($tableau as $cle=>$valeur)
160                                                                {   $swt= $swt.$cle.' : '.$valeur.'||';
161                                                                        $meta = 1;} }   }
162                                                        if  ( pwg_get_session_var('show_metadata') == 1 )
163                                                        {       $lang['Show file metadata'] =  'EXIF Metadata';
164                                                                 if (isset($metadata[0] ['TITLE'])) // advanced meta
165                                                                {$lang['Show file metadata']    = $metadata [0] ['TITLE'];}
166                                                                if ($meta  != 1 ) {$lang['Show file metadata'] =  'No Metadata';}
167                                                        }
168                                                        $template->assign( 'U_METADATA', $u_metadata.'" title="'.$lang['Show file metadata']."||".$swt);
169                                                        unset( $metadata[0]); 
170                                                         $template->Clear_assign('metadata');// hide original metadata 
171                                                         $template->assign('metadata',$metadata);} //  original metadata item > 0       
172                                  }
173                                  else
174                                  {if  ( pwg_get_session_var('show_metadata') == 1 )
175                                  {$lang['Show file metadata'] =  'No Metadata';
176                                   $template->assign( 'U_METADATA', $u_metadata.'" title="'.$lang['Show file metadata']);}
177                                   }
178                                } 
179                        }
180                }
181        // --------------------------------------
182        // Add llgbo requirement to ELEMENT_CONTENT
183        // --------------------------------------
184        $template->set_filenames( array('llgbo_content'=> dirname(__FILE__).'/template/llgbo_content.tpl') );
185        $template->concat('picture', $template->parse('llgbo_content', true));
186} 
187
188
189
190/******************************************************************
191                        ------   MANAGE PICTURE PAGE                --------------     
192 ******************************************************************/
193 // --> function llgbo_RenderContent($content,$element_info)
194 include_once(LLGBO_PATH.'include/manage_picture_content.php');
195/******************************************************************/             
196 
197
198
199/******************************************************************/
200function LLGBO_prefilter_Content_Frame($content, $smarty)
201/******************************************************************/
202{ 
203// --------------------------------------
204// add  End frame  picture_content TPL
205// --------------------------------------
206  global $themeconf;
207  $search = '{foreach from=$current.unique_derivatives';
208  $replacement = '{$llgbo.FRAME_END}'.'</div>'."\n".' <!-- end LLGBO frame -->'."\n".$search;
209        if (( strpos(strtoupper($themeconf['name']) , 'STRIPPED') === 0) ) 
210                {$search = 'class="hideTabs">';
211                $replacement =  $search
212                .'{$llgbo.FRAME_END}'
213                ."</div>";
214                }
215   if (( strpos(strtoupper($themeconf['name']) , 'PWGCARBON_DFT') === 0) ) 
216                {$search = '{if $DISPLAY_NAV_THUMB}';
217                $replacement =   '{$llgbo.FRAME_END}'
218                ."</div>"."</div> <!-- end GBO frame -->"
219                .$search;
220                } 
221  $content = str_replace($search, $replacement, $content); 
222  return $content;
223}
224
225
226/******************************************************************/
227function LLGBO_prefilter_Picture_Frame($content, $smarty)
228/******************************************************************/
229{ 
230// ------------------------------------
231//  add begin frame on picture TPL
232// --------------------------------------
233 $search = '<div id="theImage">';
234 $replacement = $search."\n".'{if isset($llgbo.TITLE_FRAME)}'."\n".'<span  id="llgboh2" style ="background:transparent;z-index:3;color:{$llgbo.TITLE_FRAME_COLOR}">{$llgbo.TITLE_FRAME}</span>';
235 $replacement = $replacement."\n".'{/if}'."\n".'{$llgbo.FRAME_SIZE}'."\n".'{$llgbo.FRAME_BEGIN}';
236
237// ------------------------
238  return  str_replace($search, $replacement, $content);
239
240}
241/******************************************************************/
242//    trigger à intercepter   
243/******************************************************************/   
244 add_event_handler('init', 'llgbo_init'); 
245if (defined('IN_ADMIN'))
246{
247  add_event_handler('get_admin_plugin_menu_links', 'llgbo_admin_menu');
248}
249else
250{                   
251        add_event_handler('loc_begin_page_header', 'llgbo_beginheader');
252        add_event_handler('loc_end_page_header', 'llgbo_endHeader');
253        Add_event_handler( 'loc_begin_picture','llgbo_BeginPicture');
254        Add_event_handler( 'loc_end_picture', 'llgbo_EndPicture');
255        add_event_handler('render_element_content', 'llgbo_RenderContent',  EVENT_HANDLER_PRIORITY_NEUTRAL-1, 20  );
256}
257
258?>
Note: See TracBrowser for help on using the repository browser.