public static function get_form($item_uri, $property, $restrictions, $datas, $instance_name, $flag) { global $msg, $charset, $ontology_tpl, $lang, $composed; $object_id = onto_common_uri::get_id($item_uri); if ($object_id) { $vedette_id = vedette_link::get_vedette_id_from_object($object_id, TYPE_CONCEPT_PREFLABEL); } else { $vedette_id = 0; } $vedette_ui = new vedette_ui($vedette_id); $form = $ontology_tpl['skos_concept_card_ui_wrapper']; // Si on a une vedette composée, on ne veut pas de valeur dans les champs classiques if ($composed == 'composed' || $vedette_id) { $datas = array(); } $form = str_replace("!!skos_concept_card_ui_parent_form!!", parent::get_form($item_uri, $property, $restrictions, $datas, $instance_name, $flag), $form); $form = str_replace("!!skos_concept_card_ui_derived_form!!", $vedette_ui->get_form($property, 0, $instance_name), $form); $form = str_replace("!!onto_row_label!!", htmlentities($property->label, ENT_QUOTES, $charset), $form); $form = str_replace("!!instance_name!!", htmlentities($instance_name, ENT_QUOTES, $charset), $form); $form = str_replace("!!property_name!!", htmlentities($property->pmb_name, ENT_QUOTES, $charset), $form); if ($composed == 'composed' || $vedette_id) { $form = str_replace("!!skos_concept_card_ui_btn_value!!", $msg['skos_concept_card_ui_btn_parent'], $form); $form = str_replace("!!skos_concept_card_ui_parent_visible!!", "style='display:none'", $form); $form = str_replace("!!skos_concept_card_ui_derived_visible!!", "", $form); $form = str_replace("!!is_composed!!", "composed", $form); } else { $form = str_replace("!!skos_concept_card_ui_btn_value!!", $msg['skos_concept_card_ui_btn_derived'], $form); $form = str_replace("!!skos_concept_card_ui_parent_visible!!", "", $form); $form = str_replace("!!skos_concept_card_ui_derived_visible!!", "style='display:none'", $form); $form = str_replace("!!is_composed!!", "", $form); } return $form; }
public static function get_values_from_form($instance_name, $property, $uri_item) { $datatypes = array(); $var_name = $instance_name . "_" . $property->pmb_name; global ${$var_name}; if (${$var_name} && count(${$var_name})) { global ${$var_name . "_is_composed"}; if (!${$var_name . "_is_composed"}) { // Ce n'est pas une vedette composée //On va supprimer une éventuelle vedette précédente global ${$var_name . "_composed"}; foreach (${$var_name . "_composed"} as $order => $data) { if ($data["id"]) { $vedette_composee = new vedette_composee($data["id"]); $vedette_composee->delete(); } } // On va chercher les valeurs actuelles foreach (${$var_name} as $order => $data) { $data = stripslashes_array($data); if ($data["value"]) { $data_properties = array(); if ($data["lang"]) { $data_properties["lang"] = $data["lang"]; } if ($data["type"] == "http://www.w3.org/2000/01/rdf-schema#Literal") { $data_properties["type"] = "literal"; } else { $data_properties["type"] = "uri"; } if ($data["display_label"]) { $data_properties["display_label"] = $data["display_label"]; } $class_name = get_called_class(); $datatypes[$property->uri][] = new $class_name($data["value"], $data["type"], $data_properties); } } } else { // C'est une vedette composée global ${$var_name . "_composed"}; foreach (${$var_name . "_composed"} as $order => $data) { $data = stripslashes_array($data); if ($data["elements"]) { $vedette_composee = new vedette_composee($data["id"]); if ($data["value"]) { $vedette_composee->set_label($data["value"]); } // On commence par réinitialiser le tableau des éléments de la vedette composée $vedette_composee->reset_elements(); // On remplit le tableau des éléments de la vedette composée foreach ($data["elements"] as $subdivision => $elements) { if ($elements["elements_order"] !== "") { $elements_order = explode(",", $elements["elements_order"]); foreach ($elements_order as $position => $num_element) { if ($elements[$num_element]["id"] && $elements[$num_element]["label"]) { $velement = $elements[$num_element]["type"]; $available_field_class_name = $vedette_composee->get_at_available_field_class_name($velement); if ($available_field_class_name['params']) { $vedette_element = new $velement($available_field_class_name['params'], $available_field_class_name["num"], $elements[$num_element]["id"], $elements[$num_element]["label"]); } else { $vedette_element = new $velement($available_field_class_name["num"], $elements[$num_element]["id"], $elements[$num_element]["label"]); } $vedette_composee->add_element($vedette_element, $subdivision, $position); } } } } $vedette_composee_id = $vedette_composee->save(); } if ($vedette_composee_id) { vedette_link::save_vedette_link($vedette_composee, onto_common_uri::get_id($uri_item), TYPE_CONCEPT_PREFLABEL); if ($data["value"]) { $data_properties = array(); if ($data["type"] == "http://www.w3.org/2000/01/rdf-schema#Literal") { $data_properties["type"] = "literal"; } else { $data_properties["type"] = "uri"; } $class_name = get_called_class(); $datatypes[$property->uri][] = new $class_name($data["value"], $data["type"], $data_properties); } } } } } return $datatypes; }
function update_vedette($data, $id, $type) { if ($data["elements"]) { $vedette_composee = new vedette_composee($data["id"], 'tu_authors'); if ($data["value"]) { $vedette_composee->set_label($data["value"]); } // On commence par réinitialiser le tableau des éléments de la vedette composée $vedette_composee->reset_elements(); // On remplit le tableau des éléments de la vedette composée $vedette_composee_id = 0; $tosave = false; foreach ($data["elements"] as $subdivision => $elements) { if ($elements["elements_order"] !== "") { $elements_order = explode(",", $elements["elements_order"]); foreach ($elements_order as $position => $num_element) { if ($elements[$num_element]["id"] && $elements[$num_element]["label"]) { $tosave = true; $velement = $elements[$num_element]["type"]; if (strpos($velement, "vedette_ontologies") === 0) { $velement = "vedette_ontologies"; } $available_field_class_name = $vedette_composee->get_at_available_field_class_name($velement); if ($available_field_class_name['params']) { $vedette_element = new $velement($available_field_class_name['params'], $available_field_class_name["num"], $elements[$num_element]["id"], $elements[$num_element]["label"]); } else { $vedette_element = new $velement($available_field_class_name["num"], $elements[$num_element]["id"], $elements[$num_element]["label"]); } $vedette_composee->add_element($vedette_element, $subdivision, $position); } } } } if ($tosave) { $vedette_composee_id = $vedette_composee->save(); } } if ($vedette_composee_id) { vedette_link::save_vedette_link($vedette_composee, $id, $type); } }
static function delete_vedette_links($id) { global $dbh; $rqt_responsability = 'select id_responsability, responsability_type from responsability where responsability_notice="' . $id . '" '; $res_responsability = pmb_mysql_query($rqt_responsability, $dbh); if (pmb_mysql_num_rows($res_responsability)) { while ($r = pmb_mysql_fetch_object($res_responsability)) { $object_id = $r->id_responsability; $type_aut = $r->responsability_type; switch ($type_aut) { case 0: vedette_link::delete_vedette_link_from_object(new vedette_composee(0, 'analysis_authors'), $object_id, TYPE_NOTICE_RESPONSABILITY_PRINCIPAL); break; case 1: vedette_link::delete_vedette_link_from_object(new vedette_composee(0, 'analysis_authors'), $object_id, TYPE_NOTICE_RESPONSABILITY_AUTRE); break; case 2: vedette_link::delete_vedette_link_from_object(new vedette_composee(0, 'analysis_authors'), $object_id, TYPE_NOTICE_RESPONSABILITY_SECONDAIRE); break; } } } }
/** * Retourne la vedette composée associée au concept * @return vedette_composee */ public function get_vedette() { if (!$this->vedette) { if ($vedette_id = vedette_link::get_vedette_id_from_object($this->id, TYPE_CONCEPT_PREFLABEL)) { $this->vedette = new vedette_composee($vedette_id); } } return $this->vedette; }
/** * Met à jour les vedettes contenant l'élément * @param int $element_id Identifiant en base de l'élément * @param string $element_type Type de l'élément */ public static function update_vedettes_built_with_element($element_id, $element_type) { global $dbh; $vedettes_id = self::get_vedettes_built_with_element($element_id, $element_type); foreach ($vedettes_id as $vedette_id) { $vedette = new vedette_composee($vedette_id); $vedette->update_label(); $query = "update vedette set label = '" . $vedette->get_label() . "' where id_vedette = " . $vedette->get_id(); pmb_mysql_query($query, $dbh); vedette_link::update_objects_linked_with_vedette($vedette); } }
protected function proceed_delete($force_delete = false) { global $dbh, $msg; // On déclare un flag pour savoir si on peut continuer la suppression $deletion_allowed = true; $message = $this->item->get_label($this->handler->get_display_label($this->handler->get_class_uri($this->params->categ))); // on déjà vérifier l'utilisation dans les notices d'un concept $query = "select num_object from index_concept where type_object =1 and num_concept = " . onto_common_uri::get_id($this->item->get_uri()); $result = pmb_mysql_query($query, $dbh); if (pmb_mysql_num_rows($result)) { $deletion_allowed = false; $message .= "<br/>" . $msg['concept_use_in_notices_cant_delete']; } // On regarde si l'autorité est utilisée dans des vedettes composées $attached_vedettes = vedette_composee::get_vedettes_built_with_element(onto_common_uri::get_id($this->item->get_uri()), "concept"); if (count($attached_vedettes)) { // Cette autorité est utilisée dans des vedettes composées, impossible de la supprimer $deletion_allowed = false; $message .= "<br/>" . $msg['vedette_dont_del_autority']; } if ($deletion_allowed) { // On peut continuer la suppression $id_vedette = vedette_link::get_vedette_id_from_object(onto_common_uri::get_id($this->item->get_uri()), TYPE_CONCEPT_PREFLABEL); $vedette = new vedette_composee($id_vedette); $vedette->delete(); //suppression des autorités liées... // liens entre autorités if (get_class($this->item) == "onto_skos_concept_item") { $aut_link = new aut_link(AUT_TABLE_CONCEPT, onto_common_uri::get_id($this->item->get_uri())); $aut_link->delete(); } parent::proceed_delete($force_delete); } else { error_message($msg[132], $message, 1, "./autorites.php?categ=concepts&sub=concept&action=edit&id=" . onto_common_uri::get_id($this->item->get_uri())); } }