[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/templates/cassiopeia/ -> component.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Site
   5   * @subpackage  Templates.cassiopeia
   6   *
   7   * @copyright   (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
   8   * @license     GNU General Public License version 2 or later; see LICENSE.txt
   9   */
  10  
  11  defined('_JEXEC') or die;
  12  
  13  use Joomla\CMS\Factory;
  14  use Joomla\CMS\HTML\HTMLHelper;
  15  
  16  /** @var Joomla\CMS\Document\HtmlDocument $this */
  17  
  18  $app = Factory::getApplication();
  19  $wa  = $this->getWebAssetManager();
  20  
  21  // Color Theme
  22  $paramsColorName = $this->params->get('colorName', 'colors_standard');
  23  $assetColorName  = 'theme.' . $paramsColorName;
  24  $wa->registerAndUseStyle($assetColorName, 'media/templates/site/cassiopeia/css/global/' . $paramsColorName . '.css');
  25  
  26  // Use a font scheme if set in the template style options
  27  $paramsFontScheme = $this->params->get('useFontScheme', false);
  28  $fontStyles       = '';
  29  
  30  if ($paramsFontScheme) {
  31      if (stripos($paramsFontScheme, 'https://') === 0) {
  32          $this->getPreloadManager()->preconnect('https://fonts.googleapis.com/', ['crossorigin' => 'anonymous']);
  33          $this->getPreloadManager()->preconnect('https://fonts.gstatic.com/', ['crossorigin' => 'anonymous']);
  34          $this->getPreloadManager()->preload($paramsFontScheme, ['as' => 'style', 'crossorigin' => 'anonymous']);
  35          $wa->registerAndUseStyle('fontscheme.current', $paramsFontScheme, [], ['media' => 'print', 'rel' => 'lazy-stylesheet', 'onload' => 'this.media=\'all\'', 'crossorigin' => 'anonymous']);
  36  
  37          if (preg_match_all('/family=([^?:]*):/i', $paramsFontScheme, $matches) > 0) {
  38              $fontStyles = '--cassiopeia-font-family-body: "' . str_replace('+', ' ', $matches[1][0]) . '", sans-serif;
  39              --cassiopeia-font-family-headings: "' . str_replace('+', ' ', isset($matches[1][1]) ? $matches[1][1] : $matches[1][0]) . '", sans-serif;
  40              --cassiopeia-font-weight-normal: 400;
  41              --cassiopeia-font-weight-headings: 700;';
  42          }
  43      } else {
  44          $wa->registerAndUseStyle('fontscheme.current', $paramsFontScheme, ['version' => 'auto'], ['media' => 'print', 'rel' => 'lazy-stylesheet', 'onload' => 'this.media=\'all\'']);
  45          $this->getPreloadManager()->preload($wa->getAsset('style', 'fontscheme.current')->getUri() . '?' . $this->getMediaVersion(), ['as' => 'style']);
  46      }
  47  }
  48  
  49  // Enable assets
  50  $wa->usePreset('template.cassiopeia.' . ($this->direction === 'rtl' ? 'rtl' : 'ltr'))
  51      ->useStyle('template.active.language')
  52      ->useStyle('template.user')
  53      ->useScript('template.user')
  54      ->addInlineStyle(":root {
  55          --hue: 214;
  56          --template-bg-light: #f0f4fb;
  57          --template-text-dark: #495057;
  58          --template-text-light: #ffffff;
  59          --template-link-color: #2a69b8;
  60          --template-special-color: #001B4C;
  61          $fontStyles
  62      }");
  63  
  64  
  65  // Override 'template.active' asset to set correct ltr/rtl dependency
  66  $wa->registerStyle('template.active', '', [], [], ['template.cassiopeia.' . ($this->direction === 'rtl' ? 'rtl' : 'ltr')]);
  67  
  68  // Browsers support SVG favicons
  69  $this->addHeadLink(HTMLHelper::_('image', 'joomla-favicon.svg', '', [], true, 1), 'icon', 'rel', ['type' => 'image/svg+xml']);
  70  $this->addHeadLink(HTMLHelper::_('image', 'favicon.ico', '', [], true, 1), 'alternate icon', 'rel', ['type' => 'image/vnd.microsoft.icon']);
  71  $this->addHeadLink(HTMLHelper::_('image', 'joomla-favicon-pinned.svg', '', [], true, 1), 'mask-icon', 'rel', ['color' => '#000']);
  72  
  73  // Defer font awesome
  74  $wa->getAsset('style', 'fontawesome')->setAttribute('rel', 'lazy-stylesheet');
  75  ?>
  76  <!DOCTYPE html>
  77  <html lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>">
  78  <head>
  79      <jdoc:include type="metas" />
  80      <meta name="viewport" content="width=device-width, initial-scale=1.0">
  81      <jdoc:include type="styles" />
  82      <jdoc:include type="scripts" />
  83  </head>
  84  <body class="<?php echo $this->direction === 'rtl' ? 'rtl' : ''; ?>">
  85      <jdoc:include type="message" />
  86      <jdoc:include type="component" />
  87  </body>
  88  </html>


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer