diff --git a/CHANGELOG.md b/CHANGELOG.md
index a6be055..e23cf5e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,22 @@
# (MODX)EvolutionCMS.snippets.ddGetDocuments changelog
+## 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:
+ * \+ `extendersParams->pagination->wrapperTpl`: The new placeholder `[+totalPages+]`.
+ * \* Small refactoring.
+* \* `\ddGetDocuments\DataProvider\DataProvider::prepareQueryData`: TVs default values are used (#6).
+* \* `\ddGetDocuments\Outputter\Json\Outputter::parse`: Removed unused variable.
+* \+ README, CHAGNELOG: Style improvements.
+* \* Composer.json:
+ * \+ `homepage`.
+ * \+ `authors`.
+ * \* `name`: Renamed as `evolutioncms-snippets-ddgetdocuments` from `dd/modxevo-snippet-ddgetdocuments`.
+ * \* `require`:→ `dd/evolutioncms-libraries-ddtools`: Renamed from `dd/modxevo-library-ddtools`.
+
+
## Version 1.0 (2020-03-11)
* \* Attention! (MODX)EvolutionCMS.libraries.ddTools >= 0.30 is required.
* \+ Providers → Customdbtable. Get resources from custom DB table.
@@ -26,4 +42,5 @@
* \+ The first release.
+
\ No newline at end of file
diff --git a/README.md b/README.md
index 5f628cd..a480a9b 100644
--- a/README.md
+++ b/README.md
@@ -4,10 +4,11 @@ A snippet for fetching and parsing resources from the document tree or custom DB
## Requires
+
* PHP >= 5.4
* 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.30
+* [(MODX)EvolutionCMS.libraries.ddTools](https://code.divandesign.biz/modx/ddtools) >= 0.40.1
## Documentation
@@ -19,7 +20,7 @@ A snippet for fetching and parsing resources from the document tree or custom DB
#### 1. Elements → Snippets: Create a new snippet with the following data
1. Snippet name: `ddGetDocuments`.
-2. Description: `1.0 A snippet for fetching and parsing resources from the document tree or custom DB table by a custom rule.`.
+2. Description: `1.1 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.
@@ -568,6 +569,7 @@ Output in [YML format](https://yandex.ru/support/partnermarket/export/yml.html).
* `[+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:`
@@ -698,4 +700,7 @@ Output in [YML format](https://yandex.ru/support/partnermarket/export/yml.html).
* **Required**
-## [Home page →](https://code.divandesign.biz/modx/ddgetdocuments)
\ No newline at end of file
+## [Home page →](https://code.divandesign.biz/modx/ddgetdocuments)
+
+
+
\ No newline at end of file
diff --git a/composer.json b/composer.json
index 84c606d..e32139e 100644
--- a/composer.json
+++ b/composer.json
@@ -1,7 +1,7 @@
{
- "name": "dd/modxevo-snippet-ddgetdocuments",
+ "name": "dd/evolutioncms-snippets-ddgetdocuments",
"type": "modxevo-snippet",
- "version": "1.0.0",
+ "version": "1.1.0",
"description": "A snippet for fetching and parsing resources from the document tree or custom DB table by a custom rule.",
"keywords": [
"modx",
@@ -17,11 +17,26 @@
"get documents",
"ddgetdocuments"
],
+ "homepage": "https://code.divandesign.biz/modx/ddgetdocuments",
+ "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"
+ }
+ ],
"license": "MIT",
"require": {
"php": ">=5.4.0",
- "dd/modxevo-library-ddtools": ">=0.30",
- "composer/installers": "~1.0"
+ "dd/evolutioncms-libraries-ddtools": ">=0.40.1",
+ "composer/installers": "~1.0.0"
},
"autoload": {
"psr-4": {
diff --git a/ddGetDocuments_snippet.php b/ddGetDocuments_snippet.php
index f6ddb6e..dd4492e 100644
--- a/ddGetDocuments_snippet.php
+++ b/ddGetDocuments_snippet.php
@@ -1,13 +1,13 @@
getConfig('base_path') .
'assets/snippets/ddGetDocuments/'
;
+$snippetPath_src =
+ $snippetPath .
+ 'src' .
+ DIRECTORY_SEPARATOR
+;
//Include (MODX)EvolutionCMS.libraries.ddTools
if(!class_exists('\ddTools')){
require_once(
- $modx->config['base_path'] .
+ $modx->getConfig('base_path') .
'assets/libs/ddTools/modx.ddtools.class.php'
);
}
@@ -36,13 +41,13 @@
}
//Backward compatibility
-extract(\ddTools::verifyRenamedParams(
- $params,
- [
+extract(\ddTools::verifyRenamedParams([
+ 'params' => $params,
+ 'compliance' => [
'outputter' => 'outputFormat',
'outputterParams' => 'outputFormatParams'
]
-));
+]));
//General
$total =
@@ -77,7 +82,7 @@
$provider :
'parent'
;
-$providerClass = \ddGetDocuments\DataProvider\DataProvider::includeProviderByName($provider);
+$dataProviderClass = \ddGetDocuments\DataProvider\DataProvider::includeProviderByName($provider);
$providerParams =
isset($providerParams) ?
$providerParams :
@@ -114,7 +119,7 @@
''
;
-if(class_exists($providerClass)){
+if(class_exists($dataProviderClass)){
//Prepare provider params
$providerParams = \ddTools::encodedStringToArray($providerParams);
//Prepare extender params
@@ -176,35 +181,31 @@
$extenders as
$extenderName
){
- $extender = \ddGetDocuments\Extender\Extender::createChildInstance([
+ $extenderObject = \ddGetDocuments\Extender\Extender::createChildInstance([
'name' => $extenderName,
'parentDir' =>
- $snippetPath .
- 'src' .
- DIRECTORY_SEPARATOR .
+ $snippetPath_src .
'Extender'
,
//Passing parameters into constructor
'params' => $input->extendersParams->{$extenderName}
]);
//Passing a link to the storage
- $extendersStorage[$extenderName] = $extender;
+ $extendersStorage[$extenderName] = $extenderObject;
//Overwrite the snippet parameters with the result of applying them to the current extender
- $input->snippetParams = $extender->applyToSnippetParams($input->snippetParams);
+ $input->snippetParams = $extenderObject->applyToSnippetParams($input->snippetParams);
}
- $dataProvider = new $providerClass($input);
+ $dataProviderObject = new $dataProviderClass($input);
if ($outputter != 'raw'){
- $input->outputterParams->dataProvider = $dataProvider;
+ $input->outputterParams->dataProvider = $dataProviderObject;
$outputterObject = \ddGetDocuments\Outputter\Outputter::createChildInstance([
'name' => $outputter,
'parentDir' =>
- $snippetPath .
- 'src' .
- DIRECTORY_SEPARATOR .
+ $snippetPath_src .
'Outputter'
,
//Passing parameters into constructor
@@ -212,23 +213,23 @@
]);
}
- $providerResult = $dataProvider->get();
+ $dataProviderResult = $dataProviderObject->get();
- $data = new \ddGetDocuments\Output($providerResult);
+ $outputData = new \ddGetDocuments\Output($dataProviderResult);
//Iterate through all extenders again to apply them to the output
foreach(
$extendersStorage as
$extenderName =>
- $extender
+ $extenderObject
){
- $data->extenders[$extenderName] = $extender->applyToOutput($providerResult);
+ $outputData->extenders[$extenderName] = $extenderObject->applyToOutput($dataProviderResult);
}
if ($outputter == 'raw'){
- $snippetResult = $data;
+ $snippetResult = $outputData;
}else{
- $snippetResult = $outputterObject->parse($data);
+ $snippetResult = $outputterObject->parse($outputData);
}
}
diff --git a/src/DataProvider/Customdbtable/DataProvider.php b/src/DataProvider/Customdbtable/DataProvider.php
index 28b6371..8c503d3 100644
--- a/src/DataProvider/Customdbtable/DataProvider.php
+++ b/src/DataProvider/Customdbtable/DataProvider.php
@@ -2,8 +2,7 @@
namespace ddGetDocuments\DataProvider\Customdbtable;
-class DataProvider extends \ddGetDocuments\DataProvider\DataProvider
-{
+class DataProvider extends \ddGetDocuments\DataProvider\DataProvider {
protected
$resourcesTableName = ''
;
diff --git a/src/DataProvider/DataProvider.php b/src/DataProvider/DataProvider.php
index df9adb0..511aa7c 100644
--- a/src/DataProvider/DataProvider.php
+++ b/src/DataProvider/DataProvider.php
@@ -30,7 +30,7 @@ abstract class DataProvider extends \DDTools\BaseClass {
*/
private $getResourcesDataFromDb_tvsSQL = 'JSON_OBJECTAGG(
`tvName`.`name`,
- `tvValue`.`value`
+ coalesce(`tvValue`.`value`, `tvName`.`default_text`)
)';
/**
@@ -76,7 +76,7 @@ public final static function includeProviderByName($providerName){
/**
* __construct
- * @version 1.2.4 (2020-03-11)
+ * @version 1.3 (2020-05-20)
*
* @param $input {\ddGetDocuments\Input}
*/
@@ -132,7 +132,7 @@ function __construct(\ddGetDocuments\Input $input){
LEADING "{" FROM TRIM(
TRAILING "}" FROM JSON_OBJECT(
`tvName`.`name`,
- `tvValue`.`value`
+ coalesce(`tvValue`.`value`, `tvName`.`default_text`)
)
)
)
@@ -588,7 +588,7 @@ protected final function prepareQueryData($params = []){
/**
* prepareQuery
- * @version 1.2.1 (2020-03-10)
+ * @version 1.3 (2020-05-20)
*
* @param $params {arrayAssociative|stdClass}
* @param $params['resourcesIds'] — Document IDs to get ($this->filter will be used). Default: ''.
@@ -627,11 +627,15 @@ protected function prepareQuery($params = []){
SELECT
' . $this->getResourcesDataFromDb_tvsSQL . '
FROM
- ' . \ddTools::$tables['site_tmplvar_contentvalues'] . ' as `tvValue`,
- ' . \ddTools::$tables['site_tmplvars'] . ' as `tvName`
+ ' . \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
- `tvName`.`id` = `tvValue`.`tmplvarid` AND
- `resources`.`id` = `tvValue`.`contentid`
+ `resources`.`id` = `content`.`id`
) as `TVs`
';
}
diff --git a/src/DataProvider/DataProviderOutput.php b/src/DataProvider/DataProviderOutput.php
index 78d3c34..3c34f04 100644
--- a/src/DataProvider/DataProviderOutput.php
+++ b/src/DataProvider/DataProviderOutput.php
@@ -2,8 +2,7 @@
namespace ddGetDocuments\DataProvider;
-class DataProviderOutput
-{
+class DataProviderOutput {
public
$items,
$totalFound
diff --git a/src/DataProvider/Parent/DataProvider.php b/src/DataProvider/Parent/DataProvider.php
index 80a8179..d085bfc 100644
--- a/src/DataProvider/Parent/DataProvider.php
+++ b/src/DataProvider/Parent/DataProvider.php
@@ -2,8 +2,7 @@
namespace ddGetDocuments\DataProvider\Parent;
-class DataProvider extends \ddGetDocuments\DataProvider\DataProvider
-{
+class DataProvider extends \ddGetDocuments\DataProvider\DataProvider {
protected
$filter = '`published` = 1 AND `deleted` = 0',
diff --git a/src/DataProvider/Select/DataProvider.php b/src/DataProvider/Select/DataProvider.php
index e933d86..921f5bc 100644
--- a/src/DataProvider/Select/DataProvider.php
+++ b/src/DataProvider/Select/DataProvider.php
@@ -2,8 +2,7 @@
namespace ddGetDocuments\DataProvider\Select;
-class DataProvider extends \ddGetDocuments\DataProvider\DataProvider
-{
+class DataProvider extends \ddGetDocuments\DataProvider\DataProvider {
protected
$filter = null,
diff --git a/src/Extender/Pagination/Extender.php b/src/Extender/Pagination/Extender.php
index 48d29b4..eae7086 100644
--- a/src/Extender/Pagination/Extender.php
+++ b/src/Extender/Pagination/Extender.php
@@ -4,8 +4,7 @@
use ddGetDocuments\DataProvider\DataProviderOutput;
-class Extender extends \ddGetDocuments\Extender\Extender
-{
+class Extender extends \ddGetDocuments\Extender\Extender {
private
/**
* @property $snippetParams {stdClass}
@@ -113,7 +112,7 @@ public function applyToSnippetParams($snippetParams){
/**
* applyToOutput
- * @version 1.1.9 (2020-03-11)
+ * @version 1.2 (2020-06-22)
*
* @param $dataProviderOutput {\ddGetDocuments\DataProvider\DataProviderOutput}
*
@@ -237,7 +236,8 @@ public function applyToOutput(DataProviderOutput $dataProviderOutput){
,
'totalPages' => $pagesTotal
]
- ]))
+ ])),
+ 'totalPages' => $pagesTotal
]
]));
}
diff --git a/src/Extender/Search/Extender.php b/src/Extender/Search/Extender.php
index 6e6dfeb..37640f5 100644
--- a/src/Extender/Search/Extender.php
+++ b/src/Extender/Search/Extender.php
@@ -4,8 +4,7 @@
use ddGetDocuments\DataProvider\DataProviderOutput;
-class Extender extends \ddGetDocuments\Extender\Extender
-{
+class Extender extends \ddGetDocuments\Extender\Extender {
private
$currentQuery = ''
;
diff --git a/src/Extender/Tagging/Extender.php b/src/Extender/Tagging/Extender.php
index 66ae1cf..551fd93 100644
--- a/src/Extender/Tagging/Extender.php
+++ b/src/Extender/Tagging/Extender.php
@@ -4,8 +4,7 @@
use ddGetDocuments\DataProvider\DataProviderOutput;
-class Extender extends \ddGetDocuments\Extender\Extender
-{
+class Extender extends \ddGetDocuments\Extender\Extender {
private
//Current selected tags
$currentTags = []
diff --git a/src/Outputter/Json/Outputter.php b/src/Outputter/Json/Outputter.php
index be9bb88..7fd8015 100644
--- a/src/Outputter/Json/Outputter.php
+++ b/src/Outputter/Json/Outputter.php
@@ -8,11 +8,11 @@ class Outputter extends \ddGetDocuments\Outputter\Outputter
{
/**
* parse
- * @version 2.1.2 (2019-03-11)
+ * @version 2.1.4 (2020-06-08)
*
* @param $data {Output}
*
- * @return {string_json_array}
+ * @return {stringJsonArray}
*/
public function parse(Output $data){
$result = [];
@@ -20,7 +20,7 @@ public function parse(Output $data){
//Пройдемся по полученным данным
foreach(
$data->provider->items as
- $itemIndex => $itemData
+ $itemData
){
$result_item = [];
diff --git a/src/Outputter/Sitemap/Outputter.php b/src/Outputter/Sitemap/Outputter.php
index eda4c2e..9387ba2 100644
--- a/src/Outputter/Sitemap/Outputter.php
+++ b/src/Outputter/Sitemap/Outputter.php
@@ -4,8 +4,7 @@
use ddGetDocuments\Output;
-class Outputter extends \ddGetDocuments\Outputter\Outputter
-{
+class Outputter extends \ddGetDocuments\Outputter\Outputter {
protected
$priorityTVName = 'general_seo_sitemap_priority',
$changefreqTVName = 'general_seo_sitemap_changefreq',
@@ -56,7 +55,7 @@ function __construct($params = []){
/**
* parse
- * @version 1.1.1 (2019-03-19)
+ * @version 1.1.2 (2020-04-30)
*
* @param $data {Output}
*
@@ -65,7 +64,8 @@ function __construct($params = []){
public function parse(Output $data){
foreach (
$data->provider->items as
- $docIndex => $docData
+ $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 8f9fb4f..eb48c46 100644
--- a/src/Outputter/String/Outputter.php
+++ b/src/Outputter/String/Outputter.php
@@ -4,8 +4,7 @@
use ddGetDocuments\Output;
-class Outputter extends \ddGetDocuments\Outputter\Outputter
-{
+class Outputter extends \ddGetDocuments\Outputter\Outputter {
public
$placeholders = []
;
diff --git a/src/Outputter/Yandexmarket/Outputter.php b/src/Outputter/Yandexmarket/Outputter.php
index 51abfbd..6ea556e 100644
--- a/src/Outputter/Yandexmarket/Outputter.php
+++ b/src/Outputter/Yandexmarket/Outputter.php
@@ -4,8 +4,7 @@
use ddGetDocuments\Output;
-class Outputter extends \ddGetDocuments\Outputter\Outputter
-{
+class Outputter extends \ddGetDocuments\Outputter\Outputter {
protected
/**
* @property $templates {stdClass}