@@ -46,32 +46,32 @@ discard block |
||
| 46 | 46 | const DOCUMENTATION_URL = 'https://github.com/nystudio107/craft-seomatic/wiki'; |
| 47 | 47 | |
| 48 | 48 | const PULL_TEXT_FIELDS = [ |
| 49 | - ['fieldName' => 'seoTitle', 'seoField' => 'seoTitle'], |
|
| 50 | - ['fieldName' => 'seoDescription', 'seoField' => 'seoDescription'], |
|
| 51 | - ['fieldName' => 'seoKeywords', 'seoField' => 'seoKeywords'], |
|
| 52 | - ['fieldName' => 'seoImageDescription', 'seoField' => 'seoImageDescription'], |
|
| 53 | - ['fieldName' => 'ogTitle', 'seoField' => 'seoTitle'], |
|
| 54 | - ['fieldName' => 'ogSiteNamePosition', 'seoField' => 'siteNamePosition'], |
|
| 55 | - ['fieldName' => 'ogDescription', 'seoField' => 'seoDescription'], |
|
| 56 | - ['fieldName' => 'ogImageDescription', 'seoField' => 'seoImageDescription'], |
|
| 57 | - ['fieldName' => 'twitterTitle', 'seoField' => 'seoTitle'], |
|
| 58 | - ['fieldName' => 'twitterSiteNamePosition', 'seoField' => 'siteNamePosition'], |
|
| 59 | - ['fieldName' => 'twitterCreator', 'seoField' => 'twitterHandle'], |
|
| 60 | - ['fieldName' => 'twitterDescription', 'seoField' => 'seoDescription'], |
|
| 61 | - ['fieldName' => 'twitterImageDescription', 'seoField' => 'seoImageDescription'], |
|
| 49 | + [ 'fieldName' => 'seoTitle', 'seoField' => 'seoTitle' ], |
|
| 50 | + [ 'fieldName' => 'seoDescription', 'seoField' => 'seoDescription' ], |
|
| 51 | + [ 'fieldName' => 'seoKeywords', 'seoField' => 'seoKeywords' ], |
|
| 52 | + [ 'fieldName' => 'seoImageDescription', 'seoField' => 'seoImageDescription' ], |
|
| 53 | + [ 'fieldName' => 'ogTitle', 'seoField' => 'seoTitle' ], |
|
| 54 | + [ 'fieldName' => 'ogSiteNamePosition', 'seoField' => 'siteNamePosition' ], |
|
| 55 | + [ 'fieldName' => 'ogDescription', 'seoField' => 'seoDescription' ], |
|
| 56 | + [ 'fieldName' => 'ogImageDescription', 'seoField' => 'seoImageDescription' ], |
|
| 57 | + [ 'fieldName' => 'twitterTitle', 'seoField' => 'seoTitle' ], |
|
| 58 | + [ 'fieldName' => 'twitterSiteNamePosition', 'seoField' => 'siteNamePosition' ], |
|
| 59 | + [ 'fieldName' => 'twitterCreator', 'seoField' => 'twitterHandle' ], |
|
| 60 | + [ 'fieldName' => 'twitterDescription', 'seoField' => 'seoDescription' ], |
|
| 61 | + [ 'fieldName' => 'twitterImageDescription', 'seoField' => 'seoImageDescription' ], |
|
| 62 | 62 | ]; |
| 63 | 63 | |
| 64 | 64 | const PULL_ASSET_FIELDS = [ |
| 65 | - ['fieldName' => 'seoImage', 'seoField' => 'seoImage', 'transformName' => 'base'], |
|
| 66 | - ['fieldName' => 'ogImage', 'seoField' => 'seoImage', 'transformName' => 'facebook'], |
|
| 67 | - ['fieldName' => 'twitterImage', 'seoField' => 'seoImage', 'transformName' => 'twitter'], |
|
| 65 | + [ 'fieldName' => 'seoImage', 'seoField' => 'seoImage', 'transformName' => 'base' ], |
|
| 66 | + [ 'fieldName' => 'ogImage', 'seoField' => 'seoImage', 'transformName' => 'facebook' ], |
|
| 67 | + [ 'fieldName' => 'twitterImage', 'seoField' => 'seoImage', 'transformName' => 'twitter' ], |
|
| 68 | 68 | ]; |
| 69 | 69 | |
| 70 | 70 | const SETUP_GRADES = [ |
| 71 | - ['id' => 'data1', 'name' => 'A', 'color' => '#008002'], |
|
| 72 | - ['id' => 'data2', 'name' => 'B', 'color' => '#9ACD31'], |
|
| 73 | - ['id' => 'data4', 'name' => 'C', 'color' => '#FFA500'], |
|
| 74 | - ['id' => 'data5', 'name' => 'D', 'color' => '#8B0100'], |
|
| 71 | + [ 'id' => 'data1', 'name' => 'A', 'color' => '#008002' ], |
|
| 72 | + [ 'id' => 'data2', 'name' => 'B', 'color' => '#9ACD31' ], |
|
| 73 | + [ 'id' => 'data4', 'name' => 'C', 'color' => '#FFA500' ], |
|
| 74 | + [ 'id' => 'data5', 'name' => 'D', 'color' => '#8B0100' ], |
|
| 75 | 75 | ]; |
| 76 | 76 | |
| 77 | 77 | const SEO_SETUP_FIELDS = [ |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | */ |
| 113 | 113 | public function actionDashboard(string $siteHandle = null, bool $showWelcome = false): Response |
| 114 | 114 | { |
| 115 | - $variables = []; |
|
| 115 | + $variables = [ ]; |
|
| 116 | 116 | // Get the site to edit |
| 117 | 117 | $siteId = $this->getSiteIdFromHandle($siteHandle); |
| 118 | 118 | $pluginName = Seomatic::$settings->pluginName; |
@@ -124,20 +124,20 @@ discard block |
||
| 124 | 124 | } catch (InvalidConfigException $e) { |
| 125 | 125 | Craft::error($e->getMessage(), __METHOD__); |
| 126 | 126 | } |
| 127 | - $variables['baseAssetsUrl'] = Craft::$app->assetManager->getPublishedUrl( |
|
| 127 | + $variables[ 'baseAssetsUrl' ] = Craft::$app->assetManager->getPublishedUrl( |
|
| 128 | 128 | '@nystudio107/seomatic/assetbundles/seomatic/dist', |
| 129 | 129 | true |
| 130 | 130 | ); |
| 131 | 131 | // Enabled sites |
| 132 | 132 | $this->setMultiSiteVariables($siteHandle, $siteId, $variables); |
| 133 | - $variables['controllerHandle'] = 'dashboard'; |
|
| 133 | + $variables[ 'controllerHandle' ] = 'dashboard'; |
|
| 134 | 134 | |
| 135 | 135 | // Basic variables |
| 136 | - $variables['fullPageForm'] = false; |
|
| 137 | - $variables['docsUrl'] = self::DOCUMENTATION_URL; |
|
| 138 | - $variables['pluginName'] = Seomatic::$settings->pluginName; |
|
| 139 | - $variables['title'] = $templateTitle; |
|
| 140 | - $variables['crumbs'] = [ |
|
| 136 | + $variables[ 'fullPageForm' ] = false; |
|
| 137 | + $variables[ 'docsUrl' ] = self::DOCUMENTATION_URL; |
|
| 138 | + $variables[ 'pluginName' ] = Seomatic::$settings->pluginName; |
|
| 139 | + $variables[ 'title' ] = $templateTitle; |
|
| 140 | + $variables[ 'crumbs' ] = [ |
|
| 141 | 141 | [ |
| 142 | 142 | 'label' => $pluginName, |
| 143 | 143 | 'url' => UrlHelper::cpUrl('seomatic'), |
@@ -147,60 +147,60 @@ discard block |
||
| 147 | 147 | 'url' => UrlHelper::cpUrl('seomatic/dashboard'), |
| 148 | 148 | ], |
| 149 | 149 | ]; |
| 150 | - $variables['selectedSubnavItem'] = 'dashboard'; |
|
| 151 | - $variables['showWelcome'] = $showWelcome; |
|
| 150 | + $variables[ 'selectedSubnavItem' ] = 'dashboard'; |
|
| 151 | + $variables[ 'showWelcome' ] = $showWelcome; |
|
| 152 | 152 | // Calulate the setup grades |
| 153 | - $variables['contentSetupStats'] = []; |
|
| 154 | - $variables['globalSetupStats'] = []; |
|
| 155 | - $variables['setupGrades'] = self::SETUP_GRADES; |
|
| 153 | + $variables[ 'contentSetupStats' ] = [ ]; |
|
| 154 | + $variables[ 'globalSetupStats' ] = [ ]; |
|
| 155 | + $variables[ 'setupGrades' ] = self::SETUP_GRADES; |
|
| 156 | 156 | $numFields = count(self::SEO_SETUP_FIELDS); |
| 157 | 157 | $numGrades = count(self::SETUP_GRADES); |
| 158 | 158 | while ($numGrades--) { |
| 159 | - $variables['contentSetupStats'][] = 0; |
|
| 160 | - $variables['globalSetupStats'][] = 0; |
|
| 159 | + $variables[ 'contentSetupStats' ][ ] = 0; |
|
| 160 | + $variables[ 'globalSetupStats' ][ ] = 0; |
|
| 161 | 161 | } |
| 162 | 162 | $numGrades = count(self::SETUP_GRADES); |
| 163 | 163 | // Content SEO grades |
| 164 | - $variables['metaBundles'] = Seomatic::$plugin->metaBundles->getContentMetaBundlesForSiteId($siteId); |
|
| 164 | + $variables[ 'metaBundles' ] = Seomatic::$plugin->metaBundles->getContentMetaBundlesForSiteId($siteId); |
|
| 165 | 165 | /** @var MetaBundle $metaBundle */ |
| 166 | - foreach ($variables['metaBundles'] as $metaBundle) { |
|
| 166 | + foreach ($variables[ 'metaBundles' ] as $metaBundle) { |
|
| 167 | 167 | $stat = 0; |
| 168 | 168 | foreach (self::SEO_SETUP_FIELDS as $setupField) { |
| 169 | - $stat += intval(!empty($metaBundle->metaGlobalVars[$setupField])); |
|
| 169 | + $stat += intval(!empty($metaBundle->metaGlobalVars[ $setupField ])); |
|
| 170 | 170 | } |
| 171 | 171 | $stat = round($numGrades - (($stat * $numGrades) / $numFields)); |
| 172 | 172 | if ($stat >= $numGrades) { |
| 173 | 173 | $stat = $numGrades - 1; |
| 174 | 174 | } |
| 175 | - $variables['contentSetupStats'][$stat]++; |
|
| 175 | + $variables[ 'contentSetupStats' ][ $stat ]++; |
|
| 176 | 176 | } |
| 177 | 177 | // Global SEO grades |
| 178 | 178 | $metaBundle = Seomatic::$plugin->metaBundles->getGlobalMetaBundle(intval($siteId)); |
| 179 | 179 | $stat = 0; |
| 180 | 180 | foreach (self::SEO_SETUP_FIELDS as $setupField) { |
| 181 | - $stat += intval(!empty($metaBundle->metaGlobalVars[$setupField])); |
|
| 181 | + $stat += intval(!empty($metaBundle->metaGlobalVars[ $setupField ])); |
|
| 182 | 182 | } |
| 183 | 183 | $stat = round($numGrades - (($stat * $numGrades) / $numFields)); |
| 184 | 184 | if ($stat >= $numGrades) { |
| 185 | 185 | $stat = $numGrades - 1; |
| 186 | 186 | } |
| 187 | - $variables['globalSetupStats'][$stat]++; |
|
| 187 | + $variables[ 'globalSetupStats' ][ $stat ]++; |
|
| 188 | 188 | // Site Settings grades |
| 189 | 189 | $numFields = count(self::SITE_SETUP_FIELDS); |
| 190 | 190 | $numGrades = count(self::SETUP_GRADES); |
| 191 | 191 | while ($numGrades--) { |
| 192 | - $variables['siteSetupStats'][] = 0; |
|
| 192 | + $variables[ 'siteSetupStats' ][ ] = 0; |
|
| 193 | 193 | } |
| 194 | 194 | $numGrades = count(self::SETUP_GRADES); |
| 195 | 195 | $stat = 0; |
| 196 | 196 | foreach (self::SITE_SETUP_FIELDS as $setupField) { |
| 197 | - $stat += intval(!empty($metaBundle->metaSiteVars[$setupField])); |
|
| 197 | + $stat += intval(!empty($metaBundle->metaSiteVars[ $setupField ])); |
|
| 198 | 198 | } |
| 199 | 199 | $stat = round($numGrades - (($stat * $numGrades) / $numFields)); |
| 200 | 200 | if ($stat >= $numGrades) { |
| 201 | 201 | $stat = $numGrades - 1; |
| 202 | 202 | } |
| 203 | - $variables['siteSetupStats'][$stat]++; |
|
| 203 | + $variables[ 'siteSetupStats' ][ $stat ]++; |
|
| 204 | 204 | |
| 205 | 205 | // Render the template |
| 206 | 206 | return $this->renderTemplate('seomatic/dashboard/index', $variables); |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | */ |
| 219 | 219 | public function actionGlobal(string $subSection = 'general', string $siteHandle = null): Response |
| 220 | 220 | { |
| 221 | - $variables = []; |
|
| 221 | + $variables = [ ]; |
|
| 222 | 222 | $siteId = $this->getSiteIdFromHandle($siteHandle); |
| 223 | 223 | |
| 224 | 224 | $pluginName = Seomatic::$settings->pluginName; |
@@ -230,18 +230,18 @@ discard block |
||
| 230 | 230 | } catch (InvalidConfigException $e) { |
| 231 | 231 | Craft::error($e->getMessage(), __METHOD__); |
| 232 | 232 | } |
| 233 | - $variables['baseAssetsUrl'] = Craft::$app->assetManager->getPublishedUrl( |
|
| 233 | + $variables[ 'baseAssetsUrl' ] = Craft::$app->assetManager->getPublishedUrl( |
|
| 234 | 234 | '@nystudio107/seomatic/assetbundles/seomatic/dist', |
| 235 | 235 | true |
| 236 | 236 | ); |
| 237 | 237 | // Basic variables |
| 238 | - $variables['fullPageForm'] = true; |
|
| 239 | - $variables['docsUrl'] = self::DOCUMENTATION_URL; |
|
| 240 | - $variables['pluginName'] = Seomatic::$settings->pluginName; |
|
| 241 | - $variables['title'] = $templateTitle; |
|
| 242 | - $variables['subSectionTitle'] = $subSectionTitle; |
|
| 243 | - $variables['docTitle'] = $templateTitle.' - '.$subSectionTitle; |
|
| 244 | - $variables['crumbs'] = [ |
|
| 238 | + $variables[ 'fullPageForm' ] = true; |
|
| 239 | + $variables[ 'docsUrl' ] = self::DOCUMENTATION_URL; |
|
| 240 | + $variables[ 'pluginName' ] = Seomatic::$settings->pluginName; |
|
| 241 | + $variables[ 'title' ] = $templateTitle; |
|
| 242 | + $variables[ 'subSectionTitle' ] = $subSectionTitle; |
|
| 243 | + $variables[ 'docTitle' ] = $templateTitle . ' - ' . $subSectionTitle; |
|
| 244 | + $variables[ 'crumbs' ] = [ |
|
| 245 | 245 | [ |
| 246 | 246 | 'label' => $pluginName, |
| 247 | 247 | 'url' => UrlHelper::cpUrl('seomatic'), |
@@ -252,39 +252,39 @@ discard block |
||
| 252 | 252 | ], |
| 253 | 253 | [ |
| 254 | 254 | 'label' => $subSectionTitle, |
| 255 | - 'url' => UrlHelper::cpUrl('seomatic/global/'.$subSection), |
|
| 255 | + 'url' => UrlHelper::cpUrl('seomatic/global/' . $subSection), |
|
| 256 | 256 | ], |
| 257 | 257 | ]; |
| 258 | - $variables['selectedSubnavItem'] = 'global'; |
|
| 258 | + $variables[ 'selectedSubnavItem' ] = 'global'; |
|
| 259 | 259 | // Pass in the pull fields |
| 260 | 260 | $this->setGlobalFieldSourceVariables($variables); |
| 261 | 261 | // Enabled sites |
| 262 | 262 | $this->setMultiSiteVariables($siteHandle, $siteId, $variables); |
| 263 | - $variables['controllerHandle'] = 'global'.'/'.$subSection; |
|
| 264 | - $variables['currentSubSection'] = $subSection; |
|
| 263 | + $variables[ 'controllerHandle' ] = 'global' . '/' . $subSection; |
|
| 264 | + $variables[ 'currentSubSection' ] = $subSection; |
|
| 265 | 265 | // Meta bundle settings |
| 266 | - $metaBundle = Seomatic::$plugin->metaBundles->getGlobalMetaBundle(intval($variables['currentSiteId'])); |
|
| 267 | - $variables['globals'] = $metaBundle->metaGlobalVars; |
|
| 268 | - $variables['sitemap'] = $metaBundle->metaSitemapVars; |
|
| 269 | - $variables['settings'] = $metaBundle->metaBundleSettings; |
|
| 266 | + $metaBundle = Seomatic::$plugin->metaBundles->getGlobalMetaBundle(intval($variables[ 'currentSiteId' ])); |
|
| 267 | + $variables[ 'globals' ] = $metaBundle->metaGlobalVars; |
|
| 268 | + $variables[ 'sitemap' ] = $metaBundle->metaSitemapVars; |
|
| 269 | + $variables[ 'settings' ] = $metaBundle->metaBundleSettings; |
|
| 270 | 270 | // Template container settings |
| 271 | 271 | $templateContainers = $metaBundle->frontendTemplatesContainer->data; |
| 272 | - $variables['robotsTemplate'] = $templateContainers[FrontendTemplates::ROBOTS_TXT_HANDLE]; |
|
| 273 | - $variables['humansTemplate'] = $templateContainers[FrontendTemplates::HUMANS_TXT_HANDLE]; |
|
| 272 | + $variables[ 'robotsTemplate' ] = $templateContainers[ FrontendTemplates::ROBOTS_TXT_HANDLE ]; |
|
| 273 | + $variables[ 'humansTemplate' ] = $templateContainers[ FrontendTemplates::HUMANS_TXT_HANDLE ]; |
|
| 274 | 274 | // Image selectors |
| 275 | 275 | $bundleSettings = $metaBundle->metaBundleSettings; |
| 276 | - $variables['elementType'] = Asset::class; |
|
| 277 | - $variables['seoImageElements'] = $this->assetElementsFromIds($bundleSettings->seoImageIds, $siteId); |
|
| 278 | - $variables['twitterImageElements'] = $this->assetElementsFromIds($bundleSettings->twitterImageIds, $siteId); |
|
| 279 | - $variables['ogImageElements'] = $this->assetElementsFromIds($bundleSettings->ogImageIds, $siteId); |
|
| 276 | + $variables[ 'elementType' ] = Asset::class; |
|
| 277 | + $variables[ 'seoImageElements' ] = $this->assetElementsFromIds($bundleSettings->seoImageIds, $siteId); |
|
| 278 | + $variables[ 'twitterImageElements' ] = $this->assetElementsFromIds($bundleSettings->twitterImageIds, $siteId); |
|
| 279 | + $variables[ 'ogImageElements' ] = $this->assetElementsFromIds($bundleSettings->ogImageIds, $siteId); |
|
| 280 | 280 | // Preview the meta containers |
| 281 | 281 | Seomatic::$plugin->metaContainers->previewMetaContainers( |
| 282 | 282 | MetaBundles::GLOBAL_META_BUNDLE, |
| 283 | - intval($variables['currentSiteId']) |
|
| 283 | + intval($variables[ 'currentSiteId' ]) |
|
| 284 | 284 | ); |
| 285 | 285 | |
| 286 | 286 | // Render the template |
| 287 | - return $this->renderTemplate('seomatic/settings/global/'.$subSection, $variables); |
|
| 287 | + return $this->renderTemplate('seomatic/settings/global/' . $subSection, $variables); |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | /** |
@@ -314,11 +314,11 @@ discard block |
||
| 314 | 314 | $metaBundle->metaBundleSettings->setAttributes($bundleSettings); |
| 315 | 315 | } |
| 316 | 316 | $templateContainers = $metaBundle->frontendTemplatesContainer->data; |
| 317 | - $robotsContainer = $templateContainers[FrontendTemplates::ROBOTS_TXT_HANDLE]; |
|
| 317 | + $robotsContainer = $templateContainers[ FrontendTemplates::ROBOTS_TXT_HANDLE ]; |
|
| 318 | 318 | if (!empty($robotsContainer) && is_array($robotsTemplate)) { |
| 319 | 319 | $robotsContainer->setAttributes($robotsTemplate); |
| 320 | 320 | } |
| 321 | - $humansContainer = $templateContainers[FrontendTemplates::HUMANS_TXT_HANDLE]; |
|
| 321 | + $humansContainer = $templateContainers[ FrontendTemplates::HUMANS_TXT_HANDLE ]; |
|
| 322 | 322 | if (!empty($humansContainer) && is_array($humansTemplate)) { |
| 323 | 323 | $humansContainer->setAttributes($humansTemplate); |
| 324 | 324 | } |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | */ |
| 344 | 344 | public function actionContent(string $siteHandle = null): Response |
| 345 | 345 | { |
| 346 | - $variables = []; |
|
| 346 | + $variables = [ ]; |
|
| 347 | 347 | // Get the site to edit |
| 348 | 348 | $siteId = $this->getSiteIdFromHandle($siteHandle); |
| 349 | 349 | |
@@ -355,16 +355,16 @@ discard block |
||
| 355 | 355 | } catch (InvalidConfigException $e) { |
| 356 | 356 | Craft::error($e->getMessage(), __METHOD__); |
| 357 | 357 | } |
| 358 | - $variables['baseAssetsUrl'] = Craft::$app->assetManager->getPublishedUrl( |
|
| 358 | + $variables[ 'baseAssetsUrl' ] = Craft::$app->assetManager->getPublishedUrl( |
|
| 359 | 359 | '@nystudio107/seomatic/assetbundles/seomatic/dist', |
| 360 | 360 | true |
| 361 | 361 | ); |
| 362 | 362 | // Basic variables |
| 363 | - $variables['fullPageForm'] = false; |
|
| 364 | - $variables['docsUrl'] = self::DOCUMENTATION_URL; |
|
| 365 | - $variables['pluginName'] = Seomatic::$settings->pluginName; |
|
| 366 | - $variables['title'] = $templateTitle; |
|
| 367 | - $variables['crumbs'] = [ |
|
| 363 | + $variables[ 'fullPageForm' ] = false; |
|
| 364 | + $variables[ 'docsUrl' ] = self::DOCUMENTATION_URL; |
|
| 365 | + $variables[ 'pluginName' ] = Seomatic::$settings->pluginName; |
|
| 366 | + $variables[ 'title' ] = $templateTitle; |
|
| 367 | + $variables[ 'crumbs' ] = [ |
|
| 368 | 368 | [ |
| 369 | 369 | 'label' => $pluginName, |
| 370 | 370 | 'url' => UrlHelper::cpUrl('seomatic'), |
@@ -375,9 +375,9 @@ discard block |
||
| 375 | 375 | ], |
| 376 | 376 | ]; |
| 377 | 377 | $this->setMultiSiteVariables($siteHandle, $siteId, $variables); |
| 378 | - $variables['controllerHandle'] = 'content'; |
|
| 379 | - $variables['selectedSubnavItem'] = 'content'; |
|
| 380 | - $variables['metaBundles'] = Seomatic::$plugin->metaBundles->getContentMetaBundlesForSiteId($siteId); |
|
| 378 | + $variables[ 'controllerHandle' ] = 'content'; |
|
| 379 | + $variables[ 'selectedSubnavItem' ] = 'content'; |
|
| 380 | + $variables[ 'metaBundles' ] = Seomatic::$plugin->metaBundles->getContentMetaBundlesForSiteId($siteId); |
|
| 381 | 381 | |
| 382 | 382 | // Render the template |
| 383 | 383 | return $this->renderTemplate('seomatic/settings/content/index', $variables); |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | string $sourceHandle, |
| 402 | 402 | string $siteHandle = null |
| 403 | 403 | ): Response { |
| 404 | - $variables = []; |
|
| 404 | + $variables = [ ]; |
|
| 405 | 405 | // @TODO: Let people choose an entry/categorygroup/product as the preview |
| 406 | 406 | // Get the site to edit |
| 407 | 407 | $siteId = $this->getSiteIdFromHandle($siteHandle); |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | } catch (InvalidConfigException $e) { |
| 414 | 414 | Craft::error($e->getMessage(), __METHOD__); |
| 415 | 415 | } |
| 416 | - $variables['baseAssetsUrl'] = Craft::$app->assetManager->getPublishedUrl( |
|
| 416 | + $variables[ 'baseAssetsUrl' ] = Craft::$app->assetManager->getPublishedUrl( |
|
| 417 | 417 | '@nystudio107/seomatic/assetbundles/seomatic/dist', |
| 418 | 418 | true |
| 419 | 419 | ); |
@@ -423,22 +423,22 @@ discard block |
||
| 423 | 423 | $metaBundle = Seomatic::$plugin->metaBundles->getMetaBundleBySourceHandle( |
| 424 | 424 | $sourceBundleType, |
| 425 | 425 | $sourceHandle, |
| 426 | - intval($variables['currentSiteId']) |
|
| 426 | + intval($variables[ 'currentSiteId' ]) |
|
| 427 | 427 | ); |
| 428 | - $variables['globals'] = $metaBundle->metaGlobalVars; |
|
| 429 | - $variables['sitemap'] = $metaBundle->metaSitemapVars; |
|
| 430 | - $variables['settings'] = $metaBundle->metaBundleSettings; |
|
| 431 | - $variables['currentSourceHandle'] = $metaBundle->sourceHandle; |
|
| 432 | - $variables['currentSourceBundleType'] = $metaBundle->sourceBundleType; |
|
| 428 | + $variables[ 'globals' ] = $metaBundle->metaGlobalVars; |
|
| 429 | + $variables[ 'sitemap' ] = $metaBundle->metaSitemapVars; |
|
| 430 | + $variables[ 'settings' ] = $metaBundle->metaBundleSettings; |
|
| 431 | + $variables[ 'currentSourceHandle' ] = $metaBundle->sourceHandle; |
|
| 432 | + $variables[ 'currentSourceBundleType' ] = $metaBundle->sourceBundleType; |
|
| 433 | 433 | // Basic variables |
| 434 | 434 | $templateTitle = $metaBundle->sourceName; |
| 435 | 435 | $subSectionTitle = Craft::t('seomatic', ucfirst($subSection)); |
| 436 | - $variables['fullPageForm'] = true; |
|
| 437 | - $variables['docsUrl'] = self::DOCUMENTATION_URL; |
|
| 438 | - $variables['pluginName'] = Seomatic::$settings->pluginName; |
|
| 439 | - $variables['title'] = $templateTitle; |
|
| 440 | - $variables['subSectionTitle'] = $subSectionTitle; |
|
| 441 | - $variables['crumbs'] = [ |
|
| 436 | + $variables[ 'fullPageForm' ] = true; |
|
| 437 | + $variables[ 'docsUrl' ] = self::DOCUMENTATION_URL; |
|
| 438 | + $variables[ 'pluginName' ] = Seomatic::$settings->pluginName; |
|
| 439 | + $variables[ 'title' ] = $templateTitle; |
|
| 440 | + $variables[ 'subSectionTitle' ] = $subSectionTitle; |
|
| 441 | + $variables[ 'crumbs' ] = [ |
|
| 442 | 442 | [ |
| 443 | 443 | 'label' => $pluginName, |
| 444 | 444 | 'url' => UrlHelper::cpUrl('seomatic'), |
@@ -448,19 +448,19 @@ discard block |
||
| 448 | 448 | 'url' => UrlHelper::cpUrl('seomatic/content'), |
| 449 | 449 | ], |
| 450 | 450 | [ |
| 451 | - 'label' => $metaBundle->sourceName.' · '.$subSectionTitle, |
|
| 451 | + 'label' => $metaBundle->sourceName . ' · ' . $subSectionTitle, |
|
| 452 | 452 | 'url' => UrlHelper::cpUrl("seomatic/content/${subSection}/${sourceBundleType}/${sourceHandle}"), |
| 453 | 453 | ], |
| 454 | 454 | ]; |
| 455 | - $variables['selectedSubnavItem'] = 'content'; |
|
| 456 | - $variables['controllerHandle'] = "edit-content/${subSection}/${sourceBundleType}/${sourceHandle}"; |
|
| 455 | + $variables[ 'selectedSubnavItem' ] = 'content'; |
|
| 456 | + $variables[ 'controllerHandle' ] = "edit-content/${subSection}/${sourceBundleType}/${sourceHandle}"; |
|
| 457 | 457 | // Image selectors |
| 458 | - $variables['currentSubSection'] = $subSection; |
|
| 458 | + $variables[ 'currentSubSection' ] = $subSection; |
|
| 459 | 459 | $bundleSettings = $metaBundle->metaBundleSettings; |
| 460 | - $variables['elementType'] = Asset::class; |
|
| 461 | - $variables['seoImageElements'] = $this->assetElementsFromIds($bundleSettings->seoImageIds, $siteId); |
|
| 462 | - $variables['twitterImageElements'] = $this->assetElementsFromIds($bundleSettings->twitterImageIds, $siteId); |
|
| 463 | - $variables['ogImageElements'] = $this->assetElementsFromIds($bundleSettings->ogImageIds, $siteId); |
|
| 460 | + $variables[ 'elementType' ] = Asset::class; |
|
| 461 | + $variables[ 'seoImageElements' ] = $this->assetElementsFromIds($bundleSettings->seoImageIds, $siteId); |
|
| 462 | + $variables[ 'twitterImageElements' ] = $this->assetElementsFromIds($bundleSettings->twitterImageIds, $siteId); |
|
| 463 | + $variables[ 'ogImageElements' ] = $this->assetElementsFromIds($bundleSettings->ogImageIds, $siteId); |
|
| 464 | 464 | // Pass in the pull fields |
| 465 | 465 | $groupName = "Entry"; |
| 466 | 466 | $this->setContentFieldSourceVariables($sourceBundleType, $sourceHandle, $groupName, $variables); |
@@ -468,11 +468,11 @@ discard block |
||
| 468 | 468 | // Preview the meta containers |
| 469 | 469 | Seomatic::$plugin->metaContainers->previewMetaContainers( |
| 470 | 470 | $uri, |
| 471 | - intval($variables['currentSiteId']) |
|
| 471 | + intval($variables[ 'currentSiteId' ]) |
|
| 472 | 472 | ); |
| 473 | 473 | |
| 474 | 474 | // Render the template |
| 475 | - return $this->renderTemplate('seomatic/settings/content/'.$subSection, $variables); |
|
| 475 | + return $this->renderTemplate('seomatic/settings/content/' . $subSection, $variables); |
|
| 476 | 476 | } |
| 477 | 477 | |
| 478 | 478 | |
@@ -541,7 +541,7 @@ discard block |
||
| 541 | 541 | */ |
| 542 | 542 | public function actionSite(string $subSection = 'identity', string $siteHandle = null): Response |
| 543 | 543 | { |
| 544 | - $variables = []; |
|
| 544 | + $variables = [ ]; |
|
| 545 | 545 | // Get the site to edit |
| 546 | 546 | $siteId = $this->getSiteIdFromHandle($siteHandle); |
| 547 | 547 | |
@@ -551,24 +551,24 @@ discard block |
||
| 551 | 551 | if ($subSection == "social") { |
| 552 | 552 | $subSectionSuffix = " Media"; |
| 553 | 553 | } |
| 554 | - $subSectionTitle = Craft::t('seomatic', ucfirst($subSection).$subSectionSuffix); |
|
| 554 | + $subSectionTitle = Craft::t('seomatic', ucfirst($subSection) . $subSectionSuffix); |
|
| 555 | 555 | // Asset bundle |
| 556 | 556 | try { |
| 557 | 557 | Seomatic::$view->registerAssetBundle(SeomaticAsset::class); |
| 558 | 558 | } catch (InvalidConfigException $e) { |
| 559 | 559 | Craft::error($e->getMessage(), __METHOD__); |
| 560 | 560 | } |
| 561 | - $variables['baseAssetsUrl'] = Craft::$app->assetManager->getPublishedUrl( |
|
| 561 | + $variables[ 'baseAssetsUrl' ] = Craft::$app->assetManager->getPublishedUrl( |
|
| 562 | 562 | '@nystudio107/seomatic/assetbundles/seomatic/dist', |
| 563 | 563 | true |
| 564 | 564 | ); |
| 565 | 565 | // Basic variables |
| 566 | - $variables['fullPageForm'] = true; |
|
| 567 | - $variables['docsUrl'] = self::DOCUMENTATION_URL; |
|
| 568 | - $variables['pluginName'] = Seomatic::$settings->pluginName; |
|
| 569 | - $variables['title'] = $templateTitle; |
|
| 570 | - $variables['subSectionTitle'] = $subSectionTitle; |
|
| 571 | - $variables['crumbs'] = [ |
|
| 566 | + $variables[ 'fullPageForm' ] = true; |
|
| 567 | + $variables[ 'docsUrl' ] = self::DOCUMENTATION_URL; |
|
| 568 | + $variables[ 'pluginName' ] = Seomatic::$settings->pluginName; |
|
| 569 | + $variables[ 'title' ] = $templateTitle; |
|
| 570 | + $variables[ 'subSectionTitle' ] = $subSectionTitle; |
|
| 571 | + $variables[ 'crumbs' ] = [ |
|
| 572 | 572 | [ |
| 573 | 573 | 'label' => $pluginName, |
| 574 | 574 | 'url' => UrlHelper::cpUrl('seomatic'), |
@@ -579,24 +579,24 @@ discard block |
||
| 579 | 579 | ], |
| 580 | 580 | [ |
| 581 | 581 | 'label' => $subSectionTitle, |
| 582 | - 'url' => UrlHelper::cpUrl('seomatic/site/'.$subSection), |
|
| 582 | + 'url' => UrlHelper::cpUrl('seomatic/site/' . $subSection), |
|
| 583 | 583 | ], |
| 584 | 584 | ]; |
| 585 | - $variables['selectedSubnavItem'] = 'site'; |
|
| 586 | - $variables['currentSubSection'] = $subSection; |
|
| 585 | + $variables[ 'selectedSubnavItem' ] = 'site'; |
|
| 586 | + $variables[ 'currentSubSection' ] = $subSection; |
|
| 587 | 587 | |
| 588 | 588 | // Enabled sites |
| 589 | 589 | $this->setMultiSiteVariables($siteHandle, $siteId, $variables); |
| 590 | - $variables['controllerHandle'] = 'site'.'/'.$subSection; |
|
| 590 | + $variables[ 'controllerHandle' ] = 'site' . '/' . $subSection; |
|
| 591 | 591 | |
| 592 | 592 | // The site settings for the appropriate meta bundle |
| 593 | - $metaBundle = Seomatic::$plugin->metaBundles->getGlobalMetaBundle(intval($variables['currentSiteId'])); |
|
| 594 | - $variables['site'] = $metaBundle->metaSiteVars; |
|
| 595 | - $variables['genericImageElements'] = $this->assetElementsFromIds($variables['site']->identity->genericImageIds, $siteId); |
|
| 596 | - $variables['elementType'] = Asset::class; |
|
| 593 | + $metaBundle = Seomatic::$plugin->metaBundles->getGlobalMetaBundle(intval($variables[ 'currentSiteId' ])); |
|
| 594 | + $variables[ 'site' ] = $metaBundle->metaSiteVars; |
|
| 595 | + $variables[ 'genericImageElements' ] = $this->assetElementsFromIds($variables[ 'site' ]->identity->genericImageIds, $siteId); |
|
| 596 | + $variables[ 'elementType' ] = Asset::class; |
|
| 597 | 597 | |
| 598 | 598 | // Render the template |
| 599 | - return $this->renderTemplate('seomatic/settings/site/'.$subSection, $variables); |
|
| 599 | + return $this->renderTemplate('seomatic/settings/site/' . $subSection, $variables); |
|
| 600 | 600 | } |
| 601 | 601 | |
| 602 | 602 | /** |
@@ -611,26 +611,26 @@ discard block |
||
| 611 | 611 | $siteSettings = $request->getParam('site'); |
| 612 | 612 | |
| 613 | 613 | // Make sure the twitter handle isn't prefixed with an @ |
| 614 | - if (!empty($siteSettings['twitterHandle'])) { |
|
| 615 | - $siteSettings['twitterHandle'] = ltrim($siteSettings['twitterHandle'], '@'); |
|
| 614 | + if (!empty($siteSettings[ 'twitterHandle' ])) { |
|
| 615 | + $siteSettings[ 'twitterHandle' ] = ltrim($siteSettings[ 'twitterHandle' ], '@'); |
|
| 616 | 616 | } |
| 617 | 617 | // Make sure the sameAsLinks are indexed by the handle |
| 618 | - if (!empty($siteSettings['sameAsLinks'])) { |
|
| 619 | - $siteSettings['sameAsLinks'] = ArrayHelper::index($siteSettings['sameAsLinks'], 'handle'); |
|
| 618 | + if (!empty($siteSettings[ 'sameAsLinks' ])) { |
|
| 619 | + $siteSettings[ 'sameAsLinks' ] = ArrayHelper::index($siteSettings[ 'sameAsLinks' ], 'handle'); |
|
| 620 | 620 | } |
| 621 | 621 | // The site settings for the appropriate meta bundle |
| 622 | 622 | $metaBundle = Seomatic::$plugin->metaBundles->getGlobalMetaBundle($siteId); |
| 623 | 623 | if ($metaBundle) { |
| 624 | 624 | if (is_array($siteSettings)) { |
| 625 | - if (!empty($siteSettings['identity'])) { |
|
| 626 | - $this->normalizeTimes($siteSettings['identity']['localBusinessOpeningHours']); |
|
| 627 | - $metaBundle->metaSiteVars->identity->setAttributes($siteSettings['identity']); |
|
| 628 | - $siteSettings['identity'] = $metaBundle->metaSiteVars->identity; |
|
| 625 | + if (!empty($siteSettings[ 'identity' ])) { |
|
| 626 | + $this->normalizeTimes($siteSettings[ 'identity' ][ 'localBusinessOpeningHours' ]); |
|
| 627 | + $metaBundle->metaSiteVars->identity->setAttributes($siteSettings[ 'identity' ]); |
|
| 628 | + $siteSettings[ 'identity' ] = $metaBundle->metaSiteVars->identity; |
|
| 629 | 629 | } |
| 630 | - if (!empty($siteSettings['creator'])) { |
|
| 631 | - $this->normalizeTimes($siteSettings['creator']['localBusinessOpeningHours']); |
|
| 632 | - $metaBundle->metaSiteVars->creator->setAttributes($siteSettings['creator']); |
|
| 633 | - $siteSettings['creator'] = $metaBundle->metaSiteVars->creator; |
|
| 630 | + if (!empty($siteSettings[ 'creator' ])) { |
|
| 631 | + $this->normalizeTimes($siteSettings[ 'creator' ][ 'localBusinessOpeningHours' ]); |
|
| 632 | + $metaBundle->metaSiteVars->creator->setAttributes($siteSettings[ 'creator' ]); |
|
| 633 | + $siteSettings[ 'creator' ] = $metaBundle->metaSiteVars->creator; |
|
| 634 | 634 | } |
| 635 | 635 | $metaBundle->metaSiteVars->setAttributes($siteSettings); |
| 636 | 636 | } |
@@ -650,7 +650,7 @@ discard block |
||
| 650 | 650 | */ |
| 651 | 651 | public function actionPlugin(): Response |
| 652 | 652 | { |
| 653 | - $variables = []; |
|
| 653 | + $variables = [ ]; |
|
| 654 | 654 | $pluginName = Seomatic::$settings->pluginName; |
| 655 | 655 | $templateTitle = Craft::t('seomatic', 'Plugin Settings'); |
| 656 | 656 | // Asset bundle |
@@ -659,16 +659,16 @@ discard block |
||
| 659 | 659 | } catch (InvalidConfigException $e) { |
| 660 | 660 | Craft::error($e->getMessage(), __METHOD__); |
| 661 | 661 | } |
| 662 | - $variables['baseAssetsUrl'] = Craft::$app->assetManager->getPublishedUrl( |
|
| 662 | + $variables[ 'baseAssetsUrl' ] = Craft::$app->assetManager->getPublishedUrl( |
|
| 663 | 663 | '@nystudio107/seomatic/assetbundles/seomatic/dist', |
| 664 | 664 | true |
| 665 | 665 | ); |
| 666 | 666 | // Basic variables |
| 667 | - $variables['fullPageForm'] = true; |
|
| 668 | - $variables['docsUrl'] = self::DOCUMENTATION_URL; |
|
| 669 | - $variables['pluginName'] = Seomatic::$settings->pluginName; |
|
| 670 | - $variables['title'] = $templateTitle; |
|
| 671 | - $variables['crumbs'] = [ |
|
| 667 | + $variables[ 'fullPageForm' ] = true; |
|
| 668 | + $variables[ 'docsUrl' ] = self::DOCUMENTATION_URL; |
|
| 669 | + $variables[ 'pluginName' ] = Seomatic::$settings->pluginName; |
|
| 670 | + $variables[ 'title' ] = $templateTitle; |
|
| 671 | + $variables[ 'crumbs' ] = [ |
|
| 672 | 672 | [ |
| 673 | 673 | 'label' => $pluginName, |
| 674 | 674 | 'url' => UrlHelper::cpUrl('seomatic'), |
@@ -678,8 +678,8 @@ discard block |
||
| 678 | 678 | 'url' => UrlHelper::cpUrl('seomatic/settings'), |
| 679 | 679 | ], |
| 680 | 680 | ]; |
| 681 | - $variables['selectedSubnavItem'] = 'plugin'; |
|
| 682 | - $variables['settings'] = Seomatic::$settings; |
|
| 681 | + $variables[ 'selectedSubnavItem' ] = 'plugin'; |
|
| 682 | + $variables[ 'settings' ] = Seomatic::$settings; |
|
| 683 | 683 | |
| 684 | 684 | // Render the template |
| 685 | 685 | return $this->renderTemplate('seomatic/settings/plugin/_edit', $variables); |
@@ -698,24 +698,24 @@ discard block |
||
| 698 | 698 | */ |
| 699 | 699 | public function actionTracking(string $subSection = 'googleAnalytics', string $siteHandle = null): Response |
| 700 | 700 | { |
| 701 | - $variables = []; |
|
| 701 | + $variables = [ ]; |
|
| 702 | 702 | // Get the site to edit |
| 703 | 703 | $siteId = $this->getSiteIdFromHandle($siteHandle); |
| 704 | 704 | // Enabled sites |
| 705 | 705 | $this->setMultiSiteVariables($siteHandle, $siteId, $variables); |
| 706 | - $variables['controllerHandle'] = 'tracking'; |
|
| 707 | - $variables['currentSubSection'] = $subSection; |
|
| 706 | + $variables[ 'controllerHandle' ] = 'tracking'; |
|
| 707 | + $variables[ 'currentSubSection' ] = $subSection; |
|
| 708 | 708 | |
| 709 | 709 | // The script meta containers for the global meta bundle |
| 710 | - $metaBundle = Seomatic::$plugin->metaBundles->getGlobalMetaBundle(intval($variables['currentSiteId'])); |
|
| 711 | - $variables['scripts'] = Seomatic::$plugin->metaBundles->getContainerDataFromBundle( |
|
| 710 | + $metaBundle = Seomatic::$plugin->metaBundles->getGlobalMetaBundle(intval($variables[ 'currentSiteId' ])); |
|
| 711 | + $variables[ 'scripts' ] = Seomatic::$plugin->metaBundles->getContainerDataFromBundle( |
|
| 712 | 712 | $metaBundle, |
| 713 | 713 | MetaScriptContainer::CONTAINER_TYPE |
| 714 | 714 | ); |
| 715 | 715 | // Plugin and section settings |
| 716 | 716 | $pluginName = Seomatic::$settings->pluginName; |
| 717 | 717 | $templateTitle = Craft::t('seomatic', 'Tracking Scripts'); |
| 718 | - $subSectionTitle = $variables['scripts'][$subSection]->name; |
|
| 718 | + $subSectionTitle = $variables[ 'scripts' ][ $subSection ]->name; |
|
| 719 | 719 | $subSectionTitle = Craft::t('seomatic', $subSectionTitle); |
| 720 | 720 | // Asset bundle |
| 721 | 721 | try { |
@@ -723,17 +723,17 @@ discard block |
||
| 723 | 723 | } catch (InvalidConfigException $e) { |
| 724 | 724 | Craft::error($e->getMessage(), __METHOD__); |
| 725 | 725 | } |
| 726 | - $variables['baseAssetsUrl'] = Craft::$app->assetManager->getPublishedUrl( |
|
| 726 | + $variables[ 'baseAssetsUrl' ] = Craft::$app->assetManager->getPublishedUrl( |
|
| 727 | 727 | '@nystudio107/seomatic/assetbundles/seomatic/dist', |
| 728 | 728 | true |
| 729 | 729 | ); |
| 730 | 730 | // Basic variables |
| 731 | - $variables['fullPageForm'] = true; |
|
| 732 | - $variables['docsUrl'] = self::DOCUMENTATION_URL; |
|
| 733 | - $variables['pluginName'] = Seomatic::$settings->pluginName; |
|
| 734 | - $variables['title'] = $templateTitle; |
|
| 735 | - $variables['subSectionTitle'] = $subSectionTitle; |
|
| 736 | - $variables['crumbs'] = [ |
|
| 731 | + $variables[ 'fullPageForm' ] = true; |
|
| 732 | + $variables[ 'docsUrl' ] = self::DOCUMENTATION_URL; |
|
| 733 | + $variables[ 'pluginName' ] = Seomatic::$settings->pluginName; |
|
| 734 | + $variables[ 'title' ] = $templateTitle; |
|
| 735 | + $variables[ 'subSectionTitle' ] = $subSectionTitle; |
|
| 736 | + $variables[ 'crumbs' ] = [ |
|
| 737 | 737 | [ |
| 738 | 738 | 'label' => $pluginName, |
| 739 | 739 | 'url' => UrlHelper::cpUrl('seomatic'), |
@@ -744,10 +744,10 @@ discard block |
||
| 744 | 744 | ], |
| 745 | 745 | [ |
| 746 | 746 | 'label' => $subSectionTitle, |
| 747 | - 'url' => UrlHelper::cpUrl('seomatic/tracking/'.$subSection), |
|
| 747 | + 'url' => UrlHelper::cpUrl('seomatic/tracking/' . $subSection), |
|
| 748 | 748 | ], |
| 749 | 749 | ]; |
| 750 | - $variables['selectedSubnavItem'] = 'tracking'; |
|
| 750 | + $variables[ 'selectedSubnavItem' ] = 'tracking'; |
|
| 751 | 751 | |
| 752 | 752 | // Render the template |
| 753 | 753 | return $this->renderTemplate('seomatic/settings/tracking/_edit', $variables); |
@@ -775,7 +775,7 @@ discard block |
||
| 775 | 775 | foreach ($scriptData as $key => $value) { |
| 776 | 776 | if (is_array($value)) { |
| 777 | 777 | foreach ($value as $varsKey => $varsValue) { |
| 778 | - $data->$key[$varsKey]['value'] = $varsValue; |
|
| 778 | + $data->$key[ $varsKey ][ 'value' ] = $varsValue; |
|
| 779 | 779 | } |
| 780 | 780 | } else { |
| 781 | 781 | $data->$key = $value; |
@@ -805,17 +805,17 @@ discard block |
||
| 805 | 805 | if (is_string($value)) { |
| 806 | 806 | $value = Json::decode($value); |
| 807 | 807 | } |
| 808 | - $normalized = []; |
|
| 809 | - $times = ['open', 'close']; |
|
| 808 | + $normalized = [ ]; |
|
| 809 | + $times = [ 'open', 'close' ]; |
|
| 810 | 810 | for ($day = 0; $day <= 6; $day++) { |
| 811 | 811 | foreach ($times as $time) { |
| 812 | 812 | if ( |
| 813 | - isset($value[$day][$time]) && |
|
| 814 | - ($date = DateTimeHelper::toDateTime($value[$day][$time])) !== false |
|
| 813 | + isset($value[ $day ][ $time ]) && |
|
| 814 | + ($date = DateTimeHelper::toDateTime($value[ $day ][ $time ])) !== false |
|
| 815 | 815 | ) { |
| 816 | - $normalized[$day][$time] = $date; |
|
| 816 | + $normalized[ $day ][ $time ] = $date; |
|
| 817 | 817 | } else { |
| 818 | - $normalized[$day][$time] = null; |
|
| 818 | + $normalized[ $day ][ $time ] = null; |
|
| 819 | 819 | } |
| 820 | 820 | } |
| 821 | 821 | } |
@@ -838,47 +838,47 @@ discard block |
||
| 838 | 838 | $objectPrefix = 'object.'; |
| 839 | 839 | } |
| 840 | 840 | foreach (self::PULL_TEXT_FIELDS as $fields) { |
| 841 | - $fieldName = $fields['fieldName']; |
|
| 842 | - $source = $bundleSettings[$fieldName.'Source'] ?? ''; |
|
| 843 | - $sourceField = $bundleSettings[$fieldName.'Field'] ?? ''; |
|
| 841 | + $fieldName = $fields[ 'fieldName' ]; |
|
| 842 | + $source = $bundleSettings[ $fieldName . 'Source' ] ?? ''; |
|
| 843 | + $sourceField = $bundleSettings[ $fieldName . 'Field' ] ?? ''; |
|
| 844 | 844 | if (!empty($source)) { |
| 845 | - $seoField = $fields['seoField']; |
|
| 845 | + $seoField = $fields[ 'seoField' ]; |
|
| 846 | 846 | switch ($source) { |
| 847 | 847 | case 'sameAsSeo': |
| 848 | - $globalsSettings[$fieldName] = |
|
| 849 | - '{seomatic.meta.'.$seoField.'}'; |
|
| 848 | + $globalsSettings[ $fieldName ] = |
|
| 849 | + '{seomatic.meta.' . $seoField . '}'; |
|
| 850 | 850 | break; |
| 851 | 851 | |
| 852 | 852 | case 'sameAsSiteTwitter': |
| 853 | - $globalsSettings[$fieldName] = |
|
| 854 | - '{seomatic.site.'.$seoField.'}'; |
|
| 853 | + $globalsSettings[ $fieldName ] = |
|
| 854 | + '{seomatic.site.' . $seoField . '}'; |
|
| 855 | 855 | break; |
| 856 | 856 | |
| 857 | 857 | case 'fromField': |
| 858 | - $globalsSettings[$fieldName] = |
|
| 858 | + $globalsSettings[ $fieldName ] = |
|
| 859 | 859 | '{seomatic.helper.extractTextFromField(' |
| 860 | - .$objectPrefix.$elementName.$sourceField |
|
| 860 | + .$objectPrefix . $elementName . $sourceField |
|
| 861 | 861 | .')}'; |
| 862 | 862 | break; |
| 863 | 863 | |
| 864 | 864 | case 'fromUserField': |
| 865 | - $globalsSettings[$fieldName] = |
|
| 865 | + $globalsSettings[ $fieldName ] = |
|
| 866 | 866 | '{seomatic.helper.extractTextFromField(' |
| 867 | - .$objectPrefix.$elementName.'author.'.$sourceField |
|
| 867 | + .$objectPrefix . $elementName . 'author.' . $sourceField |
|
| 868 | 868 | .')}'; |
| 869 | 869 | break; |
| 870 | 870 | |
| 871 | 871 | case 'summaryFromField': |
| 872 | - $globalsSettings[$fieldName] = |
|
| 872 | + $globalsSettings[ $fieldName ] = |
|
| 873 | 873 | '{seomatic.helper.extractSummary(seomatic.helper.extractTextFromField(' |
| 874 | - .$objectPrefix.$elementName.$sourceField |
|
| 874 | + .$objectPrefix . $elementName . $sourceField |
|
| 875 | 875 | .'))}'; |
| 876 | 876 | break; |
| 877 | 877 | |
| 878 | 878 | case 'keywordsFromField': |
| 879 | - $globalsSettings[$fieldName] = |
|
| 879 | + $globalsSettings[ $fieldName ] = |
|
| 880 | 880 | '{seomatic.helper.extractKeywords(seomatic.helper.extractTextFromField(' |
| 881 | - .$objectPrefix.$elementName.$sourceField |
|
| 881 | + .$objectPrefix . $elementName . $sourceField |
|
| 882 | 882 | .'))}'; |
| 883 | 883 | break; |
| 884 | 884 | |
@@ -905,85 +905,85 @@ discard block |
||
| 905 | 905 | $objectPrefix = 'object.'; |
| 906 | 906 | } |
| 907 | 907 | foreach (self::PULL_ASSET_FIELDS as $fields) { |
| 908 | - $fieldName = $fields['fieldName']; |
|
| 909 | - $source = $bundleSettings[$fieldName.'Source'] ?? ''; |
|
| 910 | - $ids = $bundleSettings[$fieldName.'Ids'] ?? []; |
|
| 911 | - $sourceField = $bundleSettings[$fieldName.'Field'] ?? ''; |
|
| 908 | + $fieldName = $fields[ 'fieldName' ]; |
|
| 909 | + $source = $bundleSettings[ $fieldName . 'Source' ] ?? ''; |
|
| 910 | + $ids = $bundleSettings[ $fieldName . 'Ids' ] ?? [ ]; |
|
| 911 | + $sourceField = $bundleSettings[ $fieldName . 'Field' ] ?? ''; |
|
| 912 | 912 | if (!empty($source)) { |
| 913 | - $transformImage = $bundleSettings[$fieldName.'Transform']; |
|
| 914 | - $seoField = $fields['seoField']; |
|
| 915 | - $transformName = $fields['transformName']; |
|
| 913 | + $transformImage = $bundleSettings[ $fieldName . 'Transform' ]; |
|
| 914 | + $seoField = $fields[ 'seoField' ]; |
|
| 915 | + $transformName = $fields[ 'transformName' ]; |
|
| 916 | 916 | // Special-case Twitter transforms |
| 917 | 917 | if ($transformName == 'twitter') { |
| 918 | 918 | $transformName = 'twitter-summary'; |
| 919 | - if ($globalsSettings['twitterCard'] == 'summary_large_image') { |
|
| 919 | + if ($globalsSettings[ 'twitterCard' ] == 'summary_large_image') { |
|
| 920 | 920 | $transformName = 'twitter-large'; |
| 921 | 921 | } |
| 922 | 922 | } |
| 923 | 923 | if ($transformImage) { |
| 924 | 924 | switch ($source) { |
| 925 | 925 | case 'sameAsSeo': |
| 926 | - $seoSource = $bundleSettings[$seoField.'Source'] ?? ''; |
|
| 927 | - $seoIds = $bundleSettings[$seoField.'Ids'] ?? []; |
|
| 928 | - $seoSourceField = $bundleSettings[$seoField.'Field'] ?? ''; |
|
| 926 | + $seoSource = $bundleSettings[ $seoField . 'Source' ] ?? ''; |
|
| 927 | + $seoIds = $bundleSettings[ $seoField . 'Ids' ] ?? [ ]; |
|
| 928 | + $seoSourceField = $bundleSettings[ $seoField . 'Field' ] ?? ''; |
|
| 929 | 929 | if (!empty($seoSource)) { |
| 930 | 930 | switch ($seoSource) { |
| 931 | 931 | case 'fromField': |
| 932 | 932 | if (!empty($seoSourceField)) { |
| 933 | - $globalsSettings[$fieldName] = '{seomatic.helper.socialTransform(' |
|
| 934 | - .$objectPrefix.$elementName.$seoSourceField.'.one()' |
|
| 935 | - .', "'.$transformName.'"' |
|
| 936 | - .', '.$siteId.')}'; |
|
| 933 | + $globalsSettings[ $fieldName ] = '{seomatic.helper.socialTransform(' |
|
| 934 | + .$objectPrefix . $elementName . $seoSourceField . '.one()' |
|
| 935 | + .', "' . $transformName . '"' |
|
| 936 | + .', ' . $siteId . ')}'; |
|
| 937 | 937 | } |
| 938 | 938 | break; |
| 939 | 939 | case 'fromAsset': |
| 940 | 940 | if (!empty($seoIds)) { |
| 941 | - $globalsSettings[$fieldName] = '{seomatic.helper.socialTransform(' |
|
| 942 | - .$seoIds[0] |
|
| 943 | - .', "'.$transformName.'"' |
|
| 944 | - .', '.$siteId.')}'; |
|
| 941 | + $globalsSettings[ $fieldName ] = '{seomatic.helper.socialTransform(' |
|
| 942 | + .$seoIds[ 0 ] |
|
| 943 | + .', "' . $transformName . '"' |
|
| 944 | + .', ' . $siteId . ')}'; |
|
| 945 | 945 | } |
| 946 | 946 | break; |
| 947 | 947 | default: |
| 948 | - $globalsSettings[$fieldName] = '{seomatic.meta.'.$seoField.'}'; |
|
| 948 | + $globalsSettings[ $fieldName ] = '{seomatic.meta.' . $seoField . '}'; |
|
| 949 | 949 | break; |
| 950 | 950 | } |
| 951 | 951 | } |
| 952 | 952 | break; |
| 953 | 953 | case 'fromField': |
| 954 | 954 | if (!empty($sourceField)) { |
| 955 | - $globalsSettings[$fieldName] = '{seomatic.helper.socialTransform(' |
|
| 956 | - .$objectPrefix.$elementName.$sourceField.'.one()' |
|
| 957 | - .', "'.$transformName.'"' |
|
| 958 | - .', '.$siteId.')}'; |
|
| 955 | + $globalsSettings[ $fieldName ] = '{seomatic.helper.socialTransform(' |
|
| 956 | + .$objectPrefix . $elementName . $sourceField . '.one()' |
|
| 957 | + .', "' . $transformName . '"' |
|
| 958 | + .', ' . $siteId . ')}'; |
|
| 959 | 959 | } |
| 960 | 960 | break; |
| 961 | 961 | case 'fromAsset': |
| 962 | 962 | if (!empty($ids)) { |
| 963 | - $globalsSettings[$fieldName] = '{seomatic.helper.socialTransform(' |
|
| 964 | - .$ids[0] |
|
| 965 | - .', "'.$transformName.'"' |
|
| 966 | - .', '.$siteId.')}'; |
|
| 963 | + $globalsSettings[ $fieldName ] = '{seomatic.helper.socialTransform(' |
|
| 964 | + .$ids[ 0 ] |
|
| 965 | + .', "' . $transformName . '"' |
|
| 966 | + .', ' . $siteId . ')}'; |
|
| 967 | 967 | } |
| 968 | 968 | break; |
| 969 | 969 | } |
| 970 | 970 | } else { |
| 971 | 971 | switch ($source) { |
| 972 | 972 | case 'sameAsSeo': |
| 973 | - $globalsSettings[$fieldName] = '{seomatic.meta.'.$seoField.'}'; |
|
| 973 | + $globalsSettings[ $fieldName ] = '{seomatic.meta.' . $seoField . '}'; |
|
| 974 | 974 | break; |
| 975 | 975 | case 'fromField': |
| 976 | 976 | if (!empty($sourceField)) { |
| 977 | - $globalsSettings[$fieldName] = '{' |
|
| 978 | - .$elementName.$sourceField.'.one().url' |
|
| 977 | + $globalsSettings[ $fieldName ] = '{' |
|
| 978 | + .$elementName . $sourceField . '.one().url' |
|
| 979 | 979 | .'}'; |
| 980 | 980 | } |
| 981 | 981 | break; |
| 982 | 982 | case 'fromAsset': |
| 983 | 983 | if (!empty($ids)) { |
| 984 | - $globalsSettings[$fieldName] = '{{ craft.app.assets.assetById(' |
|
| 985 | - .$ids[0] |
|
| 986 | - .', '.$siteId.').url }}'; |
|
| 984 | + $globalsSettings[ $fieldName ] = '{{ craft.app.assets.assetById(' |
|
| 985 | + .$ids[ 0 ] |
|
| 986 | + .', ' . $siteId . ').url }}'; |
|
| 987 | 987 | } |
| 988 | 988 | break; |
| 989 | 989 | } |
@@ -997,15 +997,15 @@ discard block |
||
| 997 | 997 | */ |
| 998 | 998 | protected function setGlobalFieldSourceVariables(array &$variables) |
| 999 | 999 | { |
| 1000 | - $variables['textFieldSources'] = array_merge( |
|
| 1001 | - ['globalsGroup' => ['optgroup' => 'Globals Fields']], |
|
| 1000 | + $variables[ 'textFieldSources' ] = array_merge( |
|
| 1001 | + [ 'globalsGroup' => [ 'optgroup' => 'Globals Fields' ] ], |
|
| 1002 | 1002 | FieldHelper::fieldsOfTypeFromGlobals( |
| 1003 | 1003 | FieldHelper::TEXT_FIELD_CLASS_KEY, |
| 1004 | 1004 | false |
| 1005 | 1005 | ) |
| 1006 | 1006 | ); |
| 1007 | - $variables['assetFieldSources'] = array_merge( |
|
| 1008 | - ['globalsGroup' => ['optgroup' => 'Globals Fields']], |
|
| 1007 | + $variables[ 'assetFieldSources' ] = array_merge( |
|
| 1008 | + [ 'globalsGroup' => [ 'optgroup' => 'Globals Fields' ] ], |
|
| 1009 | 1009 | FieldHelper::fieldsOfTypeFromGlobals( |
| 1010 | 1010 | FieldHelper::ASSET_FIELD_CLASS_KEY, |
| 1011 | 1011 | false |
@@ -1025,8 +1025,8 @@ discard block |
||
| 1025 | 1025 | string $groupName, |
| 1026 | 1026 | array &$variables |
| 1027 | 1027 | ) { |
| 1028 | - $variables['textFieldSources'] = array_merge( |
|
| 1029 | - ['entryGroup' => ['optgroup' => $groupName.' Fields'], 'title' => 'Title'], |
|
| 1028 | + $variables[ 'textFieldSources' ] = array_merge( |
|
| 1029 | + [ 'entryGroup' => [ 'optgroup' => $groupName . ' Fields' ], 'title' => 'Title' ], |
|
| 1030 | 1030 | FieldHelper::fieldsOfTypeFromSource( |
| 1031 | 1031 | $sourceBundleType, |
| 1032 | 1032 | $sourceHandle, |
@@ -1034,8 +1034,8 @@ discard block |
||
| 1034 | 1034 | false |
| 1035 | 1035 | ) |
| 1036 | 1036 | ); |
| 1037 | - $variables['assetFieldSources'] = array_merge( |
|
| 1038 | - ['entryGroup' => ['optgroup' => $groupName.' Fields']], |
|
| 1037 | + $variables[ 'assetFieldSources' ] = array_merge( |
|
| 1038 | + [ 'entryGroup' => [ 'optgroup' => $groupName . ' Fields' ] ], |
|
| 1039 | 1039 | FieldHelper::fieldsOfTypeFromSource( |
| 1040 | 1040 | $sourceBundleType, |
| 1041 | 1041 | $sourceHandle, |
@@ -1043,15 +1043,15 @@ discard block |
||
| 1043 | 1043 | false |
| 1044 | 1044 | ) |
| 1045 | 1045 | ); |
| 1046 | - $variables['assetVolumeTextFieldSources'] = array_merge( |
|
| 1047 | - ['entryGroup' => ['optgroup' => 'Asset Volume Fields'], 'title' => 'Title'], |
|
| 1046 | + $variables[ 'assetVolumeTextFieldSources' ] = array_merge( |
|
| 1047 | + [ 'entryGroup' => [ 'optgroup' => 'Asset Volume Fields' ], 'title' => 'Title' ], |
|
| 1048 | 1048 | FieldHelper::fieldsOfTypeFromAssetVolumes( |
| 1049 | 1049 | FieldHelper::TEXT_FIELD_CLASS_KEY, |
| 1050 | 1050 | false |
| 1051 | 1051 | ) |
| 1052 | 1052 | ); |
| 1053 | - $variables['userFieldSources'] = array_merge( |
|
| 1054 | - ['entryGroup' => ['optgroup' => 'User Fields']], |
|
| 1053 | + $variables[ 'userFieldSources' ] = array_merge( |
|
| 1054 | + [ 'entryGroup' => [ 'optgroup' => 'User Fields' ] ], |
|
| 1055 | 1055 | FieldHelper::fieldsOfTypeFromUsers( |
| 1056 | 1056 | FieldHelper::TEXT_FIELD_CLASS_KEY, |
| 1057 | 1057 | false |
@@ -1109,43 +1109,43 @@ discard block |
||
| 1109 | 1109 | $sites = Craft::$app->getSites(); |
| 1110 | 1110 | if (Craft::$app->getIsMultiSite()) { |
| 1111 | 1111 | // Set defaults based on the section settings |
| 1112 | - $variables['enabledSiteIds'] = []; |
|
| 1113 | - $variables['siteIds'] = []; |
|
| 1112 | + $variables[ 'enabledSiteIds' ] = [ ]; |
|
| 1113 | + $variables[ 'siteIds' ] = [ ]; |
|
| 1114 | 1114 | |
| 1115 | 1115 | /** @var Site $site */ |
| 1116 | 1116 | foreach ($sites->getEditableSiteIds() as $editableSiteId) { |
| 1117 | - $variables['enabledSiteIds'][] = $editableSiteId; |
|
| 1118 | - $variables['siteIds'][] = $editableSiteId; |
|
| 1117 | + $variables[ 'enabledSiteIds' ][ ] = $editableSiteId; |
|
| 1118 | + $variables[ 'siteIds' ][ ] = $editableSiteId; |
|
| 1119 | 1119 | } |
| 1120 | 1120 | |
| 1121 | 1121 | // Make sure the $siteId they are trying to edit is in our array of editable sites |
| 1122 | - if (!in_array($siteId, $variables['enabledSiteIds'])) { |
|
| 1123 | - if (!empty($variables['enabledSiteIds'])) { |
|
| 1124 | - $siteId = reset($variables['enabledSiteIds']); |
|
| 1122 | + if (!in_array($siteId, $variables[ 'enabledSiteIds' ])) { |
|
| 1123 | + if (!empty($variables[ 'enabledSiteIds' ])) { |
|
| 1124 | + $siteId = reset($variables[ 'enabledSiteIds' ]); |
|
| 1125 | 1125 | } else { |
| 1126 | - $this->requirePermission('editSite:'.$siteId); |
|
| 1126 | + $this->requirePermission('editSite:' . $siteId); |
|
| 1127 | 1127 | } |
| 1128 | 1128 | } |
| 1129 | 1129 | } |
| 1130 | 1130 | // Set the currentSiteId and currentSiteHandle |
| 1131 | - $variables['currentSiteId'] = empty($siteId) ? Craft::$app->getSites()->currentSite->id : $siteId; |
|
| 1132 | - $variables['currentSiteHandle'] = empty($siteHandle) |
|
| 1131 | + $variables[ 'currentSiteId' ] = empty($siteId) ? Craft::$app->getSites()->currentSite->id : $siteId; |
|
| 1132 | + $variables[ 'currentSiteHandle' ] = empty($siteHandle) |
|
| 1133 | 1133 | ? Craft::$app->getSites()->currentSite->handle |
| 1134 | 1134 | : $siteHandle; |
| 1135 | 1135 | |
| 1136 | 1136 | // Page title |
| 1137 | - $variables['showSites'] = ( |
|
| 1137 | + $variables[ 'showSites' ] = ( |
|
| 1138 | 1138 | Craft::$app->getIsMultiSite() && |
| 1139 | - count($variables['enabledSiteIds']) |
|
| 1139 | + count($variables[ 'enabledSiteIds' ]) |
|
| 1140 | 1140 | ); |
| 1141 | 1141 | |
| 1142 | - if ($variables['showSites']) { |
|
| 1143 | - $variables['sitesMenuLabel'] = Craft::t( |
|
| 1142 | + if ($variables[ 'showSites' ]) { |
|
| 1143 | + $variables[ 'sitesMenuLabel' ] = Craft::t( |
|
| 1144 | 1144 | 'site', |
| 1145 | - $sites->getSiteById(intval($variables['currentSiteId']))->name |
|
| 1145 | + $sites->getSiteById(intval($variables[ 'currentSiteId' ]))->name |
|
| 1146 | 1146 | ); |
| 1147 | 1147 | } else { |
| 1148 | - $variables['sitesMenuLabel'] = ''; |
|
| 1148 | + $variables[ 'sitesMenuLabel' ] = ''; |
|
| 1149 | 1149 | } |
| 1150 | 1150 | } |
| 1151 | 1151 | |
@@ -1160,10 +1160,10 @@ discard block |
||
| 1160 | 1160 | protected function assetElementsFromIds($assetIds, int $siteId) |
| 1161 | 1161 | { |
| 1162 | 1162 | $elements = Craft::$app->getElements(); |
| 1163 | - $assets = []; |
|
| 1163 | + $assets = [ ]; |
|
| 1164 | 1164 | if (!empty($assetIds)) { |
| 1165 | 1165 | foreach ($assetIds as $assetId) { |
| 1166 | - $assets[] = $elements->getElementById($assetId, Asset::class, $siteId); |
|
| 1166 | + $assets[ ] = $elements->getElementById($assetId, Asset::class, $siteId); |
|
| 1167 | 1167 | } |
| 1168 | 1168 | } |
| 1169 | 1169 | |
@@ -1184,7 +1184,7 @@ discard block |
||
| 1184 | 1184 | if ($siteHandle !== null) { |
| 1185 | 1185 | $site = Craft::$app->getSites()->getSiteByHandle($siteHandle); |
| 1186 | 1186 | if (!$site) { |
| 1187 | - throw new NotFoundHttpException('Invalid site handle: '.$siteHandle); |
|
| 1187 | + throw new NotFoundHttpException('Invalid site handle: ' . $siteHandle); |
|
| 1188 | 1188 | } |
| 1189 | 1189 | $siteId = $site->id; |
| 1190 | 1190 | } else { |