-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Fix 20.0 button dropdown part02 #31217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
aa8fa0c
9d1a235
6b1632f
8c481ed
5d9bdde
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12291,6 +12291,39 @@ function dolGetButtonAction($label, $text = '', $actionType = 'default', $url = | |
|
|
||
| // If $url is an array, we must build a dropdown button or recursively iterate over each value | ||
| if (is_array($url)) { | ||
|
|
||
| /** | ||
| * An anonymous function to complete dropdown url | ||
| * @param string $url | ||
| * @return string | ||
| */ | ||
| $completeUrl = function ($url) use ($params) { | ||
| if (empty($url)) { | ||
| return ''; | ||
| } | ||
|
|
||
| $parsedUrl = parse_url($url); | ||
| if (isset($parsedUrl['scheme']) && $parsedUrl['scheme'] === 'javascript') { | ||
| return $url; | ||
| } | ||
|
|
||
| if (!empty($parsedUrl['query'])) { | ||
| // Use parse_str() function to parse the string passed via URL | ||
| parse_str($parsedUrl['query'], $urlQuery); | ||
| if (!isset($urlQuery['backtopage']) && isset($params['backtopage'])) { | ||
| $url.= '&backtopage='.urlencode($params['backtopage']); | ||
| } | ||
| } | ||
|
|
||
| // TODO : this is a first fix of button behavior : external module will needs to use http:// or https:// prefix on there Urls | ||
| if (!isset($parsedUrl['scheme'])) { | ||
| $url = DOL_URL_ROOT.$url; | ||
| } | ||
|
|
||
| return $url; | ||
| }; | ||
|
Comment on lines
+12295
to
+12324
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @eldy I think you've misunderstood what I mean with this function.
but in all cases the code force to add see this pull request of subtotal module and search to restart on good bases of code, I will recreate 2 separated PRs
|
||
|
|
||
|
|
||
| // Loop on $url array to remove entries of disabled modules | ||
| foreach ($url as $key => $subbutton) { | ||
| if (isset($subbutton['enabled']) && empty($subbutton['enabled'])) { | ||
|
|
@@ -12311,13 +12344,15 @@ function dolGetButtonAction($label, $text = '', $actionType = 'default', $url = | |
| $tmpUrl = DOL_URL_ROOT.$button['url'].(empty($params['backtopage']) ? '' : '&backtopage='.urlencode($params['backtopage'])); | ||
| $id = $button['id'] ?? ''; | ||
| $userRight = $button['perm'] ?? 1; | ||
| $params = $button['params'] ?? []; | ||
| $button['params'] = $button['params'] ?? []; | ||
|
|
||
| $out .= dolGetButtonAction($label, $text, $actionType, $tmpUrl, $id, $userRight, $params); | ||
| $out .= dolGetButtonAction($label, $text, $actionType, $tmpUrl, $id, $userRight, $button['params']); | ||
| } | ||
| return $out; | ||
| } | ||
|
|
||
|
|
||
|
|
||
| if (count($url) > 1) { | ||
| $out .= '<div class="dropdown inline-block dropdown-holder">'; | ||
| $out .= '<a style="margin-right: auto;" class="dropdown-toggle classfortooltip butAction'.($userRight ? '' : 'Refused').'" title="'.dol_escape_htmltag($label).'" data-toggle="dropdown">'.($text ? $text : $label).'</a>'; | ||
|
|
@@ -12326,8 +12361,12 @@ function dolGetButtonAction($label, $text = '', $actionType = 'default', $url = | |
| if (!empty($subbutton['lang'])) { | ||
| $langs->load($subbutton['lang']); | ||
| } | ||
| $tmpurl = DOL_URL_ROOT.$subbutton['url'].(empty($params['backtopage']) ? '' : '&backtopage='.urlencode($params['backtopage'])); | ||
| $out .= dolGetButtonAction('', $langs->trans($subbutton['label']), 'default', $tmpurl, '', $subbutton['perm'], array('isDropDown' => true)); | ||
|
|
||
| if (!isset($subbutton['params'])) { | ||
| $subbutton['params'] = array(); | ||
| } | ||
| $subbutton['params']['isDropdown'] = true; | ||
| $out .= dolGetButtonAction('', $langs->trans($subbutton['label']), 'default', $completeUrl($subbutton['url']), $subbutton['id'] ?? '', $subbutton['perm'], $subbutton['params']); | ||
| } | ||
| $out .= "</div>"; | ||
| $out .= "</div>"; | ||
|
|
@@ -12336,16 +12375,14 @@ function dolGetButtonAction($label, $text = '', $actionType = 'default', $url = | |
| if (!empty($subbutton['lang'])) { | ||
| $langs->load($subbutton['lang']); | ||
| } | ||
| $tmpurl = DOL_URL_ROOT.$subbutton['url'].(empty($params['backtopage']) ? '' : '&backtopage='.urlencode($params['backtopage'])); | ||
| $out .= dolGetButtonAction('', $langs->trans($subbutton['label']), 'default', $tmpurl, '', $subbutton['perm']); | ||
| $out .= dolGetButtonAction('', $langs->trans($subbutton['label']), 'default', $completeUrl($subbutton['url']), '', $subbutton['perm']); | ||
| } | ||
| } | ||
|
|
||
| return $out; | ||
| } | ||
|
|
||
| // Here, $url is a simple link | ||
|
|
||
| if (!empty($params['isDropdown'])) { | ||
| $class = "dropdown-item"; | ||
| } else { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.