- Timestamp:
- Feb 21, 2021 4:20:55 AM (3 years ago)
- Location:
- trunk/lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/App.inc.php
r740 r742 1140 1140 * @param mixed $carry_args Additional url arguments to carry in the query, 1141 1141 * or FALSE to prevent carrying queries. Can be any of the following formats: 1142 * array('key1', key2', key3') <-- to save these keys if in the formdata.1143 * array('key1'=>'value', key2'='value') <-- to set keys to default values if not present in formdata.1142 * array('key1', key2', key3') <-- to save these keys, if they exist in the request data. 1143 * array('key1'=>'value', key2'='value') <-- to set keys to default values if not present in request data. 1144 1144 * false <-- To not carry any queries. If URL already has queries those will be retained. 1145 1145 * -
trunk/lib/Utilities.inc.php
r741 r742 899 899 function urlEncodeArrayToString($data, $prefix='') 900 900 { 901 902 901 $array_args = urlEncodeArray($data, $prefix); 903 902 $url_args = ''; … … 1465 1464 1466 1465 return preg_replace('/[?#].*$/' . $app->getParam('preg_u'), '', $url); 1466 } 1467 1468 /* 1469 * Merge query arguments into a URL. 1470 * Usage: 1471 * Add ?lang=it or replace an existing ?lang= argument: 1472 * $url = urlMerge('https://example.com/?lang=en', ['lang' => 'it']). 1473 * 1474 * @access public 1475 * @param string $url Original URL. 1476 * @param array $new_args New/modified query arguments. 1477 * @return string Modified URL. 1478 * @author Quinn Comendant <quinn@strangecode.com> 1479 * @since 20 Feb 2021 21:21:53 1480 */ 1481 function urlMergeQuery($url, Array $new_args) 1482 { 1483 $u = parse_url($url); 1484 if (isset($u['query']) && '' != $u['query']) { 1485 parse_str($u['query'], $args); 1486 } else { 1487 $args = []; 1488 } 1489 $u['query'] = http_build_query(array_merge($args, $new_args)); 1490 return sprintf('%s%s%s%s%s', 1491 (isset($u['scheme']) && '' != $u['scheme'] ? $u['scheme'] . '://' : ''), 1492 (isset($u['host']) && '' != $u['host'] ? $u['host'] : ''), 1493 (isset($u['path']) && '' != $u['path'] ? $u['path'] : '/'), 1494 (isset($u['query']) && '' != $u['query'] ? '?' . $u['query'] : ''), 1495 (isset($u['fragment']) && '' != $u['fragment'] ? '#' . $u['fragment'] : '') 1496 ); 1467 1497 } 1468 1498
Note: See TracChangeset
for help on using the changeset viewer.