Skip to content

Commit

Permalink
Version 0.60
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronef committed May 14, 2023
2 parents c10961a + 51da4ce commit 47964ab
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 19 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# (MODX)EvolutionCMS.libraries.ddTools changelog


## Version 0.60 (2023-05-14)
* \+ `\ddTools::getTpl`: The new public method (see README).


## Version 0.59 (2023-03-30)
* \+ `\ddTools::parseText`: In addition to accessing nested properties via placeholders like `'[+prop.subProp+]'`, you can get whole object as JSON via placeholders like `'[+prop+]'` (see README → Examples).

Expand Down Expand Up @@ -557,5 +561,5 @@
* \+ The first release.


<link rel="stylesheet" type="text/css" href="https://DivanDesign.ru/assets/files/ddMarkdown.css" />
<link rel="stylesheet" type="text/css" href="https://raw.githack.com/DivanDesign/CSS.ddMarkdown/master/style.min.css" />
<style>ul{list-style:none;}</style>
6 changes: 5 additions & 1 deletion CHANGELOG_ru.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# (MODX)EvolutionCMS.libraries.ddTools changelog


## Версия 0.60 (2023-05-14)
* \+ `\ddTools::getTpl`: Новый публичный метод (см. README).


## Версия 0.59 (2023-03-30)
* \+ `\ddTools::parseText`: Помимо доступа свойствам вложенных объектов через плейсхоледры вида `'[+prop.subProp+]'`, вы также можете получить весь объект в JSON через плейсхолдеры вида `'[+prop+]'` (см. README → Примеры).

Expand Down Expand Up @@ -559,5 +563,5 @@
* \+ Первый релиз.


<link rel="stylesheet" type="text/css" href="https://DivanDesign.ru/assets/files/ddMarkdown.css" />
<link rel="stylesheet" type="text/css" href="https://raw.githack.com/DivanDesign/CSS.ddMarkdown/master/style.min.css" />
<style>ul{list-style:none;}</style>
30 changes: 26 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,28 @@ All kinds of query parameters, hash, ports, etc. are not modified.
* Valid values: `string`


### `\ddTools::getTpl($tpl = '')`

The same as `$modx->getTpl` with some differences:
* This method always returns `string` regardless of the parameter type. For example, `$modx->getTpl(null)` returns `null`, this method returns `''`.
* The parameter is optional. `$modx->getTpl()` throws an error, this method jsut returns `''`.
* `$modx->getTpl('@CODE:')` returns `'@CODE:'`, this method returns `''`.

* `$tpl`
* Desctription: Chunk name or inline template.
* Valid values:
* `stringChunkName`
* `string` — use inline templates starting with `@CODE:`
* Default value: `''`


#### Returns

* `$result`
* Desctription: Required template.
* Valid values: `string`


### `\ddTools::parseText($params)`

Replaces placeholders in a text with required values.
Expand Down Expand Up @@ -835,7 +857,7 @@ It's convenient to override this method in child classes if items are not plain
Simple abstract class with some small methods facilitating your work.
It is convenient to inherit your classes from this.

