Better support of text editor when no js available.

This commit is contained in:
Laurent Destailleur 2017-09-15 11:19:56 +02:00
parent e02c220c08
commit 0ade500535
4 changed files with 19 additions and 16 deletions

View File

@ -941,7 +941,14 @@ else
if (($object->statut == 0 || $object->statut == 1) && $user->rights->mailing->creer)
{
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&amp;id='.$object->id.'">'.$langs->trans("EditWithEditor").'</a>';
if (! empty($conf->fckeditor->enabled) && ! empty($conf->global->FCKEDITOR_ENABLE_MAILING))
{
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&amp;id='.$object->id.'">'.$langs->trans("EditWithEditor").'</a>';
}
else
{
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edit&amp;id='.$object->id.'">'.$langs->trans("EditWithTextEditor").'</a>';
}
if (! empty($conf->use_javascript_ajax)) print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=edithtml&amp;id='.$object->id.'">'.$langs->trans("EditHTMLSource").'</a>';
}
@ -1103,7 +1110,7 @@ else
$readonly=1;
// Editeur wysiwyg
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor=new DolEditor('bodyemail',$object->body,'',600,'dolibarr_mailings','',false,true,empty($conf->global->FCKEDITOR_ENABLE_MAILING)?0:1,20,120,$readonly);
$doleditor=new DolEditor('bodyemail',$object->body,'',600,'dolibarr_mailings','',false,true,empty($conf->global->FCKEDITOR_ENABLE_MAILING)?0:1,20,'90%',$readonly);
$doleditor->Create();
}
else print dol_htmlentitiesbr($object->body);

View File

@ -170,7 +170,8 @@ class DolEditor
if (in_array($this->tool,array('textarea','ckeditor')))
{
$found=1;
//$out.= '<textarea id="'.$this->htmlname.'" name="'.$this->htmlname.'" rows="'.$this->rows.'" cols="'.$this->cols.'"'.($this->readonly?' disabled':'').' class="flat">';
//$out.= '<textarea id="'.$this->htmlname.'" name="'.$this->htmlname.'" '.($this->readonly?' disabled':'').' rows="'.$this->rows.'"'.(preg_match('/%/',$this->cols)?' style="margin-top: 5px; width: '.$this->cols.'"':' cols="'.$this->cols.'"').' class="flat">';
// TODO We do not put the disabled tag because on a read form, it change style with grey.
$out.= '<textarea id="'.$this->htmlname.'" name="'.$this->htmlname.'" rows="'.$this->rows.'"'.(preg_match('/%/',$this->cols)?' style="margin-top: 5px; width: '.$this->cols.'"':' cols="'.$this->cols.'"').' class="flat">';
$out.= $this->content;
$out.= '</textarea>';

View File

@ -259,14 +259,18 @@ function dol_shutdown()
* @param int $filter Filter to apply when $check is set to 'custom'. (See http://php.net/manual/en/filter.filters.php for détails)
* @param mixed $options Options to pass to filter_var when $check is set to 'custom'.
* @return string|string[] Value found (string or array), or '' if check fails
*
* @TODO Set default value for check to alpha. Check all WYSIWYG edition (email and description...) is still ok with rich text.
*/
function GETPOST($paramname, $check='', $method=0, $filter=NULL, $options=NULL)
function GETPOST($paramname, $check='alpha', $method=0, $filter=NULL, $options=NULL)
{
global $mysoc,$user,$conf;
if (empty($paramname)) return 'BadFirstParameterForGETPOST';
if (empty($check))
{
dol_syslog("Deprecated use of GETPOST, called with 1st param = ".$paramname." and 2nd param is '', when calling page ".$_SERVER["PHP_SELF"], LOG_WARNING);
// Enable this line to know who call the GETPOST with '' $check parameter.
//var_dump(debug_backtrace()[0]);
}
if (empty($method)) $out = isset($_GET[$paramname])?$_GET[$paramname]:(isset($_POST[$paramname])?$_POST[$paramname]:'');
elseif ($method==1) $out = isset($_GET[$paramname])?$_GET[$paramname]:'';
@ -420,15 +424,6 @@ function GETPOST($paramname, $check='', $method=0, $filter=NULL, $options=NULL)
}
if (empty($check) && ! empty($conf->global->MAIN_FEATURES_LEVEL) && $conf->global->MAIN_FEATURES_LEVEL >= 2)
{
dol_syslog("Deprecated use of GETPOST, called with 1st param = ".$paramname." and 2nd param not defined, when calling page ".$_SERVER["PHP_SELF"], LOG_WARNING);
// Enable this line to know who call the GETPOST with empty $check parameter.
//var_dump(debug_backtrace()[0]);
}
if (! empty($check))
{
// Substitution variables for GETPOST (used to get final url with variable parameters or final default value with variable paramaters)
// Example of variables: __DAY__, __MONTH__, __YEAR__, __MYCOUNTRYID__, __USERID__, __ENTITYID__, ...
// We do this only if var is a GET. If it is a POST, may be we want to post the text with vars as the setup text.
@ -518,7 +513,6 @@ function GETPOST($paramname, $check='', $method=0, $filter=NULL, $options=NULL)
$out=filter_var($out, $filter, $options);
break;
}
}
// Code for search criteria persistence.
// Save data into session if key start with 'search_' or is 'smonth', 'syear', 'month', 'year'

View File

@ -714,6 +714,7 @@ CreateDraft=Create draft
SetToDraft=Back to draft
ClickToEdit=Click to edit
EditWithEditor=Edit with CKEditor
EditWithTextEditor=Edit with Text editor
EditHTMLSource=Edit HTML Source
ObjectDeleted=Object %s deleted
ByCountry=By country