/** * * * @param property property la propriété concernée * @param onto_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_validation_js($item_uri, $property, $restrictions, $datas, $instance_name, $flag) { global $msg; return '{ "message": "' . addslashes($property->label) . '", "valid" : true, "nb_values": 0, "error": "", "values": new Array(), "check": function(){ this.values = new Array(); this.nb_values = 0; this.valid = true; var order = document.getElementById("' . $instance_name . '_' . $property->pmb_name . '_new_order").value; for (var i=0; i<=order ; i++){ var label = document.getElementById("' . $instance_name . '_' . $property->pmb_name . '_"+i+"_value"); var lang = document.getElementById("' . $instance_name . '_' . $property->pmb_name . '_"+i+"_lang"); if(label.value != ""){ if(!this.values[lang.value]){ this.values[lang.value] = 0; } this.values[lang.value]++; if(this.nb_values < this.values[lang.value]) { this.nb_values = this.values[lang.value]; } } } if(this.nb_values < ' . $restrictions->get_min() . '){ this.valid = false; this.error = "min"; } if(this.nb_values > ' . $restrictions->get_max() . '){ this.valid = false; this.error = "max"; } return this.valid; }, "get_error_message": function(){ switch(this.error){ case "min" : this.message = "' . addslashes($msg['onto_error_no_minima']) . '"; break; case "max" : this.message = "' . addslashes($msg['onto_error_too_much_values']) . '"; break; } this.message = this.message.replace("%s","' . addslashes($property->label) . '"); return this.message; } }'; }