user_input = stripslashes($user_input); } else { $this->user_input = ''; } parent::__construct($id); } protected function get_display_label_column($label='', $infobulle='') { global $charset; // htmlentities($label, ENT_QUOTES, $charset) $display = " get_edit_link($this->authority->get_num_object())."&user_input=".rawurlencode($this->user_input)."&nbr_lignes=".$this->nbr_lignes."&page=".$this->page."';\" title='".$infobulle."'> ".$this->authority->get_display_statut_class_html().$label." "; return $display; } protected function get_display_line($authority_id=0) { global $msg; $display = ''; // On va chercher les infos spécifique à l'autorité $this->authority = new authority($authority_id); if ($this->parity % 2) { $pair_impair = "even"; } else { $pair_impair = "odd"; } $this->parity += 1; if(static::class == 'entities_categories_controller') { $notice_count = $this->get_query_notice_count(); } else { $notice_count_sql = $this->get_query_notice_count(); $notice_count = pmb_mysql_result(pmb_mysql_query($notice_count_sql), 0, 0); } $tr_javascript=" onmouseover=\"this.className='surbrillance'\" onmouseout=\"this.className='$pair_impair'\" "; $display.= ""; $display.= " "; $display .= $this->get_display_columns(); if($notice_count) { $display .= "get_search_mode()."&etat=aut_search&aut_type=".$this->get_aut_type()."&aut_id=".$this->authority->get_num_object()."'\">".$notice_count.""; } else { $display .= " "; } $display.= ''.$this->authority->get_caddie().''; $display .= ""; return $display; } protected function search_form() { $model_class_name = $this->get_model_class_name(); $model_class_name::search_form(); } protected function get_pagination_link() { global $authority_statut; return $this->url_base."&sub=reach&user_input=".rawurlencode($this->user_input).'&authority_statut='.$authority_statut; } public function get_display_list() { global $page, $nb_per_page_gestion, $categ; global $last_param; $display = ''; if(!$this->user_input) $this->user_input = '*'; $this->search_form(); $this->searcher_instance = $this->get_searcher_instance(); $this->nbr_lignes = $this->searcher_instance->get_nb_results(); if(!$page) { $page=1; $this->page = $page; } else { $this->page = (int) $page; } $debut =($this->page-1)*$nb_per_page_gestion; if($this->nbr_lignes) { $display .= $this->get_display_header_list(); $this->parity=1; $sorted_objects = $this->searcher_instance->get_sorted_result('default', $debut, $nb_per_page_gestion); $this->set_session_history($this->searcher_instance->get_human_query(), $categ, 'QUERY', 'classic'); $this->set_session_history($this->searcher_instance->get_human_query(), $categ, 'AUT', 'classic'); if (is_array($sorted_objects)) { foreach ($sorted_objects as $authority_id) { $display .= $this->get_display_line($authority_id); } // fin while } if (!$last_param) $nav_bar = aff_pagination ($this->get_pagination_link(), $this->nbr_lignes, $nb_per_page_gestion, $this->page, 10, false, true) ; else $nav_bar=""; // affichage du résultat print $this->searcher_instance->get_results_list_from_search($this->get_results_title(), $this->user_input, $display, $nav_bar); } else { // la requête n'a produit aucun résultat $this->display_no_results(); } } public function proceed() { global $sub; global $force_unlock; global $PMBuserid, $save_and_continue; //parade pour la facto $formatted_sub = $sub; if($sub) { $exploded_sub = explode('_', $sub); if(isset($exploded_sub[1])) { if($exploded_sub[1] == 'form') $formatted_sub = 'form'; if($exploded_sub[1] == 'last') $formatted_sub = 'last'; } } switch($formatted_sub) { case 'reach': print $this->get_display_list(); break; case 'delete': $entity_locking = new entity_locking($this->id, $this->get_aut_const()); if($entity_locking->is_locked()){ print $entity_locking->get_locked_form(); break; } $this->proceed_delete(); break; case 'replace': $entity_locking = new entity_locking($this->id, $this->get_aut_const()); if($entity_locking->is_locked()){ print $entity_locking->get_locked_form(); break; } $this->proceed_replace(); break; case 'duplicate' : $this->proceed_duplicate(); break; case 'update': $entity_locking = new entity_locking($this->id, $this->get_aut_const()); if ($this->id && $entity_locking->is_locked()) { if($PMBuserid == $entity_locking->get_locked_user_id()){ $updated_id = $this->proceed_update(); $entity_locking->unlock_entity(); }else{ print $entity_locking->get_save_error_message(); break; } } else{ $updated_id = $this->proceed_update(); } if($updated_id) { if ($save_and_continue) { $this->id = 0; $this->proceed_form(); } else { print $this->get_display_view($updated_id); } } break; case 'form': if($this->id){ $entity_locking = new entity_locking($this->id, $this->get_aut_const()); if($entity_locking->is_locked()){ print $entity_locking->get_locked_form(); break; } } $this->proceed_form(); break; case 'last': $this->proceed_last(); break; case 'unlock': $entity_locking = new entity_locking($this->id, $this->get_aut_const()); $entity_locking->unlock_entity(); break; default: $this->proceed_default(); break; } } public function proceed_delete() { global $msg; $object_instance = $this->get_object_instance(); $sup_result = $object_instance->delete(); if(!$sup_result) { print $this->get_display_list(); }else { error_message($msg[132], $sup_result, 1, $this->get_edit_link()); } } public function proceed_replace() { global $msg; global $by, $aut_link_save; $object_instance = $this->get_object_instance(); if(!$by) { $object_instance->replace_form(); }else { // routine de remplacement $rep_result = $object_instance->replace($by,$aut_link_save); if(!$rep_result) { print $this->get_display_list(); }else { error_message($msg[132], $rep_result, 1, $this->get_edit_link()); } } } public function proceed_duplicate() { $object_instance = $this->get_object_instance(); $id = 0; $object_instance->show_form(true); } public function proceed_update() { } public function proceed_form() { global $cataloging_scheme_id, $id; $unlock_unload_script = ""; if($this->id){ $entity_locking = new entity_locking($id, $this->get_type_const()); $entity_locking->lock_entity(); $unlock_unload_script = $entity_locking->get_polling_script(); } $object_instance = $this->get_object_instance(); ob_start(); $object_instance->show_form(); $entity_form = ob_get_contents(); ob_end_clean(); $entity_form = str_replace('get_cataloging_scheme_link_script($this->get_model_class_name()); } print $entity_form; print $this->get_selector_js_script(); print $unlock_unload_script; } public function proceed_last() { global $last_param; global $tri_param, $limit_param; global $pmb_nb_lastautorities; global $clef, $nbr_lignes; $last_param=1; $tri_param = $this->get_last_order(); $limit_param = 'limit 0, '.$pmb_nb_lastautorities; $clef = ''; $nbr_lignes = 0 ; print $this->get_display_list(); } public function proceed_default() { global $pmb_allow_authorities_first_page; if(!$pmb_allow_authorities_first_page && (!isset($this->user_input) || $this->user_input == '')){ $this->search_form(); }else { // affichage du début de la liste print $this->get_display_list(); } } public function get_display_view($id=0) { print ""; } /** * Fourni le javascript permettant d'instancier le systeme d'onglet */ protected function get_selector_js_script(){ return ""; } public static function get_caddie_link() { global $msg, $categ, $user_input; //Pas de lien vers le panier si pas de recherche if (!isset($user_input) || $user_input==='') { return ''; } return "\"".$msg["histo_add_to_cart"]."\""; } /** * Retourne le template pour appliquer un tri * @param int|string $nb_results nombre de résultat de la recherce * @param string $entity_type type de l'entité * @param boolean $popup utilisation d'une popup * @return string */ public static function get_sort_link($nb_results, $entity_type, $popup = false) { global $pmb_nb_max_tri, $msg; global $affich_authorities_tris_result_liste, $affich_authorities_popup_tris_result_liste; $display_icons = ""; if ($nb_results <= $pmb_nb_max_tri) { $sort_index = "tri_".$entity_type; if ($popup) { $display_icons .= $affich_authorities_popup_tris_result_liste; } else { $display_icons .= $affich_authorities_tris_result_liste; } $display_icons = str_replace('!!entity_type!!', $entity_type, $display_icons); if (!empty($_SESSION[$sort_index])) { $sort = new sort($entity_type,"base"); $display_icons .= $msg['tri_par']." ".$sort->descriptionTriParId($_SESSION[$sort_index]); } } return $display_icons; } /** * * @param string $human_query * @param string $categ * @param string $type * @param string $search_type */ protected function set_session_history($human_query, $categ, $type, $search_type = "extended") { global $page, $msg, $id_authperso; if(!isset($_SESSION["session_history"])) $_SESSION["session_history"] = array(); switch ($type) { case 'QUERY' : $_SESSION["CURRENT"]=count($_SESSION["session_history"]); $_SESSION["session_history"][$_SESSION["CURRENT"]][$type]["URI"] = './'.$this->url_base; $_SESSION["session_history"][$_SESSION["CURRENT"]][$type]["POST"] = $_POST; $_SESSION["session_history"][$_SESSION["CURRENT"]][$type]["GET"] = $_GET; $_SESSION["session_history"][$_SESSION["CURRENT"]][$type]["GET"]["sub"] = ""; $_SESSION["session_history"][$_SESSION["CURRENT"]][$type]["POST"]["sub"] = ""; $_SESSION["session_history"][$_SESSION["CURRENT"]][$type]["HUMAN_QUERY"] = $human_query; $_SESSION["session_history"][$_SESSION["CURRENT"]][$type]["HUMAN_TITLE"] = "[".$msg["132"]."] ".$this->get_msg_from_categ($categ, (isset($id_authperso) ? $id_authperso : 0)); break; case 'AUT' : if ($_SESSION["CURRENT"] !== false) { $_SESSION["session_history"][$_SESSION["CURRENT"]][$type]["URI"] = './'.$this->url_base; $_SESSION["session_history"][$_SESSION["CURRENT"]][$type]["PAGE"] = $page; $_SESSION["session_history"][$_SESSION["CURRENT"]][$type]["POST"] = $_POST; $_SESSION["session_history"][$_SESSION["CURRENT"]][$type]["GET"] = $_GET; $_SESSION["session_history"][$_SESSION["CURRENT"]][$type]["HUMAN_QUERY"] = $human_query; $_SESSION["session_history"][$_SESSION["CURRENT"]][$type]["SEARCH_TYPE"] = $search_type; $_SESSION["session_history"][$_SESSION["CURRENT"]][$type]["SEARCH_OBJECTS_TYPE"] = $this->get_type_from_categ($categ); $_SESSION["session_history"][$_SESSION["CURRENT"]][$type]["HUMAN_TITLE"] = "[".$msg["132"]."] ".$this->get_msg_from_categ($categ, (isset($id_authperso) ? $id_authperso : 0)); $_SESSION["session_history"][$_SESSION["CURRENT"]][$type]['TEXT_LIST_QUERY']=''; $_SESSION["session_history"][$_SESSION["CURRENT"]][$type]["TEXT_QUERY"] = ""; } break; } } public function get_msg_from_categ($categ, $id_authperso = 0) { global $msg, $search; switch ($categ) { case 'auteurs' : return $msg['133']; case 'categories' : return $msg['134']; case 'editeurs' : return $msg['135']; case 'collections' : return $msg['136']; case 'souscollections' : return $msg['137']; case 'series' : return $msg['333']; case 'titres_uniformes' : return $msg['aut_menu_titre_uniforme']; case 'indexint' : return $msg['indexint_menu']; case 'concepts' : return $msg['ontology_skos_menu']; case 'authperso' : return authpersos::get_name($id_authperso); } return ''; } public static function get_type_from_categ($categ) { $type = "MIXED"; switch ($categ) { case 'auteurs' : $type = "AUTHORS"; break; case 'categories' : $type = "CATEGORIES"; break; case 'editeurs' : $type = "PUBLISHERS"; break; case 'collections' : $type = "COLLECTIONS"; break; case 'souscollections' : $type = "SUBCOLLECTIONS"; break; case 'series' : $type = "SERIES"; break; case 'titres_uniformes' : $type = "TITRES_UNIFORMES"; break; case 'indexint' : $type = "INDEXINT"; break; case 'concepts' : $type = "CONCEPTS"; break; case 'authperso' : $type = "AUTHPERSO"; break; } return $type; } //A dériver dans les enfants protected function get_aut_const(){ return ''; } public function get_type_const() { switch($this->get_model_class_name()) { case 'auteur': return TYPE_AUTHOR; case 'collection': return TYPE_COLLECTION; case 'authperso': return TYPE_AUTHPERSO; case 'category': return TYPE_CATEGORY; case 'indexint': return TYPE_INDEXINT; case 'concept': return TYPE_CONCEPT; case 'editeur': return TYPE_PUBLISHER; case 'serie': return TYPE_SERIE; case 'subcollection': return TYPE_SUBCOLLECTION; case 'titre_uniforme': return TYPE_TITRE_UNIFORME; } } }