Changeset 28990 for extensions/LLGBO2/main.inc.php
- Timestamp:
- Jul 7, 2014, 9:26:18 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/LLGBO2/main.inc.php
r22144 r28990 2 2 /* 3 3 Plugin Name: Look_like_gbo2 4 Version: 2.5.B4 Version: 2.7.A 5 5 Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=251 6 6 Author: GBo … … 18 18 2.5.A Fix bug back to default values after deactivates / reactivates actions 19 19 2.5.B Fix bug back to default values after deactivates / reactivates actions (with API) 20 2.5.C Fix bug notice with $lang 21 -- 30-12-2013 22 2.6.A Compliance Piwigo 2.6 and automatic size 23 -- 01-07-2014 24 2.7.A Compliance Piwigo 2.7 new administration management 20 25 */ 21 26 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 22 27 23 global $conf; 24 define ('LLGBO_INFO_VERSION','2.5.B'); 25 if (!defined('LLGBO_PATH')) 26 {define('LLGBO_PATH', PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)). '/');} 27 28 $conf['LLGBO_SETTINGS'] = explode("," , $conf['LLGBO']); 29 $conf['LLGBO_TOOLTIP'] = explode(",",$conf['LLGBOTOOLTIP']); 30 $conf['LLGBO_FRAME'] = explode (",",$conf['LLGBOFRAME']); 31 $conf['LLGBO_HEADER'] = explode (",",$conf['LLGBOHEADER']); 28 29 // +-----------------------------------------------------------------------+ 30 // | Plugin constants | 31 // +-----------------------------------------------------------------------+ 32 define('LLGBO_VERSION', '2.7.A'); 33 define('LLGBO_ID', basename(dirname(__FILE__))); 34 define('LLGBO_PATH' , PHPWG_PLUGINS_PATH . LLGBO_ID . '/'); 35 define('LLGBO_ADMIN', get_root_url() . 'admin.php?page=plugin-' . LLGBO_ID); 36 // +-----------------------------------------------------------------------+ 37 /* Set the administration panel of the plugin */ 38 // +-----------------------------------------------------------------------+ 39 function llgbo_admin_menu($menu) 40 { 41 $menu[] = array( 42 'NAME' => 'Look like Gbo', 43 'URL' => LLGBO_ADMIN, 44 ); 45 return $menu; 46 } 47 // +-----------------------------------------------------------------------+ 48 // | Plugin initialization | 49 // +-----------------------------------------------------------------------+ 50 function llgbo_init() 51 { 52 global $conf,$CF_LLGBO; 53 Load_language('plugin.lang', LLGBO_PATH); 54 55 $CF_LLGBO2settings = unserialize($conf['LLGBO2settings']); 56 $CF_LLGBO2tooltip = unserialize($conf['LLGBO2tooltip']); 57 $CF_LLGBO2frame = unserialize($conf['LLGBO2frame']); 58 $CF_LLGBO2header = unserialize($conf['LLGBO2header']); 59 $CF_LLGBO =array_merge((array)$CF_LLGBO2settings, (array)$CF_LLGBO2tooltip,(array) $CF_LLGBO2frame,(array) $CF_LLGBO2header); 60 } 61 62 63 /******************************************************************/ 64 /* ALWAYS DISPLAY METADATA */ 65 /******************************************************************/ 66 function llgbo_BeginPicture() 67 /******************************************************************/ 68 {global $CF_LLGBO,$template; 69 If ($CF_LLGBO['exifunderbt']) // exif under bt 70 {$_GET['metadata'] = 'O';} 71 72 If ($CF_LLGBO['alwaysdisplayexif']) //always display metadata 73 {if ( pwg_get_session_var('show_metadata') == null ) 74 { pwg_set_session_var('show_metadata', 1 ); } 75 } 76 }// --------------- end begin picture 77 78 /******************************************************************/ 79 // MANAGE BEGIN H E A D E R 80 /******************************************************************/ 81 function llgbo_beginheader() 82 /******************************************************************/ 83 { global $page,$CF_LLGBO; 84 If ($CF_LLGBO['exifunderbt'] ) // reset nofollow, noindex 85 { unset ($page['meta_robots']);} 86 } 87 /******************************************************************/ 88 // MANAGE H E A D E R 89 /******************************************************************/ 90 function llgbo_endHeader() 91 /******************************************************************/ 92 {global $template,$conf,$CF_LLGBO; 93 $page_name = script_basename(); 94 include_once(LLGBO_PATH.'include/manage_header.php'); 95 } // --------------- end header 96 97 98 /******************************************************************/ 99 //* IMPROVE FUNCTIONNALITIES --> PICTURE.TPL 100 /******************************************************************/ 101 function llgbo_EndPicture() 102 /******************************************************************/ 103 { global $template,$CF_LLGBO,$conf,$page,$lang; 104 //---------------------------------------------------- 105 /* HTML End frame on Picture.tpl */ 106 //---------------------------------------------------- 107 108 If (($CF_LLGBO['frame']) //Frame 109 and ($CF_LLGBO['rendercontent']) )// $content ok for update 110 { $target = 'picture'; 111 if ($page['slideshow'] and $conf['light_slideshow']) 112 { $target = 'slideshow';} 113 $template->set_prefilter($target, 'LLGBO_prefilter_Picture_Frame'); 114 //$PictSizeWH is not already defined by auto_size 115 $current= $template->get_template_vars('current'); 116 if (empty($CF_LLGBO['PictSizeWH'])) 117 {$CF_LLGBO['PictSizeWH'] = $current['selected_derivative']->get_size();} 118 $PictSizeWH = $CF_LLGBO['PictSizeWH']; 119 $frame_width = $PictSizeWH[0]; 120 $frame_height = $PictSizeWH[1]; 121 $frame_begin =''; 122 foreach ($CF_LLGBO['FR-sizes'] as $cle => $value) 123 { if ( $value > 0) // boder value > 0 124 { $frame_width = $frame_width + ( 2 * $value); 125 $frame_height = $frame_height + ( 2* $value); 126 $frame_begin = '<div class="llgboFR" style="border:'.$value.'px solid '.$CF_LLGBO['FR-colors'][$cle].'">'."\n".$frame_begin; 127 } 128 } 129 130 $frame_size = "\n".'<!-- Begin LLGBO frame -->'."\n".'<div id="llgbo0" class="llgbo" style="border:0 ;width:'.$frame_width.'px; height:'.$frame_height.'px;">'; 131 $template->append('llgbo', array( 132 'FRAME_SIZE' => $frame_size , 133 'FRAME_BEGIN' => $frame_begin), true); 134 135 If ($CF_LLGBO['titleframe'] ) 136 { $template->append('llgbo', array( 137 'TITLE_FRAME_COLOR' => $CF_LLGBO['FR-titlecolor'], 138 'TITLE_FRAME' => $current['name'] ), true); 139 $template->assign('SHOW_PICTURE_NAME_ON_TITLE' , false); 140 } 141 } //--------------- end frame 142 32 143 33 load_language('plugin.lang', LLGBO_PATH); 34 35 /* Set the administration panel of the plugin */ 36 function plugin_admin_menu($menu) 37 { array_push($menu, 38 array( 39 'NAME' => 'Look_like_GBo', 40 'URL' => get_admin_plugin_menu_link(dirname(__FILE__).'/admin/llgbo_admin.php') )); 41 return $menu; } 42 43 //------------------------------------------------------------- 44 /* ALWAYS DISPLAY METADATA */ 45 //------------------------------------------------------------- 46 function llgbo_BeginPicture() 47 {global $conf,$template; 48 If ($conf['LLGBO_SETTINGS'] [2] == 'true' ) // exif under bt 49 {$_GET['metadata'] = 'O';} 50 51 If ($conf['LLGBO_SETTINGS'][10] == 'true' ) //always display metadata 52 {if ( pwg_get_session_var('show_metadata') == null ) 53 { pwg_set_session_var('show_metadata', 1 ); 54 }} 55 56 } 57 58 function llgbo_beginheader() 59 { global $page,$conf; 60 If ($conf['LLGBO_SETTINGS'][2] == 'true' ) // reset nofollow, noindex 61 { unset ($page['meta_robots']);} 62 } 63 //------------------------------------------------------------- 64 // MANAGE H E A D E R 65 //------------------------------------------------------------- 66 function llgbo_endHeader() 67 {global $template,$conf; 68 $page_name = script_basename(); 69 include_once(LLGBO_PATH.'include/manage_header.php'); 70 } // end header 71 //------------------------------------------------------------- 72 //* IMPROVE FUNCTIONNALITIES --> PICTURE.TPL 73 //------------------------------------------------------------- 74 function llgbo_EndPicture() 75 { global $template,$conf,$page; 76 $infofile = $template->get_template_vars('INFO_FILE'); 77 $current = $template->get_template_vars('current'); 78 //---------------------------------------------------- 79 /* HTML End frame on Picture.tpl */ 80 //---------------------------------------------------- 81 If (($conf['LLGBO_SETTINGS'] [0] == 'true') //Frame 82 and ($conf['LLGBO_RENDERCONTENT'] == 'true') ) // $content ok for update 83 { $target = 'picture'; 84 if ($page['slideshow'] and $conf['light_slideshow']) 85 { $target = 'slideshow';} 86 $template->set_prefilter($target, 'LLGBO_prefilter_Picture_Frame'); 87 88 If (isset($conf['LLGBO_SETTINGS'] ['rirs'])) 89 { // Force javascript LlgboFr_Resize to Read MainImage Reel Size via URL 90 // Must be used when html image is already resize by HTML (IE or Chrome) 91 If ($conf['LLGBO_SETTINGS'] ['rirs'] == 'true') // Forcce javascript to read Image reel size 92 {$template->append('llgbo', array('READIMGREELSIZE' => "ok"), true); } 144 // ---- Metadata ---------- 145 $ext = get_extension($current['path']); 146 if (!in_array($ext, $conf['picture_ext'])) 147 {$lang['Show file metadata'] = 'No Metadata';} 148 else 149 {if ($conf['show_exif']) // No exif ? 150 {$meta = ""; 151 $u_metadata = $template->get_template_vars('U_METADATA'); 152 $swt = ""; 153 If ($CF_LLGBO['exifunderbt']) // exif under bt 154 { $metadata = $template->get_template_vars('metadata'); 155 if (is_array($metadata)) 156 { if (isset($metadata[0]) and is_array($metadata[0])) 157 {foreach($metadata[0] as $cle =>$tableau) 158 { if(is_array($tableau)) 159 { foreach($tableau as $cle=>$valeur) 160 { $swt= $swt.$cle.' : '.$valeur.'||'; 161 $meta = 1;} } } 162 if ( pwg_get_session_var('show_metadata') == 1 ) 163 { $lang['Show file metadata'] = 'EXIF Metadata'; 164 if (isset($metadata[0] ['TITLE'])) // advanced meta 165 {$lang['Show file metadata'] = $metadata [0] ['TITLE'];} 166 if ($meta != 1 ) {$lang['Show file metadata'] = 'No Metadata';} 167 } 168 $template->assign( 'U_METADATA', $u_metadata.'" title="'.$lang['Show file metadata']."||".$swt); 169 unset( $metadata[0]); 170 $template->Clear_assign('metadata');// hide original metadata 171 $template->assign('metadata',$metadata);} // original metadata item > 0 172 } 173 else 174 {if ( pwg_get_session_var('show_metadata') == 1 ) 175 {$lang['Show file metadata'] = 'No Metadata'; 176 $template->assign( 'U_METADATA', $u_metadata.'" title="'.$lang['Show file metadata']);} 177 } 178 } 93 179 } 94 // selected picture Size95 $PictSizeWH = $current['selected_derivative']->get_size();96 $frame_width = $PictSizeWH[0];97 $frame_height = $PictSizeWH[1];98 $lastbrdpx = 0;99 $frame_begin ='';100 for ($x = 1 ;$x < 32 ; $x =$x +2)101 { if ((isset($conf['LLGBO_FRAME'][$x+1])) and ($conf['LLGBO_FRAME'][$x+1] > 0)) // boder value > 0102 { $bordpx= $conf['LLGBO_FRAME'][$x+1];103 $frame_width = $frame_width + ( 2* $lastbrdpx);104 $frame_height = $frame_height + ( 2* $lastbrdpx);105 $bordcolor = $conf['LLGBO_FRAME'][$x];106 $frame_begin = '<div id="llgboframe'.$x.'" class="llgbo" style="border:'.$bordpx.'px solid '.$bordcolor.'">'."\n".$frame_begin;107 $lastbrdpx = $bordpx;}108 180 } 109 $frame_width = $frame_width + ( 2* $lastbrdpx); 110 $frame_height = $frame_height + ( 2* $lastbrdpx); 111 $frame_size = 'style="border:0 ;width:'.$frame_width.'px; height:'.$frame_height.'px;"'; 112 $template->append('llgbo', array( 113 'FRAME_SIZE' => $frame_size, 114 'FRAME_BEGIN' => $frame_begin), true); 115 If (($conf['LLGBO_SETTINGS'] [5] == 'true' ) /* title on frame */ 116 and ($conf['LLGBO_SETTINGS'] [0] == 'true' ) )// frame 117 { $template->append('llgbo', array( 118 'TITLE_FRAME_COLOR' => $conf['LLGBO_FRAME'][0], 119 'TITLE_FRAME' => $current['name'] ), true); 120 $template->assign('SHOW_PICTURE_NAME_ON_TITLE' , false); 121 } 122 } //end frame 123 // ---- Metadata ---------- 124 $pictExt = substr($infofile,-3); 125 if (!in_array ( $pictExt,$conf['picture_ext'])) 126 {$lang['Show file metadata'] = 'No Metadata';} 127 else 128 { 129 if ($conf['show_exif'] == true) // No exif ? 130 {$meta = ""; 131 $u_metadata = $template->get_template_vars('U_METADATA'); 132 $swt = ""; 133 If ($conf['LLGBO_SETTINGS'] [2] == 'true' ) // exif under bt 134 { $metadata = $template->get_template_vars('metadata'); 135 if (is_array($metadata)) 136 { if (isset($metadata[0]) and is_array($metadata[0])) 137 {foreach($metadata[0] as $cle =>$tableau) 138 { if(is_array($tableau)) 139 { foreach($tableau as $cle=>$valeur) 140 { $swt= $swt.$cle.' : '.$valeur.'||'; 141 $meta = 1;} } } 142 if ( pwg_get_session_var('show_metadata') == 1 ) 143 { $lang['Show file metadata'] = 'EXIF Metadata'; 144 if (isset($metadata[0] ['TITLE'])) // advanced meta 145 {$lang['Show file metadata'] = $metadata [0] ['TITLE'];} 146 if ($meta != 1 ) {$lang['Show file metadata'] = 'No Metadata';} 147 } 148 $template->assign( 'U_METADATA', $u_metadata.'" title="'.$lang['Show file metadata']."||".$swt); 149 unset( $metadata[0]); 150 $template->Clear_assign('metadata');// hide original metadata 151 $template->assign('metadata',$metadata);} // original metadata item > 0 152 } 153 else 154 {if ( pwg_get_session_var('show_metadata') == 1 ) 155 {$lang['Show file metadata'] = 'No Metadata'; 156 $template->assign( 'U_METADATA', $u_metadata.'" title="'.$lang['Show file metadata']);} 157 } 158 } 159 } 160 } 181 // -------------------------------------- 161 182 // Add llgbo requirement to ELEMENT_CONTENT 183 // -------------------------------------- 162 184 $template->set_filenames( array('llgbo_content'=> dirname(__FILE__).'/template/llgbo_content.tpl') ); 163 $template->concat(' ELEMENT_CONTENT', $template->parse('llgbo_content', true));185 $template->concat('picture', $template->parse('llgbo_content', true)); 164 186 } 165 //----------------------------------------------------------------- 166 /* ------ MANAGE PICTURE PAGE -------------- */ 167 //----------------------------------------------------------------- 168 function llgbo_RenderContent($content,$element_info ) 169 {global $template,$conf,$user,$lang,$themeconf; 170 $template->assign('LLGBO_PATH',LLGBO_PATH); 171 include_once(LLGBO_PATH.'/css/sweettitles.css.php'); 172 //----------------------------------------------------------------- 173 // ----------- add CSS tooltip in footer -------------------- 174 //----------------------------------------------------------------- 175 If (($conf['LLGBO_SETTINGS'][1] == 'true' ) /* tooltip */ 176 or ($conf['LLGBO_SETTINGS'] [2] == 'true' ) /* exif under bt */ ) 177 { $template->append('footer_elements',$sweetcss); 178 $template->append('llgbo', array( 'TOOLTIP' => 'ok' ), true);} 179 180 /* If ($conf['LLGBO_SETTINGS'] [3] == 'true' ) switch free {} */ 181 $conf['LLGBO_RENDERCONTENT'] = 'false'; 182 //----------------------------------------------------------------- 183 // AN OTHER PLUGIN IS WORKING -> GO BACK 184 if ( !empty($content) ) { return $content; } 185 // frame and navigation on picture are only available on picture extension 186 $pictExt = substr($element_info['file'],-3); 187 if (!in_array ( $pictExt,$conf['picture_ext'])) { return $content; ; } 188 $conf['LLGBO_RENDERCONTENT'] = 'true'; // $content ok for update 187 188 189 190 /****************************************************************** 191 ------ MANAGE PICTURE PAGE -------------- 192 ******************************************************************/ 193 // --> function llgbo_RenderContent($content,$element_info) 189 194 include_once(LLGBO_PATH.'include/manage_picture_content.php'); 190 } //end --> llgbo_RenderContent 191 192 function LLGBO_prefilter_Content_Frame($content, &$smarty) 193 { // End frame picture_content TPL 195 /******************************************************************/ 196 197 198 199 /******************************************************************/ 200 function LLGBO_prefilter_Content_Frame($content, $smarty) 201 /******************************************************************/ 202 { 203 // -------------------------------------- 204 // add End frame picture_content TPL 205 // -------------------------------------- 194 206 global $themeconf; 195 207 $search = '{foreach from=$current.unique_derivatives'; 196 $replacement = "\n".'{$llgbo.FRAME_END}'."\n"."</div> <!-- end GBO frame -->"."\n".$search; 197 if (( strpos(strtoupper($themeconf['name']) , 'STRIPPED') === 0) ) 198 {$search = 'class="hideTabs">'; 199 $replacement = $search."\n".'{$llgbo.FRAME_END}'."\n"."</div> <!-- end GBO frame -->";} 200 return str_replace($search, $replacement, $content); 201 } 202 203 function LLGBO_prefilter_Picture_Frame($content, &$smarty) 204 { 205 // ------------------------ 206 // begin frame on picture TPL 207 $search = '{$ELEMENT_CONTENT}'; 208 $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>'; 209 $replacement = $replacement."\n".'{/if}'."\n".'<div id="llgbo0" class="llgbo" {$llgbo.FRAME_SIZE}>'."\n".'{$llgbo.FRAME_BEGIN}'."\n".$search; 208 $replacement = '{$llgbo.FRAME_END}'.'</div>'."\n".' <!-- end LLGBO frame -->'."\n".$search; 209 if (( strpos(strtoupper($themeconf['name']) , 'STRIPPED') === 0) ) 210 {$search = 'class="hideTabs">'; 211 $replacement = $search 212 .'{$llgbo.FRAME_END}' 213 ."</div>"; 214 } 215 if (( strpos(strtoupper($themeconf['name']) , 'PWGCARBON_DFT') === 0) ) 216 {$search = '{if $DISPLAY_NAV_THUMB}'; 217 $replacement = '{$llgbo.FRAME_END}' 218 ."</div>"."</div> <!-- end GBO frame -->" 219 .$search; 220 } 221 $content = str_replace($search, $replacement, $content); 222 return $content; 223 } 224 225 226 /******************************************************************/ 227 function LLGBO_prefilter_Picture_Frame($content, $smarty) 228 /******************************************************************/ 229 { 230 // ------------------------------------ 231 // add begin frame on picture TPL 232 // -------------------------------------- 233 $search = '<div id="theImage">'; 234 $replacement = $search."\n".'{if isset($llgbo.TITLE_FRAME)}'."\n".'<span id="llgboh2" style ="background:transparent;z-index:3;color:{$llgbo.TITLE_FRAME_COLOR}">{$llgbo.TITLE_FRAME}</span>'; 235 $replacement = $replacement."\n".'{/if}'."\n".'{$llgbo.FRAME_SIZE}'."\n".'{$llgbo.FRAME_BEGIN}'; 236 210 237 // ------------------------ 211 238 return str_replace($search, $replacement, $content); 212 } 213 214 /* trigger à intercepter */ 215 add_event_handler('loc_begin_page_header', 'llgbo_beginheader'); 216 add_event_handler('loc_end_page_header', 'llgbo_endHeader'); 217 Add_event_handler( 'loc_begin_picture','llgbo_BeginPicture'); 218 Add_event_handler( 'loc_end_picture', 'llgbo_EndPicture'); 219 add_event_handler('render_element_content', 'llgbo_RenderContent', EVENT_HANDLER_PRIORITY_NEUTRAL-1, 20 ); 220 add_event_handler('get_admin_plugin_menu_links', 'plugin_admin_menu' ); 239 240 } 241 /******************************************************************/ 242 // trigger à intercepter 243 /******************************************************************/ 244 add_event_handler('init', 'llgbo_init'); 245 if (defined('IN_ADMIN')) 246 { 247 add_event_handler('get_admin_plugin_menu_links', 'llgbo_admin_menu'); 248 } 249 else 250 { 251 add_event_handler('loc_begin_page_header', 'llgbo_beginheader'); 252 add_event_handler('loc_end_page_header', 'llgbo_endHeader'); 253 Add_event_handler( 'loc_begin_picture','llgbo_BeginPicture'); 254 Add_event_handler( 'loc_end_picture', 'llgbo_EndPicture'); 255 add_event_handler('render_element_content', 'llgbo_RenderContent', EVENT_HANDLER_PRIORITY_NEUTRAL-1, 20 ); 256 } 257 221 258 ?>
Note: See TracChangeset
for help on using the changeset viewer.