Changeset 12865 for trunk/i.php

Show
Ignore:
Timestamp:
01/08/12 20:25:52 (17 months ago)
Author:
rvelices
Message:

feature 2548 multisize - added a page to build missing derivatives

  • browser driven, chained ws calls to retrieve urls, visual feedback of progress through slideshow
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/i.php

    r12851 r12865  
    109109  { 
    110110    $req = $_SERVER["QUERY_STRING"]; 
     111    if ($pos=strpos($req, '&')) 
     112    { 
     113      $req = substr($req, 0, $pos); 
     114    } 
    111115    /*foreach (array_keys($_GET) as $keynum => $key) 
    112116    { 
     
    168172    try 
    169173    { 
    170       $page['derivative_params'] = DerivativeParams::from_url_tokens($deriv); 
     174      $params = $page['derivative_params'] = DerivativeParams::from_url_tokens($deriv); 
    171175    } 
    172176    catch (Exception $e) 
    173177    { 
    174178      ierror($e->getMessage(), 400); 
     179    } 
     180    if ($params->sizing->ideal_size[0] < 20 or $params->sizing->ideal_size[1] < 20) 
     181    { 
     182      ierror('Invalid size', 400); 
     183    } 
     184    if ($params->sizing->max_crop < 0 or $params->sizing->max_crop > 1) 
     185    { 
     186      ierror('Invalid crop', 400); 
    175187    } 
    176188  } 
     
    225237 
    226238$params = $page['derivative_params']; 
    227 if ($params->sizing->ideal_size[0] < 20 or $params->sizing->ideal_size[1] < 20) 
    228 { 
    229   ierror('Invalid size', 400); 
    230 } 
    231 if ($params->sizing->max_crop < 0 or $params->sizing->max_crop > 1) 
    232 { 
    233   ierror('Invalid crop', 400); 
    234 } 
    235239 
    236240$src_mtime = @filemtime($page['src_path']); 
     
    251255$expires=false; 
    252256$now = time(); 
    253 if ( $now > (max($src_mtime, $params->last_mod_time) + 24*3600) ) 
     257if ( isset($_GET['b']) ) 
     258{ 
     259  $expires = $now + 100; 
     260  header("Cache-control: no-store, max-age=100"); 
     261} 
     262elseif ( $now > (max($src_mtime, $params->last_mod_time) + 24*3600) ) 
    254263{// somehow arbitrary - if derivative params or src didn't change for the last 24 hours, we send an expire header for several days 
    255264  $expires = $now + 10*24*3600; 
     
    268277} 
    269278 
     279if (!mkgetdir(dirname($page['derivative_path']))) 
     280{ 
     281  ierror("dir create error", 500); 
     282} 
    270283 
    271284include_once(PHPWG_ROOT_PATH . 'admin/include/image.class.php'); 
     
    275288 
    276289$image = new pwg_image($page['src_path']); 
    277  
    278 if (!mkgetdir(dirname($page['derivative_path']))) 
    279 { 
    280   ierror("dir create error", 500); 
    281 } 
    282290 
    283291$changes = 0; 
     
    326334    { 
    327335      // todo 
     336      $pad = $wm_size[0] + max(30, round($wm_size[0]/4)); 
     337      for($i=-$wm->xrepeat; $i<=$wm->xrepeat; $i++) 
     338      { 
     339        if (!$i) continue; 
     340        $x2 = $x + $i * $pad; 
     341        if ($x2>=0 && $x2+$wm_size[0]<$d_size[0]) 
     342          if (!$image->compose($wm_image, $x2, $y, $wm->opacity)) 
     343            break; 
     344      } 
    328345    } 
    329346  }