-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Fix 20.0 button dropdown part02 #31217
Fix 20.0 button dropdown part02 #31217
Conversation
I merge manually the fix for 2 of 3 points. |
/** | ||
* 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; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eldy I think you've misunderstood what I mean with this function.
In some case if href attribute of link start with javascript: because a link can have differrent sheme like
- http:
- https:
- javascript:
- maito: (I doesn't check this one yet)
- # (I doesn't check this one yet)
but in all cases the code force to add &backtopage=
to url. Also the actual dolibarr code doesn't check if query already contain backtopage param.
see this pull request of subtotal module and search javascript:
to get a usecase.
to restart on good bases of code, I will recreate 2 separated PRs
- first to fix ajax loaded BTN
- secondly to allow deactivation of
&backtopage=
need #31215 PR before
FIX Ajax loaded button or if button was added after dom ready by js
see comment
FIX Abusive Url completion
Dropdown url doesn't work for non core url or javascript url
I have created an anonymous function to factor code during the fix
FIX inconsistent case isDropDown => isDropdown
keep isDropdown not isDropDown because Dropdown is used as a word
@eldy Sorry I can't split this one... the 3 problems are in same part of code.