| ';
print $langs->trans("Color").' | ';
diff --git a/htdocs/categories/traduction.php b/htdocs/categories/traduction.php
index a66e333fdf4..29d364b5595 100644
--- a/htdocs/categories/traduction.php
+++ b/htdocs/categories/traduction.php
@@ -3,7 +3,7 @@
* Copyright (C) 2007 Rodolphe Quiedeville
* Copyright (C) 2010-2016 Destailleur Laurent
* Copyright (C) 2015 Raphaël Doursenaud
- * Copyright (C) 2024 Frédéric France
+ * Copyright (C) 2024-2026 Frédéric France
* Copyright (C) 2024 MDW
*
* This program is free software; you can redistribute it and/or modify
@@ -29,20 +29,21 @@
// Load Dolibarr environment
require '../main.inc.php';
+/**
+ * @var Conf $conf
+ * @var DoliDB $db
+ * @var ExtraFields $extrafields
+ * @var HookManager $hookmanager
+ * @var Translate $langs
+ * @var User $user
+ */
+
require_once DOL_DOCUMENT_ROOT.'/core/lib/categories.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
-/**
- * @var Conf $conf
- * @var DoliDB $db
- * @var HookManager $hookmanager
- * @var Translate $langs
- * @var User $user
- */
-
// Load translation files required by the page
$langs->loadLangs(array('categories', 'languages', 'mrp'));
@@ -63,6 +64,10 @@ if ($result <= 0) {
dol_print_error($db, $object->error);
exit;
}
+$extralabels = $extrafields->fetch_name_optionals_label("categorie_lang");
+
+// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
+$hookmanager->initHooks(array('categorietranslationcard', 'globalcard'));
$type = $object->type;
if (is_numeric($type)) {
@@ -73,21 +78,28 @@ if (is_numeric($type)) {
$result = restrictedArea($user, 'categorie', $id, '&category');
$permissiontoadd = $user->hasRight('categorie', 'creer');
-
+$permissiontodelete = $user->hasRight('categorie', 'supprimer');
/*
* Actions
*/
$error = 0;
-
+$parameters = [
+ 'id' => $id,
+ 'ref' => $label,
+];
+$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
+if ($reshook < 0) {
+ setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+}
// return to translation view if cancelled
-if ($cancel == $langs->trans("Cancel")) {
+if (empty($reshook) && $cancel == $langs->trans("Cancel")) {
$action = '';
}
// delete a translation
-if ($action == 'delete' && $langtodelete && $user->hasRight('categorie', 'creer')) {
+if (empty($reshook) && $action == 'delete' && $langtodelete && $permissiontodelete) {
$res = $object->delMultiLangs($langtodelete, $user);
if ($res < 0) {
setEventMessages($object->error, $object->errors, 'errors');
@@ -99,7 +111,7 @@ if ($action == 'delete' && $langtodelete && $user->hasRight('categorie', 'creer'
}
// validation of addition
-if ($action == 'vadd' && $cancel != $langs->trans("Cancel") && $permissiontoadd) {
+if (empty($reshook) && $action == 'vadd' && $cancel != $langs->trans("Cancel") && $permissiontoadd) {
$object->fetch($id);
$current_lang = $langs->getDefaultLang();
@@ -148,7 +160,7 @@ if ($action == 'vadd' && $cancel != $langs->trans("Cancel") && $permissiontoadd)
}
// validation of the edition
-if ($action == 'vedit' && $cancel != $langs->trans("Cancel") && $permissiontoadd) {
+if (empty($reshook) && $action == 'vedit' && $cancel != $langs->trans("Cancel") && $permissiontoadd) {
$object->fetch($id);
$current_lang = $langs->getDefaultLang();
@@ -164,6 +176,7 @@ if ($action == 'vedit' && $cancel != $langs->trans("Cancel") && $permissiontoadd
if ($key == $current_lang) {
$object->label = $libelle;
$object->description = dol_htmlcleanlastbr($desc);
+ $object->update($user);
} else {
$object->multilangs[$key]["label"] = $libelle;
$object->multilangs[$key]["description"] = dol_htmlcleanlastbr($desc);
@@ -231,12 +244,18 @@ print '';
print '';
-// Description
+// Label
print '| ';
-print $langs->trans("Description").' | ';
-print dol_htmlentitiesbr($object->description);
+print $langs->trans("Label").' | ';
+print dol_htmlentitiesbr($object->label);
print ' | ';
+// Description
+// print '| ';
+// print $langs->trans("Description").' | ';
+// print dol_htmlentitiesbr($object->description);
+// print ' | ';
+
// Color
print '| ';
print $langs->trans("Color").' | ';
@@ -249,18 +268,19 @@ print '';
print dol_get_fiche_end();
-
/*
* Action bar
*/
print "\n\n";
-if ($action == '') {
- if ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer')) {
- print ' '.$langs->trans('Add').'';
+$parameters = array();
+$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
+if (empty($reshook)) {
+ if ($action == '' && $permissiontoadd) {
+ print ' '.$langs->trans('Add').'';
if ($cnt_trans > 0) {
- print ' '.$langs->trans('Update').'';
+ print ' '.$langs->trans('Update').'';
}
}
}
@@ -268,7 +288,6 @@ if ($action == '') {
print "\n \n";
-
if ($action == 'edit') {
// WYSIWYG Editor
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
@@ -281,7 +300,8 @@ if ($action == 'edit') {
if (!empty($object->multilangs)) {
foreach ($object->multilangs as $key => $value) {
- print " ".$langs->trans('Language_'.$key)." : ";
+ $s = picto_from_langcode((string) $key);
+ print ' '.($s ? $s.' ' : '').''.$langs->trans('Language_'.$key).': ' . $langs->trans('Language_'.$key).' : ';
print '';
// Label
@@ -314,7 +334,7 @@ if ($action == 'edit') {
foreach ($object->multilangs as $key => $value) {
$s = picto_from_langcode((string) $key);
print '';
- print '| '.($s ? $s.' ' : '')." ".$langs->trans('Language_'.$key).": ".'id.'&action=delete&token='.newToken().'&langtodelete='.$key.'&type='.$type.'">'.img_delete('', '').' | ';
+ print '| '.($s ? $s.' ' : '').' '.$langs->trans('Language_'.$key).': $object->id, 'action' => 'delete', 'langtodelete' => $key, 'type' => $type], true).'">'.img_delete('', '').' | ';
print '| '.$langs->trans('Label').' | '.($object->multilangs[$key]["label"] ?? '').' | ';
print '| '.$langs->trans('Description').' | '.($object->multilangs[$key]["description"] ?? '').' | ';
if (getDolGlobalString('CATEGORY_USE_OTHER_FIELD_IN_TRANSLATION')) {
@@ -333,12 +353,12 @@ if ($action == 'edit') {
* Form to add a new translation
*/
-if ($action == 'add' && ($user->hasRight('produit', 'creer') || $user->hasRight('service', 'creer'))) {
+if ($action == 'add' && $permissiontoadd) {
//WYSIWYG Editor
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
print ' ';
- print ' | |