Commit 58a1f24c authored by Carsten  Rose's avatar Carsten Rose
Browse files

KeyValueStringParser.php: phpdoc

Link.php, AbstractBuildForm.php, BuildFormBootstrap.php, Database.php: introduced constants for glyph. Code rearranged
testtabbles.sql: extended to test Delete with filenames
parent ec361b5a
......@@ -120,9 +120,9 @@ abstract class AbstractBuildForm {
'pill' => 'Pill'
];
$this->symbol[SYMBOL_EDIT] = "<span class='glyphicon glyphicon-pencil'></span>";
$this->symbol[SYMBOL_NEW] = "<span class='glyphicon glyphicon-plus'></span>";
$this->symbol[SYMBOL_DELETE] = "<span class='glyphicon glyphicon-trash'></span>";
$this->symbol[SYMBOL_EDIT] = "<span class='glyphicon " . GLYPH_ICON_EDIT . "'></span>";
$this->symbol[SYMBOL_NEW] = "<span class='glyphicon " . GLYPH_ICON_NEW . "'></span>";
$this->symbol[SYMBOL_DELETE] = "<span class='glyphicon " . GLYPH_ICON_DELETE . "'></span>";
$this->inputCheckPattern = Sanitize::inputCheckPatternArray();
}
......@@ -1424,7 +1424,7 @@ abstract class AbstractBuildForm {
if ($flagDelete) {
$s = $this->createDeleteUrl($targetTableName, $row['id'], RETURN_SIP);
$rowHtml .= Support::wrapTag('<td>', Support::wrapTag("<button type='button' class='record-delete btn btn-default' data-sip='$s'>", '<span class="glyphicon glyphicon-trash"></span>'));
$rowHtml .= Support::wrapTag('<td>', Support::wrapTag("<button type='button' class='record-delete btn btn-default' data-sip='$s'>", '<span class="glyphicon ' . GLYPH_ICON_DELETE .'"></span>'));
}
Support::setIfNotSet($row, FE_SUBRECORD_ROW_CLASS);
......@@ -1687,7 +1687,8 @@ abstract class AbstractBuildForm {
$queryStringArray = [
SIP_TABLE => $table,
SIP_RECORD_ID => $recordId
SIP_RECORD_ID => $recordId,
SIP_MODE_ANSWER => MODE_JSON
];
$queryString = Support::arrayToQueryString($queryStringArray);
......
......@@ -137,7 +137,7 @@ class BuildFormBootstrap extends AbstractBuildForm {
$toolTip = "Edit form" . PHP_EOL . PHP_EOL . OnArray::toString($this->store->getStore(STORE_SIP), ' = ', PHP_EOL, "'");
$url = $this->createFormEditUrl();
$buttonEditForm = $this->buildButtonAnchor('form-edit-button', $url, $toolTip, 'glyphicon-wrench');
$buttonEditForm = $this->buildButtonAnchor('form-edit-button', $url, $toolTip, GLYPH_ICON_TOOL);
}
// Button: Save
......@@ -148,7 +148,7 @@ class BuildFormBootstrap extends AbstractBuildForm {
$toolTip .= PHP_EOL . "table = '" . $this->formSpec[F_TABLE_NAME] . "'" . PHP_EOL . "r = '" . $recordId . "'";
}
$buttonSave = $this->buildButtonCode('save-button', $toolTip, 'glyphicon-ok');
$buttonSave = $this->buildButtonCode('save-button', $toolTip, GLYPH_ICON_CHECK);
}
// Button: Close
......@@ -159,7 +159,7 @@ class BuildFormBootstrap extends AbstractBuildForm {
$toolTip .= PHP_EOL . "table = '" . $this->formSpec[F_TABLE_NAME] . "'" . PHP_EOL . "r = '" . $recordId . "'";
}
$buttonClose = $this->buildButtonCode('close-button', 'Close', 'glyphicon-remove');
$buttonClose = $this->buildButtonCode('close-button', 'Close', GLYPH_ICON_CLOSE);
}
// Button: Delete
......@@ -171,7 +171,7 @@ class BuildFormBootstrap extends AbstractBuildForm {
}
$disabled = ($recordId > 0) ? '' : 'disabled';
$buttonDelete = $this->buildButtonCode('delete-button', $toolTip, 'glyphicon-trash', $disabled);
$buttonDelete = $this->buildButtonCode('delete-button', $toolTip, GLYPH_ICON_DELETE, $disabled);
}
// Button: New
......@@ -179,7 +179,7 @@ class BuildFormBootstrap extends AbstractBuildForm {
$toolTip = 'New';
$url = $this->deriveNewRecordUrlFromExistingSip($toolTip);
$buttonNew = $this->buildButtonAnchor('form-new-button', $url, $toolTip, 'glyphicon-plus');
$buttonNew = $this->buildButtonAnchor('form-new-button', $url, $toolTip, GLYPH_ICON_NEW);
}
$html = Support::wrapTag('<div class="btn-group" role="group">', $buttonEditForm);
......
......@@ -144,6 +144,8 @@ const ERROR_MISSING_CLOSE_DELIMITER = 1060;
const ERROR_EXPECTED_ARRAY = 1061;
const ERROR_REPORT_FAILED_ACTION = 1062;
const ERROR_MISSING_MESSAGE_FAIL = 1063;
const ERROR_MISSING_TABLE_NAME = 1064;
const ERROR_RECORD_NOT_FOUND = 1065;
// Store
const ERROR_STORE_VALUE_ALREADY_CODPIED = 1100;
......@@ -304,8 +306,17 @@ const SYSTEM_REPORT_FULL_LEVEL = 'reportFullLevel'; // Keyname of SQL-column pro
//const SYSTEM_FORM_ELEMENT_DEF = 'formElementDefinition'; // Type: SANITIZE_ALL / AssocArray. Formelement which are processed at the moment. Useful for error reporting.
//const SYSTEM_FORM_ELEMENT_FIELD = 'formElementField'; // Type: SANITIZE_ALNUMX / String. Fieldname of processed Formelement. Useful for error reporting.
const MODE_HTML = 'html';
const MODE_JSON = 'json';
const MSG_HEADER = 'header';
const MSG_CONTENT = 'content';
const MSG_ERROR_CODE = 'errorCode';
const SIP_SIP = CLIENT_SIP; // s
const SIP_RECORD_ID = CLIENT_RECORD_ID; // r
const SIP_TARGET_URL= '_targetUrl'; // URL where to jump after delete()
const SIP_MODE_ANSWER = '_modeAnswer'; // Mode how delete() will answer to client: MODE_HTML, MODE_JSON
const SIP_FORM = CLIENT_FORM;
const SIP_TABLE = 'table'; // delete a record from 'table'
const SIP_URLPARAM = 'urlparam';
......@@ -402,11 +413,12 @@ const SUBRECORD_PARAMETER_DETAIL = 'detail';
const GLYPH_ICON_EDIT = 'glyphicon-pencil';
const GLYPH_ICON_NEW = 'glyphicon-plus';
const GLYPH_ICON_DELETE = 'glyphicon-trash';
const GLYPH_ICON_HELP = 'glyphicon glyphicon-question-sign';
const GLYPH_ICON_INFO = 'glyphicon glyphicon-info-sign';
const GLYPH_ICON_SHOW = 'glyphicon glyphicon-search';
const GLYPH_ICON_HELP = 'glyphicon-question-sign';
const GLYPH_ICON_INFO = 'glyphicon-info-sign';
const GLYPH_ICON_SHOW = 'glyphicon-search';
const GLYPH_ICON_TOOL = 'glyphicon-wrench';
const GLYPH_ICON_CHECK = 'glyphicon glyphicon-ok';
const GLYPH_ICON_CHECK = 'glyphicon-ok';
const GLYPH_ICON_CLOSE = 'glyphicon-remove';
// FORM
const F_TABLE_NAME = 'tableName';
......@@ -507,3 +519,5 @@ const INDEX_PHP = 'index.php';
const T3DATA_BODYTEXT = 'bodytext';
const T3DATA_UID = 'uid';
// Special Column to check for uploads
const COLUMN_PATH_FILE_NAME = 'pathFileName';
......@@ -120,7 +120,9 @@ class Database {
* @param array $keys
* @param array $stat DB_NUM_ROWS | DB_INSERT_ID | DB_AFFECTED_ROWS
* @return array|int
* SELECT | SHOW | DESCRIBE | EXPLAIN: If no record found, empty string ( ROW_EXPECT_0_1, ROW_EXPECT_1) or empty array (all other modes)
* SELECT | SHOW | DESCRIBE | EXPLAIN:
* If no record found: a) ROW_EXPECT_0_1, ROW_EXPECT_1: empty string, b) All other modes: empty array
* If record(s) found: a) ROW_EXPECT_0_1, ROW_EXPECT_1: one dimensional array, b) All other modes: 2 dimensional array
* INSERT: last_insert_id
* UPDATE | DELETE | REPLACE: affected rows
* @throws \qfq\CodeException
......@@ -132,12 +134,14 @@ class Database {
$this->closeMysqliStmt();
// CR often forgets to specify the $mode and use prepared statement with parameter instead.
if (is_array($mode))
if (is_array($mode)) {
throw new CodeException("Probably a parameter forgotten: \$mode ?");
}
// for error reporting in exception
if ($specificMessage)
if ($specificMessage) {
$specificMessage .= " ";
}
$count = $this->prepareExecute($sql, $parameterArray, $queryType, $stat);
......@@ -242,7 +246,6 @@ class Database {
throw new DbException('[ mysqli: ' . $this->mysqli->errno . ' ] ' . $this->mysqli->error, ERROR_DB_PREPARE);
}
if (count($parameterArray) > 0) {
if (false === $this->prepareBindParam($parameterArray)) {
throw new DbException('[ mysqli: ' . $this->mysqli_stmt->errno . ' ] ' . $this->mysqli_stmt->error, ERROR_DB_BIND);
......
......@@ -37,6 +37,8 @@ require_once(__DIR__ . '/../../qfq/Constants.php');
class KeyValueStringParser {
/**
* Builds a string based on kvp array. Concatenatet by the given delimiter.
*
* @param array $keyValueArray
* @param string $keyValueDelimiter
* @param string $listDelimiter
......@@ -82,8 +84,8 @@ class KeyValueStringParser {
* @param string $keyValueDelimiter
* @param string $listDelimiter
* @param string $valueMode
* * VALUE_GIVEN: If only a key is given, the value is ''. E.G. 'a,b' >> [ 'a' => '', 'b' => '' ]
* * IF_VALUE_EMPTY_COPY_KEY: If only a key is given, the value is the same as the key. E.G. 'a,b' >> [ 'a' => 'a', 'b' => 'b' ].
* * KVP_VALUE_GIVEN: If only a key is given, the value is ''. E.G. 'a,b' >> [ 'a' => '', 'b' => '' ]
* * KVP_IF_VALUE_EMPTY_COPY_KEY: If only a key is given, the value is the same as the key. E.G. 'a,b' >> [ 'a' => 'a', 'b' => 'b' ].
* @return array associative array indexed by keys
* @throws UserFormException Thrown if there is a value but no key.
*/
......
......@@ -178,7 +178,7 @@ class Link {
* @var array
*/
private $renderControl = array();
private $linkClassSelector = array(TOKEN_CLASS_INTERNAL => "internal", TOKEN_CLASS_EXTERNAL => "external");
private $linkClassSelector = array(TOKEN_CLASS_INTERNAL => "internal ", TOKEN_CLASS_EXTERNAL => "external ");
private $cssLinkClassInternal = '';
private $cssLinkClassExternal = '';
......@@ -1069,7 +1069,6 @@ EOF;
$vars[NAME_GLYPH_TITLE] = "Delete";
$vars[NAME_LINK_CLASS_DEFAULT] = NO_CLASS;
// Include Extjs library
// $this->utils->loadJSlib($this->fr_error);
......@@ -1101,7 +1100,7 @@ EOF;
*/
private function buildHelp($vars, $value) {
$vars[NAME_GLYPH] = GLYPH_ICON_HELP;
$vars[NAME_GLYPH] = 'glyphicon ' . GLYPH_ICON_HELP;
$vars[NAME_GLYPH_TITLE] = "Help";
$vars[NAME_LINK_CLASS_DEFAULT] = NO_CLASS;
......@@ -1117,7 +1116,7 @@ EOF;
*/
private function buildInfo($vars, $value) {
$vars[NAME_GLYPH] = GLYPH_ICON_INFO;
$vars[NAME_GLYPH] = 'glyphicon ' . GLYPH_ICON_INFO;
$vars[NAME_GLYPH_TITLE] = "Information";
$vars[NAME_LINK_CLASS_DEFAULT] = NO_CLASS;
......@@ -1149,7 +1148,7 @@ EOF;
*/
private function buildShow($vars, $value) {
$vars[NAME_GLYPH] = GLYPH_ICON_SHOW;
$vars[NAME_GLYPH] = 'glyphicon ' . GLYPH_ICON_SHOW;
$vars[NAME_GLYPH_TITLE] = "Details";
$vars[NAME_LINK_CLASS_DEFAULT] = NO_CLASS;
......
DROP TABLE IF EXISTS Person;
CREATE TABLE Person (
id BIGINT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(128) NOT NULL DEFAULT '',
firstname VARCHAR(128) NOT NULL DEFAULT '',
picture VARCHAR(255) NOT NULL DEFAULT '',
gender ENUM('', 'male', 'female') NOT NULL DEFAULT 'male',
groups SET('', 'a', 'b', 'c') NOT NULL DEFAULT '',
birthday DATE NOT NULL DEFAULT '0000-00-00',
noteId BIGINT NOT NULL DEFAULT 0,
modified TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
created DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'
id BIGINT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(128) NOT NULL DEFAULT '',
firstname VARCHAR(128) NOT NULL DEFAULT '',
pathFileName VARCHAR(128) NOT NULL DEFAULT '',
gender ENUM('', 'male', 'female') NOT NULL DEFAULT 'male',
groups SET('', 'a', 'b', 'c') NOT NULL DEFAULT '',
birthday DATE NOT NULL DEFAULT '0000-00-00',
noteId BIGINT NOT NULL DEFAULT 0,
modified TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
created DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'
);
#
......
Markdown is supported
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