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

Index.rst, delete.php: added some doc.

Report.php, Constants.php: introduce constants for report column keywords. Remove code to handle unecessary 'p:' tag for delete links.
parent eefd1188
......@@ -531,7 +531,7 @@ showButton
Display or hide the button `new`, `delete`, `close`, `save`.
* *new*: Creates a new record. If the form needs any special parameter via SIP or Client, hide this 'new' button - the necessary parameter are not provided.
* *delete*: This simple type of deleting a record only deletes the record itself, not any child records.
* *delete*: This either deletes the current record only, or (if defined via action form element 'before Delete' ) any specified subrecords.
* *close*: Close the current form. If there are changes, a popup opens and ask to save / close / cancel. The last page from the history will be shown.
* *save*: Save the form.
......@@ -1783,16 +1783,11 @@ Mandatory:
* `table=<table name>` or `form=<form name>`
* `r=<record id>`
Optional:
* `_targetUrl=<url>` , typically, this is the $_SERVER['REQUEST_URI'] available via {{REQUEST_URI:Y}}.
* `_answerMode=html`
Example:
::
SELECT 'u:typo3conf/ext/qfq/qfq/api/delete.php|U:table=Person&r=123&_targetUrl={{REQUEST_URI:Y}}&_answerMode=html|q:Do you want delete John Doe?|s|c:n' AS _link
SELECT 'U:table=Person&r=123|q:Do you want delete John Doe?|s|c:n' AS _link
It's easier to use the shortcut via special columnname `_paged`.
......@@ -1825,7 +1820,8 @@ The colum name is composed of the string *page* and a trailing character to spec
+---------------+-----------------------------------------------+-------------------------------------+----------------------------------------------+
|_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]???? |
|_paged |Internal link with delete icon (trash) |*Delete record ?* |U:form=<formname>&r=<recordid> or |
| | | |U:table=<tablename>&r=<recordid> |
+---------------+-----------------------------------------------+-------------------------------------+----------------------------------------------+
|_pagee |Internal link with edit icon (pencil) |empty |p:<pageId>[&param] |
+---------------+-----------------------------------------------+-------------------------------------+----------------------------------------------+
......@@ -1870,14 +1866,14 @@ Column: _paged
Necessary parameter:
* table
* `table` or `form`
* r
**Syntax**
::
SELECT "p:delete?table=<tablename>&r=<recordId>|q:<question>|..." AS _paged, "p:delete?form=<formname>&r=<recordId>|q:<question>|..." AS _paged
SELECT "U:table=<tablename>&r=<recordId>|q:<question>|..." AS _paged, "U:form=<formname>&r=<recordId>|q:<question>|..." AS _paged
..
......
......@@ -17,7 +17,22 @@ require_once(__DIR__ . '/../qfq/exceptions/CodeException.php');
/**
* Return JSON encoded answer
* delete: success
* SIP_MODE_ANSWER: MODE_HTML
* Send header 'location' to targetUrl
*
* SUP_MODE_ANSWER: MODE_JSON
* Send AJAX answer with Status 'success'
*
* delete: failed
* SIP_MODE_ANSWER: MODE_HTML
* No forward, print error message.
*
* SUP_MODE_ANSWER: MODE_JSON
* Send AJAX answer with Status 'error' and 'error message' as JSON encoded
*
*
* JSON Format:
*
* status: success|error
* message: <message>
......@@ -127,7 +142,7 @@ if ($modeAnswer === MODE_JSON) {
}
}
// Sent header, if given.
// Send header, if given.
if ($result[MSG_HEADER] !== '') {
header($result[MSG_HEADER]);
}
......
......@@ -578,3 +578,22 @@ const SENDMAIL_IDX_X_ID = 7;
const SENDMAIL_IDX_RECEIVER_CC = 8;
const SENDMAIL_IDX_RECEIVER_BCC = 9;
const SENDMAIL_IDX_SRC = 10;
//Report: Column Token
const COLUMN_PPAGE = "Page";
const COLUMN_PPAGEC = "Pagec";
const COLUMN_PPAGED = "Paged";
const COLUMN_PPAGEE = "Pagee";
const COLUMN_PPAGEH = "Pageh";
const COLUMN_PPAGEI = "Pagei";
const COLUMN_PPAGEN = "Pagen";
const COLUMN_PPAGES = "Pages";
const COLUMN_PAGE = "page";
const COLUMN_PAGEC = "pagec";
const COLUMN_PAGED = "paged";
const COLUMN_PAGEE = "pagee";
const COLUMN_PAGEH = "pageh";
const COLUMN_PAGEI = "pagei";
const COLUMN_PAGEN = "pagen";
const COLUMN_PAGES = "pages";
\ No newline at end of file
......@@ -575,28 +575,30 @@ class Report {
$content .= $this->myExec($columnValue);
break;
case "Page":
case "Pagec":
case "Paged":
case "Pagee":
case "Pageh":
case "Pagei":
case "Pagen":
case "Pages":
// Uppercase 'P'
case COLUMN_PPAGE:
case COLUMN_PPAGEC:
case COLUMN_PPAGED:
case COLUMN_PPAGEE:
case COLUMN_PPAGEH:
case COLUMN_PPAGEI:
case COLUMN_PPAGEN:
case COLUMN_PPAGES:
$pageColumnName = strtolower($columnName);
$tokenizedValue = $this->doFixColPosPage($columnName, $columnValue);
$linkValue = $this->doPage($pageColumnName, $tokenizedValue);
$content .= $this->link->renderLink($linkValue);
break;
case "page":
case "pagec":
case "paged":
case "pagee":
case "pageh":
case "pagei":
case "pagen":
case "pages":
// Lowercase 'P'
case COLUMN_PAGE:
case COLUMN_PAGEC:
case COLUMN_PAGED:
case COLUMN_PAGEE:
case COLUMN_PAGEH:
case COLUMN_PAGEI:
case COLUMN_PAGEN:
case COLUMN_PAGES:
$linkValue = $this->doPage($columnName, $columnValue);
$content .= $this->link->renderLink($linkValue);
break;
......@@ -804,8 +806,15 @@ class Report {
$firstParam[] = '';
}
$tokenList .= $this->composeLinkPart(TOKEN_PAGE, $firstParam[0]); // -- PageID --
$tokenList .= $this->composeLinkPart(TOKEN_URL_PARAM, $firstParam[1]);
switch ($columnName) {
case COLUMN_PPAGED:
// no pageid /pagealias given.
$tokenList .= $this->composeLinkPart(TOKEN_URL_PARAM, $allParam[0]);
break;
default:
$tokenList .= $this->composeLinkPart(TOKEN_PAGE, $firstParam[0]); // -- PageID --
$tokenList .= $this->composeLinkPart(TOKEN_URL_PARAM, $firstParam[1]);
}
if (isset($allParam[1]) && $allParam[1] !== '') {
$tokenList .= $this->composeLinkPart(TOKEN_TEXT, $allParam[1]); // -- Text --
......@@ -943,37 +952,10 @@ class Report {
$kvp = new KeyValueStringParser();
// Split in: [p => 'delete&r=100&_table=note&..', 'D' => ''... ],
// Split in: [p => 'r=100&table=note&..', 'D' => ''... ],
$param = $kvp->parse($columnValue, ':', '|');
// decode TOKEN_PAGE and fill TOKEN_URL_PARAM with it
if (isset($param[TOKEN_PAGE])) {
$args = $kvp->parse($param[TOKEN_PAGE], '=', '&');
// Remove the pageId. Instead set api/delete.php URL.
// Depending if a pageId is given by first arg (without the keyname 'id') or somewhere with 'id=': remove such position.
if (isset($args['id'])) {
unset($args['id']);
} else {
array_shift($args);
}
// Concat already existing $param[TOKEN_URL_PARAM] with additional from TOKEN_PAE
Support::setIfNotSet($param, TOKEN_URL_PARAM);
if(count($args)>0) {
if ($param[TOKEN_URL_PARAM] !== '') {
$param[TOKEN_URL_PARAM] .= '&';
}
$param[TOKEN_URL_PARAM] .= $kvp->unparse($args, '=', '&');
}
// Delete TOKEN_PAGE
unset($param[TOKEN_PAGE]);
} else {
throw new UserFormException('Missing parameter for _page or _Page', ERROR_MISSING_VALUE);
}
Support::setIfNotSet($param, TOKEN_URL_PARAM);
$param[TOKEN_URL_PARAM] .= '&' . SIP_MODE_ANSWER . '=' . MODE_HTML;
$param[TOKEN_URL_PARAM] .= '&' . SIP_TARGET_URL . '=' . $_SERVER['REQUEST_URI'];
......
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