option_visibilite = array( 'multiple' => "none", 'opac_sort' => "none", 'exclusion' => "none" ); $this->prefix="cms_editorial"; $this->base_url=$base_url; $_custom_prefixe_="cms_editorial"; $this->num_type = $type*1; $this->fetch_data_cache(); } protected function fetch_data_cache(){ if($tmp=cms_cache::get_at_cms_cache($this)){ $this->restore($tmp); }else{ $this->fetch_data(); cms_cache::set_at_cms_cache($this); } } protected function restore($cms_object){ foreach(get_object_vars($cms_object) as $propertieName=>$propertieValue){ $this->{$propertieName}=$propertieValue; } } protected function fetch_data(){ //Lecture des champs $this->no_special_fields=0; $this->t_fields=array(); $requete="select idchamp, name, titre, type, datatype, obligatoire, options, multiple, search, export, exclusion_obligatoire, pond, opac_sort from ".$this->prefix."_custom where num_type = '".$this->num_type."' order by ordre"; $resultat=pmb_mysql_query($requete); if (pmb_mysql_num_rows($resultat)==0) $this->no_special_fields=1; else { while ($r=pmb_mysql_fetch_object($resultat)) { $this->t_fields[$r->idchamp]["DATATYPE"]=$r->datatype; $this->t_fields[$r->idchamp]["NAME"]=$r->name; $this->t_fields[$r->idchamp]["TITRE"]=$r->titre; $this->t_fields[$r->idchamp]["TYPE"]=$r->type; $this->t_fields[$r->idchamp]["OPTIONS"]=$r->options; $this->t_fields[$r->idchamp]["MANDATORY"]=$r->obligatoire; $this->t_fields[$r->idchamp]["OPAC_SHOW"]=$r->multiple; $this->t_fields[$r->idchamp]["SEARCH"]=$r->search; $this->t_fields[$r->idchamp]["EXPORT"]=$r->export; $this->t_fields[$r->idchamp]["EXCLUSION"]=$r->exclusion_obligatoire; $this->t_fields[$r->idchamp]["POND"]=$r->pond; $this->t_fields[$r->idchamp]["OPAC_SORT"]=$r->opac_sort; } } } //Gestion des actions en administration public function proceed() { global $action; global $name,$titre,$type,$datatype,$_options,$multiple,$obligatoire,$search,$export,$exclusion,$ordre,$idchamp,$id,$pond,$opac_sort; switch ($action) { case "nouv": $this->show_edit_form(); break; case "edit": $this->show_edit_form($id); break; case "create": $this->check_form(); $requete="select max(ordre) from ".$this->prefix."_custom where num_type = ".$this->num_type; $resultat=pmb_mysql_query($requete); if (pmb_mysql_num_rows($resultat)!=0) $ordre=pmb_mysql_result($resultat,0,0)+1; else $ordre=1; $requete="insert into ".$this->prefix."_custom set num_type = '$this->num_type', name='$name', titre='$titre', type='$type', datatype='$datatype', options='$_options', multiple=$multiple, obligatoire=$obligatoire, ordre=$ordre, search=$search, export=$export, exclusion_obligatoire=$exclusion, opac_sort=$opac_sort "; pmb_mysql_query($requete); echo $this->show_field_list(); break; case "update": $this->check_form(); $requete="update ".$this->prefix."_custom set name='$name', titre='$titre', type='$type', datatype='$datatype', options='$_options', multiple=$multiple, obligatoire=$obligatoire, ordre=$ordre, search=$search, export=$export, exclusion_obligatoire=$exclusion, pond=$pond, opac_sort=$opac_sort where idchamp=$idchamp"; pmb_mysql_query($requete); echo $this->show_field_list(); break; case "up": $requete="select ordre from ".$this->prefix."_custom where idchamp=$id"; $resultat=pmb_mysql_query($requete); $ordre=pmb_mysql_result($resultat,0,0); $requete="select max(ordre) as ordre from ".$this->prefix."_custom where ordre<$ordre and num_type = ".$this->num_type; $resultat=pmb_mysql_query($requete); $ordre_max=@pmb_mysql_result($resultat,0,0); if ($ordre_max) { $requete="select idchamp from ".$this->prefix."_custom where ordre=$ordre_max and num_type = ".$this->num_type." limit 1"; $resultat=pmb_mysql_query($requete); $idchamp_max=pmb_mysql_result($resultat,0,0); $requete="update ".$this->prefix."_custom set ordre='".$ordre_max."' where idchamp=$id and num_type = ".$this->num_type; pmb_mysql_query($requete); $requete="update ".$this->prefix."_custom set ordre='".$ordre."' where idchamp=".$idchamp_max." and num_type = ".$this->num_type; pmb_mysql_query($requete); } echo $this->show_field_list(); break; case "down": $requete="select ordre from ".$this->prefix."_custom where idchamp=$id"; $resultat=pmb_mysql_query($requete); $ordre=pmb_mysql_result($resultat,0,0); $requete="select min(ordre) as ordre from ".$this->prefix."_custom where ordre>$ordre and num_type = ".$this->num_type; $resultat=pmb_mysql_query($requete); $ordre_min=@pmb_mysql_result($resultat,0,0); if ($ordre_min) { $requete="select idchamp from ".$this->prefix."_custom where ordre=$ordre_min and num_type = ".$this->num_type." limit 1"; $resultat=pmb_mysql_query($requete); $idchamp_min=pmb_mysql_result($resultat,0,0); $requete="update ".$this->prefix."_custom set ordre='".$ordre_min."' where idchamp=$id and num_type = ".$this->num_type; pmb_mysql_query($requete); $requete="update ".$this->prefix."_custom set ordre='".$ordre."' where idchamp=".$idchamp_min." and num_type = ".$this->num_type; pmb_mysql_query($requete); } echo $this->show_field_list(); break; case "delete": $requete="delete from ".$this->prefix."_custom where idchamp=$idchamp"; pmb_mysql_query($requete); $requete="delete from ".$this->prefix."_custom_values where ".$this->prefix."_custom_champ=$idchamp"; pmb_mysql_query($requete); $requete="delete from ".$this->prefix."_custom_lists where ".$this->prefix."_custom_champ=$idchamp"; pmb_mysql_query($requete); echo $this->show_field_list(); break; default: echo $this->show_field_list(); } } public function get_selector_options($selected=0){ global $msg,$charset; $options = $type = ""; //les champs génériques... $query = "select editorial_type_element from cms_editorial_types where id_editorial_type=".$this->num_type; $result = pmb_mysql_query($query); if(pmb_mysql_num_rows($result)){ $type = pmb_mysql_result($result,0,0); $generic_type = $this->get_generic_type($type); if($generic_type){ $generic = new cms_editorial_parametres_perso($generic_type,$this->base_url); $options.=$generic->get_selector_options($selected); } } if(strpos($type,"generic") !== false){ $options.= " "; } foreach($this->t_fields as $id=>$field){ $options.= " "; } return $options; } //Affichage de l'écran de gestion des paramètres perso (la liste de tous les champs définis) public function show_field_list() { global $type_list_empr; global $datatype_list; global $form_list; global $msg; $query="select editorial_type_label, editorial_type_element, editorial_type_comment from cms_editorial_types where id_editorial_type = ".$this->num_type; $result = pmb_mysql_query($query); if(pmb_mysql_num_rows($result)){ $row = pmb_mysql_fetch_object($result); } if(strpos($row->editorial_type_element,"generic")!== false){ $res="
".$msg["parperso_field_name"]." | ".$msg["parperso_field_title"]." | ".$msg["parperso_input_type"]." | ".$msg["parperso_data_type"]." | "; if($this->option_visibilite["multiple"] == "block") $res.= "".((strpos($this->prefix,"gestfic")!==false) ? $msg["parperso_fiche_visibility"] : $msg["parperso_opac_visibility"])." | " ; if($this->option_visibilite["opac_sort"] == "block") $res.= "".$msg["parperso_opac_sort"]." | " ; if($this->option_visibilite["obligatoire"] == "block") $res.= "".$msg["parperso_mandatory"]." | " ; if($this->option_visibilite["search"] == "block") $res.= "".$msg["parperso_field_search_tableau"]." | " ; if($this->option_visibilite["export"] == "block") $res.= "".$msg["parperso_exportable"]." | " ; if($this->option_visibilite["exclusion"] == "block") $res.= "".$msg["parperso_exclusion_entete"]." | |
---|---|---|---|---|---|---|---|---|---|---|
"; $res.=""; $res.=" | "; $res.="".$r->name." | ".$r->titre." | ".$type_list_empr[$r->type]." | ".$datatype_list[$r->datatype]." | "; if($this->option_visibilite["multiple"] == "block") { $res.=""; if ($r->multiple==1) $res.=$msg["40"]; else $res.=$msg["39"]; $res.=" | "; } if($this->option_visibilite["opac_sort"] == "block") { $res.=""; if ($r->opac_sort==1) $res.=$msg["40"]; else $res.=$msg["39"]; $res.=" | "; } if($this->option_visibilite["obligatoire"] == "block") { $res.=""; if ($r->obligatoire==1) $res.=$msg["40"]; else $res.=$msg["39"]; $res.=" | "; } if($this->option_visibilite["search"] == "block") { $res.=""; if ($r->search==1) $res.=$msg["40"]; else $res.=$msg["39"]; $res.=" | "; } if($this->option_visibilite["export"] == "block") { $res.=""; if ($r->export==1) $res.=$msg["40"]; else $res.=$msg["39"]; $res.=" | "; } if($this->option_visibilite["exclusion"] == "block"){ $res.=""; if ($r->exclusion_obligatoire==1) $res.=$msg["40"]; else $res.=$msg["39"]; $res.=" | "; } $res.="