QUEVIURES SERRA ROCA SL consta d’un equip humà d’unes 30 persones, amb una flota de vehicles especialitzats i comercials àmplia i d’unes instal·lacions amb cambres frigorífiques d’un volum aproximat de 2000 m3 i d’un magatzem per a la resta de productes d’uns 1300m2."); define ("IMG_17", "Flota de camions de Queviures Serra Roca a l’any 2010"); define ("IMG_16", "Celebració del 25è aniversari de l'empresa com a S.L. amb tots els treballadors i les seves famílies. Pastís de celebració"); define ("IMG_15", "Fotografia de pràcticament tots els treballadors de l’empresa durant el 25è anivesari, l’any 2004"); define ("IMG_14", "Fotografia dels assistents a la celebració del 25è aniversari a l'octubre del 2004 on es pot apreciar un dels regals dels treballadors a l'empresa"); define ("IMG_13", "Fotografia de pràcticament tots els treballadors de l’empresa durant el 25è anivesari, l’any 2004"); define ("IMG_12", "Detall dels treballadors a l’empresa on es pot apreciar la flota de camions que teníem a l’any 2004"); define ("IMG_11", "Final de la celebració amb un gran pastís de gormanderies on veiem els germans Serra envoltats de jovenalla"); define ("IMG_10", "Instal·lacions de Martín Códax a Cambados"); define ("IMG_9", "Instal·lacions de Martín Códax a Cambados"); define ("IMG_8", "Fotografia d’una de les fabriques de pa que té actualment Europastry"); define ("IMG_7", "Instal·lacions de Europastry S.A. (Frida i Fripan) a Sant Cugat del Vallès"); define ("IMG_6", "1967: Els primers repartiments"); define ("IMG_5", "1987: IV Diades Gastronòmiques del Bages"); define ("IMG_4", "1989: Construcció de les naus actuals"); define ("IMG_3", "1989: Expo 89: V Diades Gastronòmiques del Bages"); define ("IMG_2", "1989: Expo 89: Diades Gastronòmiques del Bages"); define ("IMG_1", "2008: Maridatge Caves Abadal amb Ferran Adrià"); define ("ANTERIOR", "anterior"); define ("SIGUIENTE", "següent"); // Seccio contacte define ("BREADCUMBS_CONTACTA", "Contacte - On som"); define ("CONTACT_US", "Contacta amb Nosaltres"); define ("DESC_CONTACTE", "Si vol més informació sobre els nostres productes o serveis, si té una suggerència, una queixa o, senzillament, necessita contactar amb nosaltres, pot fer-ho a través d’aquest formulari, per telèfon, fax o correu electrònic.
Els recordem que el nostre horari d’oficines i d’atenció al client és de 8 a 13:30 i de 15:30 a 18h."); define ("NOMBRE", "Nom i Cognoms"); define ("MAIL", "Correu Electrònic"); define ("TELEFONO", "Telèfon"); define ("SOMOS", "Som..."); define ("CLIENTES", "Clients"); define ("PROVEEDORES", "Proveïdors"); define ("OTROS", "Altres"); define ("CONSULTA", "Consulta"); define ("DONDE", "On som"); define ("CONTACT_DESC", "Les nostres instal·lacions es troben situades des del 1989 al Polígon Industrial Sant Isidre de Sant Fruitós de Bages."); define ("GMAPS", "Google Maps: fes clic"); // TODO verificar textos define ("ERROR_NAME", "El camp nom no està ben informat."); define ("ERROR_MAIL", "El camp email no està ben informat."); define ("ERROR_TELF", "El camp telèfon no està ben informat."); define ("ERROR_EMPRESA", "El camp empresa no està ben informat."); define ("ERROR_SOM", "El camp 'som' no està ben informat."); define ("ERROR_CONSULTA", "El camp consulta no està ben informat."); define ("ERROR_SEND_MAIL", "S'ha produït un error a l'enviar el correu, verifica les teves dades i torna a provar-ho."); define ("MAIL_SENDED", "El correu s'ha enviat correctament."); // Seccio novetats define ("DESCARGA_ADJUNTO", "Descarrega l'arxiu d'aquesta notìcia"); define ("DESCARGAR", "descarrega"); define ("ARXIU", "Arxiu"); define ("NO_HAY_ADJUNTO", "No n'hi ha"); // Acciones globales define ("ENVIAR", "Enviar"); define ("ENTRAR", "Entrar"); define ("BORRAR", "Esborrar"); define ("UPDATE", "Actualitzar"); define ("MODIFICAR", "Modificar"); define ("DELETE", "Eliminar"); define ("INSERT", "Afegir"); define ("OPCIONS", "Opcions"); define ("EMAIL", "EMail"); define ("AQUI", "aquì"); define ("BACKOFFICE", "BackOffice"); define ("ACCES_PAGE", "Pàgina d' accés"); define ("SALUDO", "Hola"); define ("SALUDO2", "escull l’apartat que vols modificar des del menú de dalt."); define ("NONOTICIAS", "No hi ha noticies"); define ("NONOTICIAS1", "Actualment no hi ha cap noticia a la base de dades."); // Pagina de login define ("TITLE_LOGIN", "Pàgina d' accés"); define ("INTRO1", "Benvingut a l’administració de Serraroca.com."); define ("INTRO2", "Si us plau, introdueix el teu nom d’usuari i la teva contrasenya"); define ("PAGINA_ACCES", "Pàgina d’accés"); define ("USUARIO", "Nom d’usuari"); define ("PASSWORD", "Contrasenya"); // Gestion de errores define ("ERROR_NO_VALIDA", "no es vàlida."); define ("ERROR_INESPERADO", "S'ha produït un error inesperat, torna a provar més tard o contacta amb l'administrador."); define ("ERROR_LANG", "No s'han definit els idiomes de l'aplicació."); define ("ERROR_TITULO_NOTI_1", "El títol de la notícia"); define ("ERROR_TITULO_NOTI_2", "no pot tenir més de 200 caracters."); define ("ERROR_TITULO_NOTI_3", "no pot tenir menys de 5 caracteres."); define ("ERROR_TITULO_BLANK", "No s'ha especificat el títol de la notícia"); define ("ERROR_DESC_NOTI_1", "La descripció de la notícia"); define ("ERROR_DESC_NOTI_2", "no pot tenir més de 15000 caracters."); define ("ERROR_DESC_NOTI_3", "no pot tenir menys de 15 caracters."); define ("ERROR_DESC_NOTI_4", "No s'ha especificat la descripció de la notícia"); define ("ERROR_FECHA_ALTA", "La data d'alta de la notícia"); define ("ERROR_FECHA_BLANK", "No s'ha especificat la data d'alta de la notícia."); define ("ERROR_FOTO", "No s'ha pogut processar la teva foto."); define ("ERROR_FOTO_JPG", "Només es permet pujar fotos jpg/jpeg."); define ("ERROR_FOTO_SIZE", "Només es permet pujar fotos de menys de 1Mb."); define ("ERROR_FOTO_BLANK", "No s'ha pujat cap foto associada a la notícia."); define ("ERROR_ADJUNTO", "No s'ha pogut processar l'arxiu adjunt."); define ("ERROR_INSER_NOTICIA", "No s'ha pogut afegir la notícia, torna a provar-ho més tard."); define ("INSERT_NOTICIA_OK", "S'ha afegit correctament la notícia."); define ("UPDATE_NOTICIA_OK", "S'ha modificat correctament la notícia."); // Mdul Noticies define ("ADMIN_NOVETATS", "Administrar novetats"); define ("ADMIN_H1_NOVETATS", "Administració de les novetats"); define ("CONFIRM_DELETE_NOTICIA", "Està segur que desitges eliminar la notícia?"); define ("CONFIRM_DELETE_ADJ_NOTICIA", "Estàs segur que desitja eliminar l'arxiu adjunt de la notícia? A l'eliminar l'arxiu adjunt es perdràn tots els canvis que s'hagin fet a la notícia."); define ("INSERT_NOTICIA", "Introduïr nova notícia"); define ("INSERT_NOTICIA2", "Nova notícia"); define ("TITOL", "Títol de la notícia"); define ("TITOL2", "Títol"); define ("FOTO", "Foto"); define ("IMATGE_ACTUAL", "Imatge actual"); define ("DESCRIPCIO", "Descripció"); define ("DATA", "Data de creació"); define ("DATA_PUB", "Data de publicació"); define ("DATA_PUB2", "Data publicació"); define ("ARCHIVO_ADJUNTO", "Arxiu adjunt (jpg o pdf)"); define ("ARCHIVO_ADJUNTO2", "Arxiu adjunt"); define ("ORDER_BY", "Ordenar per"); define ("NOTICIES_EXISTENTS", "noticies existents"); define ("NOTICIES_INTRO", "Notícies introduïdes"); define ("INTRO_NOUNOTICIA", "Introduïr Nova Noticia"); define ("MODIF_NOTIS", "Modificar Notícies"); define ("IMATGE", "Imatge"); // Mdul Productes define ("ADMIN_PRODUCTES", "Administrar productes"); define ("ADMIN_H1_PRODUCTES", "Administració dels productes"); define ("INSERT_PRODUCTO", "Afegir producte"); define ("CATEGORIA_PRODUCTO", "Categoria"); define ("TIPO_PRODUCTO", "Tipus de producte"); define ("TIPO_PRODUCTO2", "Tipus producte"); define ("CONFIRM_DELETE_PRODUCTE", "Està segur que desitges eliminar el producte?"); define ("INSERT_PROD", "Introduïr nou producte"); define ("CARACTERISTICAS", "Característiques"); define ("SENSE_TIPUS_PRODUCTE", "Sense subtipus de Producte"); define ("ERROR_INSER_PRODUCTE", "No s'ha pogut afegir el producte, torna a provar-ho més tard."); define ("INSERT_PRODUCTE_OK", "S'ha afegit correctament el producte."); define ("UPDATE_PRODUCTE_OK", "S'ha modificat correctament el producte."); define ("PRODUCTES_EXISTENTS", "productes existents"); define ("PRODUCTES_INTRO", "Productes introduïts"); define ("NOM_DEL_PRODUCTE", "Nom del producte"); define ("MODIF_PRODS", "Modificar Productes"); define ("NOU_PRODS", "Nou Producte"); define ("NOM", "Nom"); define ("INTRO_NOUPRODUCTE", "Introduïr"); // Gestion de errores define ("ERROR_TITULO_PROD_1", "El títol del producte"); define ("ERROR_TITULO_PROD_2", "no pot tenir més de 200 caracters."); define ("ERROR_TITULO_PROD_3", "no pot tenir menys de 5 caracteres."); define ("ERROR_TITULO_PROD_BLANK", "No s'ha especificat el títol del producte"); define ("ERROR_DESC_PROD_1", "La descripció del producte"); define ("ERROR_DESC_PROD_2", "no pot tenir més de 15000 caracters."); define ("ERROR_DESC_PROD_3", "no pot tenir menys de 15 caracters."); define ("ERROR_DESC_PROD_4", "No s'ha especificat la descripció del producte."); define ("ERROR_CARAC_PROD_1", "Les característiques del producte."); define ("ERROR_CARAC_PROD_4", "No s'han especificat les característiques del producte."); define ("ERROR_PROD_CATEGORIA", "No existeix la categoria associada al producte."); define ("ERROR_PROD_CATEGORIA_BLANK", "No s'ha associat la categoria al producte."); define ("ERROR_TIPUS_PROD", "El tipus de producte sel·leccionat no correspòn a la categoria sel·leccionada."); ?>idNoticia = $id; } function getIdNoticia() { return $this->idNoticia; } function setFecha($fecha) { $this->fecha = $fecha; } function getFecha() { return $this->fecha; } function setFechaPublicacion($fecha) { $this->fechaPublicacion = $fecha; } function getFechaPublicacion() { return $this->fechaPublicacion; } function setFoto($foto) { $this->foto = $foto; } function getFoto() { return $this->foto; } function setAdjunto($archivoAdjunto) { $this->adjunto = $archivoAdjunto; } function getAdjunto() { return $this->adjunto; } function setNoticiaLang($noticiaLang) { $this->noticiaLang = $noticiaLang; } function getNoticiaLang() { return $this->noticiaLang; } function existsNoticiaById($id) { $bd = new Bd(); $sql = "SELECT * FROM noticies WHERE id_noticia = '" . $id ."'"; $bd->select($sql); $resultados = $bd->getResults(); $num_rows = mysql_num_rows($resultados); $bd->freeResults($bd->getResults()); if($num_rows > 0) { return true; } else { return false; } } function findNoticiaById($id, $language = null) { $bd = new Bd(); $sql = "SELECT * FROM noticies WHERE id_noticia = '" . $id ."'"; $bd->select($sql); $resultados = $bd->getResults(); $num_rows = mysql_num_rows($resultados); if($num_rows == 1) { $row = mysql_fetch_object($resultados); $noticia = new Noticia(); $noticia->setIdNoticia($row->id_noticia); $noticia->setFecha($row->data); $noticia->setFechaPublicacion($row->data_publicacio); $noticia->setFoto($row->foto); $noticia->setAdjunto($row->arxiu_adjunt); $idIdioma = getIdLanguage($language); if(isset($idIdioma)) { $sqlIdiomes = "SELECT * FROM noticies_lang WHERE id_noticia = '" .$id. "' AND id_lang = '" .$idIdioma. "'"; } else { $sqlIdiomes = "SELECT * FROM noticies_lang WHERE id_noticia = '" .$id. "'"; } $bd->select($sqlIdiomes); $resultadosIdiomes = $bd->getResults(); $num_rowsIdiomes = mysql_num_rows($resultadosIdiomes); for($v = 0; $v < $num_rowsIdiomes; $v++) { $rowIdiomes = mysql_fetch_object($resultadosIdiomes); $lang = new NoticiaLang(); $lang->setIdNoticia($rowIdiomes->id_noticia); $lang->setIdLang($rowIdiomes->id_lang); $lang->setTitol($rowIdiomes->titol); $lang->setDescripcio(deleteBarrasParseoTexto($rowIdiomes->descripcio)); $results[$v] = $lang; } if(isset($results)) { $noticia->setNoticiaLang($results); } } if(isset($noticia)) { return $noticia; } else { return false; } } function findLastNoticiaPublicadaToInsert($language = null) { $bd = new Bd(); $sql = "SELECT * FROM noticies order by data desc limit 1"; $bd->select($sql); $resultados = $bd->getResults(); $num_rows = mysql_num_rows($resultados); if($num_rows == 1) { $row = mysql_fetch_object($resultados); $noticia = new Noticia(); $noticia->setIdNoticia($row->id_noticia); $noticia->setFecha($row->data); $noticia->setFechaPublicacion($row->data_publicacio); $noticia->setFoto($row->foto); $noticia->setAdjunto($row->arxiu_adjunt); $idIdioma = getIdLanguage($language); if(isset($idIdioma)) { $sqlIdiomes = "SELECT * FROM noticies_lang WHERE id_noticia = '" .$noticia->getIdNoticia(). "' AND id_lang = '" .$idIdioma. "'"; } else { $sqlIdiomes = "SELECT * FROM noticies_lang WHERE id_noticia = '" .$noticia->getIdNoticia(). "'"; } $bd->select($sqlIdiomes); $resultadosIdiomes = $bd->getResults(); $num_rowsIdiomes = mysql_num_rows($resultadosIdiomes); for($v = 0; $v < $num_rowsIdiomes; $v++) { $rowIdiomes = mysql_fetch_object($resultadosIdiomes); $lang = new NoticiaLang(); $lang->setIdNoticia($rowIdiomes->id_noticia); $lang->setIdLang($rowIdiomes->id_lang); $lang->setTitol($rowIdiomes->titol); $lang->setDescripcio($rowIdiomes->descripcio); $results[$v] = $lang; } if(isset($results)) { $noticia->setNoticiaLang($results); } } if(isset($noticia)) { return $noticia; } else { return false; } } function findLastNoticiaPublicada($language = null) { $bd = new Bd(); $sql = "SELECT * FROM noticies where data_publicacio < CURRENT_TIMESTAMP order by id_noticia desc limit 1"; $bd->select($sql); $resultados = $bd->getResults(); $num_rows = mysql_num_rows($resultados); if($num_rows == 1) { $row = mysql_fetch_object($resultados); $noticia = new Noticia(); $noticia->setIdNoticia($row->id_noticia); $noticia->setFecha($row->data); $noticia->setFechaPublicacion($row->data_publicacio); $noticia->setFoto($row->foto); $noticia->setAdjunto($row->arxiu_adjunt); $idIdioma = getIdLanguage($language); if(isset($idIdioma)) { $sqlIdiomes = "SELECT * FROM noticies_lang WHERE id_noticia = '" .$noticia->getIdNoticia(). "' AND id_lang = '" .$idIdioma. "'"; } else { $sqlIdiomes = "SELECT * FROM noticies_lang WHERE id_noticia = '" .$noticia->getIdNoticia(). "'"; } $bd->select($sqlIdiomes); $resultadosIdiomes = $bd->getResults(); $num_rowsIdiomes = mysql_num_rows($resultadosIdiomes); for($v = 0; $v < $num_rowsIdiomes; $v++) { $rowIdiomes = mysql_fetch_object($resultadosIdiomes); $lang = new NoticiaLang(); $lang->setIdNoticia($rowIdiomes->id_noticia); $lang->setIdLang($rowIdiomes->id_lang); $lang->setTitol($rowIdiomes->titol); $lang->setDescripcio(deleteBarrasParseoTexto($rowIdiomes->descripcio)); $results[$v] = $lang; } if(isset($results)) { $noticia->setNoticiaLang($results); } } if(isset($noticia)) { return $noticia; } else { return false; } } function listAllNoticiesPublicades($items = null, $language = null, $excepto = null) { $bd = new Bd(); if($items == null && $excepto == null) { $sql = "select * from noticies WHERE data_publicacio < CURRENT_TIMESTAMP() order by id_noticia desc"; } else if ($items != null && $excepto == null){ $sql = "select * from noticies WHERE data_publicacio < CURRENT_TIMESTAMP() order by id_noticia desc limit " .$items; } else if ($items == null && $excepto != null) { $sql = "select * from noticies WHERE data_publicacio < CURRENT_TIMESTAMP() AND id_noticia != ".$excepto." order by id_noticia desc"; } else { $sql = "select * from noticies WHERE data_publicacio < CURRENT_TIMESTAMP() AND id_noticia != ".$excepto." order by id_noticia desc limit " .$items; } $bd->select($sql); $resultados = $bd->getResults(); $num_rows = mysql_num_rows($resultados); for($j = 0; $j < $num_rows; $j++) { $row = mysql_fetch_object($resultados); $noticia = new Noticia(); $noticia->setIdNoticia($row->id_noticia); $noticia->setFecha($row->data); $noticia->setFechaPublicacion($row->data_publicacio); $noticia->setFoto($row->foto); $noticia->setAdjunto($row->arxiu_adjunt); $idIdioma = getIdLanguage($language); if(isset($idIdioma)) { $sqlIdiomes = "SELECT * FROM noticies_lang WHERE id_noticia = '" .$noticia->getIdNoticia(). "' AND id_lang = '" .$idIdioma. "'"; } else { $sqlIdiomes = "SELECT * FROM noticies_lang WHERE id_noticia = '" .$noticia->getIdNoticia(). "'"; } $bd->select($sqlIdiomes); $resultadosIdiomes = $bd->getResults(); $num_rowsIdiomes = mysql_num_rows($resultadosIdiomes); for($v = 0; $v < $num_rowsIdiomes; $v++) { $rowIdiomes = mysql_fetch_object($resultadosIdiomes); $lang = new NoticiaLang(); $lang->setIdNoticia($rowIdiomes->id_noticia); $lang->setIdLang($rowIdiomes->id_lang); $lang->setTitol($rowIdiomes->titol); $lang->setDescripcio($rowIdiomes->descripcio); $results[$v] = $lang; } if(isset($results)) { $noticia->setNoticiaLang($results); } $resultsNoticies[$j] = $noticia; } if(isset($resultsNoticies)) { return $resultsNoticies; } else { return false; } } function listAllNoticies($language, $excepto = null) { $bd = new Bd(); if($excepto == null) { $sql = "select * from noticies order by data asc"; } else { $sql = "select * from noticies WHERE id_noticia != ".$excepto." order by data asc"; } $bd->select($sql); $resultados = $bd->getResults(); $num_rows = mysql_num_rows($resultados); for($j = 0; $j < $num_rows; $j++) { $row = mysql_fetch_object($resultados); $noticia = new Noticia(); $noticia->setIdNoticia($row->id_noticia); $noticia->setFecha($row->data); $noticia->setFechaPublicacion($row->data_publicacio); $noticia->setFoto($row->foto); $noticia->setAdjunto($row->arxiu_adjunt); $idIdioma = getIdLanguage($language); if(isset($idIdioma)) { $sqlIdiomes = "SELECT * FROM noticies_lang WHERE id_noticia = '" .$noticia->getIdNoticia(). "' AND id_lang = '" .$idIdioma. "'"; } else { $sqlIdiomes = "SELECT * FROM noticies_lang WHERE id_noticia = '" .$noticia->getIdNoticia(). "'"; } $bd->select($sqlIdiomes); $resultadosIdiomes = $bd->getResults(); $num_rowsIdiomes = mysql_num_rows($resultadosIdiomes); for($v = 0; $v < $num_rowsIdiomes; $v++) { $rowIdiomes = mysql_fetch_object($resultadosIdiomes); $lang = new NoticiaLang(); $lang->setIdNoticia($rowIdiomes->id_noticia); $lang->setIdLang($rowIdiomes->id_lang); $lang->setTitol($rowIdiomes->titol); $lang->setDescripcio($rowIdiomes->descripcio); $results[$v] = $lang; } if(isset($results)) { $noticia->setNoticiaLang($results); } $resultsNoticies[$j] = $noticia; } if(isset($resultsNoticies)) { return $resultsNoticies; } else { return false; } } function listAllNoticiesPublicadesJSON($language, $excepto = null) { $listaNoticies = $this->listAllNoticiesPublicades(null, $language, $excepto); $returnCadena = "["; if(!empty($listaNoticies)) { foreach($listaNoticies as $noticia) { $noticiesLang = $noticia->getNoticiaLang(); $descripcion = html_entity_decode($noticiesLang[0]->getDescripcio()); $descripcion = parserHTML($descripcion, 200); $returnCadena .= "{\"idNoticia\": \"" .$noticia->getIdNoticia(). "\", "; $returnCadena .= "\"titol\": \"" .str_replace("\"","'",$noticiesLang[0]->getTitol()). "\", "; $returnCadena .= "\"data\" : \"" .date('d/m/Y',strtotime($noticia->getFecha())). "\", "; $returnCadena .= "\"descripcion\" : \"" .str_replace("\"","'",$descripcion)."\", "; $returnCadena .= "\"dataPublicacio\": \"" .date('d/m/Y',strtotime($noticia->getFechaPublicacion())). "\", "; $returnCadena .= "\"adjunto\": \"" .$noticia->getAdjunto(). "\", "; $returnCadena .= "\"foto\": \"" .$noticia->getFoto(). "\"}, "; } } $returnCadena .= "]"; $returnCadena = str_replace(", ]", "]", $returnCadena); echo $returnCadena; } function listAllNoticiesJSON($language, $excepto = null) { $listaNoticies = $this->listAllNoticies($language); $returnCadena = "["; if(!empty($listaNoticies)) { foreach($listaNoticies as $noticia) { $noticiesLang = $noticia->getNoticiaLang(); $descripcion = html_entity_decode($noticiesLang[0]->getDescripcio()); $descripcion = parserHTML($descripcion, 225); $returnCadena .= "{\"idNoticia\": \"" .$noticia->getIdNoticia(). "\", "; $returnCadena .= "\"titol\": \"" .str_replace("\"","'",$noticiesLang[0]->getTitol()). "\", "; $returnCadena .= "\"data\" : \"" .date('d/m/Y',strtotime($noticia->getFecha())). "\", "; $returnCadena .= "\"descripcion\" : \"" .str_replace("\"","'",$descripcion)."\", "; $returnCadena .= "\"dataPublicacio\": \"" .date('d/m/Y',strtotime($noticia->getFechaPublicacion())). "\", "; $textoAdjunto = ""; if($noticia->getAdjunto() != "") { $textoAdjunto = "".$noticia->getAdjunto().""; } else { $textoAdjunto = "".NO_HAY_ADJUNTO.""; } $returnCadena .= "\"adjunto\": \"" .$textoAdjunto. "\", "; $returnCadena .= "\"foto\": \"" .$noticia->getFoto(). "\"}, "; } } $returnCadena .= "]"; $returnCadena = str_replace(", ]", "]", $returnCadena); echo $returnCadena; } function countAllNoticies() { $bd = new Bd(); $sql = "SELECT count(*) FROM noticies"; $bd->select($sql); $resultados = $bd->getResults(); while ($row = mysql_fetch_row($resultados)) { $result = $row[0]; } $bd->freeResults($bd->getResults()); if(isset($result)) { return $result; } else { return 0; } } function insertNoticia($noticia) { $bd = new Bd(); if($noticia->getAdjunto()!= null && $noticia->getAdjunto() != "") { $sql = "INSERT INTO noticies (data, data_publicacio, foto, arxiu_adjunt) "; $sql .= "VALUES('".date( 'Y-m-d H:i:s')."', '".date('Y-m-d',strtotime($noticia->getFechaPublicacion()))."', "; $sql .= "'".$noticia->getFoto()."', '".$noticia->getAdjunto()."')"; } else { $sql = "INSERT INTO noticies (data, data_publicacio, foto) "; $sql .= "VALUES('".date( 'Y-m-d H:i:s')."', '".date('Y-m-d',strtotime($noticia->getFechaPublicacion()))."', "; $sql .= "'".$noticia->getFoto()."')"; } $bd->select($sql); $resultados = $bd->getResults(); if(!$resultados) { return false; } else { $noti = $noticia->findLastNoticiaPublicadaToInsert(); $idNoticia = $noti->getIdNoticia(); $result = true; foreach($noticia->getNoticiaLang() as $lang) { $sql2 = "INSERT INTO noticies_lang (id_noticia, id_lang, titol, descripcio) "; $sql2 .= "VALUES(".$idNoticia.", ".$lang->getIdLang().", "; $sql2 .= "'".mysql_real_escape_string($lang->getTitol())."', '".mysql_real_escape_string($lang->getDescripcio())."')"; $bd->select($sql2); $resultados2 = $bd->getResults(); if(!$resultados2) { $result = false; } } return $result; } } function deleteNoticia($id) { $bd = new Bd(); $sql2 = "DELETE FROM noticies_lang WHERE id_noticia = '". $id ."'"; $bd->select($sql2); $resultados2 = $bd->getResults(); if(!$resultados2) { return false; } else { $sql = "DELETE FROM noticies WHERE id_noticia = '". $id ."'"; $bd->select($sql); $resultados = $bd->getResults(); if(!$resultados) { return false; } else { return true; } } } function existsPhoto($nombreFoto) { $bd = new Bd(); $sql = "SELECT count(*) FROM noticies WHERE foto = '" . $nombreFoto ."'"; $bd->select($sql); $resultados = $bd->getResults(); while ($row = mysql_fetch_row($resultados)) { $result = $row[0]; } $bd->freeResults($bd->getResults()); if(isset($result)) { return $result; } else { return 0; } } function existsAdjunto($nombre) { $bd = new Bd(); $sql = "SELECT count(*) FROM noticies WHERE arxiu_adjunt = '" . $nombre ."'"; $bd->select($sql); $resultados = $bd->getResults(); while ($row = mysql_fetch_row($resultados)) { $result = $row[0]; } $bd->freeResults($bd->getResults()); if(isset($result)) { return $result; } else { return 0; } } function deleteAdjunto($idNoticia) { $bd = new Bd(); $sql = "UPDATE noticies SET arxiu_adjunt = null WHERE id_noticia = '". $idNoticia ."'"; $bd->select($sql); $resultados = $bd->getResults(); if(!$resultados) { return false; } else { return true; } } function updateNoticia($noticia) { $bd = new Bd(); if($noticia->getFoto()!= null && $noticia->getFoto() != "" && $noticia->getAdjunto() != null && $noticia->getAdjunto() != "") { $sql = "UPDATE noticies SET data_publicacio = '".date('Y-m-d',strtotime($noticia->getFechaPublicacion()))."', foto = '".$noticia->getFoto()."', arxiu_adjunt = '".$noticia->getAdjunto()."' WHERE id_noticia = '".$noticia->getIdNoticia()."'"; } else if($noticia->getFoto()!= null && $noticia->getFoto() != "" && ($noticia->getAdjunto() == null || $noticia->getAdjunto() == "")){ $sql = "UPDATE noticies SET data_publicacio = '".date('Y-m-d',strtotime($noticia->getFechaPublicacion()))."', foto = '".$noticia->getFoto()."' WHERE id_noticia = '".$noticia->getIdNoticia()."'"; } else if(($noticia->getFoto()== null || $noticia->getFoto() == "") && $noticia->getAdjunto() != null && $noticia->getAdjunto() != "") { $sql = "UPDATE noticies SET data_publicacio = '".date('Y-m-d',strtotime($noticia->getFechaPublicacion()))."', arxiu_adjunt = '".$noticia->getAdjunto()."' WHERE id_noticia = '".$noticia->getIdNoticia()."'"; } else { $sql = "UPDATE noticies SET data_publicacio = '".date('Y-m-d',strtotime($noticia->getFechaPublicacion()))."' WHERE id_noticia = '".$noticia->getIdNoticia()."'"; } $bd->select($sql); $resultados = $bd->getResults(); if(!$resultados) { return false; } else { $result = true; foreach($noticia->getNoticiaLang() as $lang) { $sql2 = "UPDATE noticies_lang SET titol = '".mysql_real_escape_string($lang->getTitol())."', descripcio = '".mysql_real_escape_string($lang->getDescripcio())."' WHERE id_noticia = '".$lang->getIdNoticia()."' AND id_lang = '" .$lang->getIdLang()."'"; $bd->select($sql2); $resultados2 = $bd->getResults(); if(!$resultados2) { $result = false; } } return $result; } } } ?> TITLE | TITLE_INICIO