Skip to content

Commit 35f9829

Browse files
committed
Version 2.5.1
2 parents 2d5e28f + 9a23784 commit 35f9829

8 files changed

Lines changed: 354 additions & 317 deletions

File tree

CHANGELOG.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
# (MODX)EvolutionCMS.snippets.ddGetFileInfo changelog
22

33

4+
## Version 2.5.1 (2025-06-17)
5+
6+
* \* Refactoring and other small changes.
7+
* \* `\ddTools::getTpl` is used instead of `$modx->getTpl` (means a bit less bugs).
8+
* \* Attention! PHP >= 7.4 is required (not tested with older versions).
9+
* \* Attention! (MODX)EvolutionCMS.libraries.ddTools >= 0.60 is required.
10+
11+
412
## Version 2.5 (2021-04-25)
13+
514
* \* Attention! PHP >= 5.6 is required.
615
* \* Attention! (MODX)EvolutionCMS.libraries.ddTools >= 0.49 is required.
716
* \* Parameters:
@@ -23,23 +32,27 @@
2332

2433

2534
## Version 2.4 (2021-01-15)
35+
2636
* \+ The ability to return the MIME content type for a file (see the `tpl` parameter).
2737
* \* Parameters → `tpl`: Wrong `[+file+]` placeholder was fixed.
2838
* \+ README, CHANGELOG: Style improvements.
2939
* \+ README → Documentation → Parameters description → `tpl_placeholders`: Text improved.
3040

3141

3242
## Version 2.3 (2019-12-12)
43+
3344
* \+ If `file` doesn't contain base path, the snippet will add it.
3445
* \* `fopen` is not used anymore because `@` operator doesn't always work.
3546
* \* `filesize` is used only for local files, not for URLs. `@` steel used because not only URLs will generate errors.
3647

3748

3849
## Version 2.2.1 (2018-11-24)
50+
3951
* \* Critical variable name error was fixed.
4052

4153

4254
## Version 2.2 (2018-11-24)
55+
4356
* \* Attention! PHP >= 5.4 is required.
4457
* \* Attention! MODXEvo >= 1.1 is required.
4558
* \* Attention! MODXEvo.libraries.ddTools >= 0.18 is required.
@@ -58,8 +71,9 @@
5871

5972

6073
## Version 1.0 (2010)
74+
6175
* \+ The first release.
6276

6377

64-
<link rel="stylesheet" type="text/css" href="https://DivanDesign.ru/assets/files/ddMarkdown.css" />
78+
<link rel="stylesheet" type="text/css" href="https://raw.githack.com/DivanDesign/CSS.ddMarkdown/master/style.min.css" />
6579
<style>ul{list-style:none;}</style>

CHANGELOG_ru.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
# (MODX)EvolutionCMS.snippets.ddGetFileInfo changelog
22

33

4+
## Версия 2.5.1 (2025-06-17)
5+
6+
* \* Рефакторинг и другие небольшие изменения.
7+
* \* `\ddTools::getTpl` используется вместо `$modx->getTpl` (стало чуть меньше багов).
8+
* \* Внимание! Требуется PHP >= 7.4 (не тестировался с более старыми версиями).
9+
* \* Внимание! Требуется (MODX)EvolutionCMS.libraries.ddTools >= 0.60.
10+
11+
412
## Версия 2.5 (2021-04-25)
13+
514
* \* Внимание! Требуется PHP >= 5.6.
615
* \* Внимание! Требуется (MODX)EvolutionCMS.libraries.ddTools >= 0.49.
716
* \* Параметры:
@@ -23,13 +32,15 @@
2332

2433

2534
## Версия 2.4 (2021-01-15)
35+
2636
* \+ Возможность возвращать MIME тип файла (см. параметр `tpl`).
2737
* \* Параметры → `tpl`: Некорректный плейсходлер `[+file+]` исправлен.
2838
* \+ README, CHANGELOG: Улучшения стиля.
2939
* \+ README → Документация → Описание параметров → `tpl_placeholders`: Текст улучшен.
3040

3141

