$('{$this->input->id}edit').addClassName('inplace_edit_input');
{$this->input->id}edit.onclick=null;
inplace_edit_ok{$this->input->id}.onclick= function () {
var json={$this->json};
json['ieaction']='ok';
json['value']=$('{$this->input->id}').value;
new Ajax.Updater('{$this->input->id}edit'
,'{$this->callback}',
{parameters: json ,evalScripts:true});}
inplace_edit_cancel{$this->input->id}.onclick= function () {
var json={$this->json};
json['ieaction']='cancel';
new Ajax.Updater('{$this->input->id}edit'
,'{$this->callback}',
{parameters: json ,evalScripts:true});}
EOF;
$ret= ob_get_contents();
ob_end_clean();
return $ret;
}
/**
* @brief display only the value , if the action after saving or cancelling
*
*/
function value()
{
$v=$this->input->get_value();
$v=html_entity_decode($v??"");
if ( $this->input instanceof ITextarea) {
echo '';
$v=(trim($v)=="")?$this->message:$v;
echo $v;
echo '';
echo'Cliquer pour changer ';
} else {
$v=(trim($v)=="")?$this->message:$v;
echo $v,
' ';
}
echo "
";
}
/***
* @brief display the value with the click event
*/
function input() {
ob_start();
$v=$this->input->get_value();
$v=html_entity_decode($v??"");
if ( $this->input instanceof ITextarea) {
echo '';
echo '';
$v=(trim($v)=="")?$this->message:$v;
echo $v;
echo '';
echo'Cliquer pour changer ';
} else {
$v=(trim($v)=="")?$this->message:$v;
echo <<
EOF;
echo $v;
echo' ';
}
echo "";
echo "
";
$ret= ob_get_contents();
ob_end_clean();
return $ret;
}
/**
* @brief the php callback file to call for ajax
*/
function set_callback($callback) {
$this->callback=$callback;
}
/***
* @brief the JSON parameter to give to the script,
* this function shouldn't be used since it override the default JSON value
* @see add_json_parameter
*/
function set_json($json) {
$this->json=$json;
}
/**
* Add json parameter to the current one, if there attribute already exists
* it will be overwritten
*/
function add_json_param($p_attribute,$p_value) {
$x=json_decode($this->json,TRUE);
$x[$p_attribute]=$p_value;
$this->json=json_encode($x, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP |JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES|JSON_NUMERIC_CHECK);
}
/**
* \brief return the HtmlObject , var input
*
*/
function get_input() {
return $this->input;
}
/**
* @brief set the var input (HtmlObject) and update the
* json attribute input
* @param HtmlInput $p_input
*/
function set_input(HtmlInput $p_input) {
$this->input = $p_input;
$x=json_decode($this->json,TRUE);
$x["input"]=base64_encode(serialize($p_input));
$this->json=json_encode($x, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP |JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES|JSON_NUMERIC_CHECK);
}
/**
* Set the value of the HtmlInput object $input
* @param type $p_value
*/
function set_value($p_value) {
$input=$this->get_input();
$this->input->set_value($p_value);
$this->set_input($input);
}
/**
* Message to display if the value is empty
* @param string $p_str
*/
function set_message($p_str) {
$this->message=$p_str;
}
}