From 06c5f3427cc676905b925be37642bff5aff32237 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 5 Nov 2011 21:24:55 +0100 Subject: [PATCH] New: There is now two "inline edit" solution: Solution 1 use jquery and is enabled if MAIN_USE_JQUERY_JEDITABLE is on. Solution 2 use a link "edit field" on resubmit page for eache field (this is by default). And we are ready to add more. New: Add also option MAIN_EDIT_ALSO_INLINE. Goal of this option is to say: Even if this field can be edited by a global edit form, we allow field to be edited with the "inline edit" feature (whatever is the inline edit solution active). This option is to keep the standard behaviour "We must click a "modify" button to allow to edit globally all fields at once working and have only this way. If option is on, we can also use the inlinde edit. If off, inline edit is available only for fields not included into a global "modify" form. line --- htdocs/compta/deplacement/fiche.php | 28 +++++++++++++++------------ htdocs/core/class/doleditor.class.php | 3 +++ htdocs/core/class/html.form.class.php | 19 ++++++++++++------ htdocs/fichinter/fiche.php | 12 ++++++------ 4 files changed, 38 insertions(+), 24 deletions(-) diff --git a/htdocs/compta/deplacement/fiche.php b/htdocs/compta/deplacement/fiche.php index 1243ac5eaba..8e2cdce109e 100644 --- a/htdocs/compta/deplacement/fiche.php +++ b/htdocs/compta/deplacement/fiche.php @@ -244,7 +244,9 @@ if ($action == 'create') print ''; print ''.$langs->trans('NotePublic').''; print ''; - print ''; + require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"); + $doleditor=new DolEditor('note_public',GETPOST('note_public'),600,200,'dolibarr_notes','In',false,true,true,ROWS_8,100); + print $doleditor->Create(1); print ''; // Private note @@ -253,7 +255,9 @@ if ($action == 'create') print ''; print ''.$langs->trans('NotePrivate').''; print ''; - print ''; + require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"); + $doleditor=new DolEditor('note_private',GETPOST('note_private'),600,200,'dolibarr_notes','In',false,true,true,ROWS_8,100); + print $doleditor->Create(1); print ''; } @@ -376,9 +380,9 @@ else if ($id) // Type print ''; - print $form->editfieldkey("Type",'type',$langs->trans($object->type),'id',$object->id,$user->rights->deplacement->creer,'select:type_fees'); + print $form->editfieldkey("Type",'type',$langs->trans($object->type),'id',$object->id,$conf->global->MAIN_EDIT_ALSO_INLINE && $user->rights->deplacement->creer,'select:type_fees'); print ''; - print $form->editfieldval("Type",'type',$langs->trans($object->type),'id',$object->id,$user->rights->deplacement->creer,'select:type_fees'); + print $form->editfieldval("Type",'type',$langs->trans($object->type),'id',$object->id,$conf->global->MAIN_EDIT_ALSO_INLINE && $user->rights->deplacement->creer,'select:type_fees'); print ''; // Who @@ -390,16 +394,16 @@ else if ($id) // Date print ''; - print $form->editfieldkey("Date",'dated',$object->date,'id',$object->id,$user->rights->deplacement->creer,'datepicker'); + print $form->editfieldkey("Date",'dated',$object->date,'id',$object->id,$conf->global->MAIN_EDIT_ALSO_INLINE && $user->rights->deplacement->creer,'datepicker'); print ''; - print $form->editfieldval("Date",'dated',$object->date,'id',$object->id,$user->rights->deplacement->creer,'datepicker'); + print $form->editfieldval("Date",'dated',$object->date,'id',$object->id,$conf->global->MAIN_EDIT_ALSO_INLINE && $user->rights->deplacement->creer,'datepicker'); print ''; // Km/Price print ''; - print $form->editfieldkey("FeesKilometersOrAmout",'km',$object->km,'id',$object->id,$user->rights->deplacement->creer,'numeric:6'); + print $form->editfieldkey("FeesKilometersOrAmout",'km',$object->km,'id',$object->id,$conf->global->MAIN_EDIT_ALSO_INLINE && $user->rights->deplacement->creer,'numeric:6'); print ''; - print $form->editfieldval("FeesKilometersOrAmout",'km',$object->km,'id',$object->id,$user->rights->deplacement->creer,'numeric:6'); + print $form->editfieldval("FeesKilometersOrAmout",'km',$object->km,'id',$object->id,$conf->global->MAIN_EDIT_ALSO_INLINE && $user->rights->deplacement->creer,'numeric:6'); print ""; // Where @@ -443,18 +447,18 @@ else if ($id) // Public note print ''; - print $form->editfieldkey("NotePublic",'note_public',$object->note_public,'id',$object->id,$user->rights->deplacement->creer,'ckeditor:dolibarr_notes:600:180:100:6'); + print $form->editfieldkey("NotePublic",'note_public',$object->note_public,'id',$object->id,$conf->global->MAIN_EDIT_ALSO_INLINE && $user->rights->deplacement->creer,'ckeditor:dolibarr_notes:600:180'); print ''; - print $form->editfieldval("NotePublic",'note_public',$object->note_public,'id',$object->id,$user->rights->deplacement->creer,'ckeditor:dolibarr_notes:600:180:100:6'); + print $form->editfieldval("NotePublic",'note_public',$object->note_public,'id',$object->id,$conf->global->MAIN_EDIT_ALSO_INLINE && $user->rights->deplacement->creer,'ckeditor:dolibarr_notes:600:180'); print ""; // Private note if (! $user->societe_id) { print ''; - print $form->editfieldkey("NotePrivate",'note',$object->note_private,'id',$object->id,$user->rights->deplacement->creer,'ckeditor:dolibarr_notes:600:180:100:6'); + print $form->editfieldkey("NotePrivate",'note',$object->note_private,'id',$object->id,$conf->global->MAIN_EDIT_ALSO_INLINE && $user->rights->deplacement->creer,'ckeditor:dolibarr_notes:600:180'); print ''; - print $form->editfieldval("NotePrivate",'note',$object->note_private,'id',$object->id,$user->rights->deplacement->creer,'ckeditor:dolibarr_notes:600:180:100:6'); + print $form->editfieldval("NotePrivate",'note',$object->note_private,'id',$object->id,$conf->global->MAIN_EDIT_ALSO_INLINE && $user->rights->deplacement->creer,'ckeditor:dolibarr_notes:600:180'); print ""; } diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index 0339dedb3b1..1e89c73ef71 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -68,6 +68,9 @@ class DolEditor dol_syslog("DolEditor::DolEditor htmlname=".$htmlname." tool=".$tool); + if (! $rows) $rows=round($height/25); + if (! $cols) $rows=round($height/6); + // Name of extended editor to use (FCKEDITOR_EDITORNAME can be 'ckeditor' or 'fckeditor') $defaulteditor='ckeditor'; $this->tool=empty($conf->global->FCKEDITOR_EDITORNAME)?$defaulteditor:$conf->global->FCKEDITOR_EDITORNAME; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 648938a7c8c..26ea9fda78d 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -74,7 +74,7 @@ class Form * @param string $paramkey Key of parameter for Url (unique if there is several parameter to show). In most cases "id". * @param string $paramvalue Value of parameter for Url * @param boolean $perm Permission to allow button to edit parameter - * @param string $typeofdata Type of data ('string' by default, 'email', 'text' or 'textarea', 'day' or 'datepicker', 'ckeditor:dolibarr_zzz', 'select:xxx'...) + * @param string $typeofdata Type of data ('string' by default, 'email', 'numeric:99', 'text' or 'textarea', 'day' or 'datepicker', 'ckeditor:dolibarr_zzz:width:height', 'select:xxx'...) * @return string HTML edit field */ function editfieldkey($text,$htmlname,$preselected,$paramkey,$paramvalue,$perm,$typeofdata='string') @@ -102,7 +102,7 @@ class Form * @param string $value Value to show/edit * @param string $paramkey Key of parameter (unique if there is several parameter to show). In most cases "id". * @param boolean $perm Permission to allow button to edit parameter - * @param string $typeofdata Type of data ('string' by default, 'email', 'numeric:99', 'text' or 'textarea', 'day' or 'datepicker', 'ckeditor:dolibarr_zzz:width:height:rows:cols', 'select:xxx'...) + * @param string $typeofdata Type of data ('string' by default, 'email', 'numeric:99', 'text' or 'textarea', 'day' or 'datepicker', 'ckeditor:dolibarr_zzz:width:height', 'select:xxx'...) * @param string $editvalue When in edit mode, use this value as $value instead of value * @return string HTML edit field */ @@ -132,7 +132,7 @@ class Form $tmp=explode(':',$typeofdata); $ret.=''; } - else if ($typeofdata == 'text' || $typeofdata == 'textarea') + else if ($typeofdata == 'text' || $typeofdata == 'textarea' || $typeofdata == 'note') { $ret.=''; } @@ -144,7 +144,7 @@ class Form { $tmp=explode(':',$typeofdata); require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"); - $doleditor=new DolEditor($htmlname,($editvalue?$editvalue:$value),($tmp[2]?$tmp[2]:''),($tmp[3]?$tmp[3]:'100'),($tmp[1]?$tmp[1]:'dolibarr_notes'),'In',false,true,true,($tmp[4]?$tmp[4]:ROWS_4),($tmp[5]?$tmp[5]:'100')); + $doleditor=new DolEditor($htmlname,($editvalue?$editvalue:$value),($tmp[2]?$tmp[2]:''),($tmp[3]?$tmp[3]:'100'),($tmp[1]?$tmp[1]:'dolibarr_notes'),'In',false,true,true); $ret.=$doleditor->Create(1); //$ret.=''; } @@ -157,7 +157,14 @@ class Form { if ($typeofdata == 'email') $ret.=dol_print_email($value,0,0,0,0,1); elseif ($typeofdata == 'day' || $typeofdata == 'datepicker') $ret.=dol_print_date($value,'day'); - elseif ($typeofdata == 'text' || $typeofdata == 'textarea') $ret.=dol_htmlentitiesbr($value); + elseif ($typeofdata == 'text' || $typeofdata == 'textarea') $ret.=dol_htmlentitiesbr($value); + else if (preg_match('/^ckeditor/',$typeofdata)) + { + $tmpcontent=dol_htmlentitiesbr($value); + $firstline=preg_replace('/
.*/','',$tmpcontent); + $firstline=preg_replace('/[\n\r].*/','',$firstline); + $ret.=$firstline.((strlen($firstline) != strlen($tmpcontent))?'...':''); + } else $ret.=$value; } } @@ -173,7 +180,7 @@ class Form * @param string $inputType Type of input ('numeric', 'datepicker', 'textarea', 'ckeditor:dolibarr_zzz', 'select:xxx') * @return string HTML edit in place */ - function editInPlace($value, $htmlname, $condition, $inputType='textarea') + private function editInPlace($value, $htmlname, $condition, $inputType='textarea') { global $conf; diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php index 027d8fba2ce..c0a97637996 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -816,9 +816,9 @@ else if ($id > 0 || ! empty($ref)) // Description (must be a textarea and not html must be allowed (used in list view) print ''; - print $form->editfieldkey("Description",'description',$object->description,'id',$object->id,$object->statut == 0 && $user->rights->ficheinter->creer,'textarea'); + print $form->editfieldkey("Description",'description',$object->description,'id',$object->id,$user->rights->ficheinter->creer,'textarea'); print ''; - print $form->editfieldval("Description",'description',$object->description,'id',$object->id,$object->statut == 0 && $user->rights->ficheinter->creer,'textarea'); + print $form->editfieldval("Description",'description',$object->description,'id',$object->id,$user->rights->ficheinter->creer,'textarea'); print ''; print ''; @@ -857,18 +857,18 @@ else if ($id > 0 || ! empty($ref)) // Public note print ''; - print $form->editfieldkey("NotePublic",'note_public',$object->note_public,'id',$object->id,$user->rights->ficheinter->creer,'textarea'); + print $form->editfieldkey("NotePublic",'note_public',$object->note_public,'id',$object->id,$user->rights->ficheinter->creer,'ckeditor:dolibarr_notes:600:180'); print ''; - print $form->editfieldval("NotePublic",'note_public',$object->note_public,'id',$object->id,$user->rights->ficheinter->creer,'textarea'); + print $form->editfieldval("NotePublic",'note_public',$object->note_public,'id',$object->id,$user->rights->ficheinter->creer,'ckeditor:dolibarr_notes:600:180'); print ""; // Private note if (! $user->societe_id) { print ''; - print $form->editfieldkey("NotePrivate",'note_private',$object->note_private,'id',$object->id,$user->rights->ficheinter->creer,'textarea'); + print $form->editfieldkey("NotePrivate",'note_private',$object->note_private,'id',$object->id,$user->rights->ficheinter->creer,'ckeditor:dolibarr_notes:600:180'); print ''; - print $form->editfieldval("NotePrivate",'note_private',$object->note_private,'id',$object->id,$user->rights->ficheinter->creer,'textarea'); + print $form->editfieldval("NotePrivate",'note_private',$object->note_private,'id',$object->id,$user->rights->ficheinter->creer,'ckeditor:dolibarr_notes:600:180'); print ""; }