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']));
......@@ -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) {
......@@ -533,6 +537,7 @@ EOF;
* @param array $formElement
* @param $htmlFormElementName
* @param $value
*
* @return mixed
*/
public function buildPill(array $formElement, $htmlFormElementName, $value, array &$json) {
......@@ -556,6 +561,7 @@ EOF;
* @param array $formElement Complete FormElement, especially some FE_WRAP
* @param string $htmlElement Content to wrap.
* @param $htmlFormElementName
*
* @return string Wrapped $htmlElement
* @throws \qfq\UserFormException
*/
......@@ -616,6 +622,7 @@ EOF;
* @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 integer $recordId
*
* @throws CodeException
* @throws DbException
* @throws UserFormException
......@@ -85,6 +87,7 @@ class Delete {
*
* @param array $row
* @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');
......@@ -61,6 +60,7 @@ class Evaluate {
* @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 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);
}
......
......@@ -40,7 +40,7 @@ class File {
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",
];
}
......@@ -74,6 +74,7 @@ class File {
/**
* @param string $sipUpload
* @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
*/
......@@ -228,6 +235,7 @@ class Save {
* @param string $tableName
* @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) {
......@@ -312,7 +321,9 @@ class Save {
* @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 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
......@@ -424,6 +436,7 @@ class Save {
*
* @param array $fe
* @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.
*/
private function getFormElementByName($name) {
......
......@@ -9,11 +9,6 @@
namespace qfq;
use qfq;
use qfq\CodeException;
use qfq\DbException;
use qfq\UserFormException;
use qfq\Support;
use qfq\Store;
require_once(__DIR__ . '/../exceptions/UserFormException.php');
require_once(__DIR__ . '/../exceptions/CodeException.php');
......@@ -121,15 +116,16 @@ class Database {
}
/**
* Fires query $sql and fetches result as assoc array (all modes but ROW_KEYS) or as num array (mode: ROW_KEYS). Throws exception.
* Fires query $sql and fetches result as assoc array (all modes but ROW_KEYS) or as num array (mode: ROW_KEYS).
* Throws exception.
*
* $mode
* ROW_REGULAR: Return 2-dimensional assoc array. Every query row is one array row.
* ROW_IMPLODE_ALL: Return string. All cells of all rows imploded to one string.
* ROW_EXPECT_0: Return empty string if there is no record row, Else an exception.
* ROW_EXPECT_1: Return 1-dimensional assoc array if there are exact one row. Else an exception.
* ROW_EXPECT_0_1: Return empty array if there is no row. Return 1-dimensional assoc array if there is one row. Else an exception.
* ROW_EXPECT_GE_1: Like 'ROW_REGULAR'. Throws an exception if there is an empty resultset.
* ROW_EXPECT_0_1: Return empty array if there is no row. Return 1-dimensional assoc array if there is one row.
* Else an exception. ROW_EXPECT_GE_1: Like 'ROW_REGULAR'. Throws an exception if there is an empty resultset.
* ROW_KEYS: Return 2-dimensional num(!) array. Every query row is one array row. $keys are the column names.
*
* @param $sql
......@@ -138,6 +134,7 @@ class Database {
* @param string $specificMessage
* @param array $keys
* @param array $stat DB_NUM_ROWS | DB_INSERT_ID | DB_AFFECTED_ROWS
*
* @return array|int
* SELECT | SHOW | DESCRIBE | EXPLAIN: see $mode
* INSERT: last_insert_id
......@@ -239,12 +236,15 @@ class Database {
/**
* Execute a prepared SQL statement like SELECT, INSERT, UPDATE, DELETE, SHOW, ...
*
* Returns the number of selected rows (SELECT, SHOW, ..) or the affected rows (UPDATE, INSERT). $stat contains appropriate num_rows, insert_id or rows_affected.
* Returns the number of selected rows (SELECT, SHOW, ..) or the affected rows (UPDATE, INSERT). $stat contains
* appropriate num_rows, insert_id or rows_affected.
*
* @param string $sql SQL statement with prepared statement variable.
* @param array $parameterArray parameter array for prepared statement execution.
* @param string $queryType returns QUERY_TYPE_SELECT | QUERY_TYPE_UPDATE | QUERY_TYPE_INSERT, depending on the query.
* @param string $queryType returns QUERY_TYPE_SELECT | QUERY_TYPE_UPDATE | QUERY_TYPE_INSERT, depending on
* the query.
* @param array $stat DB_NUM_ROWS | DB_INSERT_ID | DB_AFFECTED_ROWS
*
* @return int|mixed
* @throws \qfq\CodeException
* @throws \qfq\DbException
......@@ -344,6 +344,7 @@ class Database {
* Check if the given SQL Statement might modify data.
*
* @param $sql
*
* @return bool true is the statement might modify data, else: false
*/
private function isSqlModify($sql) {
......@@ -367,6 +368,7 @@ class Database {
*
* @param $sql
* @param array $parameterArray
*
* @return string
* @throws \qfq\UserFormException