diff options
author | ArthurHoaro <arthur@hoa.ro> | 2019-07-27 12:34:30 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2019-07-27 12:34:30 +0200 |
commit | 38672ba0d1c722e5d6d33a58255ceb55e9410e46 (patch) | |
tree | dae4c7c47532380eac3ae641db99122fc77c93dc /application/api/controllers/Links.php | |
parent | 83faedadff76c5bdca036f39f13943f63b27e164 (diff) | |
parent | 1e77e0448bbd25675d8c0fe4a73206ad9048904b (diff) | |
download | Shaarli-38672ba0d1c722e5d6d33a58255ceb55e9410e46.tar.gz Shaarli-38672ba0d1c722e5d6d33a58255ceb55e9410e46.tar.zst Shaarli-38672ba0d1c722e5d6d33a58255ceb55e9410e46.zip |
Merge tag 'v0.10.4' into stable
Release v0.10.4
Diffstat (limited to 'application/api/controllers/Links.php')
-rw-r--r-- | application/api/controllers/Links.php | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/application/api/controllers/Links.php b/application/api/controllers/Links.php index eb78dd26..ffcfd4c7 100644 --- a/application/api/controllers/Links.php +++ b/application/api/controllers/Links.php | |||
@@ -59,25 +59,25 @@ class Links extends ApiController | |||
59 | $limit = $request->getParam('limit'); | 59 | $limit = $request->getParam('limit'); |
60 | if (empty($limit)) { | 60 | if (empty($limit)) { |
61 | $limit = self::$DEFAULT_LIMIT; | 61 | $limit = self::$DEFAULT_LIMIT; |
62 | } else if (ctype_digit($limit)) { | 62 | } elseif (ctype_digit($limit)) { |
63 | $limit = intval($limit); | 63 | $limit = intval($limit); |
64 | } else if ($limit === 'all') { | 64 | } elseif ($limit === 'all') { |
65 | $limit = count($links); | 65 | $limit = count($links); |
66 | } else { | 66 | } else { |
67 | throw new ApiBadParametersException('Invalid limit'); | 67 | throw new ApiBadParametersException('Invalid limit'); |
68 | } | 68 | } |
69 | 69 | ||
70 | // 'environment' is set by Slim and encapsulate $_SERVER. | 70 | // 'environment' is set by Slim and encapsulate $_SERVER. |
71 | $index = index_url($this->ci['environment']); | 71 | $indexUrl = index_url($this->ci['environment']); |
72 | 72 | ||
73 | $out = []; | 73 | $out = []; |
74 | $cpt = 0; | 74 | $index = 0; |
75 | foreach ($links as $link) { | 75 | foreach ($links as $link) { |
76 | if (count($out) >= $limit) { | 76 | if (count($out) >= $limit) { |
77 | break; | 77 | break; |
78 | } | 78 | } |
79 | if ($cpt++ >= $offset) { | 79 | if ($index++ >= $offset) { |
80 | $out[] = ApiUtils::formatLink($link, $index); | 80 | $out[] = ApiUtils::formatLink($link, $indexUrl); |
81 | } | 81 | } |
82 | } | 82 | } |
83 | 83 | ||