Browse Source

Favicon fix

master
Egorka 6 years ago
parent
commit
fcf321d619
  1. 6
      backend/controllers/settings/ListController.php
  2. 4
      backend/views/auth/login.php
  3. BIN
      backend/web/favicon.ico
  4. 8
      core/components/favicon/FaviconGenerator.php
  5. 4
      core/widgets/FaviconWidget.php
  6. BIN
      frontend/web/favicon.ico

6
backend/controllers/settings/ListController.php

@ -155,11 +155,11 @@ class ListController extends Controller
if ($form->load(Yii::$app->request->post())) { if ($form->load(Yii::$app->request->post())) {
$form->image = UploadedFile::getInstance($form, 'image'); $form->image = UploadedFile::getInstance($form, 'image');
if ($form->image && $form->validate()) { if ($form->image && $form->validate()) {
if (!file_exists(Yii::getAlias('@staticRoot') . '/images/origin/favicon')) { if (!file_exists(Yii::getAlias('@staticRoot') . '/origin/favicon')) {
mkdir(Yii::getAlias('@staticRoot') . '/images/origin/favicon', 0777, true); mkdir(Yii::getAlias('@staticRoot') . '/origin/favicon', 0777, true);
} }
$form->image->saveAs(Yii::getAlias('@staticRoot') . '/images/origin/favicon/favicon.png'); $form->image->saveAs(Yii::getAlias('@staticRoot') . '/origin/favicon/favicon.png');
$this->_service->newFavicon(); $this->_service->newFavicon();
Yii::$app->session->setFlash('success', Yii::t('main', 'Favicon generation complete')); Yii::$app->session->setFlash('success', Yii::t('main', 'Favicon generation complete'));
return $this->redirect(['settings/list/index']); return $this->redirect(['settings/list/index']);

4
backend/views/auth/login.php

@ -22,8 +22,8 @@ $fieldOptions2 = [
<div class="login-box"> <div class="login-box">
<div class="login-logo"> <div class="login-logo">
<?php if (file_exists(Yii::getAlias('@static/images/cache/favicon/favicon-96x96.png'))) : ?> <?php if (file_exists(Yii::getAlias('@staticRoot/cache/favicon/favicon-96x96.png'))) : ?>
<img style="filter: drop-shadow(0px 0px 5px rgba(0, 0, 0, 0.2));" src="<?= Yii::getAlias('@static/images/cache/favicon/favicon-96x96.png') ?>" alt="Zertex CMS"> <img style="filter: drop-shadow(0px 0px 5px rgba(0, 0, 0, 0.2));" src="<?= Yii::getAlias('@static/cache/favicon/favicon-96x96.png') ?>" alt="Zertex CMS">
<br> <br>
<?php endif; ?> <?php endif; ?>
<a style="filter: drop-shadow(0px 0px 5px rgba(0, 0, 0, 0.2));" href="#"><b>Zertex</b>CMS</a> <a style="filter: drop-shadow(0px 0px 5px rgba(0, 0, 0, 0.2));" href="#"><b>Zertex</b>CMS</a>

BIN
backend/web/favicon.ico

Binary file not shown.

Before

Width:  |  Height:  |  Size: 318 B

After

Width:  |  Height:  |  Size: 1.1 KiB

8
core/components/favicon/FaviconGenerator.php

@ -17,8 +17,8 @@ class FaviconGenerator
public function __construct() public function __construct()
{ {
$this->originPath = Yii::getAlias('@staticRoot') . '/images/origin/favicon'; $this->originPath = Yii::getAlias('@staticRoot') . '/origin/favicon';
$this->cachePath = Yii::getAlias('@staticRoot') . '/images/cache/favicon'; $this->cachePath = Yii::getAlias('@staticRoot') . '/cache/favicon';
} }
public function generateIcons() public function generateIcons()
@ -90,7 +90,7 @@ class FaviconGenerator
protected function generateManifestJson() protected function generateManifestJson()
{ {
$cacheUrl = Yii::getAlias('@static') . '/images/cache'; $cacheUrl = Yii::getAlias('@static') . '/cache';
// frontend // frontend
file_put_contents( file_put_contents(
@ -113,7 +113,7 @@ class FaviconGenerator
protected function generateBrowserConfigXml() protected function generateBrowserConfigXml()
{ {
$cacheUrl = Yii::getAlias('@static') . '/images/cache'; $cacheUrl = Yii::getAlias('@static') . '/cache';
// frontend // frontend
file_put_contents( file_put_contents(

4
core/widgets/FaviconWidget.php

@ -20,8 +20,8 @@ class FaviconWidget extends Widget
/** @var \yii\web\View $View */ /** @var \yii\web\View $View */
$View = \Yii::$app->get('view'); $View = \Yii::$app->get('view');
$this->iconsPath = Yii::getAlias('@staticRoot') . '/images/cache/favicon'; $this->iconsPath = Yii::getAlias('@staticRoot') . '/cache/favicon';
$this->iconsUrl = Yii::getAlias('@static') . '/images/cache/favicon'; $this->iconsUrl = Yii::getAlias('@static') . '/cache/favicon';
foreach ([16, 32, 96, 194] as $s) { foreach ([16, 32, 96, 194] as $s) {
$filename = sprintf('favicon-%sx%s.png', $s, $s); $filename = sprintf('favicon-%sx%s.png', $s, $s);

BIN
frontend/web/favicon.ico

Binary file not shown.

Before

Width:  |  Height:  |  Size: 318 B

After

Width:  |  Height:  |  Size: 1.1 KiB

Loading…
Cancel
Save