<?php
class Document {
	private $title;
	private $description;
	private $keywords;	
	private $links = array();		
	private $styles = array();
	private $scripts = array();
	

			private function isIgnoredUrl($url, $ignored_urls) {
				foreach($ignored_urls as $ignoredUrl) {
					if (strpos($url, $ignoredUrl) !== false) {
						return true;
					}
				}
				
				return false;
			}
			
	public function setTitle($title) {
		$this->title = $title;
	}
	
	public function getTitle() {
		return $this->title;
	}
	
	public function setDescription($description) {
		$this->description = $description;
	}
	
	public function getDescription() {
		return $this->description;
	}
	
	public function setKeywords($keywords) {
		$this->keywords = $keywords;
	}
	
	public function getKeywords() {
		return $this->keywords;
	}
	
	public function addLink($href, $rel) {
		$this->links[md5($href)] = array(
			'href' => $href,
			'rel'  => $rel
		);			
	}
	
	public function getLinks() {
		return $this->links;
	}	
	
	public function addStyle($href, $rel = 'stylesheet', $media = 'screen') {
		$this->styles[md5($href)] = array(
			'href'  => $href,
			'rel'   => $rel,
			'media' => $media
		);
	}
	
	public function getStyles() {
		
			$oc_root = dirname(DIR_APPLICATION);
			//load NitroCache
			require_once $oc_root.DS.'system'.DS.'nitro'.DS.'config.php';
			require_once $oc_root.DS.'system'.DS.'nitro'.DS.'core'.DS.'core.php';
			
			$nitroSettings = getNitroPersistence();
			if (defined('HTTP_CATALOG') || (!empty($nitroSettings['Nitro']['Mini']['CSSExtract']) && $nitroSettings['Nitro']['Mini']['CSSExtract'] == 'yes')) 
				return $this->styles;
			else {
				require_once dirname(DIR_APPLICATION).DIRECTORY_SEPARATOR.'system'.DIRECTORY_SEPARATOR.'nitro'.DIRECTORY_SEPARATOR.'core'.DIRECTORY_SEPARATOR.'minify_functions.php';
				return minifyCSS($this->styles);
			}
			
	}	
	
	public function addScript($script) {
		$this->scripts[md5($script)] = $script;			
	}
	
	public function getScripts() {
		
			$oc_root = dirname(DIR_APPLICATION);
			//load NitroCache
			require_once $oc_root.DS.'system'.DS.'nitro'.DS.'config.php';
			require_once $oc_root.DS.'system'.DS.'nitro'.DS.'core'.DS.'core.php';
			
			$nitroSettings = getNitroPersistence();
			if (defined('HTTP_CATALOG') || (!empty($nitroSettings['Nitro']['Mini']['JSExtract']) && $nitroSettings['Nitro']['Mini']['JSExtract'] == 'yes')) 
				return $this->scripts;
			else {
				require_once dirname(DIR_APPLICATION).DIRECTORY_SEPARATOR.'system'.DIRECTORY_SEPARATOR.'nitro'.DIRECTORY_SEPARATOR.'core'.DIRECTORY_SEPARATOR.'minify_functions.php';
				return minifyJS($this->scripts);
			}
			
	}
}
?>