Skip to content

Commit a43ea3b

Browse files
committed
Add fields "published", "published_at" to the File object
1 parent bfe9a34 commit a43ea3b

8 files changed

Lines changed: 109 additions & 28 deletions

File tree

_build/elements/settings.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
),
3939
'grid_fields' => array(
4040
'xtype' => 'textfield',
41-
'value' => 'id,thumb,name,title,description,group,private,download',
41+
'value' => 'id,thumb,name,title,description,group,published,private,download',
4242
'area' => 'fileman_main',
4343
),
4444
'pdotools' => array(

assets/components/fileman/js/mgr/widgets/files.grid.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ Ext.extend(FileMan.grid.Files, MODx.grid.Grid, {
368368
group: { sortable: true, width: 150 },
369369
extension: { sortable: true, width: 50 },
370370
download: { sortable: true, width: 50 },
371+
published: { sortable: true, width: 50, renderer: FileMan.utils.renderBoolean },
371372
private: { sortable: true, width: 50, renderer: FileMan.utils.renderBoolean },
372373
path: { sortable: true, width: 100 },
373374
};

assets/components/fileman/js/mgr/widgets/files.window.js

Lines changed: 55 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Ext.extend(FileMan.window.UpdateFile, MODx.Window, {
4949
},
5050

5151
getFields: function (config) {
52-
var fieldsTabGeneral = [
52+
let fieldsTabGeneral = [
5353
{
5454
xtype: 'hidden',
5555
name: 'id',
@@ -69,7 +69,7 @@ Ext.extend(FileMan.window.UpdateFile, MODx.Window, {
6969
name: 'description',
7070
id: config.id + '-description',
7171
anchor: '99%',
72-
height: 120
72+
height: 80
7373
},
7474
{
7575
xtype: 'textfield',
@@ -79,6 +79,49 @@ Ext.extend(FileMan.window.UpdateFile, MODx.Window, {
7979
anchor: '99%',
8080
allowBlank: true
8181
},
82+
{
83+
xtype: 'xdatetime',
84+
fieldLabel: _('fileman_published_at'),
85+
name: 'published_at',
86+
id: config.id + '-published_at',
87+
anchor: '50%',
88+
allowBlank: true,
89+
dateFormat: MODx.config.manager_date_format,
90+
timeFormat: MODx.config.manager_time_format,
91+
startDay: parseInt(MODx.config.manager_week_start),
92+
},
93+
{
94+
layout: 'column',
95+
border: false,
96+
items: [{
97+
columnWidth: .5,
98+
border: false,
99+
layout: 'form',
100+
items: [{
101+
xtype: 'xcheckbox',
102+
id: config.id + '-published',
103+
fieldLabel: _('fileman_published'),
104+
boxLabel: _('fileman_published_desc'),
105+
hideLabel: false,
106+
name: 'published'
107+
}]
108+
}, {
109+
columnWidth: .5,
110+
border: false,
111+
layout: 'form',
112+
items: [{
113+
xtype: 'xcheckbox',
114+
id: config.id + '-private',
115+
fieldLabel: _('fileman_private'),
116+
boxLabel: _('fileman_private_desc'),
117+
hideLabel: false,
118+
name: 'private'
119+
}]
120+
}]
121+
}
122+
];
123+
124+
let fieldsTabSettings = [
82125
{
83126
xtype: 'textfield',
84127
fieldLabel: _('fileman_name'),
@@ -87,17 +130,6 @@ Ext.extend(FileMan.window.UpdateFile, MODx.Window, {
87130
anchor: '99%',
88131
allowBlank: false
89132
},
90-
{
91-
xtype: 'xcheckbox',
92-
id: config.id + '-private',
93-
fieldLabel: _('fileman_private'),
94-
boxLabel: _('fileman_private_desc'),
95-
hideLabel: false,
96-
name: 'private'
97-
}
98-
];
99-
100-
var fieldsTabSettings = [
101133
{
102134
xtype: 'statictextfield',
103135
fieldLabel: _('fileman_path'),
@@ -112,13 +144,13 @@ Ext.extend(FileMan.window.UpdateFile, MODx.Window, {
112144
id: config.id + '-internal_name',
113145
anchor: '99%'
114146
},
115-
{
116-
xtype: 'statictextfield',
117-
fieldLabel: _('fileman_extension'),
118-
name: 'extension',
119-
id: config.id + '-extension',
120-
anchor: '99%'
121-
},
147+
// {
148+
// xtype: 'statictextfield',
149+
// fieldLabel: _('fileman_extension'),
150+
// name: 'extension',
151+
// id: config.id + '-extension',
152+
// anchor: '99%'
153+
// },
122154
{
123155
xtype: 'statictextfield',
124156
fieldLabel: _('fileman_fid'),
@@ -151,9 +183,8 @@ Ext.extend(FileMan.window.UpdateFile, MODx.Window, {
151183

152184
var result = [];
153185
if (FileMan.config.resource_id > 0) {
154-
result.push({ xtype: 'hidden', name: 'resource_id', id: config.id + '-resource_id' });
155-
}
156-
else {
186+
result.push({xtype: 'hidden', name: 'resource_id', id: config.id + '-resource_id'});
187+
} else {
157188
fieldsTabSettings.unshift({
158189
xtype: 'modx-combo',
159190
id: config.id + '-resource_id',
@@ -204,7 +235,7 @@ Ext.extend(FileMan.window.UpdateFile, MODx.Window, {
204235

205236
result.push({
206237
xtype: 'modx-tabs',
207-
defaults: { border: false, autoHeight: true },
238+
defaults: {border: false, autoHeight: true},
208239
deferredRender: false,
209240
border: true,
210241
hideMode: 'offsets',

core/components/fileman/lexicon/en/default.inc.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
$_lang['fileman_group'] = 'Group';
4040
$_lang['fileman_hash'] = 'SHA1 hash';
4141
$_lang['fileman_size'] = 'Size';
42+
$_lang['fileman_published'] = 'Published';
43+
$_lang['fileman_published_desc'] = 'The file will be displayed on the website.';
44+
$_lang['fileman_published_at'] = 'Date';
4245
$_lang['fileman_download'] = 'Number of downloads';
4346

4447
$_lang['fileman_file_tab_general'] = 'General';

core/components/fileman/lexicon/ru/default.inc.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,24 @@
3131
$_lang['fileman_sort_order'] = 'Порядок';
3232
$_lang['fileman_fid'] = 'ID файла';
3333
$_lang['fileman_thumb'] = 'Превью';
34-
$_lang['fileman_name'] = 'Название файла';
35-
$_lang['fileman_internal_name'] = 'Внутреннее название файла';
34+
$_lang['fileman_name'] = 'Имя файла';
35+
$_lang['fileman_internal_name'] = 'Внутреннее имя файла';
3636
$_lang['fileman_extension'] = 'Расширение файла';
3737
$_lang['fileman_path'] = 'Путь';
3838
$_lang['fileman_title'] = 'Заголовок';
3939
$_lang['fileman_description'] = 'Описание';
4040
$_lang['fileman_group'] = 'Группа';
4141
$_lang['fileman_hash'] = 'Контрольная сумма SHA1';
4242
$_lang['fileman_size'] = 'Размер';
43+
$_lang['fileman_published'] = 'Опубликован';
44+
$_lang['fileman_published_desc'] = 'Файл будет отображаться в публичной части сайта';
45+
$_lang['fileman_published_at'] = 'Дата';
4346
$_lang['fileman_download'] = 'Скачано';
4447

4548
$_lang['fileman_file_tab_general'] = 'Файл';
4649
$_lang['fileman_file_tab_settings'] = 'Настройки';
4750

48-
$_lang['fileman_file_err_name'] = 'Вы должны указать название файла.';
51+
$_lang['fileman_file_err_name'] = 'Вы должны указать имя файла.';
4952
$_lang['fileman_file_err_ae'] = 'Файл с таким именем уже существует.';
5053
$_lang['fileman_file_err_nf'] = 'Файл не найден.';
5154
$_lang['fileman_file_err_ns'] = 'Файл не указан.';

core/components/fileman/schema/fileman.mysql.schema.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
<field key="size" dbtype="int" precision="10" phptype="integer" attributes="unsigned" null="false" default="0"/>
1313
<field key="hash" dbtype="varchar" precision="50" phptype="string" null="false" default=""/>
1414

15+
<field key="published" dbtype="tinyint" precision="1" attributes="unsigned" phptype="boolean" null="false" default="1" />
1516
<field key="private" dbtype="tinyint" precision="1" phptype="boolean" attributes="unsigned" null="false" default="0"/>
17+
<field key="published_at" dbtype="datetime" phptype="datetime" null="true" />
1618
<field key="download" dbtype="int" precision="10" phptype="integer" attributes="unsigned" null="false" default="0"/>
1719

1820
<field key="resource_id" dbtype="int" precision="10" phptype="integer" null="false" default="0"/>
@@ -25,6 +27,9 @@
2527
<index alias="name" name="name" primary="false" unique="false" type="BTREE">
2628
<column key="name" length="" collation="A" null="false"/>
2729
</index>
30+
<index alias="published" name="published" primary="false" unique="false" type="BTREE">
31+
<column key="published" length="" collation="A" null="false"/>
32+
</index>
2833
<index alias="resource_id" name="resource_id" primary="false" unique="false" type="BTREE">
2934
<column key="resource_id" length="" collation="A" null="false"/>
3035
</index>

core/components/fileman/src/Model/File.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ class File extends \xPDO\Om\xPDOSimpleObject
1919
/** @var modMediaSource|bool $source */
2020
private $source = false;
2121

22+
public function setMediaSource(modMediaSource &$source)
23+
{
24+
$this->source = $source;
25+
}
26+
2227
/**
2328
* Get the source, preparing it for usage.
2429
*

core/components/fileman/src/Model/mysql/File.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ class File extends \FileMan\Model\File
2727
'group' => '',
2828
'size' => 0,
2929
'hash' => '',
30+
'published' => 1,
3031
'private' => 0,
32+
'published_at' => NULL,
3133
'download' => 0,
3234
'resource_id' => 0,
3335
'user_id' => 0,
@@ -115,6 +117,15 @@ class File extends \FileMan\Model\File
115117
'null' => false,
116118
'default' => '',
117119
),
120+
'published' =>
121+
array (
122+
'dbtype' => 'tinyint',
123+
'precision' => '1',
124+
'attributes' => 'unsigned',
125+
'phptype' => 'boolean',
126+
'null' => false,
127+
'default' => 1,
128+
),
118129
'private' =>
119130
array (
120131
'dbtype' => 'tinyint',
@@ -124,6 +135,12 @@ class File extends \FileMan\Model\File
124135
'null' => false,
125136
'default' => 0,
126137
),
138+
'published_at' =>
139+
array (
140+
'dbtype' => 'datetime',
141+
'phptype' => 'datetime',
142+
'null' => true,
143+
),
127144
'download' =>
128145
array (
129146
'dbtype' => 'int',
@@ -193,6 +210,22 @@ class File extends \FileMan\Model\File
193210
),
194211
),
195212
),
213+
'published' =>
214+
array (
215+
'alias' => 'published',
216+
'primary' => false,
217+
'unique' => false,
218+
'type' => 'BTREE',
219+
'columns' =>
220+
array (
221+
'published' =>
222+
array (
223+
'length' => '',
224+
'collation' => 'A',
225+
'null' => false,
226+
),
227+
),
228+
),
196229
'resource_id' =>
197230
array (
198231
'alias' => 'resource_id',

0 commit comments

Comments
 (0)