id_rss_flux = $id+0;
$this->getData();
}
// ---------------------------------------------------------------
// getData() : recuperation infos
// ---------------------------------------------------------------
public function getData() {
if (!$this->id_rss_flux) {
// pas d'identifiant. on retourne un tableau vide
$this->id_rss_flux=0;
$this->nom_rss_flux = "" ;
$this->link_rss_flux = "" ;
$this->descr_rss_flux = "" ;
$this->metadata_rss_flux = 1 ;
$this->lang_rss_flux = "" ;
$this->copy_rss_flux = "" ;
$this->editor_rss_flux = "" ;
$this->webmaster_rss_flux = "" ;
$this->ttl_rss_flux = 0 ;
$this->img_url_rss_flux = "" ;
$this->img_title_rss_flux = "" ;
$this->img_link_rss_flux = "" ;
$this->format_flux = "";
$this->export_court_flux = 0;
$this->tpl_title_rss_flux = "0";
$this->tpl_rss_flux = "0";
$this->id_tri_rss_flux = 0;
$this->compte_elements();
} else {
$requete = "SELECT id_rss_flux, nom_rss_flux, link_rss_flux, descr_rss_flux, metadata_rss_flux, lang_rss_flux, copy_rss_flux, editor_rss_flux, webmaster_rss_flux, ttl_rss_flux, img_url_rss_flux, img_title_rss_flux, img_link_rss_flux, format_flux, export_court_flux, tpl_title_rss_flux, tpl_rss_flux, id_tri_rss_flux,";
$requete .= "IF(date_add(rss_flux_last,INTERVAL ttl_rss_flux MINUTE)>sysdate(),rss_flux_content,'') as contenu_du_flux ";
$requete .= "FROM rss_flux WHERE id_rss_flux='".$this->id_rss_flux."' " ;
$result = pmb_mysql_query($requete);
if(pmb_mysql_num_rows($result)) {
$temp = pmb_mysql_fetch_object($result);
$this->id_rss_flux = $temp->id_rss_flux ;
$this->nom_rss_flux = $temp->nom_rss_flux ;
$this->link_rss_flux = $temp->link_rss_flux ;
$this->descr_rss_flux = $temp->descr_rss_flux ;
$this->metadata_rss_flux = $temp->metadata_rss_flux ;
$this->lang_rss_flux = $temp->lang_rss_flux ;
$this->copy_rss_flux = $temp->copy_rss_flux ;
$this->editor_rss_flux = $temp->editor_rss_flux ;
$this->webmaster_rss_flux = $temp->webmaster_rss_flux ;
$this->ttl_rss_flux = $temp->ttl_rss_flux ;
$this->img_url_rss_flux = $temp->img_url_rss_flux ;
$this->img_title_rss_flux = $temp->img_title_rss_flux ;
$this->img_link_rss_flux = $temp->img_link_rss_flux ;
$this->format_flux = $temp->format_flux ;
$this->contenu_du_flux = $temp->contenu_du_flux ;
$this->export_court_flux = $temp->export_court_flux;
$this->tpl_title_rss_flux = $temp->tpl_title_rss_flux;
$this->tpl_rss_flux = $temp->tpl_rss_flux;
$this->id_tri_rss_flux = $temp->id_tri_rss_flux;
$this->compte_elements();
} else {
// pas de flux avec cette cle
$this->id_rss_flux=0;
$this->nom_rss_flux = "" ;
$this->link_rss_flux = "" ;
$this->descr_rss_flux = "" ;
$this->metadata_rss_flux = 1 ;
$this->lang_rss_flux = "" ;
$this->copy_rss_flux = "" ;
$this->editor_rss_flux = "" ;
$this->webmaster_rss_flux = "" ;
$this->ttl_rss_flux = 0 ;
$this->img_url_rss_flux = "" ;
$this->img_title_rss_flux = "" ;
$this->img_link_rss_flux = "" ;
$this->format_flux="";
$this->contenu_du_flux="";
$this->export_court_flux = 0;
$this->tpl_title_rss_flux = "0";
$this->tpl_rss_flux = "0";
$this->id_tri_rss_flux = 0;
$this->compte_elements();
}
}
}
// ---------------------------------------------------------------
// show_form : affichage du formulaire de saisie
// ---------------------------------------------------------------
public function show_form() {
global $msg, $charset;
global $dsi_flux_form;
global $dbh ;
if($this->id_rss_flux) {
$action = "./dsi.php?categ=fluxrss&sub=&id_rss_flux=$this->id_rss_flux&suite=update";
$button_delete = "";
$libelle = $msg['dsi_flux_form_modif'];
} else {
$action = "./dsi.php?categ=fluxrss&sub=&id_rss_flux=0&suite=update";
$libelle = $msg['dsi_flux_form_creat'];
$button_delete ='';
}
$dsi_flux_form = str_replace('!!libelle!!', $libelle, $dsi_flux_form);
$dsi_flux_form = str_replace('!!id_rss_flux!!', $this->id_rss_flux, $dsi_flux_form);
$dsi_flux_form = str_replace('!!action!!', $action, $dsi_flux_form);
$dsi_flux_form = str_replace('!!nom_rss_flux!!' , htmlentities($this->nom_rss_flux ,ENT_QUOTES, $charset), $dsi_flux_form);
$dsi_flux_form = str_replace('!!link_rss_flux!!' , htmlentities($this->link_rss_flux ,ENT_QUOTES, $charset), $dsi_flux_form);
$dsi_flux_form = str_replace('!!descr_rss_flux!!' , htmlentities($this->descr_rss_flux ,ENT_QUOTES, $charset), $dsi_flux_form);
$dsi_flux_form = str_replace('!!metadata_rss_flux!!' , ($this->metadata_rss_flux ? "checked='checked'" : ""), $dsi_flux_form);
$dsi_flux_form = str_replace('!!lang_rss_flux!!' , htmlentities($this->lang_rss_flux ,ENT_QUOTES, $charset), $dsi_flux_form);
$dsi_flux_form = str_replace('!!copy_rss_flux!!' , htmlentities($this->copy_rss_flux ,ENT_QUOTES, $charset), $dsi_flux_form);
$dsi_flux_form = str_replace('!!editor_rss_flux!!' , htmlentities($this->editor_rss_flux ,ENT_QUOTES, $charset), $dsi_flux_form);
$dsi_flux_form = str_replace('!!webmaster_rss_flux!!' , htmlentities($this->webmaster_rss_flux ,ENT_QUOTES, $charset), $dsi_flux_form);
$dsi_flux_form = str_replace('!!ttl_rss_flux!!' , htmlentities($this->ttl_rss_flux ,ENT_QUOTES, $charset), $dsi_flux_form);
$dsi_flux_form = str_replace('!!img_url_rss_flux!!' , htmlentities($this->img_url_rss_flux ,ENT_QUOTES, $charset), $dsi_flux_form);
$dsi_flux_form = str_replace('!!img_title_rss_flux!!' , htmlentities($this->img_title_rss_flux ,ENT_QUOTES, $charset), $dsi_flux_form);
$dsi_flux_form = str_replace('!!img_link_rss_flux!!' , htmlentities($this->img_link_rss_flux ,ENT_QUOTES, $charset), $dsi_flux_form);
$dsi_flux_form = str_replace('!!format_flux!!' , htmlentities($this->format_flux ,ENT_QUOTES, $charset), $dsi_flux_form);
$dsi_flux_form = str_replace('!!export_court!!' , $this->export_court_flux ? 'checked' : '', $dsi_flux_form);
$rqt="select idcaddie as id_obj, name as name_obj from caddie where type='NOTI' order by name ";
$result = pmb_mysql_query($rqt);
$paniers = "";
while (($contenant = pmb_mysql_fetch_object($result))) {
if (array_search($contenant->id_obj,$this->num_paniers)!==false) $checked="checked" ;
else $checked="" ;
$paniers .= "
";
}
$dsi_flux_form = str_replace('!!paniers!!', $paniers, $dsi_flux_form);
$rqt="select id_bannette as id_obj, nom_bannette as name_obj from bannettes where proprio_bannette=0 order by nom_bannette ";
$result = pmb_mysql_query($rqt);
$bannettes = "";
while (($contenant = pmb_mysql_fetch_object($result))) {
if (array_search($contenant->id_obj,$this->num_bannettes)!==false) $checked="checked" ;
else $checked="" ;
$bannettes .= "
";
}
$dsi_flux_form = str_replace('!!bannettes!!', $bannettes, $dsi_flux_form);
if($this->id_tri_rss_flux>0){
$sort = new sort("notices","base");
$dsi_flux_form = str_replace('!!tri!!', $this->id_tri_rss_flux, $dsi_flux_form);
$dsi_flux_form = str_replace('!!tri_name!!', $sort->descriptionTriParId($this->id_tri_rss_flux), $dsi_flux_form);
}else{
$dsi_flux_form = str_replace('!!tri!!', "", $dsi_flux_form);
$dsi_flux_form = str_replace('!!tri_name!!', $msg['dsi_flux_form_no_active_tri'], $dsi_flux_form);
}
$dsi_flux_form = str_replace('!!delete!!', $button_delete, $dsi_flux_form);
// afin de revenir oł on etait : $form_cb, le critere de recherche
global $form_cb ;
$dsi_flux_form = str_replace('!!form_cb!!', $form_cb, $dsi_flux_form);
print $dsi_flux_form;
}
// ---------------------------------------------------------------
// delete() : suppression
// ---------------------------------------------------------------
public function delete() {
global $msg;
if (!$this->id_rss_flux) return $msg['dsi_flux_no_access']; // impossible d'acceder
$requete = "delete from rss_flux_content WHERE num_rss_flux='$this->id_rss_flux'";
pmb_mysql_query($requete);
$requete = "delete from rss_flux WHERE id_rss_flux='$this->id_rss_flux'";
pmb_mysql_query($requete);
}
// ---------------------------------------------------------------
// update
// ---------------------------------------------------------------
public function update($temp) {
global $dbh;
if ($this->id_rss_flux) {
// update
$req = "UPDATE rss_flux set ";
$clause = " WHERE id_rss_flux='".$this->id_rss_flux."' ";
} else {
$req = "insert into rss_flux set ";
$clause = "";
}
$req .= "id_rss_flux ='".$temp->id_rss_flux ."', " ;
$req .= "nom_rss_flux ='".$temp->nom_rss_flux ."', " ;
$req .= "link_rss_flux ='".$temp->link_rss_flux ."', " ;
$req .= "descr_rss_flux ='".$temp->descr_rss_flux ."', " ;
$req .= "metadata_rss_flux ='".$temp->metadata_rss_flux ."', " ;
$req .= "lang_rss_flux ='".$temp->lang_rss_flux ."', " ;
$req .= "copy_rss_flux ='".$temp->copy_rss_flux ."', " ;
$req .= "editor_rss_flux ='".$temp->editor_rss_flux ."', " ;
$req .= "webmaster_rss_flux='".$temp->webmaster_rss_flux ."', " ;
$req .= "ttl_rss_flux ='".$temp->ttl_rss_flux ."', " ;
$req .= "img_url_rss_flux ='".$temp->img_url_rss_flux ."', " ;
$req .= "img_title_rss_flux='".$temp->img_title_rss_flux ."', " ;
$req .= "img_link_rss_flux ='".$temp->img_link_rss_flux ."', " ;
$req .= "export_court_flux ='".$temp->export_court_flux ."', " ;
$req .= "tpl_title_rss_flux='".$temp->tpl_title_rss_flux ."', " ;
$req .= "tpl_rss_flux ='".$temp->tpl_rss_flux ."', " ;
$req .= "id_tri_rss_flux ='".$temp->id_tri_rss_flux ."', " ;
$req .= "format_flux ='".$temp->format_flux ."' " ;
$req.=$clause ;
$res = pmb_mysql_query($req);
if (!$this->id_rss_flux) $this->id_rss_flux = pmb_mysql_insert_id() ;
pmb_mysql_query("delete from rss_flux_content where num_rss_flux='$this->id_rss_flux' " ) ;
for ($i=0;$inum_paniers);$i++) {
pmb_mysql_query("insert into rss_flux_content set num_rss_flux='$this->id_rss_flux', type_contenant='CAD', num_contenant='".$temp->num_paniers[$i]."' " ) ;
}
for ($i=0;$inum_bannettes);$i++) {
pmb_mysql_query("insert into rss_flux_content set num_rss_flux='$this->id_rss_flux', type_contenant='BAN', num_contenant='".$temp->num_bannettes[$i]."' " ) ;
}
}
// ---------------------------------------------------------------
// compte_elements() : methode pour pouvoir recompter en dehors !
// ---------------------------------------------------------------
public function compte_elements() {
$this->nb_paniers=0;
$this->nb_bannettes=0;
$this->num_paniers=array();
$this->num_bannettes=array();
$req_nb = "SELECT num_contenant from rss_flux_content WHERE num_rss_flux='".$this->id_rss_flux."' and type_contenant='CAD' " ;
$res_nb = pmb_mysql_query($req_nb);
while (($res = pmb_mysql_fetch_object($res_nb))) {
$this->num_paniers[]=$res->num_contenant ;
$this->nb_paniers++ ;
}
$req_nb = "SELECT num_contenant from rss_flux_content WHERE num_rss_flux='".$this->id_rss_flux."' and type_contenant='BAN' " ;
$res_nb = pmb_mysql_query($req_nb);
while ($res = pmb_mysql_fetch_object($res_nb)) {
$this->num_bannettes[]=$res->num_contenant ;
$this->nb_bannettes++ ;
}
}
// ---------------------------------------------------------------
// generation du fichier XML
// ---------------------------------------------------------------
public function xmlfile() {
global $pmb_bdd_version, $charset ;
if (!$charset) $charset='ISO-8859-1';
if (!$this->id_rss_flux) die();
$this->envoi="
".htmlspecialchars ($this->nom_rss_flux,ENT_QUOTES, $charset)."
".htmlspecialchars ($this->link_rss_flux,ENT_QUOTES, $charset)."
".htmlspecialchars ($this->descr_rss_flux,ENT_QUOTES, $charset)."
".htmlspecialchars ($this->lang_rss_flux,ENT_QUOTES, $charset)."
".htmlspecialchars ($this->copy_rss_flux,ENT_QUOTES, $charset)."
".addslashes(date("D, d M Y H:i:s O"))."
http://backend.userland.com/rss
PMB Version ".$pmb_bdd_version."
".htmlspecialchars ($this->editor_rss_flux,ENT_QUOTES, $charset)."
".htmlspecialchars ($this->webmaster_rss_flux,ENT_QUOTES, $charset)."
".$this->ttl_rss_flux."";
if ($this->img_url_rss_flux) {
$this->envoi.="
".htmlspecialchars ($this->img_url_rss_flux,ENT_QUOTES, $charset)."
".htmlspecialchars ($this->img_title_rss_flux,ENT_QUOTES, $charset)."
".htmlspecialchars ($this->img_link_rss_flux,ENT_QUOTES, $charset)."
" ;
}
$this->envoi.="
!!items!!
";
}
// ---------------------------------------------------------------
// stocke_cache($cache) : stockage du flux en cache pour eviter de le recalculer a chaque appel
// ---------------------------------------------------------------
public function stocke_cache() {
global $dbh;
global $msg;
if (!$this->id_rss_flux) return $msg['dsi_flux_no_access']; // impossible d'acceder
$requete = "update rss_flux set rss_flux_content='".addslashes($this->contenu_du_flux)."', rss_flux_last=sysdate() WHERE id_rss_flux='$this->id_rss_flux'";
pmb_mysql_query($requete, $dbh);
}
protected function get_sort_rss_flux_query($query='', $sort_name="notices") {
global $opac_flux_rss_notices_order;
if($this->id_tri_rss_flux) {
$dSort = new dataSort($sort_name, 'session');
$dSort->applyTri($this->id_tri_rss_flux);
}
if (isset($_SESSION["last_sort$sort_name"])) {
$sort = new sort($sort_name, 'session');
$query = $sort->appliquer_tri($_SESSION["last_sort$sort_name"], $query, "notice_id", 0, 0);
} else {
if (!$opac_flux_rss_notices_order) $opac_flux_rss_notices_order="index_serie, tnvol, index_sew";
$query = $query." order by ".$opac_flux_rss_notices_order;
}
return $query;
}
// ---------------------------------------------------------------
// id des notices concernees, attention, on n'envoie que les publiques (statuts de notices)
// ---------------------------------------------------------------
public function items_notices() {
global $dbh, $liens_opac ;
global $charset;
global $opac_notice_affichage_class;
global $deflt2docs_location;
if (!$this->nb_bannettes && !$this->nb_paniers) {
$this->notices = "";
return;
}
$retour_aff = '';
if (!$charset) $charset='ISO-8859-1';
$rqt = array();
if ($this->nb_bannettes) {
$rqt[] = "select distinct notice_id, niveau_biblio, index_sew, create_date, update_date, index_serie, tnvol, year, date_parution
from notices join bannette_contenu on num_notice=notice_id
join notice_statut on statut=id_notice_statut
where notice_visible_opac=1 and notice_visible_opac_abon=0 and num_bannette in (".implode(",",$this->num_bannettes).") ";
}
if ($this->nb_paniers) {
$rqt[] = "select distinct notice_id, niveau_biblio, index_sew, create_date, update_date, index_serie, tnvol, year, date_parution
from notices join caddie_content on object_id=notice_id
join notice_statut on statut=id_notice_statut
where notice_visible_opac=1 and notice_visible_opac_abon=0 and caddie_id in (".implode(",",$this->num_paniers).") ";
}
$rqtfinale = implode(' union ',$rqt) ;
pmb_mysql_query("create temporary table tmpfluxrss ENGINE=MyISAM $rqtfinale ",$dbh); // Thu, 27 Apr 2006 23:40:11 +0100
$query_not = "select distinct notice_id, niveau_biblio, DATE_FORMAT(create_date,'%a, %e %b %Y %T') as pubdate from tmpfluxrss ";
$query_not = $this->get_sort_rss_flux_query($query_not);
$res = pmb_mysql_query($query_not,$dbh);
while (($tmp=pmb_mysql_fetch_object($res))) {
if($opac_notice_affichage_class != ""){
$notice = new $opac_notice_affichage_class($tmp->notice_id, $liens_opac, "", 1, 0, 0, 1, true);
}else $notice = new notice_affichage($tmp->notice_id, $liens_opac, "", 1, 0, 0, 1, true);
$notice->visu_expl = 0 ;
$notice->visu_explnum = 0 ;
$title = '';
if($this->tpl_title_rss_flux){
if(intval($this->tpl_title_rss_flux)) {
$noti_tpl = notice_tpl_gen::get_instance($this->tpl_title_rss_flux);
$title.=$noti_tpl->build_notice($tmp->notice_id,$deflt2docs_location);
} else {
$title.= record_display::get_display_for_rss_title($tmp->notice_id, $this->tpl_title_rss_flux);
}
} else {
$notice->do_header_without_html();
$title .= $notice->notice_header_without_html;
}
if($tmp->niveau_biblio == 'b') {
$bulletin_id = pmb_mysql_result(pmb_mysql_query("select bulletin_id from bulletins where num_notice = ".$tmp->notice_id), 0, 'bulletin_id');
$permalink = str_replace("!!id!!", $bulletin_id, $liens_opac['lien_rech_bulletin']);
} else {
$permalink = str_replace("!!id!!", $tmp->notice_id, $liens_opac['lien_rech_notice']);
}
$retour_aff .= "-
".htmlspecialchars ($title,ENT_QUOTES, $charset)."
".htmlspecialchars ($tmp->pubdate,ENT_QUOTES, $charset)."
".htmlspecialchars ($permalink, ENT_QUOTES, $charset)."" ;
$desc='';
$desc_explnum='';
if ($this->export_court_flux) {
$notice->do_isbd(1,0);
$desc=$notice->notice_isbd;
}elseif($this->tpl_rss_flux){
if(intval($this->tpl_rss_flux)) {
$noti_tpl = notice_tpl_gen::get_instance($this->tpl_rss_flux);
$desc.=$noti_tpl->build_notice($tmp->notice_id,$deflt2docs_location);
} else {
$desc.= record_display::get_display_for_rss_description($tmp->notice_id, $this->tpl_rss_flux);
}
}else{
switch ($this->format_flux) {
case 'TITLE' :
$desc='';
break;
case 'ABSTRACT' :
$desc=$notice->notice->n_resume.'
';
break;
case 'ISBD' :
default :
$notice->do_isbd(0,0);
$desc=$notice->notice_isbd;
$desc_explnum=$this->do_explnum($tmp->notice_id,$tmp->niveau_biblio);
}
}
if(!$this->tpl_rss_flux){
$image = $this->do_image($notice->notice->code,$notice->notice->thumbnail_url,$notice->notice->tit1) ;
$desc = str_replace("
","
",$desc);
$retour_aff .= " ".htmlspecialchars(strip_tags($image.$desc," "),ENT_QUOTES, $charset)."";
$retour_aff .= $desc_explnum;
}else{
$retour_aff .= " ".htmlspecialchars($desc,ENT_QUOTES, $charset)."";
}
$retour_aff .= "" ;
}
$this->notices = $retour_aff ;
}
public function do_image($code,$vigurl="",$tit1="") {
global $charset;
global $opac_show_book_pics ;
global $opac_book_pics_url ;
global $opac_book_pics_msg ;
global $opac_url_base ;
global $msg;
$image = "";
if ($code<>"" || $vigurl<>"") {
if ($opac_show_book_pics=='1' && ($opac_book_pics_url || $vigurl)) {
$url_image_ok=getimage_url($code, $vigurl);
$title_image_ok = "";
if(!$vigurl) {
$title_image_ok = htmlentities($opac_book_pics_msg, ENT_QUOTES, $charset);
}
if(!trim($title_image_ok)){
$title_image_ok = htmlentities($tit1, ENT_QUOTES, $charset);
}
$image = "";
}
}
return $image ;
}
// fonction retournant les infos d'exemplaires numeriques pour une notice
public function do_explnum($no_notice,$niveau_biblio="m") {
global $dbh;
global $charset;
global $opac_url_base ;
if (!$no_notice) return "";
if (!$charset) $charset='ISO-8859-1';
create_tableau_mimetype() ;
// recuperation du nombre d'exemplaires
$requete = "SELECT explnum_id, explnum_notice, explnum_nom, explnum_mimetype, explnum_url, length(explnum_data) as taille ";
$requete .= "FROM explnum JOIN explnum_statut on explnum_statut.id_explnum_statut = explnum.explnum_docnum_statut ";
if($niveau_biblio != "b"){
$requete .= "JOIN notices ON explnum.explnum_notice=notice_id AND explnum.explnum_bulletin=0 ";
$requete .= "JOIN notice_statut ON notices.statut=notice_statut.id_notice_statut ";
$requete .= "WHERE explnum.explnum_notice='".$no_notice."' ";
}else{//Pour les notices de bulletin
$requete .= "JOIN bulletins ON explnum.explnum_bulletin=bulletins.bulletin_id AND explnum.explnum_notice=0 ";
$requete .= "JOIN notices ON bulletins.num_notice=notices.notice_id ";
$requete .= "JOIN notice_statut ON notices.statut=notice_statut.id_notice_statut ";
$requete .= "WHERE bulletins.num_notice='".$no_notice."' ";
}
$requete .= "AND explnum_statut.explnum_visible_opac=1 and explnum_statut.explnum_visible_opac_abon=0 ";
$requete .= "AND notice_statut.explnum_visible_opac=1 and notice_statut.explnum_visible_opac_abon=0 ";
$requete .= "ORDER BY explnum_mimetype, explnum_id";
$res = pmb_mysql_query($requete, $dbh);
$retour = "";
while (($expl = pmb_mysql_fetch_object($res))) {
$url=htmlspecialchars ($opac_url_base."doc_num.php?explnum_id=".$expl->explnum_id,ENT_QUOTES, $charset) ;
$mime=htmlspecialchars ($expl->explnum_mimetype,ENT_QUOTES, $charset) ;
$retour .= "taille."\" />";
}
return $retour;
}
} # fin de definition
|