source: extensions/LLGBO2/include/manage_picture_content.php

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

improve frame size when using zoom in browser -> ctrl +/-

File size: 6.1 KB
Line 
1<?php
2function llgbo_RenderContent($content,$element_info)
3/******************************************************************/
4{       //----------------------------------------------------   
5        /*      LLGBO Manage Picture_content                       */
6        //----------------------------------------------------
7        global $template,$conf; 
8        $template->assign('LLGBO_PATH',LLGBO_PATH);
9        include_once(LLGBO_PATH.'/css/sweettitles.css.php');   
10        //-----------------------------------------------------------------
11        // -----------  add CSS tooltip in footer --------------------
12        //-----------------------------------------------------------------
13         if (($conf['LLGBO2']['tooltipdisp']  )  or  ($conf['LLGBO2']['exifunderbt']))   
14                {       $template->append('footer_elements',$sweetcss);
15                        $template->append('llgbo', array( 'TOOLTIP' => 'ok' ), true);}
16        //-----------------------------------------------------------------
17        // Frame is only available on picture extension
18        //-----------------------------------------------------------------
19        unset ($conf['LLGBO2']['is-picture']); 
20         $ext = get_extension($element_info['path']);
21         if (!in_array($ext, $conf['picture_ext'])) 
22                                {return $content;}
23                               
24        $conf['LLGBO2']['is-picture'] = true;   // $content ok for update
25        $update_tpl = false ;
26        //-----------------------------------------------------------------
27        // AN OTHER PLUGIN IS WORKING -> GO BACK
28        //-----------------------------------------------------------------
29        if ( !empty($content) ) 
30                {        // 2.6 paticular case automatic size management and Modus
31                         $autosize_on = $template->get_template_vars('is_automatic_size');
32                         $current = $template->get_template_vars('current'); // modus
33                         if ((empty ($current['selected_derivative'])) and (empty($autosize_on) ))
34                                                {return $content;}                                             
35                }
36        //--------------Autosize compatibility with out frame -------------------------------------------
37                $autosize_type = $template->get_template_vars('automatic_size');
38                if (isset($autosize_type)) // auto size
39                        { $update_tpl = true ;}
40        //-----------------------------------------------------------------
41        if (($conf['LLGBO2']['frame'])   ) //Frame
42        {       $deriv_type = pwg_get_session_var('picture_deriv', $conf['derivative_default_size']);
43                $PictSizeWH =  $element_info['derivatives'][$deriv_type]->get_size();  // default conf
44                                       
45                if (isset($autosize_type)) // auto size
46                        {       $PictSizeWH =  $element_info['derivatives'][$autosize_type]->get_size(); 
47                                $update_tpl = true ;}
48                               
49                if (isset($current['selected_derivative'])) // modus
50                        {       $PictSizeWH =  $current['selected_derivative']->get_size(); 
51                                $update_tpl = true ;}
52                       
53        // -- Css Theme adaptation
54                $themeconf = $template->get_template_vars('themeconf');
55                if (file_exists(LLGBO_PATH."css/llgbo_content_".$themeconf['id'].".css")) // no css file dedicated for this theme
56                           { $themestyle = $themeconf['id'];}
57                           else
58                           {$themestyle = 'default';}
59        // -- Frame build               
60                $frame_begin = '';   
61                        $frame_border =0;               
62                        $frame_end = '</div>'."\n".' <!-- end LLGBO frame -->'."\n";
63                         foreach ($conf['LLGBO2']['FR-sizes'] as $cle  => $value) 
64                                { if ( $value > 0)      // boder value > 0     
65                                         {      $frame_border = $frame_border + ( 2 * $value);                           
66                                                $frame_begin = '<div class="llgboFR" style="border:'.$value.'px solid '.$conf['LLGBO2']['FR-colors'][$cle].'">'."\n".$frame_begin;
67                                                $frame_end = '</div>'.$frame_end;
68                                                } 
69                                }
70                        $frame_begin ="\n".'<!-- Begin LLGBO frame -->'."\n".$frame_begin;
71                        $PictSizeWH[0] = $PictSizeWH[0] + $frame_border;
72                        $PictSizeWH[1] = $PictSizeWH[1] + $frame_border;
73                        $frame_size = "\n".'<div   id="llgbo0" class="llgbo" style="border:0 ;width:'.$PictSizeWH[0].'px; height:'.$PictSizeWH[1].'px;">';
74                $frame_title = "";
75                        if ($conf['LLGBO2']['titleframe']) {
76                                $frame_title =  "\n".'<!-- Begin LLGBO -->'."\n".'<span  id="llgboh2" style ="background:transparent;z-index:3;color:'.$conf['LLGBO2']['FR-titlecolor'].'">';   
77                                }
78                               
79                        $template->append('llgbo', array(   
80                                                        'FRAME_TITLE1' => $frame_title,
81                                                        'FRAME_TITLE3' => '</span>',
82                                                        'FRAME_SIZE' => $frame_size ,
83                                                        'FRAME_BEGIN' => $frame_begin,
84                                                        'FRAME_END' => $frame_end,
85                                                         'GBOCSS' => LLGBO_PATH."css/llgbo_content_".$themestyle.".css" ), true); 
86                                                         
87                        $template->set_prefilter('default_content', 'LLGBO_prefilter_Content_Frame');           
88        } // end frame                                 
89//----------------------------------------------------   
90//-------      Tooltip                   -------------   
91//----------------------------------------------------
92        if ($conf['LLGBO2']['tooltipdisp'] )//   tooltip 
93        {       $prev = $template->get_template_vars('previous');
94                $next  = $template->get_template_vars('next');
95       
96                if (isset($prev)){
97                        $prev_thumbimg =  '||<img src='.$prev['derivatives']['thumb']->get_url(); 
98                        $template->append('previous',  array('TITLE_ESC' =>  $prev['TITLE_ESC'].$prev_thumbimg.'>'),TRUE);
99                        }
100                if (isset($next)){
101                                $next_thumbimg =  '||<img src='.$next['derivatives']['thumb']->get_url(); 
102                                $template->append('next',  array('TITLE_ESC' =>  $next['TITLE_ESC'].$next_thumbimg.'>'),TRUE);
103                        } 
104                $template->append('llgbo', array('tooltipCSS'  => $sweetcss), true); 
105        }       
106 // -----------------------------------------------------------
107 // 2.6 paticular case automatic size and modus management
108 // -----------------------------------------------------------
109        if ($update_tpl) 
110                {return $template->parse( 'default_content', true);} 
111                                               
112} //end --> llgbo_RenderContent
113
114/******************************************************************/
115function LLGBO_prefilter_Content_Frame($content, $smarty)
116/******************************************************************/
117{        // add  frame on picture_content TPL
118        // --------------------------------------   
119                $patern = '/'.'<img(.*)id="theMainImage"(.*)>'.'/';     
120        $replacement =  '{if !empty($llgbo.FRAME_TITLE1)}{$llgbo.FRAME_TITLE1}{$current.TITLE} {$llgbo.FRAME_TITLE3}{/if}{$llgbo.FRAME_SIZE}{$llgbo.FRAME_BEGIN}'."\n".'<img $1 id="theMainImage" $2>'.'{$llgbo.FRAME_END}';
121                $content = preg_replace($patern, $replacement, $content); 
122        return $content;
123}
124
125?>
Note: See TracBrowser for help on using the repository browser.