Skip to content

Commit

Permalink
Correct path for favicons, correct rendering images
Browse files Browse the repository at this point in the history
  • Loading branch information
drmenzelit committed Jun 2, 2023
1 parent cb4a23e commit 7170437
Show file tree
Hide file tree
Showing 17 changed files with 698 additions and 588 deletions.
44 changes: 22 additions & 22 deletions component.php
Expand Up @@ -7,43 +7,43 @@

/** @var Joomla\CMS\Document\HtmlDocument $this */

$app = Factory::getApplication();
$document = $app->getDocument();
$wa = $this->getWebAssetManager();
$params = $this->params;
$app = Factory::getApplication();
$document = $app->getDocument();
$wa = $this->getWebAssetManager();
$params = $this->params;

// Template path
$templatePath = 'media/templates/site/nature';

// Load Icons
if ($params->get('icons') == 1)
{
$wa->useStyle('fontawesome');
$this->getPreloadManager()->preload($wa->getAsset('style', 'fontawesome')->getUri() . '?' . $this->getMediaVersion(), ['as' => 'style']);
$wa->useStyle('fontawesome');
$this->getPreloadManager()->preload($wa->getAsset('style', 'fontawesome')->getUri() . '?' . $this->getMediaVersion(), ['as' => 'style']);
}
elseif ($params->get('icons') == 2)
{
$wa->registerAndUseStyle('bi-icons', $templatePath . '/css/bootstrap-icons.css');
$wa->registerAndUseStyle('icons', $templatePath . '/css/icons.css');
$this->getPreloadManager()->preload($wa->getAsset('style', 'bi-icons')->getUri() . '?' . $this->getMediaVersion(), ['as' => 'style']);
$this->getPreloadManager()->preload($wa->getAsset('style', 'icons')->getUri() . '?' . $this->getMediaVersion(), ['as' => 'style']);
$wa->registerAndUseStyle('bi-icons', $templatePath . '/css/bootstrap-icons.css');
$wa->registerAndUseStyle('icons', $templatePath . '/css/icons.css');
$this->getPreloadManager()->preload($wa->getAsset('style', 'bi-icons')->getUri() . '?' . $this->getMediaVersion(), ['as' => 'style']);
$this->getPreloadManager()->preload($wa->getAsset('style', 'icons')->getUri() . '?' . $this->getMediaVersion(), ['as' => 'style']);
}

// Use a font scheme if set in the template style options
$paramsFontScheme = $params->get('useFontScheme', false);

if ($paramsFontScheme)
{
$assetFontScheme = 'fontscheme.' . $paramsFontScheme;
$wa->registerAndUseStyle($assetFontScheme, $templatePath . '/css/global/' . $paramsFontScheme . '.css');
$this->getPreloadManager()->preload($wa->getAsset('style', $assetFontScheme)->getUri() . '?' . $this->getMediaVersion(), ['as' => 'style']);
$assetFontScheme = 'fontscheme.' . $paramsFontScheme;
$wa->registerAndUseStyle($assetFontScheme, $templatePath . '/css/global/' . $paramsFontScheme . '.css');
$this->getPreloadManager()->preload($wa->getAsset('style', $assetFontScheme)->getUri() . '?' . $this->getMediaVersion(), ['as' => 'style']);
}

// Enable assets
$wa->useStyle('template.nature')
->useScript('template.nature')
->useStyle('template.user')
->useScript('template.user');
->useScript('template.nature')
->useStyle('template.user')
->useScript('template.user');
$this->getPreloadManager()->preload($wa->getAsset('style', 'template.nature')->getUri() . '?' . $this->getMediaVersion(), ['as' => 'style']);

