Commit 117828fc authored by Carsten  Rose's avatar Carsten Rose
Browse files

File Upload: Preparation

file.php: created
Store.php: New store 'STORE_EXTRA' implemented.
BuildFormBootstrap: call to file.php implemented.
parent 5d523a3e
<?php
/**
* Created by PhpStorm.
* User: crose
* Date: 4/25/16
* Time: 8:02 PM
*/
$answer = array();
$answer[API_MESSAGE] = '';
$answer[API_STATUS] = API_ANSWER_STATUS_ERROR;
try {
$upload = new \qfq\File();
$upload->process();
$answer[API_MESSAGE] = 'upload: success';
$answer[API_REDIRECT] = API_ANSWER_REDIRECT_NO;
$answer[API_STATUS] = API_ANSWER_STATUS_SUCCESS;
} catch (qfq\UserFormException $e) {
$answer[API_MESSAGE] = $e->formatMessage();
} catch (qfq\CodeException $e) {
$answer[API_MESSAGE] = $e->formatMessage();
} catch (qfq\DbException $e) {
$answer[API_MESSAGE] = $e->formatMessage();
} catch (\Exception $e) {
$answer[API_MESSAGE] = "Generic Exception: " . $e->getMessage();
}
header("Content-Type: application/json");
echo json_encode($answer);
......@@ -324,8 +324,8 @@ class BuildFormBootstrap extends AbstractBuildForm {
formId: '$formId',
submitTo: 'typo3conf/ext/qfq/qfq/api/save.php',
deleteUrl: '$deleteUrl',
refreshUrl: "typo3conf/ext/qfq/qfq/api/load.php"
refreshUrl: "typo3conf/ext/qfq/qfq/api/load.php",
fileUploadTo: 'typo3conf/ext/qfq/qfq/api/file.php'
});
var qfqRecordList = new QfqNS.QfqRecordList('typo3conf/ext/qfq/qfq/api/delete.php');
......
<?php
/**
* Created by PhpStorm.
* User: crose
* Date: 4/25/16
* Time: 10:39 PM
*/
namespace qfq;
require_once(__DIR__ . '/store/Store.php');
require_once(__DIR__ . '/Constants.php');
class File {
/**
* @var null|Store
*/
private $store = null;
public function __construct($phpUnit = false) {
$this->store = Store::getInstance('', $phpUnit);
}
public function process() {
$sClient = $this->store->getVar(CLIENT_SIP, STORE_CLIENT, SANITIZE_ALLOW_ALNUMX);
$sStore = $this->store->getVar(SIP_SIP, STORE_SIP);
if ($sClient === false || $sStore === false || $sClient !== $sStore) {
throw new UserFormException('SIP invalid', ERROR_SIP_INVALID);
}
$uploadFeName = $this->store->getVar(CLIENT_UPLOAD_FE_NAME, STORE_CLIENT, SANITIZE_ALLOW_ALNUMX);
$uploadDelete = $this->store->getVar(CLIENT_UPLOAD_DELETE, STORE_CLIENT, SANITIZE_ALLOW_ALNUMX);
$newArr = $_FILES;
$oldArr = $this->store->getVar($uploadFeName . STORE_EXTRA, SANITIZE_ALLOW_ALL);
if (isset($oldArr[EXTRA_UPLOAD_DELETE]) && $oldArr[EXTRA_UPLOAD_DELETE] === 'yes') {
$uploadDelete = 'yes';
}
if ($uploadDelete === 'yes')
$newArr[EXTRA_UPLOAD_DELETE] = 'yes';
$this->store->setVar($uploadFeName, $newArr, STORE_EXTRA);
}
}
\ No newline at end of file
......@@ -148,6 +148,7 @@ class Store {
self::fillStoreTypo3($bodytext);
self::fillStoreClient();
self::fillStoreSip();
self::fillStoreExtra();
}
/**
......@@ -359,6 +360,17 @@ class Store {
return false;
}
/**
* @throws UserFormException
* @throws \qfq\CodeException
*/
private static function fillStoreExtra() {
if (isset($_SESSION[STORE_EXTRA]))
self::setVarArray($_SESSION[STORE_EXTRA], STORE_EXTRA, true);
else
self::setVarArray(array(), STORE_EXTRA, true);
}
/**
* @param string $bodytext
* @param bool|false $phpUnit
......@@ -418,9 +430,9 @@ class Store {
}
/**
* @param $key
* @param $value
* @param $store
* @param string $key
* @param string|array $value
* @param string $store
* @param bool|true $overWrite
* @throws UserFormException
* @throws \qfq\CodeException
......@@ -438,6 +450,14 @@ class Store {
}
self::$raw[$store][$key] = $value;
// The STORE_EXTRA saves arrays and is persistent
if ($store === STORE_EXTRA) {
foreach ($value as $k1 => $v1) {
$_SESSION[STORE_EXTRA][$key][$k1] = $v1;
}
}
}
/**
......
......@@ -53,48 +53,48 @@ CREATE TABLE IF NOT EXISTS `Form` (
DROP TABLE IF EXISTS `FormElement`;
CREATE TABLE IF NOT EXISTS `FormElement` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`formId` INT(11) NOT NULL,
`feIdContainer` INT(11) NOT NULL DEFAULT '0',
`dynamicUpdate` ENUM('yes', 'no') NOT NULL DEFAULT 'no',
`id` INT(11) NOT NULL AUTO_INCREMENT,
`formId` INT(11) NOT NULL,
`feIdContainer` INT(11) NOT NULL DEFAULT '0',
`dynamicUpdate` ENUM('yes', 'no') NOT NULL DEFAULT 'no',
`enabled` ENUM('yes', 'no') NOT NULL DEFAULT 'yes',
`enabled` ENUM('yes', 'no') NOT NULL DEFAULT 'yes',
`name` VARCHAR(255) NOT NULL DEFAULT '',
`label` VARCHAR(255) NOT NULL DEFAULT '',
`name` VARCHAR(255) NOT NULL DEFAULT '',
`label` VARCHAR(255) NOT NULL DEFAULT '',
`mode` ENUM('show', 'readonly', 'required', 'lock', 'disabled') NOT NULL DEFAULT 'show',
`class` ENUM('native', 'action', 'container') NOT NULL DEFAULT 'native',
`type` ENUM('checkbox', 'date', 'datetime', 'dateJQW', 'datetimeJQW', 'gridJQW', 'hidden', 'text', 'time',
`mode` ENUM('show', 'readonly', 'required', 'lock', 'disabled') NOT NULL DEFAULT 'show',
`class` ENUM('native', 'action', 'container') NOT NULL DEFAULT 'native',
`type` ENUM('checkbox', 'date', 'datetime', 'dateJQW', 'datetimeJQW', 'gridJQW', 'hidden', 'text', 'time',
'note', 'password', 'radio', 'select', 'subrecord', 'upload', 'fieldset', 'pill',
'before_load', 'before_save', 'before_insert', 'before_update', 'before_delete', 'after_load',
'after_save', 'after_insert', 'after_update', 'after_delete', 'feGroup',
'sendmail') NOT NULL DEFAULT 'text',
`subrecordOption` SET('edit', 'delete', 'new') NOT NULL DEFAULT '',
`checkType` ENUM('alnumx', 'digit', 'email', 'min|max', 'min|max date', 'pattern', 'all') NOT NULL DEFAULT 'alnumx',
`checkPattern` VARCHAR(255) NOT NULL DEFAULT '',
`onChange` VARCHAR(255) NOT NULL DEFAULT '',
`ord` INT(11) NOT NULL DEFAULT '0',
`tabindex` INT(11) NOT NULL DEFAULT '0',
`size` VARCHAR(255) NOT NULL DEFAULT '',
`maxLength` VARCHAR(255) NOT NULL DEFAULT '',
`note` TEXT NOT NULL,
`tooltip` VARCHAR(255) NOT NULL DEFAULT '',
`placeholder` VARCHAR(255) NOT NULL DEFAULT '',
`value` TEXT NOT NULL,
`sql1` TEXT NOT NULL,
`sql2` TEXT NOT NULL,
`parameter` TEXT NOT NULL,
`clientJs` TEXT NOT NULL,
`feGroup` VARCHAR(255) NOT NULL DEFAULT '',
`deleted` ENUM('yes', 'no') NOT NULL DEFAULT 'no',
`modified` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
'sendmail') NOT NULL DEFAULT 'text',
`subrecordOption` SET('edit', 'delete', 'new') NOT NULL DEFAULT '',
`checkType` ENUM('alnumx', 'digit', 'email', 'min|max', 'min|max date', 'pattern', 'allbut', 'all') NOT NULL DEFAULT 'alnumx',
`checkPattern` VARCHAR(255) NOT NULL DEFAULT '',
`onChange` VARCHAR(255) NOT NULL DEFAULT '',
`ord` INT(11) NOT NULL DEFAULT '0',
`tabindex` INT(11) NOT NULL DEFAULT '0',
`size` VARCHAR(255) NOT NULL DEFAULT '',
`maxLength` VARCHAR(255) NOT NULL DEFAULT '',
`note` TEXT NOT NULL,
`tooltip` VARCHAR(255) NOT NULL DEFAULT '',
`placeholder` VARCHAR(255) NOT NULL DEFAULT '',
`value` TEXT NOT NULL,
`sql1` TEXT NOT NULL,
`sql2` TEXT NOT NULL,
`parameter` TEXT NOT NULL,
`clientJs` TEXT NOT NULL,
`feGroup` VARCHAR(255) NOT NULL DEFAULT '',
`deleted` ENUM('yes', 'no') NOT NULL DEFAULT 'no',
`modified` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`id`),
KEY `formId` (`formId`),
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment