debug=true; // Inicialitzem Templates $tpl = new CachedTemplate(); $tpl->init(); $tpl->use_get(); // Variables d'idioma eval (ST ("txt_page", "\$txt_page", $_languageID)); $tpl->set_var("txt_page",$txt_page); eval (ST ("txt_registres", "\$txt_registres", $_languageID)); $tpl->set_var("txt_registres",$txt_registres); eval (ST ("txt_gotopage", "\$txt_gotopage", $_languageID)); $tpl->set_var("txt_gotopage",$txt_gotopage); eval (ST ("txt_ErrorPageMustBeNumber", "\$txt_ErrorPageMustBeNumber", $_languageID)); $tpl->set_var("txt_ErrorPageMustBeNumber",$txt_ErrorPageMustBeNumber); eval (ST ("txt_NotValidPage", "\$txt_NotValidPage", $_languageID)); $tpl->set_var("txt_NotValidPage",$txt_NotValidPage); eval (ST ("txt_of", "\$txt_of", $_languageID)); $tpl->set_var("txt_of",$txt_of); eval (ST ("txt_go", "\$txt_go", $_languageID)); $tpl->set_var("txt_go",$txt_go); eval (ST ("txt_buscador", "\$txt_buscador", $_languageID)); $tpl->set_var("txt_buscador",$txt_buscador); eval (ST ("tit_noticies", "\$tit_noticies", $_languageID)); eval(ST("txt_Opinions", "\$opinions_txt", $_languageID)); eval(ST("tit_noticies", "\$noticies_txt", $_languageID)); // Agafem variables per GET $id = $_GET['id']; $tpl->set_var("str_buscador",stripslashes($_GET['buscador'])); // Seleccionem plantilla i includes $arr_tpl = array("main"=>_TEMPLATES_DIR."/noticies/default.ihtml", "header"=>_TEMPLATES_DIR."/header.ihtml", "left"=>_TEMPLATES_DIR."/left.ihtml", "footer"=>_TEMPLATES_DIR."/footer.ihtml", "right"=>_TEMPLATES_DIR."/right.ihtml"); $tpl->set_file($arr_tpl); //Directorios $tpl->set_var("IMG_ADMIN_ROOT", _IMG_ADMIN_ROOT); $tpl->set_var("_IMG", _IMG); $tpl->set_var("CSS_ADMIN_ROOT", _CSS_ADMIN_ROOT); $tpl->set_var("JS_ADMIN_ROOT", _JS_ADMIN_ROOT); $tpl->set_var("ADMIN_ROOT", _ADMIN_ROOT); $tpl->set_var("WEB_ROOT", _WEB_ROOT); $tpl->set_var("NOTIS_SEC_PK", $NOTIS_SEC_PK); $tpl->set_var("lang", $_languageID); // +----------------------------------------------------------------------+ // | CUERPO | // +----------------------------------------------------------------------+ // Guardem l'audiència if ($_GET['t']) { $x_sec = $_GET['t'];} else {$x_sec = $_GET['id'];} AudienceSection($db,$x_sec,"",$_SESSION['session_usuPK']); $tpl->set_block("main","BNoticia","BlockNoticia"); $tpl->set_block("main","BTextCercador","BlockTextCercador"); $tpl->set_block("main","BSubCategories","BlockSubCategories"); //Carreguem INCS include(_COMMON_INC."/header.php"); $tpl->parse("header", "header"); include(_COMMON_INC."/left.php"); $tpl->parse("left", "left"); include(_COMMON_INC."/right.php"); $tpl->parse("right", "right"); //include(_COMMON_INC."/footer.php"); $tpl->parse("footer", "footer"); if ($cat) { // Select subcategories $sql = "SELECT * FROM core_Themes WHERE thm_FK_usu_PK = $USU_PK AND thm_FK_thm_PK=$cat ORDER BY thm_Order, thm_PK"; $rsCategories = $db->Execute($sql); if(!$rsCategories->EOF){ $cont = 0; while($oCategories = $rsCategories->FetchNextObject()){ $tpl->set_var("thm_Name",$oCategories->THM_NAME); $tpl->set_var("thm_PK",$oCategories->THM_PK); $tpl->set_var("thm_FK_thm_PK",$oCategories->THM_FK_THM_PK); $cont++; if ($cont == 7) { $tpl->set_var("TR_subcat",""); $cont = 0; } else { $tpl->set_var("TR_subcat",""); } $tpl->parse("BlockSubCategories","BSubCategories",true); } $tpl->set_var("x_pad_subcat","style=\"padding-bottom:10px\""); } $rsCategories->Close(); } if ($sub) { $cat = $sub; } // Select de Notis secció $sql = "SELECT DISTINCT core_ArticlesPortal.* FROM core_ArticlesPortal INNER JOIN core_ArticlesPortalSection ON ars_FK_art_PK = art_PK INNER JOIN core_Themes ON thm_PK = ars_FK_thm_PK INNER JOIN core_ThemeLanguage ON thl_FK_thm_PK = thm_PK WHERE art_FK_usu_PK = $USU_PK AND art_Publish = 1"; if(isset($_REQUEST["cat"])) $sql .= " AND (thm_PK = ".$_REQUEST["cat"]." OR thm_FK_thm_PK = ".$_REQUEST["cat"].")"; if(isset($_REQUEST["q"])) { $sql .= " AND (art_Headline LIKE '%".$_REQUEST["q"]."%' OR art_Lead LIKE '%".$_REQUEST["q"]."%' OR art_Body LIKE '%".$_REQUEST["q"]."%' OR art_Keywords LIKE '%".$_REQUEST["q"]."%')"; $tpl->set_var("miss_cerca", "Mostrant resultats de la cerca '".$_REQUEST["q"]."':"); $tpl->parse("BlockTextCercador", "BTextCercador", true); } $sql .= " ORDER BY art_TimePublish DESC"; //echo $sql; // paginador $MaxArticles = 20; $tpl->set_var("MaxArticles",$MaxArticles); $paginador = new templatePager($sql,$db,$tpl); $paginador->set_regsPerPage($MaxArticles); $paginador->set_templateLocation(_TEMPLATES_DIR."/core_pager.ihtml"); $paginador->runSQL(); $rsNoticies = $paginador->get_rs(); if ($paginador->get_maxPages()>1){ $tpl->set_var("paginador", $paginador->putPager()); } $NumRegisters = $rsNoticies->RecordCount(); $tpl->set_var("txt_noticies", $noticies_txt); if (!$rsNoticies->EOF ) { $cont = 1; while ($oNoticies = $rsNoticies->FetchNextObject()) { if ($cont<=6) { // ============================================================================ // Busquem thm_Name i thm_PK categoria // ============================================================================ $sql = "SELECT thm_PK, thm_Name FROM core_Themes INNER JOIN core_ArticlesPortalSection ON thm_PK = ars_FK_thm_PK INNER JOIN core_ArticlesPortal ON ars_FK_art_PK = art_PK WHERE art_PK = ".$oNoticies->ART_PK." AND art_FK_usu_PK = $USU_PK LIMIT 1"; $rsCategoria = $db->Execute($sql); $idCategoria = ""; $categoria = ""; if (!$rsCategoria->EOF){ if($oCategoria = $rsCategoria->FetchNextObject()){ $categoria = $oCategoria->THM_NAME; $idCategoria = $oCategoria->THM_PK; $tpl->set_var("categoria_".$cont,''.strtoupper($oCategoria->THM_NAME).''); } } $rsCategoria->Close(); // ============================================================================ $tpl->set_var("titol_".$cont,$oNoticies->ART_HEADLINE); $tpl->set_var("PK_".$cont,$oNoticies->ART_PK); $aux = explode(" ",$oNoticies->ART_DATEPUBLISH); $data = explode("-", $aux[0]); $data = $data[2]."-".$data[1]."-".$data[0]; if ($oNoticies->ART_AUTOR) { $x_autor = " / ".$oNoticies->ART_AUTOR; } else { $x_autor = " / Redacció"; } $tpl->set_var("data_".$cont, date("d/m/Y H:i",strtotime($oNoticies->ART_TIMEPUBLISH)).$x_autor); if ($oNoticies->ART_YOUTUBE) { $tpl->set_var("foto_".$cont,'
'.$oNoticies->ART_YOUTUBE.'
'); //$tpl->set_var("foto_".$cont,'
'); } elseif ($oNoticies->ART_FOTO1) { $tpl->set_var("foto_".$cont,''); } $sql = "SELECT COUNT(*) AS num FROM core_ArticlesPortalOpinion WHERE aro_FK_art_PK = ".$oNoticies->ART_PK." AND aro_FK_usu_PK = $USU_PK AND aro_Publish = 1"; $rsOpinions = $db->Execute($sql); $opinions = 0; if (!$rsOpinions->EOF) if($oOpinions = $rsOpinions->FetchNextObject()) //$tpl->set_var("opinions_".$cont, "".$oOpinions->NUM." $opinions_txt".""); $rsOpinions->Close(); } else { if(!isset($_GET["cat"])) $tpl->set_var("separador", " - "); else $tpl->set_var("separador", ""); // ============================================================================ // Busquem thm_Name i thm_PK categoria // ============================================================================ $sql = "SELECT thm_PK, thm_Name FROM core_Themes INNER JOIN core_ArticlesPortalSection ON thm_PK = ars_FK_thm_PK INNER JOIN core_ArticlesPortal ON ars_FK_art_PK = art_PK WHERE art_PK = ".$oNoticies->ART_PK." AND art_FK_usu_PK = $USU_PK LIMIT 1"; $rsCategoria = $db->Execute($sql); $idCategoria = ""; $categoria = ""; if (!$rsCategoria->EOF){ if($oCategoria = $rsCategoria->FetchNextObject()){ $categoria = $oCategoria->THM_NAME; $idCategoria = $oCategoria->THM_PK; $tpl->set_var("noticiaCategoria",''.strtoupper($oCategoria->THM_NAME).''); } } $rsCategoria->Close(); // ============================================================================ $tpl->set_var("noticiaTitol", "ART_PK."\" class=\"titular_llistat\">".$oNoticies->ART_HEADLINE.""); if ($oNoticies->ART_FOTO1) { $tpl->set_var("noticiaFoto",''); } else { $tpl->set_var("noticiaFoto",''); } if ($oNoticies->ART_AUTOR) { $x_autor = " / ".$oNoticies->ART_AUTOR; } else { $x_autor = " / Redacció"; } $tpl->set_var("noticiaData", date("d/m/Y H:i",strtotime($oNoticies->ART_TIMEPUBLISH)).$x_autor); $sql = "SELECT COUNT(*) AS num FROM core_ArticlesPortalOpinion WHERE aro_FK_art_PK = ".$oNoticies->ART_PK." AND aro_FK_usu_PK = $USU_PK AND aro_Publish = 1"; $rsOpinions = $db->Execute($sql); $opinions = 0; if (!$rsOpinions->EOF) if($oOpinions = $rsOpinions->FetchNextObject()) //$tpl->set_var("noticiaOpinions", "".$oOpinions->NUM." $opinions_txt".""); $rsOpinions->Close(); $tpl->parse("BlockNoticia", "BNoticia", true); // Posem variables a 0 $tpl->set_var("noticiaTitol"," "); $tpl->set_var("noticiaData"," "); $tpl->set_var("noticiaOpinions"," "); } $cont++; } } $rsNoticies->Close(); // +----------------------------------------------------------------------+ // | FINALITZACIONS | // +----------------------------------------------------------------------+ // Parsejar pàgina $tpl->pparse("out","main"); // Tancar la connexió amb la BD $db->Close(); ?>