/// Favicons
Expand All @@ -55,13 +55,13 @@
<!DOCTYPE html>
<html lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>">
<head>
<jdoc:include type="metas" />
<?php include "includes/style.php";?>
<jdoc:include type="styles" />
<jdoc:include type="scripts" />
<jdoc:include type="metas" />
<?php include "includes/style.php";?>
<jdoc:include type="styles" />
<jdoc:include type="scripts" />
</head>
<body class="<?php echo $this->direction === 'rtl' ? 'rtl' : ''; ?>">
<jdoc:include type="message" />
<jdoc:include type="component" />
<jdoc:include type="message" />
<jdoc:include type="component" />
</body>
</html>
206 changes: 111 additions & 95 deletions error.php
Expand Up @@ -3,25 +3,25 @@
defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\LayoutHelper;
use Joomla\CMS\Uri\Uri;

/** @var Joomla\CMS\Document\HtmlDocument $this */
/** @var Joomla\CMS\Document\ErrorDocument $this */

$app = Factory::getApplication();
$wa = $this->getWebAssetManager();
$document = $app->getDocument();
$app = Factory::getApplication();
$wa = $this->getWebAssetManager();
$document = $app->getDocument();

// Detecting Active Variables
$option = $app->input->getCmd('option', '');
$view = $app->input->getCmd('view', '');
$layout = $app->input->getCmd('layout', '');
$task = $app->input->getCmd('task', '');
$itemid = $app->input->getCmd('Itemid', '');
$sitename = htmlspecialchars($app->get('sitename'), ENT_QUOTES, 'UTF-8');
$menu = $app->getMenu()->getActive();
$pageclass = $menu !== null ? $menu->getParams()->get('pageclass_sfx', '') : '';
$option = $app->input->getCmd('option', '');
$view = $app->input->getCmd('view', '');
$layout = $app->input->getCmd('layout', '');
$task = $app->input->getCmd('task', '');
$itemid = $app->input->getCmd('Itemid', '');
$sitename = htmlspecialchars($app->get('sitename'), ENT_QUOTES, 'UTF-8');
$menu = $app->getMenu()->getActive();
$pageclass = $menu !== null ? $menu->getParams()->get('pageclass_sfx', '') : '';

// Getting params from template
$params = $app->getTemplate(true)->params;
Expand All @@ -34,30 +34,46 @@

if ($paramsFontScheme)
{
$assetFontScheme = 'fontscheme.' . $paramsFontScheme;
$wa->registerAndUseStyle($assetFontScheme, $templatePath . '/css/global/' . $paramsFontScheme . '.css');
$this->getPreloadManager()->preload($wa->getAsset('style', $assetFontScheme)->getUri() . '?' . $this->getMediaVersion(), ['as' => 'style']);
$assetFontScheme = 'fontscheme.' . $paramsFontScheme;
$wa->registerAndUseStyle($assetFontScheme, $templatePath . '/css/global/' . $paramsFontScheme . '.css');
$this->getPreloadManager()->preload($wa->getAsset('style', $assetFontScheme)->getUri() . '?' . $this->getMediaVersion(), ['as' => 'style']);
}

// Enable assets
$wa->useStyle('template.nature')
->useScript('template.nature')
->useStyle('template.user')
->useScript('template.user');
->useScript('template.nature')
->useStyle('template.user')
->useScript('template.user');
$this->getPreloadManager()->preload($wa->getAsset('style', 'template.nature')->getUri() . '?' . $this->getMediaVersion(), ['as' => 'style']);

// Logo file or site title param
if ($params->get('logoFile'))
{
$logo = '<img src="' . Uri::root() . htmlspecialchars($params->get('logoFile'), ENT_QUOTES) . '" alt="' . $sitename . '">';
$imageAttr = [
'src' => Uri::root(true) . '/' . $params->get('logoFile'),
'class' => 'logo',
'alt' => $sitename,
'loading' => 'eager',
'decoding' => 'async'
];
$logo = LayoutHelper::render('joomla.html.image', $imageAttr);
}
elseif ($params->get('siteTitle'))
{
$logo = '<span title="' . $sitename . '">' . htmlspecialchars($params->get('siteTitle'), ENT_COMPAT, 'UTF-8') . '</span>';
$logo = '<span title="' . $sitename . '">' . htmlspecialchars($params->get('siteTitle'), ENT_COMPAT, 'UTF-8') . '</span>';
}
else
{
$logo = '<img src="' . $this->baseurl . '/' . $templatePath. '/images/nature-logo.png" class="logo" alt="' . $sitename . '">';
$imageAttr = [
'src' => Uri::root(true) . '/' . $templatePath . '/images/nature-logo.png',
'class' => 'logo',
'width' => '250',
'height' => '92',
'alt' => $sitename,
'loading' => 'eager',
'decoding' => 'async'
];
$logo = LayoutHelper::render('joomla.html.image', $imageAttr);
}

