Changeset 12820
- Timestamp:
- Jan 1, 2012, 10:10:43 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin.php
r12102 r12820 166 166 'U_NOTIFICATION_BY_MAIL'=> $link_start.'notification_by_mail', 167 167 'U_CONFIG_GENERAL'=> $link_start.'configuration', 168 'U_CONFIG_DERIVATIVES'=> $link_start.'derivatives', 168 169 'U_CONFIG_DISPLAY'=> $conf_link.'default', 169 170 'U_CONFIG_EXTENTS'=> $link_start.'extend_for_templates', -
trunk/admin/include/functions.php
r12797 r12820 2055 2055 2056 2056 case 'configuration': 2057 case 'derivatives': 2057 2058 case 'extend_for_templates': 2058 2059 case 'menubar': … … 2248 2249 } 2249 2250 2250 function clear_derivative_cache($type='all') 2251 /** delete all derivative files for one or several types */ 2252 function clear_derivative_cache($types='all') 2251 2253 { 2252 2254 $pattern='#.*-'; 2253 if ($type == 'all') 2255 if ($types == 'all') 2256 { 2257 $types = ImageStdParams::get_all_types(); 2258 $types[] = IMG_CUSTOM; 2259 } 2260 elseif (!is_array($types)) 2261 { 2262 $types = array($types); 2263 } 2264 2265 if (count($types)>1) 2254 2266 { 2255 2267 $type_urls = array(); 2256 foreach( ImageStdParams::get_all_types()as $dtype)2268 foreach($types as $dtype) 2257 2269 { 2258 2270 $type_urls[] = derivative_to_url($dtype); 2259 2271 } 2260 $type_urls[] = derivative_to_url(IMG_CUSTOM);2261 2272 $pattern .= '(' . implode('|',$type_urls) . ')'; 2262 2273 } 2263 2274 else 2264 2275 { 2265 $pattern .= derivative_to_url($type); 2266 } 2276 $pattern .= derivative_to_url($types[0]); 2277 } 2278 2267 2279 $pattern.='(_[a-zA-Z0-9]+)*\.[a-zA-Z0-9]{3,4}$#'; 2268 2280 if ($contents = opendir(PHPWG_ROOT_PATH.PWG_DERIVATIVE_DIR)) … … 2321 2333 } 2322 2334 clearstatcache(); 2323 rmdir($path);2335 @rmdir($path); 2324 2336 } 2325 2337 return $rmdir; -
trunk/admin/themes/default/template/admin.tpl
r12482 r12820 85 85 <ul> 86 86 <li><a href="{$U_CONFIG_GENERAL}">{'Options'|@translate}</a></li> 87 <li><a href="{$U_CONFIG_DERIVATIVES}">{'Derivatives'|@translate}</a></li> 87 88 <li><a href="{$U_CONFIG_MENUBAR}">{'Menu Management'|@translate}</a></li> 88 89 <li><a href="{$U_CONFIG_EXTENTS}">{'Templates'|@translate}</a></li> -
trunk/i.php
r12802 r12820 168 168 try 169 169 { 170 $page['derivative_params'] = ImageParams::from_url_tokens($deriv);170 $page['derivative_params'] = DerivativeParams::from_url_tokens($deriv); 171 171 } 172 172 catch (Exception $e) … … 184 184 } 185 185 186 187 function send_derivative($expires) 188 { 189 global $page; 190 $fp = fopen($page['derivative_path'], 'rb'); 191 192 $fstat = fstat($fp); 193 header('Last-Modified: '.gmdate('D, d M Y H:i:s', $fstat['mtime']).' GMT'); 194 if ($expires!==false) 195 { 196 header('Expires: '.gmdate('D, d M Y H:i:s', $expires).' GMT'); 197 } 198 header('Content-length: '.$fstat['size']); 199 header('Connection: close'); 200 201 $ctype="application/octet-stream"; 202 switch (strtolower($page['derivative_ext'])) 203 { 204 case ".jpe": case ".jpeg": case ".jpg": $ctype="image/jpeg"; break; 205 case ".png": $ctype="image/png"; break; 206 case ".gif": $ctype="image/gif"; break; 207 } 208 header("Content-Type: $ctype"); 209 210 fpassthru($fp); 211 fclose($fp); 212 } 186 213 187 214 … … 220 247 { 221 248 $need_generate = true; 249 } 250 251 $expires=false; 252 $now = time(); 253 if ( $now > (max($src_mtime, $params->last_mod_time) + 24*3600) ) 254 {// somehow arbitrary - if derivative params or src didn't change for the last 24 hours, we send an expire header for several days 255 $expires = $now + 10*24*3600; 222 256 } 223 257 … … 231 265 exit; 232 266 } 233 // todo send pass-through267 send_derivative($expires); 234 268 } 235 269 … … 271 305 $image->destroy(); 272 306 273 $fp = fopen($page['derivative_path'], 'rb'); 274 275 $fstat = fstat($fp); 276 header('Last-Modified: '.gmdate('D, d M Y H:i:s', $fstat['mtime']).' GMT'); 277 header('Expires: '.gmdate('D, d M Y H:i:s', time()+10*24*3600).' GMT'); 278 header('Content-length: '.$fstat['size']); 279 header('Connection: close'); 280 281 $ctype="application/octet-stream"; 282 switch (strtolower($page['derivative_ext'])) 283 { 284 case ".jpe": case ".jpeg": case ".jpg": $ctype="image/jpeg"; break; 285 case ".png": $ctype="image/png"; break; 286 case ".gif": $ctype="image/gif"; break; 287 } 288 header("Content-Type: $ctype"); 289 290 fpassthru($fp); 291 fclose($fp); 307 send_derivative($expires); 292 308 ?> -
trunk/include/derivative_params.inc.php
r12797 r12820 279 279 280 280 /*how we generate a derivative image*/ 281 final class ImageParams281 final class DerivativeParams 282 282 { 283 283 public $type = IMG_CUSTOM; … … 290 290 } 291 291 292 public function __sleep() 293 { 294 return array('last_mod_time', 'sizing'); 295 } 296 292 297 function add_url_tokens(&$tokens) 293 298 { … … 298 303 { 299 304 $sizing = SizingParams::from_url_tokens($tokens); 300 $ret = new ImageParams($sizing);305 $ret = new DerivativeParams($sizing); 301 306 return $ret; 302 307 } -
trunk/include/derivative_std_params.inc.php
r12796 r12820 35 35 private static $type_map = array(); 36 36 private static $undefined_type_map = array(); 37 37 38 38 static function get_all_types() 39 39 { 40 40 return self::$all_types; 41 41 } 42 42 43 43 static function get_all_type_map() 44 44 { … … 55 55 return self::$undefined_type_map; 56 56 } 57 57 58 58 static function get_by_type($type) 59 59 { 60 60 return self::$all_type_map[$type]; 61 61 } 62 62 63 63 static function load_from_db() 64 64 { 65 self::make_default(); 65 global $conf; 66 $arr = @unserialize($conf['derivatives']); 67 if (false!==$arr) 68 { 69 self::$type_map = $arr['d']; 70 } 71 else 72 { 73 self::make_default(); 74 } 66 75 self::build_maps(); 67 76 } … … 69 78 static function load_from_file() 70 79 { 71 self::make_default(); 80 global $conf; 81 $arr = @unserialize(@file_get_contents(PHPWG_ROOT_PATH.$conf['data_location'].'derivatives.dat')); 82 if (false!==$arr) 83 { 84 self::$type_map = $arr['d']; 85 } 86 else 87 { 88 self::make_default(); 89 } 90 self::build_maps(); 91 } 92 93 static function set_and_save($map) 94 { 95 global $conf; 96 self::$type_map = $map; 97 98 $ser = serialize( array( 99 'd' => self::$type_map 100 ) ); 101 conf_update_param('derivatives', addslashes($ser) ); 102 file_put_contents(PHPWG_ROOT_PATH.$conf['data_location'].'derivatives.dat', $ser); 72 103 self::build_maps(); 73 104 } … … 75 106 static function make_default() 76 107 { 77 //todo 78 self::$type_map[IMG_SQUARE] = new ImageParams( SizingParams::square(100,100) ); 79 self::$type_map[IMG_THUMB] = new ImageParams( SizingParams::classic(144,144) ); 80 self::$type_map[IMG_SMALL] = new ImageParams( SizingParams::classic(240,240) ); 81 self::$type_map[IMG_MEDIUM] = new ImageParams( SizingParams::classic(432,432) ); 82 self::$type_map[IMG_LARGE] = new ImageParams( SizingParams::classic(648,576) ); 83 self::$type_map[IMG_XLARGE] = new ImageParams( SizingParams::classic(864,648) ); 84 self::$type_map[IMG_XXLARGE] = new ImageParams( SizingParams::classic(1200,900) ); 108 self::$type_map[IMG_SQUARE] = new DerivativeParams( SizingParams::square(100,100) ); 109 self::$type_map[IMG_THUMB] = new DerivativeParams( SizingParams::classic(144,144) ); 110 self::$type_map[IMG_SMALL] = new DerivativeParams( SizingParams::classic(240,240) ); 111 self::$type_map[IMG_MEDIUM] = new DerivativeParams( SizingParams::classic(432,432) ); 112 self::$type_map[IMG_LARGE] = new DerivativeParams( SizingParams::classic(648,576) ); 113 self::$type_map[IMG_XLARGE] = new DerivativeParams( SizingParams::classic(864,648) ); 114 self::$type_map[IMG_XXLARGE] = new DerivativeParams( SizingParams::classic(1200,900) ); 85 115 } 86 116 87 117 private static function build_maps() 88 118 { … … 111 141 } 112 142 } 113 143 114 144 } 115 145 -
trunk/language/en_UK/common.lang.php
r12693 r12820 363 363 $lang['Your Gallery Customization'] = "Your gallery customization"; 364 364 $lang['Your password has been reset'] = 'Your password has been reset'; 365 365 $lang['square'] = "Square"; 366 $lang['thumb'] = "Thumb"; 367 $lang['small'] = "Small"; 368 $lang['medium'] = "Medium"; 369 $lang['large'] = "Large"; 370 $lang['xlarge'] = "XLarge"; 371 $lang['xxlarge'] = "XXLarge"; 372 $lang['original'] = "Original"; 366 373 ?>
Note: See TracChangeset
for help on using the changeset viewer.