getName() != 'site' || $doc->getType() !== 'html')
{
return true;
}
$router = $app->getRouter();
$uri = JUri::getInstance();
$domain = $this->params->get('domain');
if ($domain === null || $domain === '')
{
$domain = $uri->toString(array('scheme', 'host', 'port'));
}
$parsed = $router->parse($uri);
$fakelink = 'index.php?' . http_build_query($parsed);
$link = $domain . JRoute::_($fakelink, false);
if ($uri !== $link)
{
$doc->addHeadLink(htmlspecialchars($link), 'canonical');
}
}
/**
* Converting the site URL to fit to the HTTP request
*
* @return void
*/
public function onAfterRender()
{
$app = JFactory::getApplication();
if ($app->getName() != 'site' || $app->getCfg('sef') == '0')
{
return true;
}
// Replace src links
$base = JUri::base(true).'/';
$buffer = JResponse::getBody();
$regex = '#href="index.php\?([^"]*)#m';
$buffer = preg_replace_callback($regex, array('PlgSystemSef', 'route'), $buffer);
$this->checkBuffer($buffer);
$protocols = '[a-zA-Z0-9]+:'; //To check for all unknown protocals (a protocol must contain at least one alpahnumeric fillowed by :
$regex = '#(src|href|poster)="(?!/|' . $protocols . '|\#|\')([^"]*)"#m';
$buffer = preg_replace($regex, "$1=\"$base\$2\"", $buffer);
$this->checkBuffer($buffer);
$regex = '#(onclick="window.open\(\')(?!/|' . $protocols . '|\#)([^/]+[^\']*?\')#m';
$buffer = preg_replace($regex, '$1' . $base . '$2', $buffer);
$this->checkBuffer($buffer);
// ONMOUSEOVER / ONMOUSEOUT
$regex = '#(onmouseover|onmouseout)="this.src=([\']+)(?!/|' . $protocols . '|\#|\')([^"]+)"#m';
$buffer = preg_replace($regex, '$1="this.src=$2' . $base .'$3$4"', $buffer);
$this->checkBuffer($buffer);
// Background image
$regex = '#style\s*=\s*[\'\"](.*):\s*url\s*\([\'\"]?(?!/|' . $protocols . '|\#)([^\)\'\"]+)[\'\"]?\)#m';
$buffer = preg_replace($regex, 'style="$1: url(\'' . $base .'$2$3\')', $buffer);
$this->checkBuffer($buffer);
// OBJECT -- fix it only inside the tag
$regex = '#(]\s*value\s*=\s*"(?!/|' . $protocols . '|\#|\')([^"]*)"#m';
$buffer = preg_replace($regex, '$1name="$2" value="' . $base . '$3"', $buffer);
$this->checkBuffer($buffer);
// OBJECT -- fix it only inside the tag
$regex = '#(]*)value\s*=\s*"(?!/|' . $protocols . '|\#|\')([^"]*)"\s*name\s*=\s*"(movie|src|url)"#m';
$buffer = preg_replace($regex, 'checkBuffer($buffer);
// OBJECT data="xx" attribute -- fix it only in the object tag
$regex = '#(