Development

Changeset 1331

You must first sign up to be able to contribute.

Changeset 1331

Show
Ignore:
Timestamp:
05/09/06 16:49:57 (3 years ago)
Author:
fabien
Message:

added a new option to make image tag path absolute + fixed https for absolute urls (closes #477)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/controller/sfWebController.class.php

    r1027 r1331  
    114114    if ($absolute) 
    115115    { 
    116       $url = 'http://'.$this->getContext()->getRequest()->getHost().$url; 
     116      $request = $this->getContext()->getRequest(); 
     117      $url = 'http'.($request->isSecure() ? 's' : '').'://'.$request->getHost().$url; 
    117118    } 
    118119 
  • trunk/lib/helper/AssetHelper.php

    r1145 r1331  
    5151 *     /js/ajax.js 
    5252*/ 
    53 function javascript_path($source
    54 { 
    55   return _compute_public_path($source, 'js', 'js'); 
     53function javascript_path($source, $absolute = false
     54{ 
     55  return _compute_public_path($source, 'js', 'js', $absolute); 
    5656} 
    5757 
     
    8787 *   stylesheet_path('style') => /css/style.css 
    8888 */ 
    89 function stylesheet_path($source
    90 { 
    91   return _compute_public_path($source, 'css', 'css'); 
     89function stylesheet_path($source, $absolute = false
     90{ 
     91  return _compute_public_path($source, 'css', 'css', $absolute); 
    9292} 
    9393 
     
    133133 * * file name without extension, like "logo", that gets expanded to "/images/logo.png" 
    134134 */ 
    135 function image_path($source
    136 { 
    137   return _compute_public_path($source, 'images', 'png'); 
     135function image_path($source, $absolute = false
     136{ 
     137  return _compute_public_path($source, 'images', 'png', $absolute); 
    138138} 
    139139 
     
    158158  $options = _parse_attributes($options); 
    159159 
    160   $options['src'] = image_path($source); 
     160  $absolute = false; 
     161  if (isset($options['absolute'])) 
     162  { 
     163    unset($options['absolute']); 
     164    $absolute = true; 
     165  } 
     166 
     167  $options['src'] = image_path($source, $absolute); 
    161168 
    162169  if (!isset($options['alt'])) 
     
    178185} 
    179186 
    180 function _compute_public_path($source, $dir, $ext
     187function _compute_public_path($source, $dir, $ext, $absolute = false
    181188{ 
    182189  if (strpos($source, '://')) 
     
    185192  } 
    186193 
    187   $sf_relative_url_root = sfContext::getInstance()->getRequest()->getRelativeUrlRoot(); 
     194  $request = sfContext::getInstance()->getRequest(); 
     195  $sf_relative_url_root = $request->getRelativeUrlRoot(); 
    188196  if (strpos($source, '/') !== 0) 
    189197  { 
     
    199207  } 
    200208 
     209  if ($absolute) 
     210  { 
     211    $source = 'http'.($request->isSecure() ? 's' : '').'://'.$request->getHost().$source; 
     212  } 
     213 
    201214  return $source; 
    202215} 
  • trunk/lib/helper/UrlHelper.php

    r1282 r1331  
    4747 
    4848  $absolute = false; 
    49   if (isset($html_options['absolute_url'])
     49  if (isset($html_options['absolute_url']) || isset($html_options['absolute'])
    5050  { 
    5151    unset($html_options['absolute_url']); 
     52    unset($html_options['absolute']); 
    5253    $absolute = true; 
    5354  }