Skip to content

Commit

Permalink
Update to version 5.7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mivxxx committed Nov 1, 2018
1 parent ac48713 commit 456800f
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 13 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<a name="5.7.1"></a>
# 5.7.1 (2018-11-01)

### Основные изменения
* Оптимизация кода, исправление ошибок

<a name="5.7.0"></a>
# 5.7.0 (2018-10-22)

Expand Down
39 changes: 28 additions & 11 deletions src/Iris/Storage/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@ public function __construct($storageAdapter)
$this->storageAdapter = $storageAdapter;
}

/**
* @inheritdoc
*/
public function getFileStream($sysName)
{
$file = $this->storageAdapter->readStream($sysName);
if ($file['stream'] === false) {
throw new StorageException(_('Запрашиваемый файл был удален'));
}

return $file['stream'];
}

/**
* @inheritdoc
*/
Expand All @@ -34,20 +47,26 @@ public function sendFile($sysName, $fileName)
$fileExt = $fileNameParts[count($fileNameParts) - 1];
}

$file = $this->storageAdapter->readStream($sysName);
$realFilePath = $this->storageAdapter->applyPathPrefix($file['path']);
if (!file_exists($realFilePath)) {
throw new StorageException(_('Запрашиваемый файл был удален'));
}
$stream = $this->getFileStream($sysName);

header("Content-Type: application/download");
if ($fileExt) {
header('Content-Type: application/' . $fileExt);
}
header('content-disposition: attachment; filename="' . $fileName . '"');
header('Content-Length: ' . filesize($realFilePath));
header('Content-Length: ' . fstat($stream)['size']);

fpassthru($file['stream']);
fpassthru($stream);
}

/**
* @inheritdoc
*/
public function storeFile($sysName, $fileName)
{
$config = new Config();
$stream = fopen($fileName, 'r+');
$this->storageAdapter->writeStream($sysName, $stream, $config);
}

/**
Expand All @@ -56,12 +75,10 @@ public function sendFile($sysName, $fileName)
public function storeUploadedFiles($files)
{
$res = null;
$config = new Config();

foreach ($_FILES as $key => $file) {
foreach ($files as $key => $file) {
$sysName = create_guid();
$stream = fopen($file['tmp_name'], 'r+');
$this->storageAdapter->writeStream($sysName, $stream, $config);
$this->storeFile($sysName, $file['tmp_name']);

$res[UtfEncode($key)] = [
'sysname' => $sysName,
Expand Down
14 changes: 14 additions & 0 deletions src/Iris/Storage/StorageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
interface StorageInterface
{

/**
* Get file stream resource
* @param string $sysName File name with relative path, example: '000e927c-3b48-f266-07f0-86288b2ead42'
* @return resource
*/
public function getFileStream($sysName);

/**
* Send file to client with headers
* @param string $sysName File name with relative path, example: '000e927c-3b48-f266-07f0-86288b2ead42'
Expand All @@ -13,6 +20,13 @@ interface StorageInterface
*/
public function sendFile($sysName, $fileName);

/**
* Send file to client with headers
* @param string $sysName File name, example: '000e927c-3b48-f266-07f0-86288b2ead42'
* @param string $fileName Full file name (with path) to store
*/
public function storeFile($sysName, $fileName);

/**
* @param array $files
* @return File[]
Expand Down
1 change: 1 addition & 0 deletions src/Iris/core/engine/js/controls/radiobutton.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ function selectRadioButton(element, p_nochange_select) {
*/
if (!label.hasClass('active')) {
select.val(elemValue);
jQuery(select).trigger("field:edit");
jQuery(select).trigger("field:edited");
}
else {
Expand Down
2 changes: 1 addition & 1 deletion src/Iris/core/engine/js/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Iris/core/version.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<VERSION_INFO>
<CURRENT_VERSION>5.7.0</CURRENT_VERSION>
<CURRENT_VERSION>5.7.1</CURRENT_VERSION>
</VERSION_INFO>

0 comments on commit 456800f

Please sign in to comment.