Skip to content

Commit 0d8dcfa

Browse files
Update
1 parent fe14c6b commit 0d8dcfa

2 files changed

Lines changed: 53 additions & 30 deletions

File tree

src/CmsSeoComponent.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,6 @@ public function bootstrap($application)
707707
'forcePageParam' => $this->forcePageParam,
708708
]);
709709

710-
711710
if (\Yii::$app->request->queryParams) {
712711
$utms = [];
713712
foreach (\Yii::$app->request->queryParams as $paramName => $paramValue) {
@@ -726,16 +725,31 @@ public function bootstrap($application)
726725
'pm_block',
727726
'pm_position',
728727

728+
'cm_id',
729+
729730
'clid',
730731
'yclid',
731732
'ymclid',
732733
'frommarket',
733734
'text',
735+
736+
'roistat',
737+
'roistat_referrer',
738+
'roistat_pos',
739+
740+
'rs',
741+
'rs_referrer',
742+
'rs_pos',
734743
])) {
735744
$utms[$paramName] = $paramValue;
736745
}
737746
}
738747

748+
//Если есть хоть одна utm метка, нужно обновить и первый реферрер (страница с которой человек первый раз попал на сайт)
749+
if ($utms && \Yii::$app->request->referrer) {
750+
$utms["sx_first_referrer"] = \Yii::$app->request->referrer;
751+
}
752+
739753
if ($utms) {
740754
$this->setUtms($utms);
741755
}

src/vendor/CanUrl.php

Lines changed: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ class CanUrl extends Component implements BootstrapInterface
6969
public $is_track_pjax = false;
7070
public $is_track_flash = false;
7171
public $is_soret_query_params = false;
72-
72+
7373
public $is_redirrect = true;
74-
74+
7575
protected $_scheme;
7676
protected $_user = '';
7777
protected $_pass = '';
@@ -102,6 +102,16 @@ class CanUrl extends Component implements BootstrapInterface
102102
'ymclid' => null,
103103
'frommarket' => null,
104104
'text' => null,
105+
106+
'roistat' => null,
107+
'roistat_referrer' => null,
108+
'roistat_pos' => null,
109+
110+
'rs' => null,
111+
'rs_referrer' => null,
112+
'rs_pos' => null,
113+
114+
'cm_id' => null
105115
];
106116
public function bootstrap($application)
107117
{
@@ -125,7 +135,7 @@ public function event_end_page(Event $event)
125135
if (!isset($view->linkTags['canonical'])) {
126136
$view->linkTags['canonical'] = '<link rel="canonical" href="'.$canurl.'">';
127137
}
128-
138+
129139
}
130140

131141

@@ -195,7 +205,7 @@ public function if_need_then_send_redirect($is_final, $current_url = null)
195205
if ($this->is_redirrect !== true) {
196206
return false;
197207
}
198-
208+
199209
if (!$this->is_tracked()) {
200210
return false;
201211
}
@@ -218,17 +228,17 @@ public function is_tracked()
218228
$request = \Yii::$app->getRequest();
219229