You can see an example of how it works in the [(MODX)EvolutionCMS.snippets.ddGetDocumentField](https://code.divandesign.biz/modx/ddgetdocumentfield) code.
You can see an example of how it works in the [(MODX)EvolutionCMS.snippets.ddGetDocumentField](https://code.divandesign.ru/modx/ddgetdocumentfield) code.


#### `\DDTools\Base\Base::setExistingProps($props)`
Expand Down Expand Up @@ -906,7 +928,7 @@ The same as `\DDTools\Base\Base::toJSON()`.

Simple trait for ancestors with some small methods facilitating your work.

You can see an example of how it works in the [(MODX)EvolutionCMS.snippets.ddGetDocumentField](https://code.divandesign.biz/modx/ddgetdocumentfield) code.
You can see an example of how it works in the [(MODX)EvolutionCMS.snippets.ddGetDocumentField](https://code.divandesign.ru/modx/ddgetdocumentfield) code.


#### `\DDTools\Base\AncestorTrait::createChildInstance($params)`
Expand Down Expand Up @@ -2201,10 +2223,10 @@ array(

## Links

* [Home page](https://code.divandesign.biz/modx/ddtools)
* [Home page](https://code.divandesign.ru/modx/ddtools)
* [Telegram chat](https://t.me/dd_code)
* [Packagist](https://packagist.org/packages/dd/evolutioncms-libraries-ddtools)
* [GitHub](https://github.com/DivanDesign/EvolutionCMS.libraries.ddTools)


<link rel="stylesheet" type="text/css" href="https://DivanDesign.ru/assets/files/ddMarkdown.css" />
<link rel="stylesheet" type="text/css" href="https://raw.githack.com/DivanDesign/CSS.ddMarkdown/master/style.min.css" />
13 changes: 3 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,24 @@
{
"name": "dd/evolutioncms-libraries-ddtools",
"type": "modxevo-library-ddtools",
"version": "0.59.0",
"version": "0.60.0",
"description": "A library with various tools facilitating your work.",
"keywords": [
"modx",
"modx evo",
"modx evolution",
"ddtools"
],
"homepage": "https://code.divandesign.biz/modx/ddtools",
"homepage": "https://code.divandesign.ru/modx/ddtools",
"authors": [
{
"name": "DD Group",
"email": "[email protected]",
"homepage": "https://code.divandesign.biz",
"role": "Owner"
},
{
"name": "Ilyas Ronef",
"email": "[email protected]",
"homepage": "https://ronef.ru",
"role": "Developer"
"role": "Owner"
},
{
"name": "Alexey Davydov",
"email": "[email protected]",
"homepage": "https://github.com/davalemic",
"role": "Developer"
},
Expand Down
40 changes: 37 additions & 3 deletions modx.ddtools.class.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php
/**
* EvolutionCMS.libraries.ddTools
* @version 0.59 (2023-03-30)
* @version 0.60 (2023-05-14)
*
* @see README.md
*
* @copyright 2012–2023 DD Group {@link https://DivanDesign.biz }
* @copyright 2012–2023 Ronef {@link https://Ronef.ru }
*/

global $modx;
Expand Down Expand Up @@ -891,6 +891,40 @@ public static function logEvent($params){
);
}

/**
* getTpl
* @version 1.0 (2023-05-14)
*
* @see README.md
*/
public static function getTpl($tpl = ''){
//Cast the parameter to a string
$tpl = $tpl . '';

$result = $tpl;

if (!empty($tpl)){
//$modx->getTpl('@CODE:') returns '@CODE:' O_o
if (
substr(
$tpl,
0,
6
) ==
'@CODE:'
){
$result = substr(
$tpl,
6
);
}else{
$result = self::$modx->getTpl($tpl);
}
}

return $result;
}

/**
* parseText
* @version 1.7 (2023-03-29)
Expand Down Expand Up @@ -2389,7 +2423,7 @@ public static function getDocumentChildrenTVarOutput(
* @desc Adds a required JS-file into a required MODX inner list according to its version and name. The method is used to register the scripts, that has already been connected manually.
* Be advised that the method does not add script code, but register its name and version to avoid future connections with $modx->regClientScript and $modx->regClientStartupScript, and the script code will be deleted if the script had been connected with $modx->regClientScript or $modx->regClientStartupScript.
*
* @see ddRegJsCssLinks snippet (http://code.divandesign.biz/modx/ddregjscsslinks), предназначенный для «правильного» подключения js и css. Даже при «ручном» подключении сниппет регистрирует то, что подключил, используя данный метод.
* @see ddRegJsCssLinks snippet (http://code.divandesign.ru/modx/ddregjscsslinks), предназначенный для «правильного» подключения js и css. Даже при «ручном» подключении сниппет регистрирует то, что подключил, используя данный метод.
*
* @param $params {stdClass|arrayAssociative} — Parameters, the pass-by-name style is used. @required
* @param $params->name {string} — Script name. @required
Expand Down

0 comments on commit 47964ab

Please sign in to comment.