Development

Changeset 5355

You must first sign up to be able to contribute.

Changeset 5355

Show
Ignore:
Timestamp:
10/03/07 19:33:30 (2 years ago)
Author:
noel
Message:

plugin-install tasks create relative symlink instead of absolute symlink (closes #2229)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.0/data/tasks/sfPakePlugins.php

    r4729 r5355  
    259259  { 
    260260    pake_echo_action('plugin', 'installing web data for plugin'); 
    261     pake_symlink($web_dir, sfConfig::get('sf_web_dir').DIRECTORY_SEPARATOR.$plugin_name, true); 
     261    $path_diff = _absolute_path_difference(sfConfig::get('sf_web_dir'), $web_dir); 
     262    pake_symlink($path_diff, sfConfig::get('sf_web_dir').DIRECTORY_SEPARATOR.$plugin_name, true); 
    262263  } 
    263264} 
     
    281282  } 
    282283} 
     284 
     285function _absolute_path_difference($source, $target) 
     286{ 
     287  if (!sfToolkit::isPathAbsolute($source) || !sfToolkit::isPathAbsolute($target)) 
     288  { 
     289 
     290    return $target; 
     291  } 
     292 
     293  $source = split(DIRECTORY_SEPARATOR, rtrim($source, DIRECTORY_SEPARATOR)); 
     294  $target = split(DIRECTORY_SEPARATOR, rtrim($target, DIRECTORY_SEPARATOR)); 
     295 
     296  if ($source == $target) 
     297  {  
     298    return '.'; 
     299  } 
     300 
     301  for ($i = 0; $i < count($source); $i++) 
     302  { 
     303    if (! isset($target[$i]) || $target[$i] != $source[$i]) 
     304    { 
     305      $source_path_diff = array_fill(0, count($source) - $i, '..'); 
     306      $target_path_diff = array_slice($target, $i); 
     307      $merge = array_merge($source_path_diff, $target_path_diff); 
     308 
     309      return join(DIRECTORY_SEPARATOR, $merge); 
     310    } 
     311  } 
     312 
     313  return join(DIRECTORY_SEPARATOR, array_slice($target, count($source))); 
     314} 
     315 

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting.
Sensio Labs also supports several large Open-Source projects.