mirror of
https://github.com/friendica/friendica
synced 2025-04-26 18:30:11 +00:00
Merge branch 'develop' into task/3954-move-auth-to-src
This commit is contained in:
commit
9a3e773a9a
54 changed files with 2172 additions and 2028 deletions
57
boot.php
57
boot.php
|
@ -573,6 +573,51 @@ function x($s, $k = null)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the provided variable value if it exists and is truthy or the provided
|
||||
* default value instead.
|
||||
*
|
||||
* Works with initialized variables and potentially uninitialized array keys
|
||||
*
|
||||
* Usages:
|
||||
* - defaults($var, $default)
|
||||
* - defaults($array, 'key', $default)
|
||||
*
|
||||
* @brief Returns a defaut value if the provided variable or array key is falsy
|
||||
* @see x()
|
||||
* @return mixed
|
||||
*/
|
||||
function defaults() {
|
||||
$args = func_get_args();
|
||||
|
||||
if (count($args) < 2) {
|
||||
throw new BadFunctionCallException('defaults() requires at least 2 parameters');
|
||||
}
|
||||
if (count($args) > 3) {
|
||||
throw new BadFunctionCallException('defaults() cannot use more than 3 parameters');
|
||||
}
|
||||
if (count($args) === 3 && !is_array($args[0])) {
|
||||
throw new BadFunctionCallException('defaults($arr, $key, $def) requires an array as first parameter');
|
||||
}
|
||||
if (count($args) === 3 && is_null($args[1])) {
|
||||
throw new BadFunctionCallException('defaults($arr, $key, $def) $key is null');
|
||||
}
|
||||
|
||||
$default = array_pop($args);
|
||||
|
||||
if (call_user_func_array('x', $args)) {
|
||||
if (count($args) === 1) {
|
||||
$return = $args[0];
|
||||
} else {
|
||||
$return = $args[0][$args[1]];
|
||||
}
|
||||
} else {
|
||||
$return = $default;
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns the baseurl.
|
||||
*
|
||||
|
@ -1516,14 +1561,11 @@ function argv($x)
|
|||
function infinite_scroll_data($module)
|
||||
{
|
||||
if (PConfig::get(local_user(), 'system', 'infinite_scroll')
|
||||
&& ($module == "network") && ($_GET["mode"] != "minimal")
|
||||
&& $module == 'network'
|
||||
&& defaults($_GET, 'mode', '') != 'minimal'
|
||||
) {
|
||||
// get the page number
|
||||
if (is_string($_GET["page"])) {
|
||||
$pageno = $_GET["page"];
|
||||
} else {
|
||||
$pageno = 1;
|
||||
}
|
||||
$pageno = defaults($_GET, 'page', 1);
|
||||
|
||||
$reload_uri = "";
|
||||
|
||||
|
@ -1534,7 +1576,8 @@ function infinite_scroll_data($module)
|
|||
}
|
||||
}
|
||||
|
||||
if (($a->page_offset != "") && ! strstr($reload_uri, "&offset=")) {
|
||||
$a = get_app();
|
||||
if ($a->page_offset != "" && !strstr($reload_uri, "&offset=")) {
|
||||
$reload_uri .= "&offset=" . urlencode($a->page_offset);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue