js = (bool) $options['js'];
$this->jsurl = $options['jsurl'];
$this->css = (bool) $options['css'];
$this->cssurl = $options['cssurl'];
$this->img = (bool) $options['img'];
$this->imgurl = $options['imgurl'];
$siteurl = site_url();
if($this->js)
{
if(preg_match_all('##Usmi',$this->content,$matches))
{
foreach($matches[0] as $tag)
{
if(preg_match('#src=("|\')(.*)("|\')#Usmi',$tag,$url))
{
$url = $url[2];
if(strpos($url,$siteurl)!==false)
{
$this->replace[$tag] = str_replace($siteurl,$this->jsurl,$tag);
}
}
}
}
}
if($this->css)
{
if(preg_match_all('#]*stylesheet[^>]*>#Usmi',$this->content,$matches))
{
foreach($matches[0] as $tag)
{
if(preg_match('#href=("|\')(.*)("|\')#Usmi',$tag,$url))
{
$url = $url[2];
if(strpos($url,$siteurl)!==false)
{
$this->replace[$tag] = str_replace($siteurl,$this->cssurl,$tag);
}
}
}
}
}
if($this->img)
{
if(preg_match_all('#
]*src[^>]*>#Usmi',$this->content,$matches))
{
foreach($matches[0] as $tag)
{
if(preg_match('#src=("|\')(.*)("|\')#Usmi',$tag,$url))
{
$url = $url[2];
if(strpos($url,$siteurl)!==false)
{
$this->replace[$tag] = str_replace($siteurl,$this->imgurl,$tag);
}
}
}
}
}
//Do we need further processing?
return (count($this->replace)>0);
}
//Do the tag replacing
public function minify()
{
//Replace the tags with the CDNed ones
$this->content = str_replace(array_keys($this->replace),array_values($this->replace),$this->content);
}
//Does nothing
public function cache()
{
//No cache for CDN
return true;
}
//Returns the content
public function getcontent()
{
return $this->content;
}
}