From 1df4561a619929392fd1d2baa1ce74481d477245 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 11 Aug 2026 19:30:44 +0200 Subject: [PATCH] NEW: Migrate category extrafields admin pages to the unified page --- .../admin/categorie_extrafields.php | 105 -------------- .../admin/categorie_lang_extrafields.php | 128 ------------------ htdocs/core/lib/admin_extrafields.lib.php | 22 +++ htdocs/core/lib/categories.lib.php | 4 +- 4 files changed, 24 insertions(+), 235 deletions(-) delete mode 100644 htdocs/categories/admin/categorie_extrafields.php delete mode 100644 htdocs/categories/admin/categorie_lang_extrafields.php diff --git a/htdocs/categories/admin/categorie_extrafields.php b/htdocs/categories/admin/categorie_extrafields.php deleted file mode 100644 index 48fbd3eacbe..00000000000 --- a/htdocs/categories/admin/categorie_extrafields.php +++ /dev/null @@ -1,105 +0,0 @@ - - * Copyright (C) 2003 Jean-Louis Bergamo - * Copyright (C) 2004-2012 Laurent Destailleur - * Copyright (C) 2012 Regis Houssin - * Copyright (C) 2024-2026 Frédéric France - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/categories/admin/categorie_extrafields.php - * \ingroup societe - * \brief Page to setup extra fields of category - */ - -// 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'; - -// Load translation files required by the page -$langs->loadLangs(array('categories', 'admin')); - -$form = new Form($db); - -// List of supported format -$type2label = ExtraFields::getListOfTypesLabels(); - -$action = GETPOST('action', 'aZ09'); -$attrname = GETPOST('attrname', 'alpha'); -$elementtype = 'categorie'; //Must be the $element of the class that manage extrafield - -if (!$user->admin) { - accessforbidden(); -} - - -/* - * Actions - */ - -require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; - - -/* - * View - */ - -$textobject = $langs->transnoentitiesnoconv("Categories"); - -$help_url = 'EN:Module Categories|FR:Module Catégories|ES:Módulo Categorías|DE:Modul_Kategorien'; -llxHeader('', $langs->trans("Categories"), $help_url); - - -$linkback = ''.img_picto($langs->trans("BackToModuleList"), 'back', 'class="pictofixedwidth"').''.$langs->trans("BackToModuleList").''; -print load_fiche_titre($langs->trans("CategoriesSetup"), $linkback, 'title_setup'); - -$head = categoriesadmin_prepare_head(); - -print dol_get_fiche_head($head, 'attributes_categories', $langs->trans("Categories"), -1, 'category'); - -require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; - -print dol_get_fiche_end(); - - -// Creation of an optional field -if ($action == 'create') { - print '
'; - print load_fiche_titre($langs->trans('NewAttribute')); - - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; -} - -// Edition of an optional field -if ($action == 'edit' && !empty($attrname)) { - print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; -} - -// End of page -llxFooter(); -$db->close(); diff --git a/htdocs/categories/admin/categorie_lang_extrafields.php b/htdocs/categories/admin/categorie_lang_extrafields.php deleted file mode 100644 index 953bd871a59..00000000000 --- a/htdocs/categories/admin/categorie_lang_extrafields.php +++ /dev/null @@ -1,128 +0,0 @@ - - * Copyright (C) 2003 Jean-Louis Bergamo - * Copyright (C) 2004-2011 Laurent Destailleur - * Copyright (C) 2012 Regis Houssin - * Copyright (C) 2014 Florian Henry - * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2026 Frédéric France - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file admin/categorie_lang_extrafields.php - * \ingroup categorie - * \brief Page to setup extra fields of categorie lang - */ - -// 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'; - -// Load translation files required by the page -$langs->loadLangs(array('admin', 'categories')); - -$form = new Form($db); - -// List of supported format -$tmptype2label = ExtraFields::$type2label; -$type2label = array(''); -foreach ($tmptype2label as $key => $val) { - $type2label[$key] = $langs->transnoentitiesnoconv($val); -} - -$action = GETPOST('action', 'aZ09'); -$attrname = GETPOST('attrname', 'alpha'); -$elementtype = 'categorie_lang'; // Must be the $table_element of the class that manage extrafield - -if (!$user->admin) { - accessforbidden(); -} - - -/* - * Actions - */ - -require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; - - - -/* - * View - */ - -$textobject = $langs->transnoentitiesnoconv("Category"); - -$help_url = ''; -$page_name = "CategoriesTranslationsExtrafields"; - -llxHeader('', $langs->trans($page_name), $help_url); - - -$linkback = ''.$langs->trans("BackToModuleList").''; -print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup'); - - -$head = categoriesadmin_prepare_head(); - -print dol_get_fiche_head($head, 'translationAttributes', $langs->trans($page_name), -1, 'categorie'); - -require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; - -print dol_get_fiche_end(); - - -// Buttons -if ($action != 'create' && $action != 'edit') { - print '
'; - print ''.$langs->trans("NewAttribute").''; - print "
"; -} - - -/* - * Creation of an optional field - */ -if ($action == 'create') { - print '
'; - print load_fiche_titre($langs->trans('NewAttribute')); - - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; -} - -/* - * Edition of an optional field - */ -if ($action == 'edit' && !empty($attrname)) { - print "
"; - print load_fiche_titre($langs->trans("FieldEdition", $attrname)); - - require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; -} - -// End of page -llxFooter(); -$db->close(); diff --git a/htdocs/core/lib/admin_extrafields.lib.php b/htdocs/core/lib/admin_extrafields.lib.php index f614ac7eef0..d78cdf0aafc 100644 --- a/htdocs/core/lib/admin_extrafields.lib.php +++ b/htdocs/core/lib/admin_extrafields.lib.php @@ -581,5 +581,27 @@ function getExtrafieldsAdminMap() 'helpurl' => '', 'langs' => array('workstation', 'admin'), ), + 'categorie' => array( + 'headfunction' => 'categoriesadmin_prepare_head', + 'headfile' => 'core/lib/categories.lib.php', + 'tabid' => 'attributes_categories', + 'headlabel' => 'Categories', + 'textobject' => 'Categories', + 'headpicto' => 'category', + 'title' => 'Categories', + 'helpurl' => 'EN:Module Categories|FR:Module Catégories|ES:Módulo Categorías|DE:Modul_Kategorien', + 'langs' => array('categories', 'admin'), + ), + 'categorie_lang' => array( + 'headfunction' => 'categoriesadmin_prepare_head', + 'headfile' => 'core/lib/categories.lib.php', + 'tabid' => 'translationAttributes', + 'headlabel' => 'CategoriesTranslationsExtrafields', + 'textobject' => 'Category', + 'headpicto' => 'categorie', + 'title' => 'CategoriesTranslationsExtrafields', + 'helpurl' => '', + 'langs' => array('admin', 'categories'), + ), ); } diff --git a/htdocs/core/lib/categories.lib.php b/htdocs/core/lib/categories.lib.php index 86aa162047e..01d214cbdc5 100644 --- a/htdocs/core/lib/categories.lib.php +++ b/htdocs/core/lib/categories.lib.php @@ -100,7 +100,7 @@ function categoriesadmin_prepare_head() $head[$h][2] = 'setup'; $h++; - $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/categories/admin/categorie_extrafields.php'); + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/admin/extrafields.php', array('elementtype' => 'categorie')); $head[$h][1] = $langs->trans("ExtraFieldsCategories"); $nbExtrafields = $extrafields->attributes['categorie']['count']; if ($nbExtrafields > 0) { @@ -111,7 +111,7 @@ function categoriesadmin_prepare_head() // Multilangs Extrafields if (getDolGlobalInt('MAIN_MULTILANGS')) { - $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/categories/admin/categorie_lang_extrafields.php'); + $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/admin/extrafields.php', array('elementtype' => 'categorie_lang')); $head[$h][1] = $langs->trans("CategoriesTranslationsExtrafields"); $nbExtrafields = isset($extrafields->attributes['categorie_lang']['count']) ? $extrafields->attributes['categorie_lang']['count'] : 0; if ($nbExtrafields > 0) {