dolibarr/htdocs/core/tpl
Frédéric FRANCE 585afa14de
Qual: Use dolBuildUrl() instead of manual urlencode() concatenation in ecm (#39557)
* Qual: Use dolBuildUrl() instead of manual urlencode() concatenation in ecm

Replaces manual '?key='.urlencode($val).'&key2='.urlencode($val2)
string-building with dolBuildUrl($path, $params) across the ECM
directory-tree/file-manager code, for consistency with the rest of
the codebase (see htdocs/core/lib/ecm.lib.php, which already uses
this pattern for the same page) and to benefit from dolBuildUrl()'s
buildurl hook.

- core/ajax/ajaxdirtree.php: the dir_card.php edit link built from
  the sql tree loop.
- ecm/dir_card.php: the edit/add-section action buttons and the two
  delete confirmation URLs. Also switches the three buttons that used
  to manually concatenate '&token='.newToken() to dolBuildUrl()'s own
  $addtoken parameter.
- ecm/class/ecmfiles.class.php: EcmFiles::getNomUrl()'s document.php
  and file_card.php URLs.
- ecm/tpl/enablefiletreeajax.tpl.php: the ajaxdirtree.php script URL
  and the ajaxdirpreview.php URL. The token here intentionally stays
  currentToken() (not dolBuildUrl()'s own newToken()-based
  $addtoken), per the existing comment: ajaxdirtree.php has
  NOTOKENRENEWAL defined, so the token must match the one already
  valid on the calling page. $paramwithoutsection is a pre-built raw
  query-string fragment from an external caller and is appended as-is
  after the dolBuildUrl() result rather than folded into it.

Verified all five refactored URL-building expressions produce byte-
identical output to the original code for representative inputs
(including values with '/', '&' and spaces), except for query
parameter order (which has no effect) and one real, minor pre-
existing bug this incidentally fixes: the delete-section confirm URL
in dir_card.php was building '&module='.$module without urlencode(),
now correctly encoded by dolBuildUrl()/http_build_query().

Could not do a live browser check (no Chrome available for Playwright
in this environment) - verified via php -l, phpcs, and a standalone
script comparing old vs new output for each call site instead.

* Qual: Use dolBuildUrl() instead of manual urlencode() concatenation in filemanager.tpl.php

Same refactor as the previous commit, applied to the 7 remaining
manually-concatenated URLs in core/tpl/filemanager.tpl.php (used by
the ECM/medias file manager): the delete-file/delete-section/
convert-to-webp confirm URLs, the create-directory and refresh-list
toolbar buttons (now using dolBuildUrl()'s $addtoken instead of a
manual '&token='.newToken()), the two generate-webp buttons, and the
"Root" link.

$websitekeyandpageid is kept as a helper to build the raw sub-query
string embedded once (single-encoded) as the create-directory
button's 'backtopage' value - it is not itself passed to dolBuildUrl.

Verified all 7 refactored URL-building expressions produce the same
query parameters as the original code for representative inputs
(compared as parsed, order-independent query strings, since
http_build_query() does not preserve insertion order the same way as
the original manual concatenation), including one case
(convertimgwebp confirm with sortfield/sortorder) where the original
code had a harmless but sloppy leading '?&' that dolBuildUrl() no
longer produces.

* fix

* Qual: Use dolBuildUrl() instead of manual urlencode() concatenation in index_auto.php

Same refactor as the previous commits, applied to the 4 manually-
concatenated URLs in ecm/index_auto.php: the delete-file and
delete-section confirm URLs, the refresh-list toolbar link, and the
per-directory link in the auto-directories list.

Verified all 4 refactored URL-building expressions produce the same
query parameters as the original code for representative inputs
(including an empty-module/empty-section case for the refresh link,
and values with '/' and spaces for the others).

* Qual: Use dolBuildUrl() instead of manual urlencode() concatenation in ecm (file_card, dir_add_card, index_medias)

Same refactor as the previous commits, applied to the remaining
manually-concatenated URLs in:
- ecm/file_card.php: the cancel and rename-file redirects, the
  internal download link (document.php), the delete-file confirm URL
  and the edit button.
- ecm/dir_add_card.php: the delete-section confirm URL and the delete
  button (now using dolBuildUrl()'s $addtoken instead of a manual
  '&token='.newToken()).
- ecm/index_medias.php: the $backtopage URL used by
  core/actions_linkedfiles.inc.php after a confirm_deletefile.

Left ecm/search.php's '$param = "&section=".urlencode($section)'
alone: it is a raw query-string fragment (starting with '&', no
leading path) passed into FormFile::list_of_documents(), not a
base+params URL build, so it does not fit the dolBuildUrl($path,
$params) shape - same reasoning as $paramwithoutsection in the
already-refactored enablefiletreeajax.tpl.php.

Verified all 8 refactored URL-building expressions produce the same
query parameters as the original code for representative inputs
(order-independent comparison, since http_build_query() does not
preserve the original insertion order).
2026-08-17 04:41:05 +02:00
..
admin_extrafields_add.tpl.php Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into 2026-08-14 16:13:22 +02:00
admin_extrafields_edit.tpl.php FIX: Escape extrafield form field values to stop double quotes truncating them 2026-08-12 08:48:27 +02:00
admin_extrafields_view.tpl.php FIX: Separate whitelisted page key from real elementtype to fix post-save redirects and the agenda/actioncomm override leaking into self-referencing links 2026-08-12 05:18:53 +02:00
ajaxrow.tpl.php QUAL of file ajaxrow.tpl.php (#37850) 2026-04-13 15:49:08 +02:00
apitoken_list.tpl.php Clean code 2026-04-23 17:41:15 +02:00
arrayfield_object_position_fields.tpl.php New add drag and drop for fields (#37462) 2026-06-13 16:19:14 +02:00
bloc_comment.tpl.php Qual: Fix PHPStan messages (#38053) 2026-05-07 14:20:03 +02:00
bloc_showhide.tpl.php Qual: Fix PHPStan messages (#38053) 2026-05-07 14:20:03 +02:00
card_presend.tpl.php Fix mail object-line substitutions to respect selected language (#38201) 2026-05-28 10:56:32 +02:00
commonfields_add.tpl.php Qual: Phan/fix for notices seen in #37875 & ci (#37876) 2026-04-15 17:59:06 +02:00
commonfields_edit.tpl.php
commonfields_view.tpl.php
contacts.tpl.php Debug v24 - Switch contact status 2026-08-07 19:43:34 +02:00
document_actions_post_headers.tpl.php Qual: Fix PHPStan messages (#38053) 2026-05-07 14:20:03 +02:00
error.tpl.php
extrafields_add.tpl.php FIX: propagate extrafields from objectsrc in extrafields_add.tpl.php (#39073) 2026-07-10 19:45:33 +02:00
extrafields_edit.tpl.php
extrafields_list_array_fields.tpl.php Qual: Fix PHPStan messages (#38053) 2026-05-07 14:20:03 +02:00
extrafields_list_print_fields.tpl.php Fix #39143 store computed extrafields with object context (#39172) 2026-07-19 16:22:57 +02:00
extrafields_list_search_input.tpl.php
extrafields_list_search_param.tpl.php clean code (#35843) 2025-10-19 17:09:54 +02:00
extrafields_list_search_sql.tpl.php Qual: Fix 'SqlInjection' notices (#39220) 2026-07-20 02:51:00 +02:00
extrafields_list_search_title.tpl.php Qual: Fix PHPStan messages (#38053) 2026-05-07 14:20:03 +02:00
extrafields_view.tpl.php FIX #30801 Filter a dependent select list of extrafields when the field is edited alone (#39488) 2026-08-15 03:04:31 +02:00
filemanager.tpl.php Qual: Use dolBuildUrl() instead of manual urlencode() concatenation in ecm (#39557) 2026-08-17 04:41:05 +02:00
footer.tpl.php
formlayoutai.tpl.php Debug v23 2026-02-02 15:53:41 +01:00
header.tpl.php
list_print_subtotal.tpl.php
list_print_total.tpl.php Qual: Fix 'SqlInjection' notices (#39220) 2026-07-20 02:51:00 +02:00
login.tpl.php NEW: Add OIDC user auto-creation and fix login bugs (#37314) 2026-02-28 15:37:48 +01:00
massactions_pre.tpl.php Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into 2026-06-10 12:38:39 +02:00
notes.tpl.php
object_currency_amount.tpl.php
object_discounts.tpl.php Qual: Phan/fix for notices seen in #37875 & ci (#37876) 2026-04-15 17:59:06 +02:00
objectline_create.tpl.php FIX #39403: Fill extrafields of type boolean, select, radio, date, and html when selecting a product with the same extrafield (#39404) 2026-08-13 05:41:17 +02:00
objectline_edit.tpl.php Debug v24 2026-07-01 14:24:54 +02:00
objectline_title.tpl.php Qual: Fix PHPStan messages (#38053) 2026-05-07 14:20:03 +02:00
objectline_view.tpl.php Qual: Fix 'SqlInjection' notices (#39216) 2026-07-23 19:06:39 +02:00
objectlinked_lineimport.tpl.php Merge branch '22.0' of git@github.com:Dolibarr/dolibarr.git into develop 2025-11-20 12:00:49 +01:00
onlinepaymentlinks.tpl.php Removed old option PAYMENT_SECURITY_TOKEN_UNIQUE has been removed 2026-04-10 15:21:37 +02:00
originproductline.tpl.php Qual: Fix PHPStan messages (#38053) 2026-05-07 14:20:03 +02:00
originsubtotalline.tpl.php
passwordforgotten.tpl.php css 2025-12-29 14:17:38 +01:00
passwordreset.tpl.php css 2025-12-29 14:17:38 +01:00
README Clean files 2026-01-07 19:01:54 +01:00
resource_add.tpl.php
resource_view.tpl.php
subtotal_ajaxrow.tpl.php
subtotal_create.tpl.php Debug v24 - Checkbox useless 2026-08-07 15:53:35 +02:00
subtotal_edit.tpl.php Debug v24 - Checkbox useless 2026-08-07 15:53:35 +02:00
subtotal_expedition_view.tpl.php
subtotal_view.tpl.php Automated merge from 23.0 to develop 2026-06-09 00:27:55 +02:00
subtotalline_select.tpl.php

README (english)

This directory is used for storing the common default templates of the system core. (outside any modules)