From 8a7d608fe1c8844923ad9746f3dea60f056f0d01 Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Tue, 9 Mar 2021 20:00:01 +0300 Subject: [PATCH 01/14] * Code style, `elseif` is used instead of `else if`. --- src/Outputter/Outputter.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Outputter/Outputter.php b/src/Outputter/Outputter.php index 3dce281..3d86b57 100644 --- a/src/Outputter/Outputter.php +++ b/src/Outputter/Outputter.php @@ -43,7 +43,7 @@ public final static function includeOutputterByName($parserName){ /** * __construct - * @version 1.3 (2020-03-10) + * @version 1.3.1 (2021-03-09) * * @param $params {stdClass|arrayAssociative} * @param $params->dataProvider {\ddGetDocuments\DataProvider\DataProvider} @@ -65,7 +65,7 @@ function __construct($params = []){ if (empty($this->docFields)){ //We need something $this->docFields = ['id']; - }else if (isset($params->dataProvider)){ + }elseif (isset($params->dataProvider)){ //Ask dataProvider to get them $params->dataProvider->addResourcesFieldsToGet($this->docFields); } From c8901e6a0b01838b354a59cf103f4fc9ac81cdd4 Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Mon, 12 Jul 2021 10:33:49 +0300 Subject: [PATCH 02/14] + `\ddGetDocuments\Outputter\Outputter`: + `$templates`: The new field. + `__construct`: Added templates preparing. --- src/Outputter/Outputter.php | 42 +++++++++++++++++- src/Outputter/Yandexmarket/Outputter.php | 55 ++++++++---------------- 2 files changed, 58 insertions(+), 39 deletions(-) diff --git a/src/Outputter/Outputter.php b/src/Outputter/Outputter.php index 3d86b57..e56293d 100644 --- a/src/Outputter/Outputter.php +++ b/src/Outputter/Outputter.php @@ -10,7 +10,13 @@ abstract class Outputter extends \DDTools\BaseClass { * @property $docFields {array} — Document fields including TVs used in the output. * @property $docFields[i] {string} — Field name. */ - $docFields = ['id'] + $docFields = ['id'], + + /** + * @property $templates {stdClass} + * @property $templates->{$templateName} {string} + */ + $templates = [] ; /** @@ -43,7 +49,7 @@ public final static function includeOutputterByName($parserName){ /** * __construct - * @version 1.3.1 (2021-03-09) + * @version 1.4 (2021-07-09) * * @param $params {stdClass|arrayAssociative} * @param $params->dataProvider {\ddGetDocuments\DataProvider\DataProvider} @@ -51,6 +57,38 @@ public final static function includeOutputterByName($parserName){ function __construct($params = []){ $params = (object) $params; + + //# Prepare templates + $this->templates = (object) $this->templates; + + //If parameter is passed + if ( + \DDTools\ObjectTools::isPropExists([ + 'object' => $params, + 'propName' => 'templates' + ]) + ){ + //Estend defaults + $this->templates = \DDTools\ObjectTools::extend([ + 'objects' => [ + $this->templates, + $params->templates + ] + ]); + + //Remove from params to prevent overwriting through `$this->setExistingProps` + unset($params->templates); + } + + foreach ( + $this->templates as + $templateName => + $templateValue + ){ + $this->templates->{$templateName} = \ddTools::$modx->getTpl($templateValue); + } + + //Все параметры задают свойства объекта $this->setExistingProps($params); diff --git a/src/Outputter/Yandexmarket/Outputter.php b/src/Outputter/Yandexmarket/Outputter.php index 48215ab..2de88c3 100644 --- a/src/Outputter/Yandexmarket/Outputter.php +++ b/src/Outputter/Yandexmarket/Outputter.php @@ -177,7 +177,7 @@ class Outputter extends \ddGetDocuments\Outputter\Outputter { /** * __construct - * @version 2.1 (2021-02-27) + * @version 2.1.1 (2021-07-09) * * @note @link https://yandex.ru/support/partnermarket/export/yml.html * @@ -221,31 +221,23 @@ function __construct($params = []){ $this->construct_prepareFields(); - //# Save shopData and templates - foreach( - [ - 'shopData', - 'templates' - ] as - $fieldName + //# Save shopData + //If parameter is passed + if ( + \DDTools\ObjectTools::isPropExists([ + 'object' => $params, + 'propName' => 'shopData' + ]) ){ - //If parameter is passed - if ( - \DDTools\ObjectTools::isPropExists([ - 'object' => $params, - 'propName' => $fieldName - ]) - ){ - $this->{$fieldName} = \DDTools\ObjectTools::extend([ - 'objects' => [ - $this->{$fieldName}, - $params->{$fieldName} - ] - ]); - - //Remove from params to prevent overwriting through `$this->setExistingProps` - unset($params->{$fieldName}); - } + $this->shopData = \DDTools\ObjectTools::extend([ + 'objects' => [ + $this->shopData, + $params->shopData + ] + ]); + + //Remove from params to prevent overwriting through `$this->setExistingProps` + unset($params->shopData); } @@ -279,16 +271,6 @@ function __construct($params = []){ } - //# Prepare templates - foreach ( - $this->templates as - $templateName => - $templateValue - ){ - $this->templates->{$templateName} = \ddTools::$modx->getTpl($templateValue); - } - - //# Call base constructor parent::__construct($params); @@ -321,7 +303,7 @@ function __construct($params = []){ /** * construct_prepareFields - * @version 1.0 (2021-02-08) + * @version 1.0.1 (2021-07-09) * * @return {void} */ @@ -337,7 +319,6 @@ private function construct_prepareFields(){ $this->offerFields->{$offerFieldName} = (object) $this->offerFields->{$offerFieldName}; } - $this->templates = (object) $this->templates; //Trim all templates foreach ( $this->templates as From bee526df6352973a5257254d3f0a10e524939ba5 Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Mon, 12 Jul 2021 11:31:38 +0300 Subject: [PATCH 03/14] =?UTF-8?q?+=20Outputters=20=E2=86=92=20Json=20?= =?UTF-8?q?=E2=86=92=20Parameters=20=E2=86=92=20`outputterParams->template?= =?UTF-8?q?s`:=20The=20new=20parameters.=20You=20can=20use=20templates=20f?= =?UTF-8?q?or=20some=20document=20fields.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 19 +++++++++++++++++++ src/Outputter/Json/Outputter.php | 20 +++++++++++++++++--- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3dce8e6..41cf6b8 100644 --- a/README.md +++ b/README.md @@ -242,6 +242,25 @@ Get resources from custom DB table. * `stringDocFieldName` * `stringTvName` * **Required** + +* `outputterParams->templates` + * Desctription: Templates. + * Valid values: `object` + * Default value: — + +* `outputterParams->templates->{$docFieldName}` + * Desctription: + You can use templates for some document fields. + Templates will be used before JSON conversion of results. So you don't need to care about characters escaping. + + It is useful for manipulations with doc field values through running snippets. + + Available placeholders: + * `[+value+]` — document field value + * Valid values: + * `stringChunkName` + * `string` — use inline templates starting with `@CODE:` + * **Required** ##### Outputter → Sitemap (``&outputter=`sitemap` ``) diff --git a/src/Outputter/Json/Outputter.php b/src/Outputter/Json/Outputter.php index 7fd8015..75e1b20 100644 --- a/src/Outputter/Json/Outputter.php +++ b/src/Outputter/Json/Outputter.php @@ -4,11 +4,10 @@ use ddGetDocuments\Output; -class Outputter extends \ddGetDocuments\Outputter\Outputter -{ +class Outputter extends \ddGetDocuments\Outputter\Outputter { /** * parse - * @version 2.1.4 (2020-06-08) + * @version 2.2 (2021-07-12) * * @param $data {Output} * @@ -30,6 +29,21 @@ public function parse(Output $data){ $docField ){ $result_item[$docField] = $itemData[$docField]; + + //If template for this field is set + if ( + \DDTools\ObjectTools::isPropExists([ + 'object' => $this->templates, + 'propName' => $docField + ]) + ){ + $result_item[$docField] = \ddTools::parseSource(\ddTools::parseText([ + 'text' => $this->templates->{$docField}, + 'data' => [ + 'value' => $result_item[$docField] + ] + ])); + } } $result[] = $result_item; From eb38febebe66d5977a3f5f4559f01738895056ab Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Tue, 13 Jul 2021 17:24:31 +0300 Subject: [PATCH 04/14] + `\ddGetDocuments\Outputter\Outputter::__construct`: Improved `$this->templates` preparing. --- src/Outputter/Outputter.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Outputter/Outputter.php b/src/Outputter/Outputter.php index e56293d..0184044 100644 --- a/src/Outputter/Outputter.php +++ b/src/Outputter/Outputter.php @@ -49,7 +49,7 @@ public final static function includeOutputterByName($parserName){ /** * __construct - * @version 1.4 (2021-07-09) + * @version 1.5 (2021-07-13) * * @param $params {stdClass|arrayAssociative} * @param $params->dataProvider {\ddGetDocuments\DataProvider\DataProvider} @@ -85,7 +85,10 @@ function __construct($params = []){ $templateName => $templateValue ){ - $this->templates->{$templateName} = \ddTools::$modx->getTpl($templateValue); + //Exclude null values + if (is_string($templateValue)){ + $this->templates->{$templateName} = \ddTools::$modx->getTpl($templateValue); + } } From 57a3f587e264bbe0707451ea2cbf6f1074a447ad Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Sun, 18 Jul 2021 16:13:02 +0300 Subject: [PATCH 05/14] * `\ddGetDocuments\Input::__construct`: Outputter name will converted to lowercase before calling backward compatibility methods because it can be used there. --- src/Input.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Input.php b/src/Input.php index 3de665b..afe9b5f 100644 --- a/src/Input.php +++ b/src/Input.php @@ -40,7 +40,7 @@ class Input extends \DDTools\BaseClass { /** * __construct - * @version 4.4.1 (2021-02-26) + * @version 4.4.2 (2021-07-18) * * @param $snippetParams {stdClass} — The object of parameters. @required * @param $snippetParams->providerParams {stdClass|arrayAssociative|stringJsonObject} @@ -84,6 +84,9 @@ public function __construct($snippetParams){ } + $this->outputter = strtolower($this->outputter); + + //Backward compatibility $this->backwardCompatibility_dataProviderParams($snippetParams); $this->backwardCompatibility_outputterParams(); @@ -96,10 +99,6 @@ public function __construct($snippetParams){ $this->setExistingProps($snippetParams); - //TODO: Is it needed? - $this->outputter = strtolower($this->outputter); - - //Make sure orderBy and filter looks like SQL foreach ( [ From fe555d72f69390ca9a5cf9f5665dbd1ad63b469c Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Sun, 18 Jul 2021 16:26:41 +0300 Subject: [PATCH 06/14] * `\ddGetDocuments\Input::backwardCompatibility_outputterParams`: Refactoring, yandexmarket preparation has been moved out to a standalone method. --- src/Input.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Input.php b/src/Input.php index afe9b5f..cb3dbb1 100644 --- a/src/Input.php +++ b/src/Input.php @@ -213,15 +213,28 @@ private function backwardCompatibility_dataProviderParams($snippetParams){ /** * backwardCompatibility_outputterParams - * @version 1.0 (2021-02-25) + * @version 1.0.1 (2021-07-18) * * @desc Prepare data provider params preserve backward compatibility. * * @return {void} */ private function backwardCompatibility_outputterParams(){ + switch ($this->outputter){ + case 'yandexmarket': + $this->backwardCompatibility_outputterParams_yandexmarket(); + break; + } + } + + /** + * backwardCompatibility_outputterParams_yandexmarket + * @version 1.0 (2021-07-18) + * + * @return {void} + */ + private function backwardCompatibility_outputterParams_yandexmarket(){ if ( - $this->outputter == 'yandexmarket' && //If required shopData is not set, then we need to provide backward compatibility !\DDTools\ObjectTools::isPropExists([ 'object' => $this->outputterParams, From 5286dfd40554c3b8c1044f6478fff4b0ab86340d Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Sun, 18 Jul 2021 17:13:39 +0300 Subject: [PATCH 07/14] =?UTF-8?q?*=20Outputters=20=E2=86=92=20String=20?= =?UTF-8?q?=E2=86=92=20Parameters=20=E2=86=92=20`outputterParams->template?= =?UTF-8?q?s`:=20The=20following=20parameters=20moved=20here=20(with=20bac?= =?UTF-8?q?kward=20compatibility):=20=09*=20`outputterParams->itemTpl`=20?= =?UTF-8?q?=E2=86=92=20`outputterParams->templates->item`.=20=09*=20`outpu?= =?UTF-8?q?tterParams->itemTplFirst`=20=E2=86=92=20`outputterParams->templ?= =?UTF-8?q?ates->itemFirst`.=20=09*=20`outputterParams->itemTplLast`=20?= =?UTF-8?q?=E2=86=92=20`outputterParams->templates->itemLast`.=20=09*=20`o?= =?UTF-8?q?utputterParams->wrapperTpl`=20=E2=86=92=20`outputterParams->tem?= =?UTF-8?q?plates->wrapper`.=20=09*=20`outputterParams->noResults`=20?= =?UTF-8?q?=E2=86=92=20`outputterParams->templates->noResults`.=20*=20Outp?= =?UTF-8?q?utters=20=E2=86=92=20Sitemap=20=E2=86=92=20Parameters=20?= =?UTF-8?q?=E2=86=92=20`outputterParams->templates`:=20The=20following=20p?= =?UTF-8?q?arameters=20moved=20here=20(with=20backward=20compatibility):?= =?UTF-8?q?=20=09*=20`outputterParams->itemTpl`=20=E2=86=92=20`outputterPa?= =?UTF-8?q?rams->templates->item`.=20=09*=20`outputterParams->wrapperTpl`?= =?UTF-8?q?=20=E2=86=92=20`outputterParams->templates->wrapper`.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 82 +++++++++++---------- src/Input.php | 59 ++++++++++++++- src/Outputter/Outputter.php | 59 ++++++++------- src/Outputter/Sitemap/Outputter.php | 22 +++--- src/Outputter/String/Outputter.php | 92 +++++++++++------------- src/Outputter/Yandexmarket/Outputter.php | 8 ++- 6 files changed, 193 insertions(+), 129 deletions(-) diff --git a/README.md b/README.md index 41cf6b8..ea1f1da 100644 --- a/README.md +++ b/README.md @@ -159,11 +159,16 @@ Get resources from custom DB table. * `stirngJsonObject` * `stringQueryFormated` * Default value: — + +* `outputterParams->templates` + * Desctription: Output templates. + * Valid values: `object` + * Default value: — ##### Outputter → String (``&outputter=`string` ``) -* `outputterParams->itemTpl` +* `outputterParams->templates->item` * Desctription: Item template. Available placeholders: * `[+`any document field or tv name`+]` — Any document field name or TV. @@ -176,21 +181,21 @@ Get resources from custom DB table. * `string` — use inline templates starting with `@CODE:` * **Required** -* `outputterParams->itemTplFirst` - * Desctription: Template for the first item. Has the same placeholders as `outputterParams->itemTpl`. +* `outputterParams->templates->itemFirst` + * Desctription: Template for the first item. Has the same placeholders as `outputterParams->templates->item`. * Valid values: * `stringChunkName` * `string` — use inline templates starting with `@CODE:` - * Default value: == `outputterParams->itemTpl`. + * Default value: == `outputterParams->templates->item`. -* `outputterParams->itemTplLast` - * Desctription: Template for the last item. Has the same placeholders as `outputterParams->itemTpl`. +* `outputterParams->templates->itemLast` + * Desctription: Template for the last item. Has the same placeholders as `outputterParams->templates->item`. * Valid values: * `stringChunkName` * `string` — use inline templates starting with `@CODE:` - * Default value: == `outputterParams->itemTpl`. + * Default value: == `outputterParams->templates->item`. -* `outputterParams->wrapperTpl` +* `outputterParams->templates->wrapper` * Desctription: Wrapper template. Available placeholders: * `[+`any document field or tv name`+]` — Any document field name or TV. @@ -202,9 +207,17 @@ Get resources from custom DB table. * `string` — use inline templates starting with `@CODE:` * Default value: — +* `outputterParams->templates->noResults` + * Desctription: A chunk or text to output when no items found. + Has the same placeholders as `outputterParams->templates->wrapper`. + * Valid values: + * `stringChunkName` + * `string` — use inline templates starting with `@CODE:` + * Default value: — + * `outputterParams->placeholders` * Desctription: - Additional data has to be passed into `itemTpl`, `itemTplFirst`, `itemTplLast` and `wrapperTpl`. + Additional data has to be passed into `templates->item`, `templates->itemFirst`, `templates->itemLast` and `templates->wrapper`. Arrays are supported too: `some[a]=one&some[b]=two` => `[+some.a+]`, `[+some.b+]`; `some[]=one&some[]=two` => `[+some.0+]`, `[some.1]`. * Valid values: `object` * Default value: — @@ -218,13 +231,6 @@ Get resources from custom DB table. * Desctription: The string that combines items while rendering. * Valid values: `string` * Default value: `''` - -* `outputterParams->noResults` - * Desctription: A chunk or text to output when no items found. Has the same placeholders as `outputterParams->wrapperTpl`. - * Valid values: - * `stringChunkName` - * `string` — use inline templates starting with `@CODE:` - * Default value: — ##### Outputter → Json (``&outputter=`json` ``) @@ -243,11 +249,6 @@ Get resources from custom DB table. * `stringTvName` * **Required** -* `outputterParams->templates` - * Desctription: Templates. - * Valid values: `object` - * Default value: — - * `outputterParams->templates->{$docFieldName}` * Desctription: You can use templates for some document fields. @@ -277,7 +278,7 @@ Output in [Sitemap XML format](https://en.wikipedia.org/wiki/Sitemaps). * Valid values: `stringTvName` * Default value: `'general_seo_sitemap_changefreq'` -* `outputterParams->itemTpl` +* `outputterParams->templates->item` * Desctription: Item template. Available placeholders: * `[+`any document field or tv name`+]` — Any document field name or TV. @@ -297,7 +298,7 @@ Output in [Sitemap XML format](https://en.wikipedia.org/wiki/Sitemaps). ``` -* `outputterParams->wrapperTpl` +* `outputterParams->templates->wrapper` * Desctription: Wrapper template. Available placeholders: * `[+`any document field or tv name`+]` — Any document field name or TV. @@ -505,11 +506,6 @@ Output in [YML format](https://yandex.ru/support/partnermarket/export/yml.html). * `stringTvName` * Default value: — -* `outputterParams->templates` - * Desctription: Templates. - * Valid values: `object` - * Default value: — - * `outputterParams->templates->wrapper` * Desctription: Wrapper template. Available placeholders: @@ -793,7 +789,9 @@ Output in [YML format](https://yandex.ru/support/partnermarket/export/yml.html). "depth": 1 }` &outputterParams=`{ - "itemTpl": "@CODE:

[+pagetitle+]

[+introtext+]

[+someTV+]
" + "templates": { + "item": "@CODE:

[+pagetitle+]

[+introtext+]

[+someTV+]
" + } }` ]] ``` @@ -814,7 +812,9 @@ _Don't forget about `fieldDelimiter`._ "filter": "#published# = 1" }` &outputterParams=`{ - "itemTpl": "documents_item" + "templates": { + "item": "documents_item" + } }` ]] ``` @@ -830,7 +830,9 @@ So we can filter as much as we like (we can use `AND` and `OR`, doucument fields "filter": "#published# = 1 AND #hidemenu# = 0 OR #SomeTVName# = 1" }` &outputterParams=`{ - "itemTpl": "documents_item" + "templates: { + "item": "documents_item" + } }` ]] ``` @@ -928,9 +930,11 @@ Returns: "orderBy": "#pub_date# DESC`" }` &outputterParams=`{ - "itemTpl": "documents_item", - "wrapperTpl": "@CODE:[+ddGetDocuments_items+][+extenders.pagination+]", - "noResult": "@CODE:" + "templates": { + "item": "documents_item", + "wrapper": "@CODE:[+ddGetDocuments_items+][+extenders.pagination+]", + "noResults": "@CODE:" + } }` &extenders=`pagination` &extendersParams=`{ @@ -951,10 +955,10 @@ Returns: * ``&providerParams=`{"filter": "#published# = 1"}` `` — only published. * ``&providerParams=`{"total": 3}` `` — items per page. * ``&providerParams=`{"orderBy": "#pub_date# DESC"} `` — sort by publish date, new first. -* ``&outputterParams=`{"itemTpl": "documents_item"}` `` — item template (chunk name). -* ``&outputterParams=`{"noResult": "@CODE:"}` `` — return nothing if nothing found. +* ``&outputterParams=`{"templates": {"item": "documents_item"}}` `` — item template (chunk name). +* ``&outputterParams=`{"templates": {"wrapper": "@CODE:[+ddGetDocuments_items+][+extenders.pagination+]"}}` `` — we need set where pagination will being outputted. +* ``&outputterParams=`{"templates": {"noResults": "@CODE:"}}` `` — return nothing if nothing found. * ``&extendersParams=`{"pagination": {}}` `` — pagination templates (see the parameters description). -* ``&wrapperTpl=`@CODE:[+ddGetDocuments_items+][+extenders.pagination+]` `` — we need set where pagination will being outputted. #### Extenders → Search (``&extenders=`search` ``) @@ -976,7 +980,9 @@ Set up filter to get only necessary documets. "docFieldsToSearch": "pagetitle,content,someTv" }` &outputterParams=`{ - "itemTpl": "documents_item" + "templates": { + "item": "documents_item" + } } ]] ``` diff --git a/src/Input.php b/src/Input.php index cb3dbb1..b114b1d 100644 --- a/src/Input.php +++ b/src/Input.php @@ -213,7 +213,7 @@ private function backwardCompatibility_dataProviderParams($snippetParams){ /** * backwardCompatibility_outputterParams - * @version 1.0.1 (2021-07-18) + * @version 1.1 (2021-07-18) * * @desc Prepare data provider params preserve backward compatibility. * @@ -221,12 +221,69 @@ private function backwardCompatibility_dataProviderParams($snippetParams){ */ private function backwardCompatibility_outputterParams(){ switch ($this->outputter){ + case 'string': + $this->backwardCompatibility_outputterParams_moveTemplates([ + 'item' => 'itemTpl', + 'itemFirst' => 'itemTplFirst', + 'itemLast' => 'itemTplLast', + 'wrapper' => 'wrapperTpl', + 'noResults' => 'noResults' + ]); + break; + + case 'sitemap': + $this->backwardCompatibility_outputterParams_moveTemplates([ + 'item' => 'itemTpl', + 'wrapper' => 'wrapperTpl' + ]); + break; + case 'yandexmarket': $this->backwardCompatibility_outputterParams_yandexmarket(); break; } } + /** + * backwardCompatibility_outputterParams_moveTemplates + * @version 1.0 (2021-07-18) + * + * @desc Moves required templates from $this->outputterParams to $this->outputterParams->templates. + * + * @param $complianceArray {arrayAssociative} — Compliance between new and old names. @required + * @param $complianceArray[$newName] {string} — Key is a new name, value is an old name. @required + * + * @return {void} + */ + private function backwardCompatibility_outputterParams_moveTemplates($complianceArray){ + if ( + //If required templates is not set, then we need to provide backward compatibility + !\DDTools\ObjectTools::isPropExists([ + 'object' => $this->outputterParams, + 'propName' => 'templates' + ]) + ){ + $this->outputterParams->templates = (object) []; + + foreach( + $complianceArray as + $newName => + $oldName + ){ + if ( + \DDTools\ObjectTools::isPropExists([ + 'object' => $this->outputterParams, + 'propName' => $oldName + ]) + ){ + $this->outputterParams->templates->{$newName} = $this->outputterParams->{$oldName}; + + unset($this->outputterParams->{$oldName}); + } + } + } + } + /** * backwardCompatibility_outputterParams_yandexmarket * @version 1.0 (2021-07-18) diff --git a/src/Outputter/Outputter.php b/src/Outputter/Outputter.php index 0184044..2b62447 100644 --- a/src/Outputter/Outputter.php +++ b/src/Outputter/Outputter.php @@ -49,7 +49,7 @@ public final static function includeOutputterByName($parserName){ /** * __construct - * @version 1.5 (2021-07-13) + * @version 1.5.1 (2021-07-13) * * @param $params {stdClass|arrayAssociative} * @param $params->dataProvider {\ddGetDocuments\DataProvider\DataProvider} @@ -57,8 +57,38 @@ public final static function includeOutputterByName($parserName){ function __construct($params = []){ $params = (object) $params; + //Prepare templates + $this->construct_prepareFields_templates($params); + //Remove from params to prevent overwriting through `$this->setExistingProps` + unset($params->templates); - //# Prepare templates + //Все параметры задают свойства объекта + $this->setExistingProps($params); + + //Comma separated strings + if (!is_array($this->docFields)){ + $this->docFields = explode( + ',', + $this->docFields + ); + } + + if (empty($this->docFields)){ + //We need something + $this->docFields = ['id']; + }elseif (isset($params->dataProvider)){ + //Ask dataProvider to get them + $params->dataProvider->addResourcesFieldsToGet($this->docFields); + } + } + + /** + * construct_prepareFields_templates + * @version 1.0 (2021-07-13) + * + * @param $params {stdClass|arrayAssociative} — See __construct. + */ + protected function construct_prepareFields_templates($params){ $this->templates = (object) $this->templates; //If parameter is passed @@ -68,16 +98,13 @@ function __construct($params = []){ 'propName' => 'templates' ]) ){ - //Estend defaults + //Extend defaults $this->templates = \DDTools\ObjectTools::extend([ 'objects' => [ $this->templates, $params->templates ] ]); - - //Remove from params to prevent overwriting through `$this->setExistingProps` - unset($params->templates); } foreach ( @@ -90,26 +117,6 @@ function __construct($params = []){ $this->templates->{$templateName} = \ddTools::$modx->getTpl($templateValue); } } - - - //Все параметры задают свойства объекта - $this->setExistingProps($params); - - //Comma separated strings - if (!is_array($this->docFields)){ - $this->docFields = explode( - ',', - $this->docFields - ); - } - - if (empty($this->docFields)){ - //We need something - $this->docFields = ['id']; - }elseif (isset($params->dataProvider)){ - //Ask dataProvider to get them - $params->dataProvider->addResourcesFieldsToGet($this->docFields); - } } /** diff --git a/src/Outputter/Sitemap/Outputter.php b/src/Outputter/Sitemap/Outputter.php index 9387ba2..67485c6 100644 --- a/src/Outputter/Sitemap/Outputter.php +++ b/src/Outputter/Sitemap/Outputter.php @@ -8,8 +8,10 @@ class Outputter extends \ddGetDocuments\Outputter\Outputter { protected $priorityTVName = 'general_seo_sitemap_priority', $changefreqTVName = 'general_seo_sitemap_changefreq', - $itemTpl = '[(site_url)][~[+id+]~][+editedon+][+[+priorityTVName+]+][+[+changefreqTVName+]+]', - $wrapperTpl = '[+ddGetDocuments_items+]' + $templates = [ + 'item' => '[(site_url)][~[+id+]~][+editedon+][+[+priorityTVName+]+][+[+changefreqTVName+]+]', + 'wrapper' => '[+ddGetDocuments_items+]' + ] ; private @@ -18,21 +20,22 @@ class Outputter extends \ddGetDocuments\Outputter\Outputter { /** * __construct - * @version 1.1 (2020-03-10) + * @version 2.0 (2021-07-13) * - * @param $params {arrayAssociative} + * @param $params {stdClass|arrayAssociative} * @param $params->priorityTVName {stringTvName} — Name of TV which sets the relative priority of the document. Default: 'general_seo_sitemap_priority'. * @param $params->changefreqTVName {stringTvName} — Name of TV which sets the change frequency. Default: 'general_seo_sitemap_changefreq'. - * @param $params->itemTpl {stringChunkName} — Available placeholders: [+any field or tv name+], [+any of extender placeholders+]. Default: ''. - * @param $params->wrapperTpl {stringChunkName} — Available placeholders: [+ddGetDocuments_items+], [+any of extender placeholders+]. Default: '[+ddGetDocuments_items+]'. + * @param $params->templates {stdClass|arrayAssociative} — Templates. Default: —. + * @param $params->templates->item {string|stringChunkName} — Available placeholders: [+any field or tv name+], [+any of extender placeholders+]. Default: ''. + * @param $params->templates->wrapper {string|stringChunkName} — Available placeholders: [+ddGetDocuments_items+], [+any of extender placeholders+]. Default: '[+ddGetDocuments_items+]'. */ function __construct($params = []){ //Call base constructor parent::__construct($params); //Prepare item template - $this->itemTpl = \ddTools::parseText([ - 'text' => $this->itemTpl, + $this->templates->item = \ddTools::parseText([ + 'text' => $this->templates->item, 'data' => [ 'priorityTVName' => $this->priorityTVName, 'changefreqTVName' => $this->changefreqTVName @@ -43,8 +46,7 @@ function __construct($params = []){ //We use the “String” Outputter as base $outputter_StringClass = \ddGetDocuments\Outputter\Outputter::includeOutputterByName('String'); $outputter_StringParams = (object) [ - 'itemTpl' => $this->itemTpl, - 'wrapperTpl' => $this->wrapperTpl + 'templates' => $this->templates ]; //Transfer provider link if (isset($params->dataProvider)){ diff --git a/src/Outputter/String/Outputter.php b/src/Outputter/String/Outputter.php index a0e7b18..1e319d9 100644 --- a/src/Outputter/String/Outputter.php +++ b/src/Outputter/String/Outputter.php @@ -10,65 +10,61 @@ class Outputter extends \ddGetDocuments\Outputter\Outputter { ; protected - $itemTpl = null, - $itemTplFirst = null, - $itemTplLast = null, - $wrapperTpl = null, - $noResults = null, + $templates = [ + 'item' => null, + 'itemFirst' => null, + 'itemLast' => null, + 'wrapper' => null, + 'noResults' => null + ], $itemGlue = '' ; /** - * __construct - * @version 1.2 (2020-03-10) + * construct_prepareFields_templates + * @version 1.0 (2021-07-13) * * @param $params {stdClass|arrayAssociative} — @required - * @param $params->itemTpl {stringChunkName} — Available placeholders: [+any field or tv name+], [+any of extender placeholders+]. @required - * @param $params->itemTplFirst {stringChunkName} — Available placeholders: [+any field or tv name+], [+any of extender placeholders+]. Default: $params->itemTpl; - * @param $params->itemTplLast {stringChunkName} — Available placeholders: [+any field or tv name+], [+any of extender placeholders+]. Default: $params->itemTpl; - * @param $params->wrapperTpl {stringChunkName} — Available placeholders: [+ddGetDocuments_items+], [+any of extender placeholders+]. - * @param $params->noResults {stringChunkName} — A chunk or text to output when no items found. Available placeholders: [+any of extender placeholders+]. - * @param $params->placeholders {arrayAssociative}. Additional data has to be passed into “itemTpl”, “itemTplFirst”, “itemTplLast” and “wrapperTpl”. Default: []. + * @param $params->templates {stdClass|arrayAssociative} — Templates. @required + * @param $params->templates->item {string|stringChunkName} — Available placeholders: [+any field or tv name+], [+any of extender placeholders+]. @required + * @param $params->templates->itemFirst {string|stringChunkName} — Available placeholders: [+any field or tv name+], [+any of extender placeholders+]. Default: $params->templates->item; + * @param $params->templates->itemLast {string|stringChunkName} — Available placeholders: [+any field or tv name+], [+any of extender placeholders+]. Default: $params->templates->item; + * @param $params->templates->wrapper {string|stringChunkName} — Available placeholders: [+ddGetDocuments_items+], [+any of extender placeholders+]. + * @param $params->templates->noResults {string|stringChunkName} — A chunk or text to output when no items found. Available placeholders: [+any of extender placeholders+]. + * @param $params->placeholders {arrayAssociative}. Additional data has to be passed into “templates->item”, “templates->itemFirst”, “templates->itemLast” and “templates->wrapper”. Default: []. * @param $params->placeholders[name] {string} — Key for placeholder name and value for placeholder value. @required * @param $params->itemGlue {string} — The string that combines items while rendering. Default: ''. */ - public function __construct($params){ - $params = (object) $params; + protected function construct_prepareFields_templates($params){ + //Call base method + parent::construct_prepareFields_templates($params); //Prepare item templates - if (isset($params->itemTpl)){ - //All items - $params->itemTpl = \ddTools::$modx->getTpl($params->itemTpl); - - $textToGetPlaceholdersFrom = $params->itemTpl; + if (is_string($this->templates->item)){ + $textToGetPlaceholdersFrom = $this->templates->item; //First item - if (isset($params->itemTplFirst)){ - $params->itemTplFirst = \ddTools::$modx->getTpl($params->itemTplFirst); - $textToGetPlaceholdersFrom .= $params->itemTplFirst; + if (is_string($this->templates->itemFirst)){ + $textToGetPlaceholdersFrom .= $this->templates->itemFirst; }else{ - $params->itemTplFirst = $params->itemTpl; + $this->templates->itemFirst = $this->templates->item; } //Last item - if (isset($params->itemTplLast)){ - $params->itemTplLast = \ddTools::$modx->getTpl($params->itemTplLast); - $textToGetPlaceholdersFrom .= $params->itemTplFirst; + if (is_string($this->templates->itemLast)){ + $textToGetPlaceholdersFrom .= $this->templates->itemLast; }else{ - $params->itemTplLast = $params->itemTpl; + $this->templates->itemLast = $this->templates->item; } - $params->docFields = \ddTools::getPlaceholdersFromText([ + $this->docFields = \ddTools::getPlaceholdersFromText([ 'text' => $textToGetPlaceholdersFrom ]); } - - //Call base constructor - parent::__construct($params); } /** * parse - * @version 2.1.3 (2021-02-28) + * @version 2.1.4 (2021-07-13) * * @param $data {Output} * @@ -108,7 +104,7 @@ public function parse(Output $data){ if( is_array($data->provider->items) && //Item template is set - $this->itemTpl !== null + $this->templates->item !== null ){ $maxIndex = $total - 1; //Foreach items @@ -118,11 +114,11 @@ public function parse(Output $data){ ){ //Prepare item output template if($index == 0){ - $chunkName = $this->itemTplFirst; + $chunkName = $this->templates->itemFirst; }elseif($index == $maxIndex){ - $chunkName = $this->itemTplLast; + $chunkName = $this->templates->itemLast; }else{ - $chunkName = $this->itemTpl; + $chunkName = $this->templates->item; } $resultItems[] = \ddTools::parseSource(\ddTools::parseText([ @@ -149,22 +145,16 @@ public function parse(Output $data){ //If no items found and “noResults” is not empty if( $total == 0 && - $this->noResults !== null && - $this->noResults != '' + $this->templates->noResults !== null && + $this->templates->noResults != '' ){ - $chunkContent = \ddTools::$modx->getChunk($this->noResults); - - if(!is_null($chunkContent)){ - $result = \ddTools::parseSource(\ddTools::parseText([ - 'text' => \ddTools::$modx->getTpl($this->noResults), - 'data' => $generalPlaceholders - ])); - }else{ - $result = $this->noResults; - } - }elseif($this->wrapperTpl !== null){ + $result = \ddTools::parseSource(\ddTools::parseText([ + 'text' => $this->templates->noResults, + 'data' => $generalPlaceholders + ])); + }elseif($this->templates->wrapper !== null){ $result = \ddTools::parseText([ - 'text' => \ddTools::$modx->getTpl($this->wrapperTpl), + 'text' => $this->templates->wrapper, 'data' => \DDTools\ObjectTools::extend([ 'objects' => [ $generalPlaceholders, diff --git a/src/Outputter/Yandexmarket/Outputter.php b/src/Outputter/Yandexmarket/Outputter.php index 2de88c3..1a29e8c 100644 --- a/src/Outputter/Yandexmarket/Outputter.php +++ b/src/Outputter/Yandexmarket/Outputter.php @@ -177,7 +177,7 @@ class Outputter extends \ddGetDocuments\Outputter\Outputter { /** * __construct - * @version 2.1.1 (2021-07-09) + * @version 2.1.2 (2021-07-12) * * @note @link https://yandex.ru/support/partnermarket/export/yml.html * @@ -291,8 +291,10 @@ function __construct($params = []){ //We use the “String” Outputter as base $outputter_StringClass = \ddGetDocuments\Outputter\Outputter::includeOutputterByName('String'); $outputter_StringParams = (object) [ - 'itemTpl' => $this->templates->offers_item, - 'wrapperTpl' => $this->templates->wrapper + 'templates' => (object) [ + 'item' => $this->templates->offers_item, + 'wrapper' => $this->templates->wrapper + ] ]; //Transfer provider link if (isset($params->dataProvider)){ From 0ea75b37cf2c238b7fe491d69a261c21e83a2ea2 Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Tue, 27 Jul 2021 19:42:01 +0300 Subject: [PATCH 08/14] =?UTF-8?q?+=20Parameters=20=E2=86=92=20`providerPar?= =?UTF-8?q?ams`,=20`outputterParams`,=20`extendersParams`:=20Can=20also=20?= =?UTF-8?q?be=20set=20as=20[HJSON](https://hjson.github.io/)=20or=20as=20a?= =?UTF-8?q?=20native=20PHP=20object=20or=20array=20(e.=20g.=20for=20calls?= =?UTF-8?q?=20through=20`$modx->runSnippet`).=20*=20Attention!=20PHP=20>?= =?UTF-8?q?=3D=205.6=20is=20required.=20*=20Attention!=20(MODX)EvolutionCM?= =?UTF-8?q?S.libraries.ddTools=20>=3D=200.50=20is=20required.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 24 ++++++++++++++++++------ composer.json | 4 ++-- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index ea1f1da..d63b88a 100644 --- a/README.md +++ b/README.md @@ -5,10 +5,10 @@ A snippet for fetching and parsing resources from the document tree or custom DB ## Requires -* PHP >= 5.4 +* PHP >= 5.6 * MySQL >= 8 or MariaDB >= 10.3.10 (not tested in older versions). * [(MODX)EvolutionCMS](https://github.com/evolution-cms/evolution) >= 1.1 -* [(MODX)EvolutionCMS.libraries.ddTools](https://code.divandesign.biz/modx/ddtools) >= 0.42 +* [(MODX)EvolutionCMS.libraries.ddTools](https://code.divandesign.biz/modx/ddtools) >= 0.50 ## Documentation @@ -56,8 +56,12 @@ A snippet for fetching and parsing resources from the document tree or custom DB * `providerParams` * Desctription: Parameters to be passed to the provider. * Valid values: - * `stirngJsonObject` — as [JSON](https://en.wikipedia.org/wiki/JSON) + * `stringJsonObject` — as [JSON](https://en.wikipedia.org/wiki/JSON) + * `stringHjsonObject` — as [HJSON](https://hjson.github.io/) * `stringQueryFormated` — as [Query string](https://en.wikipedia.org/wiki/Query_string) + * It can also be set as a native PHP object or array (e. g. for calls through `$modx->runSnippet`): + * `arrayAssociative` + * `object` * Default value: — * `providerParams->filter` @@ -156,8 +160,12 @@ Get resources from custom DB table. * `outputterParams` * Desctription: Parameters to be passed to the specified outputter. * Valid values: - * `stirngJsonObject` - * `stringQueryFormated` + * `stringJsonObject` — as [JSON](https://en.wikipedia.org/wiki/JSON) + * `stringHjsonObject` — as [HJSON](https://hjson.github.io/) + * `stringQueryFormated` — as [Query string](https://en.wikipedia.org/wiki/Query_string) + * It can also be set as a native PHP object or array (e. g. for calls through `$modx->runSnippet`): + * `arrayAssociative` + * `object` * Default value: — * `outputterParams->templates` @@ -620,8 +628,12 @@ Output in [YML format](https://yandex.ru/support/partnermarket/export/yml.html). * Desctription: Parameters to be passed to their corresponding extensions. You can avoid extender name if you are using only one extender (see examples below). * Valid values: - * `stirngJsonObject` — as [JSON](https://en.wikipedia.org/wiki/JSON) + * `stringJsonObject` — as [JSON](https://en.wikipedia.org/wiki/JSON) + * `stringHjsonObject` — as [HJSON](https://hjson.github.io/) * `stringQueryFormated` — as [Query string](https://en.wikipedia.org/wiki/Query_string) + * It can also be set as a native PHP object or array (e. g. for calls through `$modx->runSnippet`): + * `arrayAssociative` + * `object` * Default value: — * `extendersParams->{$extenderName}` diff --git a/composer.json b/composer.json index c5751fa..3bd73d8 100644 --- a/composer.json +++ b/composer.json @@ -34,8 +34,8 @@ ], "license": "MIT", "require": { - "php": ">=5.4.0", - "dd/evolutioncms-libraries-ddtools": ">=0.42.0", + "php": ">=5.6.0", + "dd/evolutioncms-libraries-ddtools": ">=0.50.0", "composer/installers": "~1.0.0" }, "autoload": { From 3d889253d3196485181ed7322dc976c81eab5171 Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Tue, 27 Jul 2021 19:51:33 +0300 Subject: [PATCH 09/14] =?UTF-8?q?+=20You=20can=20just=20call=20`\DDTools\S?= =?UTF-8?q?nippet::runSnippet`=20to=20run=20the=20snippet=20without=20DB?= =?UTF-8?q?=20and=20eval=20(see=20README=20=E2=86=92=20Examples).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 23 +++++++++++++++++++++++ require.php | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d63b88a..d59004b 100644 --- a/README.md +++ b/README.md @@ -1004,6 +1004,29 @@ Then just add to the page URL `?query=Some query text` and the snippet returns o We recommend to use cashed snippet calls and turn on document caching type with $_GET parameters in CMS configuration. +#### Run the snippet through `\DDTools\Snippet::runSnippet` without DB and eval + +```php +//Include (MODX)EvolutionCMS.libraries.ddTools +require_once( + $modx->getConfig('base_path') . + 'assets/libs/ddTools/modx.ddtools.class.php' +); + +//Run (MODX)EvolutionCMS.snippets.ddGetDocuments +\DDTools\Snippet::runSnippet([ + 'name' => 'ddGetDocuments', + 'params' => [ + //It is convenient to set the parameter as a native PHP array or object + 'providerParams' => [ + 'parentIds' => 1 + ], + 'outputter' => 'json' + ] +]); +``` + + ## Links * [Home page](https://code.divandesign.biz/modx/ddgetdocuments) diff --git a/require.php b/require.php index d67aacf..9a95b0b 100644 --- a/require.php +++ b/require.php @@ -5,7 +5,7 @@ dirname( __DIR__, 2 - ). + ) . '/libs/ddTools/modx.ddtools.class.php' ); From fd2df18b85ed0b95f10c85303b0a22cc712f02f9 Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Tue, 27 Jul 2021 19:52:53 +0300 Subject: [PATCH 10/14] =?UTF-8?q?+=20Composer.json=20=E2=86=92=C2=A0`suppo?= =?UTF-8?q?rt`.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/composer.json b/composer.json index 3bd73d8..a0eb9f2 100644 --- a/composer.json +++ b/composer.json @@ -18,6 +18,9 @@ "ddgetdocuments" ], "homepage": "https://code.divandesign.biz/modx/ddgetdocuments", + "support": { + "chat": "https://t.me/dd_code" + }, "authors": [ { "name": "DD Group", From c3c814ab4da810469b143f4323f1c0661471ebaa Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Tue, 27 Jul 2021 19:55:46 +0300 Subject: [PATCH 11/14] =?UTF-8?q?+=20Composer.json=20=E2=86=92=20`authors`?= =?UTF-8?q?:=20Added=20missed=20authors.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/composer.json b/composer.json index a0eb9f2..a959aba 100644 --- a/composer.json +++ b/composer.json @@ -33,6 +33,27 @@ "email": "ilyas@DivanDesign.ru", "homepage": "https://ronef.ru", "role": "Developer" + }, + { + "name": "Alexey Davydov", + "email": "davalemic@DivanDesign.ru", + "homepage": "https://github.com/davalemic", + "role": "Developer" + }, + { + "name": "Vladislav Lavrov", + "homepage": "https://github.com/Tornek", + "role": "Developer" + }, + { + "name": "Andrey Demchenko", + "homepage": "https://github.com/deversjkee", + "role": "Developer" + }, + { + "name": "Pavel Unzhakov", + "homepage": "https://github.com/psthmn", + "role": "Developer" } ], "license": "MIT", From 6d6be2c016627d1eb3393694bfc445699f9b90df Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Tue, 27 Jul 2021 20:00:04 +0300 Subject: [PATCH 12/14] =?UTF-8?q?+=20README=20=E2=86=92=20Documentation=20?= =?UTF-8?q?=E2=86=92=20Installation=20=E2=86=92=20Using=20(MODX)EvolutionC?= =?UTF-8?q?MS.libraries.ddInstaller.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d59004b..c2870ca 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,10 @@ A snippet for fetching and parsing resources from the document tree or custom DB ### Installation -#### 1. Elements → Snippets: Create a new snippet with the following data +#### Manually + + +##### 1. Elements → Snippets: Create a new snippet with the following data 1. Snippet name: `ddGetDocuments`. 2. Description: `1.3.1 A snippet for fetching and parsing resources from the document tree or custom DB table by a custom rule.`. @@ -26,12 +29,34 @@ A snippet for fetching and parsing resources from the document tree or custom DB 5. Snippet code (php): Insert content of the `ddGetDocuments_snippet.php` file from the archive. -#### 2. Elements → Manage Files: +##### 2. Elements → Manage Files: 1. Create a new folder `assets/snippets/ddGetDocuments/`. 2. Extract the archive to the folder (except `ddGetDocuments_snippet.php`). +#### Using [(MODX)EvolutionCMS.libraries.ddInstaller](https://github.com/DivanDesign/EvolutionCMS.libraries.ddInstaller) + +Just run the following PHP code in your sources or [Console](https://github.com/vanchelo/MODX-Evolution-Ajax-Console): + +```php +//Include (MODX)EvolutionCMS.libraries.ddInstaller +require_once( + $modx->getConfig('base_path') . + 'assets/libs/ddInstaller/require.php' +); + +//Install (MODX)EvolutionCMS.snippets.ddGetDocuments +\DDInstaller::install([ + 'url' => 'https://github.com/DivanDesign/EvolutionCMS.snippets.ddGetDocuments', + 'type' => 'snippet' +]); +``` + +* If `ddGetDocuments` is not exist on your site, `ddInstaller` will just install it. +* If `ddGetDocuments` is already exist on your site, `ddInstaller` will check it version and update it if needed. + + ### Parameters description From 2202605742ec8341c08fc6631e8a7bed88cb2094 Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Tue, 27 Jul 2021 22:34:04 +0300 Subject: [PATCH 13/14] + CHANGELOG_ru. --- CHANGELOG_ru.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 CHANGELOG_ru.md diff --git a/CHANGELOG_ru.md b/CHANGELOG_ru.md new file mode 100644 index 0000000..a260b26 --- /dev/null +++ b/CHANGELOG_ru.md @@ -0,0 +1,13 @@ +# (MODX)EvolutionCMS.snippets.ddGetDocuments changelog + + +## Версия 1.3.1 (2021-02-28) +* \* Outputters → String → Параметры → `outputterParams->placeholders`: Исправлена критическая ошибка, когда параметр используется. + + +## Версия 0.1 (2015-09-23) +* \+ Первый релиз. + + + + \ No newline at end of file From e4357be2bec81c677c7f80bb0cfa1f04a403ee39 Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Tue, 27 Jul 2021 22:46:18 +0300 Subject: [PATCH 14/14] Prerelease --- CHANGELOG.md | 21 +++++++++++++++++++++ CHANGELOG_ru.md | 21 +++++++++++++++++++++ README.md | 2 +- composer.json | 2 +- ddGetDocuments_snippet.php | 2 +- src/Snippet.php | 2 +- 6 files changed, 46 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 277de3e..645eea1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,27 @@ # (MODX)EvolutionCMS.snippets.ddGetDocuments changelog +## Version 1.4 (2021-07-27) +* \* Attention! PHP >= 5.6 is required. +* \* Attention! (MODX)EvolutionCMS.libraries.ddTools >= 0.50 is required. +* \+ Parameters → `providerParams`, `outputterParams`, `extendersParams`: Can also be set as [HJSON](https://hjson.github.io/) or as a native PHP object or array (e. g. for calls through `$modx->runSnippet`). +* \+ You can just call `\DDTools\Snippet::runSnippet` to run the snippet without DB and eval (see README → Examples). +* \+ Outputters → Json → Parameters → `outputterParams->templates`: The new parameters. You can use templates for some document fields. +* \* Outputters → String → Parameters → `outputterParams->templates`: The following parameters moved here (with backward compatibility): + * \* `outputterParams->itemTpl` → `outputterParams->templates->item`. + * \* `outputterParams->itemTplFirst` → `outputterParams->templates->itemFirst`. + * \* `outputterParams->itemTplLast` → `outputterParams->templates->itemLast`. + * \* `outputterParams->wrapperTpl` → `outputterParams->templates->wrapper`. + * \* `outputterParams->noResults` → `outputterParams->templates->noResults`. +* \* Outputters → Sitemap → Parameters → `outputterParams->templates`: The following parameters moved here (with backward compatibility): + * \* `outputterParams->itemTpl` → `outputterParams->templates->item`. + * \* `outputterParams->wrapperTpl` → `outputterParams->templates->wrapper`. +* \+ README → Documentation → Installation → Using (MODX)EvolutionCMS.libraries.ddInstaller. +* \+ Composer.json. + * \+ `support`. + * \+ `authors`: Added missed authors. + + ## Version 1.3.1 (2021-02-28) * \* Outputters → String → Parameters → `outputterParams->placeholders`: Fixed critical error when the parameter is used. diff --git a/CHANGELOG_ru.md b/CHANGELOG_ru.md index a260b26..d9c52de 100644 --- a/CHANGELOG_ru.md +++ b/CHANGELOG_ru.md @@ -1,6 +1,27 @@ # (MODX)EvolutionCMS.snippets.ddGetDocuments changelog +## Версия 1.4 (2021-07-27) +* \* Внимание! Требуется PHP >= 5.6. +* \* Внимание! Требуется (MODX)EvolutionCMS.libraries.ddTools >= 0.50. +* \+ Параметры → `providerParams`, `outputterParams`, `extendersParams`: Также могут быть заданы, как [HJSON](https://hjson.github.io/) или как нативный PHP объект или массив (например, для вызовов через `$modx->runSnippet`). +* \+ Запустить сниппет без DB и eval можно через `\DDTools\Snippet::runSnippet` (см. примеры в README). +* \+ Outputters → Json → Параметры → `outputterParams->templates`: Новые параметры. Вы можете использовать шаблоны для нужных полей документов. +* \* Outputters → String → Параметры → `outputterParams->templates`: Следующие параметры перемещены сюда (с обратной совместимостью): + * \* `outputterParams->itemTpl` → `outputterParams->templates->item`. + * \* `outputterParams->itemTplFirst` → `outputterParams->templates->itemFirst`. + * \* `outputterParams->itemTplLast` → `outputterParams->templates->itemLast`. + * \* `outputterParams->wrapperTpl` → `outputterParams->templates->wrapper`. + * \* `outputterParams->noResults` → `outputterParams->templates->noResults`. +* \* Outputters → Sitemap → Параметры → `outputterParams->templates`: Следующие параметры перемещены сюда (с обратной совместимостью): + * \* `outputterParams->itemTpl` → `outputterParams->templates->item`. + * \* `outputterParams->wrapperTpl` → `outputterParams->templates->wrapper`. +* \+ Документация → Установка → Используя (MODX)EvolutionCMS.libraries.ddInstaller. +* \+ Composer.json. + * \+ `support`. + * \+ `authors`: Добавлены недостающие авторы. + + ## Версия 1.3.1 (2021-02-28) * \* Outputters → String → Параметры → `outputterParams->placeholders`: Исправлена критическая ошибка, когда параметр используется. diff --git a/README.md b/README.md index c2870ca..5ad500d 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ A snippet for fetching and parsing resources from the document tree or custom DB ##### 1. Elements → Snippets: Create a new snippet with the following data 1. Snippet name: `ddGetDocuments`. -2. Description: `1.3.1 A snippet for fetching and parsing resources from the document tree or custom DB table by a custom rule.`. +2. Description: `1.4 A snippet for fetching and parsing resources from the document tree or custom DB table by a custom rule.`. 3. Category: `Core`. 4. Parse DocBlock: `no`. 5. Snippet code (php): Insert content of the `ddGetDocuments_snippet.php` file from the archive. diff --git a/composer.json b/composer.json index a959aba..ece41da 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "dd/evolutioncms-snippets-ddgetdocuments", "type": "modxevo-snippet", - "version": "1.3.1", + "version": "1.4.0", "description": "A snippet for fetching and parsing resources from the document tree or custom DB table by a custom rule.", "keywords": [ "modx", diff --git a/ddGetDocuments_snippet.php b/ddGetDocuments_snippet.php index a14699c..ec4e49a 100644 --- a/ddGetDocuments_snippet.php +++ b/ddGetDocuments_snippet.php @@ -1,7 +1,7 @@ 'outputFormat',