-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #233 from oc-shopaholic/develop
Release version 1.24.0
- Loading branch information
Showing
22 changed files
with
181 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
repo_token: ${{ secrets.Coveralls }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,18 +10,18 @@ | |
/** | ||
* Class BrandItem | ||
* @package Lovata\Shopaholic\Classes\Item | ||
* @author Andrey Kharanenka, [email protected], LOVATA Group | ||
* @author Andrey Kharanenka, [email protected], LOVATA Group | ||
* | ||
* @property int $id | ||
* @property string $name | ||
* @property string $slug | ||
* @property string $code | ||
* @property int $id | ||
* @property string $name | ||
* @property string $slug | ||
* @property string $code | ||
* | ||
* @property string $preview_text | ||
* @property \System\Models\File $preview_image | ||
* @property string $preview_text | ||
* @property \System\Models\File $preview_image | ||
* | ||
* @property string $description | ||
* @property \October\Rain\Database\Collection|\System\Models\File[] $images | ||
* @property string $description | ||
* @property \October\Rain\Database\Collection|\System\Models\File[] $images | ||
*/ | ||
class BrandItem extends ElementItem | ||
{ | ||
|
@@ -34,13 +34,14 @@ class BrandItem extends ElementItem | |
* Returns URL of a brand page. | ||
* | ||
* @param string $sPageCode | ||
* @param array $arRemoveParamList | ||
* | ||
* @return string | ||
*/ | ||
public function getPageUrl($sPageCode = 'brand') | ||
public function getPageUrl($sPageCode = 'brand', $arRemoveParamList = []) | ||
{ | ||
//Get URL params | ||
$arParamList = $this->getPageParamList($sPageCode); | ||
$arParamList = $this->getPageParamList($sPageCode, $arRemoveParamList); | ||
|
||
//Generate page URL | ||
$sURL = CmsPage::url($sPageCode, $arParamList); | ||
|
@@ -51,19 +52,25 @@ public function getPageUrl($sPageCode = 'brand') | |
/** | ||
* Get URL param list by page code | ||
* @param string $sPageCode | ||
* @param array $arRemoveParamList | ||
* @return array | ||
*/ | ||
public function getPageParamList($sPageCode) : array | ||
public function getPageParamList($sPageCode, $arRemoveParamList = []) : array | ||
{ | ||
$arPageParamList = []; | ||
$arResult = []; | ||
if (!empty($arRemoveParamList)) { | ||
foreach ($arRemoveParamList as $sParamName) { | ||
$arResult[$sParamName] = null; | ||
} | ||
} | ||
|
||
//Get URL params for page | ||
$arParamList = PageHelper::instance()->getUrlParamList($sPageCode, 'BrandPage'); | ||
if (!empty($arParamList)) { | ||
$sPageParam = array_shift($arParamList); | ||
$arPageParamList[$sPageParam] = $this->slug; | ||
$arResult[$sPageParam] = $this->slug; | ||
} | ||
|
||
return $arPageParamList; | ||
return $arResult; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,8 +8,6 @@ | |
* Class BrandData | ||
* @package Lovata\Shopaholic\Components | ||
* @author Andrey Kharanenka, [email protected], LOVATA Group | ||
* | ||
* @link https://github.com/lovata/oc-shopaholic-plugin/wiki/BrandData | ||
*/ | ||
class BrandData extends ElementData | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,6 @@ | |
* Class BrandList | ||
* @package Lovata\Shopaholic\Components | ||
* @author Andrey Kharanenka, [email protected], LOVATA Group | ||
* | ||
* @link https://github.com/lovata/oc-shopaholic-plugin/wiki/BrandList | ||
*/ | ||
class BrandList extends ComponentBase | ||
{ | ||
|
@@ -36,6 +34,7 @@ public function make($arElementIDList = null) | |
|
||
/** | ||
* Method for ajax request with empty response | ||
* @deprecated | ||
* @return bool | ||
*/ | ||
public function onAjaxRequest() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,8 +10,6 @@ | |
* Class BrandPage | ||
* @package Lovata\Shopaholic\Components | ||
* @author Andrey Kharanenka, [email protected], LOVATA Group | ||
* | ||
* @link https://github.com/lovata/oc-shopaholic-plugin/wiki/BrandPage | ||
*/ | ||
class BrandPage extends ElementPage | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,8 +11,6 @@ | |
* @package Lovata\Shopaholic\Components | ||
* @author Andrey Kharanenka, [email protected], LOVATA Group | ||
* @deprecated | ||
* | ||
* @link https://github.com/lovata/oc-shopaholic-plugin/wiki/Breadcrumbs | ||
*/ | ||
class Breadcrumbs extends ComponentBase | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,8 +8,6 @@ | |
* Class CategoryData | ||
* @package Lovata\Shopaholic\Components | ||
* @author Andrey Kharanenka, [email protected], LOVATA Group | ||
* | ||
* @link https://github.com/lovata/oc-shopaholic-plugin/wiki/CategoryData | ||
*/ | ||
class CategoryData extends ElementData | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,6 @@ | |
* Class CategoryList | ||
* @package Lovata\Shopaholic\Components | ||
* @author Andrey Kharanenka, [email protected], LOVATA Group | ||
* @link https://github.com/lovata/oc-shopaholic-plugin/wiki/CategoryList | ||
*/ | ||
class CategoryList extends ComponentBase | ||
{ | ||
|
@@ -35,6 +34,7 @@ public function make($arElementIDList = null) | |
|
||
/** | ||
* Method for ajax request with empty response | ||
* @deprecated | ||
* @return bool | ||
*/ | ||
public function onAjaxRequest() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,12 +10,11 @@ | |
* Class CategoryPage | ||
* @package Lovata\Shopaholic\Components | ||
* @author Andrey Kharanenka, [email protected], LOVATA Group | ||
* | ||
* @link https://github.com/lovata/oc-shopaholic-plugin/wiki/CategoryPage | ||
*/ | ||
class CategoryPage extends ElementPage | ||
{ | ||
protected $bNeedSmartURLCheck = true; | ||
protected $bHasWildCard = true; | ||
|
||
/** @var \Lovata\Shopaholic\Models\Category */ | ||
protected $obElement; | ||
|
@@ -45,6 +44,26 @@ protected function getElementObject($sElementSlug) | |
return null; | ||
} | ||
|
||
if (!$this->property('has_wildcard')) { | ||
$obElement = $this->getElementBySlug($sElementSlug); | ||
} else { | ||
$obElement = $this->getElementByWildcard($sElementSlug); | ||
} | ||
|
||
if (!empty($obElement)) { | ||
Event::fire('shopaholic.category.open', [$obElement]); | ||
} | ||
|
||
return $obElement; | ||
} | ||
|
||
/** | ||
* Get category by default | ||
* @param string $sElementSlug | ||
* @return Category|null | ||
*/ | ||
protected function getElementBySlug($sElementSlug) | ||
{ | ||
if ($this->isSlugTranslatable()) { | ||
$obElement = Category::active()->transWhere('slug', $sElementSlug)->first(); | ||
if (!$this->checkTransSlug($obElement, $sElementSlug)) { | ||
|
@@ -53,8 +72,66 @@ protected function getElementObject($sElementSlug) | |
} else { | ||
$obElement = Category::active()->getBySlug($sElementSlug)->first(); | ||
} | ||
if (!empty($obElement)) { | ||
Event::fire('shopaholic.category.open', [$obElement]); | ||
|
||
return $obElement; | ||
} | ||
|
||
/** | ||
* Get category by wildcard | ||
* @param string $sElementSlug | ||
* @return Category|null | ||
*/ | ||
protected function getElementByWildcard($sElementSlug) | ||
{ | ||
$arSlugList = explode('/', $sElementSlug); | ||
if (empty($arSlugList)) { | ||
return null; | ||
} | ||
|
||
$arSlugList = array_reverse($arSlugList); | ||
$sElementSlug = array_shift($arSlugList); | ||
|
||
$obElement = $this->getElementBySlug($sElementSlug); | ||
if (empty($obElement)) { | ||
return null; | ||
} | ||
|
||
if (empty($arSlugList) && empty($obElement->parent)) { | ||
return $obElement; | ||
} | ||
|
||
$obNestingElement = $obElement; | ||
|
||
foreach ($arSlugList as $sSlug) { | ||
$obNestingElement = $this->getNestingElement($sSlug, $obNestingElement); | ||
if (empty($obNestingElement)) { | ||
return null; | ||
} | ||
} | ||
|
||
if (!empty($obNestingElement->parent)) { | ||
return null; | ||
} | ||
|
||
return $obElement; | ||
} | ||
|
||
/** | ||
* Get nesting element | ||
* @param string $sElementSlug | ||
* @param Category $obNestingElement | ||
* @return Category | ||
*/ | ||
protected function getNestingElement($sElementSlug, $obNestingElement) | ||
{ | ||
if (empty($obNestingElement) || empty($sElementSlug)) { | ||
return null; | ||
} | ||
|
||
$obElement = $obNestingElement->parent; | ||
|
||
if (empty($obElement) || $obElement->slug != $sElementSlug) { | ||
return null; | ||
} | ||
|
||
return $obElement; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.