// Favicons
Expand All @@ -69,83 +85,83 @@
<!DOCTYPE html>
<html lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>">
<head>
<jdoc:include type="metas" />
<?php include "includes/style.php";?>
<jdoc:include type="styles" />
<jdoc:include type="scripts" />
<jdoc:include type="metas" />
<?php include "includes/style.php";?>
<jdoc:include type="styles" />
<jdoc:include type="scripts" />
</head>

<body class="site error-site <?php echo $option
. ' view-' . $view
. ($layout ? ' layout-' . $layout : ' no-layout')
. ($task ? ' task-' . $task : ' no-task')
. ($itemid ? ' itemid-' . $itemid : '')
. ' ' . $pageclass;
echo ($this->direction == 'rtl' ? ' rtl' : '');
. ' view-' . $view
. ($layout ? ' layout-' . $layout : ' no-layout')
. ($task ? ' task-' . $task : ' no-task')
. ($itemid ? ' itemid-' . $itemid : '')
. ' ' . $pageclass;
echo ($this->direction == 'rtl' ? ' rtl' : '');
?>">
<header class="header">
<a href="#main" class="skip-link">Skip to main content</a>
<div class="wrapper">
<div class="navbar-brand">
<a class="brand-logo" href="<?php echo $this->baseurl; ?>/">
<?php echo $logo; ?>
</a>
<?php if ($params->get('siteDescription')) : ?>
<div class="site-description"><?php echo htmlspecialchars($params->get('siteDescription')); ?></div>
<?php endif; ?>
</div>
</div>
</header>

<main id="main" tabindex="-1">
<div class="wrapper">
<h1 class="page-header"><?php echo Text::_('JERROR_LAYOUT_PAGE_NOT_FOUND'); ?></h1>
<jdoc:include type="message" />
<p><strong><?php echo Text::_('JERROR_LAYOUT_ERROR_HAS_OCCURRED_WHILE_PROCESSING_YOUR_REQUEST'); ?></strong></p>
<p><?php echo Text::_('JERROR_LAYOUT_NOT_ABLE_TO_VISIT'); ?></p>
<ul>
<li><?php echo Text::_('JERROR_LAYOUT_AN_OUT_OF_DATE_BOOKMARK_FAVOURITE'); ?></li>
<li><?php echo Text::_('JERROR_LAYOUT_MIS_TYPED_ADDRESS'); ?></li>
<li><?php echo Text::_('JERROR_LAYOUT_SEARCH_ENGINE_OUT_OF_DATE_LISTING'); ?></li>
<li><?php echo Text::_('JERROR_LAYOUT_YOU_HAVE_NO_ACCESS_TO_THIS_PAGE'); ?></li>
</ul>
<p><?php echo Text::_('JERROR_LAYOUT_GO_TO_THE_HOME_PAGE'); ?></p>
<p><a href="<?php echo $this->baseurl; ?>/index.php" class="btn btn-primary"><span class="icon-home" aria-hidden="true"></span> <?php echo Text::_('JERROR_LAYOUT_HOME_PAGE'); ?></a></p>
<hr>
<p><?php echo Text::_('JERROR_LAYOUT_PLEASE_CONTACT_THE_SYSTEM_ADMINISTRATOR'); ?></p>
<blockquote>
<?php echo $this->error->getCode(); ?> <?php echo htmlspecialchars($this->error->getMessage(), ENT_QUOTES, 'UTF-8'); ?>
</blockquote>
<?php if ($this->debug) : ?>
<div>
<?php echo $this->renderBacktrace(); ?>
<?php // Check if there are more Exceptions and render their data as well ?>
<?php if ($this->error->getPrevious()) : ?>
<?php $loop = true; ?>
<?php // Reference $this->_error here and in the loop as setError() assigns errors to this property and we need this for the backtrace to work correctly ?>
<?php // Make the first assignment to setError() outside the loop so the loop does not skip Exceptions ?>
<?php $this->setError($this->_error->getPrevious()); ?>
<?php while ($loop === true) : ?>
<p><strong><?php echo Text::_('JERROR_LAYOUT_PREVIOUS_ERROR'); ?></strong></p>
<p><?php echo htmlspecialchars($this->_error->getMessage(), ENT_QUOTES, 'UTF-8'); ?></p>
<?php echo $this->renderBacktrace(); ?>
<?php $loop = $this->setError($this->_error->getPrevious()); ?>
<?php endwhile; ?>
<?php // Reset the main error object to the base error ?>
<?php $this->setError($this->error); ?>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
</main>

