Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
filesave.php
1
<?php
2
namespace
Bitrix\Clouds
;
3
4
use
Bitrix\Main
,
5
Bitrix\Main\Localization\Loc
;
6
Loc::loadMessages
(__FILE__);
7
38
class
FileSaveTable
extends
Main\ORM\Data\DataManager
39
{
40
private
static
$files = array();
41
47
public
static
function
getTableName
()
48
{
49
return
'b_clouds_file_save'
;
50
}
51
57
public
static
function
getMap
()
58
{
59
return
array(
60
'ID'
=> array(
61
'data_type'
=>
'integer'
,
62
'primary'
=>
true
,
63
'autocomplete'
=>
true
,
64
'title'
=>
Loc::getMessage
(
'FILE_SAVE_ENTITY_ID_FIELD'
),
65
),
66
'TIMESTAMP_X'
=> array(
67
'data_type'
=>
'datetime'
,
68
'required'
=>
true
,
69
'title'
=>
Loc::getMessage
(
'FILE_SAVE_ENTITY_TIMESTAMP_X_FIELD'
),
70
),
71
'BUCKET_ID'
=> array(
72
'data_type'
=>
'integer'
,
73
'required'
=>
true
,
74
'title'
=>
Loc::getMessage
(
'FILE_SAVE_ENTITY_BUCKET_ID_FIELD'
),
75
),
76
'SUBDIR'
=> array(
77
'data_type'
=>
'string'
,
78
'validation'
=> array(__CLASS__,
'validateSubdir'
),
79
'title'
=>
Loc::getMessage
(
'FILE_SAVE_ENTITY_SUBDIR_FIELD'
),
80
),
81
'FILE_NAME'
=> array(
82
'data_type'
=>
'string'
,
83
'required'
=>
true
,
84
'validation'
=> array(__CLASS__,
'validateFileName'
),
85
'title'
=>
Loc::getMessage
(
'FILE_SAVE_ENTITY_FILE_NAME_FIELD'
),
86
),
87
'EXTERNAL_ID'
=> array(
88
'data_type'
=>
'string'
,
89
'validation'
=> array(__CLASS__,
'validateExternalId'
),
90
'title'
=>
Loc::getMessage
(
'FILE_SAVE_ENTITY_EXTERNAL_ID_FIELD'
),
91
),
92
'FILE_SIZE'
=> array(
93
'data_type'
=>
'integer'
,
94
'title'
=>
Loc::getMessage
(
'FILE_SAVE_ENTITY_FILE_SIZE_FIELD'
),
95
),
96
);
97
}
103
public
static
function
validateSubdir
()
104
{
105
return
array(
106
new
Main\
Entity
\Validator\Length(
null
, 255),
107
);
108
}
114
public
static
function
validateFileName
()
115
{
116
return
array(
117
new
Main\
Entity
\Validator\Length(
null
, 255),
118
);
119
}
125
public
static
function
validateExternalId
()
126
{
127
return
array(
128
new
Main\
Entity
\Validator\Length(
null
, 50),
129
);
130
}
131
142
public
static
function
startFileOperation
($bucketId, $subDir, $fileName, $externalId)
143
{
144
$key = $bucketId.
"|"
.$subDir.
"|"
.$fileName;
145
$fileSave = \Bitrix\Clouds\FileSaveTable::createObject();
146
$fileSave->setTimestampX(
new
\
Bitrix
\Main\
Type
\
DateTime
());
147
$fileSave->setBucketId($bucketId);
148
$fileSave->setSubdir($subDir);
149
$fileSave->setFileName($fileName);
150
$fileSave->setExternalId($externalId);
151
$fileSave->setFileSize(-1);
152
$saveResult = $fileSave->save();
153
if
($saveResult->isSuccess())
154
{
155
self::$files[$key] = $fileSave;
156
}
157
}
168
public
static
function
setFileSize
($bucketId, $subDir, $fileName, $fileSize)
169
{
170
$key = $bucketId.
"|"
.$subDir.
"|"
.$fileName;
171
if
(isset(self::$files[$key]))
172
{
173
$fileSave = self::$files[$key];
174
$fileSave->setFileSize($fileSize);
175
$fileSave->save();
176
}
177
}
187
public
static
function
endFileOperation
($bucketId, $subDir, $fileName)
188
{
189
$key = $bucketId.
"|"
.$subDir.
"|"
.$fileName;
190
if
(isset(self::$files[$key]))
191
{
192
$fileSave = self::$files[$key];
193
$fileSave->delete();
194
unset(self::$files[$key]);
195
}
196
}
197
}
Bitrix\Clouds\FileSaveTable
Definition
filesave.php:39
Bitrix\Clouds\FileSaveTable\endFileOperation
static endFileOperation($bucketId, $subDir, $fileName)
Definition
filesave.php:187
Bitrix\Clouds\FileSaveTable\getMap
static getMap()
Definition
filesave.php:57
Bitrix\Clouds\FileSaveTable\setFileSize
static setFileSize($bucketId, $subDir, $fileName, $fileSize)
Definition
filesave.php:168
Bitrix\Clouds\FileSaveTable\validateExternalId
static validateExternalId()
Definition
filesave.php:125
Bitrix\Clouds\FileSaveTable\validateFileName
static validateFileName()
Definition
filesave.php:114
Bitrix\Clouds\FileSaveTable\startFileOperation
static startFileOperation($bucketId, $subDir, $fileName, $externalId)
Definition
filesave.php:142
Bitrix\Clouds\FileSaveTable\validateSubdir
static validateSubdir()
Definition
filesave.php:103
Bitrix\Clouds\FileSaveTable\getTableName
static getTableName()
Definition
filesave.php:47
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Main\ORM\Data\DataManager
Definition
datamanager.php:33
Bitrix\Main\ORM\Entity
Definition
entity.php:26
Bitrix\Main\Type\DateTime
Definition
datetime.php:9
Bitrix\Clouds
Definition
copyqueue.php:2
Bitrix\Main\Type
Definition
collection.php:2
Bitrix\Main
Bitrix
modules
clouds
lib
filesave.php
Создано системой
1.10.0