<?php
/*
	16/Octubre/2019 ==> Controlador dedicado a trabajar con el SEO
	@version 1.0
*/

class SuperSEO{
	private static $name = '';
	private static $title = '';
	private static $keywords = '';
	private static $description = '';
	
	//Name
	public static function setName($newName){
		self::$name = $newName;
	}
	public static function getName($defaultValue = ''){
		return( (self::$name == '') ? $defaultValue : self::$name);
	}
	//Title
	public static function setTitle($newTitle){
		self::$title = $newTitle;
	}
	public static function getTitle($defaultValue = ''){
		return( (self::$title == '') ? $defaultValue : self::$title);
	}
	//Keywords
	public static function setKeywords($newKeywords){
		self::$keywords = $newKeywords;
	}
	public static function getKeywords($defaultValue = ''){
		return( (self::$keywords == '') ? $defaultValue : self::$keywords);
	}
	//Description
	public static function setDescription($newDescription){
		self::$description = $newDescription;
	}
	public static function getDescription($defaultValue = ''){
		return( (self::$description == '') ? $defaultValue : self::$description);
	}
	
	//En la URL dejamos ñ y tildes, vamos a simplificar ==> //TODO quitar de aquí tb las tildes
	public static function URL($url){
		//Empezamos quitando los caracteres q el entity decode no hace bien:
		$find = array('á', 'é', 'í', 'ó', 'ú', 'Á', 'É', 'Í', 'Ó', 'Ú', 'à', 'è', 'ì', 'ò', 'ù', 'À', 'È', 'Ì', 'Ò', 'Ù', 'ä', 'ë', 'ï', 'ö', 'ü', 'Ä', 'Ë', 'Ï', 'Ö', 'Ü', "'", "´", '"', "(", ")", "&", " ", "º", "ª", "?", "¿", "!", "¡",     "&", "+", 'ç', 'Ç', '%');
		$repl = array('a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U', 'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U', 'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U',  "",  "",  '', "(", ")", "_", "-", "_", "_",  "",  "",  "",  "", "&amp;", "_", 'c', 'C',  '', '-');
		$url = str_replace($find, $repl, $url);
		//Ahora pasamos a minúscula:
		$url = strtolower( urlencode($url));
		//Por último codificamos como URL:
		//$url = urlencode($url);
		return($url);
	}
}
