Clean code

This commit is contained in:
Laurent Destailleur 2022-08-29 18:21:35 +02:00
parent 49f869352c
commit 28797930fc
3 changed files with 13 additions and 9 deletions

View File

@ -10418,8 +10418,8 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st
/** /**
* Function dolGetButtonAction * Function dolGetButtonAction
* *
* @param string $label label of button without HTML : use in alt attribute for accessibility $html is not empty * @param string $label label or tooltip of button. Also used as tooltip in title attribute. Can be escaped HTML content or full simple text.
* @param string $html optional : content with html * @param string $text optional : short label on button. Can be escaped HTML content or full simple text.
* @param string $actionType default, delete, danger * @param string $actionType default, delete, danger
* @param string $url the url for link * @param string $url the url for link
* @param string $id attribute id of button * @param string $id attribute id of button
@ -10444,7 +10444,7 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st
* // phpcs:enable * // phpcs:enable
* @return string html button * @return string html button
*/ */
function dolGetButtonAction($label, $html = '', $actionType = 'default', $url = '', $id = '', $userRight = 1, $params = array()) function dolGetButtonAction($label, $text = '', $actionType = 'default', $url = '', $id = '', $userRight = 1, $params = array())
{ {
global $hookmanager, $action, $object, $langs; global $hookmanager, $action, $object, $langs;
@ -10464,8 +10464,8 @@ function dolGetButtonAction($label, $html = '', $actionType = 'default', $url =
'title' => $label 'title' => $label
); );
if (empty($html)) { if (empty($text)) {
$html = $label; $text = $label;
$attr['title'] = ''; // if html not set, leave label on title is redundant $attr['title'] = ''; // if html not set, leave label on title is redundant
} else { } else {
$attr['aria-label'] = $label; $attr['aria-label'] = $label;
@ -10544,7 +10544,7 @@ function dolGetButtonAction($label, $html = '', $actionType = 'default', $url =
'attr' => $attr, 'attr' => $attr,
'tag' => $tag, 'tag' => $tag,
'label' => $label, 'label' => $label,
'html' => $html, 'html' => $text,
'actionType' => $actionType, 'actionType' => $actionType,
'url' => $url, 'url' => $url,
'id' => $id, 'id' => $id,
@ -10556,7 +10556,11 @@ function dolGetButtonAction($label, $html = '', $actionType = 'default', $url =
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook)) { if (empty($reshook)) {
return '<' . $tag . ' ' . $compiledAttributes . '>' . $html . '</' . $tag . '>'; if (dol_textishtml($text)) { // If content already HTML encoded
return '<' . $tag . ' ' . $compiledAttributes . '>' . $text . '</' . $tag . '>';
} else {
return '<' . $tag . ' ' . $compiledAttributes . '>' . dol_escape_htmltag($text) . '</' . $tag . '>';
}
} else { } else {
return $hookmanager->resPrint; return $hookmanager->resPrint;
} }

View File

@ -94,7 +94,7 @@ class ActionsDatapolicy
$langs->load('datapolicy@datapolicy'); $langs->load('datapolicy@datapolicy');
$error = 0; // Error counter $error = 0; // Error counter
if (GETPOST('socid') && $parameters['currentcontext'] == 'thirdpartycard') { if (GETPOST('socid') && $parameters['currentcontext'] == 'thirdpartycard' && !empty($object)) {
$object->fetch(GETPOST('socid')); $object->fetch(GETPOST('socid'));
} }

View File

@ -121,7 +121,7 @@ $result = restrictedArea($user, 'societe', $id, '&societe', '', 'fk_soc', 'rowid
* Actions * Actions
*/ */
$parameters = array(); $parameters = array('socid' => $id);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) { if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');