3242
## Версия 2.1 (2015-12-28)
43+
3344
* \+ Добавлен вывод типа файла (плэйсхолдер `[+type+]` при выводе через `tpl` и `type` в `output` соответственно). Удобно использовать с [Font Awesome](http://fontawesome.io/).
3445
* \* Нулевой размер файла выводится (не считается ошибкой filesize).
3546
* \* Сниппет `ddGetDocumentField` больше не используется, значение поля документа получается при помощи метода `ddTools::getTemplateVarOutput`.
@@ -38,6 +49,7 @@
3849

3950

4051
## Версия 2.0 (2014-03-25)
52+
4153
* \* Сниппет переименован в `ddGetFileInfo`.
4254
* \* Следующие параметры были переименованы:
4355
* \* `getField` → `docField`.
@@ -53,40 +65,47 @@
5365

5466

5567
## Версия 1.6.1 (2013-10-23)
68+
5669
* \+ Существование файла теперь проверяется через `fopen`, что позволяет работать с удалёнными файлами.
5770
* \* Если имя файла начинается с сивола `/`, он всегда вырезается.
5871
* \* Если размер файла получить не удалось (например, файл где-то в интернетах), плэйсхолдер `filesize` в чанке `tpl` будет содержать пустую строку.
5972
* \* Рефакторинг.
6073

6174

6275
## Версия 1.6 (2013-08-14)
76+
6377
* \* Внимание! Нарушена обратная совместимость.
6478
* \+ При выводе через шаблон добавлен плэйсхолдер `[+file+]` (полный адрес файла).
6579
* \* При выводе через шаблон плэйсхолдер `[+ext+]` переименован в `[+fileext+]` (для однообразности).
6680
* \- Удалён параметр `getPublished` за ненадобностью.
6781

6882

6983
## Версия 1.5 (2013-01-17)
84+
7085
* \+ Добавлена возможность передавать дополнительные (параметр `placeholders`) в чанк `tpl`.
7186
* \* Внимание! Сниппет теперь использует библиотеку ddTools 0.4 (при использовании параметра `placeholders`).
7287

7388

7489
## Версия 1.4 (2012-08-13)
90+
7591
* \+ При выводе через шаблон добавлены плэйсхолдеры: `[+filename+]` (имя файла), `[+filepath+]` (путь к файлу).
7692

7793

7894
## Версия 1.3 (2011-06-07)
95+
7996
* \+ Добавлена возможность получения адреса файла из поля заданного документа (добавлены параметры `getId`, `getField`, `getPublished`).
8097

8198

8299
## Версия 1.2 (2011-04-20)
100+
83101
* \+ Если файл получить не удалось, пробуем отрезать '/' от начала имени.
84102
* \+ Добавлен плейсхолдер `[+ext+]`, в который записывается расширение файла при выводе через шаблон.
85103

86104

87105
## Версия 1.0 (2010)
106+
88107
* \+ Первый релиз.
89108

90109

91-
<link rel="stylesheet" type="text/css" href="https://DivanDesign.ru/assets/files/ddMarkdown.css" />
110+
<link rel="stylesheet" type="text/css" href="https://raw.githack.com/DivanDesign/CSS.ddMarkdown/master/style.min.css" />
92111
<style>ul{list-style:none;}</style>

README.md

Lines changed: 69 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -4,79 +4,75 @@ Displays information about a file: type, mime, size in readable format, path, na
44

55

66
## Requires
7-
* PHP >= 5.6
7+
* PHP >= 7.4
88
* [(MODX)EvolutionCMS](https://github.com/evolution-cms/evolution) >= 1.1
9-
* [(MODX)EvolutionCMS.libraries.ddTools](https://code.divandesign.biz/modx/ddtools) >= 0.49
9+
* [(MODX)EvolutionCMS.libraries.ddTools](https://code.divandesign.ru/modx/ddtools) >= 0.60
1010

1111

12-
## Documentation
12+
## Installation
1313

1414

15-
### Installation
16-
17-
18-
#### Manually
19-
20-
21-
##### 1. Elements → Snippets: Create a new snippet with the following data
22-
23-
1. Snippet name: `ddGetFileInfo`.
24-
2. Description: `<b>2.5</b> Displays information about a file: type, mime, size in readable format, path, name, extension, etc.`.
25-
3. Category: `Core`.
26-
4. Parse DocBlock: `no`.
27-
5. Snippet code (php): Insert content of the `ddGetFileInfo_snippet.php` file from the archive.
28-
29-
30-
##### 2. Elements → Manage Files
31-
32-
1. Create a new folder `assets/snippets/ddGetFileInfo/`.
33-
2. Extract the archive to the folder (except `ddGetFileInfo_snippet.php`).
34-
35-
36-
#### Using [(MODX)EvolutionCMS.libraries.ddInstaller](https://github.com/DivanDesign/EvolutionCMS.libraries.ddInstaller)
15+
### Using [(MODX)EvolutionCMS.libraries.ddInstaller](https://github.com/DivanDesign/EvolutionCMS.libraries.ddInstaller)
3716

3817
Just run the following PHP code in your sources or [Console](https://github.com/vanchelo/MODX-Evolution-Ajax-Console):
3918

4019
```php
41-
//Include (MODX)EvolutionCMS.libraries.ddInstaller
20+
// Include (MODX)EvolutionCMS.libraries.ddInstaller
4221
require_once(
43-
$modx->getConfig('base_path') .
44-
'assets/libs/ddInstaller/require.php'
22+
$modx->getConfig('base_path')
23+
. 'assets/libs/ddInstaller/require.php'
4524
);
4625

47-
//Install (MODX)EvolutionCMS.snippets.ddGetFileInfo
26+
// Install (MODX)EvolutionCMS.snippets.ddGetFileInfo
4827
\DDInstaller::install([
4928
'url' => 'https://github.com/DivanDesign/EvolutionCMS.snippets.ddGetFileInfo',
50-
'type' => 'snippet'
5129
]);
5230
```
5331

5432
* If `ddGetFileInfo` is not exist on your site, `ddInstaller` will just install it.
5533
* If `ddGetFileInfo` is already exist on your site, `ddInstaller` will check it version and update it if needed.
5634

5735

58-
### Parameters description
36+
### Manually
37+
38+
39+
#### 1. Elements → Snippets: Create a new snippet with the following data
40+
41+
1. Snippet name: `ddGetFileInfo`.
42+
2. Description: `<b>2.5.1</b> Displays information about a file: type, mime, size in readable format, path, name, extension, etc.`.
43+
3. Category: `Core`.
44+
4. Parse DocBlock: `no`.
45+
5. Snippet code (php): Insert content of the `ddGetFileInfo_snippet.php` file from the archive.
46+
47+
48+
#### 2. Elements → Manage Files
49+
50+
1. Create a new folder `assets/snippets/ddGetFileInfo/`.
51+
2. Extract the archive to the folder (except `ddGetFileInfo_snippet.php`).
52+
53+
54+
## Parameters description
5955

6056
* `file`
61-
* Desctription: File name (path).
57+
* Description: File name (path).
6258
* Valid values:
6359
* `stringFilePath` — the path to the file can be specified relative to the site root (`/` at the beginning does not matter, both variants are supported), or the full path (including `$modx->config['base_path']`)
6460
* `stringUrl` — you can specify not only a local file, but also an Internet address, but in this case not all functions are supported for objective reasons
6561
* **Required**
6662

6763
* `file_docField`
68-
* Desctription: A document field (including TV) containing the path to the file (if you want the snippet to get the file address from the document field).
64+
* Description: A document field (including TV) containing the path to the file (if you want the snippet to get the file address from the document field).
6965
* Valid values: `string`
7066
* Default value: —
7167

7268
* `file_docId`
73-
* Desctription: Resource ID, from the field of which you want to get the file address.
69+
* Description: Resource ID, from the field of which you want to get the file address.
7470
* Valid values: `integerDocId`
7571
* Default value: —
7672

7773
* `sizeUnitFormat`
78-
* Desctription: Format of file size unit.
79-
Values are case insensitive (the following names are equal: `'enshort'`, `'EnShort'`, `'ENSHORT'`, etc).
74+
* Description: Format of file size unit.
75+
* Values are case insensitive (the following names are equal: `'enshort'`, `'EnShort'`, `'ENSHORT'`, etc).
8076
* Valid values:
8177
* `'none'`
8278
* `'EnShort'` — e. g. `MB`
@@ -86,12 +82,12 @@ require_once(
8682
* Default value: `'EnShort'`
8783

8884
* `sizePrecision`
89-
* Desctription: The number of decimal digits to round to.
85+
* Description: The number of decimal digits to round to.
9086
* Valid values: `integer`
9187
* Default value: `2`
9288

9389
* `output`
94-
* Desctription: File information to output (if `tpl` is not set).
90+
* Description: File information to output (if `tpl` is not set).
9591
* Valid values:
9692
* `'size'`
9793
* `'extension'`
@@ -102,74 +98,74 @@ require_once(
10298
* Default value: `'size'`
10399

104100
* `tpl`
105-
* Desctription: Output template (if the parameter is absent, file data corresponding to `output` will be returned).
106-
Available placeholders:
107-
* `[+file+]` — full file address
108-
* `[+name+]` — file name
109-
* `[+path+]` — file path
110-
* `[+size+]` — file size with a unit in a human-readable format
111-
* `[+extension+]` — file extension
112-
* `[+type+]` — file type:
113-
* `'archive'`
114-
* `'image'`
115-
* `'video'`
116-
* `'audio'`
117-
* `'text'`
118-
* `'pdf'`
119-
* `'word'`
120-
* `'excel'`
121-
* `'powerpoint'`
122-
* `[+typeMime+]` — content type in MIME format (only for local files, not for URLs)
101+
* Description: Output template (if the parameter is absent, file data corresponding to `output` will be returned).
102+
* Available placeholders:
103+
* `[+file+]` — full file address
104+
* `[+name+]` — file name
105+
* `[+path+]` — file path
106+
* `[+size+]` — file size with a unit in a human-readable format
107+
* `[+extension+]` — file extension
108+
* `[+type+]` — file type:
109+
* `'archive'`
110+
* `'image'`
111+
* `'video'`
112+
* `'audio'`
113+
* `'text'`
114+
* `'pdf'`
115+
* `'word'`
116+
* `'excel'`
117+
* `'powerpoint'`
118+
* `[+typeMime+]` — content type in MIME format (only for local files, not for URLs)
123119
* Valid values:
124120
* `stringChunkName`
125121
* `string` — use inline templates starting with `@CODE:`
126122
* Default value: —
127123

128124
* `tpl_placeholders`
129-
* Desctription:
130-
Additional data has to be passed into the `tpl`.
131-
Nested objects and arrays are supported too:
132-
* `{"someOne": "1", "someTwo": "test" }` => `[+someOne+], [+someTwo+]`.
133-
* `{"some": {"a": "one", "b": "two"} }` => `[+some.a+]`, `[+some.b+]`.
134-
* `{"some": ["one", "two"] }` => `[+some.0+]`, `[+some.1+]`.
125+
* Description: Additional data has to be passed into the `tpl`.
126+
* Nested objects and arrays are supported too:
127+
* `{"someOne": "1", "someTwo": "test" }` => `[+someOne+], [+someTwo+]`.
128+
* `{"some": {"a": "one", "b": "two"} }` => `[+some.a+]`, `[+some.b+]`.
129+
* `{"some": ["one", "two"] }` => `[+some.0+]`, `[+some.1+]`.
135130
* Valid values:
136131
* `stringJsonObject` — as [JSON](https://en.wikipedia.org/wiki/JSON)
137132
* `stringHjsonObject` — as [HJSON](https://hjson.github.io/)
138-
* `stringQueryFormated` — as [Query string](https://en.wikipedia.org/wiki/Query_string)
133+
* `stringQueryFormatted` — as [Query string](https://en.wikipedia.org/wiki/Query_string)
139134
* It can also be set as a native PHP object or array (e. g. for calls through `$modx->runSnippet`):
140135
* `arrayAssociative`
141136
* `object`
142137
* Default value: —
143138

144139

145-
### Examples
140+
## Examples
146141

147142

148-
#### Run the snippet through `\DDTools\Snippet::runSnippet` without DB and eval
143+
### Run the snippet through `\DDTools\Snippet::runSnippet` without DB and eval
149144

150145
```php
151-
//Include (MODX)EvolutionCMS.libraries.ddTools
146+
// Include (MODX)EvolutionCMS.libraries.ddTools
152147
require_once(
153-
$modx->getConfig('base_path') .
154-
'assets/libs/ddTools/modx.ddtools.class.php'
148+
$modx->getConfig('base_path')
149+
. 'assets/libs/ddTools/modx.ddtools.class.php'
155150
);
156151

157-
//Run (MODX)EvolutionCMS.snippets.ddGetFileInfo
152+
// Run (MODX)EvolutionCMS.snippets.ddGetFileInfo
158153
\DDTools\Snippet::runSnippet([
159154
'name' => 'ddGetFileInfo',
160155
'params' => [
161156
'file' => 'assets/images/evo-logo.png',
162-
'output' => 'size'
163-
]
157+
'output' => 'size',
158+
],
164159
]);
165160
```
166161

167162

168163
## Links
169164

170-
* [Home page](https://code.divandesign.biz/modx/ddgetfileinfo)
165+
* [Home page](https://code.divandesign.ru/modx/ddgetfileinfo)
171166
* [Telegram chat](https://t.me/dd_code)
172167
* [Packagist](https://packagist.org/packages/dd/evolutioncms-snippets-ddgetfileinfo)
168+
* [GitHub](https://github.com/DivanDesign/EvolutionCMS.snippets.ddGetFileInfo)
173169

174170

175-
<link rel="stylesheet" type="text/css" href="https://DivanDesign.ru/assets/files/ddMarkdown.css" />
171+
<link rel="stylesheet" type="text/css" href="https://raw.githack.com/DivanDesign/CSS.ddMarkdown/master/style.min.css" />

0 commit comments

Comments
 (0)