Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
typo3
qfq
Commits
ee0c6718
Commit
ee0c6718
authored
Aug 07, 2018
by
Elias Villiger
Browse files
Feature #6255 - Inline Report Editing: Initial working version with db hard-coded
parent
cb2e2a70
Pipeline
#711
passed with stage
in 1 minute and 47 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
extension/qfq/api/saveReport.php
0 → 100644
View file @
ee0c6718
<?php
/**
* Created by PhpStorm.
* User: ep
* Date: 12/23/15
* Time: 6:16 PM
*/
namespace
qfq
;
use
qfq
;
require_once
(
__DIR__
.
'/../qfq/QuickFormQuery.php'
);
require_once
(
__DIR__
.
'/../qfq/store/Store.php'
);
require_once
(
__DIR__
.
'/../qfq/Constants.php'
);
require_once
(
__DIR__
.
'/../qfq/exceptions/UserFormException.php'
);
require_once
(
__DIR__
.
'/../qfq/exceptions/CodeException.php'
);
require_once
(
__DIR__
.
'/../qfq/exceptions/DbException.php'
);
/**
* Return JSON encoded answer
*/
$answer
=
array
();
$answer
[
API_REDIRECT
]
=
API_ANSWER_REDIRECT_AUTO
;
$answer
[
API_STATUS
]
=
API_ANSWER_STATUS_ERROR
;
$answer
[
API_MESSAGE
]
=
''
;
try
{
try
{
if
(
isset
(
$_POST
[
REPORT_INLINE_BODYTEXT
]))
{
$qfq
=
new
QuickFormQuery
([
'bodytext'
=>
''
]);
$data
=
$qfq
->
saveReport
();
}
// Redirect to previous page
header
(
"Location:
{
$_SERVER
[
'HTTP_REFERER'
]
}
"
);
exit
;
}
catch
(
qfq\UserFormException
$e
)
{
$answer
[
API_MESSAGE
]
=
$e
->
formatMessage
();
}
catch
(
qfq\CodeException
$e
)
{
$answer
[
API_MESSAGE
]
=
$e
->
formatMessage
();
}
catch
(
qfq\DbException
$e
)
{
$answer
[
API_MESSAGE
]
=
$e
->
formatMessage
();
}
}
catch
(
\
Exception
$e
)
{
$answer
[
API_MESSAGE
]
=
"Generic Exception: "
.
$e
->
getMessage
();
}
header
(
"Content-Type: application/json"
);
echo
json_encode
(
$answer
);
extension/qfq/qfq/Constants.php
View file @
ee0c6718
...
...
@@ -1189,6 +1189,8 @@ const INDEX_PHP = 'index.php';
const
T3DATA_BODYTEXT
=
'bodytext'
;
const
T3DATA_BODYTEXT_RAW
=
'bodytext-raw'
;
const
T3DATA_UID
=
'uid'
;
const
T3DATA_PID
=
'pid'
;
const
REPORT_INLINE_BODYTEXT
=
'bodytext'
;
// Special Column to check for uploads
const
COLUMN_PATH_FILE_NAME
=
'pathFileName'
;
...
...
extension/qfq/qfq/QuickFormQuery.php
View file @
ee0c6718
...
...
@@ -1335,7 +1335,7 @@ class QuickFormQuery {
$html
=
''
;
if
(
$this
->
store
->
getVar
(
TYPO3_BE_USER
,
STORE_TYPO3
,
SANITIZE_ALLOW_ALNUMX
))
{
$html
.
=
$this
->
d
o
InlineReport
();
$html
.
=
$this
->
buil
dInlineReport
();
}
$html
.
=
$report
->
process
(
$this
->
t3data
[
T3DATA_BODYTEXT
]);
...
...
@@ -1351,29 +1351,62 @@ class QuickFormQuery {
* @throws UserFormException
* @throws UserReportException
*/
private
function
d
o
InlineReport
()
{
private
function
buil
dInlineReport
()
{
$uid
=
$this
->
t3data
[
T3DATA_UID
];
$pid
=
$this
->
t3data
[
T3DATA_PID
];
$icon
=
Support
::
wrapTag
(
'<span class="'
.
GLYPH_ICON
.
' '
.
GLYPH_ICON_TASKS
.
'">'
,
''
);
$show
EditBox
Js
=
'$("#tt-content-edit-'
.
$uid
.
'").toggleClass("hidden")'
;
$toggleBtn
=
Support
::
wrapTag
(
"<a href='#' onclick='
$show
EditBox
Js
' style='float:right;'>"
,
$icon
);
$show
Form
Js
=
'$("#tt-content-edit-'
.
$uid
.
'").toggleClass("hidden")'
;
$toggleBtn
=
Support
::
wrapTag
(
"<a href='#' onclick='
$show
Form
Js
' style='float:right;'>"
,
$icon
);
$saveBtnAttributes
=
Support
::
doAttribute
(
'class'
,
'btn btn-default btn-block'
);
$saveBtnAttributes
.
=
Support
::
doAttribute
(
'id'
,
"tt-content-save-
$uid
"
);
$saveBtn
=
Support
::
wrapTag
(
"<button
$saveBtnAttributes
>"
,
'Save'
);
$saveBtnAttributes
.
=
Support
::
doAttribute
(
'type'
,
'submit'
);
$saveBtn
=
Support
::
wrapTag
(
"<button
$saveBtnAttributes
>"
,
'Save & Reload'
);
$ttContentCode
=
Support
::
htmlEntityEncodeDecode
(
MODE_ENCODE
,
$this
->
t3data
[
T3DATA_BODYTEXT_RAW
]);
$codeBoxAttributes
=
Support
::
doAttribute
(
'style'
,
"width:100%; height:200px;"
);
$codeBoxAttributes
.
=
Support
::
doAttribute
(
'id'
,
"tt-content-code-
$uid
"
);
$codeBoxAttributes
.
=
Support
::
doAttribute
(
'name'
,
REPORT_INLINE_BODYTEXT
);
$codeBox
=
Support
::
wrapTag
(
"<textarea
$codeBoxAttributes
>"
,
$ttContentCode
);
$editBox
=
join
(
' '
,
[
$saveBtn
,
$codeBox
]);
$editBox
=
Support
::
wrapTag
(
"<div id='tt-content-edit-
$uid
' class='hidden'>"
,
$editBox
);
$hiddenInput
=
"<input type='hidden' name='uid' value='
$uid
'>"
.
"<input type='hidden' name='pid' value='
$pid
'>"
;
$form
=
join
(
' '
,
[
$saveBtn
,
$codeBox
,
$hiddenInput
]);
$formAttributes
=
Support
::
doAttribute
(
'id'
,
"tt-content-edit-
$uid
"
);
$formAttributes
.
=
Support
::
doAttribute
(
'class'
,
'hidden'
);
$formAttributes
.
=
Support
::
doAttribute
(
'method'
,
'post'
);
$formAttributes
.
=
Support
::
doAttribute
(
'action'
,
API_DIR
.
'/saveReport.php'
);
$form
=
Support
::
wrapTag
(
"<form
$formAttributes
>"
,
$form
);
// $this->store->setStore(['form' => 'ReportForm', 'r' => $uid], STORE_TYPO3, true);
// $reportForm = $this->doForm(FORM_LOAD);
return
$toggleBtn
.
$editBox
;
return
$toggleBtn
.
$form
;
}
/**
* @return string
* @throws CodeException
* @throws DbException
* @throws UserFormException
*/
public
function
saveReport
()
{
$bodytext
=
Support
::
htmlEntityEncodeDecode
(
MODE_DECODE
,
$_POST
[
REPORT_INLINE_BODYTEXT
]);
$uid
=
$_POST
[
'uid'
];
$pid
=
$_POST
[
'pid'
];
$db
=
'elvill_qfq_t3'
;
// Update bodytext
$sql
=
"UPDATE
$db
.tt_content SET bodytext = ?, tstamp = UNIX_TIMESTAMP(NOW()) WHERE uid = ?"
;
$res
=
$this
->
dbArray
[
$this
->
dbIndexQfq
]
->
sql
(
$sql
,
ROW_REGULAR
,
[
$bodytext
,
$uid
]);
// Clear cache
$sql
=
"DELETE FROM
$db
.cf_cache_pagesection WHERE identifier LIKE '
$pid
%'"
;
$this
->
dbArray
[
$this
->
dbIndexQfq
]
->
sql
(
$sql
);
return
''
;
}
/**
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment