config = &$config; $this->ruta = $path = $this->__getPath($url); $a_path = explode("/",$path); $a_path = array_slice($a_path,1); $path = implode("/",$a_path); $this->host = $_SERVER["HTTP_HOST"]; $this->medio = 'cuatro.com'; $this->especial = $this->__getEspecial($url); $aux = $this->__setSecciones($this->medio, $this->especial, "//".$path); $this->seccion = $aux['secciones']; //ESTO LO PONEMOS PORQUE POR AHORA SOLO HAY INDEX.HTMLS // $this->pagina = $aux['pagina']; $this->pagina = ""; $resto = $this->__setResto($url); $this->seo = $resto['seo']; /*if(empty($this->pagina)){ $this->pagina = $resto['pagina']; }*/ $this->xref = $resto['xref']; $this->type = $resto['type']; $this->url = $url; } function __setResto($data){ $path = $this->ruta; if(!empty($this->pagina)){ $ruta = $this->seccion. "/" .$this->pagina; } else{ $ruta = $this->seccion; } $ruta = $this->especial."/$ruta"; $aux = str_replace($ruta, '', $path); $resto = explode("/", trim($aux, "/")); $num = count($resto); switch($num){ case 0:{ //es el del tipo secciones/ $seo = null; $xref = null; $type = null; $pag = null; break; } case 1:{ //es el del tipo secciones/SEO $seo = $resto[0]; $xref = null; $type = null; $pag = null; break; } case 2:{ //es el del tipo secciones/SEO/pagina.html //o del tipo secciones/xref/type //$unido = $resto[0].".".$resto[1]; if(ESPDataValidator::isXrefSin($resto[1])){ $seo = $resto[0]; $xref = $resto[1]; $type = null; $pag = null; } else{ $seo = $resto[0]; $xref = null; $type = null; $pag = $resto[1]; } break; } case 3:{ //es del tipo secciones/SEO/xref/type $seo = $resto[0]; $xref = $resto[1]; $type = $resto[2]; break; } } return array('seo'=>$seo,'pagina'=>$pag,'xref'=>$xref, 'type'=>$type); } function __getEspecial($data){ $temp = parse_url($data); $path = $temp['path']; $path = trim($path, "/"); $url = explode("/", $path); return $url[0]; } function __getPath($data){ $aux = array(); $data = trim($data, "/"); $temp = parse_url($data); $path = $temp['path']; $path = trim($path, "/"); $url = explode("/", $path); return $path; } function __setSecciones($medio, $especial, $path){ $especial = new ESPEspecial($medio, $especial); $sections = $especial->getSections(); $aux_sections = array(); $aux = array(); foreach($sections as $section){ if(!empty($section->URL)){ $url = $section->URL; $pages = $section->getPages(); //vemos si la ruta de la seccion esta incluida en la url if(strpos($path."/", "/".$url."/")){ $sec = $url; } /*if (strstr($path,$url)){ $sec = $url; }*/ foreach($pages as $page){ if(!empty($page->URL)){ $page_url = trim($page->URL); //vemos si la ruta de la pagina esta incluida en la url if(strpos($path, "$url/$page_url")){ $pag = $page_url; } } } } } return array('secciones'=>$sec, 'pagina'=>$pag); } function getHost(){ return $this->host; } function getMedio(){ return $this->medio; } function getEspecial(){ return $this->especial; } function getSeccion(){ return $this->Seccion; } function getPagina(){ return $this->pagina; } function getSeo(){ return $this->seo; } function getXRef(){ return $this->xref; } function getType(){ return $this->type; } function generaEstatico($minisite, $file,$tipo){ require_once DIR_CLASSES_ESPECIALES_ENGINE . 'ESEStaticFileServer.php'; switch($tipo){ case "images" : $path = 'ESPPaths::getImagePath'; break; case "css" : $path = 'ESPPaths::getCSSPath'; break; case "flash" : $path = 'ESPPaths::getFlashPath'; break; case "js" : $path = "ESPPaths::getJSPath"; break; } if ($_GET['preview'] == 1) { $cacheTime = 0; } else { $cacheTime = $this->config->getVariable('IMAGE_FILES_CACHE_SECONDS'); } $fs = new ESEStaticFileServer("cuatro.com", $minisite,$file, $path , $cacheTime); $fs->run(); } function _generaSecciones($especial){ $esp = new ESPEspecial($this->medio,$especial); // Si el especial no existe redireccionamos a la home del medio if (!$esp->exists()) { ESEUtils::redirect2MedioHome($this->medio); } $pages = $esp->getPages(); $aux = false; foreach ($pages as $page){ $container = $page->getRootContainer(); $subContainers = $container->getChildSubContainers(); foreach ($subContainers as $key => $subContainer) { if ($subContainer->getVisible() == 1 && !$subContainer->isCommonContainerInstance()){ $seccion = $subContainer->getSection(); $page = $subContainer->getPage(); $path = $subContainer->getPath(); $aux = true; break; } }//foreach if ($aux){ break; } }//foreach $pageObj = new ESPPage($this->medio, $especial, $seccion, $page); $link = $pageObj->getLink(); header("location:".$link); } function run(){ $vars = explode("/", $this->ruta); if (count($vars)==1){ $esp = new ESPEspecial($this->medio,$vars[0]); // Si el especial no existe redireccionamos a la home del medio if (!$esp->exists()) { ESEUtils::redirect2MedioHome($this->medio); } $pages = $esp->getPages(); $aux = false; foreach ($pages as $page){ $container = $page->getRootContainer(); $subContainers = $container->getChildSubContainers(); foreach ($subContainers as $key => $subContainer) { if ($subContainer->getVisible() == 1 && !$subContainer->isCommonContainerInstance()){ $this->seccion = $subContainer->getSection(); $this->page = $subContainer->getPage(); $this->path = $subContainer->getPath(); $aux = true; break; } }//foreach if ($aux){ break; } }//foreach } switch($vars[1]){ case "js" : case "css": case "images":{ global $pabloSuperLog; $pabloSuperLog['estatico'] = "Es imagen o css"; $this->generaEstatico($vars[0],$vars[2],$vars[1]); break; } default :{ require_once DIR_CLASSES_ESPECIALES . 'ESPUtils.php'; //require_once DIR_CLASSES_ESPECIALES_ENGINE . 'ESEPageGenerator.php'; require_once DIR_CLASSES_ESPECIALES_ENGINE . 'ESEPageController.php'; $previewDate = PAFHttpEnv::GET('previewDate'); if(empty($this->pagina)){ $this->pagina = 'index.html'; } global $pabloSuperLog; $pabloSuperLog['LOG'][] = __CLASS__.",".__FUNCTION__." Se instancia ESEPageController"; $pg = new ESEPageController($this->medio, $this->especial, $this->seccion , $this->pagina, $previewDate,$this->xref); $pabloSuperLog['LOG'][] = __CLASS__.",".__FUNCTION__." Se llama al metodo run de ESEPageController"; $pg->run(); } } } function checkRedirecciones() { // Excepciones de urls. require_once( '/DATA/private/cuatro2/class/php/NAV/NAVCTORedirectEspeciales.class.php'); $redir = new NAVCTORedirectEspeciales(&$this); $redir->doRedirect(); } } //solo falta ver que pasa con los ficheros flash //ver que pasa con la redireccion si no viene nada (ver correo de ana) //y traer todo el codigo aqui, claro. $url = "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; global $pabloSuperLog; $pabloSuperLog['LOG'][] = "ESP la url es: ".$url; $pabloSuperLog['LOG'][] = "ESP Se instancia parseUrl"; $parse = new parseUrl($url, $configEspeciales); $pabloSuperLog['LOG'][] = "ESP Se llama al metodo run de parseUrl"; // redirecciones de minisites. $parse->checkRedirecciones(); $parse->run(); ?>