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

Last change on this file since 16859 was 16791, checked in by gbo, 12 years ago

Frame on slideshow

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