Commit 58809c47 authored by Carsten  Rose's avatar Carsten Rose
Browse files

_[pP]aged: fixed a problem with default question

Link.php: make error messsage more user friendly
Report.php: introduced new constants DEFAULT_ICON, DEFAULT_QUESTION
parent ca0dcfeb
......@@ -1439,31 +1439,31 @@ The colum name is composed of the string *page* and a trailing character to spec
SELECT "[options]" AS _page[<link type>]
with: [options] = [p:<page & param>]|[t:<text>]|[o:<tooltip>]|[q:<msgbox>]|[c:<class>]|[g:<target>]|[r:<render mode>]
with: [options] = [p:<page & param>]|[t:<text>]|[o:<tooltip>]|[q:<question parameter>]|[c:<class>]|[g:<target>]|[r:<render mode>]
<link type> = c,d,e,h,i,n,s
..
+---------------+-----------------------------------------------+---------------+-------------------------------------+----------------------------------------------+
|**column name**|**Purpose** |**create sip** |**default value of msgbox parameter**|**Mandatory parameters** |
+---------------+-----------------------------------------------+---------------+-------------------------------------+----------------------------------------------+
|_page |Internal link without a grafic |no |empty |p:<pageId>[&param] |
+---------------+-----------------------------------------------+---------------+-------------------------------------+----------------------------------------------+
|_pagec |Internal link without a grafic, with messagebox|no |*Please confirm!* |p:<pageId>[&param] |
+---------------+-----------------------------------------------+---------------+-------------------------------------+----------------------------------------------+
|_paged |Internal link with delete icon (trash) |yes |*Delete record ?* |p:<pageId>[&param] |
+---------------+-----------------------------------------------+---------------+-------------------------------------+----------------------------------------------+
|_pagee |Internal link with edit icon (pencil) |yes |empty |p:<pageId>[&param] |
+---------------+-----------------------------------------------+---------------+-------------------------------------+----------------------------------------------+
|_pageh |Internal link with help icon (question mark) |yes |empty |p:<pageId>[&param] |
+---------------+-----------------------------------------------+---------------+-------------------------------------+----------------------------------------------+
|_pagei |Internal link with information icon (i) |no |empty |p:<pageId>[&param] |
+---------------+-----------------------------------------------+---------------+-------------------------------------+----------------------------------------------+
|_pagen |Internal link with new icon (sheet) |yes |empty |p:<pageId>[&param] |
+---------------+-----------------------------------------------+---------------+-------------------------------------+----------------------------------------------+
|_pages |Internal link with how icon (magnifier) |yes |empty |p:<pageId>[&param] |
+---------------+-----------------------------------------------+---------------+-------------------------------------+----------------------------------------------+
+---------------+-----------------------------------------------+-------------------------------------+----------------------------------------------+
|**column name**|**Purpose** |**default value of question parameter**|**Mandatory parameters** |
+---------------+-----------------------------------------------+-------------------------------------+----------------------------------------------+
|_page |Internal link without a grafic |empty |p:<pageId>[&param] |
+---------------+-----------------------------------------------+-------------------------------------+----------------------------------------------+
|_pagec |Internal link without a grafic, with question |*Please confirm!* |p:<pageId>[&param] |
+---------------+-----------------------------------------------+-------------------------------------+----------------------------------------------+
|_paged |Internal link with delete icon (trash) |*Delete record ?* |p:<pageId>[&param] |
+---------------+-----------------------------------------------+-------------------------------------+----------------------------------------------+
|_pagee |Internal link with edit icon (pencil) |empty |p:<pageId>[&param] |
+---------------+-----------------------------------------------+-------------------------------------+----------------------------------------------+
|_pageh |Internal link with help icon (question mark) |empty |p:<pageId>[&param] |
+---------------+-----------------------------------------------+-------------------------------------+----------------------------------------------+
|_pagei |Internal link with information icon (i) |empty |p:<pageId>[&param] |
+---------------+-----------------------------------------------+-------------------------------------+----------------------------------------------+
|_pagen |Internal link with new icon (sheet) |empty |p:<pageId>[&param] |
+---------------+-----------------------------------------------+-------------------------------------+----------------------------------------------+
|_pages |Internal link with how icon (magnifier) |empty |p:<pageId>[&param] |
+---------------+-----------------------------------------------+-------------------------------------+----------------------------------------------+
* All paramater are optional.
......@@ -1500,7 +1500,7 @@ Columns: _Page[X]
::
[<page id|alias>[&param=value&...]] | [text] | [tooltip] | [msgbox] | [class] | [target] | [render mode] | [create sip] "" as _pagee.
[<page id|alias>[&param=value&...]] | [text] | [tooltip] | [question parameter] | [class] | [target] | [render mode] | [create sip] "" as _pagee.
..
......
......@@ -411,7 +411,7 @@ class Link {
$tokenGiven[$key] = true;
if (!isset($this->tableVarName[$key])) {
throw new UserReportException ("Unknown link qualifier: '$key'", ERROR_UNKNOWN_LINK_QUALIFIER);
throw new UserReportException ("Unknown link qualifier: '$key' - do you forget the one character qualifier?", ERROR_UNKNOWN_LINK_QUALIFIER);
}
$keyName = $this->tableVarName[$key]; // convert token to name
......
......@@ -35,9 +35,10 @@ const TOKEN_FEND = 'fend';
const TOKEN_FSEP = 'fsep';
const TOKEN_RBGD = 'rbgd';
const TOKEN_DEBUG = 'debug';
const TOKEN_FORM = 'form';
const DEFAULT_QUESTION = 'question';
const DEFAULT_ICON = 'icon';
class Report {
......@@ -137,18 +138,19 @@ class Report {
$this->showDebugInfo = ($this->store->getVar(SYSTEM_SHOW_DEBUG_INFO, STORE_SYSTEM) === 'yes');
$this->pageDefaults["msgbox"]["pagec"] = "Please confirm!";
$this->pageDefaults[DEFAULT_QUESTION]["pagec"] = "Please confirm!";
$this->pageDefaults[DEFAULT_QUESTION]["paged"] = "Do you really want to delete the record?";
// $this->pageDefaults["sip"]["paged"] = TOKEN_SIP;
// $this->pageDefaults["sip"]["pagee"] = TOKEN_SIP;
// $this->pageDefaults["sip"]["pagen"] = TOKEN_SIP;
$this->pageDefaults["icon"]["paged"] = TOKEN_DELETE;
$this->pageDefaults["icon"]["pagee"] = TOKEN_EDIT;
$this->pageDefaults["icon"]["pageh"] = TOKEN_HELP;
$this->pageDefaults["icon"]["pagei"] = TOKEN_INFO;
$this->pageDefaults["icon"]["pagen"] = TOKEN_NEW;
$this->pageDefaults["icon"]["pages"] = TOKEN_SHOW;
$this->pageDefaults[DEFAULT_ICON]["paged"] = TOKEN_DELETE;
$this->pageDefaults[DEFAULT_ICON]["pagee"] = TOKEN_EDIT;
$this->pageDefaults[DEFAULT_ICON]["pageh"] = TOKEN_HELP;
$this->pageDefaults[DEFAULT_ICON]["pagei"] = TOKEN_INFO;
$this->pageDefaults[DEFAULT_ICON]["pagen"] = TOKEN_NEW;
$this->pageDefaults[DEFAULT_ICON]["pages"] = TOKEN_SHOW;
$this->db = new Database();
$this->utils = new Utils();
......@@ -844,7 +846,7 @@ class Report {
}
if (isset($allParam[3]) && $allParam[3] !== '') {
$text = isset($this->pageDefaults["msgbox"][$columnName]) ? $this->pageDefaults["msgbox"][$columnName] : '';
$text = isset($this->pageDefaults[DEFAULT_QUESTION][$columnName]) ? $this->pageDefaults[DEFAULT_QUESTION][$columnName] : '';
$tokenList .= $this->composeLinkPart(TOKEN_QUESTION, $allParam[3], $text); // -- msgbox
}
......@@ -866,8 +868,8 @@ class Report {
$tokenList .= $this->composeLinkPart(TOKEN_SIP, $allParam[7]); // -- SIP --
if (isset($this->pageDefaults["icon"][$columnName])) {
$tokenList .= $this->pageDefaults["icon"][$columnName] . "|";
if (isset($this->pageDefaults[DEFAULT_ICON][$columnName])) {
$tokenList .= $this->pageDefaults[DEFAULT_ICON][$columnName] . "|";
}
return ($tokenList);
......@@ -908,12 +910,12 @@ class Report {
$param = explode('|', $columnValue);
# get all defaultvalues, depending on the columnname
$defaultImage = isset($this->pageDefaults["icon"][$columnName]) ? $this->pageDefaults["icon"][$columnName] : '';
$defaultImage = isset($this->pageDefaults[DEFAULT_ICON][$columnName]) ? $this->pageDefaults[DEFAULT_ICON][$columnName] : '';
$defaultSip = 's';
# define defaultquestion only, if pagetype needs a question
if (!empty($this->pageDefaults["msgbox"][$columnName])) {
$defaultQuestion = 'q:' . $this->pageDefaults["msgbox"][$columnName];
if (!empty($this->pageDefaults[DEFAULT_QUESTION][$columnName])) {
$defaultQuestion = 'q:' . $this->pageDefaults[DEFAULT_QUESTION][$columnName];
}
foreach ($param as $key) {
......
......@@ -560,6 +560,158 @@ EOF;
$this->assertEquals('<a href="?id=form&r=123&a=hello&type=5&L=3&final=world" class="myclass" target="mytarget" title="This is a tooltip" >Person</a>', $result);
}
/**
*
*/
public function testReportPageC() {
$js = <<<EOF
id="12345" onClick="var alert = new QfqNS.Alert({ message: 'Please confirm!', type: 'info', modal: true, timeout: 0, buttons: [
{ label: 'Ok', eventName: 'ok' },
{ label: 'Cancel',eventName: 'cancel'}
] } );
alert.on('alert.ok', function() {
window.location = $('#12345').attr('href');
});
alert.show();
return false;"
EOF;
// _Page: incl. alert
$result = $this->report->process("10.sql = SELECT 'p:form' AS _pagec FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&s=badcaffee1234" class="internal" ' . $js . ' >index.php?id=form&s=badcaffee1234</a>', $result);
// _Page: other than defaults for the alert.
$js = str_replace('Please confirm!', 'Do you like to open', $js);
$js = str_replace("type: 'info'", "type: 'success'", $js);
$js = str_replace('Ok', 'yes', $js);
$js = str_replace('Cancel', 'no', $js);
$js = str_replace('timeout: 0', 'timeout: 10000', $js);
$js = str_replace('modal: true', 'modal: false', $js);
$result = $this->report->process("10.sql = SELECT 'p:form|q:Do you like to open:success:yes:no:10:0' AS _pagec FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&s=badcaffee1234" class="internal" ' . $js . ' >index.php?id=form&s=badcaffee1234</a>', $result);
$result = $this->report->process("10.sql = SELECT 'p:form|q:Do you like to open:success:yes:no:10:0|t:click me' AS _pagec FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&s=badcaffee1234" class="internal" ' . $js . ' >click me</a>', $result);
}
/**
*
*/
public function testReportPageFixC() {
$js = <<<EOF
id="12345" onClick="var alert = new QfqNS.Alert({ message: 'Please confirm!', type: 'info', modal: true, timeout: 0, buttons: [
{ label: 'Ok', eventName: 'ok' },
{ label: 'Cancel',eventName: 'cancel'}
] } );
alert.on('alert.ok', function() {
window.location = $('#12345').attr('href');
});
alert.show();
return false;"
EOF;
// _Page: incl. alert
$result = $this->report->process("10.sql = SELECT 'form' AS _Pagec FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&s=badcaffee1234" class="internal" ' . $js . ' >index.php?id=form&s=badcaffee1234</a>', $result);
// _Page: other than defaults for the alert.
$js = str_replace('Please confirm!', 'Do you like to open', $js);
$js = str_replace("type: 'info'", "type: 'success'", $js);
$js = str_replace('Ok', 'yes', $js);
$js = str_replace('Cancel', 'no', $js);
$js = str_replace('timeout: 0', 'timeout: 10000', $js);
$js = str_replace('modal: true', 'modal: false', $js);
$result = $this->report->process("10.sql = SELECT 'form|||Do you like to open:success:yes:no:10:0' AS _Pagec FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&s=badcaffee1234" class="internal" ' . $js . ' >index.php?id=form&s=badcaffee1234</a>', $result);
$result = $this->report->process("10.sql = SELECT 'form|click me||Do you like to open:success:yes:no:10:0' AS _Pagec FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&s=badcaffee1234" class="internal" ' . $js . ' >click me</a>', $result);
}
/**
*
*/
public function testReportPageD() {
$js = <<<EOF
id="12345" onClick="var alert = new QfqNS.Alert({ message: 'Do you really want to delete the record?', type: 'info', modal: true, timeout: 0, buttons: [
{ label: 'Ok', eventName: 'ok' },
{ label: 'Cancel',eventName: 'cancel'}
] } );
alert.on('alert.ok', function() {
window.location = $('#12345').attr('href');
});
alert.show();
return false;"
EOF;
// _paged: incl. alert
$result = $this->report->process("10.sql = SELECT 'p:form' AS _paged FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&s=badcaffee1234" class="btn btn-default" title="Delete" ' . $js . ' ><span class="glyphicon glyphicon-trash" ></span></a>', $result);
// _paged: other than defaults for the alert.
$js = str_replace('Do you really want to delete the record?', 'Move to trash?', $js);
$js = str_replace("type: 'info'", "type: 'success'", $js);
$js = str_replace('Ok', 'yes', $js);
$js = str_replace('Cancel', 'no', $js);
$js = str_replace('timeout: 0', 'timeout: 10000', $js);
$js = str_replace('modal: true', 'modal: false', $js);
$result = $this->report->process("10.sql = SELECT 'p:form|q:Move to trash?:success:yes:no:10:0' AS _paged FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&s=badcaffee1234" class="btn btn-default" title="Delete" ' . $js . ' ><span class="glyphicon glyphicon-trash" ></span></a>', $result);
$result = $this->report->process("10.sql = SELECT 'p:form|q:Move to trash?:success:yes:no:10:0|t:click me' AS _paged FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&s=badcaffee1234" class="btn btn-default" title="Delete" ' . $js . ' ><span class="glyphicon glyphicon-trash" ></span> click me</a>', $result);
}
/**
*
*/
public function testReportPageFixD() {
$js = <<<EOF
id="12345" onClick="var alert = new QfqNS.Alert({ message: 'Do you really want to delete the record?', type: 'info', modal: true, timeout: 0, buttons: [
{ label: 'Ok', eventName: 'ok' },
{ label: 'Cancel',eventName: 'cancel'}
] } );
alert.on('alert.ok', function() {
window.location = $('#12345').attr('href');
});
alert.show();
return false;"
EOF;
// _paged: incl. alert
$result = $this->report->process("10.sql = SELECT 'form' AS _Paged FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&s=badcaffee1234" class="btn btn-default" title="Delete" ' . $js . ' ><span class="glyphicon glyphicon-trash" ></span></a>', $result);
// _paged: other than defaults for the alert.
$js = str_replace('Do you really want to delete the record?', 'Move to trash?', $js);
$js = str_replace("type: 'info'", "type: 'success'", $js);
$js = str_replace('Ok', 'yes', $js);
$js = str_replace('Cancel', 'no', $js);
$js = str_replace('timeout: 0', 'timeout: 10000', $js);
$js = str_replace('modal: true', 'modal: false', $js);
$result = $this->report->process("10.sql = SELECT 'form|||Move to trash?:success:yes:no:10:0' AS _Paged FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&s=badcaffee1234" class="btn btn-default" title="Delete" ' . $js . ' ><span class="glyphicon glyphicon-trash" ></span></a>', $result);
$result = $this->report->process("10.sql = SELECT 'form|click me||Move to trash?:success:yes:no:10:0' AS _Paged FROM Person ORDER BY id LIMIT 1");
$this->assertEquals('<a href="index.php?id=form&s=badcaffee1234" class="btn btn-default" title="Delete" ' . $js . ' ><span class="glyphicon glyphicon-trash" ></span> click me</a>', $result);
}
/**
*
*/
......
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