public function init() { $returnResult = new HttpResult(); $returnResult->setSuccess(1); //iniciando o resultado para o html $retornoDaPaginaHTML = new HttpMenu(); //inicia a variavel de consulta de obj para cache $obj = NULL; $save_cache = TRUE; $cache_base_folder = "cache/menu/init/"; if (Config::USE_QUERY_CACHE) { //verifica se tem cache $cache_folder = $cache_base_folder; $cache_file = md5(implode("/", $this->arrayRestFolder)); /* Debug::print_r($this->arrayRestFolder); echo Debug::li($cache_file); */ $cache_location = $cache_folder . $cache_file; if (file_exists($cache_location)) { $resultSerial = unserialize(file_get_contents($cache_location)); //return $resultSerial; $obj = $resultSerial; $save_cache = FALSE; } } //o cache não está gravado if ($obj == NULL) { $obj = $this; //pedindo para consultar $this->consultValues(); } $retornoDaPaginaHTML->arrayMaterial = $obj->arrayMaterial->result; $retornoDaPaginaHTML->arrayColor = $obj->arrayColor->result; $retornoDaPaginaHTML->arrayStyle = $obj->arrayStyle->result; $retornoDaPaginaHTML->arrayFormat = $obj->arrayFormat->result; $retornoDaPaginaHTML->arrayTheme = $obj->arrayTheme->result; $retornoDaPaginaHTML->arrayComposition = $obj->arrayComposition->result; $retornoDaPaginaHTML->arrayTechnique = $obj->arrayTechnique->result; $retornoDaPaginaHTML->arrayType = $obj->arrayType->result; $botaoPromocoes = new stdClass(); $botaoPromocoes->name = "em promoção"; //echo Debug::li($this->currentQuery);exit(); if (!$this->currentQuery) { $this->currentQuery = "SELECT count( DISTINCT `view_product_model_quadro_b`.id) as count FROM `view_product_model_quadro_b` WHERE 1 AND view_product_model_quadro_b.`active` = '1'"; } $queryPromocao = $this->currentQuery . " AND promocao = 1 "; //oic 2 $dbi = new DbInterface(); $rt = $dbi->query($queryPromocao); //echo Debug::li($this->currentQuery); if (isset($_GET["teste"])) { Debug::print_r($rt); } $rt->fetchAll(); //Debug::print_r($rt);exit(); $botaoPromocoes->id = 1; $botaoPromocoes->total = $rt->result[0]->count; //total de produtos em promoção $retornoDaPaginaHTML->arrayPromocoes = array($botaoPromocoes); $retornoDaPaginaHTML->requestMaterial = $obj->requestMaterial; $retornoDaPaginaHTML->requestColor = $obj->requestColor; $retornoDaPaginaHTML->requestStyle = $obj->requestStyle; $retornoDaPaginaHTML->requestFormat = $obj->requestFormat; $retornoDaPaginaHTML->requestTheme = $obj->requestTheme; $retornoDaPaginaHTML->requestComposition = $obj->requestComposition; $retornoDaPaginaHTML->requestTechnique = $obj->requestTechnique; $retornoDaPaginaHTML->requestType = $obj->requestType; $retornoDaPaginaHTML->requestSearch = $obj->requestSearch; $retornoDaPaginaHTML->requestResumeSearch = $obj->requestResumeSearch; $retornoDaPaginaHTML->requestPromocao = $obj->requestPromocao; $retornoDaPaginaHTML->arrayRestFolder = $this->arrayRestFolder; $retornoDaPaginaHTML->arrayVariable = $this->arrayVariable; $retornoDaPaginaHTML->url_final = $obj->url_final; //salvando o objeto de resultado de html no retorno $returnResult->setHttpContentResult($retornoDaPaginaHTML); // -------------------------------------------------------------------[ BREAD CRUMB ] // Agora criando a array de bread crumb $retornoDaPaginaHTML->arrayBreadCrumb = $this->arrayBreadCrumb; // E também popula os títulos, que até então ele não tinha como pegar foreach ($retornoDaPaginaHTML->arrayBreadCrumb as $BreadCrumbInfoVO) { //pelo tipo de item e id ele ve o nome if (FALSE) { //apenas para o auto completar do eclipse $BreadCrumbInfoVO = new BreadCrumbInfoVO(); } $BreadCrumbInfoVO->tittle = $retornoDaPaginaHTML->getNameByTypeAndId($BreadCrumbInfoVO->reference, $BreadCrumbInfoVO->id); } if (Config::USE_QUERY_CACHE && $save_cache) { //grava o cache DataHandler::createRecursiveFoldersIfNotExists($cache_folder); //criando obj simplificado para serializar $stdObj = new stdClass(); $stdObj->arrayMaterial = $obj->arrayMaterial; $stdObj->arrayColor = $obj->arrayColor; $stdObj->arrayStyle = $obj->arrayStyle; $stdObj->arrayFormat = $obj->arrayFormat; $stdObj->arrayTheme = $obj->arrayTheme; $stdObj->arrayComposition = $obj->arrayComposition; $stdObj->arrayTechnique = $obj->arrayTechnique; $stdObj->arrayType = $obj->arrayType; $stdObj->requestMaterial = $obj->requestMaterial; $stdObj->requestColor = $obj->requestColor; $stdObj->requestStyle = $obj->requestStyle; $stdObj->requestFormat = $obj->requestFormat; $stdObj->requestTheme = $obj->requestTheme; $stdObj->requestComposition = $obj->requestComposition; $stdObj->requestTechnique = $obj->requestTechnique; $stdObj->requestType = $obj->requestType; $stdObj->requestSearch = $obj->requestSearch; $stdObj->requestResumeSearch = $obj->requestResumeSearch; $stdObj->requestPromocao = $obj->requestPromocao; $stdObj->url_final = $obj->url_final; DataHandler::writeFile($cache_folder, $cache_file, serialize($stdObj)); } return $returnResult; }