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

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

Compliance Map & earth

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