From 52ac578820415ebd1388a37577ee1ecdd82cf908 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Fri, 2 Dec 2016 13:20:26 +0200 Subject: [PATCH] add variantSku --- widgets/Seo.php | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/widgets/Seo.php b/widgets/Seo.php index 93f8841..b6f846c 100755 --- a/widgets/Seo.php +++ b/widgets/Seo.php @@ -23,6 +23,10 @@ class Seo extends Widget public $key; public $name; public $project_name; + public $widgetData; + + public $widgetDynamicData; + public static $optionsListObject; public static $optionsList; protected static $check_url; protected static $check_url_bool; @@ -37,9 +41,16 @@ class Seo extends Widget public function init() { $this->url = \Yii::$app->request->url; + $this->project_name = \Yii::$app->name; + + $this->widgetData = static::findSeoByUrl($this->url); + + $this->widgetDynamicData = $this->findSeoByDynamic(); + if(empty(self::$optionsList)){ - self::$optionsList = ArrayHelper::getColumn(TaxGroup::find()->joinWith('lang')->where(['is_filter' => 'TRUE'])->asArray()->all(),'lang.alias'); + self::$optionsListObject = TaxGroup::find()->joinWith('lang')->where(['is_filter' => 'TRUE'])->asArray()->all(); + self::$optionsList = ArrayHelper::getColumn(self::$optionsListObject,'lang.alias'); } parent::init(); @@ -58,6 +69,8 @@ class Seo extends Widget } + + switch ($this->row) { case self::SEO_TEXT: @@ -68,25 +81,22 @@ class Seo extends Widget if(empty($filter) && empty($sort) && empty($paginate) ){ - return $this->prepareString($this->selectSeoData(self::SEO_TEXT,$filter,$priority)); + return $this->prepareString($this->selectSeoData(self::SEO_TEXT,$filter, $this->widgetData, $this->widgetData, $priority)); } else { - $widgetData = static::findSeoByUrl($this->url); $result = ''; - if ($widgetData instanceof \artweb\artbox\seo\models\Seo) { + if ($this->widgetData instanceof \artweb\artbox\seo\models\Seo) { - $result = $widgetData->{self::SEO_TEXT}; + $result = $this->widgetData->{self::SEO_TEXT}; } else { - $widgetData = $this->findSeoByDynamic(); - - if ($widgetData instanceof SeoDynamic) { + if ($this->widgetData instanceof SeoDynamic) { - $result = $widgetData->lang->{self::SEO_TEXT}; + $result = $this->widgetData->lang->{self::SEO_TEXT}; } @@ -101,7 +111,7 @@ class Seo extends Widget $filter = \Yii::$app->request->get('filters', []); - $default = $this->selectSeoData(self::H1, $filter,$priority); + $default = $this->selectSeoData(self::H1, $filter, $this->widgetData, $this->widgetData, $priority); if ($default != $this->{self::H1}) { @@ -122,7 +132,7 @@ class Seo extends Widget $filter = \Yii::$app->request->get('filters', []); - $title = $this->selectSeoData(self::TITLE, $filter,$priority); + $title = $this->selectSeoData(self::TITLE, $filter, $this->widgetData, $this->widgetData, $priority); if(!empty($filter) && $priority==3 || !empty($filter) && empty($this->{Seo::TITLE})) { @@ -148,7 +158,7 @@ class Seo extends Widget $filter = \Yii::$app->request->get('filters', []); - $description = $this->selectSeoData(self::DESCRIPTION, $filter,$priority); + $description = $this->selectSeoData(self::DESCRIPTION, $filter, $this->widgetData, $this->widgetData, $priority); if (!empty($description)) { @@ -177,7 +187,7 @@ class Seo extends Widget $sort = \Yii::$app->request->get('sort', []); $paginate = \Yii::$app->request->get('page', []); - $meta = $this->selectSeoData(self::META, $filter,$priority); + $meta = $this->selectSeoData(self::META, $filter, $this->widgetData, $this->widgetData, $priority); if(!empty($filter) && !$this->checkFilter($filter) && count($filter, COUNT_RECURSIVE) == 2){ $key = array_keys ( $filter); @@ -321,15 +331,15 @@ class Seo extends Widget * @param $param * @param $filter * @param $priority + * @param $widgetData + * @param $widgetDynamicData * @return mixed */ - protected function selectSeoData($param, $filter, &$priority) + protected function selectSeoData($param, $filter, $widgetData, $widgetDynamicData, &$priority) { $result = ''; - $widgetData = static::findSeoByUrl($this->url); - $widgetDynamicData = $this->findSeoByDynamic(); if ($widgetData instanceof \artweb\artbox\seo\models\Seo) { $priority = 1; @@ -424,7 +434,7 @@ class Seo extends Widget } - $optionsList = ArrayHelper::map(TaxGroup::find()->joinWith('lang')->where(['is_filter' => 'TRUE'])->asArray()->all(), 'lang.alias', 'name'); + $optionsList = ArrayHelper::map(self::$optionsListObject, 'lang.alias', 'name'); foreach ($optionsList as $optionList => $name) { -- libgit2 0.21.4