From 3a78007ce6fd0dd89c93aa06cd781865060db9f9 Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Wed, 28 Dec 2022 22:11:53 +0400 Subject: [PATCH 01/20] * `\ddGetDocuments\DataProvider\DataProvider::construct_compatibilityWithOldMariaDB`: `JSON_OBJECTAGG` was added in MariaDB 10.5, not in 10.4. --- src/DataProvider/DataProvider.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/DataProvider/DataProvider.php b/src/DataProvider/DataProvider.php index 80779b9..5e59577 100644 --- a/src/DataProvider/DataProvider.php +++ b/src/DataProvider/DataProvider.php @@ -27,7 +27,7 @@ abstract class DataProvider extends \DDTools\BaseClass { ; /** - * @property $getResourcesDataFromDb_tvsSQL {string} — Temporary code for compatibility with MariaDB < 10.4. This code must be removed when MariaDB 10.4 will be released. + * @property $getResourcesDataFromDb_tvsSQL {string} — Temporary code for compatibility with MariaDB < 10.5. This code must be removed when MariaDB 10.5 will be released. */ private $getResourcesDataFromDb_tvsSQL = 'JSON_OBJECTAGG( `tvName`.`name`, @@ -59,9 +59,9 @@ function __construct($params){ /** * construct_compatibilityWithOldMariaDB - * @version 1.0 (2020-10-01) + * @version 1.0.1 (2020-10-01) * - * @todo Temporary code for compatibility with MariaDB < 10.4. This code must be removed when MariaDB 10.4 will be released. + * @todo Temporary code for compatibility with MariaDB < 10.5. This code must be removed when MariaDB 10.5 will be released. * * @return {void} */ @@ -74,10 +74,10 @@ private function construct_compatibilityWithOldMariaDB(){ $dbVersion, 'mariadb' ) !== false && - //And version < 10.4 + //And version < 10.5 version_compare( $dbVersion, - '10.4', + '10.5', '<' ) ){ From 4bcaa66ea35868097d65e725c93cd29afd651c03 Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Wed, 4 Jan 2023 15:26:39 +0400 Subject: [PATCH 02/20] * Minor changes. --- src/DataProvider/DataProvider.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/DataProvider/DataProvider.php b/src/DataProvider/DataProvider.php index 5e59577..c827a72 100644 --- a/src/DataProvider/DataProvider.php +++ b/src/DataProvider/DataProvider.php @@ -553,7 +553,7 @@ protected final function prepareQueryData($params = []){ /** * prepareQuery - * @version 1.4 (2022-06-03) + * @version 1.4.1 (2023-01-04) * * @param $params {arrayAssociative|stdClass} * @param $params['resourcesIds'] — Document IDs to get ($this->filter will be used). Default: ''. @@ -592,13 +592,15 @@ protected function prepareQuery($params = []){ SELECT ' . $this->getResourcesDataFromDb_tvsSQL . ' FROM - ' . \ddTools::$tables['site_content'] . ' as `content` LEFT JOIN - ' . \ddTools::$tables['site_tmplvar_templates'] . ' as `resTvTemplates` ON - `content`.`template` = `resTvTemplates`.`templateid` LEFT JOIN - ' . \ddTools::$tables['site_tmplvars'] . ' as `tvName` ON - `resTvTemplates`.`tmplvarid` = `tvName`.`id` LEFT JOIN - ' . \ddTools::$tables['site_tmplvar_contentvalues'] . ' as `tvValue` ON - `content`.`id` = `tvValue`.`contentid` AND `tvName`.`id` = `tvValue`.`tmplvarid` + ' . \ddTools::$tables['site_content'] . ' as `content` + LEFT JOIN ' . \ddTools::$tables['site_tmplvar_templates'] . ' as `resTvTemplates` + ON `content`.`template` = `resTvTemplates`.`templateid` + LEFT JOIN ' . \ddTools::$tables['site_tmplvars'] . ' as `tvName` + ON `resTvTemplates`.`tmplvarid` = `tvName`.`id` + LEFT JOIN ' . \ddTools::$tables['site_tmplvar_contentvalues'] . ' as `tvValue` + ON + `content`.`id` = `tvValue`.`contentid` AND + `tvName`.`id` = `tvValue`.`tmplvarid` WHERE `resources`.`id` = `content`.`id` ) as `TVs` From cfaa64a79028ed983ab5c260004875dcf1d21e6f Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Tue, 2 May 2023 23:15:44 +0400 Subject: [PATCH 03/20] * README, CHANGELOG: CSS is included directly from GitHub. --- CHANGELOG.md | 2 +- CHANGELOG_ru.md | 2 +- README.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ab4bf7..ca096d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -111,5 +111,5 @@ * \+ The first release. - + \ No newline at end of file diff --git a/CHANGELOG_ru.md b/CHANGELOG_ru.md index 08481a3..d57226e 100644 --- a/CHANGELOG_ru.md +++ b/CHANGELOG_ru.md @@ -40,5 +40,5 @@ * \+ Первый релиз. - + \ No newline at end of file diff --git a/README.md b/README.md index f4776b7..ee417ed 100644 --- a/README.md +++ b/README.md @@ -1129,4 +1129,4 @@ require_once( * [Packagist](https://packagist.org/packages/dd/evolutioncms-snippets-ddgetdocuments) - \ No newline at end of file + \ No newline at end of file From b020ed40b0953ca70c85431f201126f981baf6e0 Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Tue, 2 May 2023 23:36:05 +0400 Subject: [PATCH 04/20] * Refactoring, the `\DDTools\Base\Base` class is used instead of `\DDTools\BaseClass`. * Attention! (MODX)EvolutionCMS.libraries.ddTools >= 0.56 is required. --- README.md | 2 +- composer.json | 2 +- src/DataProvider/DataProvider.php | 5 +++-- src/Extender/Extender.php | 9 +++------ src/Input.php | 2 +- src/Outputter/Outputter.php | 5 +++-- 6 files changed, 12 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index ee417ed..8cfe2d5 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ A snippet for fetching and parsing resources from the document tree or custom DB * 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.50 +* [(MODX)EvolutionCMS.libraries.ddTools](https://code.divandesign.biz/modx/ddtools) >= 0.56 ## Installation diff --git a/composer.json b/composer.json index e000a47..0b9bae0 100644 --- a/composer.json +++ b/composer.json @@ -59,7 +59,7 @@ "license": "MIT", "require": { "php": ">=5.6.0", - "dd/evolutioncms-libraries-ddtools": ">=0.50.0", + "dd/evolutioncms-libraries-ddtools": ">=0.56.0", "composer/installers": "~1.0.0" }, "autoload": { diff --git a/src/DataProvider/DataProvider.php b/src/DataProvider/DataProvider.php index c827a72..fcd0aaf 100644 --- a/src/DataProvider/DataProvider.php +++ b/src/DataProvider/DataProvider.php @@ -1,8 +1,9 @@ Date: Tue, 2 May 2023 23:42:07 +0400 Subject: [PATCH 05/20] * Refactoring, the optional parameter `$params->parentDir` of `\DDTools\Base\AncestorTrait::createChildInstance` is not used. * Attention! (MODX)EvolutionCMS.libraries.ddTools >= 0.58 is required. --- README.md | 2 +- composer.json | 2 +- src/Snippet.php | 17 +---------------- 3 files changed, 3 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 8cfe2d5..6d0cb2f 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ A snippet for fetching and parsing resources from the document tree or custom DB * 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.56 +* [(MODX)EvolutionCMS.libraries.ddTools](https://code.divandesign.biz/modx/ddtools) >= 0.58 ## Installation diff --git a/composer.json b/composer.json index 0b9bae0..5238415 100644 --- a/composer.json +++ b/composer.json @@ -59,7 +59,7 @@ "license": "MIT", "require": { "php": ">=5.6.0", - "dd/evolutioncms-libraries-ddtools": ">=0.56.0", + "dd/evolutioncms-libraries-ddtools": ">=0.58.0", "composer/installers": "~1.0.0" }, "autoload": { diff --git a/src/Snippet.php b/src/Snippet.php index 238febc..9e5284a 100644 --- a/src/Snippet.php +++ b/src/Snippet.php @@ -13,7 +13,7 @@ class Snippet extends \DDTools\Snippet { /** * run - * @version 1.0 (2021-02-18) + * @version 1.0.1 (2023-05-02) */ public function run(){ $result = ''; @@ -31,11 +31,6 @@ public function run(){ ){ $extenderObject = \ddGetDocuments\Extender\Extender::createChildInstance([ 'name' => $extenderName, - 'parentDir' => - $this->paths->src . - 'Extender' - , - //Passing parameters into constructor 'params' => $extenderParams ]); //Passing a link to the storage @@ -47,11 +42,6 @@ public function run(){ $dataProviderObject = \ddGetDocuments\DataProvider\DataProvider::createChildInstance([ 'name' => $input->provider, - 'parentDir' => - $this->paths->src . - 'DataProvider' - , - //Passing parameters into constructor 'params' => $input->providerParams ]); @@ -60,11 +50,6 @@ public function run(){ $outputterObject = \ddGetDocuments\Outputter\Outputter::createChildInstance([ 'name' => $input->outputter, - 'parentDir' => - $this->paths->src . - 'Outputter' - , - //Passing parameters into constructor 'params' => $input->outputterParams ]); } From e6c0d56f57bee023f8e6fee227d1bc926b5bb2cc Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Tue, 2 May 2023 23:48:27 +0400 Subject: [PATCH 06/20] - `\ddGetDocuments\Outputter\Outputter::includeOutputterByName`: The method has been deleted. `\DDTools\Base\AncestorTrait::createChildInstance` is used instead. --- src/Outputter/Outputter.php | 32 ++---------------------- src/Outputter/Sitemap/Outputter.php | 10 +++++--- src/Outputter/Yandexmarket/Outputter.php | 10 +++++--- 3 files changed, 14 insertions(+), 38 deletions(-) diff --git a/src/Outputter/Outputter.php b/src/Outputter/Outputter.php index 173cb25..8b8d84e 100644 --- a/src/Outputter/Outputter.php +++ b/src/Outputter/Outputter.php @@ -20,42 +20,14 @@ abstract class Outputter extends \DDTools\Base\Base { $templates = [] ; - /** - * includeOutputterByName - * @version 1.0.3 (2019-03-11) - * - * @TODO: Remove it, use `\DDTools\BaseClass::createChildInstance` instead - * - * @param $parserName {string} - * - * @throws \Exception - * - * @return {string} - */ - public final static function includeOutputterByName($parserName){ - $parserName = ucfirst(strtolower($parserName)); - $parserPath = $parserName.DIRECTORY_SEPARATOR . 'Outputter' . '.php'; - - if(is_file(__DIR__.DIRECTORY_SEPARATOR . $parserPath)){ - require_once($parserPath); - - return __NAMESPACE__ . '\\' . $parserName . '\\' . 'Outputter'; - }else{ - throw new \Exception( - 'Outputter “' . $parserName . '” not found.', - 500 - ); - } - } - /** * __construct - * @version 1.5.1 (2021-07-13) + * @version 1.5.2 (2023-05-02) * * @param $params {stdClass|arrayAssociative} * @param $params->dataProvider {\ddGetDocuments\DataProvider\DataProvider} */ - function __construct($params = []){ + public function __construct($params = []){ $params = (object) $params; //Prepare templates diff --git a/src/Outputter/Sitemap/Outputter.php b/src/Outputter/Sitemap/Outputter.php index 67485c6..f465757 100644 --- a/src/Outputter/Sitemap/Outputter.php +++ b/src/Outputter/Sitemap/Outputter.php @@ -20,7 +20,7 @@ class Outputter extends \ddGetDocuments\Outputter\Outputter { /** * __construct - * @version 2.0 (2021-07-13) + * @version 2.0.1 (2023-05-02) * * @param $params {stdClass|arrayAssociative} * @param $params->priorityTVName {stringTvName} — Name of TV which sets the relative priority of the document. Default: 'general_seo_sitemap_priority'. @@ -29,7 +29,7 @@ class Outputter extends \ddGetDocuments\Outputter\Outputter { * @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 = []){ + public function __construct($params = []){ //Call base constructor parent::__construct($params); @@ -44,7 +44,6 @@ function __construct($params = []){ ]); //We use the “String” Outputter as base - $outputter_StringClass = \ddGetDocuments\Outputter\Outputter::includeOutputterByName('String'); $outputter_StringParams = (object) [ 'templates' => $this->templates ]; @@ -52,7 +51,10 @@ function __construct($params = []){ if (isset($params->dataProvider)){ $outputter_StringParams->dataProvider = $params->dataProvider; } - $this->outputter_StringInstance = new $outputter_StringClass($outputter_StringParams); + $this->outputter_StringInstance = \ddGetDocuments\Outputter\Outputter::createChildInstance([ + 'name' => 'String', + 'params' => $outputter_StringParams + ]); } /** diff --git a/src/Outputter/Yandexmarket/Outputter.php b/src/Outputter/Yandexmarket/Outputter.php index 125b8f8..f70f34e 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.2 (2021-07-12) + * @version 2.1.3 (2023-05-02) * * @note @link https://yandex.ru/support/partnermarket/export/yml.html * @@ -213,7 +213,7 @@ class Outputter extends \ddGetDocuments\Outputter\Outputter { * @param $params->templates->{'offers_item_elem' . $FieldName} {stringChunkName|string} — Можно задать шаблон любого элемента offer, называем в соответствии с параметрами 'offerFields_', например: $params->templates_offers_item_elemCountryOfOrigin. Default: —. * @param $params->categoryIds_last {stringCommaSepareted} — id конечных категорий(parent). Если пусто то выводятся только непосредственный родитель товара. Defalut: —. */ - function __construct($params = []){ + public function __construct($params = []){ $params = (object) $params; @@ -289,7 +289,6 @@ function __construct($params = []){ //We use the “String” Outputter as base - $outputter_StringClass = \ddGetDocuments\Outputter\Outputter::includeOutputterByName('String'); $outputter_StringParams = (object) [ 'templates' => (object) [ 'item' => $this->templates->offers_item, @@ -300,7 +299,10 @@ function __construct($params = []){ if (isset($params->dataProvider)){ $outputter_StringParams->dataProvider = $params->dataProvider; } - $this->outputter_StringInstance = new $outputter_StringClass($outputter_StringParams); + $this->outputter_StringInstance = \ddGetDocuments\Outputter\Outputter::createChildInstance([ + 'name' => 'String', + 'params' => $outputter_StringParams + ]); } /** From c1add6e55aead111349ac6a71155cbbd5cf0994e Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Sun, 14 May 2023 23:00:32 +0400 Subject: [PATCH 07/20] * `\ddTools::getTpl` is used instead of `$modx->getTpl` (means a bit less bugs). * Attention! (MODX)EvolutionCMS.libraries.ddTools >= 0.60 is required. --- README.md | 2 +- composer.json | 2 +- src/Extender/Pagination/Extender.php | 4 ++-- src/Outputter/Outputter.php | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 6d0cb2f..14e4266 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ A snippet for fetching and parsing resources from the document tree or custom DB * 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.58 +* [(MODX)EvolutionCMS.libraries.ddTools](https://code.divandesign.biz/modx/ddtools) >= 0.60 ## Installation diff --git a/composer.json b/composer.json index 5238415..7e4254f 100644 --- a/composer.json +++ b/composer.json @@ -59,7 +59,7 @@ "license": "MIT", "require": { "php": ">=5.6.0", - "dd/evolutioncms-libraries-ddtools": ">=0.58.0", + "dd/evolutioncms-libraries-ddtools": ">=0.60.0", "composer/installers": "~1.0.0" }, "autoload": { diff --git a/src/Extender/Pagination/Extender.php b/src/Extender/Pagination/Extender.php index 9cb28a5..eec12ef 100644 --- a/src/Extender/Pagination/Extender.php +++ b/src/Extender/Pagination/Extender.php @@ -43,7 +43,7 @@ class Extender extends \ddGetDocuments\Extender\Extender { /** * __construct - * @version 1.2.2 (2020-10-02) + * @version 1.2.3 (2023-05-14) * * @param $params {stdClass|arrayAssociative} */ @@ -63,7 +63,7 @@ public function __construct($params = []){ ] as $tplName ){ - $this->{$tplName} = \ddTools::$modx->getTpl((string) $this->{$tplName}); + $this->{$tplName} = \ddTools::getTpl($this->{$tplName}); } $this->pageIndex = diff --git a/src/Outputter/Outputter.php b/src/Outputter/Outputter.php index 8b8d84e..ae52494 100644 --- a/src/Outputter/Outputter.php +++ b/src/Outputter/Outputter.php @@ -57,7 +57,7 @@ public function __construct($params = []){ /** * construct_prepareFields_templates - * @version 1.0 (2021-07-13) + * @version 1.0.1 (2023-05-14) * * @param $params {stdClass|arrayAssociative} — See __construct. */ @@ -87,7 +87,7 @@ protected function construct_prepareFields_templates($params){ ){ //Exclude null values if (is_string($templateValue)){ - $this->templates->{$templateName} = \ddTools::$modx->getTpl($templateValue); + $this->templates->{$templateName} = \ddTools::getTpl($templateValue); } } } From 89f3e750e7b9e66c19330d86f63d255ed23a56cb Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Tue, 5 Sep 2023 11:18:25 +0400 Subject: [PATCH 08/20] =?UTF-8?q?*=20README=20=E2=86=92=C2=A0Parameters=20?= =?UTF-8?q?description=20=E2=86=92=20`outputterParams->templates->item`,?= =?UTF-8?q?=20`outputterParams->templates->wrapper`=20=E2=86=92=20Placehol?= =?UTF-8?q?ders=20=E2=86=92=20`[+total+]`,=20`[+totalFound+]`:=20Missed=20?= =?UTF-8?q?description=20has=20been=20added.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 14e4266..d650df4 100644 --- a/README.md +++ b/README.md @@ -216,6 +216,8 @@ Get resources from custom DB table. * `[+`any placeholders from `placeholders` param`+]` — Any custom placeholders (see `outputterParams->placeholders` description below). * `[+itemNumber+]` — Item number started from 1. * `[+itemNumberZeroBased+]` Item number started from 0. + * `[+total+]` — number of returned items + * `[+totalFound+]` — number of found items * Valid values: * `stringChunkName` * `string` — use inline templates starting with `@CODE:` @@ -242,6 +244,8 @@ Get resources from custom DB table. * `[+`any of extender placeholders`+]` — Any extender placeholders (see extenders description below). * `[+`any placeholders from `placeholders` param`+]` — Any custom placeholders (see `outputterParams->placeholders` description below). * `[+ddGetDocuments_items+]` + * `[+total+]` — number of returned items + * `[+totalFound+]` — number of found items * Valid values: * `stringChunkName` * `string` — use inline templates starting with `@CODE:` From a58b69257b5495177c2d00bd39ecebbeb5a37900 Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Sat, 13 Jul 2024 14:05:42 +0400 Subject: [PATCH 09/20] * Better compatibility with (MODX)EvolutionCMS.libraries.ddTools >= 0.62. * Attention! (MODX)EvolutionCMS.libraries.ddTools >= 0.62 is required. --- README.md | 2 +- composer.json | 2 +- src/Outputter/Sitemap/Outputter.php | 4 ++-- src/Outputter/Yandexmarket/Outputter.php | 18 +++++++++--------- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index d650df4..fe1869c 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ A snippet for fetching and parsing resources from the document tree or custom DB * 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.60 +* [(MODX)EvolutionCMS.libraries.ddTools](https://code.divandesign.biz/modx/ddtools) >= 0.62 ## Installation diff --git a/composer.json b/composer.json index 7e4254f..3b41d8a 100644 --- a/composer.json +++ b/composer.json @@ -59,7 +59,7 @@ "license": "MIT", "require": { "php": ">=5.6.0", - "dd/evolutioncms-libraries-ddtools": ">=0.60.0", + "dd/evolutioncms-libraries-ddtools": ">=0.62.0", "composer/installers": "~1.0.0" }, "autoload": { diff --git a/src/Outputter/Sitemap/Outputter.php b/src/Outputter/Sitemap/Outputter.php index f465757..033f1a7 100644 --- a/src/Outputter/Sitemap/Outputter.php +++ b/src/Outputter/Sitemap/Outputter.php @@ -20,7 +20,7 @@ class Outputter extends \ddGetDocuments\Outputter\Outputter { /** * __construct - * @version 2.0.1 (2023-05-02) + * @version 2.0.2 (2024-07-13) * * @param $params {stdClass|arrayAssociative} * @param $params->priorityTVName {stringTvName} — Name of TV which sets the relative priority of the document. Default: 'general_seo_sitemap_priority'. @@ -40,7 +40,7 @@ public function __construct($params = []){ 'priorityTVName' => $this->priorityTVName, 'changefreqTVName' => $this->changefreqTVName ], - 'mergeAll' => false + 'isCompletelyParsingEnabled' => false ]); //We use the “String” Outputter as base diff --git a/src/Outputter/Yandexmarket/Outputter.php b/src/Outputter/Yandexmarket/Outputter.php index f70f34e..193b593 100644 --- a/src/Outputter/Yandexmarket/Outputter.php +++ b/src/Outputter/Yandexmarket/Outputter.php @@ -336,7 +336,7 @@ private function construct_prepareFields(){ /** * construct_prepareTemplates - * @version 1.0 (2021-02-08) + * @version 1.0.1 (2024-07-13) * * @return {void} */ @@ -353,7 +353,7 @@ private function construct_prepareTemplates(){ 'value' => $templateData['shopData']['currencyId'], 'attrs' => '' ], - 'mergeAll' => false + 'isCompletelyParsingEnabled' => false ]); foreach ( @@ -378,7 +378,7 @@ private function construct_prepareTemplates(){ $this->templates->offers_item = \ddTools::parseText([ 'text' => $this->templates->offers_item, 'data' => $templateData, - 'mergeAll' => false + 'isCompletelyParsingEnabled' => false ]); @@ -398,7 +398,7 @@ private function construct_prepareTemplates(){ 'value' => $templateData['shopData']['agency'], 'attrs' => '' ], - 'mergeAll' => false + 'isCompletelyParsingEnabled' => false ]); } @@ -406,7 +406,7 @@ private function construct_prepareTemplates(){ $this->templates->wrapper = \ddTools::parseText([ 'text' => $this->templates->wrapper, 'data' => $templateData, - 'mergeAll' => false + 'isCompletelyParsingEnabled' => false ]); } @@ -440,7 +440,7 @@ private function escapeSpecialChars($inputString){ /** * parse - * @version 1.6 (2021-02-27) + * @version 1.6.1 (2024-07-13) * * @param $data {Output} * @@ -615,7 +615,7 @@ public function parse(Output $data){ //Escaped value $this->escapeSpecialChars($docData[$offerFieldData->docFieldName]) ], - 'mergeAll' => false + 'isCompletelyParsingEnabled' => false ]); } } @@ -642,7 +642,7 @@ public function parse(Output $data){ /** * parse_categories - * @version 1.1.7 (2021-02-08) + * @version 1.1.8 (2024-07-13) * * @return {string} */ @@ -698,7 +698,7 @@ private function parse_categories(){ ' parentId="' . $categoryDocData['parent'] . '"' : '' ], - 'mergeAll' => false + 'isCompletelyParsingEnabled' => false ]); if($hasParentCategory){ From 81d47f135364c1c8e690dc638765a49296442251 Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Tue, 6 Aug 2024 11:19:08 +0400 Subject: [PATCH 10/20] * Minor changes (code style). --- README.md | 14 +- ddGetDocuments_snippet.php | 2 +- require.php | 8 +- src/DataProvider/DataProvider.php | 108 +++++++-------- src/DataProvider/Parent/DataProvider.php | 16 +-- src/DataProvider/Select/DataProvider.php | 4 +- src/Extender/Pagination/Extender.php | 42 +++--- src/Extender/Search/Extender.php | 8 +- src/Extender/Sortfromurl/Extender.php | 8 +- src/Extender/Tagging/Extender.php | 18 +-- src/Input.php | 50 +++---- src/Outputter/Json/Outputter.php | 10 +- src/Outputter/Outputter.php | 22 +-- src/Outputter/Sitemap/Outputter.php | 16 +-- src/Outputter/String/Outputter.php | 20 +-- src/Outputter/Yandexmarket/Outputter.php | 162 +++++++++++------------ src/Snippet.php | 12 +- 17 files changed, 260 insertions(+), 260 deletions(-) diff --git a/README.md b/README.md index fe1869c..da19398 100644 --- a/README.md +++ b/README.md @@ -37,13 +37,13 @@ A snippet for fetching and parsing resources from the document tree or custom DB 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 +// Include (MODX)EvolutionCMS.libraries.ddInstaller require_once( $modx->getConfig('base_path') . 'assets/libs/ddInstaller/require.php' ); -//Install (MODX)EvolutionCMS.snippets.ddGetDocuments +// Install (MODX)EvolutionCMS.snippets.ddGetDocuments \DDInstaller::install([ 'url' => 'https://github.com/DivanDesign/EvolutionCMS.snippets.ddGetDocuments', 'type' => 'snippet' @@ -997,9 +997,9 @@ And we want to make a gender list with unique items: [[ddGetDocuments? &fieldDelimiter=`#` &providerParams=`{ - //The parent of our documents + // The parent of our documents parentIds: 42 - //The field by which the items will be grouped + // The field by which the items will be grouped groupBy: "#gender#" }` &outputter=`json` @@ -1106,17 +1106,17 @@ We recommend to use cashed snippet calls and turn on document caching type with ### Run the snippet through `\DDTools\Snippet::runSnippet` without DB and eval ```php -//Include (MODX)EvolutionCMS.libraries.ddTools +// Include (MODX)EvolutionCMS.libraries.ddTools require_once( $modx->getConfig('base_path') . 'assets/libs/ddTools/modx.ddtools.class.php' ); -//Run (MODX)EvolutionCMS.snippets.ddGetDocuments +// 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 + // It is convenient to set the parameter as a native PHP array or object 'providerParams' => [ 'parentIds' => 1 ], diff --git a/ddGetDocuments_snippet.php b/ddGetDocuments_snippet.php index 87efa10..bc21262 100644 --- a/ddGetDocuments_snippet.php +++ b/ddGetDocuments_snippet.php @@ -10,7 +10,7 @@ * @copyright 2015–2022 DD Group {@link https://DivanDesign.biz } */ -//Include (MODX)EvolutionCMS.libraries.ddTools +// Include (MODX)EvolutionCMS.libraries.ddTools require_once( $modx->getConfig('base_path') . 'assets/libs/ddTools/modx.ddtools.class.php' diff --git a/require.php b/require.php index 9a95b0b..d15b7f6 100644 --- a/require.php +++ b/require.php @@ -1,12 +1,12 @@ setExistingProps($params); - //Init source DB table name + // Init source DB table name $this->resourcesTableName = isset(\ddTools::$tables[$this->resourcesTableName]) ? \ddTools::$tables[$this->resourcesTableName] : \ddTools::$modx->getFullTableName($this->resourcesTableName) ; - //Init needed resources fields + // Init needed resources fields $this->resourcesFieldsToGet = (object) $this->resourcesFieldsToGet; $this->construct_compatibilityWithOldMariaDB(); @@ -60,7 +60,7 @@ function __construct($params){ /** * construct_compatibilityWithOldMariaDB - * @version 1.0.1 (2020-10-01) + * @version 1.0.2 (2024-08-06) * * @todo Temporary code for compatibility with MariaDB < 10.5. This code must be removed when MariaDB 10.5 will be released. * @@ -70,12 +70,12 @@ private function construct_compatibilityWithOldMariaDB(){ $dbVersion = \ddTools::$modx->db->getValue(\ddTools::$modx->db->query('SELECT VERSION()')); if ( - //MariaDB is used + // MariaDB is used stripos( $dbVersion, 'mariadb' ) !== false && - //And version < 10.5 + // And version < 10.5 version_compare( $dbVersion, '10.5', @@ -101,7 +101,7 @@ private function construct_compatibilityWithOldMariaDB(){ /** * addResourcesFieldsToGet - * @version 2.0.2 (2019-03-19) + * @version 2.0.3 (2024-08-06) * * @param $fields {array} * @param $fields[i] {string} — Name of document field or TV. @@ -109,19 +109,19 @@ private function construct_compatibilityWithOldMariaDB(){ * @return {void} */ public function addResourcesFieldsToGet($fields){ - //Separate TVs and common document fields + // Separate TVs and common document fields $fields = \ddTools::prepareDocData([ 'data' => array_flip($fields) ]); - //Save common fields + // Save common fields if (!empty($fields->fieldsData)){ $this->resourcesFieldsToGet->fields = array_unique(array_merge( $this->resourcesFieldsToGet->fields, array_keys($fields->fieldsData) )); } - //Save TVs + // Save TVs if (!empty($fields->tvsData)){ $this->resourcesFieldsToGet->tvs = array_unique(array_merge( $this->resourcesFieldsToGet->tvs, @@ -132,7 +132,7 @@ public function addResourcesFieldsToGet($fields){ /** * getResourcesDataFromDb - * @version 6.1.3 (2020-03-10) + * @version 6.1.4 (2024-08-06) * * @param $params {arrayAssociative|stdClass} * @param $params['resourcesIds'] — Document IDs to get ($this->filter will be used). Default: ''. @@ -140,7 +140,7 @@ public function addResourcesFieldsToGet($fields){ * @return {\ddGetDocuments\DataProvider\DataProviderOutput} */ protected final function getResourcesDataFromDb($params = []){ - //Empty result by default + // Empty result by default $result = new DataProviderOutput( [], 0 @@ -148,7 +148,7 @@ protected final function getResourcesDataFromDb($params = []){ $query = $this->prepareQuery($params); - //Invalid query — empty result + // Invalid query — empty result if(!empty($query)){ $data = \ddTools::$modx->db->makeArray(\ddTools::$modx->db->query($query)); @@ -158,9 +158,9 @@ protected final function getResourcesDataFromDb($params = []){ ){ $totalFound = \ddTools::$modx->db->getValue('SELECT FOUND_ROWS()'); - //If TVs exist + // If TVs exist if (!empty($this->resourcesFieldsToGet->tvs)){ - //Get TVs values + // Get TVs values foreach ( $data as $docIndex => @@ -175,7 +175,7 @@ protected final function getResourcesDataFromDb($params = []){ $this->resourcesFieldsToGet->tvs as $tvName ){ - //If valid TV exist + // If valid TV exist if(isset($docValue['TVs'][$tvName])){ $data[$docIndex][$tvName] = $docValue['TVs'][$tvName]; } @@ -207,7 +207,7 @@ public function get(){ /** * getUsedFieldsFromSqlString - * @version 1.0 (2019-03-13) + * @version 1.0.1 (2024-08-06) * * @param $sqlString {string_sql} * @@ -217,7 +217,7 @@ public function get(){ protected final function getUsedFieldsFromSqlString($sqlString){ $result = []; - //Try to find all resources fields (including tvs) used in string (e. g. in “filter”) by the pattern + // Try to find all resources fields (including tvs) used in string (e. g. in “filter”) by the pattern preg_match_all( "/`(\w+)`/", $sqlString, @@ -233,7 +233,7 @@ protected final function getUsedFieldsFromSqlString($sqlString){ /** * prepareUsedDocFieldsFromSqlString - * @version 3.0.3 (2020-03-10) + * @version 3.0.4 (2024-08-06) * * @param $sqlString {string_sql} * @@ -249,10 +249,10 @@ protected function prepareUsedDocFieldsFromSqlString($sqlString){ $usedFields = $this->getUsedFieldsFromSqlString($sqlString); if(!empty($usedFields)){ - //Sort out fields from tvs + // Sort out fields from tvs $fieldsArray = \ddTools::prepareDocData([ 'data' => array_flip($usedFields), - //Just something + // Just something 'tvAdditionalFieldsToGet' => [ 'name' ] @@ -262,17 +262,17 @@ protected function prepareUsedDocFieldsFromSqlString($sqlString){ $result->fields = array_keys($fieldsArray->fieldsData); } - //If there were tv names in the passed filter string + // If there were tv names in the passed filter string if(!empty($fieldsArray->tvsAdditionalData)){ $result->tvs = []; - //Check whether the current tv name is an actual tv name + // Check whether the current tv name is an actual tv name foreach( $fieldsArray->tvsAdditionalData as $tvName => $tvData ){ - //Pupulate the array with the current tv name + // Pupulate the array with the current tv name $result->tvs[] = $tvName; } @@ -287,7 +287,7 @@ protected function prepareUsedDocFieldsFromSqlString($sqlString){ /** * buildTVsSubQuery - * @version 1.0.6 (2020-03-10) + * @version 1.0.7 (2024-08-06) * * @desc A helper method to build subquery with joined TVS to make possible to use filter conditions for both fields and tvs. * @@ -296,22 +296,22 @@ protected function prepareUsedDocFieldsFromSqlString($sqlString){ * @return {string} */ protected function buildTVsSubQuery(array $tvs){ - //Aliases: - //c - site_content - //tvt - site_tmplvar_templates - //tv - site_tmplvars - //tvcv - site_tmplvar_contentvalues + // Aliases: + // c - site_content + // tvt - site_tmplvar_templates + // tv - site_tmplvars + // tvcv - site_tmplvar_contentvalues - //select query + // select query $selectTvsQuery = 'SELECT `c`.*,'; $fromTvsQuery = 'FROM ' . $this->resourcesTableName . ' as `c`' ; - //join query + // join query $joinTvsQuery = ''; - //where query + // where query $whereTvsQuery = ''; $tvCounter = 1; @@ -320,25 +320,25 @@ protected function buildTVsSubQuery(array $tvs){ $tvs as $tvName ){ - //alias of tmplvar_templates + // alias of tmplvar_templates $tvtAlias = '`tvt_' . $tvCounter . '`' ; - //alias of tmplvars + // alias of tmplvars $tvAlias = '`tv_' . $tvCounter . '`' ; - //alias of tmplvar_contentvalues + // alias of tmplvar_contentvalues $tvcvAlias = '`tvcv_' . $tvCounter . '`' ; - //select not null value from either the real value column or default + // select not null value from either the real value column or default $selectTvsQuery .= 'coalesce(' . $tvcvAlias . @@ -401,7 +401,7 @@ protected function buildTVsSubQuery(array $tvs){ ) ; - //complete from query + // complete from query return $selectTvsQuery . ' ' . @@ -415,7 +415,7 @@ protected function buildTVsSubQuery(array $tvs){ /** * prepareQueryData_fromAndFilter - * @version 3.0.1 (2020-03-10) + * @version 3.0.2 (2024-08-06) * * @param $filterStr {string} — Filter string. @required * @@ -425,18 +425,18 @@ protected function buildTVsSubQuery(array $tvs){ */ protected final function prepareQueryData_fromAndFilter($filterStr){ $result = (object) [ - //By default, the required data is just fetched from the site_content table + // By default, the required data is just fetched from the site_content table 'from' => $this->resourcesTableName, 'filter' => '' ]; - //If a filter is set, it is needed to check which TVs are used in the filter query + // If a filter is set, it is needed to check which TVs are used in the filter query if(!empty($filterStr)){ $usedFields = $this->prepareUsedDocFieldsFromSqlString($filterStr); - //If there are some TV names in the filter query, make a temp table from which the required data will be fetched + // If there are some TV names in the filter query, make a temp table from which the required data will be fetched if(!empty($usedFields->tvs)){ - //complete from query + // complete from query $result->from = '(' . $this->buildTVsSubQuery($usedFields->tvs) . @@ -456,7 +456,7 @@ protected final function prepareQueryData_fromAndFilter($filterStr){ /** * prepareQueryData - * @version 2.2 (2022-06-03) + * @version 2.2.1 (2024-08-06) * * @param $params {arrayAssociative|stdClass} * @param $params['resourcesIds'] — Document IDs to get. Default: ''. @@ -469,7 +469,7 @@ protected final function prepareQueryData_fromAndFilter($filterStr){ * @return $result->limit {string} */ protected final function prepareQueryData($params = []){ - //Defaults + // Defaults $params = (object) array_merge( [ 'resourcesIds' => '' @@ -501,14 +501,14 @@ protected final function prepareQueryData($params = []){ ; } - //If LIMIT needed + // If LIMIT needed if ( !empty($this->offset) || !empty($this->total) ){ $result->limit = 'LIMIT '; - //Prepare offset + // Prepare offset if (!empty($this->offset)){ $result->limit .= $this->offset . @@ -516,11 +516,11 @@ protected final function prepareQueryData($params = []){ ; } - //Prepare total rows + // Prepare total rows if (!empty($this->total)){ $result->limit .= $this->total; }else{ - //All rows + // All rows $result->limit .= PHP_INT_MAX; } } @@ -554,7 +554,7 @@ protected final function prepareQueryData($params = []){ /** * prepareQuery - * @version 1.4.1 (2023-01-04) + * @version 1.4.2 (2024-08-06) * * @param $params {arrayAssociative|stdClass} * @param $params['resourcesIds'] — Document IDs to get ($this->filter will be used). Default: ''. @@ -562,7 +562,7 @@ protected final function prepareQueryData($params = []){ * @return $result {string} */ protected function prepareQuery($params = []){ - //Defaults + // Defaults $params = (object) array_merge( [ 'resourcesIds' => '' @@ -574,7 +574,7 @@ protected function prepareQuery($params = []){ $queryData = $this->prepareQueryData($params); - //Invalid query data — empty result + // Invalid query data — empty result if(!empty($queryData->from)){ $result = ' SELECT @@ -585,7 +585,7 @@ protected function prepareQuery($params = []){ ) . '` '; - //If TVs exist + // If TVs exist if (!empty($this->resourcesFieldsToGet->tvs)){ $result .= ' , diff --git a/src/DataProvider/Parent/DataProvider.php b/src/DataProvider/Parent/DataProvider.php index 318809e..7c03e15 100644 --- a/src/DataProvider/Parent/DataProvider.php +++ b/src/DataProvider/Parent/DataProvider.php @@ -13,15 +13,15 @@ class DataProvider extends \ddGetDocuments\DataProvider\DataProvider { /** * __construct - * @version 2.0 (2021-02-15) + * @version 2.0.1 (2024-08-06) * * @param $params {stdClass|arrayAssociative} */ public function __construct($params){ - //Call base constructor + // Call base constructor parent::__construct($params); - //Comma separated strings support + // Comma separated strings support if (!is_array($this->parentIds)){ $this->parentIds = explode( ',', @@ -35,8 +35,8 @@ public function __construct($params){ ); } - //Parent IDs must be set. - //TODO: Does we need to to this? People must set correct parameters. Or not? :) + // Parent IDs must be set. + // TODO: Does we need to to this? People must set correct parameters. Or not? :) if (empty($this->parentIds)){ $this->parentIds = [0]; } @@ -44,7 +44,7 @@ public function __construct($params){ /** * get - * @version 2.0.9 (2020-03-10) + * @version 2.0.10 (2024-08-06) * * @return {\ddGetDocuments\DataProvider\DataProviderOutput} */ @@ -67,7 +67,7 @@ public function get(){ $excludeIdsStr = ''; } - //Need to get multiple levels + // Need to get multiple levels if($this->depth > 1){ $allChildrenIds = ' WITH RECURSIVE `recursive_query` ( `id`, `parent`, `depth` ) AS ( @@ -99,7 +99,7 @@ public function get(){ FROM `recursive_query` '; - //Just single level + // Just single level }else{ $allChildrenIds = ' SELECT diff --git a/src/DataProvider/Select/DataProvider.php b/src/DataProvider/Select/DataProvider.php index 921f5bc..54e760b 100644 --- a/src/DataProvider/Select/DataProvider.php +++ b/src/DataProvider/Select/DataProvider.php @@ -11,12 +11,12 @@ class DataProvider extends \ddGetDocuments\DataProvider\DataProvider { /** * get - * @version 1.0.7 (2020-03-10) + * @version 1.0.8 (2024-08-06) * * @return {\ddGetDocuments\DataProvider\DataProviderOutput} */ public function get(){ - //Order by selected IDs sequence + // Order by selected IDs sequence if ( empty($this->orderBy) && !empty($this->ids) diff --git a/src/Extender/Pagination/Extender.php b/src/Extender/Pagination/Extender.php index eec12ef..4355755 100644 --- a/src/Extender/Pagination/Extender.php +++ b/src/Extender/Pagination/Extender.php @@ -8,18 +8,18 @@ class Extender extends \ddGetDocuments\Extender\Extender { * @property $dataProviderParams {stdClass} */ $dataProviderParams, - //Current page index + // Current page index $pageIndex, - //The parameter in $_REQUEST to get the current page index from + // The parameter in $_REQUEST to get the current page index from $pageIndexRequestParamName = 'page' ; protected - //Chunk to be used to output pages within the pagination + // Chunk to be used to output pages within the pagination $pageTpl = '[+page+]', - //Chunk to be used to output the current page within the pagination + // Chunk to be used to output the current page within the pagination $currentPageTpl = '[+page+]', - //Chunk to be used to output the pagination + // Chunk to be used to output the pagination $wrapperTpl = '
', - //Chunk to be used to output the navigation block to the next page + // Chunk to be used to output the navigation block to the next page $nextTpl = 'Следующая →
Последняя →', - //Chunk to be used to output the navigation block to the next page if there are no more pages after + // Chunk to be used to output the navigation block to the next page if there are no more pages after $nextOffTpl = 'Следующая →
Последняя →', - //Chunk to be used to output the navigation block to the previous page + // Chunk to be used to output the navigation block to the previous page $previousTpl = '← Предыдущая
← Первая', - //Chunk to be used to output the navigation block to the previous page if there are no more pages before + // Chunk to be used to output the navigation block to the previous page if there are no more pages before $previousOffTpl = '← Предыдущая
← Первая' ; /** * __construct - * @version 1.2.3 (2023-05-14) + * @version 1.2.4 (2024-08-06) * * @param $params {stdClass|arrayAssociative} */ public function __construct($params = []){ - //Call base constructor + // Call base constructor parent::__construct($params); foreach ( @@ -75,14 +75,14 @@ public function __construct($params = []){ /** * applyToDataProviderParams - * @version 1.0 (2020-10-02) + * @version 1.0.1 (2024-08-06) * * @param $dataProviderParams {stdClass} * * @return {stdClass} */ public function applyToDataProviderParams($dataProviderParams){ - //If “total” is set then we need to override “offset” according to the current page index + // If “total” is set then we need to override “offset” according to the current page index if(isset($dataProviderParams->total)){ $dataProviderParams->offset = ( @@ -100,7 +100,7 @@ public function applyToDataProviderParams($dataProviderParams){ /** * applyToOutput - * @version 1.2.3 (2021-02-12) + * @version 1.2.4 (2024-08-06) * * @param $dataProviderOutput {\ddGetDocuments\DataProvider\DataProviderOutput} * @@ -109,7 +109,7 @@ public function applyToDataProviderParams($dataProviderParams){ public function applyToOutput(\ddGetDocuments\DataProvider\DataProviderOutput $dataProviderOutput){ $result = ''; - //Check to prevent division by zero + // Check to prevent division by zero if($this->dataProviderParams->total != 0){ $pagesTotal = ceil( $dataProviderOutput->totalFound / @@ -125,12 +125,12 @@ public function applyToOutput(\ddGetDocuments\DataProvider\DataProviderOutput $d $currentQuery ); - //Remove MODX internal parameter + // Remove MODX internal parameter if (isset($currentQuery['q'])){ unset($currentQuery['q']); } - //Remove the “page” parameter + // Remove the “page” parameter if (isset($currentQuery[$this->pageIndexRequestParamName])){ unset($currentQuery[$this->pageIndexRequestParamName]); } @@ -145,13 +145,13 @@ public function applyToOutput(\ddGetDocuments\DataProvider\DataProviderOutput $d $pagesOutputText = ''; - //If the current page index is greater than the total number of pages - //then it has to be reset + // If the current page index is greater than the total number of pages + // then it has to be reset if($this->pageIndex > $pagesTotal){ $this->pageIndex = 1; } - //Iterating through pages + // Iterating through pages for( $pageIndex = 1; $pageIndex <= $pagesTotal; @@ -159,7 +159,7 @@ public function applyToOutput(\ddGetDocuments\DataProvider\DataProviderOutput $d ){ $pageChunk = $this->pageTpl; - //Check if the page we're iterating through is current + // Check if the page we're iterating through is current if($pageIndex == $this->pageIndex){ $pageChunk = $this->currentPageTpl; } diff --git a/src/Extender/Search/Extender.php b/src/Extender/Search/Extender.php index 2014506..89c0f6c 100644 --- a/src/Extender/Search/Extender.php +++ b/src/Extender/Search/Extender.php @@ -16,13 +16,13 @@ class Extender extends \ddGetDocuments\Extender\Extender { /** * __construct - * @version 1.1 (2018-06-12) + * @version 1.1.1 (2024-08-06) * * @param $params {stdClass|arrayAssociative} * @param $params->docFieldsToSearch {array|stringCommaSepareted} — Document fields to search in. Default: ['pagetitle', 'content']. */ public function __construct($params = []){ - //Call base constructor + // Call base constructor parent::__construct($params); if(!is_array($this->docFieldsToSearch)){ @@ -39,14 +39,14 @@ public function __construct($params = []){ /** * applyToDataProviderParams - * @version 1.0 (2021-02-12) + * @version 1.0.1 (2024-08-06) * * @param $dataProviderParams {stdClass} * * @return {stdClass} */ public function applyToDataProviderParams($dataProviderParams){ - //If URL contains tags + // If URL contains tags if (!empty($this->currentQuery)){ $searchQueries = []; diff --git a/src/Extender/Sortfromurl/Extender.php b/src/Extender/Sortfromurl/Extender.php index 8df2310..50c7a60 100644 --- a/src/Extender/Sortfromurl/Extender.php +++ b/src/Extender/Sortfromurl/Extender.php @@ -9,12 +9,12 @@ class Extender extends \ddGetDocuments\Extender\Extender { /** * __construct - * @version 1.0 (2020-10-02) + * @version 1.0.1 (2024-08-06) * * @param $params {stdClass|arrayAssociative} */ public function __construct($params = []){ - //Call base constructor + // Call base constructor parent::__construct($params); if (isset($_REQUEST['orderBy'])){ @@ -28,14 +28,14 @@ public function __construct($params = []){ /** * applyToDataProviderParams - * @version 1.0 (2020-10-02) + * @version 1.0.1 (2024-08-06) * * @param $dataProviderParams {stdClass} * * @return {stdClass} */ public function applyToDataProviderParams($dataProviderParams){ - //If URL contains sorting rules + // If URL contains sorting rules if (!empty($this->currentOrderBy)){ $dataProviderParams->orderBy = $this->currentOrderBy; } diff --git a/src/Extender/Tagging/Extender.php b/src/Extender/Tagging/Extender.php index ca2357a..45b4039 100644 --- a/src/Extender/Tagging/Extender.php +++ b/src/Extender/Tagging/Extender.php @@ -4,22 +4,22 @@ class Extender extends \ddGetDocuments\Extender\Extender { private - //Current selected tags + // Current selected tags $currentTags = [] ; protected - //The parameter in $_REQUEST to get the tags value from + // The parameter in $_REQUEST to get the tags value from $tagsRequestParamName = 'tags', - //A document field (TV) contains tags + // A document field (TV) contains tags $tagsDocumentField = 'tags', - //Tags delimiter + // Tags delimiter $tagsDelimiter = ', ' ; /** * __construct - * @version 1.1.2 (2020-03-10) + * @version 1.1.3 (2024-08-06) * * @param $params {stdClass|arrayAssociative} * @param $params->tagsDocumentField {stringTvName} — The document field (TV) contains tags. Default: 'tags'. @@ -27,14 +27,14 @@ class Extender extends \ddGetDocuments\Extender\Extender { * @param $params->tagsRequestParamName {string} — The parameter in $_REQUEST to get the tags value from. Default: 'tags'. */ public function __construct($params = []){ - //Call base constructor + // Call base constructor parent::__construct($params); if (isset($_REQUEST[$this->tagsRequestParamName])){ $this->currentTags = $_REQUEST[$this->tagsRequestParamName]; //?tags[]=someTag1&tags[]=someTag2 - //or + // or //?tags=someTag1,someTag2 if (!is_array($this->currentTags)){ $this->currentTags = explode( @@ -55,14 +55,14 @@ public function __construct($params = []){ /** * applyToDataProviderParams - * @version 1.0 (2021-02-12) + * @version 1.0.1 (2024-08-06) * * @param $dataProviderParams {stdClass} * * @return {stdClass} */ public function applyToDataProviderParams($dataProviderParams){ - //If URL contains tags + // If URL contains tags if (!empty($this->currentTags)){ if( isset($dataProviderParams->filter) && diff --git a/src/Input.php b/src/Input.php index d196c57..1f66252 100644 --- a/src/Input.php +++ b/src/Input.php @@ -40,7 +40,7 @@ class Input extends \DDTools\Base\Base { /** * __construct - * @version 4.5 (2022-06-03) + * @version 4.5.1 (2024-08-06) * * @param $snippetParams {stdClass} — The object of parameters. @required * @param $snippetParams->providerParams {stdClass|arrayAssociative|stringJsonObject} @@ -48,7 +48,7 @@ class Input extends \DDTools\Base\Base { * @param $snippetParams->outputterParams {stdClass|arrayAssociative|stringJsonObject} */ public function __construct($snippetParams){ - //Prepare provider, outputter and extender params + // Prepare provider, outputter and extender params foreach ( [ 'providerParams', @@ -57,7 +57,7 @@ public function __construct($snippetParams){ ] as $paramName ){ - //Convert to object + // Convert to object $this->{$paramName} = (object) $this->{$paramName}; if ( @@ -68,9 +68,9 @@ public function __construct($snippetParams){ ){ $this->{$paramName} = \DDTools\ObjectTools::extend([ 'objects' => [ - //Defaults + // Defaults $this->{$paramName}, - //Given parameters + // Given parameters \DDTools\ObjectTools::convertType([ 'object' => $snippetParams->{$paramName}, 'type' => 'objectStdClass' @@ -79,7 +79,7 @@ public function __construct($snippetParams){ ]); } - //Remove it to prevent overwriting through `$this->setExistingProps` + // Remove it to prevent overwriting through `$this->setExistingProps` unset($snippetParams->{$paramName}); } @@ -87,7 +87,7 @@ public function __construct($snippetParams){ $this->outputter = strtolower($this->outputter); - //Backward compatibility + // Backward compatibility $this->backwardCompatibility_dataProviderParams($snippetParams); $this->backwardCompatibility_outputterParams(); @@ -95,11 +95,11 @@ public function __construct($snippetParams){ $this->prepareExtendersParams($snippetParams); - //Set object properties from snippet parameters + // Set object properties from snippet parameters $this->setExistingProps($snippetParams); - //Make sure groupBy, orderBy and filter looks like SQL + // Make sure groupBy, orderBy and filter looks like SQL foreach ( [ 'filter', @@ -118,7 +118,7 @@ public function __construct($snippetParams){ /** * prepareExtendersParams - * @version 3.0 (2021-02-26) + * @version 3.0.1 (2024-08-06) * * @desc Prepare extenders params. * @@ -133,7 +133,7 @@ private function prepareExtendersParams($snippetParams){ 'propName' => 'extenders' ]) ){ - //Prepare extenders + // Prepare extenders if (is_string($snippetParams->extenders)){ if (!empty($snippetParams->extenders)){ $snippetParams->extenders = explode( @@ -145,10 +145,10 @@ private function prepareExtendersParams($snippetParams){ } } - //Prepare extenders params + // Prepare extenders params if(!empty($snippetParams->extenders)){ - //If we have a single extender then make sure that extender params set as an array - //like [extenderName => [extenderParameter_1, extenderParameter_2, ...]] + // If we have a single extender then make sure that extender params set as an array + // like [extenderName => [extenderParameter_1, extenderParameter_2, ...]] if(count($snippetParams->extenders) === 1){ if( !\DDTools\ObjectTools::isPropExists([ @@ -161,7 +161,7 @@ private function prepareExtendersParams($snippetParams){ ]; } }else{ - //Make sure that for each extender there is an item in $this->extendersParams + // Make sure that for each extender there is an item in $this->extendersParams foreach( $snippetParams->extenders as $extenderName @@ -182,7 +182,7 @@ private function prepareExtendersParams($snippetParams){ /** * backwardCompatibility_dataProviderParams - * @version 2.0 (2021-02-26) + * @version 2.0.1 (2024-08-06) * * @desc Prepare data provider params preserve backward compatibility. * @@ -191,7 +191,7 @@ private function prepareExtendersParams($snippetParams){ * @return {void} */ private function backwardCompatibility_dataProviderParams($snippetParams){ - //Move parameters from snippetParams to providerParams + // Move parameters from snippetParams to providerParams foreach ( [ 'filter', @@ -247,7 +247,7 @@ private function backwardCompatibility_outputterParams(){ /** * backwardCompatibility_outputterParams_moveTemplates - * @version 1.0 (2021-07-18) + * @version 1.0.1 (2024-08-06) * * @desc Moves required templates from $this->outputterParams to $this->outputterParams->templates. * @@ -258,7 +258,7 @@ private function backwardCompatibility_outputterParams(){ */ private function backwardCompatibility_outputterParams_moveTemplates($complianceArray){ if ( - //If required templates is not set, then we need to provide backward compatibility + // If required templates is not set, then we need to provide backward compatibility !\DDTools\ObjectTools::isPropExists([ 'object' => $this->outputterParams, 'propName' => 'templates' @@ -287,19 +287,19 @@ private function backwardCompatibility_outputterParams_moveTemplates($compliance /** * backwardCompatibility_outputterParams_yandexmarket - * @version 1.0 (2021-07-18) + * @version 1.0.1 (2024-08-06) * * @return {void} */ private function backwardCompatibility_outputterParams_yandexmarket(){ if ( - //If required shopData is not set, then we need to provide backward compatibility + // If required shopData is not set, then we need to provide backward compatibility !\DDTools\ObjectTools::isPropExists([ 'object' => $this->outputterParams, 'propName' => 'shopData' ]) ){ - //If shopData is not set, then offerFields and templates are not set too + // If shopData is not set, then offerFields and templates are not set too $this->outputterParams->shopData = (object) []; $this->outputterParams->offerFields = (object) []; $this->outputterParams->templates = (object) []; @@ -312,7 +312,7 @@ private function backwardCompatibility_outputterParams_yandexmarket(){ $targetGroupName = NULL; $targetParamName = NULL; - //$this->outputterParams->shopData + // $this->outputterParams->shopData if ( substr( $paramName, @@ -325,7 +325,7 @@ private function backwardCompatibility_outputterParams_yandexmarket(){ $paramName, 9 ); - //$this->outputterParams->offerFields + // $this->outputterParams->offerFields }elseif ( substr( $paramName, @@ -338,7 +338,7 @@ private function backwardCompatibility_outputterParams_yandexmarket(){ $paramName, 12 ); - //$this->outputterParams->templates + // $this->outputterParams->templates }elseif ( substr( $paramName, diff --git a/src/Outputter/Json/Outputter.php b/src/Outputter/Json/Outputter.php index 1667faf..ff53631 100644 --- a/src/Outputter/Json/Outputter.php +++ b/src/Outputter/Json/Outputter.php @@ -7,7 +7,7 @@ class Outputter extends \ddGetDocuments\Outputter\Outputter { /** * parse - * @version 2.3 (2022-09-30) + * @version 2.3.1 (2024-08-06) * * @param $data {Output} * @@ -16,21 +16,21 @@ class Outputter extends \ddGetDocuments\Outputter\Outputter { public function parse(Output $data){ $result = []; - //Пройдемся по полученным данным + // Пройдемся по полученным данным foreach( $data->provider->items as $itemData ){ $result_item = []; - //Result must contains only specified fields + // Result must contains only specified fields foreach( $this->docFields as $docField ){ $result_item[$docField] = $itemData[$docField]; - //If template for this field is set + // If template for this field is set if ( \DDTools\ObjectTools::isPropExists([ 'object' => $this->templates, @@ -54,7 +54,7 @@ public function parse(Output $data){ $result[] = $result_item; } - //JSON_UNESCAPED_UNICODE — Не кодировать многобайтные символы Unicode || JSON_UNESCAPED_SLASHES — Не экранировать / + // JSON_UNESCAPED_UNICODE — Не кодировать многобайтные символы Unicode || JSON_UNESCAPED_SLASHES — Не экранировать / return json_encode( $result, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES diff --git a/src/Outputter/Outputter.php b/src/Outputter/Outputter.php index ae52494..d8fecb1 100644 --- a/src/Outputter/Outputter.php +++ b/src/Outputter/Outputter.php @@ -22,7 +22,7 @@ abstract class Outputter extends \DDTools\Base\Base { /** * __construct - * @version 1.5.2 (2023-05-02) + * @version 1.5.3 (2024-08-06) * * @param $params {stdClass|arrayAssociative} * @param $params->dataProvider {\ddGetDocuments\DataProvider\DataProvider} @@ -30,15 +30,15 @@ abstract class Outputter extends \DDTools\Base\Base { public function __construct($params = []){ $params = (object) $params; - //Prepare templates + // Prepare templates $this->construct_prepareFields_templates($params); - //Remove from params to prevent overwriting through `$this->setExistingProps` + // Remove from params to prevent overwriting through `$this->setExistingProps` unset($params->templates); - //Все параметры задают свойства объекта + // Все параметры задают свойства объекта $this->setExistingProps($params); - //Comma separated strings + // Comma separated strings if (!is_array($this->docFields)){ $this->docFields = explode( ',', @@ -47,31 +47,31 @@ public function __construct($params = []){ } if (empty($this->docFields)){ - //We need something + // We need something $this->docFields = ['id']; }elseif (isset($params->dataProvider)){ - //Ask dataProvider to get them + // Ask dataProvider to get them $params->dataProvider->addResourcesFieldsToGet($this->docFields); } } /** * construct_prepareFields_templates - * @version 1.0.1 (2023-05-14) + * @version 1.0.2 (2024-08-06) * * @param $params {stdClass|arrayAssociative} — See __construct. */ protected function construct_prepareFields_templates($params){ $this->templates = (object) $this->templates; - //If parameter is passed + // If parameter is passed if ( \DDTools\ObjectTools::isPropExists([ 'object' => $params, 'propName' => 'templates' ]) ){ - //Extend defaults + // Extend defaults $this->templates = \DDTools\ObjectTools::extend([ 'objects' => [ $this->templates, @@ -85,7 +85,7 @@ protected function construct_prepareFields_templates($params){ $templateName => $templateValue ){ - //Exclude null values + // Exclude null values if (is_string($templateValue)){ $this->templates->{$templateName} = \ddTools::getTpl($templateValue); } diff --git a/src/Outputter/Sitemap/Outputter.php b/src/Outputter/Sitemap/Outputter.php index 033f1a7..c81ba7f 100644 --- a/src/Outputter/Sitemap/Outputter.php +++ b/src/Outputter/Sitemap/Outputter.php @@ -20,7 +20,7 @@ class Outputter extends \ddGetDocuments\Outputter\Outputter { /** * __construct - * @version 2.0.2 (2024-07-13) + * @version 2.0.3 (2024-08-06) * * @param $params {stdClass|arrayAssociative} * @param $params->priorityTVName {stringTvName} — Name of TV which sets the relative priority of the document. Default: 'general_seo_sitemap_priority'. @@ -30,10 +30,10 @@ class Outputter extends \ddGetDocuments\Outputter\Outputter { * @param $params->templates->wrapper {string|stringChunkName} — Available placeholders: [+ddGetDocuments_items+], [+any of extender placeholders+]. Default: '[+ddGetDocuments_items+]'. */ public function __construct($params = []){ - //Call base constructor + // Call base constructor parent::__construct($params); - //Prepare item template + // Prepare item template $this->templates->item = \ddTools::parseText([ 'text' => $this->templates->item, 'data' => [ @@ -43,11 +43,11 @@ public function __construct($params = []){ 'isCompletelyParsingEnabled' => false ]); - //We use the “String” Outputter as base + // We use the “String” Outputter as base $outputter_StringParams = (object) [ 'templates' => $this->templates ]; - //Transfer provider link + // Transfer provider link if (isset($params->dataProvider)){ $outputter_StringParams->dataProvider = $params->dataProvider; } @@ -59,7 +59,7 @@ public function __construct($params = []){ /** * parse - * @version 1.1.2 (2020-04-30) + * @version 1.1.3 (2024-08-06) * * @param $data {Output} * @@ -71,7 +71,7 @@ public function parse(Output $data){ $docIndex => $docData ){ - //Convert date to appropriate format + // Convert date to appropriate format if (isset($data->provider->items[$docIndex]['editedon'])){ $data->provider->items[$docIndex]['editedon'] = date( 'Y-m-d', @@ -80,7 +80,7 @@ public function parse(Output $data){ } } - //Just use the “String” class + // Just use the “String” class return $this->outputter_StringInstance->parse($data); } } \ No newline at end of file diff --git a/src/Outputter/String/Outputter.php b/src/Outputter/String/Outputter.php index 1e319d9..100605d 100644 --- a/src/Outputter/String/Outputter.php +++ b/src/Outputter/String/Outputter.php @@ -22,7 +22,7 @@ class Outputter extends \ddGetDocuments\Outputter\Outputter { /** * construct_prepareFields_templates - * @version 1.0 (2021-07-13) + * @version 1.0.1 (2024-08-06) * * @param $params {stdClass|arrayAssociative} — @required * @param $params->templates {stdClass|arrayAssociative} — Templates. @required @@ -36,20 +36,20 @@ class Outputter extends \ddGetDocuments\Outputter\Outputter { * @param $params->itemGlue {string} — The string that combines items while rendering. Default: ''. */ protected function construct_prepareFields_templates($params){ - //Call base method + // Call base method parent::construct_prepareFields_templates($params); - //Prepare item templates + // Prepare item templates if (is_string($this->templates->item)){ $textToGetPlaceholdersFrom = $this->templates->item; - //First item + // First item if (is_string($this->templates->itemFirst)){ $textToGetPlaceholdersFrom .= $this->templates->itemFirst; }else{ $this->templates->itemFirst = $this->templates->item; } - //Last item + // Last item if (is_string($this->templates->itemLast)){ $textToGetPlaceholdersFrom .= $this->templates->itemLast; }else{ @@ -64,7 +64,7 @@ protected function construct_prepareFields_templates($params){ /** * parse - * @version 2.1.4 (2021-07-13) + * @version 2.1.5 (2024-08-06) * * @param $data {Output} * @@ -103,16 +103,16 @@ public function parse(Output $data){ if( is_array($data->provider->items) && - //Item template is set + // Item template is set $this->templates->item !== null ){ $maxIndex = $total - 1; - //Foreach items + // Foreach items foreach( $data->provider->items as $index => $item ){ - //Prepare item output template + // Prepare item output template if($index == 0){ $chunkName = $this->templates->itemFirst; }elseif($index == $maxIndex){ @@ -142,7 +142,7 @@ public function parse(Output $data){ $resultItems ); - //If no items found and “noResults” is not empty + // If no items found and “noResults” is not empty if( $total == 0 && $this->templates->noResults !== null && diff --git a/src/Outputter/Yandexmarket/Outputter.php b/src/Outputter/Yandexmarket/Outputter.php index 193b593..9c51d76 100644 --- a/src/Outputter/Yandexmarket/Outputter.php +++ b/src/Outputter/Yandexmarket/Outputter.php @@ -11,7 +11,7 @@ class Outputter extends \ddGetDocuments\Outputter\Outputter { */ $docFields = [ 'id', - //May need for smart name + // May need for smart name 'pagetitle' ], @@ -69,7 +69,7 @@ class Outputter extends \ddGetDocuments\Outputter\Outputter { ], 'available' => [ 'docFieldName' => '', - //without template + // without template 'templateName' => '' ], 'description' => [ @@ -177,7 +177,7 @@ class Outputter extends \ddGetDocuments\Outputter\Outputter { /** * __construct - * @version 2.1.3 (2023-05-02) + * @version 2.1.4 (2024-08-06) * * @note @link https://yandex.ru/support/partnermarket/export/yml.html * @@ -217,12 +217,12 @@ public function __construct($params = []){ $params = (object) $params; - //# Prepare object fields + // # Prepare object fields $this->construct_prepareFields(); - //# Save shopData - //If parameter is passed + // # Save shopData + // If parameter is passed if ( \DDTools\ObjectTools::isPropExists([ 'object' => $params, @@ -236,18 +236,18 @@ public function __construct($params = []){ ] ]); - //Remove from params to prevent overwriting through `$this->setExistingProps` + // Remove from params to prevent overwriting through `$this->setExistingProps` unset($params->shopData); } - //# Save offerFields + // # Save offerFields foreach ( $params->offerFields as $offerFieldName => $offerFieldParamValue ){ - //If parameter set as full data + // If parameter set as full data if (is_object($offerFieldParamValue)){ $this->offerFields->{$offerFieldName} = \DDTools\ObjectTools::extend([ 'objects' => [ @@ -255,27 +255,27 @@ public function __construct($params = []){ $offerFieldParamValue ] ]); - //If parameter set as doc field name only + // If parameter set as doc field name only }else{ $this->offerFields->{$offerFieldName}->docFieldName = $offerFieldParamValue; } } - //Remove from params to prevent overwriting through `$this->setExistingProps` + // Remove from params to prevent overwriting through `$this->setExistingProps` unset($params->offerFields); - //If name doc field is not set + // If name doc field is not set if (empty($this->offerFields->name->docFieldName)){ - //Pagetitle will be used + // Pagetitle will be used $this->offerFields->name->docFieldName = 'pagetitle'; } - //# Call base constructor + // # Call base constructor parent::__construct($params); - //# Prepare last parent category IDs + // # Prepare last parent category IDs if (!is_array($this->categoryIds_last)){ $this->categoryIds_last = explode( ',', @@ -284,18 +284,18 @@ public function __construct($params = []){ } - //# Prepare templates + // # Prepare templates $this->construct_prepareTemplates(); - //We use the “String” Outputter as base + // We use the “String” Outputter as base $outputter_StringParams = (object) [ 'templates' => (object) [ 'item' => $this->templates->offers_item, 'wrapper' => $this->templates->wrapper ] ]; - //Transfer provider link + // Transfer provider link if (isset($params->dataProvider)){ $outputter_StringParams->dataProvider = $params->dataProvider; } @@ -307,12 +307,12 @@ public function __construct($params = []){ /** * construct_prepareFields - * @version 1.0.2 (2022-09-20) + * @version 1.0.3 (2024-08-06) * * @return {void} */ private function construct_prepareFields(){ - //Convert fields to objects + // Convert fields to objects $this->shopData = (object) $this->shopData; $this->offerFields = (object) $this->offerFields; $this->templates = (object) $this->templates; @@ -324,7 +324,7 @@ private function construct_prepareFields(){ $this->offerFields->{$offerFieldName} = (object) $this->offerFields->{$offerFieldName}; } - //Trim all templates + // Trim all templates foreach ( $this->templates as $templateName => @@ -336,12 +336,12 @@ private function construct_prepareFields(){ /** * construct_prepareTemplates - * @version 1.0.1 (2024-07-13) + * @version 1.0.2 (2024-08-06) * * @return {void} */ private function construct_prepareTemplates(){ - //Offer + // Offer $templateData = [ 'shopData' => (array) $this->shopData ]; @@ -363,18 +363,18 @@ private function construct_prepareTemplates(){ ){ $templateData[$fieldAlias] = $fieldData->docFieldName; - //Replace to field name placeholder + // Replace to field name placeholder if (!empty($fieldData->docFieldName)){ $templateData[$fieldAlias] = '[+' . $templateData[$fieldAlias] . '+]'; }else{ - //Always available + // Always available if ($fieldAlias == 'available'){ $templateData[$fieldAlias] = 'true'; } } } - //Prepare offer item template + // Prepare offer item template $this->templates->offers_item = \ddTools::parseText([ 'text' => $this->templates->offers_item, 'data' => $templateData, @@ -382,14 +382,14 @@ private function construct_prepareTemplates(){ ]); - //Wrapper + // Wrapper $templateData = [ 'shopData' => (array) $this->shopData, 'generationDate' => date('Y-m-d H:i') ]; - //TODO Это здесь вообще надо делать или лучше в другое место перенести? - //Prepare «agency» tag + // TODO Это здесь вообще надо делать или лучше в другое место перенести? + // Prepare «agency» tag if (!empty($templateData['shopData']['agency'])){ $templateData['shopData']['agency'] = \ddTools::parseText([ 'text' => $this->templates->offers_item_elem, @@ -402,7 +402,7 @@ private function construct_prepareTemplates(){ ]); } - //Prepare wrapper template + // Prepare wrapper template $this->templates->wrapper = \ddTools::parseText([ 'text' => $this->templates->wrapper, 'data' => $templateData, @@ -440,82 +440,82 @@ private function escapeSpecialChars($inputString){ /** * parse - * @version 1.6.1 (2024-07-13) + * @version 1.6.2 (2024-08-06) * * @param $data {Output} * * @return {string} */ public function parse(Output $data){ - //# Items + // # Items foreach ( - //Foreach all docs-items + // Foreach all docs-items $data->provider->items as $docIndex => - //Value must be assigned by reference for modifying inside the cycle + // Value must be assigned by reference for modifying inside the cycle &$docData ){ - //Correct price + // Correct price if ( - //Main price is not set + // Main price is not set empty($docData[$this->offerFields->price->docFieldName]) && - //But old price is set + // But old price is set !empty($docData[$this->offerFields->priceOld->docFieldName]) ){ - //Use old price as main price + // Use old price as main price $docData[$this->offerFields->price->docFieldName] = $docData[$this->offerFields->priceOld->docFieldName]; - //And old price is no needed + // And old price is no needed unset($docData[$this->offerFields->priceOld->docFieldName]); } - //Check required elements + // Check required elements if ( - //Price + // Price !empty($docData[$this->offerFields->price->docFieldName]) ){ - //If category is set + // If category is set if (is_numeric($docData[$this->offerFields->categoryId->docFieldName])){ - //Save category ID + // Save category ID $this->categoryIds[] = $docData[$this->offerFields->categoryId->docFieldName]; } - //Foreach all offer fields + // Foreach all offer fields foreach( $this->offerFields as $offerFieldName => $offerFieldData ){ - //Smart offer name + // Smart offer name if ( $offerFieldName == 'name' && - //If doc name is empty + // If doc name is empty empty($docData[$offerFieldData->docFieldName]) ){ - //Pagetitle will be used + // Pagetitle will be used $docData[$offerFieldData->docFieldName] = $docData['pagetitle']; } - //Numeric fields + // Numeric fields if ( - //If weight is set + // If weight is set $offerFieldName == 'weight' && - //But invalid + // But invalid $docData[$offerFieldData->docFieldName] == '0' ){ - //Clear it + // Clear it $docData[$offerFieldData->docFieldName] = ''; } if ( - //If object field is set + // If object field is set !empty($offerFieldData->docFieldName) && - //And doc data is set + // And doc data is set !empty($docData[$offerFieldData->docFieldName]) ){ - //Boolean fields + // Boolean fields if ( in_array( $offerFieldName, @@ -538,7 +538,7 @@ public function parse(Output $data){ } - //Fields that may be set as document IDs + // Fields that may be set as document IDs if ( in_array( $offerFieldName, @@ -547,41 +547,41 @@ public function parse(Output $data){ 'countryOfOrigin' ] ) && - //Set as document id + // Set as document id is_numeric($docData[$offerFieldData->docFieldName]) ){ - //Try to get pagetitle + // Try to get pagetitle $docData_fieldToGet_data = \ddTools::getDocument( $docData[$offerFieldData->docFieldName], 'pagetitle' ); - //If success + // If success if (is_array($docData_fieldToGet_data)){ $docData[$offerFieldData->docFieldName] = $docData_fieldToGet_data['pagetitle']; } } - //Value prefix + // Value prefix if (isset($offerFieldData->valuePrefix)){ $docData[$offerFieldData->docFieldName] = $offerFieldData->valuePrefix . $docData[$offerFieldData->docFieldName] ; } - //Value suffix + // Value suffix if (isset($offerFieldData->valueSuffix)){ $docData[$offerFieldData->docFieldName] .= $offerFieldData->valueSuffix; } - //Try to search template by name + // Try to search template by name $templateName = 'offers_item_elem' . ucfirst($offerFieldName) ; if (!isset($this->templates->{$templateName})){ - //Default element template + // Default element template if (!isset($offerFieldData->templateName)){ $templateName = 'offers_item_elem'; }else{ @@ -591,18 +591,18 @@ public function parse(Output $data){ if ( - //If need to use template + // If need to use template !empty($templateName) && - //Required data for template + // Required data for template !empty($offerFieldData->tagName) ){ - //Final element parsing + // Final element parsing $docData[$offerFieldData->docFieldName] = \ddTools::parseText([ 'text' => $this->templates->{$templateName}, 'data' => [ 'tagName' => $offerFieldData->tagName, 'value' => - //If escaping is disabled + // If escaping is disabled ( \DDTools\ObjectTools::isPropExists([ 'object' => $offerFieldData, @@ -610,9 +610,9 @@ public function parse(Output $data){ ]) && $offerFieldData->disableEscaping ) ? - //Unescaped value + // Unescaped value $docData[$offerFieldData->docFieldName] : - //Escaped value + // Escaped value $this->escapeSpecialChars($docData[$offerFieldData->docFieldName]) ], 'isCompletelyParsingEnabled' => false @@ -621,28 +621,28 @@ public function parse(Output $data){ } } }else{ - //Remove invalid offers + // Remove invalid offers unset($data->provider->items[$docIndex]); } } - //Destroy unused referenced variable + // Destroy unused referenced variable unset($docData); $this->categoryIds = array_unique($this->categoryIds); - //# Categories + // # Categories $this->outputter_StringInstance->placeholders['ddGetDocuments_categories'] = $this->parse_categories(); - //Just use the “String” class + // Just use the “String” class return $this->outputter_StringInstance->parse($data); } /** * parse_categories - * @version 1.1.8 (2024-07-13) + * @version 1.1.9 (2024-08-06) * * @return {string} */ @@ -651,7 +651,7 @@ private function parse_categories(){ $categoryIds_all = []; - //TODO: Avoid to use global variables + // TODO: Avoid to use global variables $getCategories = function ($id) use ( &$categoryIds_all, &$getCategories @@ -666,21 +666,21 @@ private function parse_categories(){ ){ $categoryIds_all[] = $id; - //Get category doc data + // Get category doc data $categoryDocData = \ddTools::getDocument( - //id + // id $id, 'pagetitle,id,parent', - //published + // published 'all', - //deleted + // deleted 0 ); $hasParentCategory = - //If root categories are set + // If root categories are set !empty($this->categoryIds_last) && - //And it is not one of the “root” category + // And it is not one of the “root” category !in_array( $id, $this->categoryIds_last @@ -702,7 +702,7 @@ private function parse_categories(){ ]); if($hasParentCategory){ - //Get parent category + // Get parent category $result .= $getCategories($categoryDocData['parent']); } } diff --git a/src/Snippet.php b/src/Snippet.php index 9e5284a..9fd8f95 100644 --- a/src/Snippet.php +++ b/src/Snippet.php @@ -13,17 +13,17 @@ class Snippet extends \DDTools\Snippet { /** * run - * @version 1.0.1 (2023-05-02) + * @version 1.0.2 (2024-08-06) */ public function run(){ $result = ''; $input = new \ddGetDocuments\Input($this->params); - //Extenders storage + // Extenders storage $extendersStorage = []; - //Iterate through all extenders to create their instances + // Iterate through all extenders to create their instances foreach( $input->extendersParams as $extenderName => @@ -33,10 +33,10 @@ public function run(){ 'name' => $extenderName, 'params' => $extenderParams ]); - //Passing a link to the storage + // Passing a link to the storage $extendersStorage[$extenderName] = $extenderObject; - //Overwrite the data provider parameters with the result of applying them to the current extender + // Overwrite the data provider parameters with the result of applying them to the current extender $input->providerParams = $extenderObject->applyToDataProviderParams($input->providerParams); } @@ -58,7 +58,7 @@ public function run(){ $outputData = new \ddGetDocuments\Output($dataProviderResult); - //Iterate through all extenders again to apply them to the output + // Iterate through all extenders again to apply them to the output foreach( $extendersStorage as $extenderName => From 0d7ba454824f05e9887e55b2f52e5ebc6ecc81d5 Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Sat, 5 Oct 2024 14:23:53 +0400 Subject: [PATCH 11/20] * Minor changes (code style). --- ddGetDocuments_snippet.php | 6 +- .../Customdbtable/DataProvider.php | 20 +- src/DataProvider/DataProvider.php | 279 +++++++++--------- src/DataProvider/DataProviderOutput.php | 4 +- src/DataProvider/Parent/DataProvider.php | 16 +- src/DataProvider/Select/DataProvider.php | 12 +- src/Extender/Pagination/Extender.php | 166 ++++++----- src/Extender/Search/Extender.php | 36 +-- src/Extender/Tagging/Extender.php | 48 +-- src/Input.php | 90 +++--- src/Output.php | 2 +- src/Outputter/Json/Outputter.php | 38 +-- src/Outputter/Outputter.php | 14 +- src/Outputter/Sitemap/Outputter.php | 20 +- src/Outputter/String/Outputter.php | 79 ++--- src/Snippet.php | 22 +- 16 files changed, 445 insertions(+), 407 deletions(-) diff --git a/ddGetDocuments_snippet.php b/ddGetDocuments_snippet.php index bc21262..2f634b2 100644 --- a/ddGetDocuments_snippet.php +++ b/ddGetDocuments_snippet.php @@ -12,12 +12,12 @@ // Include (MODX)EvolutionCMS.libraries.ddTools require_once( - $modx->getConfig('base_path') . - 'assets/libs/ddTools/modx.ddtools.class.php' + $modx->getConfig('base_path') + . 'assets/libs/ddTools/modx.ddtools.class.php' ); return \DDTools\Snippet::runSnippet([ 'name' => 'ddGetDocuments', - 'params' => $params + 'params' => $params, ]); ?> \ No newline at end of file diff --git a/src/DataProvider/Customdbtable/DataProvider.php b/src/DataProvider/Customdbtable/DataProvider.php index 8c503d3..a16ef7a 100644 --- a/src/DataProvider/Customdbtable/DataProvider.php +++ b/src/DataProvider/Customdbtable/DataProvider.php @@ -9,7 +9,7 @@ class DataProvider extends \ddGetDocuments\DataProvider\DataProvider { /** * addResourcesFieldsToGet - * @version 1.1.1 (2020-03-10) + * @version 1.1.2 (2024-10-05) * * @param $fields {array} * @param $fields[i] {string} — Name of table column to add. @@ -20,18 +20,20 @@ public function addResourcesFieldsToGet($fields){ $existingFields = \ddTools::$modx->db->getColumn( 'Field', \ddTools::$modx->db->query( - 'SHOW COLUMNS FROM ' . - $this->resourcesTableName + 'SHOW COLUMNS FROM ' + . $this->resourcesTableName ) ); - $this->resourcesFieldsToGet->fields = array_unique(array_merge( - $this->resourcesFieldsToGet->fields, - array_intersect( - $existingFields, - $fields + $this->resourcesFieldsToGet->fields = array_unique( + array_merge( + $this->resourcesFieldsToGet->fields, + array_intersect( + $existingFields, + $fields + ) ) - )); + ); } /** diff --git a/src/DataProvider/DataProvider.php b/src/DataProvider/DataProvider.php index b51e780..0bd4284 100644 --- a/src/DataProvider/DataProvider.php +++ b/src/DataProvider/DataProvider.php @@ -18,7 +18,7 @@ abstract class DataProvider extends \DDTools\Base\Base { */ $resourcesFieldsToGet = [ 'fields' => ['id'], - 'tvs' => [] + 'tvs' => [], ], $total, $filter = '', @@ -37,7 +37,7 @@ abstract class DataProvider extends \DDTools\Base\Base { /** * __construct - * @version 2.0.1 (2024-08-06) + * @version 2.0.2 (2024-10-05) * * @param $params {stdClass|arrayAssociative} */ @@ -47,9 +47,9 @@ function __construct($params){ // Init source DB table name $this->resourcesTableName = - isset(\ddTools::$tables[$this->resourcesTableName]) ? - \ddTools::$tables[$this->resourcesTableName] : - \ddTools::$modx->getFullTableName($this->resourcesTableName) + isset(\ddTools::$tables[$this->resourcesTableName]) + ? \ddTools::$tables[$this->resourcesTableName] + : \ddTools::$modx->getFullTableName($this->resourcesTableName) ; // Init needed resources fields @@ -60,23 +60,26 @@ function __construct($params){ /** * construct_compatibilityWithOldMariaDB - * @version 1.0.2 (2024-08-06) + * @version 1.0.3 (2024-10-05) * * @todo Temporary code for compatibility with MariaDB < 10.5. This code must be removed when MariaDB 10.5 will be released. * * @return {void} */ private function construct_compatibilityWithOldMariaDB(){ - $dbVersion = \ddTools::$modx->db->getValue(\ddTools::$modx->db->query('SELECT VERSION()')); + $dbVersion = \ddTools::$modx->db->getValue( + \ddTools::$modx->db->query('SELECT VERSION()') + ); if ( // MariaDB is used stripos( $dbVersion, 'mariadb' - ) !== false && + ) + !== false // And version < 10.5 - version_compare( + && version_compare( $dbVersion, '10.5', '<' @@ -101,7 +104,7 @@ private function construct_compatibilityWithOldMariaDB(){ /** * addResourcesFieldsToGet - * @version 2.0.3 (2024-08-06) + * @version 2.0.4 (2024-10-05) * * @param $fields {array} * @param $fields[i] {string} — Name of document field or TV. @@ -111,28 +114,32 @@ private function construct_compatibilityWithOldMariaDB(){ public function addResourcesFieldsToGet($fields){ // Separate TVs and common document fields $fields = \ddTools::prepareDocData([ - 'data' => array_flip($fields) + 'data' => array_flip($fields), ]); // Save common fields if (!empty($fields->fieldsData)){ - $this->resourcesFieldsToGet->fields = array_unique(array_merge( - $this->resourcesFieldsToGet->fields, - array_keys($fields->fieldsData) - )); + $this->resourcesFieldsToGet->fields = array_unique( + array_merge( + $this->resourcesFieldsToGet->fields, + array_keys($fields->fieldsData) + ) + ); } // Save TVs if (!empty($fields->tvsData)){ - $this->resourcesFieldsToGet->tvs = array_unique(array_merge( - $this->resourcesFieldsToGet->tvs, - array_keys($fields->tvsData) - )); + $this->resourcesFieldsToGet->tvs = array_unique( + array_merge( + $this->resourcesFieldsToGet->tvs, + array_keys($fields->tvsData) + ) + ); } } /** * getResourcesDataFromDb - * @version 6.1.4 (2024-08-06) + * @version 6.1.5 (2024-10-05) * * @param $params {arrayAssociative|stdClass} * @param $params['resourcesIds'] — Document IDs to get ($this->filter will be used). Default: ''. @@ -150,11 +157,13 @@ protected final function getResourcesDataFromDb($params = []){ // Invalid query — empty result if(!empty($query)){ - $data = \ddTools::$modx->db->makeArray(\ddTools::$modx->db->query($query)); + $data = \ddTools::$modx->db->makeArray( + \ddTools::$modx->db->query($query) + ); if( - is_array($data) && - !empty($data) + is_array($data) + && !empty($data) ){ $totalFound = \ddTools::$modx->db->getValue('SELECT FOUND_ROWS()'); @@ -162,9 +171,9 @@ protected final function getResourcesDataFromDb($params = []){ if (!empty($this->resourcesFieldsToGet->tvs)){ // Get TVs values foreach ( - $data as - $docIndex => - $docValue + $data + as $docIndex + => $docValue ){ $docValue['TVs'] = json_decode( $docValue['TVs'], @@ -172,8 +181,8 @@ protected final function getResourcesDataFromDb($params = []){ ); foreach ( - $this->resourcesFieldsToGet->tvs as - $tvName + $this->resourcesFieldsToGet->tvs + as $tvName ){ // If valid TV exist if(isset($docValue['TVs'][$tvName])){ @@ -233,7 +242,7 @@ protected final function getUsedFieldsFromSqlString($sqlString){ /** * prepareUsedDocFieldsFromSqlString - * @version 3.0.4 (2024-08-06) + * @version 3.0.5 (2024-10-05) * * @param $sqlString {string_sql} * @@ -254,8 +263,8 @@ protected function prepareUsedDocFieldsFromSqlString($sqlString){ 'data' => array_flip($usedFields), // Just something 'tvAdditionalFieldsToGet' => [ - 'name' - ] + 'name', + ], ]); if(!empty($fieldsArray->fieldsData)){ @@ -268,9 +277,9 @@ protected function prepareUsedDocFieldsFromSqlString($sqlString){ // Check whether the current tv name is an actual tv name foreach( - $fieldsArray->tvsAdditionalData as - $tvName => - $tvData + $fieldsArray->tvsAdditionalData + as $tvName + => $tvData ){ // Pupulate the array with the current tv name $result->tvs[] = $tvName; @@ -287,7 +296,7 @@ protected function prepareUsedDocFieldsFromSqlString($sqlString){ /** * buildTVsSubQuery - * @version 1.0.7 (2024-08-06) + * @version 1.0.8 (2024-10-05) * * @desc A helper method to build subquery with joined TVS to make possible to use filter conditions for both fields and tvs. * @@ -305,9 +314,9 @@ protected function buildTVsSubQuery(array $tvs){ // select query $selectTvsQuery = 'SELECT `c`.*,'; $fromTvsQuery = - 'FROM ' . - $this->resourcesTableName . - ' as `c`' + 'FROM ' + . $this->resourcesTableName + . ' as `c`' ; // join query $joinTvsQuery = ''; @@ -317,73 +326,73 @@ protected function buildTVsSubQuery(array $tvs){ $tvCounter = 1; foreach( - $tvs as - $tvName + $tvs + as $tvName ){ // alias of tmplvar_templates $tvtAlias = - '`tvt_' . - $tvCounter . - '`' + '`tvt_' + . $tvCounter + . '`' ; // alias of tmplvars $tvAlias = - '`tv_' . - $tvCounter . - '`' + '`tv_' + . $tvCounter + . '`' ; // alias of tmplvar_contentvalues $tvcvAlias = - '`tvcv_' . - $tvCounter . - '`' + '`tvcv_' + . $tvCounter + . '`' ; // select not null value from either the real value column or default $selectTvsQuery .= - 'coalesce(' . - $tvcvAlias . - '.`value`, ' . - $tvAlias . - '.`default_text`) as `' . - $tvName . - '`,' + 'coalesce(' + . $tvcvAlias + . '.`value`, ' + . $tvAlias + . '.`default_text`) as `' + . $tvName + . '`,' ; $joinTvsQuery .= - ' LEFT JOIN ' . - \ddTools::$tables['site_tmplvar_templates'] . - ' AS ' . - $tvtAlias . - ' ON ' . - $tvtAlias . - '.`templateid` = `c`.`template`' . - ' LEFT JOIN ' . - \ddTools::$tables['site_tmplvars'] . - ' AS ' . - $tvAlias . - ' ON ' . - $tvAlias . - '.`id` = ' . - $tvtAlias . - '.`tmplvarid`' . - ' LEFT JOIN ' . - \ddTools::$tables['site_tmplvar_contentvalues'] . - ' AS ' . - $tvcvAlias . - ' ON ' . - $tvcvAlias . - '.`contentid` = `c`.`id` AND ' . - $tvcvAlias . - '.`tmplvarid` = ' . - $tvAlias . - '.`id`' + ' LEFT JOIN ' + . \ddTools::$tables['site_tmplvar_templates'] + . ' AS ' + . $tvtAlias + . ' ON ' + . $tvtAlias + . '.`templateid` = `c`.`template`' + . ' LEFT JOIN ' + . \ddTools::$tables['site_tmplvars'] + . ' AS ' + . $tvAlias + . ' ON ' + . $tvAlias + . '.`id` = ' + . $tvtAlias + . '.`tmplvarid`' + . ' LEFT JOIN ' + . \ddTools::$tables['site_tmplvar_contentvalues'] + . ' AS ' + . $tvcvAlias + . ' ON ' + . $tvcvAlias + . '.`contentid` = `c`.`id` AND ' + . $tvcvAlias + . '.`tmplvarid` = ' + . $tvAlias + . '.`id`' ; $whereTvsQuery .= - $tvAlias . - '.`name` = "' . - $tvName . - '" AND' + $tvAlias + . '.`name` = "' + . $tvName + . '" AND' ; $tvCounter++; @@ -394,8 +403,8 @@ protected function buildTVsSubQuery(array $tvs){ ',' ); $whereTvsQuery = - 'WHERE ' . - trim( + 'WHERE ' + . trim( $whereTvsQuery, ' AND' ) @@ -403,19 +412,19 @@ protected function buildTVsSubQuery(array $tvs){ // complete from query return - $selectTvsQuery . - ' ' . - $fromTvsQuery . - ' ' . - $joinTvsQuery . - ' ' . - $whereTvsQuery + $selectTvsQuery + . ' ' + . $fromTvsQuery + . ' ' + . $joinTvsQuery + . ' ' + . $whereTvsQuery ; } /** * prepareQueryData_fromAndFilter - * @version 3.0.2 (2024-08-06) + * @version 3.0.3 (2024-10-05) * * @param $filterStr {string} — Filter string. @required * @@ -427,7 +436,7 @@ protected final function prepareQueryData_fromAndFilter($filterStr){ $result = (object) [ // By default, the required data is just fetched from the site_content table 'from' => $this->resourcesTableName, - 'filter' => '' + 'filter' => '', ]; // If a filter is set, it is needed to check which TVs are used in the filter query @@ -438,16 +447,16 @@ protected final function prepareQueryData_fromAndFilter($filterStr){ if(!empty($usedFields->tvs)){ // complete from query $result->from = - '(' . - $this->buildTVsSubQuery($usedFields->tvs) . - ')' + '(' + . $this->buildTVsSubQuery($usedFields->tvs) + . ')' ; } $result->filter = - '(' . - $filterStr . - ')' + '(' + . $filterStr + . ')' ; } @@ -456,7 +465,7 @@ protected final function prepareQueryData_fromAndFilter($filterStr){ /** * prepareQueryData - * @version 2.2.1 (2024-08-06) + * @version 2.2.2 (2024-10-05) * * @param $params {arrayAssociative|stdClass} * @param $params['resourcesIds'] — Document IDs to get. Default: ''. @@ -472,7 +481,7 @@ protected final function prepareQueryData($params = []){ // Defaults $params = (object) array_merge( [ - 'resourcesIds' => '' + 'resourcesIds' => '', ], (array) $params ); @@ -489,30 +498,30 @@ protected final function prepareQueryData($params = []){ if(!empty($this->groupBy)){ $result->groupBy = - 'GROUP BY ' . - $this->groupBy + 'GROUP BY ' + . $this->groupBy ; } if(!empty($this->orderBy)){ $result->orderBy = - 'ORDER BY ' . - $this->orderBy + 'ORDER BY ' + . $this->orderBy ; } // If LIMIT needed if ( - !empty($this->offset) || - !empty($this->total) + !empty($this->offset) + || !empty($this->total) ){ $result->limit = 'LIMIT '; // Prepare offset if (!empty($this->offset)){ $result->limit .= - $this->offset . - ',' + $this->offset + . ',' ; } @@ -527,15 +536,15 @@ protected final function prepareQueryData($params = []){ if(!empty($params->resourcesIds)){ $result->where .= - '`resources`.`id` IN (' . - $params->resourcesIds . - ')' + '`resources`.`id` IN (' + . $params->resourcesIds + . ')' ; - + if(!empty($fromAndFilterQueries->filter)){ $result->where .= - ' AND ' . - $fromAndFilterQueries->filter + ' AND ' + . $fromAndFilterQueries->filter ; } }else{ @@ -544,8 +553,8 @@ protected final function prepareQueryData($params = []){ if (!empty($result->where)){ $result->where = - 'WHERE ' . - $result->where + 'WHERE ' + . $result->where ; } @@ -554,7 +563,7 @@ protected final function prepareQueryData($params = []){ /** * prepareQuery - * @version 1.4.2 (2024-08-06) + * @version 1.4.3 (2024-10-05) * * @param $params {arrayAssociative|stdClass} * @param $params['resourcesIds'] — Document IDs to get ($this->filter will be used). Default: ''. @@ -565,7 +574,7 @@ protected function prepareQuery($params = []){ // Defaults $params = (object) array_merge( [ - 'resourcesIds' => '' + 'resourcesIds' => '', ], (array) $params ); @@ -609,17 +618,17 @@ protected function prepareQuery($params = []){ } $result .= - 'FROM ' . - $queryData->from . - ' AS `resources` ' . - $queryData->where . - ' ' . - $queryData->groupBy . - ' ' . - $queryData->orderBy . - ' ' . - $queryData->limit . - ' ' + 'FROM ' + . $queryData->from + . ' AS `resources` ' + . $queryData->where + . ' ' + . $queryData->groupBy + . ' ' + . $queryData->orderBy + . ' ' + . $queryData->limit + . ' ' ; } diff --git a/src/DataProvider/DataProviderOutput.php b/src/DataProvider/DataProviderOutput.php index 3c34f04..92800e7 100644 --- a/src/DataProvider/DataProviderOutput.php +++ b/src/DataProvider/DataProviderOutput.php @@ -10,7 +10,7 @@ class DataProviderOutput { /** * __construct - * @version 1.0.1 (2018-06-12) + * @version 1.0.2 (2024-10-05) * * @param $items {array} * @param $totalFound {integer|null} @@ -26,7 +26,7 @@ public function __construct( public function toArray(){ return [ 'items' => $this->items, - 'totalFound' => $this->totalFound + 'totalFound' => $this->totalFound, ]; } } \ No newline at end of file diff --git a/src/DataProvider/Parent/DataProvider.php b/src/DataProvider/Parent/DataProvider.php index 7c03e15..a954994 100644 --- a/src/DataProvider/Parent/DataProvider.php +++ b/src/DataProvider/Parent/DataProvider.php @@ -44,7 +44,7 @@ public function __construct($params){ /** * get - * @version 2.0.10 (2024-08-06) + * @version 2.0.11 (2024-10-05) * * @return {\ddGetDocuments\DataProvider\DataProviderOutput} */ @@ -56,12 +56,14 @@ public function get(){ if (!empty($this->excludeIds)){ $excludeIdsStr = - 'AND `id` NOT IN (' . - trim(implode( - ',', - $this->excludeIds - )) . - ')' + 'AND `id` NOT IN (' + . trim( + implode( + ',', + $this->excludeIds + ) + ) + . ')' ; }else{ $excludeIdsStr = ''; diff --git a/src/DataProvider/Select/DataProvider.php b/src/DataProvider/Select/DataProvider.php index 54e760b..9063a93 100644 --- a/src/DataProvider/Select/DataProvider.php +++ b/src/DataProvider/Select/DataProvider.php @@ -11,20 +11,20 @@ class DataProvider extends \ddGetDocuments\DataProvider\DataProvider { /** * get - * @version 1.0.8 (2024-08-06) + * @version 1.0.9 (2024-10-05) * * @return {\ddGetDocuments\DataProvider\DataProviderOutput} */ public function get(){ // Order by selected IDs sequence if ( - empty($this->orderBy) && - !empty($this->ids) + empty($this->orderBy) + && !empty($this->ids) ){ $this->orderBy = - 'FIELD (`resources`.`id`,' . - $this->ids . - ')' + 'FIELD (`resources`.`id`,' + . $this->ids + . ')' ; } diff --git a/src/Extender/Pagination/Extender.php b/src/Extender/Pagination/Extender.php index 4355755..e15a003 100644 --- a/src/Extender/Pagination/Extender.php +++ b/src/Extender/Pagination/Extender.php @@ -43,7 +43,7 @@ class Extender extends \ddGetDocuments\Extender\Extender { /** * __construct - * @version 1.2.4 (2024-08-06) + * @version 1.2.5 (2024-10-05) * * @param $params {stdClass|arrayAssociative} */ @@ -60,22 +60,22 @@ public function __construct($params = []){ 'nextOffTpl', 'previousTpl', 'previousOffTpl' - ] as - $tplName + ] + as $tplName ){ $this->{$tplName} = \ddTools::getTpl($this->{$tplName}); } $this->pageIndex = - isset($_REQUEST[$this->pageIndexRequestParamName]) ? - (int) $_REQUEST[$this->pageIndexRequestParamName] : - 1 + isset($_REQUEST[$this->pageIndexRequestParamName]) + ? (int) $_REQUEST[$this->pageIndexRequestParamName] + : 1 ; } /** * applyToDataProviderParams - * @version 1.0.1 (2024-08-06) + * @version 1.0.2 (2024-10-05) * * @param $dataProviderParams {stdClass} * @@ -86,10 +86,10 @@ public function applyToDataProviderParams($dataProviderParams){ if(isset($dataProviderParams->total)){ $dataProviderParams->offset = ( - $this->pageIndex - - 1 - ) * - $dataProviderParams->total + $this->pageIndex + - 1 + ) + * $dataProviderParams->total ; } @@ -100,7 +100,7 @@ public function applyToDataProviderParams($dataProviderParams){ /** * applyToOutput - * @version 1.2.4 (2024-08-06) + * @version 1.2.5 (2024-10-05) * * @param $dataProviderOutput {\ddGetDocuments\DataProvider\DataProviderOutput} * @@ -112,8 +112,8 @@ public function applyToOutput(\ddGetDocuments\DataProvider\DataProviderOutput $d // Check to prevent division by zero if($this->dataProviderParams->total != 0){ $pagesTotal = ceil( - $dataProviderOutput->totalFound / - $this->dataProviderParams->total + $dataProviderOutput->totalFound + / $this->dataProviderParams->total ); if($pagesTotal > 1){ @@ -137,8 +137,8 @@ public function applyToOutput(\ddGetDocuments\DataProvider\DataProviderOutput $d if (count($currentQuery) > 0){ $urlPrefix .= - http_build_query($currentQuery) . - '&' + http_build_query($currentQuery) + . '&' ; } } @@ -164,77 +164,85 @@ public function applyToOutput(\ddGetDocuments\DataProvider\DataProviderOutput $d $pageChunk = $this->currentPageTpl; } - $pagesOutputText .= \ddTools::parseSource(\ddTools::parseText([ - 'text' => $pageChunk, - 'data' => [ - 'url' => - $urlPrefix . - $this->pageIndexRequestParamName . - '=' . - $pageIndex - , - 'page' => $pageIndex - ] - ])); + $pagesOutputText .= \ddTools::parseSource( + \ddTools::parseText([ + 'text' => $pageChunk, + 'data' => [ + 'url' => + $urlPrefix + . $this->pageIndexRequestParamName + . '=' + . $pageIndex + , + 'page' => $pageIndex, + ], + ]) + ); } $previousLinkChunk = - $this->pageIndex == 1 ? - $this->previousOffTpl : - $this->previousTpl + $this->pageIndex == 1 + ? $this->previousOffTpl + : $this->previousTpl ; $nextLinkChunk = - $this->pageIndex == $pagesTotal ? - $this->nextOffTpl : - $this->nextTpl + $this->pageIndex == $pagesTotal + ? $this->nextOffTpl + : $this->nextTpl ; - $result = \ddTools::parseSource(\ddTools::parseText([ - 'text' => $this->wrapperTpl, - 'data' => [ - 'previous' => \ddTools::parseSource(\ddTools::parseText([ - 'text' => $previousLinkChunk, - 'data' => [ - 'url' => - $this->pageIndex == 1 ? - '' : - ( - $urlPrefix . - $this->pageIndexRequestParamName . - '=' . - ( - $this->pageIndex - - 1 - ) - ) - , - 'totalPages' => $pagesTotal - ] - ])), - 'pages' => $pagesOutputText, - 'next' => \ddTools::parseSource(\ddTools::parseText([ - 'text' => $nextLinkChunk, - 'data' => [ - 'url' => - $this->pageIndex == $pagesTotal ? - '' : - ( - $urlPrefix . - $this->pageIndexRequestParamName . - '=' . - ( - $this->pageIndex + - 1 - ) - ) - , - 'totalPages' => $pagesTotal - ] - ])), - 'totalPages' => $pagesTotal - ] - ])); + $result = \ddTools::parseSource( + \ddTools::parseText([ + 'text' => $this->wrapperTpl, + 'data' => [ + 'previous' => \ddTools::parseSource( + \ddTools::parseText([ + 'text' => $previousLinkChunk, + 'data' => [ + 'url' => + $this->pageIndex == 1 + ? '' + : ( + $urlPrefix + . $this->pageIndexRequestParamName + . '=' + . ( + $this->pageIndex + - 1 + ) + ) + , + 'totalPages' => $pagesTotal, + ], + ]) + ), + 'pages' => $pagesOutputText, + 'next' => \ddTools::parseSource( + \ddTools::parseText([ + 'text' => $nextLinkChunk, + 'data' => [ + 'url' => + $this->pageIndex == $pagesTotal + ? '' + : ( + $urlPrefix + . $this->pageIndexRequestParamName + . '=' + . ( + $this->pageIndex + + 1 + ) + ) + , + 'totalPages' => $pagesTotal, + ], + ]) + ), + 'totalPages' => $pagesTotal, + ], + ]) + ); } } diff --git a/src/Extender/Search/Extender.php b/src/Extender/Search/Extender.php index 89c0f6c..220d0cc 100644 --- a/src/Extender/Search/Extender.php +++ b/src/Extender/Search/Extender.php @@ -10,13 +10,13 @@ class Extender extends \ddGetDocuments\Extender\Extender { protected $docFieldsToSearch = [ 'pagetitle', - 'content' + 'content', ] ; /** * __construct - * @version 1.1.1 (2024-08-06) + * @version 1.1.2 (2024-10-05) * * @param $params {stdClass|arrayAssociative} * @param $params->docFieldsToSearch {array|stringCommaSepareted} — Document fields to search in. Default: ['pagetitle', 'content']. @@ -33,13 +33,15 @@ public function __construct($params = []){ } if (isset($_REQUEST['query'])){ - $this->currentQuery = trim(\ddTools::$modx->db->escape($_REQUEST['query'])); + $this->currentQuery = trim( + \ddTools::$modx->db->escape($_REQUEST['query']) + ); } } /** * applyToDataProviderParams - * @version 1.0.1 (2024-08-06) + * @version 1.0.2 (2024-10-05) * * @param $dataProviderParams {stdClass} * @@ -51,21 +53,21 @@ public function applyToDataProviderParams($dataProviderParams){ $searchQueries = []; foreach ( - $this->docFieldsToSearch as - $docField + $this->docFieldsToSearch + as $docField ){ $searchQueries[] = - '`' . - trim($docField) . - '` LIKE("%' . - $this->currentQuery . - '%")' + '`' + . trim($docField) + . '` LIKE("%' + . $this->currentQuery + . '%")' ; } if( - isset($dataProviderParams->filter) && - trim($dataProviderParams->filter) != '' + isset($dataProviderParams->filter) + && trim($dataProviderParams->filter) != '' ){ $dataProviderParams->filter .= ' AND'; }else{ @@ -73,12 +75,12 @@ public function applyToDataProviderParams($dataProviderParams){ } $dataProviderParams->filter .= - ' (' . - implode( + ' (' + . implode( ' OR ', $searchQueries - ) . - ')' + ) + . ')' ; } diff --git a/src/Extender/Tagging/Extender.php b/src/Extender/Tagging/Extender.php index 45b4039..c826dc0 100644 --- a/src/Extender/Tagging/Extender.php +++ b/src/Extender/Tagging/Extender.php @@ -19,7 +19,7 @@ class Extender extends \ddGetDocuments\Extender\Extender { /** * __construct - * @version 1.1.3 (2024-08-06) + * @version 1.1.4 (2024-10-05) * * @param $params {stdClass|arrayAssociative} * @param $params->tagsDocumentField {stringTvName} — The document field (TV) contains tags. Default: 'tags'. @@ -44,9 +44,9 @@ public function __construct($params = []){ } foreach ( - $this->currentTags as - $index => - $value + $this->currentTags + as $index + => $value ){ $this->currentTags[$index] = \ddTools::$modx->db->escape($value); } @@ -55,7 +55,7 @@ public function __construct($params = []){ /** * applyToDataProviderParams - * @version 1.0.1 (2024-08-06) + * @version 1.0.2 (2024-10-05) * * @param $dataProviderParams {stdClass} * @@ -65,8 +65,8 @@ public function applyToDataProviderParams($dataProviderParams){ // If URL contains tags if (!empty($this->currentTags)){ if( - isset($dataProviderParams->filter) && - trim($dataProviderParams->filter) != '' + isset($dataProviderParams->filter) + && trim($dataProviderParams->filter) != '' ){ $dataProviderParams->filter .= ' AND'; }else{ @@ -76,29 +76,29 @@ public function applyToDataProviderParams($dataProviderParams){ $tagQueries = []; foreach ( - $this->currentTags as - $currentTag + $this->currentTags + as $currentTag ){ $tagQueries[] = - '`' . - $this->tagsDocumentField . - '` REGEXP "(^|' . - $this->tagsDelimiter . - ')' . - $currentTag . - '($|' . - $this->tagsDelimiter . - ')"' + '`' + . $this->tagsDocumentField + . '` REGEXP "(^|' + . $this->tagsDelimiter + . ')' + . $currentTag + . '($|' + . $this->tagsDelimiter + . ')"' ; } $dataProviderParams->filter .= - ' (' . - implode( + ' (' + . implode( ' OR ', $tagQueries - ) . - ')' + ) + . ')' ; } @@ -107,7 +107,7 @@ public function applyToDataProviderParams($dataProviderParams){ /** * applyToOutput - * @version 1.0.3 (2020-10-02) + * @version 1.0.4 (2024-10-05) * * @param $dataProviderOutput {\ddGetDocuments\DataProvider\DataProviderOutput} * @@ -115,7 +115,7 @@ public function applyToDataProviderParams($dataProviderParams){ */ public function applyToOutput(\ddGetDocuments\DataProvider\DataProviderOutput $dataProviderOutput){ return [ - 'currentTags' => $this->currentTags + 'currentTags' => $this->currentTags, ]; } } \ No newline at end of file diff --git a/src/Input.php b/src/Input.php index 1f66252..20645fa 100644 --- a/src/Input.php +++ b/src/Input.php @@ -19,7 +19,7 @@ class Input extends \DDTools\Base\Base { 'filter' => '', 'offset' => 0, 'total' => NULL, - 'orderBy' => '' + 'orderBy' => '', ], /** @@ -40,7 +40,7 @@ class Input extends \DDTools\Base\Base { /** * __construct - * @version 4.5.1 (2024-08-06) + * @version 4.5.2 (2024-10-05) * * @param $snippetParams {stdClass} — The object of parameters. @required * @param $snippetParams->providerParams {stdClass|arrayAssociative|stringJsonObject} @@ -53,9 +53,9 @@ public function __construct($snippetParams){ [ 'providerParams', 'outputterParams', - 'extendersParams' - ] as - $paramName + 'extendersParams', + ] + as $paramName ){ // Convert to object $this->{$paramName} = (object) $this->{$paramName}; @@ -63,7 +63,7 @@ public function __construct($snippetParams){ if ( \DDTools\ObjectTools::isPropExists([ 'object' => $snippetParams, - 'propName' => $paramName + 'propName' => $paramName, ]) ){ $this->{$paramName} = \DDTools\ObjectTools::extend([ @@ -73,9 +73,9 @@ public function __construct($snippetParams){ // Given parameters \DDTools\ObjectTools::convertType([ 'object' => $snippetParams->{$paramName}, - 'type' => 'objectStdClass' - ]) - ] + 'type' => 'objectStdClass', + ]), + ], ]); } @@ -104,9 +104,9 @@ public function __construct($snippetParams){ [ 'filter', 'groupBy', - 'orderBy' - ] as - $paramName + 'orderBy', + ] + as $paramName ){ $this->providerParams->{$paramName} = str_replace( $this->fieldDelimiter, @@ -118,7 +118,7 @@ public function __construct($snippetParams){ /** * prepareExtendersParams - * @version 3.0.1 (2024-08-06) + * @version 3.0.2 (2024-10-05) * * @desc Prepare extenders params. * @@ -130,7 +130,7 @@ private function prepareExtendersParams($snippetParams){ if ( \DDTools\ObjectTools::isPropExists([ 'object' => $snippetParams, - 'propName' => 'extenders' + 'propName' => 'extenders', ]) ){ // Prepare extenders @@ -153,23 +153,23 @@ private function prepareExtendersParams($snippetParams){ if( !\DDTools\ObjectTools::isPropExists([ 'object' => $this->extendersParams, - 'propName' => $snippetParams->extenders[0] + 'propName' => $snippetParams->extenders[0], ]) ){ $this->extendersParams = (object) [ - $snippetParams->extenders[0] => $this->extendersParams + $snippetParams->extenders[0] => $this->extendersParams, ]; } }else{ // Make sure that for each extender there is an item in $this->extendersParams foreach( - $snippetParams->extenders as - $extenderName + $snippetParams->extenders + as $extenderName ){ if( !\DDTools\ObjectTools::isPropExists([ 'object' => $this->extendersParams, - 'propName' => $extenderName + 'propName' => $extenderName, ]) ){ $this->extendersParams->{$extenderName} = (object) []; @@ -182,7 +182,7 @@ private function prepareExtendersParams($snippetParams){ /** * backwardCompatibility_dataProviderParams - * @version 2.0.1 (2024-08-06) + * @version 2.0.2 (2024-10-05) * * @desc Prepare data provider params preserve backward compatibility. * @@ -197,14 +197,14 @@ private function backwardCompatibility_dataProviderParams($snippetParams){ 'filter', 'offset', 'total', - 'orderBy' - ] as - $paramName + 'orderBy', + ] + as $paramName ){ if ( \DDTools\ObjectTools::isPropExists([ 'object' => $snippetParams, - 'propName' => $paramName + 'propName' => $paramName, ]) ){ $this->providerParams->{$paramName} = $snippetParams->{$paramName}; @@ -214,7 +214,7 @@ private function backwardCompatibility_dataProviderParams($snippetParams){ /** * backwardCompatibility_outputterParams - * @version 1.1 (2021-07-18) + * @version 1.1.1 (2024-10-05) * * @desc Prepare data provider params preserve backward compatibility. * @@ -228,14 +228,14 @@ private function backwardCompatibility_outputterParams(){ 'itemFirst' => 'itemTplFirst', 'itemLast' => 'itemTplLast', 'wrapper' => 'wrapperTpl', - 'noResults' => 'noResults' + 'noResults' => 'noResults', ]); break; case 'sitemap': $this->backwardCompatibility_outputterParams_moveTemplates([ 'item' => 'itemTpl', - 'wrapper' => 'wrapperTpl' + 'wrapper' => 'wrapperTpl', ]); break; @@ -247,7 +247,7 @@ private function backwardCompatibility_outputterParams(){ /** * backwardCompatibility_outputterParams_moveTemplates - * @version 1.0.1 (2024-08-06) + * @version 1.0.2 (2024-10-05) * * @desc Moves required templates from $this->outputterParams to $this->outputterParams->templates. * @@ -261,20 +261,20 @@ private function backwardCompatibility_outputterParams_moveTemplates($compliance // If required templates is not set, then we need to provide backward compatibility !\DDTools\ObjectTools::isPropExists([ 'object' => $this->outputterParams, - 'propName' => 'templates' + 'propName' => 'templates', ]) ){ $this->outputterParams->templates = (object) []; foreach( - $complianceArray as - $newName => - $oldName + $complianceArray + as $newName + => $oldName ){ if ( \DDTools\ObjectTools::isPropExists([ 'object' => $this->outputterParams, - 'propName' => $oldName + 'propName' => $oldName, ]) ){ $this->outputterParams->templates->{$newName} = $this->outputterParams->{$oldName}; @@ -287,7 +287,7 @@ private function backwardCompatibility_outputterParams_moveTemplates($compliance /** * backwardCompatibility_outputterParams_yandexmarket - * @version 1.0.1 (2024-08-06) + * @version 1.0.2 (2024-10-05) * * @return {void} */ @@ -305,12 +305,12 @@ private function backwardCompatibility_outputterParams_yandexmarket(){ $this->outputterParams->templates = (object) []; foreach ( - $this->outputterParams as - $paramName => - $paramValue + $this->outputterParams + as $paramName + => $paramValue ){ - $targetGroupName = NULL; - $targetParamName = NULL; + $targetGroupName = null; + $targetParamName = null; // $this->outputterParams->shopData if ( @@ -318,9 +318,11 @@ private function backwardCompatibility_outputterParams_yandexmarket(){ $paramName, 0, 9 - ) == 'shopData_' + ) + == 'shopData_' ){ $targetGroupName = 'shopData'; + $targetParamName = substr( $paramName, 9 @@ -331,9 +333,11 @@ private function backwardCompatibility_outputterParams_yandexmarket(){ $paramName, 0, 12 - ) == 'offerFields_' + ) + == 'offerFields_' ){ $targetGroupName = 'offerFields'; + $targetParamName = substr( $paramName, 12 @@ -344,9 +348,11 @@ private function backwardCompatibility_outputterParams_yandexmarket(){ $paramName, 0, 10 - ) == 'templates_' + ) + == 'templates_' ){ $targetGroupName = 'offerFields'; + $targetParamName = substr( $paramName, 10 diff --git a/src/Output.php b/src/Output.php index 638f86f..f110bdc 100644 --- a/src/Output.php +++ b/src/Output.php @@ -22,7 +22,7 @@ public final function __construct(\ddGetDocuments\DataProvider\DataProviderOutpu public final function toArray(){ return [ 'provider' => $this->provider->toArray(), - 'extenders' => $this->extenders + 'extenders' => $this->extenders, ]; } } \ No newline at end of file diff --git a/src/Outputter/Json/Outputter.php b/src/Outputter/Json/Outputter.php index ff53631..b042ac2 100644 --- a/src/Outputter/Json/Outputter.php +++ b/src/Outputter/Json/Outputter.php @@ -7,7 +7,7 @@ class Outputter extends \ddGetDocuments\Outputter\Outputter { /** * parse - * @version 2.3.1 (2024-08-06) + * @version 2.3.2 (2024-10-05) * * @param $data {Output} * @@ -18,15 +18,15 @@ public function parse(Output $data){ // Пройдемся по полученным данным foreach( - $data->provider->items as - $itemData + $data->provider->items + as $itemData ){ $result_item = []; // Result must contains only specified fields foreach( - $this->docFields as - $docField + $this->docFields + as $docField ){ $result_item[$docField] = $itemData[$docField]; @@ -34,20 +34,24 @@ public function parse(Output $data){ if ( \DDTools\ObjectTools::isPropExists([ 'object' => $this->templates, - 'propName' => $docField + 'propName' => $docField, ]) ){ - $result_item[$docField] = \ddTools::parseSource(\ddTools::parseText([ - 'text' => $this->templates->{$docField}, - 'data' => \DDTools\ObjectTools::extend([ - 'objects' => [ - $itemData, - [ - 'value' => $result_item[$docField] - ] - ] - ]) - ])); + $result_item[$docField] = + \ddTools::parseSource( + \ddTools::parseText([ + 'text' => $this->templates->{$docField}, + 'data' => \DDTools\ObjectTools::extend([ + 'objects' => [ + $itemData, + [ + 'value' => $result_item[$docField], + ] + ], + ]), + ]) + ) + ; } } diff --git a/src/Outputter/Outputter.php b/src/Outputter/Outputter.php index d8fecb1..3a86a82 100644 --- a/src/Outputter/Outputter.php +++ b/src/Outputter/Outputter.php @@ -57,7 +57,7 @@ public function __construct($params = []){ /** * construct_prepareFields_templates - * @version 1.0.2 (2024-08-06) + * @version 1.0.3 (2024-10-05) * * @param $params {stdClass|arrayAssociative} — See __construct. */ @@ -68,22 +68,22 @@ protected function construct_prepareFields_templates($params){ if ( \DDTools\ObjectTools::isPropExists([ 'object' => $params, - 'propName' => 'templates' + 'propName' => 'templates', ]) ){ // Extend defaults $this->templates = \DDTools\ObjectTools::extend([ 'objects' => [ $this->templates, - $params->templates - ] + $params->templates, + ], ]); } foreach ( - $this->templates as - $templateName => - $templateValue + $this->templates + as $templateName + => $templateValue ){ // Exclude null values if (is_string($templateValue)){ diff --git a/src/Outputter/Sitemap/Outputter.php b/src/Outputter/Sitemap/Outputter.php index c81ba7f..86e022e 100644 --- a/src/Outputter/Sitemap/Outputter.php +++ b/src/Outputter/Sitemap/Outputter.php @@ -10,7 +10,7 @@ class Outputter extends \ddGetDocuments\Outputter\Outputter { $changefreqTVName = 'general_seo_sitemap_changefreq', $templates = [ 'item' => '[(site_url)][~[+id+]~][+editedon+][+[+priorityTVName+]+][+[+changefreqTVName+]+]', - 'wrapper' => '[+ddGetDocuments_items+]' + 'wrapper' => '[+ddGetDocuments_items+]', ] ; @@ -20,7 +20,7 @@ class Outputter extends \ddGetDocuments\Outputter\Outputter { /** * __construct - * @version 2.0.3 (2024-08-06) + * @version 2.0.4 (2024-10-05) * * @param $params {stdClass|arrayAssociative} * @param $params->priorityTVName {stringTvName} — Name of TV which sets the relative priority of the document. Default: 'general_seo_sitemap_priority'. @@ -38,14 +38,14 @@ public function __construct($params = []){ 'text' => $this->templates->item, 'data' => [ 'priorityTVName' => $this->priorityTVName, - 'changefreqTVName' => $this->changefreqTVName + 'changefreqTVName' => $this->changefreqTVName, ], - 'isCompletelyParsingEnabled' => false + 'isCompletelyParsingEnabled' => false, ]); // We use the “String” Outputter as base $outputter_StringParams = (object) [ - 'templates' => $this->templates + 'templates' => $this->templates, ]; // Transfer provider link if (isset($params->dataProvider)){ @@ -53,13 +53,13 @@ public function __construct($params = []){ } $this->outputter_StringInstance = \ddGetDocuments\Outputter\Outputter::createChildInstance([ 'name' => 'String', - 'params' => $outputter_StringParams + 'params' => $outputter_StringParams, ]); } /** * parse - * @version 1.1.3 (2024-08-06) + * @version 1.1.4 (2024-10-05) * * @param $data {Output} * @@ -67,9 +67,9 @@ public function __construct($params = []){ */ public function parse(Output $data){ foreach ( - $data->provider->items as - $docIndex => - $docData + $data->provider->items + as $docIndex + => $docData ){ // Convert date to appropriate format if (isset($data->provider->items[$docIndex]['editedon'])){ diff --git a/src/Outputter/String/Outputter.php b/src/Outputter/String/Outputter.php index 100605d..514e933 100644 --- a/src/Outputter/String/Outputter.php +++ b/src/Outputter/String/Outputter.php @@ -15,14 +15,14 @@ class Outputter extends \ddGetDocuments\Outputter\Outputter { 'itemFirst' => null, 'itemLast' => null, 'wrapper' => null, - 'noResults' => null + 'noResults' => null, ], $itemGlue = '' ; /** * construct_prepareFields_templates - * @version 1.0.1 (2024-08-06) + * @version 1.0.2 (2024-10-05) * * @param $params {stdClass|arrayAssociative} — @required * @param $params->templates {stdClass|arrayAssociative} — Templates. @required @@ -57,14 +57,14 @@ protected function construct_prepareFields_templates($params){ } $this->docFields = \ddTools::getPlaceholdersFromText([ - 'text' => $textToGetPlaceholdersFrom + 'text' => $textToGetPlaceholdersFrom, ]); } } /** * parse - * @version 2.1.5 (2024-08-06) + * @version 2.1.6 (2024-10-05) * * @param $data {Output} * @@ -78,14 +78,14 @@ public function parse(Output $data){ $generalPlaceholders = [ 'total' => $total, - 'totalFound' => $data->provider->totalFound + 'totalFound' => $data->provider->totalFound, ]; $generalPlaceholders = \DDTools\ObjectTools::extend([ 'objects' => [ $generalPlaceholders, - $this->placeholders - ] + $this->placeholders, + ], ]); if(isset($data->extenders)){ @@ -93,24 +93,25 @@ public function parse(Output $data){ 'objects' => [ $generalPlaceholders, [ - 'extenders' => $data->extenders - ] - ] + 'extenders' => $data->extenders, + ], + ], ]); $generalPlaceholders = \ddTools::unfoldArray($generalPlaceholders); } if( - is_array($data->provider->items) && + is_array($data->provider->items) // Item template is set - $this->templates->item !== null + && $this->templates->item !== null ){ $maxIndex = $total - 1; // Foreach items foreach( - $data->provider->items as - $index => $item + $data->provider->items + as $index + => $item ){ // Prepare item output template if($index == 0){ @@ -121,19 +122,21 @@ public function parse(Output $data){ $chunkName = $this->templates->item; } - $resultItems[] = \ddTools::parseSource(\ddTools::parseText([ - 'text' => $chunkName, - 'data' => \DDTools\ObjectTools::extend([ - 'objects' => [ - $item, - $generalPlaceholders, - [ - 'itemNumber' => $index + 1, - 'itemNumberZeroBased' => $index - ] - ] + $resultItems[] = \ddTools::parseSource( + \ddTools::parseText([ + 'text' => $chunkName, + 'data' => \DDTools\ObjectTools::extend([ + 'objects' => [ + $item, + $generalPlaceholders, + [ + 'itemNumber' => $index + 1, + 'itemNumberZeroBased' => $index, + ], + ], + ]), ]) - ])); + ); } } @@ -144,14 +147,16 @@ public function parse(Output $data){ // If no items found and “noResults” is not empty if( - $total == 0 && - $this->templates->noResults !== null && - $this->templates->noResults != '' + $total == 0 + && $this->templates->noResults !== null + && $this->templates->noResults != '' ){ - $result = \ddTools::parseSource(\ddTools::parseText([ - 'text' => $this->templates->noResults, - 'data' => $generalPlaceholders - ])); + $result = \ddTools::parseSource( + \ddTools::parseText([ + 'text' => $this->templates->noResults, + 'data' => $generalPlaceholders, + ]) + ); }elseif($this->templates->wrapper !== null){ $result = \ddTools::parseText([ 'text' => $this->templates->wrapper, @@ -159,10 +164,10 @@ public function parse(Output $data){ 'objects' => [ $generalPlaceholders, [ - 'ddGetDocuments_items' => $result - ] - ] - ]) + 'ddGetDocuments_items' => $result, + ], + ], + ]), ]); } diff --git a/src/Snippet.php b/src/Snippet.php index 9fd8f95..3917909 100644 --- a/src/Snippet.php +++ b/src/Snippet.php @@ -7,13 +7,13 @@ class Snippet extends \DDTools\Snippet { $renamedParamsCompliance = [ 'outputter' => 'outputFormat', - 'outputterParams' => 'outputFormatParams' + 'outputterParams' => 'outputFormatParams', ] ; /** * run - * @version 1.0.2 (2024-08-06) + * @version 1.0.3 (2024-10-05) */ public function run(){ $result = ''; @@ -25,13 +25,13 @@ public function run(){ // Iterate through all extenders to create their instances foreach( - $input->extendersParams as - $extenderName => - $extenderParams + $input->extendersParams + as $extenderName + => $extenderParams ){ $extenderObject = \ddGetDocuments\Extender\Extender::createChildInstance([ 'name' => $extenderName, - 'params' => $extenderParams + 'params' => $extenderParams, ]); // Passing a link to the storage $extendersStorage[$extenderName] = $extenderObject; @@ -42,7 +42,7 @@ public function run(){ $dataProviderObject = \ddGetDocuments\DataProvider\DataProvider::createChildInstance([ 'name' => $input->provider, - 'params' => $input->providerParams + 'params' => $input->providerParams, ]); if ($input->outputter != 'raw'){ @@ -50,7 +50,7 @@ public function run(){ $outputterObject = \ddGetDocuments\Outputter\Outputter::createChildInstance([ 'name' => $input->outputter, - 'params' => $input->outputterParams + 'params' => $input->outputterParams, ]); } @@ -60,9 +60,9 @@ public function run(){ // Iterate through all extenders again to apply them to the output foreach( - $extendersStorage as - $extenderName => - $extenderObject + $extendersStorage + as $extenderName + => $extenderObject ){ $outputData->extenders[$extenderName] = $extenderObject->applyToOutput($dataProviderResult); } From 4fbd273ed031c5d6cbcdab4d3dfe097954bf2d98 Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Sat, 5 Oct 2024 17:48:36 +0400 Subject: [PATCH 12/20] =?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->{$docFieldName}`=20=E2=86=92=20Placeholders=20=E2=86=92=20`[?= =?UTF-8?q?+itemNumber+]`,=20`[+itemNumberZeroBased+]`:=20The=20new=20plac?= =?UTF-8?q?eholders.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 ++ src/Outputter/Json/Outputter.php | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index da19398..625fecd 100644 --- a/README.md +++ b/README.md @@ -303,6 +303,8 @@ Get resources from custom DB table. Available placeholders: * `[+value+]` — the field value * `[+`any document field or tv name`+]` — Any document field name or TV specified in `outputterParams->docFields` + * `[+itemNumber+]` — item number started from 1 + * `[+itemNumberZeroBased+]` — item number started from 0 * Valid values: * `stringChunkName` * `string` — use inline templates starting with `@CODE:` diff --git a/src/Outputter/Json/Outputter.php b/src/Outputter/Json/Outputter.php index b042ac2..a653a68 100644 --- a/src/Outputter/Json/Outputter.php +++ b/src/Outputter/Json/Outputter.php @@ -7,7 +7,7 @@ class Outputter extends \ddGetDocuments\Outputter\Outputter { /** * parse - * @version 2.3.2 (2024-10-05) + * @version 2.4 (2024-10-05) * * @param $data {Output} * @@ -19,7 +19,8 @@ public function parse(Output $data){ // Пройдемся по полученным данным foreach( $data->provider->items - as $itemData + as $itemIndex + => $itemData ){ $result_item = []; @@ -46,6 +47,8 @@ public function parse(Output $data){ $itemData, [ 'value' => $result_item[$docField], + 'itemNumber' => $itemIndex + 1, + 'itemNumberZeroBased' => $itemIndex, ] ], ]), From 07aa33ee728cf7e7d73ecb6f7043bb6f9c036ab1 Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Sun, 6 Oct 2024 19:20:42 +0400 Subject: [PATCH 13/20] =?UTF-8?q?+=20Outputters=20=E2=86=92=20Json=20?= =?UTF-8?q?=E2=86=92=20Parameters=20=E2=86=92=20`outputterParams->docField?= =?UTF-8?q?s[i]`:=20Added=20ability=20to=20use=20custom=20aliases=20instea?= =?UTF-8?q?d=20of=20field=20names=20for=20output=20using=20the=20`'=3D'`?= =?UTF-8?q?=20separator,=20for=20example:=20`'pagetitle=3Dtitle'`,=20`'con?= =?UTF-8?q?tent=3Dtext'`,=20etc.=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 | 47 ++++++++++++++++++++++++++++++-- src/Outputter/Json/Outputter.php | 19 +++++++++++-- src/Outputter/Outputter.php | 46 ++++++++++++++++++++++++++++--- 3 files changed, 104 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 625fecd..436a4fa 100644 --- a/README.md +++ b/README.md @@ -288,9 +288,10 @@ Get resources from custom DB table. * `outputterParams->docFields[i]` * Desctription: Document field or TV. + * You can use custom aliases instead of field names for output using the `'='` separator (for example: `'pagetitle=title'`, `'content=text'`, etc). * Valid values: - * `stringDocFieldName` - * `stringTvName` + * `string` — document field + * `stringSeparated` — document field and it's alias separated by `'='` * **Required** * `outputterParams->templates->{$docFieldName}` @@ -983,6 +984,48 @@ Returns: ``` +### Outputters → JSON (``&outputter=`json` ``): Use custom aliases instead of field names + +``` +[[ddGetDocuments? + &providerParams=`{ + parentIds: 1 + }` + &outputter=`json` + &outputterParams=`{ + docFields: pagetitle=name,menuindex=position + }` +]] +``` + +Returns: + +```json +[ + { + "name": "Denial", + "position": "0", + }, + { + "name": "Anger", + "position": "1", + }, + { + "name": "Bargaining", + "position": "2", + }, + { + "name": "Depression", + "position": "3", + }, + { + "name": "Acceptance", + "position": "4", + } +] +``` + + ### Group items that have the same field values into summary item (`providerParams->orderBy`) For example we have the following documents with TV `gender`: diff --git a/src/Outputter/Json/Outputter.php b/src/Outputter/Json/Outputter.php index a653a68..b546782 100644 --- a/src/Outputter/Json/Outputter.php +++ b/src/Outputter/Json/Outputter.php @@ -7,7 +7,7 @@ class Outputter extends \ddGetDocuments\Outputter\Outputter { /** * parse - * @version 2.4 (2024-10-05) + * @version 2.5 (2024-10-05) * * @param $data {Output} * @@ -16,6 +16,8 @@ class Outputter extends \ddGetDocuments\Outputter\Outputter { public function parse(Output $data){ $result = []; + $isFieldAliasesUsed = !\ddTools::isEmpty($this->fieldAliases); + // Пройдемся по полученным данным foreach( $data->provider->items @@ -29,7 +31,20 @@ public function parse(Output $data){ $this->docFields as $docField ){ - $result_item[$docField] = $itemData[$docField]; + // If aliases are used + if ( + $isFieldAliasesUsed + && \DDTools\Tools\Objects::isPropExists([ + 'object' => $this->fieldAliases, + 'propName' => $docField, + ]) + ){ + $result_item[$this->fieldAliases->{$docField}] = $itemData[$docField]; + + $docField = $this->fieldAliases->{$docField}; + }else{ + $result_item[$docField] = $itemData[$docField]; + } // If template for this field is set if ( diff --git a/src/Outputter/Outputter.php b/src/Outputter/Outputter.php index 3a86a82..5f6f7d6 100644 --- a/src/Outputter/Outputter.php +++ b/src/Outputter/Outputter.php @@ -13,6 +13,12 @@ abstract class Outputter extends \DDTools\Base\Base { */ $docFields = ['id'], + /** + * @property $fieldAliases {stdClass} — Aliases of fields if used. + * @property $fieldAliases->{$fieldName} {string} — A key is an original field name, a value is an alias. + */ + $fieldAliases = [], + /** * @property $templates {stdClass} * @property $templates->{$templateName} {string} @@ -22,7 +28,7 @@ abstract class Outputter extends \DDTools\Base\Base { /** * __construct - * @version 1.5.3 (2024-08-06) + * @version 1.6 (2024-10-05) * * @param $params {stdClass|arrayAssociative} * @param $params->dataProvider {\ddGetDocuments\DataProvider\DataProvider} @@ -38,6 +44,8 @@ public function __construct($params = []){ // Все параметры задают свойства объекта $this->setExistingProps($params); + $this->fieldAliases = (object) $this->fieldAliases; + // Comma separated strings if (!is_array($this->docFields)){ $this->docFields = explode( @@ -49,9 +57,39 @@ public function __construct($params = []){ if (empty($this->docFields)){ // We need something $this->docFields = ['id']; - }elseif (isset($params->dataProvider)){ - // Ask dataProvider to get them - $params->dataProvider->addResourcesFieldsToGet($this->docFields); + }else{ + // Prepare field aliases + foreach ( + $this->docFields + as $fieldNameIndex + => $fieldName + ){ + // If alias is used + if ( + strpos( + $fieldName, + '=' + ) + !== false + ){ + // E. g. 'pagetitle=title' + $fieldName = explode( + '=', + $fieldName + ); + + // Remove alias from field name + $this->docFields[$fieldNameIndex] = $fieldName[0]; + + // Save alias + $this->fieldAliases->{$this->docFields[$fieldNameIndex]} = $fieldName[1]; + } + } + + if (isset($params->dataProvider)){ + // Ask dataProvider to get them + $params->dataProvider->addResourcesFieldsToGet($this->docFields); + } } } From c848fb8620f96f09e089c1e8b62c9b46f6006402 Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Sun, 6 Oct 2024 19:23:44 +0400 Subject: [PATCH 14/20] =?UTF-8?q?*=20README=20=E2=86=92=20Installation:=20?= =?UTF-8?q?Description=20order=20has=20been=20changed.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 436a4fa..1d3e6a3 100644 --- a/README.md +++ b/README.md @@ -14,24 +14,6 @@ A snippet for fetching and parsing resources from the document tree or custom DB ## Installation -### Manually - - -#### 1. Elements → Snippets: Create a new snippet with the following data - -1. Snippet name: `ddGetDocuments`. -2. Description: `1.6 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. - - -#### 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): @@ -54,6 +36,24 @@ require_once( * If `ddGetDocuments` is already exist on your site, `ddInstaller` will check it version and update it if needed. +### Manually + + +#### 1. Elements → Snippets: Create a new snippet with the following data + +1. Snippet name: `ddGetDocuments`. +2. Description: `1.6 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. + + +#### 2. Elements → Manage Files: + +1. Create a new folder `assets/snippets/ddGetDocuments/`. +2. Extract the archive to the folder (except `ddGetDocuments_snippet.php`). + + ## Parameters description From ecde3c8a2582cd6a0e567a6b4f5c25ac076eef29 Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Sun, 6 Oct 2024 19:24:54 +0400 Subject: [PATCH 15/20] * README: Misprints have been fixed. --- README.md | 180 +++++++++++++++++++++++++++--------------------------- 1 file changed, 90 insertions(+), 90 deletions(-) diff --git a/README.md b/README.md index 1d3e6a3..1e6b641 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ require_once( ### Core parameters * `fieldDelimiter` - * Desctription: The field delimiter to be used in order to distinct data base column names in those parameters which can contain SQL queries directly, e. g. `providerParams->groupBy`, `providerParams->orderBy` and `providerParams->filter`. + * Description: The field delimiter to be used in order to distinct data base column names in those parameters which can contain SQL queries directly, e. g. `providerParams->groupBy`, `providerParams->orderBy` and `providerParams->filter`. * Valid values: `string` * Default value: ``'`'`` @@ -68,7 +68,7 @@ require_once( ### Data provider parameters * `provider` - * Desctription: Name of the provider that will be used to fetch documents. + * Description: Name of the provider that will be used to fetch documents. Data provider names are case insensitive (the following names are equal: `parent`, `Parent`, `pArEnT`, etc). * Valid values: * `'parent'` @@ -76,44 +76,44 @@ require_once( * Default value: `'parent'` * `providerParams` - * Desctription: Parameters to be passed to the provider. + * Description: Parameters to be passed to the provider. * Valid values: * `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) + * `stringQueryFormatted` — 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` - * Desctription: The filter condition in SQL-style to be applied while resource fetching. + * Description: The filter condition in SQL-style to be applied while resource fetching. Notice that all fields/tvs names specified in the filter parameter must be wrapped in `fieldDelimiter`. * Valid values: `string` * Default value: ``'`published` = 1 AND `deleted` = 0'`` * `providerParams->total` - * Desctription: The maximum number of the resources that will be returned. + * Description: The maximum number of the resources that will be returned. * Valid values: `integer` * Default value: — (all) * `providerParams->offset` - * Desctription: Resources offset. + * Description: Resources offset. * Valid values: `integer` * Default value: `0` * `providerParams->groupBy` - * Desctription: Group items that have the same values into summary item (like SQL `GROUP BY`). + * Description: Group items that have the same values into summary item (like SQL `GROUP BY`). * Valid values: `stringCommaSeparated` * Default value: — * `providerParams->groupBy[$i]` - * Desctription: Document field or TV by which the items will be grouped. + * Description: Document field or TV by which the items will be grouped. * Valid values: `string` * **Required** * `providerParams->orderBy` - * Desctription: A string representing the sorting rule. + * Description: A string representing the sorting rule. TV names also can be used. * Valid values: `string` * Default value: — @@ -122,31 +122,31 @@ require_once( #### Providers → Parent (``&provider=`parent` ``) * `providerParams->parentIds` - * Desctription: Parent ID(s). + * Description: Parent ID(s). * Valid values: * `array` * `stringCommaSeparated` * Default value: `[0]` * `providerParams->parentIds[i]` - * Desctription: Document ID. + * Description: Document ID. * Valid values: `integer` * **Required** * `providerParams->depth` - * Desctription: Depth of children documents search. + * Description: Depth of children documents search. * Valid values: `integer` * Default value: `1` * `providerParams->excludeIds` - * Desctription: The document IDs which need to exclude. + * Description: The document IDs which need to exclude. * Valid values: * `array` * `stringCommaSeparated` * Default value: — * `providerParams->excludeIds[i]` - * Desctription: Document ID. + * Description: Document ID. * Valid values: `integer` * **Required** @@ -154,14 +154,14 @@ require_once( #### Providers → Select (``&provider=`select` ``) * `providerParams->ids` - * Desctription: Document IDs to output. + * Description: Document IDs to output. * Valid values: * `array` * `stringCommaSeparated` * **Required** * `providerParams->ids[i]` - * Desctription: Document ID. + * Description: Document ID. * Valid values: `integer` * **Required** @@ -171,7 +171,7 @@ require_once( Get resources from custom DB table. * `providerParams->resourcesTableName` - * Desctription: DB table to get resources from. + * Description: DB table to get resources from. * Valid values: `string` * **Required** @@ -179,7 +179,7 @@ Get resources from custom DB table. ### Output format parameters * `outputter` - * Desctription: Format of the output. + * Description: Format of the output. Outputter names are case insensitive (the following names are equal: `string`, `String`, `sTrInG`, etc). * Valid values: * `'string'` @@ -190,18 +190,18 @@ Get resources from custom DB table. * Default value: `'string'` * `outputterParams` - * Desctription: Parameters to be passed to the specified outputter. + * Description: Parameters to be passed to the specified outputter. * Valid values: * `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) + * `stringQueryFormatted` — 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` - * Desctription: Output templates. + * Description: Output templates. * Valid values: `object` * Default value: — @@ -209,7 +209,7 @@ Get resources from custom DB table. #### Outputter → String (``&outputter=`string` ``) * `outputterParams->templates->item` - * Desctription: Item template. + * Description: Item template. Available placeholders: * `[+`any document field or tv name`+]` — Any document field name or TV. * `[+`any of extender placeholders`+]` — Any extender placeholders (see extenders description below). @@ -224,21 +224,21 @@ Get resources from custom DB table. * **Required** * `outputterParams->templates->itemFirst` - * Desctription: Template for the first item. Has the same placeholders as `outputterParams->templates->item`. + * Description: 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->templates->item`. * `outputterParams->templates->itemLast` - * Desctription: Template for the last item. Has the same placeholders as `outputterParams->templates->item`. + * Description: 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->templates->item`. * `outputterParams->templates->wrapper` - * Desctription: Wrapper template. + * Description: Wrapper template. Available placeholders: * `[+`any document field or tv name`+]` — Any document field name or TV. * `[+`any of extender placeholders`+]` — Any extender placeholders (see extenders description below). @@ -252,7 +252,7 @@ Get resources from custom DB table. * Default value: — * `outputterParams->templates->noResults` - * Desctription: A chunk or text to output when no items found. + * Description: A chunk or text to output when no items found. Has the same placeholders as `outputterParams->templates->wrapper`. * Valid values: * `stringChunkName` @@ -260,19 +260,19 @@ Get resources from custom DB table. * Default value: — * `outputterParams->placeholders` - * Desctription: + * Description: 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: — * `outputterParams->placeholders->{$name}` - * Desctription: Key for placeholder name and value for placeholder value. + * Description: Key for placeholder name and value for placeholder value. * Valid values: `string` * **Required** * `outputterParams->itemGlue` - * Desctription: The string that combines items while rendering. + * Description: The string that combines items while rendering. * Valid values: `string` * Default value: `''` @@ -280,14 +280,14 @@ Get resources from custom DB table. #### Outputter → Json (``&outputter=`json` ``) * `outputterParams->docFields` - * Desctription: Document fields to output (including TVs). + * Description: Document fields to output (including TVs). * Valid values: * `array` * `stringCommaSeparated` * Default value: `'id'` * `outputterParams->docFields[i]` - * Desctription: Document field or TV. + * Description: Document field or TV. * You can use custom aliases instead of field names for output using the `'='` separator (for example: `'pagetitle=title'`, `'content=text'`, etc). * Valid values: * `string` — document field @@ -295,7 +295,7 @@ Get resources from custom DB table. * **Required** * `outputterParams->templates->{$docFieldName}` - * Desctription: + * Description: 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. @@ -317,17 +317,17 @@ Get resources from custom DB table. Output in [Sitemap XML format](https://en.wikipedia.org/wiki/Sitemaps). * `outputterParams->priorityTVName` - * Desctription: Name of TV which sets the relative priority of the document. + * Description: Name of TV which sets the relative priority of the document. * Valid values: `stringTvName` * Default value: `'general_seo_sitemap_priority'` * `outputterParams->changefreqTVName` - * Desctription: Name of TV which sets the change frequency. + * Description: Name of TV which sets the change frequency. * Valid values: `stringTvName` * Default value: `'general_seo_sitemap_changefreq'` * `outputterParams->templates->item` - * Desctription: Item template. + * Description: Item template. Available placeholders: * `[+`any document field or tv name`+]` — Any document field name or TV. * `[+`any of extender placeholders`+]` — Any extender placeholders (see extenders description below). @@ -347,7 +347,7 @@ Output in [Sitemap XML format](https://en.wikipedia.org/wiki/Sitemaps). ``` * `outputterParams->templates->wrapper` - * Desctription: Wrapper template. + * Description: Wrapper template. Available placeholders: * `[+`any document field or tv name`+]` — Any document field name or TV. * `[+`any of extender placeholders`+]` — Any extender placeholders (see extenders description below). @@ -368,100 +368,100 @@ Output in [Sitemap XML format](https://en.wikipedia.org/wiki/Sitemaps). Output in [YML format](https://yandex.ru/support/partnermarket/export/yml.html). * `outputterParams->shopData` - * Desctription: Shop data. + * Description: Shop data. * Valid values: `object` * **Required** * `outputterParams->shopData->shopName` - * Desctription: Short shop name, length <= 20. + * Description: Short shop name, length <= 20. * Valid values: `string` * **Required** * `outputterParams->shopData->companyName` - * Desctription: Company legal name. Internal data that not be displayed but required by Yandex. + * Description: Company legal name. Internal data that not be displayed but required by Yandex. * Valid values: `string` * **Required** * `outputterParams->shopData->agency` - * Desctription: Web developers agency name. + * Description: Web developers agency name. * Valid values: `string` * Default value: — * `outputterParams->shopData->currencyId` - * Desctription: Currency code (see [Yandex docs](https://yandex.ru/support/partnermarket/currencies.html)). + * Description: Currency code (see [Yandex docs](https://yandex.ru/support/partnermarket/currencies.html)). * Valid values: `string` * Default value: `'RUR'` * `outputterParams->shopData->platform` - * Desctription: `` tag content. + * Description: `` tag content. * Valid values: `string` * Default value: `'(MODX) Evolution CMS'` * `outputterParams->shopData->version` - * Desctription: `` tag content. + * Description: `` tag content. * Valid values: `string` * Default value: `'[(settings_version)]'` * `outputterParams->categoryIds_last` - * Desctription: Allows to add additional parent elements in the category section. If empty only immediate parents of goods will be returned. + * Description: Allows to add additional parent elements in the category section. If empty only immediate parents of goods will be returned. * Valid values: `stringCommaSeparated` * Default value: — * `outputterParams->categoryIds_last[i]` - * Desctription: Document ID. + * Description: Document ID. * Valid values: `integer` * **Required** * `outputterParams->offerFields` - * Desctription: Offer fields parameters. + * Description: Offer fields parameters. * Valid values: `object` * **Required** * `outputterParams->offerFields->{$fieldName}` - * Desctription: Offer field parameter. + * Description: Offer field parameter. * Valid values: * `string` — the parameter can be set as a document field name * `object` — or as an object with additional params (see below) * Default value: — * `outputterParams->offerFields->{$fieldName}->docFieldName` - * Desctription: A document field name that contains offer field value. + * Description: A document field name that contains offer field value. * Valid values: `stringTvName` * **Required** * `outputterParams->offerFields->{$fieldName}->disableEscaping` - * Desctription: You can disable escaping special characters (`'`, `"`, `&`, `<`, `>`) in the field value. + * Description: You can disable escaping special characters (`'`, `"`, `&`, `<`, `>`) in the field value. * Valid values: `boolean` * Default value: `false` * `outputterParams->offerFields->{$fieldName}->valuePrefix` - * Desctription: You can set custom string that will be added before the field value. + * Description: You can set custom string that will be added before the field value. * Valid values: `string` * Default value: — * `outputterParams->offerFields->{$fieldName}->valueSuffix` - * Desctription: You can set custom string that will be added after the field value. + * Description: You can set custom string that will be added after the field value. * Valid values: `string` * Default value: — * `outputterParams->offerFields->price` - * Desctription: A document field name, that contains offer price. + * Description: A document field name, that contains offer price. If a document field value is empty, but `outputterParams->offerFields->priceOld` is set, the last will be used instead. * Valid values: `stringTvName` * **Required** * `outputterParams->offerFields->priceOld` - * Desctription: A document field name, that contains old offer price (must be less then `outputterParams->offerFields->price` or will not be used). + * Description: A document field name, that contains old offer price (must be less then `outputterParams->offerFields->price` or will not be used). * Valid values: `stringTvName` * Default value: — * `outputterParams->offerFields->picture` - * Desctription: A document field name, that contains offer picture. + * Description: A document field name, that contains offer picture. * Valid values: `stringTvName` * Default value: — * `outputterParams->offerFields->name` - * Desctription: A document field name, that contains offer name. + * Description: A document field name, that contains offer name. If a document field value is empty, the `pagetitle` field will be used instead. * Valid values: * `stringDocFieldName` @@ -469,59 +469,59 @@ Output in [YML format](https://yandex.ru/support/partnermarket/export/yml.html). * Default value: `'pagetitle'` * `outputterParams->offerFields->model` - * Desctription: A document field name, that contains offer model. + * Description: A document field name, that contains offer model. * Valid values: * `stringDocFieldName` * `stringTvName` * Default value: — * `outputterParams->offerFields->model` - * Desctription: A document field name, that contains offer vendor. + * Description: A document field name, that contains offer vendor. * Valid values: * `stringDocFieldName` * `stringTvName` * Default value: — * `outputterParams->offerFields->available` - * Desctription: A document field name, that contains offer availability status (`true`|`false`). + * Description: A document field name, that contains offer availability status (`true`|`false`). * Valid values: * `stringTvName` * `''` — always display `'true'`. * Default value: `''` * `outputterParams->offerFields->description` - * Desctription: A document field name, that contains offer description (less than 3 000 chars). + * Description: A document field name, that contains offer description (less than 3 000 chars). * Valid values: * `stringDocFieldName` * `stringTvName` * Default value: — * `outputterParams->offerFields->salesNotes` - * Desctription: A document field name, that contains offer <[sales_notes](https://yandex.ru/support/partnermarket/elements/sales_notes.html)>. + * Description: A document field name, that contains offer <[sales_notes](https://yandex.ru/support/partnermarket/elements/sales_notes.html)>. * Valid values: * `stringDocFieldName` * `stringTvName` * Default value: — * `outputterParams->offerFields->manufacturerWarranty` - * Desctription: A document field name, that contains offer manufacturer warraynty status (`true`|`false`). + * Description: A document field name, that contains offer manufacturer warraynty status (`true`|`false`). * Valid values: `stringTvName` * Default value: — * `outputterParams->offerFields->countryOfOrigin` - * Desctription: A document field name, that contains offer country of origin. + * Description: A document field name, that contains offer country of origin. * Valid values: * `stringDocFieldName` * `stringTvName` * Default value: — * `outputterParams->offerFields->homeCourierDelivery` - * Desctription: A document field name, that contains offer courier delivery status (`true`|`false`). + * Description: A document field name, that contains offer courier delivery status (`true`|`false`). * Valid values: `stringTvName` * Default value: — * `outputterParams->offerFields->dimensions` - * Desctription: A document field name, that contains offer dimensions (length, width, height) including packaging. + * Description: A document field name, that contains offer dimensions (length, width, height) including packaging. Specify dimensions in centimeters. Format: three positive numbers with accuracy of 0.001, using a dot as the decimal separator. The numbers must be separated by the slash character `/` without spaces. * Valid values: @@ -530,7 +530,7 @@ Output in [YML format](https://yandex.ru/support/partnermarket/export/yml.html). * Default value: — * `outputterParams->offerFields->weight` - * Desctription: Item weight in kilograms including packaging. + * Description: Item weight in kilograms including packaging. Some categories have limits on the minimum or maximum weight. [Download a list of minimum and maximum weight values](https://download.cdn.yandex.net/support/ru/partnermarket/yandex.market-weight.xlsx). In any category, the weight can be specified accurate to one thousandth (for example, 1.001, using a dot as a decimal point). @@ -541,21 +541,21 @@ Output in [YML format](https://yandex.ru/support/partnermarket/export/yml.html). * Default value: — * `outputterParams->offerFields->additionalParams` - * Desctription: A document field name, that contains offer <[param](https://yandex.ru/support/partnermarket/param.html)> elements. + * Description: A document field name, that contains offer <[param](https://yandex.ru/support/partnermarket/param.html)> elements. * Valid values: * `stringDocFieldName` * `stringTvName` * Default value: — * `outputterParams->offerFields->customData` - * Desctription: A document field name, that contains custom text that must be inserted before ``. + * Description: A document field name, that contains custom text that must be inserted before ``. * Valid values: * `stringDocFieldName` * `stringTvName` * Default value: — * `outputterParams->templates->wrapper` - * Desctription: Wrapper template. + * Description: Wrapper template. Available placeholders: * `[+`any document field or tv name`+]` — Any document field name or TV. * `[+`any of extender placeholders`+]` — Any extender placeholders (see extenders description below). @@ -584,7 +584,7 @@ Output in [YML format](https://yandex.ru/support/partnermarket/export/yml.html). ``` * `outputterParams->templates->categories_item` - * Desctription: Category item template. + * Description: Category item template. Available placeholders: * `[+id+]` — Category doc ID. * `[+value+]` — Category name. @@ -601,7 +601,7 @@ Output in [YML format](https://yandex.ru/support/partnermarket/export/yml.html). ``` * `outputterParams->templates->offers_item` - * Desctription: Offer item template. + * Description: Offer item template. Available placeholders: * `[+`any document field or tv name`+]` — Any document field name or TV. * `[+`any of extender placeholders`+]` — Any extender placeholders (see extenders description below). @@ -635,7 +635,7 @@ Output in [YML format](https://yandex.ru/support/partnermarket/export/yml.html). ``` * `outputterParams->templates->{'offers_item_elem' . $FieldName}` - * Desctription: You can set custom template for any offer element. Specify an element name in accordance with `offerFields->` parameters, e. g. `outputterParams->templates->offers_item_elemCountryOfOrigin`. + * Description: You can set custom template for any offer element. Specify an element name in accordance with `offerFields->` parameters, e. g. `outputterParams->templates->offers_item_elemCountryOfOrigin`. Available placeholders: * `[+tagName+]` — Element tag name. * `[+value+]` — Element value. @@ -648,13 +648,13 @@ Output in [YML format](https://yandex.ru/support/partnermarket/export/yml.html). ### Extenders parameters * `extenders` - * Desctription: Comma-separated string determining which extenders should be applied to the snippet. + * Description: Comma-separated string determining which extenders should be applied to the snippet. Be aware that the order of extender names can affect the output. * Valid values: `stringCommaSeparated` * Default value: — * `extenders[i]` - * Desctription: Extender name. + * Description: Extender name. Be aware that the order of extender names can affect the output. Extender names are case insensitive (the following names are equal: `pagination`, `Pagination`, `pAgInAtIoN`, etc). * Valid values: @@ -665,19 +665,19 @@ Output in [YML format](https://yandex.ru/support/partnermarket/export/yml.html). * **Required** * `extendersParams` - * Desctription: Parameters to be passed to their corresponding extensions. + * Description: 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: * `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) + * `stringQueryFormatted` — 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}` - * Desctription: Parameters of an extender, when the key is the extender name and the value is the extender parameters. + * Description: Parameters of an extender, when the key is the extender name and the value is the extender parameters. * Valid values: `object * Default value: — @@ -685,7 +685,7 @@ Output in [YML format](https://yandex.ru/support/partnermarket/export/yml.html). #### Extenders → Pagination (``&extenders=`pagination` ``) * `extendersParams->pagination->wrapperTpl` - * Desctription: Chunk to be used to output the pagination. + * Description: Chunk to be used to output the pagination. Available placeholders: * `[+previous+]` — HTML code of navigation block to the previous page (see parameters description below). * `[+next+]` — HTML code of navigation block to the next page (see parameters description below). @@ -706,7 +706,7 @@ Output in [YML format](https://yandex.ru/support/partnermarket/export/yml.html). ``` * `extendersParams->pagination->pageTpl` - * Desctription: Chunk to be used to output pages within the pagination. + * Description: Chunk to be used to output pages within the pagination. Available placeholders: * `[+url+]` — Page URL. * `[+page+]` — Page number. @@ -719,7 +719,7 @@ Output in [YML format](https://yandex.ru/support/partnermarket/export/yml.html). ``` * `extendersParams->pagination->currentPageTpl` - * Desctription: Chunk to be used to output the current page within the pagination. + * Description: Chunk to be used to output the current page within the pagination. Available placeholders: * `[+url+]` — Page URL. * `[+page+]` — Page number. @@ -732,7 +732,7 @@ Output in [YML format](https://yandex.ru/support/partnermarket/export/yml.html). ``` * `extendersParams->pagination->nextTpl` - * Desctription: Chunk to be used to output the navigation block to the next page. + * Description: Chunk to be used to output the navigation block to the next page. Available placeholders: * `[+url+]` — Next page URL. * `[+totalPages+]` — Total number of pages. @@ -746,7 +746,7 @@ Output in [YML format](https://yandex.ru/support/partnermarket/export/yml.html). ``` * `extendersParams->pagination->nextOffTpl` - * Desctription: Chunk to be used to output the navigation block to the next page if there are no more pages after. + * Description: Chunk to be used to output the navigation block to the next page if there are no more pages after. Available placeholders: * `[+totalPages+]` — Total number of pages. * Valid values: @@ -759,7 +759,7 @@ Output in [YML format](https://yandex.ru/support/partnermarket/export/yml.html). ``` * `extendersParams->pagination->previousTpl` - * Desctription: Chunk to be used to output the navigation block to the previous page. + * Description: Chunk to be used to output the navigation block to the previous page. Available placeholders: * `[+url+]` — Next page URL. * `[+totalPages+]` — Total number of pages. @@ -773,7 +773,7 @@ Output in [YML format](https://yandex.ru/support/partnermarket/export/yml.html). ``` * `extendersParams->pagination->previousOffTpl` - * Desctription: Chunk to be used to output the navigation block to the previous page if there are no more pages before. + * Description: Chunk to be used to output the navigation block to the previous page if there are no more pages before. Available placeholders: * `[+totalPages+]` — Total number of pages. * Valid values: @@ -789,17 +789,17 @@ Output in [YML format](https://yandex.ru/support/partnermarket/export/yml.html). #### Extenders → Tagging (``&extenders=`tagging` ``) * `extendersParams->tagging->tagsDocumentField` - * Desctription: The document field (TV) contains tags. + * Description: The document field (TV) contains tags. * Valid values: `stringTvName` * Default value: `'tags'` * `extendersParams->tagging->tagsDelimiter` - * Desctription: Tags delimiter in the document field. + * Description: Tags delimiter in the document field. * Valid values: `string` * Default value: `', '` * `extendersParams->tagging->tagsRequestParamName` - * Desctription: The parameter in `$_REQUEST` to get the tags value from. + * Description: The parameter in `$_REQUEST` to get the tags value from. * Valid values: `string` * Default value: `'tags'` @@ -807,14 +807,14 @@ Output in [YML format](https://yandex.ru/support/partnermarket/export/yml.html). #### Extenders → Search (``&extenders=`search` ``) * `extendersParams->search->docFieldsToSearch` - * Desctription: Document fields to search in (including TVs). + * Description: Document fields to search in (including TVs). * Valid values: * `array` * `stringCommaSeparated` * Default value: `'pagetitle,content'` * `extendersParams->search->docFieldsToSearch[i]` - * Desctription: Document fields or TV. + * Description: Document fields or TV. * Valid values: * `stringDocFieldName` * `stringTvName` @@ -824,7 +824,7 @@ Output in [YML format](https://yandex.ru/support/partnermarket/export/yml.html). #### Extenders → SortFromURL (``&extenders=`sortFromURL` ``) * `$_GET['orderBy']` - * Desctription: A string representing the sorting rule similar to `providerParams->orderBy`. + * Description: A string representing the sorting rule similar to `providerParams->orderBy`. * Valid values: `string` * Default value: — From 879ce98fd9c0c3a9c5f05284aa6bb04b6ef7b67f Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Sun, 6 Oct 2024 19:33:21 +0400 Subject: [PATCH 16/20] * README: Minor changes (code style). --- README.md | 255 +++++++++++++++++++++++++++--------------------------- 1 file changed, 127 insertions(+), 128 deletions(-) diff --git a/README.md b/README.md index 1e6b641..78792a2 100644 --- a/README.md +++ b/README.md @@ -21,14 +21,14 @@ Just run the following PHP code in your sources or [Console](https://github.com/ ```php // Include (MODX)EvolutionCMS.libraries.ddInstaller require_once( - $modx->getConfig('base_path') . - 'assets/libs/ddInstaller/require.php' + $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' + 'type' => 'snippet', ]); ``` @@ -68,8 +68,8 @@ require_once( ### Data provider parameters * `provider` - * Description: Name of the provider that will be used to fetch documents. - Data provider names are case insensitive (the following names are equal: `parent`, `Parent`, `pArEnT`, etc). + * Description: Name of the provider that will be used to fetch documents. + * Data provider names are case insensitive (the following names are equal: `parent`, `Parent`, `pArEnT`, etc). * Valid values: * `'parent'` * `'select'` @@ -87,8 +87,8 @@ require_once( * Default value: — * `providerParams->filter` - * Description: The filter condition in SQL-style to be applied while resource fetching. - Notice that all fields/tvs names specified in the filter parameter must be wrapped in `fieldDelimiter`. + * Description: The filter condition in SQL-style to be applied while resource fetching. + * Notice that all fields/tvs names specified in the filter parameter must be wrapped in `fieldDelimiter`. * Valid values: `string` * Default value: ``'`published` = 1 AND `deleted` = 0'`` @@ -113,8 +113,8 @@ require_once( * **Required** * `providerParams->orderBy` - * Description: A string representing the sorting rule. - TV names also can be used. + * Description: A string representing the sorting rule. + * TV names also can be used. * Valid values: `string` * Default value: — @@ -179,8 +179,8 @@ Get resources from custom DB table. ### Output format parameters * `outputter` - * Description: Format of the output. - Outputter names are case insensitive (the following names are equal: `string`, `String`, `sTrInG`, etc). + * Description: Format of the output. + * Outputter names are case insensitive (the following names are equal: `string`, `String`, `sTrInG`, etc). * Valid values: * `'string'` * `'json'` @@ -209,60 +209,61 @@ Get resources from custom DB table. #### Outputter → String (``&outputter=`string` ``) * `outputterParams->templates->item` - * Description: Item template. - Available placeholders: - * `[+`any document field or tv name`+]` — Any document field name or TV. - * `[+`any of extender placeholders`+]` — Any extender placeholders (see extenders description below). - * `[+`any placeholders from `placeholders` param`+]` — Any custom placeholders (see `outputterParams->placeholders` description below). - * `[+itemNumber+]` — Item number started from 1. - * `[+itemNumberZeroBased+]` Item number started from 0. - * `[+total+]` — number of returned items - * `[+totalFound+]` — number of found items + * Description: Item template. + * Available placeholders: + * `[+`any document field or tv name`+]` — Any document field name or TV. + * `[+`any of extender placeholders`+]` — Any extender placeholders (see extenders description below). + * `[+`any placeholders from `placeholders` param`+]` — Any custom placeholders (see `outputterParams->placeholders` description below). + * `[+itemNumber+]` — Item number started from 1. + * `[+itemNumberZeroBased+]` Item number started from 0. + * `[+total+]` — number of returned items + * `[+totalFound+]` — number of found items * Valid values: * `stringChunkName` * `string` — use inline templates starting with `@CODE:` * **Required** * `outputterParams->templates->itemFirst` - * Description: Template for the first item. Has the same placeholders as `outputterParams->templates->item`. + * Description: 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->templates->item`. * `outputterParams->templates->itemLast` - * Description: Template for the last item. Has the same placeholders as `outputterParams->templates->item`. + * Description: 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->templates->item`. * `outputterParams->templates->wrapper` - * Description: Wrapper template. - Available placeholders: - * `[+`any document field or tv name`+]` — Any document field name or TV. - * `[+`any of extender placeholders`+]` — Any extender placeholders (see extenders description below). - * `[+`any placeholders from `placeholders` param`+]` — Any custom placeholders (see `outputterParams->placeholders` description below). - * `[+ddGetDocuments_items+]` - * `[+total+]` — number of returned items - * `[+totalFound+]` — number of found items + * Description: Wrapper template. + * Available placeholders: + * `[+`any document field or tv name`+]` — Any document field name or TV. + * `[+`any of extender placeholders`+]` — Any extender placeholders (see extenders description below). + * `[+`any placeholders from `placeholders` param`+]` — Any custom placeholders (see `outputterParams->placeholders` description below). + * `[+ddGetDocuments_items+]` + * `[+total+]` — number of returned items + * `[+totalFound+]` — number of found items * Valid values: * `stringChunkName` * `string` — use inline templates starting with `@CODE:` * Default value: — * `outputterParams->templates->noResults` - * Description: A chunk or text to output when no items found. - Has the same placeholders as `outputterParams->templates->wrapper`. + * Description: 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` - * Description: - 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]`. + * Description: 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: — @@ -295,17 +296,14 @@ Get resources from custom DB table. * **Required** * `outputterParams->templates->{$docFieldName}` - * Description: - 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+]` — the field value - * `[+`any document field or tv name`+]` — Any document field name or TV specified in `outputterParams->docFields` - * `[+itemNumber+]` — item number started from 1 - * `[+itemNumberZeroBased+]` — item number started from 0 + * Description: 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+]` — the field value + * `[+`any document field or tv name`+]` — Any document field name or TV specified in `outputterParams->docFields` + * `[+itemNumber+]` — item number started from 1 + * `[+itemNumberZeroBased+]` — item number started from 0 * Valid values: * `stringChunkName` * `string` — use inline templates starting with `@CODE:` @@ -328,11 +326,11 @@ Output in [Sitemap XML format](https://en.wikipedia.org/wiki/Sitemaps). * `outputterParams->templates->item` * Description: Item template. - Available placeholders: - * `[+`any document field or tv name`+]` — Any document field name or TV. - * `[+`any of extender placeholders`+]` — Any extender placeholders (see extenders description below). - * `[+itemNumber+]` — Item number started from 1. - * `[+itemNumberZeroBased+]` Item number started from 0. + * Available placeholders: + * `[+`any document field or tv name`+]` — Any document field name or TV. + * `[+`any of extender placeholders`+]` — Any extender placeholders (see extenders description below). + * `[+itemNumber+]` — Item number started from 1. + * `[+itemNumberZeroBased+]` Item number started from 0. * Valid values: * `stringChunkName` * `string` — use inline templates starting with `@CODE:` @@ -347,11 +345,11 @@ Output in [Sitemap XML format](https://en.wikipedia.org/wiki/Sitemaps). ``` * `outputterParams->templates->wrapper` - * Description: Wrapper template. - Available placeholders: - * `[+`any document field or tv name`+]` — Any document field name or TV. - * `[+`any of extender placeholders`+]` — Any extender placeholders (see extenders description below). - * `[+ddGetDocuments_items+]` + * Description: Wrapper template. + * Available placeholders: + * `[+`any document field or tv name`+]` — Any document field name or TV. + * `[+`any of extender placeholders`+]` — Any extender placeholders (see extenders description below). + * `[+ddGetDocuments_items+]` * Valid values: * `stringChunkName` * `string` — use inline templates starting with `@CODE:` @@ -445,8 +443,8 @@ Output in [YML format](https://yandex.ru/support/partnermarket/export/yml.html). * Default value: — * `outputterParams->offerFields->price` - * Description: A document field name, that contains offer price. - If a document field value is empty, but `outputterParams->offerFields->priceOld` is set, the last will be used instead. + * Description: A document field name, that contains offer price. + * If a document field value is empty, but `outputterParams->offerFields->priceOld` is set, the last will be used instead. * Valid values: `stringTvName` * **Required** @@ -461,8 +459,8 @@ Output in [YML format](https://yandex.ru/support/partnermarket/export/yml.html). * Default value: — * `outputterParams->offerFields->name` - * Description: A document field name, that contains offer name. - If a document field value is empty, the `pagetitle` field will be used instead. + * Description: A document field name, that contains offer name. + * If a document field value is empty, the `pagetitle` field will be used instead. * Valid values: * `stringDocFieldName` * `stringTvName` @@ -521,20 +519,20 @@ Output in [YML format](https://yandex.ru/support/partnermarket/export/yml.html). * Default value: — * `outputterParams->offerFields->dimensions` - * Description: A document field name, that contains offer dimensions (length, width, height) including packaging. - Specify dimensions in centimeters. Format: three positive numbers with accuracy of 0.001, using a dot as the decimal separator. - The numbers must be separated by the slash character `/` without spaces. + * Description: A document field name, that contains offer dimensions (length, width, height) including packaging. + * Specify dimensions in centimeters. Format: three positive numbers with accuracy of 0.001, using a dot as the decimal separator. + * The numbers must be separated by the slash character `/` without spaces. * Valid values: * `stringDocFieldName` * `stringTvName` * Default value: — * `outputterParams->offerFields->weight` - * Description: Item weight in kilograms including packaging. - Some categories have limits on the minimum or maximum weight. - [Download a list of minimum and maximum weight values](https://download.cdn.yandex.net/support/ru/partnermarket/yandex.market-weight.xlsx). - In any category, the weight can be specified accurate to one thousandth (for example, 1.001, using a dot as a decimal point). - If the minimum value is set to 0, there is no minimum weight limit and it can be specified starting from one gram (0.001 kg). + * Description: Item weight in kilograms including packaging. + * Some categories have limits on the minimum or maximum weight. + * [Download a list of minimum and maximum weight values](https://download.cdn.yandex.net/support/ru/partnermarket/yandex.market-weight.xlsx). + * In any category, the weight can be specified accurate to one thousandth (for example, 1.001, using a dot as a decimal point). + * If the minimum value is set to `0`, there is no minimum weight limit and it can be specified starting from one gram (0.001 kg). * Valid values: * `stringDocFieldName` * `stringTvName` @@ -555,11 +553,11 @@ Output in [YML format](https://yandex.ru/support/partnermarket/export/yml.html). * Default value: — * `outputterParams->templates->wrapper` - * Description: Wrapper template. - Available placeholders: - * `[+`any document field or tv name`+]` — Any document field name or TV. - * `[+`any of extender placeholders`+]` — Any extender placeholders (see extenders description below). - * `[+ddGetDocuments_items+]` + * Description: Wrapper template. + * Available placeholders: + * `[+`any document field or tv name`+]` — Any document field name or TV. + * `[+`any of extender placeholders`+]` — Any extender placeholders (see extenders description below). + * `[+ddGetDocuments_items+]` * Valid values: * `stringChunkName` * `string` — use inline templates starting with `@CODE:` @@ -585,11 +583,11 @@ Output in [YML format](https://yandex.ru/support/partnermarket/export/yml.html). * `outputterParams->templates->categories_item` * Description: Category item template. - Available placeholders: - * `[+id+]` — Category doc ID. - * `[+value+]` — Category name. - * `[+parent+]` — Category parent ID. - * `[+attrs+]` — Attributes string (e. g. `parentId="42"`). + * Available placeholders: + * `[+id+]` — Category doc ID. + * `[+value+]` — Category name. + * `[+parent+]` — Category parent ID. + * `[+attrs+]` — Attributes string (e. g. `parentId="42"`). * Valid values: * `stringChunkName` * `string` — use inline templates starting with `@CODE:` @@ -601,12 +599,12 @@ Output in [YML format](https://yandex.ru/support/partnermarket/export/yml.html). ``` * `outputterParams->templates->offers_item` - * Description: Offer item template. - Available placeholders: - * `[+`any document field or tv name`+]` — Any document field name or TV. - * `[+`any of extender placeholders`+]` — Any extender placeholders (see extenders description below). - * `[+itemNumber+]` — Item number started from 1. - * `[+itemNumberZeroBased+]` Item number started from 0. + * Description: Offer item template. + * Available placeholders: + * `[+`any document field or tv name`+]` — Any document field name or TV. + * `[+`any of extender placeholders`+]` — Any extender placeholders (see extenders description below). + * `[+itemNumber+]` — Item number started from 1. + * `[+itemNumberZeroBased+]` Item number started from 0. * Valid values: * `stringChunkName` * `string` — use inline templates starting with `@CODE:` @@ -635,10 +633,11 @@ Output in [YML format](https://yandex.ru/support/partnermarket/export/yml.html). ``` * `outputterParams->templates->{'offers_item_elem' . $FieldName}` - * Description: You can set custom template for any offer element. Specify an element name in accordance with `offerFields->` parameters, e. g. `outputterParams->templates->offers_item_elemCountryOfOrigin`. - Available placeholders: - * `[+tagName+]` — Element tag name. - * `[+value+]` — Element value. + * Description: You can set custom template for any offer element. + * Specify an element name in accordance with `offerFields->` parameters, e. g. `outputterParams->templates->offers_item_elemCountryOfOrigin`. + * Available placeholders: + * `[+tagName+]` — Element tag name. + * `[+value+]` — Element value. * Valid values: * `stringChunkName` * `string` — use inline templates starting with `@CODE:` @@ -648,15 +647,15 @@ Output in [YML format](https://yandex.ru/support/partnermarket/export/yml.html). ### Extenders parameters * `extenders` - * Description: Comma-separated string determining which extenders should be applied to the snippet. - Be aware that the order of extender names can affect the output. + * Description: Comma-separated string determining which extenders should be applied to the snippet. + * Be aware that the order of extender names can affect the output. * Valid values: `stringCommaSeparated` * Default value: — * `extenders[i]` - * Description: Extender name. - Be aware that the order of extender names can affect the output. - Extender names are case insensitive (the following names are equal: `pagination`, `Pagination`, `pAgInAtIoN`, etc). + * Description: Extender name. + * Be aware that the order of extender names can affect the output. + * Extender names are case insensitive (the following names are equal: `pagination`, `Pagination`, `pAgInAtIoN`, etc). * Valid values: * `'pagination'` * `'tagging'` @@ -665,8 +664,8 @@ Output in [YML format](https://yandex.ru/support/partnermarket/export/yml.html). * **Required** * `extendersParams` - * Description: Parameters to be passed to their corresponding extensions. - You can avoid extender name if you are using only one extender (see examples below). + * Description: 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: * `stringJsonObject` — as [JSON](https://en.wikipedia.org/wiki/JSON) * `stringHjsonObject` — as [HJSON](https://hjson.github.io/) @@ -685,12 +684,12 @@ Output in [YML format](https://yandex.ru/support/partnermarket/export/yml.html). #### Extenders → Pagination (``&extenders=`pagination` ``) * `extendersParams->pagination->wrapperTpl` - * Description: Chunk to be used to output the pagination. - Available placeholders: - * `[+previous+]` — HTML code of navigation block to the previous page (see parameters description below). - * `[+next+]` — HTML code of navigation block to the next page (see parameters description below). - * `[+pages+]` — HTML code of pages navigalion block (see parameters description below). - * `[+totalPages+]` — Total number of pages. + * Description: Chunk to be used to output the pagination. + * Available placeholders: + * `[+previous+]` — HTML code of navigation block to the previous page (see parameters description below). + * `[+next+]` — HTML code of navigation block to the next page (see parameters description below). + * `[+pages+]` — HTML code of pages navigalion block (see parameters description below). + * `[+totalPages+]` — Total number of pages. * Valid values: * `stringChunkName` * `string` — use inline templates starting with `@CODE:` @@ -706,10 +705,10 @@ Output in [YML format](https://yandex.ru/support/partnermarket/export/yml.html). ``` * `extendersParams->pagination->pageTpl` - * Description: Chunk to be used to output pages within the pagination. - Available placeholders: - * `[+url+]` — Page URL. - * `[+page+]` — Page number. + * Description: Chunk to be used to output pages within the pagination. + * Available placeholders: + * `[+url+]` — Page URL. + * `[+page+]` — Page number. * Valid values: * `stringChunkName` * `string` — use inline templates starting with `@CODE:` @@ -719,10 +718,10 @@ Output in [YML format](https://yandex.ru/support/partnermarket/export/yml.html). ``` * `extendersParams->pagination->currentPageTpl` - * Description: Chunk to be used to output the current page within the pagination. - Available placeholders: - * `[+url+]` — Page URL. - * `[+page+]` — Page number. + * Description: Chunk to be used to output the current page within the pagination. + * Available placeholders: + * `[+url+]` — Page URL. + * `[+page+]` — Page number. * Valid values: * `stringChunkName` * `string` — use inline templates starting with `@CODE:` @@ -732,10 +731,10 @@ Output in [YML format](https://yandex.ru/support/partnermarket/export/yml.html). ``` * `extendersParams->pagination->nextTpl` - * Description: Chunk to be used to output the navigation block to the next page. - Available placeholders: - * `[+url+]` — Next page URL. - * `[+totalPages+]` — Total number of pages. + * Description: Chunk to be used to output the navigation block to the next page. + * Available placeholders: + * `[+url+]` — Next page URL. + * `[+totalPages+]` — Total number of pages. * Valid values: * `stringChunkName` * `string` — use inline templates starting with `@CODE:` @@ -746,9 +745,9 @@ Output in [YML format](https://yandex.ru/support/partnermarket/export/yml.html). ``` * `extendersParams->pagination->nextOffTpl` - * Description: Chunk to be used to output the navigation block to the next page if there are no more pages after. - Available placeholders: - * `[+totalPages+]` — Total number of pages. + * Description: Chunk to be used to output the navigation block to the next page if there are no more pages after. + * Available placeholders: + * `[+totalPages+]` — Total number of pages. * Valid values: * `stringChunkName` * `string` — use inline templates starting with `@CODE:` @@ -759,10 +758,10 @@ Output in [YML format](https://yandex.ru/support/partnermarket/export/yml.html). ``` * `extendersParams->pagination->previousTpl` - * Description: Chunk to be used to output the navigation block to the previous page. - Available placeholders: - * `[+url+]` — Next page URL. - * `[+totalPages+]` — Total number of pages. + * Description: Chunk to be used to output the navigation block to the previous page. + * Available placeholders: + * `[+url+]` — Next page URL. + * `[+totalPages+]` — Total number of pages. * Valid values: * `stringChunkName` * `string` — use inline templates starting with `@CODE:` @@ -773,9 +772,9 @@ Output in [YML format](https://yandex.ru/support/partnermarket/export/yml.html). ``` * `extendersParams->pagination->previousOffTpl` - * Description: Chunk to be used to output the navigation block to the previous page if there are no more pages before. - Available placeholders: - * `[+totalPages+]` — Total number of pages. + * Description: Chunk to be used to output the navigation block to the previous page if there are no more pages before. + * Available placeholders: + * `[+totalPages+]` — Total number of pages. * Valid values: * `stringChunkName` * `string` — use inline templates starting with `@CODE:` @@ -1153,8 +1152,8 @@ We recommend to use cashed snippet calls and turn on document caching type with ```php // Include (MODX)EvolutionCMS.libraries.ddTools require_once( - $modx->getConfig('base_path') . - 'assets/libs/ddTools/modx.ddtools.class.php' + $modx->getConfig('base_path') + . 'assets/libs/ddTools/modx.ddtools.class.php' ); // Run (MODX)EvolutionCMS.snippets.ddGetDocuments @@ -1163,10 +1162,10 @@ require_once( 'params' => [ // It is convenient to set the parameter as a native PHP array or object 'providerParams' => [ - 'parentIds' => 1 + 'parentIds' => 1, ], - 'outputter' => 'json' - ] + 'outputter' => 'json', + ], ]); ``` From 74cd3fedbc9ed66832186db1a8e808d1f2d0770b Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Sun, 6 Oct 2024 19:34:21 +0400 Subject: [PATCH 17/20] =?UTF-8?q?+=20README=20=E2=86=92=C2=A0Links=20?= =?UTF-8?q?=E2=86=92=20GitHub.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 78792a2..30f7cd7 100644 --- a/README.md +++ b/README.md @@ -1175,6 +1175,7 @@ require_once( * [Home page](https://code.divandesign.biz/modx/ddgetdocuments) * [Telegram chat](https://t.me/dd_code) * [Packagist](https://packagist.org/packages/dd/evolutioncms-snippets-ddgetdocuments) +* [GitHub](https://github.com/DivanDesign/EvolutionCMS.snippets.ddGetDocuments) \ No newline at end of file From 7c1eb5720c83eef103a2eab09decc7be87f88330 Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Sun, 6 Oct 2024 19:35:16 +0400 Subject: [PATCH 18/20] * CHANGELOG: Minor changes (code style). --- CHANGELOG.md | 9 +++++++++ CHANGELOG_ru.md | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca096d8..9f1b8ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,16 +2,19 @@ ## Version 1.6 (2022-09-30) + * \+ Outputters → Json → Parameters → `outputterParams->templates->{$docFieldName}` → Placeholders: The new placeholders contain any document field name or TV specified in `outputterParams->docFields`. * \* Outputters → Yandexmarket: Critical error related to missing initialization of an object field has been fixed. ## Version 1.5 (2022-06-03) + * \+ Parameters → `providerParams->groupBy`: The new parameter. Allows to group items that have the same field values into summary item (like SQL `GROUP BY`). See README. * \* README → Examples: HJSON is used for all examples. ## 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`). @@ -33,10 +36,12 @@ ## Version 1.3.1 (2021-02-28) + * \* Outputters → String → Parameters → `outputterParams->placeholders`: Fixed critical error when the parameter is used. ## Version 1.3 (2021-02-27) + * \* Attention! (MODX)Evolution.libraries.ddTools >= 0.42 is required. * \* Parameters: The following parameters were moved from Snippet to Provider (with backward compatibility): * \* `filter` → `providerParams->filter`. @@ -60,6 +65,7 @@ ## Version 1.2 (2020-10-09) + * \+ Extenders → SortFromURL (see README). * \* Parameters: The following were changed (with backward compatibility): * \- `orderBy`. @@ -71,6 +77,7 @@ ## Version 1.1 (2020-07-05) + * \* Attention! (MODX)EvolutionCMS.libraries.ddTools >= 0.40.1 is required (not tested in older versions). * \* Improved compatibility with new versions of (MODX)EvolutionCMS.libraries.ddTools. * \* Snippet: @@ -87,6 +94,7 @@ ## Version 1.0 (2020-03-11) + * \* Attention! (MODX)EvolutionCMS.libraries.ddTools >= 0.30 is required. * \+ Providers → Customdbtable. Get resources from custom DB table. * \* Outputters → Yandexmarket: @@ -108,6 +116,7 @@ ## Version 0.1 (2015-09-23) + * \+ The first release. diff --git a/CHANGELOG_ru.md b/CHANGELOG_ru.md index d57226e..4ae4154 100644 --- a/CHANGELOG_ru.md +++ b/CHANGELOG_ru.md @@ -2,16 +2,19 @@ ## Версия 1.6 (2022-09-30) + * \+ Outputters → Json → Параметры → `outputterParams->templates->{$docFieldName}` → Плейсхолдеры: Новые плейсхолдеры. Содержат значения полей документа (и TV), указанных в `outputterParams->docFields`. * \* Outputters → Yandexmarket: Исправлена критическая ошибка, связанная с отсутствием инициализации поля объекта. ## Версия 1.5 (2022-06-03) + * \+ Параметры → `providerParams->groupBy`: Новый параметр. Позволяет сгруппировать элементы, имеющие одинаковые значения полей, в один сводный элемент (как SQL `GROUP BY`). См. README. * \* README → Примеры: HJSON используется для всех примеров. ## Версия 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`). @@ -33,10 +36,12 @@ ## Версия 1.3.1 (2021-02-28) + * \* Outputters → String → Параметры → `outputterParams->placeholders`: Исправлена критическая ошибка, когда параметр используется. ## Версия 0.1 (2015-09-23) + * \+ Первый релиз. From aff9381c30ea07f9ea26ee5c643308cc20d6d96c Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Sun, 6 Oct 2024 19:37:05 +0400 Subject: [PATCH 19/20] * Minor changes (fixed inactive DivanDesign.biz link). --- README.md | 4 ++-- composer.json | 14 +++----------- ddGetDocuments_snippet.php | 4 ++-- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 30f7cd7..5f285ea 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ A snippet for fetching and parsing resources from the document tree or custom DB * 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.62 +* [(MODX)EvolutionCMS.libraries.ddTools](https://code.divandesign.ru/modx/ddtools) >= 0.62 ## Installation @@ -1172,7 +1172,7 @@ require_once( ## Links -* [Home page](https://code.divandesign.biz/modx/ddgetdocuments) +* [Home page](https://code.divandesign.ru/modx/ddgetdocuments) * [Telegram chat](https://t.me/dd_code) * [Packagist](https://packagist.org/packages/dd/evolutioncms-snippets-ddgetdocuments) * [GitHub](https://github.com/DivanDesign/EvolutionCMS.snippets.ddGetDocuments) diff --git a/composer.json b/composer.json index 3b41d8a..af2e1b6 100644 --- a/composer.json +++ b/composer.json @@ -17,26 +17,18 @@ "get documents", "ddgetdocuments" ], - "homepage": "https://code.divandesign.biz/modx/ddgetdocuments", + "homepage": "https://code.divandesign.ru/modx/ddgetdocuments", "support": { "chat": "https://t.me/dd_code" }, "authors": [ - { - "name": "DD Group", - "email": "code@DivanDesign.biz", - "homepage": "https://code.divandesign.biz", - "role": "Owner" - }, { "name": "Ilyas Ronef", - "email": "ilyas@DivanDesign.ru", - "homepage": "https://ronef.ru", - "role": "Developer" + "homepage": "https://ronef.me", + "role": "Owner" }, { "name": "Alexey Davydov", - "email": "davalemic@DivanDesign.ru", "homepage": "https://github.com/davalemic", "role": "Developer" }, diff --git a/ddGetDocuments_snippet.php b/ddGetDocuments_snippet.php index 2f634b2..ad2ae4e 100644 --- a/ddGetDocuments_snippet.php +++ b/ddGetDocuments_snippet.php @@ -5,9 +5,9 @@ * * @see README.md * - * @link https://code.divandesign.biz/modx/ddgetdocuments + * @link https://code.divandesign.ru/modx/ddgetdocuments * - * @copyright 2015–2022 DD Group {@link https://DivanDesign.biz } + * @copyright 2015–2022 Ronef {@link https://Ronef.me } */ // Include (MODX)EvolutionCMS.libraries.ddTools From e298c1ce165988d348daaa502ae0c16a8bcfe4cf Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Sun, 6 Oct 2024 19:56:18 +0400 Subject: [PATCH 20/20] Prerelease --- CHANGELOG.md | 9 +++++++++ CHANGELOG_ru.md | 9 +++++++++ README.md | 2 +- composer.json | 2 +- ddGetDocuments_snippet.php | 4 ++-- src/Snippet.php | 2 +- 6 files changed, 23 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f1b8ca..5323ae8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,15 @@ # (MODX)EvolutionCMS.snippets.ddGetDocuments changelog +## Version 1.7 (2024-10-06) + +* \+ Outputters → Json → Parameters: + * \+ `outputterParams->templates->{$docFieldName}` → Placeholders → `[+itemNumber+]`, `[+itemNumberZeroBased+]`: The new placeholders. + * \+ `outputterParams->docFields[i]`: Added ability to use custom aliases instead of field names for output using the `'='` separator, for example: `'pagetitle=title'`, `'content=text'`, etc. (see README → Examples). +* \* `\ddTools::getTpl` is used instead of `$modx->getTpl` (means a bit less bugs). +* \* Attention! (MODX)EvolutionCMS.libraries.ddTools >= 0.62 is required. + + ## Version 1.6 (2022-09-30) * \+ Outputters → Json → Parameters → `outputterParams->templates->{$docFieldName}` → Placeholders: The new placeholders contain any document field name or TV specified in `outputterParams->docFields`. diff --git a/CHANGELOG_ru.md b/CHANGELOG_ru.md index 4ae4154..50a65a1 100644 --- a/CHANGELOG_ru.md +++ b/CHANGELOG_ru.md @@ -1,6 +1,15 @@ # (MODX)EvolutionCMS.snippets.ddGetDocuments changelog +## Версия 1.7 (2024-10-06) + +* \+ Outputters → Json → Параметры: + * \+ `outputterParams->templates->{$docFieldName}` → Плейсхолдеры → `[+itemNumber+]`, `[+itemNumberZeroBased+]`: Новые плейсхолдеры. + * \+ `outputterParams->docFields[i]`: Добавлена возможность использовать кастомные псевдонимы вместо имён полей для вывода, используя разделитель `'='`, например: `'pagetitle=title'`, `'content=text'`, etc. (см. README → Примеры). +* \* `\ddTools::getTpl` используется вместо `$modx->getTpl` (стало чуть меньше багов). +* \* Внимание! Требуется (MODX)EvolutionCMS.libraries.ddTools >= 0.62. + + ## Версия 1.6 (2022-09-30) * \+ Outputters → Json → Параметры → `outputterParams->templates->{$docFieldName}` → Плейсхолдеры: Новые плейсхолдеры. Содержат значения полей документа (и TV), указанных в `outputterParams->docFields`. diff --git a/README.md b/README.md index 5f285ea..2e76024 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ require_once( #### 1. Elements → Snippets: Create a new snippet with the following data 1. Snippet name: `ddGetDocuments`. -2. Description: `1.6 A snippet for fetching and parsing resources from the document tree or custom DB table by a custom rule.`. +2. Description: `1.7 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 af2e1b6..48db47b 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "dd/evolutioncms-snippets-ddgetdocuments", "type": "modxevo-snippet", - "version": "1.6.0", + "version": "1.7.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 ad2ae4e..c6aee36 100644 --- a/ddGetDocuments_snippet.php +++ b/ddGetDocuments_snippet.php @@ -1,13 +1,13 @@ 'outputFormat',