<footer class="container-footer">
<div class="wrapper">
<?php echo $sitename; ?>
</div>
</footer>

<jdoc:include type="modules" name="debug" style="none" />
<header class="header">
<a href="#main" class="skip-link">Skip to main content</a>
<div class="wrapper">
<div class="navbar-brand">
<a class="brand-logo" href="<?php echo $this->baseurl; ?>/">
<?php echo $logo; ?>
</a>
<?php if ($params->get('siteDescription')) : ?>
<div class="site-description"><?php echo htmlspecialchars($params->get('siteDescription')); ?></div>
<?php endif; ?>
</div>
</div>
</header>

<main id="main" tabindex="-1">
<div class="wrapper">
<h1 class="page-header"><?php echo Text::_('JERROR_LAYOUT_PAGE_NOT_FOUND'); ?></h1>
<jdoc:include type="message" />
<p><strong><?php echo Text::_('JERROR_LAYOUT_ERROR_HAS_OCCURRED_WHILE_PROCESSING_YOUR_REQUEST'); ?></strong></p>
<p><?php echo Text::_('JERROR_LAYOUT_NOT_ABLE_TO_VISIT'); ?></p>
<ul>
<li><?php echo Text::_('JERROR_LAYOUT_AN_OUT_OF_DATE_BOOKMARK_FAVOURITE'); ?></li>
<li><?php echo Text::_('JERROR_LAYOUT_MIS_TYPED_ADDRESS'); ?></li>
<li><?php echo Text::_('JERROR_LAYOUT_SEARCH_ENGINE_OUT_OF_DATE_LISTING'); ?></li>
<li><?php echo Text::_('JERROR_LAYOUT_YOU_HAVE_NO_ACCESS_TO_THIS_PAGE'); ?></li>
</ul>
<p><?php echo Text::_('JERROR_LAYOUT_GO_TO_THE_HOME_PAGE'); ?></p>
<p><a href="<?php echo $this->baseurl; ?>/index.php" class="btn btn-primary"><span class="icon-home" aria-hidden="true"></span> <?php echo Text::_('JERROR_LAYOUT_HOME_PAGE'); ?></a></p>
<hr>
<p><?php echo Text::_('JERROR_LAYOUT_PLEASE_CONTACT_THE_SYSTEM_ADMINISTRATOR'); ?></p>
<blockquote>
<?php echo $this->error->getCode(); ?> <?php echo htmlspecialchars($this->error->getMessage(), ENT_QUOTES, 'UTF-8'); ?>
</blockquote>
<?php if ($this->debug) : ?>
<div>
<?php echo $this->renderBacktrace(); ?>
<?php // Check if there are more Exceptions and render their data as well ?>
<?php if ($this->error->getPrevious()) : ?>
<?php $loop = true; ?>
<?php // Reference $this->_error here and in the loop as setError() assigns errors to this property and we need this for the backtrace to work correctly ?>
<?php // Make the first assignment to setError() outside the loop so the loop does not skip Exceptions ?>
<?php $this->setError($this->_error->getPrevious()); ?>
<?php while ($loop === true) : ?>
<p><strong><?php echo Text::_('JERROR_LAYOUT_PREVIOUS_ERROR'); ?></strong></p>
<p><?php echo htmlspecialchars($this->_error->getMessage(), ENT_QUOTES, 'UTF-8'); ?></p>
<?php echo $this->renderBacktrace(); ?>
<?php $loop = $this->setError($this->_error->getPrevious()); ?>
<?php endwhile; ?>
<?php // Reset the main error object to the base error ?>
<?php $this->setError($this->error); ?>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
</main>

