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
RevLine 
[4292]1<?php 
2/*
3Plugin Name: Look_like_gbo2
[16791]4Version:  2.4.D
[4292]5Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=251
[8867]6Author: GBo
[4292]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 ......
[16145]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
[16754]13        2.4.D Compliance with Theme Simple + fix bug on option
14        2.4.F Improvement on frame management first size
[16791]15                  Frame available on SlideShow.
[12536]16 */
[4292]17if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
[14421]18
[4603]19global $conf; 
[16754]20define ('LLGBO_INFO_VERSION','2.4.F');
[4603]21if (!defined('LLGBO_PATH'))
[6549]22{define('LLGBO_PATH' ,get_root_url().'plugins/'.basename(dirname(__FILE__)) . '/');}
[4523]23         
24 $conf['LLGBO_SETTINGS'] =  explode("," , $conf['LLGBO']);
25 $conf['LLGBO_TOOLTIP'] = explode(",",$conf['LLGBOTOOLTIP']);
[4574]26 $conf['LLGBO_FRAME'] = explode (",",$conf['LLGBOFRAME']); 
[14421]27 $conf['LLGBO_HEADER'] = explode (",",$conf['LLGBOHEADER']); 
28       
[9954]29 load_language('plugin.lang', LLGBO_PATH);
30
31/* Set the administration panel of the plugin */
[4292]32  function plugin_admin_menu($menu)
33  {    array_push($menu,
34        array(
35          'NAME' => 'Look_like_GBo',
[4523]36          'URL' => get_admin_plugin_menu_link(dirname(__FILE__).'/admin/llgbo_admin.php') ));
[4292]37    return $menu;  }
[4603]38
[4713]39//-------------------------------------------------------------
40/*       ALWAYS      DISPLAY      METADATA */
41//-------------------------------------------------------------
[14421]42function llgbo_BeginPicture()
43{global $conf,$template;
44If ($conf['LLGBO_SETTINGS'] [2]  == 'true' )  // exif under bt
[4523]45        {$_GET['metadata'] = 'O';}
[4603]46       
[14421]47If ($conf['LLGBO_SETTINGS'][10]  == 'true' )  //always display metadata
[4603]48        {if ( pwg_get_session_var('show_metadata') == null )
[6234]49                {  pwg_set_session_var('show_metadata', 1 );
50                 }}
[14421]51
[4292]52}
[14421]53
54function llgbo_beginheader()
[4523]55{ global $page,$conf;
[14421]56        If ($conf['LLGBO_SETTINGS'][2]  == 'true' ) // reset nofollow, noindex
[4523]57        { unset ($page['meta_robots']);}
[4292]58}
[4713]59//-------------------------------------------------------------
60//      MANAGE               H E A D E R
61//-------------------------------------------------------------
[14421]62function llgbo_endHeader()
[4523]63{global $template,$conf;
[4574]64$page_name = script_basename();
[14421]65include_once(LLGBO_PATH.'include/manage_header.php');
[4292]66}  // end header
[4713]67//-------------------------------------------------------------
68//* IMPROVE FUNCTIONNALITIES --> PICTURE.TPL
69//-------------------------------------------------------------
[14421]70function  llgbo_EndPicture()
[16791]71{ global $template,$conf,$page;
[16754]72$infofile = $template->get_template_vars('INFO_FILE');
73$current = $template->get_template_vars('current');
[16791]74
[16754]75//----------------------------------------------------   
76/*       HTML End  frame   on Picture.tpl       */
77//---------------------------------------------------- 
[16791]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               
[16754]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                        }
[16791]118        } //end frame
[14421]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 = "";
[4523]125        $u_metadata = $template->get_template_vars('U_METADATA');
[14421]126        $swt = "";
[4523]127         If ($conf['LLGBO_SETTINGS'] [2]  == 'true' )  // exif under bt
128                {  $metadata = $template->get_template_vars('metadata');
[14421]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))
[7891]133                                         {   foreach($tableau as $cle=>$valeur)
[14421]134                                                {   $swt= $swt.$cle.' : '.$valeur.'||';
135                                                        $meta = 1;} }   }
[7891]136                                        if  ( pwg_get_session_var('show_metadata') == 1 )
137                                        {       $lang['Show file metadata'] =  'EXIF Metadata';
[14421]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));
[4292]157} 
[4713]158//-----------------------------------------------------------------
[14421]159/*  ------   MANAGE PICTURE PAGE                --------------    */ 
[4713]160//-----------------------------------------------------------------
[14421]161function llgbo_RenderContent($content,$element_info )
[15076]162{global $template,$conf,$user,$lang,$themeconf; 
[10453]163$template->assign('LLGBO_PATH',LLGBO_PATH);
[14421]164include_once(LLGBO_PATH.'/css/sweettitles.css.php');
[4713]165//-----------------------------------------------------------------
[14421]166// -----------  add CSS tooltip in footer --------------------
[4713]167//-----------------------------------------------------------------
[16754]168 If (($conf['LLGBO_SETTINGS'][1]  == 'true' ) /*  tooltip  */ 
[14421]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
[4713]175//-----------------------------------------------------------------
176// AN OTHER PLUGIN IS WORKING -> GO BACK
[4292]177if ( !empty($content) )   {  return $content;  }       
[14421]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
[6234]183
[16754]184function LLGBO_prefilter_Content_Frame($content, &$smarty)
185{   //  End frame  picture_content TPL
186  global $themeconf;
[16145]187  $search = '{foreach from=$current.unique_derivatives';
188  $replacement =  "\n".'{$llgbo.FRAME_END}'."\n"."</div> <!-- end GBO frame -->"."\n".$search;
[15076]189 if (( strpos(strtoupper($themeconf['name']) , 'STRIPPED') === 0) ) 
[16145]190        {$search = 'class="hideTabs">';
191  $replacement =  $search."\n".'{$llgbo.FRAME_END}'."\n"."</div> <!-- end GBO frame -->";}
[15076]192  return str_replace($search, $replacement, $content);
[14421]193}
[4713]194
[16754]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
[4292]206/* trigger à intercepter                                   */ 
[14421]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' );
[4292]213?>
Note: See TracBrowser for help on using the repository browser.