".$msg['noti_statut_libelle']." "; $i=0; foreach(static::$statuts as $id => $statut){ if ($i % 2) { $pair_impair = "even"; } else { $pair_impair = "odd"; } print " ".htmlentities($statut['label'], ENT_QUOTES, $charset)." "; $i++; } print "
"; } public static function get_list(){ global $dbh; if(!static::$statuts_fetched){ static::$statuts = array(); $query = "select id_authorities_statut, authorities_statut_label, authorities_statut_class_html, authorities_statut_available_for from authorities_statuts order by authorities_statut_label"; $result = pmb_mysql_query($query); if(pmb_mysql_num_rows($result)){ while($row = pmb_mysql_fetch_object($result)){ static::$statuts[$row->id_authorities_statut] = array( 'label' => $row->authorities_statut_label, 'class_html' => $row->authorities_statut_class_html, 'available_for' => unserialize($row->authorities_statut_available_for) ); if(!is_array(static::$statuts[$row->id_authorities_statut]['available_for'])){ static::$statuts[$row->id_authorities_statut]['available_for'] = array(); } } } static::$statuts_fetched = true; } } public static function show_form($id){ global $msg,$charset; global $admin_authorities_statut_form; static::get_list(); $id+=0; $form = $admin_authorities_statut_form; if(isset(static::$statuts[$id])){ $form_title = $msg['118']; $statut = static::$statuts[$id]; }else{ $form_title = $msg['115']; $statut = array( 'label' => "", 'class_html' => "statutnot1", 'available_for' => array() ); } $form = str_replace("!!form_title!!", $form_title, $form); for ($i=1;$i<=20; $i++) { if ($statut['class_html'] == "statutnot".$i){ $checked = "checked"; } else { $checked = ""; } $couleur[$i]=" "; if ($i==10) $couleur[10].="
"; elseif ($i!=20) $couleur[$i].="|"; } $couleurs=implode("",$couleur); $form = str_replace("!!class_html!!", $couleurs, $form); $form = str_replace("!!gestion_libelle!!", htmlentities($statut['label'],ENT_QUOTES,$charset),$form); if($id == 1 || !isset(static::$statuts[$id])){ $form = str_replace("!!bouton_supprimer!!","",$form); }else{ $form = str_replace("!!bouton_supprimer!!","",$form); ; } $authorities = static::get_authorities_list(); $i=0; $authorities_list = ''; foreach($authorities as $value => $name){ if($i!= 0 && $i % 5 == 0){ $authorities_list.= "
"; } $authorities_list.= " $name"; $i++; } $form = str_replace("!!list_authorities!!", $authorities_list, $form); $form.=confirmation_delete("./admin.php?categ=authorities&sub=statuts&action=del&id="); $form = str_replace('!!libelle_suppr!!', addslashes($statut['label']), $form); $form = str_replace("!!id!!",$id,$form); print $form; } public static function get_from_from(){ global $id,$form_gestion_libelle,$form_class_html, $form_available_for; if($id == 1) { $form_available_for = array_keys(self::get_authorities_list()); } return array( 'id' => stripslashes($id), 'label' => stripslashes($form_gestion_libelle), 'class_html' => stripslashes($form_class_html), 'available_for' => $form_available_for ); } public static function save($statut){ global $dbh; $statut['id'] += 0; if($statut['label'] != ""){ if($statut['id'] != 0){ $query = " update authorities_statuts set "; $where = "where id_authorities_statut = ".$statut['id']; }else{ $query = " insert into authorities_statuts set "; $where = ""; } $query.=" authorities_statut_label = '".addslashes($statut['label'])."', authorities_statut_class_html = '".addslashes($statut['class_html'])."', authorities_statut_available_for = '".addslashes(serialize($statut['available_for']))."' "; $result = pmb_mysql_query($query.$where,$dbh); if($result){ static::$statuts_fetched = false; }else{ return false; } } return true; } public static function delete($id) { global $dbh; $id+=0; if($id==1) return true; if(!count($used = static::check_used($id))){ $query = "delete from authorities_statuts where id_authorities_statut = ".$id; pmb_mysql_query($query,$dbh); return true; } return false; } public static function check_used($id){ global $dbh,$msg; global $base_path; $id+=0; $used = array(); $query = "select type_object, count(*) as used FROM authorities where num_statut = ".$id." group by type_object order by used desc"; $result = pmb_mysql_query($query,$dbh); if(pmb_mysql_num_rows($result)){ while($row = pmb_mysql_fetch_object($result)){ if($row->used != 0){ switch ($row->type_object){ case AUT_TABLE_AUTHORS: $categ='auteurs'; $name= $msg['133']; break; case AUT_TABLE_CATEG: $categ='categories'; $name= $msg['134']; break; case AUT_TABLE_PUBLISHERS: $categ='editeurs'; $name= $msg['135']; break; case AUT_TABLE_COLLECTIONS: $categ='collections'; $name= $msg['136']; break; case AUT_TABLE_SUB_COLLECTIONS: $categ='souscollections'; $name= $msg['137']; break; case AUT_TABLE_SERIES: $categ='series'; $name= $msg['333']; break; case AUT_TABLE_INDEXINT: $categ='indexint'; $name= $msg['indexint_menu']; break; case AUT_TABLE_TITRES_UNIFORMES: $categ='titres_uniformes'; $name= $msg['aut_menu_titre_uniforme']; break; case AUT_TABLE_CONCEPT: $categ='concepts'; $name= $msg['ontology_skos_menu']; break; default://Authperso $categ='authperso&id_authperso='.($row->type_object-1000); $name= $msg['authperso_multi_search_title']; break; } $used[]=array( 'type'=>$row->type_object, 'used'=>$row->used, 'categ'=>$categ, 'msg'=>$name, 'link'=>''.$name.'( '.$row->used.' )', ); } } } return $used; } private static function get_authorities_list(){ global $msg,$thesaurus_concepts_active,$pmb_use_uniform_title; $authorities = array( AUT_TABLE_AUTHORS => $msg['133'], AUT_TABLE_CATEG => $msg['134'], AUT_TABLE_PUBLISHERS => $msg['135'], AUT_TABLE_COLLECTIONS => $msg['136'], AUT_TABLE_SUB_COLLECTIONS => $msg['137'], AUT_TABLE_SERIES => $msg['333'] , AUT_TABLE_INDEXINT => $msg['indexint_menu'] ); if($pmb_use_uniform_title){ $authorities[AUT_TABLE_TITRES_UNIFORMES] = $msg['aut_menu_titre_uniforme']; } if($thesaurus_concepts_active){ $authorities[AUT_TABLE_CONCEPT] = $msg['ontology_skos_menu']; } $authpersos= authpersos::get_instance(); $info_authpersos=$authpersos->get_data(); foreach($info_authpersos as $authperso){ $authorities[($authperso['id']+1000)] = $authperso['name']; } return $authorities; } /** * Fonction permettant de générer le selecteur des statut définis pour un type d'autorité * @param integer $auth_type Constante type d'autorité (ou 1000+id authperso) * @param integer $auth_statut_id Identifiant du statut enregistré pour l'autorité courante * @param boolean $selector_search Sélécteur affiché dans la page de recherche * @return string */ public static function get_form_for($auth_type, $auth_statut_id, $search=false){ global $msg; $auth_statut_id+=0; $statuts_defined = static::get_statuts_for($auth_type); $on_change=''; $selector = ''; return $selector; } /** * Fonction retournant un tableau des statut défini pour le type d'autorité passé en parametre * @param integer $auth_type Type d'autorité * @return array $statuts_found Tableau des statuts disponible pour le type d'autorité passé en parametre */ private static function get_statuts_for($auth_type){ /** * TODO test sur auth_type pour les authorités perso */ static::get_list(); $statuts_found = array(); foreach(static::$statuts as $id_statut => $statut){ if(in_array($auth_type,$statut['available_for']) || ($id_statut==1)){ $statuts_found[$id_statut] = $statut; } //TODO: array merge authority perso } return $statuts_found; } }