<footer class="container-footer">
<div class="wrapper">
<?php echo $sitename; ?>
</div>
</footer>

<jdoc:include type="modules" name="debug" style="none" />

</body>
</html>
34 changes: 17 additions & 17 deletions html/mod_articles_news/quotes.php
Expand Up @@ -17,26 +17,26 @@

if (!$list)
{
return;
return;
}

?>
<div id="quotes">
<?php for ($i = 0, $n = count($list); $i < $n; $i ++) : ?>
<?php $item = $list[$i]; ?>
<div class="quote-box">
<div class="quote-content">
<div class="quote-icon">
<svg width="70px" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 91.2 62.6" style="enable-background:new 0 0 91.2 62.6;" xml:space="preserve">
<g id="quotes" transform="translate(0 -80.25)">
<path id="quote" class="st0" d="M20,103c11,0,19.9,8.9,19.9,19.9S31,142.9,20,142.9S0.1,134,0.1,123c0,0,0,0,0,0L0,120.1 c0-22,17.8-39.9,39.9-39.9l0,0v11.4c-7.6,0-14.8,3-20.1,8.3c-1,1-2,2.1-2.8,3.3C17.9,103.1,19,103,20,103z M71.3,103 c11,0,19.9,8.9,19.9,19.9s-8.9,19.9-19.9,19.9S51.3,134,51.3,123l-0.1-2.8c0-22,17.8-39.9,39.9-39.9v11.4c-7.6,0-14.8,3-20.1,8.3 c-1,1-2,2.1-2.8,3.3C69.2,103.1,70.2,103,71.3,103z"/>
</g>
</svg>
</div>
<?php echo $item->introtext; ?>
<p class="quote-title"><?php echo $item->title; ?></p>
</div>
</div>
<?php endfor; ?>
<?php for ($i = 0, $n = count($list); $i < $n; $i ++) : ?>
<?php $item = $list[$i]; ?>
<div class="quote-box">
<div class="quote-content">
<div class="quote-icon">
<svg width="70px" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 91.2 62.6" style="enable-background:new 0 0 91.2 62.6;" xml:space="preserve">
<g id="quotes" transform="translate(0 -80.25)">
<path id="quote" class="st0" d="M20,103c11,0,19.9,8.9,19.9,19.9S31,142.9,20,142.9S0.1,134,0.1,123c0,0,0,0,0,0L0,120.1 c0-22,17.8-39.9,39.9-39.9l0,0v11.4c-7.6,0-14.8,3-20.1,8.3c-1,1-2,2.1-2.8,3.3C17.9,103.1,19,103,20,103z M71.3,103 c11,0,19.9,8.9,19.9,19.9s-8.9,19.9-19.9,19.9S51.3,134,51.3,123l-0.1-2.8c0-22,17.8-39.9,39.9-39.9v11.4c-7.6,0-14.8,3-20.1,8.3 c-1,1-2,2.1-2.8,3.3C69.2,103.1,70.2,103,71.3,103z"/>
</g>
</svg>
</div>
<?php echo $item->introtext; ?>
<p class="quote-title"><?php echo $item->title; ?></p>
</div>
</div>
<?php endfor; ?>
</div>

0 comments on commit 7170437

Please sign in to comment.