Commit 7c95c2a1a10dd0133e403320d981aa10aaa4efa7

Authored by Alexey Boroda
2 parents 6a89b063 a3c00620

Merge remote-tracking branch 'origin/master'

.htaccess
... ... @@ -222,6 +222,11 @@ RewriteRule ^(.*)$ $1.gz [QSA,L]
222 222 </filesMatch>
223 223 </ifModule>
224 224  
  225 +# сжатие text, html, javascript, css, xml:
  226 +<ifModule mod_deflate.c>
  227 +AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/css text/javascript application/javascript application/x-javascript
  228 +</ifModule>
  229 +
225 230 #Запрет отдачи HTTP-заголовков Vary браузерам семейства MSIE
226 231 <IfModule mod_setenvif.c>
227 232 BrowserMatch "MSIE" force-no-vary
... ...
frontend/views/layouts/main.php
... ... @@ -12,6 +12,7 @@
12 12 use yii\widgets\Breadcrumbs;
13 13 use frontend\widgets\Seo;
14 14 use common\models\Event;
  15 + use frontend\widgets\AssetWidget;
15 16  
16 17 AppAsset::register($this);
17 18 ?>
... ... @@ -249,20 +250,25 @@
249 250 foreach($links as $index => $link) {
250 251 if(is_array($link)) {
251 252 $links[$index]['itemprop'] = 'url';
252   - $links[$index]['label'] = '<span itemprop="title">'.$links[$index]['label'].'</span>';
  253 + $links[$index]['label'] = '<span itemprop="name">'.$links[$index]['label'].'</span>';
253 254 }
254 255 }
255 256 }
256 257 echo Breadcrumbs::widget([
  258 + 'options' => [
  259 + 'class' => 'breadcrumb',
  260 + 'itemscope' => "",
  261 + 'itemtype' => " http://schema.org/BreadcrumbList"
  262 + ],
257 263 'encodeLabels' => false,
258   - 'itemTemplate' => "<li><span itemscope itemtype=\"http://data-vocabulary.org/Breadcrumb\">{link}</span></li>\n",
  264 + 'itemTemplate' => "<li itemprop=\"itemListElement\" itemscope itemtype=\"http://schema.org/ListItem\">{link}</li>\n",
259 265 'links' => isset($links) ? $links : [],
260 266 'homeLink' => [
261   - 'label' => '<span itemprop="title">Интернет-магазин светильников</span>',
  267 + 'label' => '<span itemprop="name">Интернет-магазин светильников</span>',
262 268 'url' => Url::to([ '/' ]),
263 269 'itemprop' => 'url',
264 270 ],
265   - 'activeItemTemplate' => '<li class="active"><span itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><span itemprop="title">{link}</span></span></li>',
  271 + 'activeItemTemplate' => '<li class="active" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><span itemprop="item">{link}</span></li>',
266 272 ])
267 273 ?>
268 274  
... ... @@ -610,8 +616,6 @@
610 616 </div>
611 617 </noscript>
612 618  
613   -
614   -
615 619 <?php $this->endBody() ?>
616 620 </body>
617 621 </html>
... ...
frontend/widgets/AssetWidget.php 0 → 100644
  1 +<?php
  2 + /**
  3 + * Created by PhpStorm.
  4 + * User: timur
  5 + * Date: 19.06.17
  6 + * Time: 14:20
  7 + */
  8 +
  9 + namespace frontend\widgets;
  10 +
  11 + use yii\base\InvalidConfigException;
  12 + use yii\base\Widget;
  13 + use yii\helpers\Html;
  14 + use yii\web\AssetBundle;
  15 +
  16 + class AssetWidget extends Widget
  17 + {
  18 + public $assets = [];
  19 +
  20 + public function init()
  21 + {
  22 + parent::init();
  23 + if(!empty($this->assets) && !is_array($this->assets)) {
  24 + throw new InvalidConfigException('Assets must be an array');
  25 + }
  26 + }
  27 +
  28 + public function run()
  29 + {
  30 + if(!empty($this->assets)) {
  31 + $assets = $this->assets;
  32 + $bundles = $this->view->assetBundles;
  33 + foreach ($assets as $asset) {
  34 + if(array_key_exists($asset, $bundles)) {
  35 + /**
  36 + * @var AssetBundle $bundle
  37 + */
  38 + $bundle = $bundles[$asset];
  39 + foreach ($bundle->css as $item) {
  40 + if(isset((new $asset)->sourcePath)){
  41 + $QQQ = \Yii::$app->assetManager->publish(
  42 + (new $asset)->sourcePath."/".$item,
  43 + []
  44 + );
  45 + $item = $QQQ[1]; // [0] - full path, [1] - /assets/...
  46 + }
  47 + echo Html::cssFile($item);
  48 + }
  49 + $bundle->css = [];
  50 + }
  51 + }
  52 + }
  53 + }
  54 + }
  55 +
0 56 \ No newline at end of file
... ...