Skip to content

Commit

Permalink
Merge pull request #77 from oc-shopaholic/develop
Browse files Browse the repository at this point in the history
Release version 1.26.0
  • Loading branch information
kharanenka authored Dec 19, 2019
2 parents 2e935ee + 5b19edb commit 716352b
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 8 deletions.
1 change: 1 addition & 0 deletions classes/component/ElementData.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function onGetJSONData()

/**
* Ajax listener
* @deprecated
* @return bool
*/
public function onAjaxRequest()
Expand Down
18 changes: 16 additions & 2 deletions classes/component/ElementPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,27 @@ abstract class ElementPage extends ComponentBase
protected $arPropertyList = [];

protected $bNeedSmartURLCheck = false;
protected $bHasWildCard = false;

/**
* @return array
*/
public function defineProperties()
{
$this->arPropertyList = array_merge($this->arPropertyList, $this->getElementPageProperties());
if ($this->bHasWildCard) {
$this->arPropertyList['has_wildcard'] = [
'title' => 'lovata.toolbox::lang.component.has_wildcard',
'type' => 'checkbox',
'default' => 0,
];
}

$this->arPropertyList['skip_error'] = [
'title' => 'lovata.toolbox::lang.component.skip_error',
'type' => 'checkbox',
'default' => 0,
];

return $this->arPropertyList;
}
Expand All @@ -50,7 +64,7 @@ public function onRun()
return null;
}

if (empty($this->obElement)) {
if (empty($this->obElement) && !$this->property('skip_error')) {
return $this->getErrorResponse();
}

Expand Down Expand Up @@ -135,7 +149,7 @@ protected function smartUrlCheck()

$sCurrentURL = $this->currentPageUrl();
$sValidURL = $this->obElementItem->getPageUrl($this->page->id);
$bResult = $sCurrentURL == $sValidURL;
$bResult = preg_match("%^{$sValidURL}%", $sCurrentURL);

return $bResult;
}
Expand Down
2 changes: 1 addition & 1 deletion classes/helper/AbstractImportModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ protected function processModelObject()
}

foreach ($this->arImportData[$sLangCode] as $sField => $sValue) {
$this->obModel->setTranslateAttribute($sField, $sValue, $sLangCode);
$this->obModel->setAttributeTranslated($sField, $sValue, $sLangCode);
}
}

Expand Down
12 changes: 9 additions & 3 deletions classes/helper/PageHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,19 @@ class PageHelper
* @param string $sPageCode
* @param string $sComponentName
* @param string $sParamName
* @param bool $bFindWildcard
*
* @return array
*/
public function getUrlParamList($sPageCode, $sComponentName, $sParamName = 'slug')
public function getUrlParamList($sPageCode, $sComponentName, $sParamName = 'slug', $bFindWildcard = false)
{
$sCacheKey = implode('_', [$sPageCode, $sComponentName, $sParamName]);
if ($this->hasCache($sCacheKey)) {
return $this->getCachedData($sCacheKey);
}

$arResult = [];
if (empty($sPageCode) || empty($sComponentName) || empty($sParamName)) {
if (empty($sPageCode) || empty($sParamName)) {
return $arResult;
}

Expand All @@ -54,7 +55,7 @@ public function getUrlParamList($sPageCode, $sComponentName, $sParamName = 'slug
}

foreach ($arComponentList as $sKey => $arPropertyList) {
if (!preg_match('%^'.$sComponentName.'%', $sKey)) {
if (!empty($sComponentName) && !preg_match('%^'.$sComponentName.'%', $sKey)) {
continue;
}

Expand All @@ -73,6 +74,11 @@ public function getUrlParamList($sPageCode, $sComponentName, $sParamName = 'slug
$sValue = trim($arMatches[1]);
$sValue = ltrim($sValue, ':');
$arResult[] = $sValue;

if ($bFindWildcard && array_get($arPropertyList, 'has_wildcard')) {
$arResult = [$sValue];
break;
}
}

$this->setCachedData($sCacheKey, $arResult);
Expand Down
2 changes: 2 additions & 0 deletions lang/en/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@
'property_mode' => 'Component mode',
'mode_submit' => 'Form submit',
'mode_ajax' => 'Ajax',
'has_wildcard' => 'URL section is wildcard',
'skip_error' => 'Skip "Not found" error',
],
'message' => [
'create_success' => 'Create :name was successful',
Expand Down
2 changes: 2 additions & 0 deletions lang/ru/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@
'property_mode' => 'Режим работы',
'mode_submit' => 'Отправка формы',
'mode_ajax' => 'Ajax',
'has_wildcard' => 'Часть URL является wildcard параметром',
'skip_error' => 'Пропустить ошибку "Не найдено"',
],
'message' => [
'create_success' => 'Создание :name было успешно выполнено',
Expand Down
2 changes: 1 addition & 1 deletion traits/helpers/TraitComponentNotFoundResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function getElementPageProperties()
* @throws AjaxException
* @return \Illuminate\Http\Response
*/
protected function getErrorResponse()
public function getErrorResponse()
{
if (Request::ajax()) {
throw new AjaxException('Element not found');
Expand Down
4 changes: 3 additions & 1 deletion updates/version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,6 @@
1.25.2:
- 'Added try->catch section for removing images in AbstractImportModel class.'
1.25.3:
- 'Fixed bug with import through queues.'
- 'Fixed bug with import through queues.'
1.26.0:
- 'Added support of wildcard params to ElementPage class.'

0 comments on commit 716352b

Please sign in to comment.