protected function resolveImage($source, &$internalPath, &$internalSrc, &$isSourceExternal, $baseDir = "", $htmlDir = "")
{
if ($this->isFinalized) {
return false;
}
$imageData = null;
if (preg_match('#^(http|ftp)s?://#i', $source) == 1) {
$urlinfo = parse_url($source);
if (strpos($urlinfo['path'], $baseDir . "/") !== false) {
$internalSrc = FileHelper::sanitizeFileName(urldecode(substr($urlinfo['path'], strpos($urlinfo['path'], $baseDir . "/") + strlen($baseDir) + 1)));
}
$internalPath = $urlinfo["scheme"] . "/" . $urlinfo["host"] . "/" . pathinfo($urlinfo["path"], PATHINFO_DIRNAME);
$isSourceExternal = true;
$imageData = ImageHelper::getImage($this, $source);
} else {
if (strpos($source, "/") === 0) {
$internalPath = pathinfo($source, PATHINFO_DIRNAME);
$path = $source;
if (!file_exists($path)) {
$path = $this->docRoot . $path;
}
$imageData = ImageHelper::getImage($this, $path);
} else {
$internalPath = $htmlDir . "/" . preg_replace('#^[/\\.]+#', '', pathinfo($source, PATHINFO_DIRNAME));
$path = $baseDir . "/" . $source;
if (!file_exists($path)) {
$path = $this->docRoot . $path;
}
$imageData = ImageHelper::getImage($this, $path);
}
}
if ($imageData !== false) {
$iSrcInfo = pathinfo($internalSrc);
if (!empty($imageData['ext']) && (!isset($iSrcInfo['extension']) || $imageData['ext'] != $iSrcInfo['extension'])) {
$internalSrc = $iSrcInfo['filename'] . "." . $imageData['ext'];
}
$internalPath = RelativePath::getRelativePath("images/" . $internalPath . "/" . $internalSrc);
if (!array_key_exists($internalPath, $this->fileList)) {
$this->addFile($internalPath, "i_" . $internalSrc, $imageData['image'], $imageData['mime']);
$this->fileList[$internalPath] = $source;
}
return true;
}
return false;
}