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 = $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;
}