Skip to content

Commit 642a39b

Browse files
Option canonicalPageParams removed
1 parent 0d18d67 commit 642a39b

4 files changed

Lines changed: 29 additions & 26 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
==============
33

4+
2.1.3
5+
-----------------
6+
* Fixed bugs
7+
* Option canonicalPageParams removed
8+
49
2.1.2
510
-----------------
611
* New cms option isRedirectNotFoundHttpException

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ Configuration app
2929
[
3030
'seo' => [
3131
'class' => 'skeeks\cms\seo\CmsSeoComponent',
32+
33+
'canUrl' => [
34+
'scheme' => 'https',
35+
'host' => 'site.ru',
36+
],
37+
38+
3239
],
3340

3441
'i18n' => [

src/CmsSeoComponent.php

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,7 @@ class CmsSeoComponent extends Component implements BootstrapInterface
9595
//"b" => 2,
9696
//"strong" => 2,
9797
]; //Учитывать следующие типы разделов
98-
/**
99-
* Добавлять тег канноникал для постраничной навигации
100-
* @var array
101-
*/
102-
public $canonicalPageParams = ['page'];
98+
10399
/**
104100
* В виджетах ListView registerLinkTags = true по умолчанию
105101
* @var bool
@@ -115,11 +111,10 @@ class CmsSeoComponent extends Component implements BootstrapInterface
115111

116112

117113
/**
114+
* false - disable canurl
118115
* @var bool|array
119116
*/
120-
protected $_canUrl = [
121-
'class' => 'skeeks\cms\seo\vendor\CanUrl'
122-
];
117+
protected $_canUrl = [];
123118

124119
/**
125120
* @var bool
@@ -243,17 +238,6 @@ public function bootstrap($application)
243238

244239
$application->on(Application::EVENT_BEFORE_REQUEST, function (Event $e) {
245240

246-
/**
247-
* Добавление канноникал для постранички
248-
*/
249-
if ($this->canonicalPageParams && is_array($this->canonicalPageParams)) {
250-
foreach ($this->canonicalPageParams as $paramName) {
251-
if (\Yii::$app->request->get($paramName)) {
252-
\Yii::$app->view->registerLinkTag(['rel' => 'canonical', 'href' => \Yii::$app->request->hostInfo . '/' . \Yii::$app->request->pathInfo]);
253-
}
254-
}
255-
}
256-
257241
/**
258242
* Добавление метатегов в постраничной навигации
259243
*/
@@ -312,7 +296,7 @@ protected function _initDefaultCanUrl() {
312296
$this->canUrl->host = \Yii::$app->request->hostName;
313297
}
314298

315-
if (!$this->canUrl->port) {
299+
if (!$this->canUrl->scheme) {
316300
$this->canUrl->scheme = \Yii::$app->request->isSecureConnection ? "https" : "http";
317301
}
318302

@@ -348,6 +332,7 @@ public function _isTrigerEventCanUrl()
348332
if (\Yii::$app->controller && in_array(\Yii::$app->controller->uniqueId, [
349333
'cms/tree',
350334
'cms/content-element',
335+
'savedFilters/saved-filters',
351336
])) {
352337
return true;
353338
}
@@ -384,10 +369,18 @@ public function setCanUrl($canUrl)
384369
*/
385370
public function getCanUrl()
386371
{
372+
if ($this->_canUrl === false) {
373+
return $this->_canUrl;
374+
}
375+
387376
if (is_array($this->_canUrl)) {
377+
$this->_canUrl = ArrayHelper::merge([
378+
'class' => 'skeeks\cms\seo\vendor\CanUrl'
379+
], $this->_canUrl);
388380
$this->_canUrl = \Yii::createObject($this->_canUrl);
389381
}
390382

383+
//print_r($this->_canUrl);die;
391384
return $this->_canUrl;
392385
}
393386

src/vendor/CanUrl.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,14 @@ public function is_need_redirect($is_final, $current_url = null)
235235
throw new InvalidParamException('(!is_string($current_url))');
236236
}
237237

238+
\Yii::info("current_url = {$current_url}", self::class);
238239
$parsed_current_url = parse_url($current_url);
239240

241+
\Yii::info("parsed_current_url = " . print_r($parsed_current_url, true), self::class);
240242
$redirurl = $this->GETredirurl($parsed_current_url, $is_final);
241243

244+
\Yii::info("redirurl = {$redirurl}", self::class);
245+
\Yii::info("this = " . print_r($this, true), self::class);
242246
if ($redirurl === $current_url) {
243247
return false;
244248
}
@@ -390,12 +394,6 @@ public function SETscheme($value)
390394
$this->_scheme = $value;
391395
return $this;
392396
}
393-
public function SETschema($value)
394-
{
395-
$this->_scheme = $value;
396-
return $this;
397-
}
398-
public function GETschema() { return $this->_scheme; }
399397
public function GETuser() { return $this->_user; }
400398
public function SETuser($value)
401399
{

0 commit comments

Comments
 (0)