[4292] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | Plugin Name: Look_like_gbo2 |
---|
[4523] | 4 | Version: 2.0.I |
---|
[4292] | 5 | Plugin URI: http://phpwebgallery.net/ext/extension_view.php?eid=251 |
---|
| 6 | Author: Ex-Ftb |
---|
| 7 | Author URI: http://www.photos.bouteyron.fr/ |
---|
| 8 | Description: Display thumbnail under button. Add navigation on picture look like GBo Gallery |
---|
| 9 | Add a border around picture ...... |
---|
| 10 | */ |
---|
| 11 | /* 2.0.d fix notice when HD picture is desactivate*/ |
---|
[4523] | 12 | /* 2.0.e fix notice with redirec.tpl */ |
---|
| 13 | /* 2.0.f Tooltip and frame define by plugin vs Css*/ |
---|
| 14 | /* 2.0.h new languages PL, ES, HU */ |
---|
| 15 | /* 2.0.i Manage tab for tooltip and frame settings */ |
---|
[4292] | 16 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 17 | /* création d'une instance de la classe */ |
---|
| 18 | $obj = new look_like_gbo(); /* class loading */ |
---|
[4523] | 19 | global $conf,$ttvalues,$plugvalues,$frvalues; |
---|
[4574] | 20 | define ('LLGBO_INFO_VERSION','2.0.Ia'); |
---|
[4292] | 21 | define('LLGBO_PATH' , PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/'); |
---|
[4523] | 22 | |
---|
| 23 | $conf['LLGBO_SETTINGS'] = explode("," , $conf['LLGBO']); |
---|
| 24 | $conf['LLGBO_TOOLTIP'] = explode(",",$conf['LLGBOTOOLTIP']); |
---|
[4574] | 25 | $conf['LLGBO_FRAME'] = explode (",",$conf['LLGBOFRAME']); |
---|
| 26 | $conf['LLGBO_HEADER'] = explode (",",$conf['LLGBOHEADER']); |
---|
[4523] | 27 | ///////////////////////////////////////////////////// |
---|
[4292] | 28 | /* plugin Class */ |
---|
| 29 | class look_like_gbo |
---|
| 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', |
---|
[4523] | 35 | 'URL' => get_admin_plugin_menu_link(dirname(__FILE__).'/admin/llgbo_admin.php') )); |
---|
[4292] | 36 | return $menu; } |
---|
| 37 | |
---|
| 38 | /* always display metadata */ |
---|
| 39 | function AutoDisplayMetadata() |
---|
[4523] | 40 | {global $conf; |
---|
| 41 | If ($conf['LLGBO_SETTINGS'] [2] == 'true' ) // exif under bt |
---|
| 42 | {$_GET['metadata'] = 'O';} |
---|
[4292] | 43 | } |
---|
| 44 | |
---|
| 45 | // reset nofollow, noindex |
---|
| 46 | function MyBeginheader() |
---|
[4523] | 47 | { global $page,$conf; |
---|
[4574] | 48 | |
---|
[4523] | 49 | If ($conf['LLGBO_SETTINGS'][2] == 'true' ) // reset nofollow, noindex |
---|
| 50 | { unset ($page['meta_robots']);} |
---|
[4292] | 51 | } |
---|
| 52 | // manage H E A D E R |
---|
| 53 | function Myheader() |
---|
[4523] | 54 | {global $template,$conf; |
---|
[4574] | 55 | $page_name = script_basename(); |
---|
| 56 | if ($conf['LLGBO_SETTINGS'] [6] = 'true' ) |
---|
| 57 | {$no_header = false; |
---|
| 58 | if ( $page_name == 'index') |
---|
| 59 | {// print_r($_GET.'----'.$page_name ); |
---|
| 60 | if ((count ($_GET)) == 0 and ($conf['LLGBO_HEADER'][0] == 'false')) {$no_header = true;}// home |
---|
| 61 | foreach($_GET as $cle =>$valeur) |
---|
| 62 | {//print_r($cle.'_'.$valeur); |
---|
| 63 | if ((strpos( $cle ,'categories') == true ) and ($conf['LLGBO_HEADER'][0] == 'false')) {$no_header = true;}// categories |
---|
| 64 | if ((strpos( $cle ,'category') == true ) and ($conf['LLGBO_HEADER'][1] == 'false')) {$no_header = true;break;} |
---|
| 65 | if ((strpos( $cle ,'filter=') == true ) and ($conf['LLGBO_HEADER'][2] == 'false')) {$no_header = true;break;} |
---|
| 66 | if ((strpos( $cle ,'categories/flat') == true ) and ($conf['LLGBO_HEADER'][3] == 'false')) {$no_header = true;break;} |
---|
| 67 | if ((strpos( $cle ,'categories/posted-monthly-list') == true ) and ($conf['LLGBO_HEADER'][4] == 'false')) {$no_header = true;break;} |
---|
| 68 | if ((strpos( $cle ,'additional_page') == true ) and ($conf['LLGBO_HEADER'][6] == 'false')) {$no_header = true;break;} |
---|
| 69 | if ((strpos( $cle ,'most_visited') == true ) and ($conf['LLGBO_HEADER'][7] == 'false')) {$no_header = true;break;} |
---|
| 70 | if ((strpos( $cle ,'best_rated') == true ) and ($conf['LLGBO_HEADER'][8] == 'false')) {$no_header = true;break;} |
---|
| 71 | if ((strpos( $cle ,'list') == true ) and ($conf['LLGBO_HEADER'][9] == 'false')) {$no_header = true;break;} |
---|
| 72 | if ((strpos( $cle ,'recent_pics') == true ) and ($conf['LLGBO_HEADER'][10] == 'false')) {$no_header = true;break;} |
---|
| 73 | if ((strpos( $cle ,'tags') == true ) and ($conf['LLGBO_HEADER'][11] == 'false')) {$no_header = true;break;} |
---|
| 74 | if ((strpos( $cle ,'created-monthly-list') == true ) and ($conf['LLGBO_HEADER'][12] == 'false')) {$no_header = true;break;} |
---|
| 75 | if ((strpos( $cle ,'favorites') == true ) and ($conf['LLGBO_HEADER'][19] == 'false')) {$no_header = true;break;} |
---|
| 76 | if ((strpos( $cle ,'recent_cats') == true ) and ($conf['LLGBO_HEADER'][20] == 'false')) {$no_header = true;break;} |
---|
| 77 | |
---|
| 78 | } |
---|
| 79 | } |
---|
| 80 | //print_r($_GET.'----'.$page_name ); |
---|
| 81 | if ( $page_name == 'picture' and $conf['LLGBO_HEADER'][5] == 'false') {$no_header = true;}//picture page |
---|
| 82 | if ( $page_name == 'tags' and $conf['LLGBO_HEADER'][11] == 'false') {$no_header = true;}//tags |
---|
| 83 | if ( $page_name == 'search' and $conf['LLGBO_HEADER'][13] == 'false') {$no_header = true;}//search |
---|
| 84 | if ( $page_name == 'comments' and $conf['LLGBO_HEADER'][14] == 'false') {$no_header = true;}//comments |
---|
| 85 | if ( $page_name == 'about' and $conf['LLGBO_HEADER'][15] == 'false') {$no_header = true;}//about |
---|
| 86 | if ( $page_name == 'notification' and $conf['LLGBO_HEADER'][16] == 'false') {$no_header = true;}//notification |
---|
| 87 | if ( $page_name == 'register' and $conf['LLGBO_HEADER'][17] == 'false') {$no_header = true;} //notification |
---|
| 88 | if ( $page_name == 'identification' and $conf['LLGBO_HEADER'][18] == 'false') {$no_header = true;}//about |
---|
| 89 | if ($no_header == true) |
---|
| 90 | {$template->append('head_elements',"\n".' <STYLE type="text/css">#theHeader{display: none}</STYLE>');} |
---|
| 91 | } |
---|
| 92 | |
---|
[4292] | 93 | |
---|
[4574] | 94 | // |
---|
| 95 | If ($conf['LLGBO_SETTINGS'] [9] == 'true' ) |
---|
| 96 | {$template->append('head_elements',"\n".' <STYLE type="text/css">.navThumb{display: none} </STYLE>');} |
---|
| 97 | |
---|
[4292] | 98 | } // end header |
---|
| 99 | |
---|
| 100 | //* improve functionnalities --> picture.tpl |
---|
| 101 | function DisplayGboLook() |
---|
[4523] | 102 | { global $template,$conf; |
---|
| 103 | $u_metadata = $template->get_template_vars('U_METADATA'); |
---|
| 104 | $swt = ' swttips="'; |
---|
| 105 | If ($conf['LLGBO_SETTINGS'] [2] == 'true' ) // exif under bt |
---|
| 106 | { $metadata = $template->get_template_vars('metadata'); |
---|
| 107 | if(is_array($metadata)) |
---|
| 108 | {foreach($metadata[0] as $cle =>$tableau) |
---|
| 109 | { if(is_array($tableau)) |
---|
| 110 | {foreach($tableau as $cle=>$valeur) |
---|
| 111 | { $swt= $swt.$cle.' : '.$valeur.'<br>'; } |
---|
| 112 | } } |
---|
| 113 | $template->assign( 'U_METADATA', $u_metadata.'"'.$swt); |
---|
| 114 | $template->clear_assign('metadata'); |
---|
| 115 | } // hide original metadata |
---|
| 116 | } |
---|
| 117 | |
---|
[4292] | 118 | } |
---|
[4523] | 119 | |
---|
| 120 | /* ------ Manage picture page---------------- */ |
---|
[4292] | 121 | function MyPictureOptions($content ) |
---|
[4523] | 122 | {global $template,$conf,$user; |
---|
| 123 | $sweetcss = ' <! --- LLGBO tooltip css--> |
---|
| 124 | <style type="text/css"> |
---|
| 125 | div#toolTip {position:absolute;z-index:1000;width:'.$conf['LLGBO_TOOLTIP'][0].'px;background:'.$conf['LLGBO_TOOLTIP'][3].';color:'.$conf['LLGBO_TOOLTIP'][5].';border:'.$conf['LLGBO_TOOLTIP'][1].'px solid '.$conf['LLGBO_TOOLTIP'][2].';padding:5px;min-height:1em;-moz-border-radius:5px} |
---|
| 126 | div#toolTip p {margin:0;padding:0;color:'.$conf['LLGBO_TOOLTIP'][5].';font-size:0.8em;font-family:Verdana,Arial,Helvetica,sans-serif;text-align:left} |
---|
| 127 | div#toolTip p em {display:block;margin-top:3px;font-style:normal;font-weight:bold;text-align:left} |
---|
| 128 | div#toolTip p.title {color:'.$conf['LLGBO_TOOLTIP'][4].';text-align:center;padding:0 0 3px 0;} |
---|
| 129 | </style>'; |
---|
[4292] | 130 | // ----------- add JS tooltip in header ---------------------- |
---|
[4574] | 131 | If (($conf['LLGBO'][1] == 'true' ) /* tooltip */ or ($conf['LLGBO_SETTINGS'] [2] == 'true' ) /* exif under bt */ |
---|
| 132 | or ($conf['LLGBO_SETTINGS'] [4] === 'true' ) /* usemap and Display Thumb */) |
---|
[4292] | 133 | { $javacss = '<script type="text/javascript" charset="utf-8" src="'.LLGBO_PATH; |
---|
| 134 | $linkcss = '<link rel="stylesheet" type="text/css" href="'.LLGBO_PATH; |
---|
[4523] | 135 | $sweetcss = $sweetcss."\n".$javacss.'js/sweettitlesn.js"></script>'."\n"; |
---|
[4292] | 136 | $template->append('head_elements',$sweetcss); } |
---|
[4523] | 137 | |
---|
[4292] | 138 | // Navigation improvement are always available |
---|
| 139 | $ThePicture = $template->get_template_vars('current'); |
---|
| 140 | $next = $template->get_template_vars('next'); |
---|
| 141 | $prev = $template->get_template_vars('previous'); |
---|
| 142 | $last = $template->get_template_vars('last'); |
---|
| 143 | $first = $template->get_template_vars('first'); |
---|
| 144 | $swtimg = ' swttips="<center><img src='; |
---|
| 145 | $nextthumb_title = $next['TITLE']; |
---|
| 146 | $prevthumb_title = $prev['TITLE']; |
---|
| 147 | $usemap =''; |
---|
[4523] | 148 | If ($conf['LLGBO_SETTINGS'][1] == 'true' )/* tooltip */ |
---|
| 149 | { $nextthumb_title = $next['TITLE']; |
---|
| 150 | $prevthumb_title = $prev['TITLE']; |
---|
[4292] | 151 | if (isset($first)){$template->assign('first', array('TITLE' => $first['TITLE'].'"'.$swtimg.$first['THUMB_SRC'].'>', |
---|
| 152 | 'U_IMG' => $first['U_IMG']));} |
---|
| 153 | if (isset($prev)){$template->assign('previous', array('TITLE' => $prev['TITLE'].'"'.$swtimg.$prev['THUMB_SRC'].'>', |
---|
| 154 | 'U_IMG' => $prev['U_IMG'], 'THUMB_SRC' => $prev['THUMB_SRC'])); } |
---|
| 155 | if (isset($next)){$template->assign('next', array('TITLE' => $next['TITLE'].'"'.$swtimg.$next['THUMB_SRC'].'>', |
---|
| 156 | 'U_IMG' => $next['U_IMG'], 'THUMB_SRC' => $next['THUMB_SRC']));} |
---|
| 157 | if (isset($last)){$template->assign('last', array('TITLE' => $last['TITLE'].'"'.$swtimg.$last['THUMB_SRC'].'>', |
---|
| 158 | 'U_IMG' => $last['U_IMG']));} |
---|
| 159 | } |
---|
| 160 | ///////////////////////////////////////////// |
---|
| 161 | // an other plugin is working -> go back |
---|
| 162 | if ( !empty($content) ) { return $content; } |
---|
| 163 | ////////////////////////////////////////////////////////////////////// |
---|
| 164 | // frame and navigation on picture are only available on picture extension |
---|
| 165 | ///////////////////////////////////////////////////////////////// |
---|
| 166 | if ($ThePicture['is_picture'] <> 1 ) { return ; } |
---|
[4523] | 167 | ///////////////////////////////////////////////////////////////// |
---|
| 168 | If (($conf['LLGBO_SETTINGS'] [1] == 'true' )/* tooltip display */ or ($conf['LLGBO_SETTINGS'] [0] == 'true') /* frame */ ) |
---|
| 169 | {$linkcss = '<link rel="stylesheet" type="text/css" href="'.LLGBO_PATH; |
---|
| 170 | $template->append('head_elements',$linkcss.'css/gbolook.css">');} |
---|
| 171 | |
---|
| 172 | If ($conf['LLGBO_SETTINGS'] [3] == 'true' ) // usemap |
---|
[4292] | 173 | { $usemap = '" usemap="#prevnext' ; |
---|
| 174 | $imgw = $ThePicture['scaled_width']; |
---|
| 175 | $imgh = $ThePicture['scaled_height']; |
---|
| 176 | $template->assign(array( |
---|
[4523] | 177 | /* left --> Prev */ 'LEFT_X1' => 0, 'LEFT_Y1' => 0, |
---|
| 178 | 'LEFT_X2' => round($imgw * 0.24), 'LEFT_Y2' => $imgh , |
---|
| 179 | /* up */ 'UP_X1' => round($imgw * 0.24) , 'UP_Y1' => 0, |
---|
| 180 | 'UP_X2' => round($imgw * 0.76), 'UP_Y2' => round($imgh * 0.50), |
---|
| 181 | /* high */ 'HIGH_X1' => round($imgw * 0.24) , 'HIGH_Y1' => round($imgh * 0.50) , |
---|
| 182 | 'HIGH_X2' => round($imgw * 0.76), 'HIGH_Y2' => $imgh, |
---|
| 183 | /* right -> next */ 'RIGHT_X1' => round($imgw * 0.76) , 'RIGHT_Y1' => 0, |
---|
| 184 | 'RIGHT_X2' => $imgw , 'RIGHT_Y2' => $imgh )); |
---|
| 185 | $template->assign( 'USEMAP', 'ok' ); |
---|
[4292] | 186 | |
---|
[4523] | 187 | If ($conf['LLGBO_SETTINGS'] [4] === 'true' ) // usemap and Display Thumb |
---|
[4292] | 188 | { $template->assign(array('NEXTTHUMB' => $swtimg.$next['THUMB_SRC'].'>"', |
---|
| 189 | 'NEXTTHUMBTITLE' => $nextthumb_title, |
---|
| 190 | 'PREVTHUMB' => $swtimg.$prev['THUMB_SRC'].'>"', |
---|
[4523] | 191 | 'PREVTHUMBTITLE' => $prevthumb_title));} |
---|
[4292] | 192 | } // end usemap |
---|
| 193 | $alt = $conf['allow_html_descriptions'] ? $ThePicture['name'] : strip_tags($ThePicture['name']); |
---|
| 194 | $template->assign( array( |
---|
[4523] | 195 | 'SRC_IMG' => $ThePicture['image_url'], |
---|
[4292] | 196 | 'WIDTH_IMG' => $ThePicture['scaled_width'], |
---|
| 197 | 'HEIGHT_IMG' => $ThePicture['scaled_height'], |
---|
[4523] | 198 | 'COMMENT_IMG' => $conf['allow_html_descriptions'] ? $ThePicture['comment'] : strip_tags($ThePicture['comment']), |
---|
[4292] | 199 | 'ALT_IMG' => $alt.$usemap |
---|
| 200 | )); |
---|
| 201 | |
---|
| 202 | If (isset($ThePicture['has_high'])and isset($ThePicture['high_url'])) |
---|
| 203 | { $uuid = uniqid(rand()); |
---|
| 204 | $template->assign( |
---|
| 205 | 'high', array( |
---|
| 206 | 'U_HIGH' => $ThePicture['high_url'] , |
---|
| 207 | 'UUID' => $uuid, ));} |
---|
| 208 | |
---|
[4523] | 209 | If (($conf['LLGBO_SETTINGS'] [5] == 'true' ) /* title on frame */ and ($conf['LLGBO_SETTINGS'] [0] == 'true' )) // display frame |
---|
| 210 | { $template->assign('SHOW_PICTURE_NAME_ON_TITLE', false); |
---|
| 211 | $template->assign('TITLE_FRAME_COLOR', $conf['LLGBO_FRAME'][0]); } |
---|
[4292] | 212 | |
---|
[4523] | 213 | /* HTML frame */ |
---|
| 214 | If (($conf['LLGBO_SETTINGS'] [0] == 'true') ) |
---|
| 215 | { $bd = 0; |
---|
| 216 | $frame_begin =''; |
---|
| 217 | $frame_end=''; |
---|
| 218 | for ($x = 1 ;$x < 32 ; $x =$x +2) |
---|
| 219 | { if ((isset($conf['LLGBO_FRAME'][$x+1])) and ($conf['LLGBO_FRAME'][$x+1] > 0)) // boder value > 0 |
---|
| 220 | {$frame_begin = '<div style="border: '.$conf['LLGBO_FRAME'][$x+1].'px solid '.$conf['LLGBO_FRAME'][$x].'">'."\n".$frame_begin; |
---|
| 221 | $bd = $bd + $conf['LLGBO_FRAME'][$x+1]; //define border sum |
---|
| 222 | $frame_end = $frame_end .' </div>'; |
---|
| 223 | } |
---|
| 224 | } |
---|
| 225 | $frame_width = $ThePicture["scaled_width"] + (2 * $bd); |
---|
| 226 | $frame_height = $ThePicture["scaled_height"] + (2 * $bd); |
---|
| 227 | $template->assign('FRAME_SIZE','style="width:'.$frame_width .'px; height:'.$frame_height.'px;"'); |
---|
| 228 | $template->assign('FRAME_BEGIN', $frame_begin); |
---|
| 229 | $template->assign('FRAME_END', $frame_end); |
---|
| 230 | // title on frame |
---|
| 231 | If ($conf['LLGBO_SETTINGS'] [5] == 'true' ) // title on frame |
---|
| 232 | {$template->assign( array( 'TITLE_FRAME' => $ThePicture['name'] )); } |
---|
| 233 | } // end frame |
---|
| 234 | else // no frame |
---|
| 235 | {$template->clear_assign('FRAME_BEGIN') ;} |
---|
[4292] | 236 | |
---|
| 237 | $template->set_filenames( array('gbo_content'=> dirname(__FILE__).'/template/picture_content.tpl') ); |
---|
| 238 | return $template->parse( 'gbo_content', true); |
---|
[4523] | 239 | } //end --> MyPictureOptions |
---|
[4292] | 240 | } // End class |
---|
| 241 | |
---|
| 242 | /* trigger à intercepter */ |
---|
| 243 | add_event_handler('loc_begin_page_header', array(&$obj, 'MyBeginheader')); |
---|
| 244 | add_event_handler('loc_end_page_header', array(&$obj, 'Myheader')); |
---|
| 245 | Add_event_handler( 'loc_begin_picture', array(&$obj, 'AutoDisplayMetadata')); |
---|
| 246 | Add_event_handler( 'loc_end_picture', array(&$obj, 'DisplayGboLook')); |
---|
| 247 | add_event_handler('render_element_content', |
---|
| 248 | array(&$obj,'MyPictureOptions'), EVENT_HANDLER_PRIORITY_NEUTRAL-1, 2 ); |
---|
| 249 | add_event_handler('get_admin_plugin_menu_links', array(&$obj, 'plugin_admin_menu') ); |
---|
| 250 | set_plugin_data($plugin['id'], $obj); |
---|
| 251 | ?> |
---|