220230
$request_method = $request->getMethod();
221-
if (!in_array($request_method, ['GET', 'HEAD']) AND !in_array($request_method, $this->extra_tracked_methods)) {
231+
if (!in_array($request_method, ['GET', 'HEAD']) and !in_array($request_method, $this->extra_tracked_methods)) {
222232
return false;
223233
}
224234

225-
if (!$this->is_track_ajax AND $request->getIsAjax()) {
235+
if (!$this->is_track_ajax and $request->getIsAjax()) {
226236
return false;
227237
}
228-
if (!$this->is_track_pjax AND $request->getIsPjax()) {
238+
if (!$this->is_track_pjax and $request->getIsPjax()) {
229239
return false;
230240
}
231-
if (!$this->is_track_flash AND $request->getIsFlash()) {
241+
if (!$this->is_track_flash and $request->getIsFlash()) {
232242
return false;
233243
}
234244

@@ -259,7 +269,7 @@ public function is_need_redirect($is_final, $current_url = null)
259269

260270
//\Yii::info("parsed_current_url = " . print_r($parsed_current_url, true), self::class);
261271
$redirurl = $this->GETredirurl($parsed_current_url, $is_final);
262-
272+
263273
//print_r($redirurl);die;
264274

265275
//\Yii::info("redirurl = {$redirurl}", self::class);
@@ -289,7 +299,7 @@ public function GETredirurl($current_url = null, $is_final = true)
289299
if (!isset($current_url)) {
290300
$current_url = \Yii::$app->getRequest()->getAbsoluteUrl();
291301
}
292-
if (!is_string($current_url) AND !is_array($current_url)) {
302+
if (!is_string($current_url) and !is_array($current_url)) {
293303
throw new InvalidParamException('(!is_string($current_url) AND !is_array($current_url))');
294304
} elseif (is_string($current_url)) {
295305
$parsed_current_url = parse_url($current_url);
@@ -353,7 +363,7 @@ public function make_query_for_redirurl($current_url = null, $is_final = true)
353363
if (!isset($current_url)) {
354364
$current_url = \Yii::$app->getRequest()->getAbsoluteUrl();
355365
}
356-
if (!is_string($current_url) AND !is_array($current_url)) {
366+
if (!is_string($current_url) and !is_array($current_url)) {
357367
throw new InvalidParamException('(!is_string($current_url) AND !is_array($current_url))');
358368
} elseif (is_string($current_url)) {
359369
$parsed_current_url = parse_url($current_url);
@@ -377,27 +387,26 @@ public function make_query_for_redirurl($current_url = null, $is_final = true)
377387
if (!isset($this->_query_params)) {
378388
return null;
379389
}
380-
if (!isset($this->_important_params) AND !$is_final) {
390+
if (!isset($this->_important_params) and !$is_final) {
381391
return null;
382392
}
383-
if (!isset($this->_minor_params) AND !$is_final) {
393+
if (!isset($this->_minor_params) and !$is_final) {
384394
return null;
385395
}
386396

387397
$this_query_params = $this->_query_params;
388398
ksort($this_query_params);
389399
$rett_params = $this_query_params;
390400

391-
$this_important_params = (isset($this->_important_params) ? $this->_important_params : []);
401+
$this_important_params = (isset($this->_important_params) ? $this->_important_params : []);
392402
$this_minor_params = (isset($this->_minor_params) ? $this->_minor_params : []);
393403

394404
if ($this->is_soret_query_params === false) {
395405

396406
if ($current_params) {
397407
$this_all_base_prams = ArrayHelper::merge($this_important_params, $this_minor_params);
398408

399-
foreach ($current_params as $key => $val)
400-
{
409+
foreach ($current_params as $key => $val) {
401410
if (array_key_exists($key, $this_all_base_prams)) {
402411
$rett_params[$key] = $val;
403412
}
@@ -406,23 +415,23 @@ public function make_query_for_redirurl($current_url = null, $is_final = true)
406415
} else {
407416
ksort($this_important_params);
408417
foreach ($this_important_params as $kkk => $vvv) {
409-
if (!isset($vvv) AND array_key_exists($kkk, $current_params)) {
418+
if (!isset($vvv) and array_key_exists($kkk, $current_params)) {
410419
$vvv = $current_params[$kkk];
411420
}
412421
$rett_params[$kkk] = $vvv;
413422
}
414-
423+
415424
ksort($this_minor_params);
416425
foreach ($this_minor_params as $kkk => $vvv) {
417-
if (!isset($vvv) AND array_key_exists($kkk, $current_params)) {
426+
if (!isset($vvv) and array_key_exists($kkk, $current_params)) {
418427
$vvv = $current_params[$kkk];
419428
}
420429
$rett_params[$kkk] = $vvv;
421430
}
422431
}
423432

424433
$res = UrlHelper::build_query($rett_params);
425-
434+
426435
return $res;
427436
}
428437
public function event_after_request(Event $event)
@@ -499,17 +508,17 @@ public function SETcore_params($core_params) { return $this->SETquery_params($co
499508
public function GETcore_params() { return $this->GETquery_params(); }
500509
public function GETquery_params()
501510
{
502-
if (isset($this->_query_params) AND !is_array($this->_query_params)) {
511+
if (isset($this->_query_params) and !is_array($this->_query_params)) {
503512
throw new Exception('(isset($this->_query_params) AND !is_array($this->_query_params))');
504513
}
505514
return $this->_query_params;
506515
}
507516
public function SETquery_params($query_params)
508517
{
509-
if (isset($query_params) AND empty($query_params)) {
518+
if (isset($query_params) and empty($query_params)) {
510519
$query_params = [];
511520
}
512-
if (isset($query_params) AND !is_array($query_params)) {
521+
if (isset($query_params) and !is_array($query_params)) {
513522
throw new InvalidParamException('(isset($query_params) AND !is_array($query_params))');
514523
}
515524
$this->_query_params = $query_params;
@@ -583,17 +592,17 @@ public function ADDimportant_params($add_important_params)
583592
}
584593
public function GETimportant_params()
585594
{
586-
if (isset($this->_important_params) AND !is_array($this->_important_params)) {
595+
if (isset($this->_important_params) and !is_array($this->_important_params)) {
587596
throw new Exception('(isset($this->_important_params) AND !is_array($this->_important_params))');
588597
}
589598
return $this->_important_params;
590599
}
591600
public function SETimportant_params($important_params)
592601
{
593-
if (isset($important_params) AND empty($important_params)) {
602+
if (isset($important_params) and empty($important_params)) {
594603
$important_params = [];
595604
}
596-
if (isset($important_params) AND !is_array($important_params)) {
605+
if (isset($important_params) and !is_array($important_params)) {
597606
throw new InvalidParamException('(isset($important_params) AND !is_array($important_params))');
598607
}
599608
$this->_important_params = $important_params;
@@ -650,17 +659,17 @@ public function ADDminor_params($add_minor_params)
650659
}
651660
public function GETminor_params()
652661
{
653-
if (isset($this->_minor_params) AND !is_array($this->_minor_params)) {
662+
if (isset($this->_minor_params) and !is_array($this->_minor_params)) {
654663
throw new Exception('(isset($this->_minor_params) AND !is_array($this->_minor_params))');
655664
}
656665
return $this->_minor_params;
657666
}
658667
public function SETminor_params($minor_params)
659668
{
660-
if (isset($minor_params) AND empty($minor_params)) {
669+
if (isset($minor_params) and empty($minor_params)) {
661670
$minor_params = [];
662671
}
663-
if (isset($minor_params) AND !is_array($minor_params)) {
672+
if (isset($minor_params) and !is_array($minor_params)) {
664673
throw new InvalidParamException('(isset($minor_params) AND !is_array($minor_params))');
665674
}
666675
$this->_minor_params = $minor_params;

0 commit comments

Comments
 (0)