/**
  * 
  *
  * @param property property la propriété concernée
  * @param restriction $restrictions le tableau des restrictions associées à la propriété 
  * @param array datas le tableau des datatypes
  * @param string instance_name nom de l'instance
  * @param string flag Flag
  * @return string
  * @static
  * @access public
  */
 public static function get_form($item_uri, $property, $restrictions, $datas, $instance_name, $flag)
 {
     global $msg, $charset, $ontology_tpl;
     $form = $ontology_tpl['form_row'];
     $form = str_replace("!!onto_row_label!!", htmlentities($property->label, ENT_QUOTES, $charset), $form);
     $content = '';
     if (sizeof($datas)) {
         $i = 1;
         $first = true;
         $new_element_order = max(array_keys($datas));
         $form = str_replace("!!onto_new_order!!", $new_element_order, $form);
         foreach ($datas as $key => $data) {
             $row = $ontology_tpl['form_row_content'];
             if ($data->get_order()) {
                 $order = $data->get_order();
             } else {
                 $order = $key;
             }
             $inside_row = $ontology_tpl['form_row_content_small_text'];
             $inside_row = str_replace("!!onto_row_content_small_text_value!!", htmlentities($data->get_formated_value(), ENT_QUOTES, $charset), $inside_row);
             $inside_row = str_replace("!!onto_row_combobox_lang!!", self::get_combobox_lang($instance_name . '_' . $property->pmb_name . '[' . $order . '][lang]', $instance_name . '_' . $property->pmb_name . '_' . $order . '_lang', $data->get_lang()), $inside_row);
             $inside_row = str_replace("!!onto_row_content_small_text_range!!", $property->range[0], $inside_row);
             $row = str_replace("!!onto_inside_row!!", $inside_row, $row);
             $input = '';
             if ($first) {
                 if ($restrictions->get_max() < $i || $restrictions->get_max() === -1) {
                     $input = $ontology_tpl['form_row_content_input_add'];
                 }
             } else {
                 $input = $ontology_tpl['form_row_content_input_del'];
             }
             $row = str_replace("!!onto_row_inputs!!", $input, $row);
             $row = str_replace("!!onto_row_order!!", $order, $row);
             $content .= $row;
             $first = false;
             $i++;
         }
     } else {
         $form = str_replace("!!onto_new_order!!", "0", $form);
         $row = $ontology_tpl['form_row_content'];
         $inside_row = $ontology_tpl['form_row_content_small_text'];
         $inside_row = str_replace("!!onto_row_content_small_text_value!!", "", $inside_row);
         $inside_row = str_replace("!!onto_row_combobox_lang!!", self::get_combobox_lang($instance_name . '_' . $property->pmb_name . '[0][lang]', $instance_name . '_' . $property->pmb_name . '_0_lang'), $inside_row);
         $inside_row = str_replace("!!onto_row_content_small_text_range!!", $property->range[0], $inside_row);
         $row = str_replace("!!onto_inside_row!!", $inside_row, $row);
         $input = '';
         if ($restrictions->get_max() != 1) {
             $input = $ontology_tpl['form_row_content_input_add'];
         }
         $row = str_replace("!!onto_row_inputs!!", $input, $row);
         $row = str_replace("!!onto_row_order!!", "0", $row);
         $content .= $row;
     }
     $form = str_replace("!!onto_rows!!", $content, $form);
     $form = str_replace("!!onto_row_id!!", $instance_name . '_' . $property->pmb_name, $form);
     return $form;
 }
