@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | Craft::t( |
| 185 | 185 | 'seomatic', |
| 186 | 186 | '{name} plugin loaded', |
| 187 | - ['name' => $this->name] |
|
| 187 | + [ 'name' => $this->name ] |
|
| 188 | 188 | ), |
| 189 | 189 | __METHOD__ |
| 190 | 190 | ); |
@@ -203,43 +203,43 @@ discard block |
||
| 203 | 203 | */ |
| 204 | 204 | public function getCpNavItem() |
| 205 | 205 | { |
| 206 | - $subNavs = []; |
|
| 206 | + $subNavs = [ ]; |
|
| 207 | 207 | $navItem = parent::getCpNavItem(); |
| 208 | 208 | /** @var User $currentUser */ |
| 209 | 209 | $currentUser = Craft::$app->getUser()->getIdentity(); |
| 210 | 210 | // Only show sub-navs the user has permission to view |
| 211 | 211 | if ($currentUser->can('seomatic:dashboard')) { |
| 212 | - $subNavs['dashboard'] = [ |
|
| 212 | + $subNavs[ 'dashboard' ] = [ |
|
| 213 | 213 | 'label' => 'Dashboard', |
| 214 | 214 | 'url' => 'seomatic/dashboard', |
| 215 | 215 | ]; |
| 216 | 216 | } |
| 217 | 217 | if ($currentUser->can('seomatic:global-meta')) { |
| 218 | - $subNavs['global'] = [ |
|
| 218 | + $subNavs[ 'global' ] = [ |
|
| 219 | 219 | 'label' => 'Global SEO', |
| 220 | 220 | 'url' => 'seomatic/global', |
| 221 | 221 | ]; |
| 222 | 222 | } |
| 223 | 223 | if ($currentUser->can('seomatic:content-meta')) { |
| 224 | - $subNavs['content'] = [ |
|
| 224 | + $subNavs[ 'content' ] = [ |
|
| 225 | 225 | 'label' => 'Content SEO', |
| 226 | 226 | 'url' => 'seomatic/content', |
| 227 | 227 | ]; |
| 228 | 228 | } |
| 229 | 229 | if ($currentUser->can('seomatic:site-settings')) { |
| 230 | - $subNavs['site'] = [ |
|
| 230 | + $subNavs[ 'site' ] = [ |
|
| 231 | 231 | 'label' => 'Site Settings', |
| 232 | 232 | 'url' => 'seomatic/site', |
| 233 | 233 | ]; |
| 234 | 234 | } |
| 235 | 235 | if ($currentUser->can('seomatic:tracking-scripts')) { |
| 236 | - $subNavs['tracking'] = [ |
|
| 236 | + $subNavs[ 'tracking' ] = [ |
|
| 237 | 237 | 'label' => 'Tracking Scripts', |
| 238 | 238 | 'url' => 'seomatic/tracking', |
| 239 | 239 | ]; |
| 240 | 240 | } |
| 241 | 241 | if ($currentUser->can('seomatic:plugin-settings')) { |
| 242 | - $subNavs['plugin'] = [ |
|
| 242 | + $subNavs[ 'plugin' ] = [ |
|
| 243 | 243 | 'label' => 'Plugin Settings', |
| 244 | 244 | 'url' => 'seomatic/plugin', |
| 245 | 245 | ]; |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | Event::on( |
| 276 | 276 | Plugins::class, |
| 277 | 277 | Plugins::EVENT_AFTER_LOAD_PLUGINS, |
| 278 | - function () { |
|
| 278 | + function() { |
|
| 279 | 279 | // Add in our event listeners that are needed for every request |
| 280 | 280 | $this->installGlobalEventListeners(); |
| 281 | 281 | // Only respond to non-console site requests |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | Event::on( |
| 301 | 301 | Plugins::class, |
| 302 | 302 | Plugins::EVENT_AFTER_INSTALL_PLUGIN, |
| 303 | - function (PluginEvent $event) { |
|
| 303 | + function(PluginEvent $event) { |
|
| 304 | 304 | if ($event->plugin === $this) { |
| 305 | 305 | // Invalidate our caches after we've been installed |
| 306 | 306 | $this->clearAllCaches(); |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | Event::on( |
| 322 | 322 | Sections::class, |
| 323 | 323 | Sections::EVENT_AFTER_SAVE_SECTION, |
| 324 | - function (SectionEvent $event) { |
|
| 324 | + function(SectionEvent $event) { |
|
| 325 | 325 | Craft::debug( |
| 326 | 326 | 'Sections::EVENT_AFTER_SAVE_SECTION', |
| 327 | 327 | __METHOD__ |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | Event::on( |
| 345 | 345 | Sections::class, |
| 346 | 346 | Sections::EVENT_AFTER_DELETE_SECTION, |
| 347 | - function (SectionEvent $event) { |
|
| 347 | + function(SectionEvent $event) { |
|
| 348 | 348 | Craft::debug( |
| 349 | 349 | 'Sections::EVENT_AFTER_DELETE_SECTION', |
| 350 | 350 | __METHOD__ |
@@ -367,7 +367,7 @@ discard block |
||
| 367 | 367 | Event::on( |
| 368 | 368 | Categories::class, |
| 369 | 369 | Categories::EVENT_AFTER_SAVE_GROUP, |
| 370 | - function (CategoryGroupEvent $event) { |
|
| 370 | + function(CategoryGroupEvent $event) { |
|
| 371 | 371 | Craft::debug( |
| 372 | 372 | 'Categories::EVENT_AFTER_SAVE_GROUP', |
| 373 | 373 | __METHOD__ |
@@ -390,7 +390,7 @@ discard block |
||
| 390 | 390 | Event::on( |
| 391 | 391 | Categories::class, |
| 392 | 392 | Categories::EVENT_AFTER_DELETE_GROUP, |
| 393 | - function (CategoryGroupEvent $event) { |
|
| 393 | + function(CategoryGroupEvent $event) { |
|
| 394 | 394 | Craft::debug( |
| 395 | 395 | 'Categories::EVENT_AFTER_DELETE_GROUP', |
| 396 | 396 | __METHOD__ |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | Event::on( |
| 414 | 414 | Elements::class, |
| 415 | 415 | Elements::EVENT_AFTER_SAVE_ELEMENT, |
| 416 | - function (ElementEvent $event) { |
|
| 416 | + function(ElementEvent $event) { |
|
| 417 | 417 | Craft::debug( |
| 418 | 418 | 'Elements::EVENT_AFTER_SAVE_ELEMENT', |
| 419 | 419 | __METHOD__ |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | Event::on( |
| 434 | 434 | Elements::class, |
| 435 | 435 | Elements::EVENT_AFTER_DELETE_ELEMENT, |
| 436 | - function (ElementEvent $event) { |
|
| 436 | + function(ElementEvent $event) { |
|
| 437 | 437 | Craft::debug( |
| 438 | 438 | 'Elements::EVENT_AFTER_DELETE_ELEMENT', |
| 439 | 439 | __METHOD__ |
@@ -463,7 +463,7 @@ discard block |
||
| 463 | 463 | Event::on( |
| 464 | 464 | ErrorHandler::class, |
| 465 | 465 | ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION, |
| 466 | - function (ExceptionEvent $event) { |
|
| 466 | + function(ExceptionEvent $event) { |
|
| 467 | 467 | Craft::debug( |
| 468 | 468 | 'ErrorHandler::EVENT_BEFORE_HANDLE_EXCEPTION', |
| 469 | 469 | __METHOD__ |
@@ -484,7 +484,7 @@ discard block |
||
| 484 | 484 | Event::on( |
| 485 | 485 | View::class, |
| 486 | 486 | View::EVENT_BEGIN_BODY, |
| 487 | - function () { |
|
| 487 | + function() { |
|
| 488 | 488 | Craft::debug( |
| 489 | 489 | 'View::EVENT_BEGIN_BODY', |
| 490 | 490 | __METHOD__ |
@@ -499,7 +499,7 @@ discard block |
||
| 499 | 499 | Event::on( |
| 500 | 500 | View::class, |
| 501 | 501 | View::EVENT_END_BODY, |
| 502 | - function () { |
|
| 502 | + function() { |
|
| 503 | 503 | Craft::debug( |
| 504 | 504 | 'View::EVENT_END_BODY', |
| 505 | 505 | __METHOD__ |
@@ -514,7 +514,7 @@ discard block |
||
| 514 | 514 | Event::on( |
| 515 | 515 | View::class, |
| 516 | 516 | View::EVENT_END_PAGE, |
| 517 | - function () { |
|
| 517 | + function() { |
|
| 518 | 518 | Craft::debug( |
| 519 | 519 | 'View::EVENT_END_PAGE', |
| 520 | 520 | __METHOD__ |
@@ -538,7 +538,7 @@ discard block |
||
| 538 | 538 | Event::on( |
| 539 | 539 | UrlManager::class, |
| 540 | 540 | UrlManager::EVENT_REGISTER_CP_URL_RULES, |
| 541 | - function (RegisterUrlRulesEvent $event) { |
|
| 541 | + function(RegisterUrlRulesEvent $event) { |
|
| 542 | 542 | Craft::debug( |
| 543 | 543 | 'UrlManager::EVENT_REGISTER_CP_URL_RULES', |
| 544 | 544 | __METHOD__ |
@@ -554,20 +554,20 @@ discard block |
||
| 554 | 554 | Event::on( |
| 555 | 555 | UserPermissions::class, |
| 556 | 556 | UserPermissions::EVENT_REGISTER_PERMISSIONS, |
| 557 | - function (RegisterUserPermissionsEvent $event) { |
|
| 557 | + function(RegisterUserPermissionsEvent $event) { |
|
| 558 | 558 | Craft::debug( |
| 559 | 559 | 'UserPermissions::EVENT_REGISTER_PERMISSIONS', |
| 560 | 560 | __METHOD__ |
| 561 | 561 | ); |
| 562 | 562 | // Register our custom permissions |
| 563 | - $event->permissions[Craft::t('seomatic', 'SEOmatic')] = $this->customAdminCpPermissions(); |
|
| 563 | + $event->permissions[ Craft::t('seomatic', 'SEOmatic') ] = $this->customAdminCpPermissions(); |
|
| 564 | 564 | } |
| 565 | 565 | ); |
| 566 | 566 | // Handler: ClearCaches::EVENT_REGISTER_CACHE_OPTIONS |
| 567 | 567 | Event::on( |
| 568 | 568 | ClearCaches::class, |
| 569 | 569 | ClearCaches::EVENT_REGISTER_CACHE_OPTIONS, |
| 570 | - function (RegisterCacheOptionsEvent $event) { |
|
| 570 | + function(RegisterCacheOptionsEvent $event) { |
|
| 571 | 571 | Craft::debug( |
| 572 | 572 | 'ClearCaches::EVENT_REGISTER_CACHE_OPTIONS', |
| 573 | 573 | __METHOD__ |
@@ -580,11 +580,11 @@ discard block |
||
| 580 | 580 | } |
| 581 | 581 | ); |
| 582 | 582 | // Entries sidebar |
| 583 | - self::$view->hook('cp.entries.edit.details', function (&$context) { |
|
| 583 | + self::$view->hook('cp.entries.edit.details', function(&$context) { |
|
| 584 | 584 | $html = ''; |
| 585 | 585 | self::$view->registerAssetBundle(SeomaticAsset::class); |
| 586 | 586 | /** @var $entry Entry */ |
| 587 | - $entry = $context['entry']; |
|
| 587 | + $entry = $context[ 'entry' ]; |
|
| 588 | 588 | if (!empty($entry) && !empty($entry->uri)) { |
| 589 | 589 | Seomatic::$plugin->metaContainers->previewMetaContainers($entry->uri, $entry->siteId, true); |
| 590 | 590 | // Render our preview sidebar template |
@@ -600,11 +600,11 @@ discard block |
||
| 600 | 600 | return $html; |
| 601 | 601 | }); |
| 602 | 602 | // Category Groups sidebar |
| 603 | - self::$view->hook('cp.categories.edit.details', function (&$context) { |
|
| 603 | + self::$view->hook('cp.categories.edit.details', function(&$context) { |
|
| 604 | 604 | $html = ''; |
| 605 | 605 | self::$view->registerAssetBundle(SeomaticAsset::class); |
| 606 | 606 | /** @var $category Category */ |
| 607 | - $category = $context['category']; |
|
| 607 | + $category = $context[ 'category' ]; |
|
| 608 | 608 | if (!empty($category) && !empty($category->uri)) { |
| 609 | 609 | Seomatic::$plugin->metaContainers->previewMetaContainers($category->uri, $category->siteId, true); |
| 610 | 610 | // Render our preview sidebar template |
@@ -646,7 +646,7 @@ discard block |
||
| 646 | 646 | |
| 647 | 647 | 'seomatic/global' => [ |
| 648 | 648 | 'route' => 'seomatic/settings/global', |
| 649 | - 'defaults' => ['subSection' => 'general'], |
|
| 649 | + 'defaults' => [ 'subSection' => 'general' ], |
|
| 650 | 650 | ], |
| 651 | 651 | 'seomatic/global/<subSection:{handle}>' => |
| 652 | 652 | 'seomatic/settings/global', |
@@ -665,7 +665,7 @@ discard block |
||
| 665 | 665 | |
| 666 | 666 | 'seomatic/site' => [ |
| 667 | 667 | 'route' => 'seomatic/settings/site', |
| 668 | - 'defaults' => ['subSection' => 'identity'], |
|
| 668 | + 'defaults' => [ 'subSection' => 'identity' ], |
|
| 669 | 669 | ], |
| 670 | 670 | 'seomatic/site/<subSection:{handle}>' => |
| 671 | 671 | 'seomatic/settings/site', |
@@ -674,7 +674,7 @@ discard block |
||
| 674 | 674 | |
| 675 | 675 | 'seomatic/tracking' => [ |
| 676 | 676 | 'route' => 'seomatic/settings/tracking', |
| 677 | - 'defaults' => ['subSection' => 'googleAnalytics'], |
|
| 677 | + 'defaults' => [ 'subSection' => 'googleAnalytics' ], |
|
| 678 | 678 | ], |
| 679 | 679 | 'seomatic/tracking/<subSection:{handle}>' => |
| 680 | 680 | 'seomatic/settings/tracking', |
@@ -698,19 +698,19 @@ discard block |
||
| 698 | 698 | [ |
| 699 | 699 | 'key' => 'seomatic-frontendtemplate-caches', |
| 700 | 700 | 'label' => Craft::t('seomatic', 'SEOmatic frontend template caches'), |
| 701 | - 'action' => [Seomatic::$plugin->frontendTemplates, 'invalidateCaches'], |
|
| 701 | + 'action' => [ Seomatic::$plugin->frontendTemplates, 'invalidateCaches' ], |
|
| 702 | 702 | ], |
| 703 | 703 | // Meta bundle caches |
| 704 | 704 | [ |
| 705 | 705 | 'key' => 'seomatic-metabundle-caches', |
| 706 | 706 | 'label' => Craft::t('seomatic', 'SEOmatic metadata caches'), |
| 707 | - 'action' => [Seomatic::$plugin->metaContainers, 'invalidateCaches'], |
|
| 707 | + 'action' => [ Seomatic::$plugin->metaContainers, 'invalidateCaches' ], |
|
| 708 | 708 | ], |
| 709 | 709 | // Sitemap caches |
| 710 | 710 | [ |
| 711 | 711 | 'key' => 'seomatic-sitemap-caches', |
| 712 | 712 | 'label' => Craft::t('seomatic', 'SEOmatic sitemap caches'), |
| 713 | - 'action' => [Seomatic::$plugin->sitemaps, 'invalidateCaches'], |
|
| 713 | + 'action' => [ Seomatic::$plugin->sitemaps, 'invalidateCaches' ], |
|
| 714 | 714 | ], |
| 715 | 715 | ]; |
| 716 | 716 | } |
@@ -734,9 +734,9 @@ discard block |
||
| 734 | 734 | $metaBundle, |
| 735 | 735 | MetaScriptContainer::CONTAINER_TYPE |
| 736 | 736 | ); |
| 737 | - $scriptsPerms = []; |
|
| 737 | + $scriptsPerms = [ ]; |
|
| 738 | 738 | foreach ($scripts as $scriptHandle => $scriptData) { |
| 739 | - $scriptsPerms["seomatic:tracking-scripts:${scriptHandle}"] = [ |
|
| 739 | + $scriptsPerms[ "seomatic:tracking-scripts:${scriptHandle}" ] = [ |
|
| 740 | 740 | 'label' => Craft::t('seomatic', $scriptData->name), |
| 741 | 741 | ]; |
| 742 | 742 | } |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | * |
| 64 | 64 | * @return null|SitemapTemplate |
| 65 | 65 | */ |
| 66 | - public static function create(array $config = []) |
|
| 66 | + public static function create(array $config = [ ]) |
|
| 67 | 67 | { |
| 68 | 68 | $defaults = [ |
| 69 | 69 | 'path' => 'sitemaps/<groupId:\d+>/<type:[-\w\.*]+>/<handle:[-\w\.*]+>/<siteId:\d+>/<file:[-\w\.*]+>', |
@@ -110,32 +110,32 @@ discard block |
||
| 110 | 110 | /** |
| 111 | 111 | * @inheritdoc |
| 112 | 112 | */ |
| 113 | - public function render($params = []): string |
|
| 113 | + public function render($params = [ ]): string |
|
| 114 | 114 | { |
| 115 | 115 | $cache = Craft::$app->getCache(); |
| 116 | - $groupId = $params['groupId']; |
|
| 116 | + $groupId = $params[ 'groupId' ]; |
|
| 117 | 117 | /** @var SiteGroup $siteGroup */ |
| 118 | 118 | $siteGroup = Craft::$app->getSites()->getGroupById($groupId); |
| 119 | 119 | $groupSiteIds = $siteGroup->getSiteIds(); |
| 120 | - $type = $params['type']; |
|
| 121 | - $handle = $params['handle']; |
|
| 122 | - $siteId = $params['siteId']; |
|
| 120 | + $type = $params[ 'type' ]; |
|
| 121 | + $handle = $params[ 'handle' ]; |
|
| 122 | + $siteId = $params[ 'siteId' ]; |
|
| 123 | 123 | $duration = Seomatic::$devMode ? $this::DEVMODE_SITEMAP_CACHE_DURATION : $this::SITEMAP_CACHE_DURATION; |
| 124 | 124 | $dependency = new TagDependency([ |
| 125 | 125 | 'tags' => [ |
| 126 | 126 | $this::GLOBAL_SITEMAP_CACHE_TAG, |
| 127 | - $this::SITEMAP_CACHE_TAG.$handle.$siteId, |
|
| 127 | + $this::SITEMAP_CACHE_TAG . $handle . $siteId, |
|
| 128 | 128 | ], |
| 129 | 129 | ]); |
| 130 | 130 | |
| 131 | - return $cache->getOrSet($this::CACHE_KEY.$groupId.$handle.$siteId, function () use ($type, $handle, $siteId, $groupSiteIds) { |
|
| 131 | + return $cache->getOrSet($this::CACHE_KEY . $groupId . $handle . $siteId, function() use ($type, $handle, $siteId, $groupSiteIds) { |
|
| 132 | 132 | Craft::info( |
| 133 | - 'Sitemap cache miss: '.$handle.'/'.$siteId, |
|
| 133 | + 'Sitemap cache miss: ' . $handle . '/' . $siteId, |
|
| 134 | 134 | __METHOD__ |
| 135 | 135 | ); |
| 136 | - $lines = []; |
|
| 136 | + $lines = [ ]; |
|
| 137 | 137 | // Sitemap index XML header and opening tag |
| 138 | - $lines[] = '<?xml version="1.0" encoding="UTF-8"?>'; |
|
| 138 | + $lines[ ] = '<?xml version="1.0" encoding="UTF-8"?>'; |
|
| 139 | 139 | // One sitemap entry for each element |
| 140 | 140 | $metaBundle = Seomatic::$plugin->metaBundles->getMetaBundleBySourceHandle($type, $handle, $siteId); |
| 141 | 141 | $multiSite = count($metaBundle->sourceAltSiteSettings) > 1; |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | $urlsetLine .= ' xmlns:xhtml="http://www.w3.org/1999/xhtml"'; |
| 151 | 151 | } |
| 152 | 152 | $urlsetLine .= '>'; |
| 153 | - $lines[] = $urlsetLine; |
|
| 153 | + $lines[ ] = $urlsetLine; |
|
| 154 | 154 | // Handle each element type separately |
| 155 | 155 | switch ($metaBundle->sourceBundleType) { |
| 156 | 156 | case MetaBundles::SECTION_META_BUNDLE: |
@@ -176,25 +176,25 @@ discard block |
||
| 176 | 176 | $path = ($element->uri === '__home__') ? '' : $element->uri; |
| 177 | 177 | $url = UrlHelper::siteUrl($path, null, null, $metaBundle->sourceSiteId); |
| 178 | 178 | $dateUpdated = $element->dateUpdated ?? $element->dateCreated ?? new \DateTime; |
| 179 | - $lines[] = ' <url>'; |
|
| 179 | + $lines[ ] = ' <url>'; |
|
| 180 | 180 | // Standard sitemap key/values |
| 181 | - $lines[] = ' <loc>'; |
|
| 182 | - $lines[] = ' '.$url; |
|
| 183 | - $lines[] = ' </loc>'; |
|
| 184 | - $lines[] = ' <lastmod>'; |
|
| 185 | - $lines[] = ' '.$dateUpdated->format(\DateTime::W3C); |
|
| 186 | - $lines[] = ' </lastmod>'; |
|
| 187 | - $lines[] = ' <changefreq>'; |
|
| 188 | - $lines[] = ' '.$metaBundle->metaSitemapVars->sitemapChangeFreq; |
|
| 189 | - $lines[] = ' </changefreq>'; |
|
| 190 | - $lines[] = ' <priority>'; |
|
| 191 | - $lines[] = ' '.$metaBundle->metaSitemapVars->sitemapPriority; |
|
| 192 | - $lines[] = ' </priority>'; |
|
| 181 | + $lines[ ] = ' <loc>'; |
|
| 182 | + $lines[ ] = ' ' . $url; |
|
| 183 | + $lines[ ] = ' </loc>'; |
|
| 184 | + $lines[ ] = ' <lastmod>'; |
|
| 185 | + $lines[ ] = ' ' . $dateUpdated->format(\DateTime::W3C); |
|
| 186 | + $lines[ ] = ' </lastmod>'; |
|
| 187 | + $lines[ ] = ' <changefreq>'; |
|
| 188 | + $lines[ ] = ' ' . $metaBundle->metaSitemapVars->sitemapChangeFreq; |
|
| 189 | + $lines[ ] = ' </changefreq>'; |
|
| 190 | + $lines[ ] = ' <priority>'; |
|
| 191 | + $lines[ ] = ' ' . $metaBundle->metaSitemapVars->sitemapPriority; |
|
| 192 | + $lines[ ] = ' </priority>'; |
|
| 193 | 193 | // Handle alternate URLs if this is multi-site |
| 194 | 194 | if ($multiSite && $metaBundle->metaSitemapVars->sitemapAltLinks) { |
| 195 | 195 | /** @var $altSiteSettings */ |
| 196 | 196 | foreach ($metaBundle->sourceAltSiteSettings as $altSiteSettings) { |
| 197 | - if (in_array($altSiteSettings['siteId'], $groupSiteIds)) { |
|
| 197 | + if (in_array($altSiteSettings[ 'siteId' ], $groupSiteIds)) { |
|
| 198 | 198 | $altElement = null; |
| 199 | 199 | // Handle each element type separately |
| 200 | 200 | switch ($metaBundle->sourceBundleType) { |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | $altElement = Entry::find() |
| 203 | 203 | ->section($metaBundle->sourceHandle) |
| 204 | 204 | ->id($element->id) |
| 205 | - ->siteId($altSiteSettings['siteId']) |
|
| 205 | + ->siteId($altSiteSettings[ 'siteId' ]) |
|
| 206 | 206 | ->enabledForSite(true) |
| 207 | 207 | ->limit(1) |
| 208 | 208 | ->one(); |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | case MetaBundles::CATEGORYGROUP_META_BUNDLE: |
| 212 | 212 | $altElement = Category::find() |
| 213 | 213 | ->id($element->id) |
| 214 | - ->siteId($altSiteSettings['siteId']) |
|
| 214 | + ->siteId($altSiteSettings[ 'siteId' ]) |
|
| 215 | 215 | ->limit(1) |
| 216 | 216 | ->enabledForSite(true) |
| 217 | 217 | ->one(); |
@@ -219,9 +219,9 @@ discard block |
||
| 219 | 219 | // @todo: handle Commerce products |
| 220 | 220 | } |
| 221 | 221 | if ($altElement) { |
| 222 | - $lines[] = ' <xhtml:link rel="alternate"' |
|
| 223 | - .' hreflang="'.$altSiteSettings['language'].'"' |
|
| 224 | - .' href="'.$altElement->url.'"' |
|
| 222 | + $lines[ ] = ' <xhtml:link rel="alternate"' |
|
| 223 | + .' hreflang="' . $altSiteSettings[ 'language' ] . '"' |
|
| 224 | + .' href="' . $altElement->url . '"' |
|
| 225 | 225 | .' />'; |
| 226 | 226 | } |
| 227 | 227 | } |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | true |
| 237 | 237 | ); |
| 238 | 238 | foreach ($assetFields as $assetField) { |
| 239 | - $assets = $element[$assetField]->all(); |
|
| 239 | + $assets = $element[ $assetField ]->all(); |
|
| 240 | 240 | foreach ($assets as $asset) { |
| 241 | 241 | $this->assetSitemapItem($asset, $metaBundle, $lines); |
| 242 | 242 | } |
@@ -248,19 +248,19 @@ discard block |
||
| 248 | 248 | true |
| 249 | 249 | ); |
| 250 | 250 | foreach ($matrixFields as $matrixField) { |
| 251 | - $matrixBlocks = $element[$matrixField]->all(); |
|
| 251 | + $matrixBlocks = $element[ $matrixField ]->all(); |
|
| 252 | 252 | foreach ($matrixBlocks as $matrixBlock) { |
| 253 | 253 | $assetFields = FieldHelper::matrixFieldsOfType($matrixBlock, AssetsField::class); |
| 254 | 254 | foreach ($assetFields as $assetField) { |
| 255 | 255 | /** @var MatrixBlock $matrixBlock */ |
| 256 | - foreach ($matrixBlock[$assetField]->all() as $asset) { |
|
| 256 | + foreach ($matrixBlock[ $assetField ]->all() as $asset) { |
|
| 257 | 257 | $this->assetSitemapItem($asset, $metaBundle, $lines); |
| 258 | 258 | } |
| 259 | 259 | } |
| 260 | 260 | } |
| 261 | 261 | } |
| 262 | 262 | } |
| 263 | - $lines[] = ' </url>'; |
|
| 263 | + $lines[ ] = ' </url>'; |
|
| 264 | 264 | // Include links to any known file types in the assets fields |
| 265 | 265 | if ($metaBundle->metaSitemapVars->sitemapFiles) { |
| 266 | 266 | // Regular Assets fields |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | true |
| 271 | 271 | ); |
| 272 | 272 | foreach ($assetFields as $assetField) { |
| 273 | - $assets = $element[$assetField]->all(); |
|
| 273 | + $assets = $element[ $assetField ]->all(); |
|
| 274 | 274 | foreach ($assets as $asset) { |
| 275 | 275 | $this->assetFilesSitemapLink($asset, $metaBundle, $lines); |
| 276 | 276 | } |
@@ -282,12 +282,12 @@ discard block |
||
| 282 | 282 | true |
| 283 | 283 | ); |
| 284 | 284 | foreach ($matrixFields as $matrixField) { |
| 285 | - $matrixBlocks = $element[$matrixField]->all(); |
|
| 285 | + $matrixBlocks = $element[ $matrixField ]->all(); |
|
| 286 | 286 | /** @var MatrixBlock $matrixBlock */ |
| 287 | 287 | foreach ($matrixBlocks as $matrixBlock) { |
| 288 | 288 | $assetFields = FieldHelper::matrixFieldsOfType($matrixBlock, AssetsField::class); |
| 289 | 289 | foreach ($assetFields as $assetField) { |
| 290 | - foreach ($matrixBlock[$assetField]->all() as $asset) { |
|
| 290 | + foreach ($matrixBlock[ $assetField ]->all() as $asset) { |
|
| 291 | 291 | $this->assetFilesSitemapLink($asset, $metaBundle, $lines); |
| 292 | 292 | } |
| 293 | 293 | } |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | } |
| 297 | 297 | } |
| 298 | 298 | // Sitemap index closing tag |
| 299 | - $lines[] = '</urlset>'; |
|
| 299 | + $lines[ ] = '</urlset>'; |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | return implode("\r\n", $lines); |
@@ -312,9 +312,9 @@ discard block |
||
| 312 | 312 | public function invalidateCache(string $handle, int $siteId) |
| 313 | 313 | { |
| 314 | 314 | $cache = Craft::$app->getCache(); |
| 315 | - TagDependency::invalidate($cache, $this::SITEMAP_CACHE_TAG.$handle.$siteId); |
|
| 315 | + TagDependency::invalidate($cache, $this::SITEMAP_CACHE_TAG . $handle . $siteId); |
|
| 316 | 316 | Craft::info( |
| 317 | - 'Sitemap cache cleared: '.$handle, |
|
| 317 | + 'Sitemap cache cleared: ' . $handle, |
|
| 318 | 318 | __METHOD__ |
| 319 | 319 | ); |
| 320 | 320 | } |
@@ -329,39 +329,39 @@ discard block |
||
| 329 | 329 | if ($asset->enabledForSite) { |
| 330 | 330 | switch ($asset->kind) { |
| 331 | 331 | case 'image': |
| 332 | - $lines[] = ' <image:image>'; |
|
| 333 | - $lines[] = ' <image:loc>'; |
|
| 334 | - $lines[] = ' '.$asset->getUrl(); |
|
| 335 | - $lines[] = ' </image:loc>'; |
|
| 332 | + $lines[ ] = ' <image:image>'; |
|
| 333 | + $lines[ ] = ' <image:loc>'; |
|
| 334 | + $lines[ ] = ' ' . $asset->getUrl(); |
|
| 335 | + $lines[ ] = ' </image:loc>'; |
|
| 336 | 336 | // Handle the dynamic field => property mappings |
| 337 | 337 | foreach ($metaBundle->metaSitemapVars->sitemapImageFieldMap as $row) { |
| 338 | - $fieldName = $row['field'] ?? ''; |
|
| 339 | - $propName = $row['property'] ?? ''; |
|
| 340 | - if (!empty($asset[$fieldName]) && !empty($propName)) { |
|
| 341 | - $lines[] = ' <image:'.$propName.'>'; |
|
| 342 | - $lines[] = ' '.$asset[$fieldName]; |
|
| 343 | - $lines[] = ' </image:'.$propName.'>'; |
|
| 338 | + $fieldName = $row[ 'field' ] ?? ''; |
|
| 339 | + $propName = $row[ 'property' ] ?? ''; |
|
| 340 | + if (!empty($asset[ $fieldName ]) && !empty($propName)) { |
|
| 341 | + $lines[ ] = ' <image:' . $propName . '>'; |
|
| 342 | + $lines[ ] = ' ' . $asset[ $fieldName ]; |
|
| 343 | + $lines[ ] = ' </image:' . $propName . '>'; |
|
| 344 | 344 | } |
| 345 | 345 | } |
| 346 | - $lines[] = ' </image:image>'; |
|
| 346 | + $lines[ ] = ' </image:image>'; |
|
| 347 | 347 | break; |
| 348 | 348 | |
| 349 | 349 | case 'video': |
| 350 | - $lines[] = ' <video:video>'; |
|
| 351 | - $lines[] = ' <video:content_loc>'; |
|
| 352 | - $lines[] = ' '.$asset->getUrl(); |
|
| 353 | - $lines[] = ' </video:content_loc>'; |
|
| 350 | + $lines[ ] = ' <video:video>'; |
|
| 351 | + $lines[ ] = ' <video:content_loc>'; |
|
| 352 | + $lines[ ] = ' ' . $asset->getUrl(); |
|
| 353 | + $lines[ ] = ' </video:content_loc>'; |
|
| 354 | 354 | // Handle the dynamic field => property mappings |
| 355 | 355 | foreach ($metaBundle->metaSitemapVars->sitemapVideoFieldMap as $row) { |
| 356 | - $fieldName = $row['field'] ?? ''; |
|
| 357 | - $propName = $row['property'] ?? ''; |
|
| 358 | - if (!empty($asset[$fieldName]) && !empty($propName)) { |
|
| 359 | - $lines[] = ' <video:'.$propName.'>'; |
|
| 360 | - $lines[] = ' '.$asset[$fieldName]; |
|
| 361 | - $lines[] = ' </video:'.$propName.'>'; |
|
| 356 | + $fieldName = $row[ 'field' ] ?? ''; |
|
| 357 | + $propName = $row[ 'property' ] ?? ''; |
|
| 358 | + if (!empty($asset[ $fieldName ]) && !empty($propName)) { |
|
| 359 | + $lines[ ] = ' <video:' . $propName . '>'; |
|
| 360 | + $lines[ ] = ' ' . $asset[ $fieldName ]; |
|
| 361 | + $lines[ ] = ' </video:' . $propName . '>'; |
|
| 362 | 362 | } |
| 363 | 363 | } |
| 364 | - $lines[] = ' </video:video>'; |
|
| 364 | + $lines[ ] = ' </video:video>'; |
|
| 365 | 365 | break; |
| 366 | 366 | } |
| 367 | 367 | } |
@@ -377,20 +377,20 @@ discard block |
||
| 377 | 377 | if ($asset->enabledForSite) { |
| 378 | 378 | if (in_array($asset->kind, $this::FILE_TYPES)) { |
| 379 | 379 | $dateUpdated = $asset->dateUpdated ?? $asset->dateCreated ?? new \DateTime; |
| 380 | - $lines[] = ' <url>'; |
|
| 381 | - $lines[] = ' <loc>'; |
|
| 382 | - $lines[] = ' '.$asset->getUrl(); |
|
| 383 | - $lines[] = ' </loc>'; |
|
| 384 | - $lines[] = ' <lastmod>'; |
|
| 385 | - $lines[] = ' '.$dateUpdated->format(\DateTime::W3C); |
|
| 386 | - $lines[] = ' </lastmod>'; |
|
| 387 | - $lines[] = ' <changefreq>'; |
|
| 388 | - $lines[] = ' '.$metaBundle->metaSitemapVars->sitemapChangeFreq; |
|
| 389 | - $lines[] = ' </changefreq>'; |
|
| 390 | - $lines[] = ' <priority>'; |
|
| 391 | - $lines[] = ' '.$metaBundle->metaSitemapVars->sitemapPriority; |
|
| 392 | - $lines[] = ' </priority>'; |
|
| 393 | - $lines[] = ' </url>'; |
|
| 380 | + $lines[ ] = ' <url>'; |
|
| 381 | + $lines[ ] = ' <loc>'; |
|
| 382 | + $lines[ ] = ' ' . $asset->getUrl(); |
|
| 383 | + $lines[ ] = ' </loc>'; |
|
| 384 | + $lines[ ] = ' <lastmod>'; |
|
| 385 | + $lines[ ] = ' ' . $dateUpdated->format(\DateTime::W3C); |
|
| 386 | + $lines[ ] = ' </lastmod>'; |
|
| 387 | + $lines[ ] = ' <changefreq>'; |
|
| 388 | + $lines[ ] = ' ' . $metaBundle->metaSitemapVars->sitemapChangeFreq; |
|
| 389 | + $lines[ ] = ' </changefreq>'; |
|
| 390 | + $lines[ ] = ' <priority>'; |
|
| 391 | + $lines[ ] = ' ' . $metaBundle->metaSitemapVars->sitemapPriority; |
|
| 392 | + $lines[ ] = ' </priority>'; |
|
| 393 | + $lines[ ] = ' </url>'; |
|
| 394 | 394 | } |
| 395 | 395 | } |
| 396 | 396 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | Seomatic::$plugin->metaContainers->loadMetaContainers($request->getPathInfo(), null); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - return ['seomatic' => Seomatic::$seomaticVariable]; |
|
| 41 | + return [ 'seomatic' => Seomatic::$seomaticVariable ]; |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /** |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | */ |
| 59 | 59 | public function getFilters() |
| 60 | 60 | { |
| 61 | - return []; |
|
| 61 | + return [ ]; |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -68,6 +68,6 @@ discard block |
||
| 68 | 68 | */ |
| 69 | 69 | public function getFunctions() |
| 70 | 70 | { |
| 71 | - return []; |
|
| 71 | + return [ ]; |
|
| 72 | 72 | } |
| 73 | 73 | } |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * |
| 36 | 36 | * @return null|MetaBundleSettings |
| 37 | 37 | */ |
| 38 | - public static function create(array $config = []) |
|
| 38 | + public static function create(array $config = [ ]) |
|
| 39 | 39 | { |
| 40 | 40 | $model = new MetaBundleSettings($config); |
| 41 | 41 | |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | /** |
| 84 | 84 | * @var int[] The AssetIDs for the SEO Image |
| 85 | 85 | */ |
| 86 | - public $seoImageIds = []; |
|
| 86 | + public $seoImageIds = [ ]; |
|
| 87 | 87 | |
| 88 | 88 | /** |
| 89 | 89 | * @var string The source that the SEO image should come from |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | /** |
| 149 | 149 | * @var int[] The AssetIDs for the Twitter Image |
| 150 | 150 | */ |
| 151 | - public $twitterImageIds = []; |
|
| 151 | + public $twitterImageIds = [ ]; |
|
| 152 | 152 | |
| 153 | 153 | /** |
| 154 | 154 | * @var string The source that the Twitter image should come from |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | /** |
| 204 | 204 | * @var int[] The AssetIDs for the Facebook OG Image |
| 205 | 205 | */ |
| 206 | - public $ogImageIds = []; |
|
| 206 | + public $ogImageIds = [ ]; |
|
| 207 | 207 | |
| 208 | 208 | /** |
| 209 | 209 | * @var string The source that the OpenGraph image should come from |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | 'boolean' |
| 295 | 295 | ], |
| 296 | 296 | [ |
| 297 | - ['seoImageSource', 'twitterImageSource', 'ogImageSource'], 'in', 'range' => [ |
|
| 297 | + [ 'seoImageSource', 'twitterImageSource', 'ogImageSource' ], 'in', 'range' => [ |
|
| 298 | 298 | 'sameAsSeo', |
| 299 | 299 | 'fromField', |
| 300 | 300 | 'fromAsset', |
@@ -302,28 +302,28 @@ discard block |
||
| 302 | 302 | ], |
| 303 | 303 | ], |
| 304 | 304 | [ |
| 305 | - ['seoTitleSource', 'twitterTitleSource', 'ogTitleSource'], 'in', 'range' => [ |
|
| 305 | + [ 'seoTitleSource', 'twitterTitleSource', 'ogTitleSource' ], 'in', 'range' => [ |
|
| 306 | 306 | 'sameAsSeo', |
| 307 | 307 | 'fromField', |
| 308 | 308 | 'fromCustom', |
| 309 | 309 | ], |
| 310 | 310 | ], |
| 311 | 311 | [ |
| 312 | - ['twitterCreatorSource'], 'in', 'range' => [ |
|
| 312 | + [ 'twitterCreatorSource' ], 'in', 'range' => [ |
|
| 313 | 313 | 'sameAsSiteTwitter', |
| 314 | 314 | 'fromUserField', |
| 315 | 315 | 'fromCustom', |
| 316 | 316 | ], |
| 317 | 317 | ], |
| 318 | 318 | [ |
| 319 | - ['siteNamePositionSource', 'twitterSiteNamePositionSource', 'ogSiteNamePositionSource'], 'in', 'range' => [ |
|
| 319 | + [ 'siteNamePositionSource', 'twitterSiteNamePositionSource', 'ogSiteNamePositionSource' ], 'in', 'range' => [ |
|
| 320 | 320 | 'sameAsSeo', |
| 321 | 321 | 'sameAsGlobal', |
| 322 | 322 | 'fromCustom', |
| 323 | 323 | ], |
| 324 | 324 | ], |
| 325 | 325 | [ |
| 326 | - ['seoDescriptionSource', 'twitterDescriptionSource', 'ogDescriptionSource'], 'in', 'range' => [ |
|
| 326 | + [ 'seoDescriptionSource', 'twitterDescriptionSource', 'ogDescriptionSource' ], 'in', 'range' => [ |
|
| 327 | 327 | 'sameAsSeo', |
| 328 | 328 | 'fromField', |
| 329 | 329 | 'summaryFromField', |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | ], |
| 332 | 332 | ], |
| 333 | 333 | [ |
| 334 | - ['seoKeywordsSource'], 'in', 'range' => [ |
|
| 334 | + [ 'seoKeywordsSource' ], 'in', 'range' => [ |
|
| 335 | 335 | 'sameAsSeo', |
| 336 | 336 | 'fromField', |
| 337 | 337 | 'keywordsFromField', |
@@ -339,7 +339,7 @@ discard block |
||
| 339 | 339 | ], |
| 340 | 340 | ], |
| 341 | 341 | [ |
| 342 | - ['seoImageDescriptionSource', 'twitterImageDescriptionSource', 'ogImageDescriptionSource'], 'in', 'range' => [ |
|
| 342 | + [ 'seoImageDescriptionSource', 'twitterImageDescriptionSource', 'ogImageDescriptionSource' ], 'in', 'range' => [ |
|
| 343 | 343 | 'sameAsSeo', |
| 344 | 344 | 'fromField', |
| 345 | 345 | 'summaryFromField', |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | 'twitterImageIds', |
| 353 | 353 | 'ogImageIds', |
| 354 | 354 | ], |
| 355 | - 'each', 'rule' => ['integer'], |
|
| 355 | + 'each', 'rule' => [ 'integer' ], |
|
| 356 | 356 | ], |
| 357 | 357 | ]; |
| 358 | 358 | } |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | 'seoDescriptionField' => '', |
| 25 | 25 | 'seoKeywordsSource' => 'fromCustom', |
| 26 | 26 | 'seoKeywordsField' => '', |
| 27 | - 'seoImageIds' => [], |
|
| 27 | + 'seoImageIds' => [ ], |
|
| 28 | 28 | 'seoImageSource' => 'fromAsset', |
| 29 | 29 | 'seoImageField' => '', |
| 30 | 30 | 'seoImageTransform' => true, |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | 'twitterSiteNamePositionSource' => 'sameAsGlobal', |
| 39 | 39 | 'twitterDescriptionSource' => 'sameAsSeo', |
| 40 | 40 | 'twitterDescriptionField' => '', |
| 41 | - 'twitterImageIds' => [], |
|
| 41 | + 'twitterImageIds' => [ ], |
|
| 42 | 42 | 'twitterImageSource' => 'sameAsSeo', |
| 43 | 43 | 'twitterImageField' => '', |
| 44 | 44 | 'twitterImageTransform' => true, |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | 'ogSiteNamePositionSource' => 'sameAsGlobal', |
| 51 | 51 | 'ogDescriptionSource' => 'sameAsSeo', |
| 52 | 52 | 'ogDescriptionField' => '', |
| 53 | - 'ogImageIds' => [], |
|
| 53 | + 'ogImageIds' => [ ], |
|
| 54 | 54 | 'ogImageSource' => 'sameAsSeo', |
| 55 | 55 | 'ogImageField' => '', |
| 56 | 56 | 'ogImageTransform' => true, |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | 'seoDescriptionField' => '', |
| 25 | 25 | 'seoKeywordsSource' => 'fromCustom', |
| 26 | 26 | 'seoKeywordsField' => '', |
| 27 | - 'seoImageIds' => [], |
|
| 27 | + 'seoImageIds' => [ ], |
|
| 28 | 28 | 'seoImageSource' => 'fromAsset', |
| 29 | 29 | 'seoImageField' => '', |
| 30 | 30 | 'seoImageTransform' => true, |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | 'twitterSiteNamePositionSource' => 'sameAsGlobal', |
| 39 | 39 | 'twitterDescriptionSource' => 'sameAsSeo', |
| 40 | 40 | 'twitterDescriptionField' => '', |
| 41 | - 'twitterImageIds' => [], |
|
| 41 | + 'twitterImageIds' => [ ], |
|
| 42 | 42 | 'twitterImageSource' => 'sameAsSeo', |
| 43 | 43 | 'twitterImageField' => '', |
| 44 | 44 | 'twitterImageTransform' => true, |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | 'ogSiteNamePositionSource' => 'sameAsGlobal', |
| 51 | 51 | 'ogDescriptionSource' => 'sameAsSeo', |
| 52 | 52 | 'ogDescriptionField' => '', |
| 53 | - 'ogImageIds' => [], |
|
| 53 | + 'ogImageIds' => [ ], |
|
| 54 | 54 | 'ogImageSource' => 'sameAsSeo', |
| 55 | 55 | 'ogImageField' => '', |
| 56 | 56 | 'ogImageTransform' => true, |
@@ -46,33 +46,33 @@ 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' => 'siteNamePosition', 'seoField' => 'siteNamePosition'], |
|
| 51 | - ['fieldName' => 'seoDescription', 'seoField' => 'seoDescription'], |
|
| 52 | - ['fieldName' => 'seoKeywords', 'seoField' => 'seoKeywords'], |
|
| 53 | - ['fieldName' => 'seoImageDescription', 'seoField' => 'seoImageDescription'], |
|
| 54 | - ['fieldName' => 'ogTitle', 'seoField' => 'seoTitle'], |
|
| 55 | - ['fieldName' => 'ogSiteNamePosition', 'seoField' => 'siteNamePosition'], |
|
| 56 | - ['fieldName' => 'ogDescription', 'seoField' => 'seoDescription'], |
|
| 57 | - ['fieldName' => 'ogImageDescription', 'seoField' => 'seoImageDescription'], |
|
| 58 | - ['fieldName' => 'twitterTitle', 'seoField' => 'seoTitle'], |
|
| 59 | - ['fieldName' => 'twitterSiteNamePosition', 'seoField' => 'siteNamePosition'], |
|
| 60 | - ['fieldName' => 'twitterCreator', 'seoField' => 'twitterHandle'], |
|
| 61 | - ['fieldName' => 'twitterDescription', 'seoField' => 'seoDescription'], |
|
| 62 | - ['fieldName' => 'twitterImageDescription', 'seoField' => 'seoImageDescription'], |
|
| 49 | + [ 'fieldName' => 'seoTitle', 'seoField' => 'seoTitle' ], |
|
| 50 | + [ 'fieldName' => 'siteNamePosition', 'seoField' => 'siteNamePosition' ], |
|
| 51 | + [ 'fieldName' => 'seoDescription', 'seoField' => 'seoDescription' ], |
|
| 52 | + [ 'fieldName' => 'seoKeywords', 'seoField' => 'seoKeywords' ], |
|
| 53 | + [ 'fieldName' => 'seoImageDescription', 'seoField' => 'seoImageDescription' ], |
|
| 54 | + [ 'fieldName' => 'ogTitle', 'seoField' => 'seoTitle' ], |
|
| 55 | + [ 'fieldName' => 'ogSiteNamePosition', 'seoField' => 'siteNamePosition' ], |
|
| 56 | + [ 'fieldName' => 'ogDescription', 'seoField' => 'seoDescription' ], |
|
| 57 | + [ 'fieldName' => 'ogImageDescription', 'seoField' => 'seoImageDescription' ], |
|
| 58 | + [ 'fieldName' => 'twitterTitle', 'seoField' => 'seoTitle' ], |
|
| 59 | + [ 'fieldName' => 'twitterSiteNamePosition', 'seoField' => 'siteNamePosition' ], |
|
| 60 | + [ 'fieldName' => 'twitterCreator', 'seoField' => 'twitterHandle' ], |
|
| 61 | + [ 'fieldName' => 'twitterDescription', 'seoField' => 'seoDescription' ], |
|
| 62 | + [ 'fieldName' => 'twitterImageDescription', 'seoField' => 'seoImageDescription' ], |
|
| 63 | 63 | ]; |
| 64 | 64 | |
| 65 | 65 | const PULL_ASSET_FIELDS = [ |
| 66 | - ['fieldName' => 'seoImage', 'seoField' => 'seoImage', 'transformName' => 'base'], |
|
| 67 | - ['fieldName' => 'ogImage', 'seoField' => 'seoImage', 'transformName' => 'facebook'], |
|
| 68 | - ['fieldName' => 'twitterImage', 'seoField' => 'seoImage', 'transformName' => 'twitter'], |
|
| 66 | + [ 'fieldName' => 'seoImage', 'seoField' => 'seoImage', 'transformName' => 'base' ], |
|
| 67 | + [ 'fieldName' => 'ogImage', 'seoField' => 'seoImage', 'transformName' => 'facebook' ], |
|
| 68 | + [ 'fieldName' => 'twitterImage', 'seoField' => 'seoImage', 'transformName' => 'twitter' ], |
|
| 69 | 69 | ]; |
| 70 | 70 | |
| 71 | 71 | const SETUP_GRADES = [ |
| 72 | - ['id' => 'data1', 'name' => 'A', 'color' => '#008002'], |
|
| 73 | - ['id' => 'data2', 'name' => 'B', 'color' => '#9ACD31'], |
|
| 74 | - ['id' => 'data4', 'name' => 'C', 'color' => '#FFA500'], |
|
| 75 | - ['id' => 'data5', 'name' => 'D', 'color' => '#8B0100'], |
|
| 72 | + [ 'id' => 'data1', 'name' => 'A', 'color' => '#008002' ], |
|
| 73 | + [ 'id' => 'data2', 'name' => 'B', 'color' => '#9ACD31' ], |
|
| 74 | + [ 'id' => 'data4', 'name' => 'C', 'color' => '#FFA500' ], |
|
| 75 | + [ 'id' => 'data5', 'name' => 'D', 'color' => '#8B0100' ], |
|
| 76 | 76 | ]; |
| 77 | 77 | |
| 78 | 78 | const SEO_SETUP_FIELDS = [ |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | public function actionDashboard(string $siteHandle = null, bool $showWelcome = false): Response |
| 115 | 115 | { |
| 116 | - $variables = []; |
|
| 116 | + $variables = [ ]; |
|
| 117 | 117 | // Get the site to edit |
| 118 | 118 | $siteId = $this->getSiteIdFromHandle($siteHandle); |
| 119 | 119 | $pluginName = Seomatic::$settings->pluginName; |
@@ -125,20 +125,20 @@ discard block |
||
| 125 | 125 | } catch (InvalidConfigException $e) { |
| 126 | 126 | Craft::error($e->getMessage(), __METHOD__); |
| 127 | 127 | } |
| 128 | - $variables['baseAssetsUrl'] = Craft::$app->assetManager->getPublishedUrl( |
|
| 128 | + $variables[ 'baseAssetsUrl' ] = Craft::$app->assetManager->getPublishedUrl( |
|
| 129 | 129 | '@nystudio107/seomatic/assetbundles/seomatic/dist', |
| 130 | 130 | true |
| 131 | 131 | ); |
| 132 | 132 | // Enabled sites |
| 133 | 133 | $this->setMultiSiteVariables($siteHandle, $siteId, $variables); |
| 134 | - $variables['controllerHandle'] = 'dashboard'; |
|
| 134 | + $variables[ 'controllerHandle' ] = 'dashboard'; |
|
| 135 | 135 | |
| 136 | 136 | // Basic variables |
| 137 | - $variables['fullPageForm'] = false; |
|
| 138 | - $variables['docsUrl'] = self::DOCUMENTATION_URL; |
|
| 139 | - $variables['pluginName'] = Seomatic::$settings->pluginName; |
|
| 140 | - $variables['title'] = $templateTitle; |
|
| 141 | - $variables['crumbs'] = [ |
|
| 137 | + $variables[ 'fullPageForm' ] = false; |
|
| 138 | + $variables[ 'docsUrl' ] = self::DOCUMENTATION_URL; |
|
| 139 | + $variables[ 'pluginName' ] = Seomatic::$settings->pluginName; |
|
| 140 | + $variables[ 'title' ] = $templateTitle; |
|
| 141 | + $variables[ 'crumbs' ] = [ |
|
| 142 | 142 | [ |
| 143 | 143 | 'label' => $pluginName, |
| 144 | 144 | 'url' => UrlHelper::cpUrl('seomatic'), |
@@ -148,47 +148,47 @@ discard block |
||
| 148 | 148 | 'url' => UrlHelper::cpUrl('seomatic/dashboard'), |
| 149 | 149 | ], |
| 150 | 150 | ]; |
| 151 | - $variables['selectedSubnavItem'] = 'dashboard'; |
|
| 152 | - $variables['showWelcome'] = $showWelcome; |
|
| 151 | + $variables[ 'selectedSubnavItem' ] = 'dashboard'; |
|
| 152 | + $variables[ 'showWelcome' ] = $showWelcome; |
|
| 153 | 153 | // Calulate the setup grades |
| 154 | - $variables['contentSetupStats'] = []; |
|
| 155 | - $variables['setupGrades'] = self::SETUP_GRADES; |
|
| 154 | + $variables[ 'contentSetupStats' ] = [ ]; |
|
| 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; |
|
| 159 | + $variables[ 'contentSetupStats' ][ ] = 0; |
|
| 160 | 160 | } |
| 161 | 161 | $numGrades = count(self::SETUP_GRADES); |
| 162 | 162 | // Content SEO grades |
| 163 | - $variables['metaBundles'] = Seomatic::$plugin->metaBundles->getContentMetaBundlesForSiteId($siteId); |
|
| 163 | + $variables[ 'metaBundles' ] = Seomatic::$plugin->metaBundles->getContentMetaBundlesForSiteId($siteId); |
|
| 164 | 164 | /** @var MetaBundle $metaBundle */ |
| 165 | - foreach ($variables['metaBundles'] as $metaBundle) { |
|
| 165 | + foreach ($variables[ 'metaBundles' ] as $metaBundle) { |
|
| 166 | 166 | $stat = 0; |
| 167 | 167 | foreach (self::SEO_SETUP_FIELDS as $setupField) { |
| 168 | - $stat += intval(!empty($metaBundle->metaGlobalVars[$setupField])); |
|
| 168 | + $stat += intval(!empty($metaBundle->metaGlobalVars[ $setupField ])); |
|
| 169 | 169 | } |
| 170 | 170 | $stat = round($numGrades - (($stat * $numGrades) / $numFields)); |
| 171 | 171 | if ($stat >= $numGrades) { |
| 172 | 172 | $stat = $numGrades - 1; |
| 173 | 173 | } |
| 174 | - $variables['contentSetupStats'][$stat]++; |
|
| 174 | + $variables[ 'contentSetupStats' ][ $stat ]++; |
|
| 175 | 175 | } |
| 176 | 176 | // Global SEO grades |
| 177 | 177 | $metaBundle = Seomatic::$plugin->metaBundles->getGlobalMetaBundle(intval($siteId)); |
| 178 | 178 | $stat = 0; |
| 179 | 179 | foreach (self::SEO_SETUP_FIELDS as $setupField) { |
| 180 | - $stat += intval(!empty($metaBundle->metaGlobalVars[$setupField])); |
|
| 180 | + $stat += intval(!empty($metaBundle->metaGlobalVars[ $setupField ])); |
|
| 181 | 181 | } |
| 182 | 182 | $stat = round(($stat / $numFields) * 100); |
| 183 | - $variables['globalSetupStat'] = $stat; |
|
| 183 | + $variables[ 'globalSetupStat' ] = $stat; |
|
| 184 | 184 | // Site Settings grades |
| 185 | 185 | $numFields = count(self::SITE_SETUP_FIELDS); |
| 186 | 186 | $stat = 0; |
| 187 | 187 | foreach (self::SITE_SETUP_FIELDS as $setupField) { |
| 188 | - $stat += intval(!empty($metaBundle->metaSiteVars[$setupField])); |
|
| 188 | + $stat += intval(!empty($metaBundle->metaSiteVars[ $setupField ])); |
|
| 189 | 189 | } |
| 190 | 190 | $stat = round(($stat / $numFields) * 100); |
| 191 | - $variables['siteSetupStat'] = $stat; |
|
| 191 | + $variables[ 'siteSetupStat' ] = $stat; |
|
| 192 | 192 | |
| 193 | 193 | // Render the template |
| 194 | 194 | return $this->renderTemplate('seomatic/dashboard/index', $variables); |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | */ |
| 207 | 207 | public function actionGlobal(string $subSection = 'general', string $siteHandle = null): Response |
| 208 | 208 | { |
| 209 | - $variables = []; |
|
| 209 | + $variables = [ ]; |
|
| 210 | 210 | $siteId = $this->getSiteIdFromHandle($siteHandle); |
| 211 | 211 | |
| 212 | 212 | $pluginName = Seomatic::$settings->pluginName; |
@@ -218,18 +218,18 @@ discard block |
||
| 218 | 218 | } catch (InvalidConfigException $e) { |
| 219 | 219 | Craft::error($e->getMessage(), __METHOD__); |
| 220 | 220 | } |
| 221 | - $variables['baseAssetsUrl'] = Craft::$app->assetManager->getPublishedUrl( |
|
| 221 | + $variables[ 'baseAssetsUrl' ] = Craft::$app->assetManager->getPublishedUrl( |
|
| 222 | 222 | '@nystudio107/seomatic/assetbundles/seomatic/dist', |
| 223 | 223 | true |
| 224 | 224 | ); |
| 225 | 225 | // Basic variables |
| 226 | - $variables['fullPageForm'] = true; |
|
| 227 | - $variables['docsUrl'] = self::DOCUMENTATION_URL; |
|
| 228 | - $variables['pluginName'] = Seomatic::$settings->pluginName; |
|
| 229 | - $variables['title'] = $templateTitle; |
|
| 230 | - $variables['subSectionTitle'] = $subSectionTitle; |
|
| 231 | - $variables['docTitle'] = $templateTitle.' - '.$subSectionTitle; |
|
| 232 | - $variables['crumbs'] = [ |
|
| 226 | + $variables[ 'fullPageForm' ] = true; |
|
| 227 | + $variables[ 'docsUrl' ] = self::DOCUMENTATION_URL; |
|
| 228 | + $variables[ 'pluginName' ] = Seomatic::$settings->pluginName; |
|
| 229 | + $variables[ 'title' ] = $templateTitle; |
|
| 230 | + $variables[ 'subSectionTitle' ] = $subSectionTitle; |
|
| 231 | + $variables[ 'docTitle' ] = $templateTitle . ' - ' . $subSectionTitle; |
|
| 232 | + $variables[ 'crumbs' ] = [ |
|
| 233 | 233 | [ |
| 234 | 234 | 'label' => $pluginName, |
| 235 | 235 | 'url' => UrlHelper::cpUrl('seomatic'), |
@@ -240,39 +240,39 @@ discard block |
||
| 240 | 240 | ], |
| 241 | 241 | [ |
| 242 | 242 | 'label' => $subSectionTitle, |
| 243 | - 'url' => UrlHelper::cpUrl('seomatic/global/'.$subSection), |
|
| 243 | + 'url' => UrlHelper::cpUrl('seomatic/global/' . $subSection), |
|
| 244 | 244 | ], |
| 245 | 245 | ]; |
| 246 | - $variables['selectedSubnavItem'] = 'global'; |
|
| 246 | + $variables[ 'selectedSubnavItem' ] = 'global'; |
|
| 247 | 247 | // Pass in the pull fields |
| 248 | 248 | $this->setGlobalFieldSourceVariables($variables); |
| 249 | 249 | // Enabled sites |
| 250 | 250 | $this->setMultiSiteVariables($siteHandle, $siteId, $variables); |
| 251 | - $variables['controllerHandle'] = 'global'.'/'.$subSection; |
|
| 252 | - $variables['currentSubSection'] = $subSection; |
|
| 251 | + $variables[ 'controllerHandle' ] = 'global' . '/' . $subSection; |
|
| 252 | + $variables[ 'currentSubSection' ] = $subSection; |
|
| 253 | 253 | // Meta bundle settings |
| 254 | - $metaBundle = Seomatic::$plugin->metaBundles->getGlobalMetaBundle(intval($variables['currentSiteId'])); |
|
| 255 | - $variables['globals'] = $metaBundle->metaGlobalVars; |
|
| 256 | - $variables['sitemap'] = $metaBundle->metaSitemapVars; |
|
| 257 | - $variables['settings'] = $metaBundle->metaBundleSettings; |
|
| 254 | + $metaBundle = Seomatic::$plugin->metaBundles->getGlobalMetaBundle(intval($variables[ 'currentSiteId' ])); |
|
| 255 | + $variables[ 'globals' ] = $metaBundle->metaGlobalVars; |
|
| 256 | + $variables[ 'sitemap' ] = $metaBundle->metaSitemapVars; |
|
| 257 | + $variables[ 'settings' ] = $metaBundle->metaBundleSettings; |
|
| 258 | 258 | // Template container settings |
| 259 | 259 | $templateContainers = $metaBundle->frontendTemplatesContainer->data; |
| 260 | - $variables['robotsTemplate'] = $templateContainers[FrontendTemplates::ROBOTS_TXT_HANDLE]; |
|
| 261 | - $variables['humansTemplate'] = $templateContainers[FrontendTemplates::HUMANS_TXT_HANDLE]; |
|
| 260 | + $variables[ 'robotsTemplate' ] = $templateContainers[ FrontendTemplates::ROBOTS_TXT_HANDLE ]; |
|
| 261 | + $variables[ 'humansTemplate' ] = $templateContainers[ FrontendTemplates::HUMANS_TXT_HANDLE ]; |
|
| 262 | 262 | // Image selectors |
| 263 | 263 | $bundleSettings = $metaBundle->metaBundleSettings; |
| 264 | - $variables['elementType'] = Asset::class; |
|
| 265 | - $variables['seoImageElements'] = $this->assetElementsFromIds($bundleSettings->seoImageIds, $siteId); |
|
| 266 | - $variables['twitterImageElements'] = $this->assetElementsFromIds($bundleSettings->twitterImageIds, $siteId); |
|
| 267 | - $variables['ogImageElements'] = $this->assetElementsFromIds($bundleSettings->ogImageIds, $siteId); |
|
| 264 | + $variables[ 'elementType' ] = Asset::class; |
|
| 265 | + $variables[ 'seoImageElements' ] = $this->assetElementsFromIds($bundleSettings->seoImageIds, $siteId); |
|
| 266 | + $variables[ 'twitterImageElements' ] = $this->assetElementsFromIds($bundleSettings->twitterImageIds, $siteId); |
|
| 267 | + $variables[ 'ogImageElements' ] = $this->assetElementsFromIds($bundleSettings->ogImageIds, $siteId); |
|
| 268 | 268 | // Preview the meta containers |
| 269 | 269 | Seomatic::$plugin->metaContainers->previewMetaContainers( |
| 270 | 270 | MetaBundles::GLOBAL_META_BUNDLE, |
| 271 | - intval($variables['currentSiteId']) |
|
| 271 | + intval($variables[ 'currentSiteId' ]) |
|
| 272 | 272 | ); |
| 273 | 273 | |
| 274 | 274 | // Render the template |
| 275 | - return $this->renderTemplate('seomatic/settings/global/'.$subSection, $variables); |
|
| 275 | + return $this->renderTemplate('seomatic/settings/global/' . $subSection, $variables); |
|
| 276 | 276 | } |
| 277 | 277 | |
| 278 | 278 | /** |
@@ -302,11 +302,11 @@ discard block |
||
| 302 | 302 | $metaBundle->metaBundleSettings->setAttributes($bundleSettings); |
| 303 | 303 | } |
| 304 | 304 | $templateContainers = $metaBundle->frontendTemplatesContainer->data; |
| 305 | - $robotsContainer = $templateContainers[FrontendTemplates::ROBOTS_TXT_HANDLE]; |
|
| 305 | + $robotsContainer = $templateContainers[ FrontendTemplates::ROBOTS_TXT_HANDLE ]; |
|
| 306 | 306 | if (!empty($robotsContainer) && is_array($robotsTemplate)) { |
| 307 | 307 | $robotsContainer->setAttributes($robotsTemplate); |
| 308 | 308 | } |
| 309 | - $humansContainer = $templateContainers[FrontendTemplates::HUMANS_TXT_HANDLE]; |
|
| 309 | + $humansContainer = $templateContainers[ FrontendTemplates::HUMANS_TXT_HANDLE ]; |
|
| 310 | 310 | if (!empty($humansContainer) && is_array($humansTemplate)) { |
| 311 | 311 | $humansContainer->setAttributes($humansTemplate); |
| 312 | 312 | } |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | */ |
| 332 | 332 | public function actionContent(string $siteHandle = null): Response |
| 333 | 333 | { |
| 334 | - $variables = []; |
|
| 334 | + $variables = [ ]; |
|
| 335 | 335 | // Get the site to edit |
| 336 | 336 | $siteId = $this->getSiteIdFromHandle($siteHandle); |
| 337 | 337 | |
@@ -343,16 +343,16 @@ discard block |
||
| 343 | 343 | } catch (InvalidConfigException $e) { |
| 344 | 344 | Craft::error($e->getMessage(), __METHOD__); |
| 345 | 345 | } |
| 346 | - $variables['baseAssetsUrl'] = Craft::$app->assetManager->getPublishedUrl( |
|
| 346 | + $variables[ 'baseAssetsUrl' ] = Craft::$app->assetManager->getPublishedUrl( |
|
| 347 | 347 | '@nystudio107/seomatic/assetbundles/seomatic/dist', |
| 348 | 348 | true |
| 349 | 349 | ); |
| 350 | 350 | // Basic variables |
| 351 | - $variables['fullPageForm'] = false; |
|
| 352 | - $variables['docsUrl'] = self::DOCUMENTATION_URL; |
|
| 353 | - $variables['pluginName'] = Seomatic::$settings->pluginName; |
|
| 354 | - $variables['title'] = $templateTitle; |
|
| 355 | - $variables['crumbs'] = [ |
|
| 351 | + $variables[ 'fullPageForm' ] = false; |
|
| 352 | + $variables[ 'docsUrl' ] = self::DOCUMENTATION_URL; |
|
| 353 | + $variables[ 'pluginName' ] = Seomatic::$settings->pluginName; |
|
| 354 | + $variables[ 'title' ] = $templateTitle; |
|
| 355 | + $variables[ 'crumbs' ] = [ |
|
| 356 | 356 | [ |
| 357 | 357 | 'label' => $pluginName, |
| 358 | 358 | 'url' => UrlHelper::cpUrl('seomatic'), |
@@ -363,9 +363,9 @@ discard block |
||
| 363 | 363 | ], |
| 364 | 364 | ]; |
| 365 | 365 | $this->setMultiSiteVariables($siteHandle, $siteId, $variables); |
| 366 | - $variables['controllerHandle'] = 'content'; |
|
| 367 | - $variables['selectedSubnavItem'] = 'content'; |
|
| 368 | - $variables['metaBundles'] = Seomatic::$plugin->metaBundles->getContentMetaBundlesForSiteId($siteId); |
|
| 366 | + $variables[ 'controllerHandle' ] = 'content'; |
|
| 367 | + $variables[ 'selectedSubnavItem' ] = 'content'; |
|
| 368 | + $variables[ 'metaBundles' ] = Seomatic::$plugin->metaBundles->getContentMetaBundlesForSiteId($siteId); |
|
| 369 | 369 | |
| 370 | 370 | // Render the template |
| 371 | 371 | return $this->renderTemplate('seomatic/settings/content/index', $variables); |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | string $sourceHandle, |
| 390 | 390 | string $siteHandle = null |
| 391 | 391 | ): Response { |
| 392 | - $variables = []; |
|
| 392 | + $variables = [ ]; |
|
| 393 | 393 | // @TODO: Let people choose an entry/categorygroup/product as the preview |
| 394 | 394 | // Get the site to edit |
| 395 | 395 | $siteId = $this->getSiteIdFromHandle($siteHandle); |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | } catch (InvalidConfigException $e) { |
| 402 | 402 | Craft::error($e->getMessage(), __METHOD__); |
| 403 | 403 | } |
| 404 | - $variables['baseAssetsUrl'] = Craft::$app->assetManager->getPublishedUrl( |
|
| 404 | + $variables[ 'baseAssetsUrl' ] = Craft::$app->assetManager->getPublishedUrl( |
|
| 405 | 405 | '@nystudio107/seomatic/assetbundles/seomatic/dist', |
| 406 | 406 | true |
| 407 | 407 | ); |
@@ -411,22 +411,22 @@ discard block |
||
| 411 | 411 | $metaBundle = Seomatic::$plugin->metaBundles->getMetaBundleBySourceHandle( |
| 412 | 412 | $sourceBundleType, |
| 413 | 413 | $sourceHandle, |
| 414 | - intval($variables['currentSiteId']) |
|
| 414 | + intval($variables[ 'currentSiteId' ]) |
|
| 415 | 415 | ); |
| 416 | - $variables['globals'] = $metaBundle->metaGlobalVars; |
|
| 417 | - $variables['sitemap'] = $metaBundle->metaSitemapVars; |
|
| 418 | - $variables['settings'] = $metaBundle->metaBundleSettings; |
|
| 419 | - $variables['currentSourceHandle'] = $metaBundle->sourceHandle; |
|
| 420 | - $variables['currentSourceBundleType'] = $metaBundle->sourceBundleType; |
|
| 416 | + $variables[ 'globals' ] = $metaBundle->metaGlobalVars; |
|
| 417 | + $variables[ 'sitemap' ] = $metaBundle->metaSitemapVars; |
|
| 418 | + $variables[ 'settings' ] = $metaBundle->metaBundleSettings; |
|
| 419 | + $variables[ 'currentSourceHandle' ] = $metaBundle->sourceHandle; |
|
| 420 | + $variables[ 'currentSourceBundleType' ] = $metaBundle->sourceBundleType; |
|
| 421 | 421 | // Basic variables |
| 422 | 422 | $templateTitle = $metaBundle->sourceName; |
| 423 | 423 | $subSectionTitle = Craft::t('seomatic', ucfirst($subSection)); |
| 424 | - $variables['fullPageForm'] = true; |
|
| 425 | - $variables['docsUrl'] = self::DOCUMENTATION_URL; |
|
| 426 | - $variables['pluginName'] = Seomatic::$settings->pluginName; |
|
| 427 | - $variables['title'] = $templateTitle; |
|
| 428 | - $variables['subSectionTitle'] = $subSectionTitle; |
|
| 429 | - $variables['crumbs'] = [ |
|
| 424 | + $variables[ 'fullPageForm' ] = true; |
|
| 425 | + $variables[ 'docsUrl' ] = self::DOCUMENTATION_URL; |
|
| 426 | + $variables[ 'pluginName' ] = Seomatic::$settings->pluginName; |
|
| 427 | + $variables[ 'title' ] = $templateTitle; |
|
| 428 | + $variables[ 'subSectionTitle' ] = $subSectionTitle; |
|
| 429 | + $variables[ 'crumbs' ] = [ |
|
| 430 | 430 | [ |
| 431 | 431 | 'label' => $pluginName, |
| 432 | 432 | 'url' => UrlHelper::cpUrl('seomatic'), |
@@ -436,19 +436,19 @@ discard block |
||
| 436 | 436 | 'url' => UrlHelper::cpUrl('seomatic/content'), |
| 437 | 437 | ], |
| 438 | 438 | [ |
| 439 | - 'label' => $metaBundle->sourceName.' · '.$subSectionTitle, |
|
| 439 | + 'label' => $metaBundle->sourceName . ' · ' . $subSectionTitle, |
|
| 440 | 440 | 'url' => UrlHelper::cpUrl("seomatic/edit-content/${subSection}/${sourceBundleType}/${sourceHandle}"), |
| 441 | 441 | ], |
| 442 | 442 | ]; |
| 443 | - $variables['selectedSubnavItem'] = 'content'; |
|
| 444 | - $variables['controllerHandle'] = "edit-content/${subSection}/${sourceBundleType}/${sourceHandle}"; |
|
| 443 | + $variables[ 'selectedSubnavItem' ] = 'content'; |
|
| 444 | + $variables[ 'controllerHandle' ] = "edit-content/${subSection}/${sourceBundleType}/${sourceHandle}"; |
|
| 445 | 445 | // Image selectors |
| 446 | - $variables['currentSubSection'] = $subSection; |
|
| 446 | + $variables[ 'currentSubSection' ] = $subSection; |
|
| 447 | 447 | $bundleSettings = $metaBundle->metaBundleSettings; |
| 448 | - $variables['elementType'] = Asset::class; |
|
| 449 | - $variables['seoImageElements'] = $this->assetElementsFromIds($bundleSettings->seoImageIds, $siteId); |
|
| 450 | - $variables['twitterImageElements'] = $this->assetElementsFromIds($bundleSettings->twitterImageIds, $siteId); |
|
| 451 | - $variables['ogImageElements'] = $this->assetElementsFromIds($bundleSettings->ogImageIds, $siteId); |
|
| 448 | + $variables[ 'elementType' ] = Asset::class; |
|
| 449 | + $variables[ 'seoImageElements' ] = $this->assetElementsFromIds($bundleSettings->seoImageIds, $siteId); |
|
| 450 | + $variables[ 'twitterImageElements' ] = $this->assetElementsFromIds($bundleSettings->twitterImageIds, $siteId); |
|
| 451 | + $variables[ 'ogImageElements' ] = $this->assetElementsFromIds($bundleSettings->ogImageIds, $siteId); |
|
| 452 | 452 | // Pass in the pull fields |
| 453 | 453 | $groupName = "Entry"; |
| 454 | 454 | $this->setContentFieldSourceVariables($sourceBundleType, $sourceHandle, $groupName, $variables); |
@@ -456,11 +456,11 @@ discard block |
||
| 456 | 456 | // Preview the meta containers |
| 457 | 457 | Seomatic::$plugin->metaContainers->previewMetaContainers( |
| 458 | 458 | $uri, |
| 459 | - intval($variables['currentSiteId']) |
|
| 459 | + intval($variables[ 'currentSiteId' ]) |
|
| 460 | 460 | ); |
| 461 | 461 | |
| 462 | 462 | // Render the template |
| 463 | - return $this->renderTemplate('seomatic/settings/content/'.$subSection, $variables); |
|
| 463 | + return $this->renderTemplate('seomatic/settings/content/' . $subSection, $variables); |
|
| 464 | 464 | } |
| 465 | 465 | |
| 466 | 466 | |
@@ -529,7 +529,7 @@ discard block |
||
| 529 | 529 | */ |
| 530 | 530 | public function actionSite(string $subSection = 'identity', string $siteHandle = null): Response |
| 531 | 531 | { |
| 532 | - $variables = []; |
|
| 532 | + $variables = [ ]; |
|
| 533 | 533 | // Get the site to edit |
| 534 | 534 | $siteId = $this->getSiteIdFromHandle($siteHandle); |
| 535 | 535 | |
@@ -539,24 +539,24 @@ discard block |
||
| 539 | 539 | if ($subSection == "social") { |
| 540 | 540 | $subSectionSuffix = " Media"; |
| 541 | 541 | } |
| 542 | - $subSectionTitle = Craft::t('seomatic', ucfirst($subSection).$subSectionSuffix); |
|
| 542 | + $subSectionTitle = Craft::t('seomatic', ucfirst($subSection) . $subSectionSuffix); |
|
| 543 | 543 | // Asset bundle |
| 544 | 544 | try { |
| 545 | 545 | Seomatic::$view->registerAssetBundle(SeomaticAsset::class); |
| 546 | 546 | } catch (InvalidConfigException $e) { |
| 547 | 547 | Craft::error($e->getMessage(), __METHOD__); |
| 548 | 548 | } |
| 549 | - $variables['baseAssetsUrl'] = Craft::$app->assetManager->getPublishedUrl( |
|
| 549 | + $variables[ 'baseAssetsUrl' ] = Craft::$app->assetManager->getPublishedUrl( |
|
| 550 | 550 | '@nystudio107/seomatic/assetbundles/seomatic/dist', |
| 551 | 551 | true |
| 552 | 552 | ); |
| 553 | 553 | // Basic variables |
| 554 | - $variables['fullPageForm'] = true; |
|
| 555 | - $variables['docsUrl'] = self::DOCUMENTATION_URL; |
|
| 556 | - $variables['pluginName'] = Seomatic::$settings->pluginName; |
|
| 557 | - $variables['title'] = $templateTitle; |
|
| 558 | - $variables['subSectionTitle'] = $subSectionTitle; |
|
| 559 | - $variables['crumbs'] = [ |
|
| 554 | + $variables[ 'fullPageForm' ] = true; |
|
| 555 | + $variables[ 'docsUrl' ] = self::DOCUMENTATION_URL; |
|
| 556 | + $variables[ 'pluginName' ] = Seomatic::$settings->pluginName; |
|
| 557 | + $variables[ 'title' ] = $templateTitle; |
|
| 558 | + $variables[ 'subSectionTitle' ] = $subSectionTitle; |
|
| 559 | + $variables[ 'crumbs' ] = [ |
|
| 560 | 560 | [ |
| 561 | 561 | 'label' => $pluginName, |
| 562 | 562 | 'url' => UrlHelper::cpUrl('seomatic'), |
@@ -567,24 +567,24 @@ discard block |
||
| 567 | 567 | ], |
| 568 | 568 | [ |
| 569 | 569 | 'label' => $subSectionTitle, |
| 570 | - 'url' => UrlHelper::cpUrl('seomatic/site/'.$subSection), |
|
| 570 | + 'url' => UrlHelper::cpUrl('seomatic/site/' . $subSection), |
|
| 571 | 571 | ], |
| 572 | 572 | ]; |
| 573 | - $variables['selectedSubnavItem'] = 'site'; |
|
| 574 | - $variables['currentSubSection'] = $subSection; |
|
| 573 | + $variables[ 'selectedSubnavItem' ] = 'site'; |
|
| 574 | + $variables[ 'currentSubSection' ] = $subSection; |
|
| 575 | 575 | |
| 576 | 576 | // Enabled sites |
| 577 | 577 | $this->setMultiSiteVariables($siteHandle, $siteId, $variables); |
| 578 | - $variables['controllerHandle'] = 'site'.'/'.$subSection; |
|
| 578 | + $variables[ 'controllerHandle' ] = 'site' . '/' . $subSection; |
|
| 579 | 579 | |
| 580 | 580 | // The site settings for the appropriate meta bundle |
| 581 | - $metaBundle = Seomatic::$plugin->metaBundles->getGlobalMetaBundle(intval($variables['currentSiteId'])); |
|
| 582 | - $variables['site'] = $metaBundle->metaSiteVars; |
|
| 583 | - $variables['genericImageElements'] = $this->assetElementsFromIds($variables['site']->identity->genericImageIds, $siteId); |
|
| 584 | - $variables['elementType'] = Asset::class; |
|
| 581 | + $metaBundle = Seomatic::$plugin->metaBundles->getGlobalMetaBundle(intval($variables[ 'currentSiteId' ])); |
|
| 582 | + $variables[ 'site' ] = $metaBundle->metaSiteVars; |
|
| 583 | + $variables[ 'genericImageElements' ] = $this->assetElementsFromIds($variables[ 'site' ]->identity->genericImageIds, $siteId); |
|
| 584 | + $variables[ 'elementType' ] = Asset::class; |
|
| 585 | 585 | |
| 586 | 586 | // Render the template |
| 587 | - return $this->renderTemplate('seomatic/settings/site/'.$subSection, $variables); |
|
| 587 | + return $this->renderTemplate('seomatic/settings/site/' . $subSection, $variables); |
|
| 588 | 588 | } |
| 589 | 589 | |
| 590 | 590 | /** |
@@ -599,26 +599,26 @@ discard block |
||
| 599 | 599 | $siteSettings = $request->getParam('site'); |
| 600 | 600 | |
| 601 | 601 | // Make sure the twitter handle isn't prefixed with an @ |
| 602 | - if (!empty($siteSettings['twitterHandle'])) { |
|
| 603 | - $siteSettings['twitterHandle'] = ltrim($siteSettings['twitterHandle'], '@'); |
|
| 602 | + if (!empty($siteSettings[ 'twitterHandle' ])) { |
|
| 603 | + $siteSettings[ 'twitterHandle' ] = ltrim($siteSettings[ 'twitterHandle' ], '@'); |
|
| 604 | 604 | } |
| 605 | 605 | // Make sure the sameAsLinks are indexed by the handle |
| 606 | - if (!empty($siteSettings['sameAsLinks'])) { |
|
| 607 | - $siteSettings['sameAsLinks'] = ArrayHelper::index($siteSettings['sameAsLinks'], 'handle'); |
|
| 606 | + if (!empty($siteSettings[ 'sameAsLinks' ])) { |
|
| 607 | + $siteSettings[ 'sameAsLinks' ] = ArrayHelper::index($siteSettings[ 'sameAsLinks' ], 'handle'); |
|
| 608 | 608 | } |
| 609 | 609 | // The site settings for the appropriate meta bundle |
| 610 | 610 | $metaBundle = Seomatic::$plugin->metaBundles->getGlobalMetaBundle($siteId); |
| 611 | 611 | if ($metaBundle) { |
| 612 | 612 | if (is_array($siteSettings)) { |
| 613 | - if (!empty($siteSettings['identity'])) { |
|
| 614 | - $this->normalizeTimes($siteSettings['identity']['localBusinessOpeningHours']); |
|
| 615 | - $metaBundle->metaSiteVars->identity->setAttributes($siteSettings['identity']); |
|
| 616 | - $siteSettings['identity'] = $metaBundle->metaSiteVars->identity; |
|
| 613 | + if (!empty($siteSettings[ 'identity' ])) { |
|
| 614 | + $this->normalizeTimes($siteSettings[ 'identity' ][ 'localBusinessOpeningHours' ]); |
|
| 615 | + $metaBundle->metaSiteVars->identity->setAttributes($siteSettings[ 'identity' ]); |
|
| 616 | + $siteSettings[ 'identity' ] = $metaBundle->metaSiteVars->identity; |
|
| 617 | 617 | } |
| 618 | - if (!empty($siteSettings['creator'])) { |
|
| 619 | - $this->normalizeTimes($siteSettings['creator']['localBusinessOpeningHours']); |
|
| 620 | - $metaBundle->metaSiteVars->creator->setAttributes($siteSettings['creator']); |
|
| 621 | - $siteSettings['creator'] = $metaBundle->metaSiteVars->creator; |
|
| 618 | + if (!empty($siteSettings[ 'creator' ])) { |
|
| 619 | + $this->normalizeTimes($siteSettings[ 'creator' ][ 'localBusinessOpeningHours' ]); |
|
| 620 | + $metaBundle->metaSiteVars->creator->setAttributes($siteSettings[ 'creator' ]); |
|
| 621 | + $siteSettings[ 'creator' ] = $metaBundle->metaSiteVars->creator; |
|
| 622 | 622 | } |
| 623 | 623 | $metaBundle->metaSiteVars->setAttributes($siteSettings); |
| 624 | 624 | } |
@@ -638,7 +638,7 @@ discard block |
||
| 638 | 638 | */ |
| 639 | 639 | public function actionPlugin(): Response |
| 640 | 640 | { |
| 641 | - $variables = []; |
|
| 641 | + $variables = [ ]; |
|
| 642 | 642 | $pluginName = Seomatic::$settings->pluginName; |
| 643 | 643 | $templateTitle = Craft::t('seomatic', 'Plugin Settings'); |
| 644 | 644 | // Asset bundle |
@@ -647,16 +647,16 @@ discard block |
||
| 647 | 647 | } catch (InvalidConfigException $e) { |
| 648 | 648 | Craft::error($e->getMessage(), __METHOD__); |
| 649 | 649 | } |
| 650 | - $variables['baseAssetsUrl'] = Craft::$app->assetManager->getPublishedUrl( |
|
| 650 | + $variables[ 'baseAssetsUrl' ] = Craft::$app->assetManager->getPublishedUrl( |
|
| 651 | 651 | '@nystudio107/seomatic/assetbundles/seomatic/dist', |
| 652 | 652 | true |
| 653 | 653 | ); |
| 654 | 654 | // Basic variables |
| 655 | - $variables['fullPageForm'] = true; |
|
| 656 | - $variables['docsUrl'] = self::DOCUMENTATION_URL; |
|
| 657 | - $variables['pluginName'] = Seomatic::$settings->pluginName; |
|
| 658 | - $variables['title'] = $templateTitle; |
|
| 659 | - $variables['crumbs'] = [ |
|
| 655 | + $variables[ 'fullPageForm' ] = true; |
|
| 656 | + $variables[ 'docsUrl' ] = self::DOCUMENTATION_URL; |
|
| 657 | + $variables[ 'pluginName' ] = Seomatic::$settings->pluginName; |
|
| 658 | + $variables[ 'title' ] = $templateTitle; |
|
| 659 | + $variables[ 'crumbs' ] = [ |
|
| 660 | 660 | [ |
| 661 | 661 | 'label' => $pluginName, |
| 662 | 662 | 'url' => UrlHelper::cpUrl('seomatic'), |
@@ -666,8 +666,8 @@ discard block |
||
| 666 | 666 | 'url' => UrlHelper::cpUrl('seomatic/settings'), |
| 667 | 667 | ], |
| 668 | 668 | ]; |
| 669 | - $variables['selectedSubnavItem'] = 'plugin'; |
|
| 670 | - $variables['settings'] = Seomatic::$settings; |
|
| 669 | + $variables[ 'selectedSubnavItem' ] = 'plugin'; |
|
| 670 | + $variables[ 'settings' ] = Seomatic::$settings; |
|
| 671 | 671 | |
| 672 | 672 | // Render the template |
| 673 | 673 | return $this->renderTemplate('seomatic/settings/plugin/_edit', $variables); |
@@ -686,24 +686,24 @@ discard block |
||
| 686 | 686 | */ |
| 687 | 687 | public function actionTracking(string $subSection = 'googleAnalytics', string $siteHandle = null): Response |
| 688 | 688 | { |
| 689 | - $variables = []; |
|
| 689 | + $variables = [ ]; |
|
| 690 | 690 | // Get the site to edit |
| 691 | 691 | $siteId = $this->getSiteIdFromHandle($siteHandle); |
| 692 | 692 | // Enabled sites |
| 693 | 693 | $this->setMultiSiteVariables($siteHandle, $siteId, $variables); |
| 694 | - $variables['controllerHandle'] = 'tracking'; |
|
| 695 | - $variables['currentSubSection'] = $subSection; |
|
| 694 | + $variables[ 'controllerHandle' ] = 'tracking'; |
|
| 695 | + $variables[ 'currentSubSection' ] = $subSection; |
|
| 696 | 696 | |
| 697 | 697 | // The script meta containers for the global meta bundle |
| 698 | - $metaBundle = Seomatic::$plugin->metaBundles->getGlobalMetaBundle(intval($variables['currentSiteId'])); |
|
| 699 | - $variables['scripts'] = Seomatic::$plugin->metaBundles->getContainerDataFromBundle( |
|
| 698 | + $metaBundle = Seomatic::$plugin->metaBundles->getGlobalMetaBundle(intval($variables[ 'currentSiteId' ])); |
|
| 699 | + $variables[ 'scripts' ] = Seomatic::$plugin->metaBundles->getContainerDataFromBundle( |
|
| 700 | 700 | $metaBundle, |
| 701 | 701 | MetaScriptContainer::CONTAINER_TYPE |
| 702 | 702 | ); |
| 703 | 703 | // Plugin and section settings |
| 704 | 704 | $pluginName = Seomatic::$settings->pluginName; |
| 705 | 705 | $templateTitle = Craft::t('seomatic', 'Tracking Scripts'); |
| 706 | - $subSectionTitle = $variables['scripts'][$subSection]->name; |
|
| 706 | + $subSectionTitle = $variables[ 'scripts' ][ $subSection ]->name; |
|
| 707 | 707 | $subSectionTitle = Craft::t('seomatic', $subSectionTitle); |
| 708 | 708 | // Asset bundle |
| 709 | 709 | try { |
@@ -711,17 +711,17 @@ discard block |
||
| 711 | 711 | } catch (InvalidConfigException $e) { |
| 712 | 712 | Craft::error($e->getMessage(), __METHOD__); |
| 713 | 713 | } |
| 714 | - $variables['baseAssetsUrl'] = Craft::$app->assetManager->getPublishedUrl( |
|
| 714 | + $variables[ 'baseAssetsUrl' ] = Craft::$app->assetManager->getPublishedUrl( |
|
| 715 | 715 | '@nystudio107/seomatic/assetbundles/seomatic/dist', |
| 716 | 716 | true |
| 717 | 717 | ); |
| 718 | 718 | // Basic variables |
| 719 | - $variables['fullPageForm'] = true; |
|
| 720 | - $variables['docsUrl'] = self::DOCUMENTATION_URL; |
|
| 721 | - $variables['pluginName'] = Seomatic::$settings->pluginName; |
|
| 722 | - $variables['title'] = $templateTitle; |
|
| 723 | - $variables['subSectionTitle'] = $subSectionTitle; |
|
| 724 | - $variables['crumbs'] = [ |
|
| 719 | + $variables[ 'fullPageForm' ] = true; |
|
| 720 | + $variables[ 'docsUrl' ] = self::DOCUMENTATION_URL; |
|
| 721 | + $variables[ 'pluginName' ] = Seomatic::$settings->pluginName; |
|
| 722 | + $variables[ 'title' ] = $templateTitle; |
|
| 723 | + $variables[ 'subSectionTitle' ] = $subSectionTitle; |
|
| 724 | + $variables[ 'crumbs' ] = [ |
|
| 725 | 725 | [ |
| 726 | 726 | 'label' => $pluginName, |
| 727 | 727 | 'url' => UrlHelper::cpUrl('seomatic'), |
@@ -732,10 +732,10 @@ discard block |
||
| 732 | 732 | ], |
| 733 | 733 | [ |
| 734 | 734 | 'label' => $subSectionTitle, |
| 735 | - 'url' => UrlHelper::cpUrl('seomatic/tracking/'.$subSection), |
|
| 735 | + 'url' => UrlHelper::cpUrl('seomatic/tracking/' . $subSection), |
|
| 736 | 736 | ], |
| 737 | 737 | ]; |
| 738 | - $variables['selectedSubnavItem'] = 'tracking'; |
|
| 738 | + $variables[ 'selectedSubnavItem' ] = 'tracking'; |
|
| 739 | 739 | |
| 740 | 740 | // Render the template |
| 741 | 741 | return $this->renderTemplate('seomatic/settings/tracking/_edit', $variables); |
@@ -763,7 +763,7 @@ discard block |
||
| 763 | 763 | foreach ($scriptData as $key => $value) { |
| 764 | 764 | if (is_array($value)) { |
| 765 | 765 | foreach ($value as $varsKey => $varsValue) { |
| 766 | - $data->$key[$varsKey]['value'] = $varsValue; |
|
| 766 | + $data->$key[ $varsKey ][ 'value' ] = $varsValue; |
|
| 767 | 767 | } |
| 768 | 768 | } else { |
| 769 | 769 | $data->$key = $value; |
@@ -793,17 +793,17 @@ discard block |
||
| 793 | 793 | if (is_string($value)) { |
| 794 | 794 | $value = Json::decode($value); |
| 795 | 795 | } |
| 796 | - $normalized = []; |
|
| 797 | - $times = ['open', 'close']; |
|
| 796 | + $normalized = [ ]; |
|
| 797 | + $times = [ 'open', 'close' ]; |
|
| 798 | 798 | for ($day = 0; $day <= 6; $day++) { |
| 799 | 799 | foreach ($times as $time) { |
| 800 | 800 | if ( |
| 801 | - isset($value[$day][$time]) && |
|
| 802 | - ($date = DateTimeHelper::toDateTime($value[$day][$time])) !== false |
|
| 801 | + isset($value[ $day ][ $time ]) && |
|
| 802 | + ($date = DateTimeHelper::toDateTime($value[ $day ][ $time ])) !== false |
|
| 803 | 803 | ) { |
| 804 | - $normalized[$day][$time] = $date; |
|
| 804 | + $normalized[ $day ][ $time ] = $date; |
|
| 805 | 805 | } else { |
| 806 | - $normalized[$day][$time] = null; |
|
| 806 | + $normalized[ $day ][ $time ] = null; |
|
| 807 | 807 | } |
| 808 | 808 | } |
| 809 | 809 | } |
@@ -826,52 +826,52 @@ discard block |
||
| 826 | 826 | $objectPrefix = 'object.'; |
| 827 | 827 | } |
| 828 | 828 | foreach (self::PULL_TEXT_FIELDS as $fields) { |
| 829 | - $fieldName = $fields['fieldName']; |
|
| 830 | - $source = $bundleSettings[$fieldName.'Source'] ?? ''; |
|
| 831 | - $sourceField = $bundleSettings[$fieldName.'Field'] ?? ''; |
|
| 829 | + $fieldName = $fields[ 'fieldName' ]; |
|
| 830 | + $source = $bundleSettings[ $fieldName . 'Source' ] ?? ''; |
|
| 831 | + $sourceField = $bundleSettings[ $fieldName . 'Field' ] ?? ''; |
|
| 832 | 832 | if (!empty($source)) { |
| 833 | - $seoField = $fields['seoField']; |
|
| 833 | + $seoField = $fields[ 'seoField' ]; |
|
| 834 | 834 | switch ($source) { |
| 835 | 835 | case 'sameAsSeo': |
| 836 | - $globalsSettings[$fieldName] = |
|
| 837 | - '{seomatic.meta.'.$seoField.'}'; |
|
| 836 | + $globalsSettings[ $fieldName ] = |
|
| 837 | + '{seomatic.meta.' . $seoField . '}'; |
|
| 838 | 838 | break; |
| 839 | 839 | |
| 840 | 840 | case 'sameAsSiteTwitter': |
| 841 | - $globalsSettings[$fieldName] = |
|
| 842 | - '{seomatic.site.'.$seoField.'}'; |
|
| 841 | + $globalsSettings[ $fieldName ] = |
|
| 842 | + '{seomatic.site.' . $seoField . '}'; |
|
| 843 | 843 | break; |
| 844 | 844 | |
| 845 | 845 | case 'sameAsGlobal': |
| 846 | - $globalsSettings[$fieldName] = |
|
| 846 | + $globalsSettings[ $fieldName ] = |
|
| 847 | 847 | ''; |
| 848 | 848 | break; |
| 849 | 849 | |
| 850 | 850 | case 'fromField': |
| 851 | - $globalsSettings[$fieldName] = |
|
| 851 | + $globalsSettings[ $fieldName ] = |
|
| 852 | 852 | '{seomatic.helper.extractTextFromField(' |
| 853 | - .$objectPrefix.$elementName.$sourceField |
|
| 853 | + .$objectPrefix . $elementName . $sourceField |
|
| 854 | 854 | .')}'; |
| 855 | 855 | break; |
| 856 | 856 | |
| 857 | 857 | case 'fromUserField': |
| 858 | - $globalsSettings[$fieldName] = |
|
| 858 | + $globalsSettings[ $fieldName ] = |
|
| 859 | 859 | '{seomatic.helper.extractTextFromField(' |
| 860 | - .$objectPrefix.$elementName.'author.'.$sourceField |
|
| 860 | + .$objectPrefix . $elementName . 'author.' . $sourceField |
|
| 861 | 861 | .')}'; |
| 862 | 862 | break; |
| 863 | 863 | |
| 864 | 864 | case 'summaryFromField': |
| 865 | - $globalsSettings[$fieldName] = |
|
| 865 | + $globalsSettings[ $fieldName ] = |
|
| 866 | 866 | '{seomatic.helper.extractSummary(seomatic.helper.extractTextFromField(' |
| 867 | - .$objectPrefix.$elementName.$sourceField |
|
| 867 | + .$objectPrefix . $elementName . $sourceField |
|
| 868 | 868 | .'))}'; |
| 869 | 869 | break; |
| 870 | 870 | |
| 871 | 871 | case 'keywordsFromField': |
| 872 | - $globalsSettings[$fieldName] = |
|
| 872 | + $globalsSettings[ $fieldName ] = |
|
| 873 | 873 | '{seomatic.helper.extractKeywords(seomatic.helper.extractTextFromField(' |
| 874 | - .$objectPrefix.$elementName.$sourceField |
|
| 874 | + .$objectPrefix . $elementName . $sourceField |
|
| 875 | 875 | .'))}'; |
| 876 | 876 | break; |
| 877 | 877 | |
@@ -898,85 +898,85 @@ discard block |
||
| 898 | 898 | $objectPrefix = 'object.'; |
| 899 | 899 | } |
| 900 | 900 | foreach (self::PULL_ASSET_FIELDS as $fields) { |
| 901 | - $fieldName = $fields['fieldName']; |
|
| 902 | - $source = $bundleSettings[$fieldName.'Source'] ?? ''; |
|
| 903 | - $ids = $bundleSettings[$fieldName.'Ids'] ?? []; |
|
| 904 | - $sourceField = $bundleSettings[$fieldName.'Field'] ?? ''; |
|
| 901 | + $fieldName = $fields[ 'fieldName' ]; |
|
| 902 | + $source = $bundleSettings[ $fieldName . 'Source' ] ?? ''; |
|
| 903 | + $ids = $bundleSettings[ $fieldName . 'Ids' ] ?? [ ]; |
|
| 904 | + $sourceField = $bundleSettings[ $fieldName . 'Field' ] ?? ''; |
|
| 905 | 905 | if (!empty($source)) { |
| 906 | - $transformImage = $bundleSettings[$fieldName.'Transform']; |
|
| 907 | - $seoField = $fields['seoField']; |
|
| 908 | - $transformName = $fields['transformName']; |
|
| 906 | + $transformImage = $bundleSettings[ $fieldName . 'Transform' ]; |
|
| 907 | + $seoField = $fields[ 'seoField' ]; |
|
| 908 | + $transformName = $fields[ 'transformName' ]; |
|
| 909 | 909 | // Special-case Twitter transforms |
| 910 | 910 | if ($transformName == 'twitter') { |
| 911 | 911 | $transformName = 'twitter-summary'; |
| 912 | - if ($globalsSettings['twitterCard'] == 'summary_large_image') { |
|
| 912 | + if ($globalsSettings[ 'twitterCard' ] == 'summary_large_image') { |
|
| 913 | 913 | $transformName = 'twitter-large'; |
| 914 | 914 | } |
| 915 | 915 | } |
| 916 | 916 | if ($transformImage) { |
| 917 | 917 | switch ($source) { |
| 918 | 918 | case 'sameAsSeo': |
| 919 | - $seoSource = $bundleSettings[$seoField.'Source'] ?? ''; |
|
| 920 | - $seoIds = $bundleSettings[$seoField.'Ids'] ?? []; |
|
| 921 | - $seoSourceField = $bundleSettings[$seoField.'Field'] ?? ''; |
|
| 919 | + $seoSource = $bundleSettings[ $seoField . 'Source' ] ?? ''; |
|
| 920 | + $seoIds = $bundleSettings[ $seoField . 'Ids' ] ?? [ ]; |
|
| 921 | + $seoSourceField = $bundleSettings[ $seoField . 'Field' ] ?? ''; |
|
| 922 | 922 | if (!empty($seoSource)) { |
| 923 | 923 | switch ($seoSource) { |
| 924 | 924 | case 'fromField': |
| 925 | 925 | if (!empty($seoSourceField)) { |
| 926 | - $globalsSettings[$fieldName] = '{seomatic.helper.socialTransform(' |
|
| 927 | - .$objectPrefix.$elementName.$seoSourceField.'.one()' |
|
| 928 | - .', "'.$transformName.'"' |
|
| 929 | - .', '.$siteId.')}'; |
|
| 926 | + $globalsSettings[ $fieldName ] = '{seomatic.helper.socialTransform(' |
|
| 927 | + .$objectPrefix . $elementName . $seoSourceField . '.one()' |
|
| 928 | + .', "' . $transformName . '"' |
|
| 929 | + .', ' . $siteId . ')}'; |
|
| 930 | 930 | } |
| 931 | 931 | break; |
| 932 | 932 | case 'fromAsset': |
| 933 | 933 | if (!empty($seoIds)) { |
| 934 | - $globalsSettings[$fieldName] = '{seomatic.helper.socialTransform(' |
|
| 935 | - .$seoIds[0] |
|
| 936 | - .', "'.$transformName.'"' |
|
| 937 | - .', '.$siteId.')}'; |
|
| 934 | + $globalsSettings[ $fieldName ] = '{seomatic.helper.socialTransform(' |
|
| 935 | + .$seoIds[ 0 ] |
|
| 936 | + .', "' . $transformName . '"' |
|
| 937 | + .', ' . $siteId . ')}'; |
|
| 938 | 938 | } |
| 939 | 939 | break; |
| 940 | 940 | default: |
| 941 | - $globalsSettings[$fieldName] = '{seomatic.meta.'.$seoField.'}'; |
|
| 941 | + $globalsSettings[ $fieldName ] = '{seomatic.meta.' . $seoField . '}'; |
|
| 942 | 942 | break; |
| 943 | 943 | } |
| 944 | 944 | } |
| 945 | 945 | break; |
| 946 | 946 | case 'fromField': |
| 947 | 947 | if (!empty($sourceField)) { |
| 948 | - $globalsSettings[$fieldName] = '{seomatic.helper.socialTransform(' |
|
| 949 | - .$objectPrefix.$elementName.$sourceField.'.one()' |
|
| 950 | - .', "'.$transformName.'"' |
|
| 951 | - .', '.$siteId.')}'; |
|
| 948 | + $globalsSettings[ $fieldName ] = '{seomatic.helper.socialTransform(' |
|
| 949 | + .$objectPrefix . $elementName . $sourceField . '.one()' |
|
| 950 | + .', "' . $transformName . '"' |
|
| 951 | + .', ' . $siteId . ')}'; |
|
| 952 | 952 | } |
| 953 | 953 | break; |
| 954 | 954 | case 'fromAsset': |
| 955 | 955 | if (!empty($ids)) { |
| 956 | - $globalsSettings[$fieldName] = '{seomatic.helper.socialTransform(' |
|
| 957 | - .$ids[0] |
|
| 958 | - .', "'.$transformName.'"' |
|
| 959 | - .', '.$siteId.')}'; |
|
| 956 | + $globalsSettings[ $fieldName ] = '{seomatic.helper.socialTransform(' |
|
| 957 | + .$ids[ 0 ] |
|
| 958 | + .', "' . $transformName . '"' |
|
| 959 | + .', ' . $siteId . ')}'; |
|
| 960 | 960 | } |
| 961 | 961 | break; |
| 962 | 962 | } |
| 963 | 963 | } else { |
| 964 | 964 | switch ($source) { |
| 965 | 965 | case 'sameAsSeo': |
| 966 | - $globalsSettings[$fieldName] = '{seomatic.meta.'.$seoField.'}'; |
|
| 966 | + $globalsSettings[ $fieldName ] = '{seomatic.meta.' . $seoField . '}'; |
|
| 967 | 967 | break; |
| 968 | 968 | case 'fromField': |
| 969 | 969 | if (!empty($sourceField)) { |
| 970 | - $globalsSettings[$fieldName] = '{' |
|
| 971 | - .$elementName.$sourceField.'.one().url' |
|
| 970 | + $globalsSettings[ $fieldName ] = '{' |
|
| 971 | + .$elementName . $sourceField . '.one().url' |
|
| 972 | 972 | .'}'; |
| 973 | 973 | } |
| 974 | 974 | break; |
| 975 | 975 | case 'fromAsset': |
| 976 | 976 | if (!empty($ids)) { |
| 977 | - $globalsSettings[$fieldName] = '{{ craft.app.assets.assetById(' |
|
| 978 | - .$ids[0] |
|
| 979 | - .', '.$siteId.').url }}'; |
|
| 977 | + $globalsSettings[ $fieldName ] = '{{ craft.app.assets.assetById(' |
|
| 978 | + .$ids[ 0 ] |
|
| 979 | + .', ' . $siteId . ').url }}'; |
|
| 980 | 980 | } |
| 981 | 981 | break; |
| 982 | 982 | } |
@@ -990,15 +990,15 @@ discard block |
||
| 990 | 990 | */ |
| 991 | 991 | protected function setGlobalFieldSourceVariables(array &$variables) |
| 992 | 992 | { |
| 993 | - $variables['textFieldSources'] = array_merge( |
|
| 994 | - ['globalsGroup' => ['optgroup' => 'Globals Fields']], |
|
| 993 | + $variables[ 'textFieldSources' ] = array_merge( |
|
| 994 | + [ 'globalsGroup' => [ 'optgroup' => 'Globals Fields' ] ], |
|
| 995 | 995 | FieldHelper::fieldsOfTypeFromGlobals( |
| 996 | 996 | FieldHelper::TEXT_FIELD_CLASS_KEY, |
| 997 | 997 | false |
| 998 | 998 | ) |
| 999 | 999 | ); |
| 1000 | - $variables['assetFieldSources'] = array_merge( |
|
| 1001 | - ['globalsGroup' => ['optgroup' => 'Globals Fields']], |
|
| 1000 | + $variables[ 'assetFieldSources' ] = array_merge( |
|
| 1001 | + [ 'globalsGroup' => [ 'optgroup' => 'Globals Fields' ] ], |
|
| 1002 | 1002 | FieldHelper::fieldsOfTypeFromGlobals( |
| 1003 | 1003 | FieldHelper::ASSET_FIELD_CLASS_KEY, |
| 1004 | 1004 | false |
@@ -1018,8 +1018,8 @@ discard block |
||
| 1018 | 1018 | string $groupName, |
| 1019 | 1019 | array &$variables |
| 1020 | 1020 | ) { |
| 1021 | - $variables['textFieldSources'] = array_merge( |
|
| 1022 | - ['entryGroup' => ['optgroup' => $groupName.' Fields'], 'title' => 'Title'], |
|
| 1021 | + $variables[ 'textFieldSources' ] = array_merge( |
|
| 1022 | + [ 'entryGroup' => [ 'optgroup' => $groupName . ' Fields' ], 'title' => 'Title' ], |
|
| 1023 | 1023 | FieldHelper::fieldsOfTypeFromSource( |
| 1024 | 1024 | $sourceBundleType, |
| 1025 | 1025 | $sourceHandle, |
@@ -1027,8 +1027,8 @@ discard block |
||
| 1027 | 1027 | false |
| 1028 | 1028 | ) |
| 1029 | 1029 | ); |
| 1030 | - $variables['assetFieldSources'] = array_merge( |
|
| 1031 | - ['entryGroup' => ['optgroup' => $groupName.' Fields']], |
|
| 1030 | + $variables[ 'assetFieldSources' ] = array_merge( |
|
| 1031 | + [ 'entryGroup' => [ 'optgroup' => $groupName . ' Fields' ] ], |
|
| 1032 | 1032 | FieldHelper::fieldsOfTypeFromSource( |
| 1033 | 1033 | $sourceBundleType, |
| 1034 | 1034 | $sourceHandle, |
@@ -1036,15 +1036,15 @@ discard block |
||
| 1036 | 1036 | false |
| 1037 | 1037 | ) |
| 1038 | 1038 | ); |
| 1039 | - $variables['assetVolumeTextFieldSources'] = array_merge( |
|
| 1040 | - ['entryGroup' => ['optgroup' => 'Asset Volume Fields'], 'title' => 'Title'], |
|
| 1039 | + $variables[ 'assetVolumeTextFieldSources' ] = array_merge( |
|
| 1040 | + [ 'entryGroup' => [ 'optgroup' => 'Asset Volume Fields' ], 'title' => 'Title' ], |
|
| 1041 | 1041 | FieldHelper::fieldsOfTypeFromAssetVolumes( |
| 1042 | 1042 | FieldHelper::TEXT_FIELD_CLASS_KEY, |
| 1043 | 1043 | false |
| 1044 | 1044 | ) |
| 1045 | 1045 | ); |
| 1046 | - $variables['userFieldSources'] = array_merge( |
|
| 1047 | - ['entryGroup' => ['optgroup' => 'User Fields']], |
|
| 1046 | + $variables[ 'userFieldSources' ] = array_merge( |
|
| 1047 | + [ 'entryGroup' => [ 'optgroup' => 'User Fields' ] ], |
|
| 1048 | 1048 | FieldHelper::fieldsOfTypeFromUsers( |
| 1049 | 1049 | FieldHelper::TEXT_FIELD_CLASS_KEY, |
| 1050 | 1050 | false |
@@ -1102,43 +1102,43 @@ discard block |
||
| 1102 | 1102 | $sites = Craft::$app->getSites(); |
| 1103 | 1103 | if (Craft::$app->getIsMultiSite()) { |
| 1104 | 1104 | // Set defaults based on the section settings |
| 1105 | - $variables['enabledSiteIds'] = []; |
|
| 1106 | - $variables['siteIds'] = []; |
|
| 1105 | + $variables[ 'enabledSiteIds' ] = [ ]; |
|
| 1106 | + $variables[ 'siteIds' ] = [ ]; |
|
| 1107 | 1107 | |
| 1108 | 1108 | /** @var Site $site */ |
| 1109 | 1109 | foreach ($sites->getEditableSiteIds() as $editableSiteId) { |
| 1110 | - $variables['enabledSiteIds'][] = $editableSiteId; |
|
| 1111 | - $variables['siteIds'][] = $editableSiteId; |
|
| 1110 | + $variables[ 'enabledSiteIds' ][ ] = $editableSiteId; |
|
| 1111 | + $variables[ 'siteIds' ][ ] = $editableSiteId; |
|
| 1112 | 1112 | } |
| 1113 | 1113 | |
| 1114 | 1114 | // Make sure the $siteId they are trying to edit is in our array of editable sites |
| 1115 | - if (!in_array($siteId, $variables['enabledSiteIds'])) { |
|
| 1116 | - if (!empty($variables['enabledSiteIds'])) { |
|
| 1117 | - $siteId = reset($variables['enabledSiteIds']); |
|
| 1115 | + if (!in_array($siteId, $variables[ 'enabledSiteIds' ])) { |
|
| 1116 | + if (!empty($variables[ 'enabledSiteIds' ])) { |
|
| 1117 | + $siteId = reset($variables[ 'enabledSiteIds' ]); |
|
| 1118 | 1118 | } else { |
| 1119 | - $this->requirePermission('editSite:'.$siteId); |
|
| 1119 | + $this->requirePermission('editSite:' . $siteId); |
|
| 1120 | 1120 | } |
| 1121 | 1121 | } |
| 1122 | 1122 | } |
| 1123 | 1123 | // Set the currentSiteId and currentSiteHandle |
| 1124 | - $variables['currentSiteId'] = empty($siteId) ? Craft::$app->getSites()->currentSite->id : $siteId; |
|
| 1125 | - $variables['currentSiteHandle'] = empty($siteHandle) |
|
| 1124 | + $variables[ 'currentSiteId' ] = empty($siteId) ? Craft::$app->getSites()->currentSite->id : $siteId; |
|
| 1125 | + $variables[ 'currentSiteHandle' ] = empty($siteHandle) |
|
| 1126 | 1126 | ? Craft::$app->getSites()->currentSite->handle |
| 1127 | 1127 | : $siteHandle; |
| 1128 | 1128 | |
| 1129 | 1129 | // Page title |
| 1130 | - $variables['showSites'] = ( |
|
| 1130 | + $variables[ 'showSites' ] = ( |
|
| 1131 | 1131 | Craft::$app->getIsMultiSite() && |
| 1132 | - count($variables['enabledSiteIds']) |
|
| 1132 | + count($variables[ 'enabledSiteIds' ]) |
|
| 1133 | 1133 | ); |
| 1134 | 1134 | |
| 1135 | - if ($variables['showSites']) { |
|
| 1136 | - $variables['sitesMenuLabel'] = Craft::t( |
|
| 1135 | + if ($variables[ 'showSites' ]) { |
|
| 1136 | + $variables[ 'sitesMenuLabel' ] = Craft::t( |
|
| 1137 | 1137 | 'site', |
| 1138 | - $sites->getSiteById(intval($variables['currentSiteId']))->name |
|
| 1138 | + $sites->getSiteById(intval($variables[ 'currentSiteId' ]))->name |
|
| 1139 | 1139 | ); |
| 1140 | 1140 | } else { |
| 1141 | - $variables['sitesMenuLabel'] = ''; |
|
| 1141 | + $variables[ 'sitesMenuLabel' ] = ''; |
|
| 1142 | 1142 | } |
| 1143 | 1143 | } |
| 1144 | 1144 | |
@@ -1153,10 +1153,10 @@ discard block |
||
| 1153 | 1153 | protected function assetElementsFromIds($assetIds, int $siteId) |
| 1154 | 1154 | { |
| 1155 | 1155 | $elements = Craft::$app->getElements(); |
| 1156 | - $assets = []; |
|
| 1156 | + $assets = [ ]; |
|
| 1157 | 1157 | if (!empty($assetIds)) { |
| 1158 | 1158 | foreach ($assetIds as $assetId) { |
| 1159 | - $assets[] = $elements->getElementById($assetId, Asset::class, $siteId); |
|
| 1159 | + $assets[ ] = $elements->getElementById($assetId, Asset::class, $siteId); |
|
| 1160 | 1160 | } |
| 1161 | 1161 | } |
| 1162 | 1162 | |
@@ -1177,7 +1177,7 @@ discard block |
||
| 1177 | 1177 | if ($siteHandle !== null) { |
| 1178 | 1178 | $site = Craft::$app->getSites()->getSiteByHandle($siteHandle); |
| 1179 | 1179 | if (!$site) { |
| 1180 | - throw new NotFoundHttpException('Invalid site handle: '.$siteHandle); |
|
| 1180 | + throw new NotFoundHttpException('Invalid site handle: ' . $siteHandle); |
|
| 1181 | 1181 | } |
| 1182 | 1182 | $siteId = $site->id; |
| 1183 | 1183 | } else { |