@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | |
44 | 44 | if (!empty($string)) { |
45 | 45 | $string = strip_tags($string); |
46 | - $result = (string)Stringy::create($string)->truncate($length, $substring); |
|
46 | + $result = (string) Stringy::create($string)->truncate($length, $substring); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | return $result; |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | |
68 | 68 | if (!empty($string)) { |
69 | 69 | $string = strip_tags($string); |
70 | - $result = (string)Stringy::create($string)->safeTruncate($length, $substring); |
|
70 | + $result = (string) Stringy::create($string)->safeTruncate($length, $substring); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | return $result; |
@@ -5,12 +5,12 @@ |
||
5 | 5 | ini_set('date.timezone', 'UTC'); |
6 | 6 | |
7 | 7 | // Use the current installation of Craft |
8 | -define('CRAFT_STORAGE_PATH', __DIR__ . '/_craft/storage'); |
|
9 | -define('CRAFT_TEMPLATES_PATH', __DIR__ . '/_craft/templates'); |
|
10 | -define('CRAFT_CONFIG_PATH', __DIR__ . '/_craft/config'); |
|
11 | -define('CRAFT_MIGRATIONS_PATH', __DIR__ . '/_craft/migrations'); |
|
12 | -define('CRAFT_TRANSLATIONS_PATH', __DIR__ . '/_craft/translations'); |
|
13 | -define('CRAFT_VENDOR_PATH', dirname(__DIR__) . '/vendor'); |
|
8 | +define('CRAFT_STORAGE_PATH', __DIR__.'/_craft/storage'); |
|
9 | +define('CRAFT_TEMPLATES_PATH', __DIR__.'/_craft/templates'); |
|
10 | +define('CRAFT_CONFIG_PATH', __DIR__.'/_craft/config'); |
|
11 | +define('CRAFT_MIGRATIONS_PATH', __DIR__.'/_craft/migrations'); |
|
12 | +define('CRAFT_TRANSLATIONS_PATH', __DIR__.'/_craft/translations'); |
|
13 | +define('CRAFT_VENDOR_PATH', dirname(__DIR__).'/vendor'); |
|
14 | 14 | define('CRAFT_TESTS_PATH', __DIR__); |
15 | 15 | |
16 | 16 | $devMode = true; |
@@ -102,14 +102,14 @@ discard block |
||
102 | 102 | if (strcmp($oldUri, $newUri) !== 0) { |
103 | 103 | // Handle trailing slash config setting |
104 | 104 | if (Craft::$app->config->general->addTrailingSlashesToUrls) { |
105 | - $oldUri = rtrim($oldUri, '/') . '/'; |
|
106 | - $newUri = rtrim($newUri, '/') . '/'; |
|
105 | + $oldUri = rtrim($oldUri, '/').'/'; |
|
106 | + $newUri = rtrim($newUri, '/').'/'; |
|
107 | 107 | } |
108 | 108 | // Handle the URL match type |
109 | 109 | if (Retour::$settings->uriChangeRedirectSrcMatch === 'fullurl') { |
110 | 110 | try { |
111 | 111 | if ($redirectSiteId !== null) { |
112 | - $redirectSiteId = (int)$redirectSiteId; |
|
112 | + $redirectSiteId = (int) $redirectSiteId; |
|
113 | 113 | } |
114 | 114 | $oldUri = \craft\helpers\UrlHelper::siteUrl($oldUri, null, null, $redirectSiteId); |
115 | 115 | $newUri = UrlHelper::siteUrl($newUri, null, null, $redirectSiteId); |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | 'siteId' => $redirectSiteId, |
128 | 128 | ]; |
129 | 129 | // Trigger a 'beforeSaveEntryRedirect' event |
130 | - $isNew = (int)$redirectConfig['id'] === 0; |
|
130 | + $isNew = (int) $redirectConfig['id'] === 0; |
|
131 | 131 | $event = new RedirectEvent([ |
132 | 132 | 'isNew' => $isNew, |
133 | 133 | 'legacyUrl' => $redirectConfig['redirectSrcUrl'], |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | public function getRecentStatistics($days = 1, $handled = false): array |
80 | 80 | { |
81 | 81 | // Ensure is an int |
82 | - $handledInt = (int)$handled; |
|
82 | + $handledInt = (int) $handled; |
|
83 | 83 | $stats = []; |
84 | 84 | $db = Craft::$app->getDb(); |
85 | 85 | if ($db->getIsMysql()) { |
@@ -210,9 +210,9 @@ discard block |
||
210 | 210 | $stats->userAgent = $userAgent; |
211 | 211 | $stats->exceptionMessage = $exceptionMessage; |
212 | 212 | $stats->exceptionFilePath = $exceptionFilePath; |
213 | - $stats->exceptionFileLine = (int)$exceptionFileLine; |
|
213 | + $stats->exceptionFileLine = (int) $exceptionFileLine; |
|
214 | 214 | $stats->hitLastTime = Db::prepareDateForDb(new \DateTime()); |
215 | - $stats->handledByRetour = (int)$handled; |
|
215 | + $stats->handledByRetour = (int) $handled; |
|
216 | 216 | $stats->hitCount++; |
217 | 217 | $statsConfig = $stats->getAttributes(); |
218 | 218 | // Record the updated statistics |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | $now = round(microtime(true) * 1000); |
357 | 357 | $cache = Craft::$app->getCache(); |
358 | 358 | $then = $cache->get(self::LAST_STATISTICS_TRIM_CACHE_KEY); |
359 | - if (($then !== false) && ($now - (int)$then < Retour::$settings->statisticsRateLimitMs)) { |
|
359 | + if (($then !== false) && ($now - (int) $then < Retour::$settings->statisticsRateLimitMs)) { |
|
360 | 360 | $limited = true; |
361 | 361 | } |
362 | 362 | $cache->set(self::LAST_STATISTICS_TRIM_CACHE_KEY, $now, 0); |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | 'COUNT(handledByRetour = 1 or null) as handled_cnt', |
82 | 82 | ]) |
83 | 83 | ->where("hitLastTime >= ( CURDATE() - INTERVAL '{$days}' DAY )"); |
84 | - if ((int)$siteId !== 0) { |
|
84 | + if ((int) $siteId !== 0) { |
|
85 | 85 | $query->andWhere(['siteId' => $siteId]); |
86 | 86 | } |
87 | 87 | $query |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | "COUNT(CASE WHEN \"handledByRetour\" = true THEN 1 END) as handled_cnt", |
100 | 100 | ]) |
101 | 101 | ->where("\"hitLastTime\" >= ( CURRENT_TIMESTAMP - INTERVAL '{$days} days' )"); |
102 | - if ((int)$siteId !== 0) { |
|
102 | + if ((int) $siteId !== 0) { |
|
103 | 103 | $query->andWhere(['siteId' => $siteId]); |
104 | 104 | } |
105 | 105 | $query |
@@ -163,8 +163,8 @@ discard block |
||
163 | 163 | } |
164 | 164 | if ($stats) { |
165 | 165 | $data = [ |
166 | - (int)$stats, |
|
167 | - (int)$handledStats, |
|
166 | + (int) $stats, |
|
167 | + (int) $handledStats, |
|
168 | 168 | ]; |
169 | 169 | } |
170 | 170 |
@@ -61,7 +61,7 @@ |
||
61 | 61 | /** @noinspection CallableParameterUseCaseInTypeContextInspection */ |
62 | 62 | $url = preg_replace('/{.*}/', '', $url); |
63 | 63 | // Remove any linebreaks that may be errantly in the URL |
64 | - $url = (string)str_replace([ |
|
64 | + $url = (string) str_replace([ |
|
65 | 65 | PHP_EOL, |
66 | 66 | "\r", |
67 | 67 | "\n", |
@@ -90,9 +90,9 @@ discard block |
||
90 | 90 | string $sort = 'hitCount|desc', |
91 | 91 | int $page = 1, |
92 | 92 | int $per_page = 20, |
93 | - $filter = '', |
|
94 | - $siteId = 0, |
|
95 | - $handled = 'all' |
|
93 | + $filter = '', |
|
94 | + $siteId = 0, |
|
95 | + $handled = 'all' |
|
96 | 96 | ): Response |
97 | 97 | { |
98 | 98 | PermissionHelper::controllerPermissionCheck('retour:dashboard'); |
@@ -186,9 +186,9 @@ discard block |
||
186 | 186 | string $sort = 'hitCount|desc', |
187 | 187 | int $page = 1, |
188 | 188 | int $per_page = 20, |
189 | - $filter = '', |
|
190 | - $siteId = 0, |
|
191 | - $shortLinks = false |
|
189 | + $filter = '', |
|
190 | + $siteId = 0, |
|
191 | + $shortLinks = false |
|
192 | 192 | ): Response |
193 | 193 | { |
194 | 194 | PermissionHelper::controllerPermissionCheck('retour:redirects'); |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | ->orderBy([$sortField => $sortType]) |
123 | 123 | ->filterWhere(['like', 'redirectSrcUrl', $filter]) |
124 | 124 | ->orFilterWhere(['like', 'referrerUrl', $filter]); |
125 | - if ((int)$siteId !== 0) { |
|
125 | + if ((int) $siteId !== 0) { |
|
126 | 126 | $query->andWhere(['siteId' => $siteId]); |
127 | 127 | } |
128 | 128 | if ($handled !== 'all') { |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | foreach ($stats as &$stat) { |
135 | 135 | $stat['addLink'] = ''; |
136 | 136 | if (!$stat['handledByRetour']) { |
137 | - $encodedUrl = urlencode('/' . ltrim($stat['redirectSrcUrl'], '/')); |
|
137 | + $encodedUrl = urlencode('/'.ltrim($stat['redirectSrcUrl'], '/')); |
|
138 | 138 | // Add the siteId to the URL, but keep the current behavior of passing in siteId=0 for "all" |
139 | 139 | $statSiteId = $stat['siteId'] ?? 0; |
140 | 140 | try { |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | } catch (SiteNotFoundException $e) { |
143 | 143 | $primarySite = null; |
144 | 144 | } |
145 | - if ($primarySite !== null && $statSiteId == (int)$primarySite->id) { |
|
145 | + if ($primarySite !== null && $statSiteId == (int) $primarySite->id) { |
|
146 | 146 | $statSiteId = 0; |
147 | 147 | } |
148 | 148 | $stat['addLink'] = UrlHelper::cpUrl('retour/add-redirect', [ |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | ->orderBy([$sortField => $sortType]) |
219 | 219 | ->filterWhere(['like', 'redirectSrcUrl', $filter]) |
220 | 220 | ->orFilterWhere(['like', 'redirectDestUrl', $filter]); |
221 | - if ((int)$siteId !== 0) { |
|
221 | + if ((int) $siteId !== 0) { |
|
222 | 222 | $query->andWhere(['siteId' => $siteId]); |
223 | 223 | } |
224 | 224 | if ($shortLinks) { |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | } |
246 | 246 | } |
247 | 247 | |
248 | - $redirect['editLink'] = UrlHelper::cpUrl('retour/edit-redirect/' . $redirect['id']); |
|
248 | + $redirect['editLink'] = UrlHelper::cpUrl('retour/edit-redirect/'.$redirect['id']); |
|
249 | 249 | } |
250 | 250 | // Format the data for the API |
251 | 251 | if ($redirects) { |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | $variables['docsUrl'] = self::DOCUMENTATION_URL; |
82 | 82 | $variables['pluginName'] = $pluginName; |
83 | 83 | $variables['title'] = $templateTitle; |
84 | - $siteHandleUri = Craft::$app->isMultiSite ? '/' . $siteHandle : ''; |
|
84 | + $siteHandleUri = Craft::$app->isMultiSite ? '/'.$siteHandle : ''; |
|
85 | 85 | $variables['crumbs'] = [ |
86 | 86 | [ |
87 | 87 | 'label' => $pluginName, |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | ], |
90 | 90 | [ |
91 | 91 | 'label' => $templateTitle, |
92 | - 'url' => UrlHelper::cpUrl('retour/redirects' . $siteHandleUri), |
|
92 | + 'url' => UrlHelper::cpUrl('retour/redirects'.$siteHandleUri), |
|
93 | 93 | ], |
94 | 94 | ]; |
95 | 95 | $variables['docTitle'] = "{$pluginName} - {$templateTitle}"; |
@@ -150,13 +150,13 @@ discard block |
||
150 | 150 | if ($redirect->siteId) { |
151 | 151 | $site = $sites->getSiteById($redirect->siteId); |
152 | 152 | if ($site) { |
153 | - MultiSiteHelper::requirePermission('editSite:' . $site->uid); |
|
153 | + MultiSiteHelper::requirePermission('editSite:'.$site->uid); |
|
154 | 154 | } |
155 | 155 | } |
156 | 156 | if ($siteId) { |
157 | 157 | $site = $sites->getSiteById($siteId); |
158 | 158 | if ($site) { |
159 | - MultiSiteHelper::requirePermission('editSite:' . $site->uid); |
|
159 | + MultiSiteHelper::requirePermission('editSite:'.$site->uid); |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 | $pluginName = Retour::$settings->pluginName; |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | ], |
193 | 193 | [ |
194 | 194 | 'label' => $templateTitle, |
195 | - 'url' => UrlHelper::cpUrl('retour/edit-redirect/' . $redirectId), |
|
195 | + 'url' => UrlHelper::cpUrl('retour/edit-redirect/'.$redirectId), |
|
196 | 196 | ], |
197 | 197 | ]; |
198 | 198 | $variables['docTitle'] = "{$pluginName} - Redirects - {$templateTitle}"; |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | if ($redirectConfig === null) { |
251 | 251 | throw new NotFoundHttpException('Redirect not found'); |
252 | 252 | } |
253 | - $redirectConfig['id'] = (int)$redirectConfig['id']; |
|
253 | + $redirectConfig['id'] = (int) $redirectConfig['id']; |
|
254 | 254 | // Handle enforcing trailing slashes |
255 | 255 | $generalConfig = Craft::$app->getConfig()->getGeneral(); |
256 | 256 | if ($generalConfig->addTrailingSlashesToUrls && $redirectConfig['redirectMatchType'] === 'exactmatch') { |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | $variables['docsUrl'] = self::DOCUMENTATION_URL; |
335 | 335 | $variables['pluginName'] = $pluginName; |
336 | 336 | $variables['title'] = $templateTitle; |
337 | - $siteHandleUri = Craft::$app->isMultiSite ? '/' . $siteHandle : ''; |
|
337 | + $siteHandleUri = Craft::$app->isMultiSite ? '/'.$siteHandle : ''; |
|
338 | 338 | $variables['crumbs'] = [ |
339 | 339 | [ |
340 | 340 | 'label' => $pluginName, |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | ], |
343 | 343 | [ |
344 | 344 | 'label' => $templateTitle, |
345 | - 'url' => UrlHelper::cpUrl('retour/shortlinks' . $siteHandleUri), |
|
345 | + 'url' => UrlHelper::cpUrl('retour/shortlinks'.$siteHandleUri), |
|
346 | 346 | ], |
347 | 347 | ]; |
348 | 348 | $variables['docTitle'] = "{$pluginName} - {$templateTitle}"; |
@@ -397,13 +397,13 @@ discard block |
||
397 | 397 | if (!preg_match('/\.[^\/]+$/', $url) && strpos($url, '?') === false) { |
398 | 398 | // If it's a root relative URL, assume it's a site URL |
399 | 399 | if (UrlHelper::isRootRelativeUrl($url)) { |
400 | - return rtrim($url, '/') . '/'; |
|
400 | + return rtrim($url, '/').'/'; |
|
401 | 401 | } |
402 | 402 | // If the URL matches any of the site's base URLs, assume it's a site URL |
403 | 403 | $sites = Craft::$app->getSites()->getAllSites(); |
404 | 404 | foreach ($sites as $site) { |
405 | 405 | if (strpos($url, $site->getBaseUrl()) === 0) { |
406 | - return rtrim($url, '/') . '/'; |
|
406 | + return rtrim($url, '/').'/'; |
|
407 | 407 | } |
408 | 408 | } |
409 | 409 | } |
@@ -60,7 +60,7 @@ |
||
60 | 60 | return; |
61 | 61 | } |
62 | 62 | // Make sure there is a leading / |
63 | - $value = '/' . ltrim($value, '/'); |
|
63 | + $value = '/'.ltrim($value, '/'); |
|
64 | 64 | $model->$attribute = $value; |
65 | 65 | } |
66 | 66 | } |