Commit fe2b8f89 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Reformatted all PHP files

parent 78b46d22
......@@ -25,14 +25,13 @@ require_once(__DIR__ . '/../qfq/QuickFormQuery.php');
* field-name: <field name>
* field-message: <message>
* form-data: [ fieldname1 => value1, fieldname2 => value2, ... ]
* form-control: [ fieldname1 => status1, fieldname2 => status2, ... ] status: show|hide, enabled|disabled, readonly|readwrite
* form-control: [ fieldname1 => status1, fieldname2 => status2, ... ] status: show|hide, enabled|disabled,
* readonly|readwrite
*
* Description:
*
* Save successfull. Button 'close', 'new'. Form.forward: 'auto'. Client logic decide to redirect or not. Show message if no redirect.
* status = 'success'
* message = <message>
* redirect = 'client'
* Save successfull. Button 'close', 'new'. Form.forward: 'auto'. Client logic decide to redirect or not. Show message
* if no redirect. status = 'success' message = <message> redirect = 'client'
*
* Save successfull. Button 'close': Form.forward: 'page'. Client redirect to url.
* status = 'success'
......@@ -40,13 +39,9 @@ require_once(__DIR__ . '/../qfq/QuickFormQuery.php');
* redirect = 'url'
* redirect-url = <URL>
*
* Save failed: Button: any. Show message and set 'alert' on _optional_ specified form element. Bring 'pill' of specified form element to front.
* status = 'error'
* message = <message>
* redirect = 'no'
* Optional:
* field-name = <field name>
* field-message = <message appearing as tooltip (or similar) near the form element>
* Save failed: Button: any. Show message and set 'alert' on _optional_ specified form element. Bring 'pill' of
* specified form element to front. status = 'error' message = <message> redirect = 'no' Optional: field-name = <field
* name> field-message = <message appearing as tooltip (or similar) near the form element>
*/
$answer = array();
......
......@@ -28,14 +28,13 @@ require_once(__DIR__ . '/../qfq/exceptions/DbException.php');
* field-name: <field name>
* field-message: <message>
* form-data: [ fieldname1 => value1, fieldname2 => value2, ... ]
* form-control: [ fieldname1 => status1, fieldname2 => status2, ... ] status: show|hide, enabled|disabled, readonly|readwrite
* form-control: [ fieldname1 => status1, fieldname2 => status2, ... ] status: show|hide, enabled|disabled,
* readonly|readwrite
*
* Description:
*
* Save successfull. Button 'close', 'new'. Form.forward: 'auto'. Client logic decide to redirect or not. Show message if no redirect.
* status = 'success'
* message = <message>
* redirect = 'client'
* Save successfull. Button 'close', 'new'. Form.forward: 'auto'. Client logic decide to redirect or not. Show message
* if no redirect. status = 'success' message = <message> redirect = 'client'
*
* Save successfull. Button 'close': Form.forward: 'page'. Client redirect to url.
* status = 'success'
......@@ -43,13 +42,9 @@ require_once(__DIR__ . '/../qfq/exceptions/DbException.php');
* redirect = 'url'
* redirect-url = <URL>
*
* Save failed: Button: any. Show message and set 'alert' on _optional_ specified form element. Bring 'pill' of specified form element to front.
* status = 'error'
* message = <message>
* redirect = 'no'
* Optional:
* field-name = <field name>
* field-message = <message appearing as tooltip (or similar) near the form element>
* Save failed: Button: any. Show message and set 'alert' on _optional_ specified form element. Bring 'pill' of
* specified form element to front. status = 'error' message = <message> redirect = 'no' Optional: field-name = <field
* name> field-message = <message appearing as tooltip (or similar) near the form element>
*/
$answer = array();
......
......@@ -56,6 +56,7 @@ class AutoCron {
* Check if there started cronJobs, older than $ageMaxMinutes
*
* @param int $ageMaxMinutes
*
* @throws CodeException
* @throws DbException
*/
......@@ -66,6 +67,7 @@ class AutoCron {
/**
* @param array $job
*
* @return array
* @throws CodeException
* @throws DbException
......@@ -80,6 +82,7 @@ class AutoCron {
// With no frequency: stop future repeating by setting nextRun=0
if ($job[AUTOCRON_FREQUENCY] == '') {
$job[AUTOCRON_NEXT_RUN] = 0;
return $job;
}
......@@ -106,6 +109,7 @@ class AutoCron {
* Calls the Webpage given in $job[AUTOCRON_CONTENT].
*
* @param array $job
*
* @return array $job, updated with AUTOCRON_LAST_STATUS
*/
private function doJobWebsite(array $job) {
......@@ -133,6 +137,7 @@ class AutoCron {
/**
* @param array $mailEntry
*
* @return array
*/
private function mailEntryFill(array $mailEntry) {
......@@ -142,6 +147,7 @@ class AutoCron {
$mailEntry[$key] = '';
}
}
return $mailEntry;
}
......@@ -150,6 +156,7 @@ class AutoCron {
* Do not send mails if: no record OR no receiver OR empty body
*
* @param array $job
*
* @return array $job, updated with AUTOCRON_LAST_STATUS
*/
private function doJobMail(array $job) {
......
......@@ -17,6 +17,7 @@ class BodytextParser {
/**
* @param $bodytext
*
* @return mixed|string
* @throws UserFormException
*/
......@@ -39,13 +40,16 @@ class BodytextParser {
if (strpos($bodytext, NESTING_TOKEN_OPEN) !== false) {
throw new \qfq\UserFormException("Missing close delimiter: $bodytext", ERROR_MISSING_CLOSE_DELIMITER);
}
return $bodytext;
}
/**
* Trim all lines, remove all empty lines and all lines which start with '#'
*
* @param $bodytext
*
* @return string
*/
......@@ -97,6 +101,7 @@ class BodytextParser {
if ($firstLine === false || $firstLine === '' || $firstLine[0] !== '#') {
$nestingOpen = '{';
$nestingClose = '}';
return;
}
......@@ -146,6 +151,7 @@ class BodytextParser {
* g,h: ^(\d+\.)*(sql|head)\s*=
*
* @param array $bodytextArray
*
* @return string
*/
private function joinLine($bodytext, $nestingOpen, $nestingClose) {
......@@ -198,6 +204,7 @@ class BodytextParser {
* Valid close (complete line): }
*
* @param $bodytext
*
* @return mixed
*/
private function encryptNestingDelimeter($bodytext, $nestingOpen, $nestingClose) {
......@@ -231,6 +238,7 @@ class BodytextParser {
* 10.20.30.sql = DELETE
*
* @param $bodytext
*
* @return mixed|string
* @throws UserFormException
*/
......@@ -297,6 +305,7 @@ class BodytextParser {
* Decrypt complex token by '{\n' and '}\n'
*
* @param $bodytext
*
* @return mixed
*/
private function decryptNestingDelimeter($bodytext, $nestingOpen, $nestingClose) {
......
......@@ -9,7 +9,6 @@
namespace qfq;
use qfq;
use qfq\UserFormException;
require_once(__DIR__ . '/../qfq/Constants.php');
require_once(__DIR__ . '/../qfq/helper/OnArray.php');
......@@ -72,6 +71,7 @@ class BuildFormBootstrap extends AbstractBuildForm {
/**
* @param string $addClass
*
* @return string
*/
public function getRowOpenTag($addClass = '') {
......@@ -116,7 +116,7 @@ class BuildFormBootstrap extends AbstractBuildForm {
public function head() {
$html = '';
$html .= '<div ' . Support::doAttribute('class', $this->formSpec[F_CLASS], TRUE) . '>'; // main <div class=...> around everything, Whole FORM; class="container" or class="container-fluid"
$html .= '<div ' . Support::doAttribute('class', $this->formSpec[F_CLASS], true) . '>'; // main <div class=...> around everything, Whole FORM; class="container" or class="container-fluid"
//TODO: nicer error reporting - make test with 'unknown index' here - unset($this->formSpec['title']) - See #3424
$title = Support::wrapTag('<div class="hidden-xs col-sm-6 col-md-8">', Support::wrapTag('<h3>', $this->formSpec['title']));
......@@ -170,7 +170,7 @@ class BuildFormBootstrap extends AbstractBuildForm {
$queryStringArray = [
'id' => $this->store->getVar(SYSTEM_EDIT_FORM_PAGE, STORE_SYSTEM),
'form' => 'copyForm',
'r' => 0,
'r' => 0,
'idSrc' => $formId,
];
$queryString = Support::arrayToQueryString($queryStringArray);
......@@ -216,7 +216,7 @@ class BuildFormBootstrap extends AbstractBuildForm {
$queryStringArray = [
'id' => $this->store->getVar(SYSTEM_EDIT_FORM_PAGE, STORE_SYSTEM),
'form' => $form,
'r' => 0
'r' => 0,
];
$queryString = Support::arrayToQueryString($queryStringArray);
$sip = $this->store->getSipInstance();
......@@ -318,6 +318,7 @@ class BuildFormBootstrap extends AbstractBuildForm {
* @param string $icon
* @param string $disabled
* @param string $class
*
* @return string
*/
private function buildButtonAnchor($url, $buttonHtmlId, $text, $toolTip, $icon, $disabled = '', $class = '') {
......@@ -344,6 +345,7 @@ class BuildFormBootstrap extends AbstractBuildForm {
* @param string $tooltip
* @param string $icon
* @param string $disabled
*
* @return string
*/
private function buildButtonCode($buttonHtmlId, $text, $tooltip, $icon, $disabled = '', $buttonOnChangeClass = '', $class = '') {
......@@ -363,6 +365,7 @@ class BuildFormBootstrap extends AbstractBuildForm {
/**
* @param $pillArray
*
* @return string
* @throws UserFormException
*/
......@@ -423,6 +426,7 @@ class BuildFormBootstrap extends AbstractBuildForm {
* Create an identifier for the pill navigation menu
*
* @param $id
*
* @return string
*/
private function createAnker($id) {
......@@ -531,8 +535,9 @@ EOF;
/**
* @param array $formElement
* @param $htmlFormElementName
* @param $value
* @param $htmlFormElementName
* @param $value
*
* @return mixed
*/
public function buildPill(array $formElement, $htmlFormElementName, $value, array &$json) {
......@@ -553,9 +558,10 @@ EOF;
}
/**
* @param array $formElement Complete FormElement, especially some FE_WRAP
* @param array $formElement Complete FormElement, especially some FE_WRAP
* @param string $htmlElement Content to wrap.
* @param $htmlFormElementName
* @param $htmlFormElementName
*
* @return string Wrapped $htmlElement
* @throws \qfq\UserFormException
*/
......@@ -609,13 +615,14 @@ EOF;
* - if $formElement[$wrapName] is given: wrap with that one. Else: wrap with $wrapArray
* - if $htmlId is give, inject it in $wrap.
*
* @param array $formElement Complete FormElement, especially some FE_WRAP
* @param array $formElement Complete FormElement, especially some FE_WRAP
* @param string $htmlElement Content to wrap.
* @param string $wrapName FE_WRAP_ROW, FE_WRAP_LABEL, FE_WRAP_INPUT, FE_WRAP_NOTE
* @param int $bsColumns
* @param array $wrapArray Systemwide Defaults: [ 'open wrap', 'close wrap' ]
* @param string $wrapName FE_WRAP_ROW, FE_WRAP_LABEL, FE_WRAP_INPUT, FE_WRAP_NOTE
* @param int $bsColumns
* @param array $wrapArray Systemwide Defaults: [ 'open wrap', 'close wrap' ]
* @param string $htmlId
* @param string $class
*
* @return string Wrapped $htmlElement
* @throws CodeException
* @throws \qfq\UserFormException
......@@ -649,6 +656,7 @@ EOF;
/**
* @param $formElement
* @param $elementHtml
*
* @return string
*/
public function buildRowPill(array $formElement, $elementHtml) {
......@@ -692,6 +700,7 @@ EOF;
/**
* @param $formElement
* @param $elementHtml
*
* @return string
*/
public function buildRowSubrecord(array $formElement, $elementHtml) {
......
......@@ -61,6 +61,7 @@ class BuildFormPlain extends AbstractBuildForm {
*/
public function doSubrecords() {
$json = array();
//TODO: $json is not returned - which is wrong. In this case, dynamic update won't work for subrecords
return $this->elements($this->store->getVar(SIP_RECORD_ID, STORE_SIP), FORM_ELEMENTS_SUBRECORD, $json);
}
......@@ -69,6 +70,7 @@ class BuildFormPlain extends AbstractBuildForm {
* @param $htmlFormElementName
* @param $formElement
* @param $value
*
* @return string
*/
public function buildRowNative(array $formElement, $htmlElement, $htmlFormElementName) {
......@@ -78,13 +80,13 @@ class BuildFormPlain extends AbstractBuildForm {
// $buildElementFunctionName = 'build' . $this->buildElementFunctionName[$formElement[FE_TYPE]];
if($formElement['nestedInFieldSet']==='no') {
if ($formElement['nestedInFieldSet'] === 'no') {
$html .= $this->wrap[WRAP_SETUP_ELEMENT][WRAP_SETUP_START];
}
$html .= $this->wrapItem(WRAP_SETUP_LABEL, $formElement[FE_LABEL]);
$html .= $this->wrapItem(WRAP_SETUP_INPUT, $htmlElement);
$html .= $this->wrapItem(WRAP_SETUP_NOTE, $formElement[FE_NOTE]);
if($formElement['nestedInFieldSet']==='no') {
if ($formElement['nestedInFieldSet'] === 'no') {
$html .= $this->wrap[WRAP_SETUP_ELEMENT][WRAP_SETUP_END];
}
......
......@@ -51,6 +51,7 @@ class BuildFormTable extends AbstractBuildForm {
public function fillWrapLabelInputNote($label, $input, $note) {
}
/**
* @return string
*/
......@@ -64,6 +65,7 @@ class BuildFormTable extends AbstractBuildForm {
public function doSubrecords() {
//TODO: $json is not returned - which is wrong. In this case, dynamic update won't work for subrecords
$json = array();
return $this->elements($this->store->getVar(SIP_RECORD_ID, STORE_SIP), FORM_ELEMENTS_SUBRECORD, $json);
}
......@@ -73,7 +75,7 @@ class BuildFormTable extends AbstractBuildForm {
public function head() {
$html = '';
$html .= '<div ' . Support::doAttribute('class', $this->formSpec[F_CLASS], TRUE) . '>'; // main <div class=...> around everything
$html .= '<div ' . Support::doAttribute('class', $this->formSpec[F_CLASS], true) . '>'; // main <div class=...> around everything
// Logged in BE User will see a FormEdit Link
$sipParamString = OnArray::toString($this->store->getStore(STORE_SIP), ':', ', ', "'");
......@@ -94,6 +96,7 @@ class BuildFormTable extends AbstractBuildForm {
* @param $htmlFormElementName
* @param $formElement
* @param $value
*
* @return string
*/
public function buildRowNative(array $formElement, $htmlElement, $htmlFormElementName) {
......@@ -117,7 +120,7 @@ class BuildFormTable extends AbstractBuildForm {
} else {
$html .= $this->wrapItem(WRAP_SETUP_IN_FIELDSET, $formElement[FE_LABEL]);
$html .= $this->wrapItem(WRAP_SETUP_IN_FIELDSET, $htmlElement);
if($formElement[FE_NOTE]!=='')
if ($formElement[FE_NOTE] !== '')
$html .= $this->wrapItem(WRAP_SETUP_IN_FIELDSET, $formElement[FE_NOTE]);
}
}
......
......@@ -35,10 +35,12 @@ class Delete {
/**
* Deletes the record id=$recordId from table $form[F_TABLE_NAME].
* If the table has a column named COLUMN_PATH_FILE_NAME and the value of that specific record column points
* to a file: delete such a file if their are no other records in the same table which also have a reference to that file.
* to a file: delete such a file if their are no other records in the same table which also have a reference to
* that file.
*
* @param string $tableName
* @param string $tableName
* @param integer $recordId
*
* @throws CodeException
* @throws DbException
* @throws UserFormException
......@@ -84,7 +86,8 @@ class Delete {
* If no: do nothing, continue with the next column.
*
* @param array $row
* @param $tableName
* @param $tableName
*
* @throws CodeException
* @throws DbException
* @throws UserFormException
......
......@@ -9,7 +9,6 @@
namespace qfq;
use qfq;
use qfq\Store;
require_once(__DIR__ . '/../qfq/store/Store.php');
require_once(__DIR__ . '/../qfq/database/Database.php');
......@@ -41,9 +40,9 @@ class Evaluate {
/**
* @param \qfq\Store $store
* @param Database $db
* @param string $startDelimiter
* @param string $endDelimiter
* @param Database $db
* @param string $startDelimiter
* @param string $endDelimiter
*/
public function __construct(Store $store, Database $db, $startDelimiter = '{{', $endDelimiter = '}}') {
$this->store = $store;
......@@ -58,9 +57,10 @@ class Evaluate {
/**
* Evaluate a whole array or a array of arrays.
*
* @param $tokenArray
* @param $tokenArray
* @param array $skip Optional Array with keynames, which will not be evaluated.
* @param array $debugStack
*
* @return array
* @throws UserFormException
*/
......@@ -87,13 +87,14 @@ class Evaluate {
}
/**
* Recursive evaluation of 'line'. Constant string, Variables or SQL Query or all of them. All queries will be fired.
* In case of an 'INSERT' statement, return the last_insert_id().
* Recursive evaluation of 'line'. Constant string, Variables or SQL Query or all of them. All queries will be
* fired. In case of an 'INSERT' statement, return the last_insert_id().
*
* Token to replace have to be enclosed by '{{' and '}}'
*
* @param $line
* @param $line
* @param int $recursion
*
* @return array|mixed|null|string
* @throws UserFormException
*/
......@@ -179,7 +180,9 @@ class Evaluate {
* If neither a) or b) match, return the token itself.
*
* @param string $token
* @param string $foundInStore Returns the name of the store where $key has been found. If $key is not found, return ''.
* @param string $foundInStore Returns the name of the store where $key has been found. If $key is not found,
* return ''.
*
* @return array|null|string
* @throws CodeException
* @throws DbException
......@@ -202,6 +205,7 @@ class Evaluate {
// SQL Statement?
if (in_array(strtoupper($arr[0] . ' '), $this->sqlKeywords)) {
$foundInStore = TOKEN_FOUND_IN_STORE_QUERY;
return $this->db->sql($token, $sqlMode);
}
......
......@@ -34,13 +34,13 @@ class File {
$this->store = Store::getInstance('', $phpUnit);
$this->uploadErrMsg = [
UPLOAD_ERR_INI_SIZE => "The uploaded file exceeds the upload_max_filesize directive in php.ini",
UPLOAD_ERR_INI_SIZE => "The uploaded file exceeds the upload_max_filesize directive in php.ini",
UPLOAD_ERR_FORM_SIZE => "The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form",
UPLOAD_ERR_PARTIAL => "The uploaded file was only partially uploaded",
UPLOAD_ERR_NO_FILE => "No file was uploaded",
UPLOAD_ERR_PARTIAL => "The uploaded file was only partially uploaded",
UPLOAD_ERR_NO_FILE => "No file was uploaded",
UPLOAD_ERR_NO_TMP_DIR => "Missing a temporary folder",
UPLOAD_ERR_CANT_WRITE => "Failed to write file to disk",
UPLOAD_ERR_EXTENSION => "File upload stopped by extension"
UPLOAD_ERR_EXTENSION => "File upload stopped by extension",
];
}
......@@ -73,7 +73,8 @@ class File {
/**
* @param string $sipUpload
* @param array $statusUpload
* @param array $statusUpload
*
* @throws CodeException
* @throws UserFormException
*/
......@@ -106,13 +107,15 @@ class File {
/**
* Checks the file filetype against the allowed mimetype definition. Return true as soon as one match is found.
* Types recognized:
* * 'mime type' as delivered by `file` which matches a definition on http://www.iana.org/assignments/media-types/media-types.xhtml
* * 'mime type' as delivered by `file` which matches a definition on
* http://www.iana.org/assignments/media-types/media-types.xhtml
* * Joker based: audio/*, video/*, image/*
* * Filename extension based: .pdf,.doc,..
*
* @param string $tmp_name
* @param string $name
* @param string $accept
*
* @return bool
* @throws UserFormException
*/
......@@ -165,6 +168,7 @@ class File {
/**
* @param $sipUpload
* @param $statusUpload
*
* @throws CodeException
* @throws UserFormException
* @internal param string $keyStoreExtra
......
......@@ -75,6 +75,7 @@ class Save {
* Create empty FormElements based on templateGroups, for those who not already exist.
*
* @param array $formValues
*
* @return array
*/
private function createEmptyTemplateGroupElements(array $formValues) {
......@@ -95,11 +96,13 @@ class Save {
$formValues[$feName] = $formElement[FE_VALUE];
}
}
return $formValues;
}
/**
* @param $feName
*
* @return bool
*/
private function isSetEmptyMeansNull($feName) {
......@@ -112,9 +115,11 @@ class Save {
}
/**
* Build an array of all values which should be saved. Values must exist as a 'form value' as well as a regular 'table column'.
* Build an array of all values which should be saved. Values must exist as a 'form value' as well as a regular
* 'table column'.
*
* @param $recordId
*
* @return int record id (in case of insert, it's different from $recordId)
* @throws CodeException
* @throws DbException
......@@ -198,6 +203,7 @@ class Save {
if ($formElement[FE_NAME] === $feName && $formElement[FE_TYPE] == 'upload')
return true;
}
return false;
}
......@@ -205,6 +211,7 @@ class Save {
* Insert new record in table $this->formSpec['tableName'].
*
* @param array $values
*
* @return int last insert id
* @throws DbException
*/
......@@ -226,8 +233,9 @@ class Save {
/**
* @param string $tableName
* @param array $values
* @param int $recordId
* @param array $values
* @param int $recordId
*
* @return bool|int false if $values is empty, else affectedrows
* @throws CodeException
* @throws DbException
......@@ -260,7 +268,8 @@ class Save {
}
/**
* Process all Upload Formelements for the given $recordId. After processing &$formValues will be updated with the final filenames.
* Process all Upload Formelements for the given $recordId. After processing &$formValues will be updated with the
* final filenames.
*
*/
public function processAllUploads($recordId) {
......@@ -309,10 +318,12 @@ class Save {
*
* Check also: doc/CODING.md
*
* @param array $formElement FormElement 'upload'
* @param string $sipUpload SIP
* @param Sip $sip
* @param string $modeUpload UPLOAD_MODE_UNCHANGED | UPLOAD_MODE_NEW | UPLOAD_MODE_DELETEOLD | UPLOAD_MODE_DELETEOLD_NEW
* @param array $formElement FormElement 'upload'
* @param string $sipUpload SIP
* @param Sip $sip
* @param string $modeUpload UPLOAD_MODE_UNCHANGED | UPLOAD_MODE_NEW | UPLOAD_MODE_DELETEOLD |
* UPLOAD_MODE_DELETEOLD_NEW
*
* @return false|string New pathFilename or false on error
* @throws CodeException
* @throws UserFormException
......@@ -371,6 +382,7 @@ class Save {
*
* @param array $formElement
* @param array $statusUpload
*
* @return array|mixed|null|string
* @throws CodeException
* @throws UserFormException
......@@ -423,7 +435,8 @@ class Save {
* Create/update or delete the slave record.
*
* @param array $fe
* @param bool $flagNewUpload
* @param bool $flagNewUpload
*
* @return int
* @throws CodeException
* @throws UserFormException
......@@ -491,6 +504,7 @@ class Save {
* Get the complete FormElement for $name
*
* @param $name
*
* @return bool|array if found the FormElement, else false.