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

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

2.4F improve frame management first size and JS resize

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