code: public static function convertRelativeUrls($strContent, $strBase='', $blnHrefOnly=false)
  	{
  		if ($strBase == '')
  		{
  			$strBase = Environment::get('base');
  		}
  
  		$search = $blnHrefOnly ? 'href' : 'href|src';
  		$arrUrls = preg_split('/(('.$search.')="([^"]+)")/i', $strContent, -1, PREG_SPLIT_DELIM_CAPTURE);
  		$strContent = '';
  
  		for ($i=0, $c=\count($arrUrls); $i<$c; $i+=4)
  		{
  			$strContent .= $arrUrls[$i];
  
  			if (!isset($arrUrls[$i+2]))
  			{
  				continue;
  			}
  
  			$strAttribute = $arrUrls[$i+2];
  			$strUrl = $arrUrls[$i+3];
  
  			if (!preg_match('@^(?:[a-z0-9]+:|#)@i', $strUrl))
  			{
  				$strUrl = $strBase . (($strUrl != '/') ? $strUrl : '');
  			}
  
  			$strContent .= $strAttribute . '="' . $strUrl . '"';
  		}
  
  		return $strContent;
  	}
docs: Convert relative URLs in href and src attributes to absolute URLs
  
  @param string  $strContent  The text with the URLs to be converted
  @param string  $strBase     An optional base URL
  @param boolean $blnHrefOnly If true, only href attributes will be converted
  
  @return string The text with the replaced URLs