コード例 #2
0
 /**
  * 
  *
  * @param onto_common_property $property la propriété concernée
  * @param restriction $restrictions le tableau des restrictions associées à la propriété 
  * @param array datas le tableau des datatypes
  * @param string instance_name nom de l'instance
  * @param string flag Flag
  * @return string
  * @static
  * @access public
  */
 public static function get_form($item_uri, $property, $restrictions, $datas, $instance_name, $flag)
 {
     global $msg, $charset, $ontology_tpl;
     $form = $ontology_tpl['form_row'];
     $form = str_replace("!!onto_row_label!!", htmlentities($property->label, ENT_QUOTES, $charset), $form);
     $range_for_form = "";
     foreach ($property->range as $range) {
         if ($range_for_form) {
             $range_for_form .= "|||";
         }
         $range_for_form .= $range;
     }
     $content = '';
     $content .= $ontology_tpl['form_row_content_input_sel'];
     if ($restrictions->get_max() < $i || $restrictions->get_max() === -1) {
         $content .= $ontology_tpl['form_row_content_input_add_ressource_selector'];
     }
     $content = str_replace("!!property_name!!", rawurlencode($property->pmb_name), $content);
     if (sizeof($datas)) {
         $i = 1;
         $first = true;
         $new_element_order = max(array_keys($datas));
         $form = str_replace("!!onto_new_order!!", $new_element_order, $form);
         foreach ($datas as $key => $data) {
             $row = $ontology_tpl['form_row_content'];
             if ($data->get_order()) {
                 $order = $data->get_order();
             } else {
                 $order = $key;
             }
             $inside_row = $ontology_tpl['form_row_content_resource_selector'];
             $inside_row = str_replace("!!form_row_content_resource_selector_display_label!!", htmlentities($data->get_formated_value(), ENT_QUOTES, $charset), $inside_row);
             $inside_row = str_replace("!!form_row_content_resource_selector_value!!", $data->get_raw_value(), $inside_row);
             $inside_row = str_replace("!!form_row_content_resource_selector_range!!", $data->get_value_type(), $inside_row);
             $inside_row = str_replace("!!onto_current_element!!", onto_common_uri::get_id($item_uri), $inside_row);
             $inside_row = str_replace("!!onto_current_range!!", $range_for_form, $inside_row);
             $row = str_replace("!!onto_inside_row!!", $inside_row, $row);
             $input = '';
             if ($first) {
                 $input .= $ontology_tpl['form_row_content_input_remove'];
             } else {
                 $input .= $ontology_tpl['form_row_content_input_del'];
             }
             $input = str_replace("!!property_name!!", rawurlencode($property->pmb_name), $input);
             $row = str_replace("!!onto_row_inputs!!", $input, $row);
             $row = str_replace("!!onto_row_order!!", $order, $row);
             $content .= $row;
             $first = false;
             $i++;
         }
     } else {
         $form = str_replace("!!onto_new_order!!", "0", $form);
         $row = $ontology_tpl['form_row_content'];
         $inside_row = $ontology_tpl['form_row_content_resource_selector'];
         $inside_row = str_replace("!!form_row_content_resource_selector_display_label!!", "", $inside_row);
         $inside_row = str_replace("!!form_row_content_resource_selector_display_label!!", "", $inside_row);
         $inside_row = str_replace("!!form_row_content_resource_selector_value!!", "", $inside_row);
         $inside_row = str_replace("!!form_row_content_resource_selector_range!!", "", $inside_row);
         $inside_row = str_replace("!!onto_current_element!!", onto_common_uri::get_id($item_uri), $inside_row);
         $inside_row = str_replace("!!onto_current_range!!", $range_for_form, $inside_row);
         $row = str_replace("!!onto_inside_row!!", $inside_row, $row);
         $input = '';
         $input .= $ontology_tpl['form_row_content_input_remove'];
         $input = str_replace("!!property_name!!", rawurlencode($property->pmb_name), $input);
         $row = str_replace("!!onto_row_inputs!!", $input, $row);
         $row = str_replace("!!onto_row_order!!", "0", $row);
         $content .= $row;
     }
     $form = str_replace("!!onto_rows!!", $content, $form);
     $form = str_replace("!!onto_row_id!!", $instance_name . '_' . $property->pmb_name, $form);
     return $form;
 }