Skip to content
GitLab
Menu
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
9de840af
Commit
9de840af
authored
Oct 08, 2018
by
Elias Villiger
Browse files
F6596 - Finalize uid option for PDFs and update manual. Refs #6596, closes #6596
parent
d457f897
Pipeline
#957
passed with stage
in 1 minute and 46 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
extension/Documentation/Manual.rst
View file @
9de840af
...
...
@@ -6296,8 +6296,8 @@ Parameter and (element) sources
* If only one `file` is specified, the default is `file`.
* If there is a) a page defined or b) multiple elements, the default is `pdf`.
* *element sources* - for `M:pdf` or `M:zip`, all of the following
three
element sources m
ight
be specified multiple times.
Any combination and order of the
thre
e options are allowed.
* *element sources* - for `M:pdf` or `M:zip`, all of the following element sources m
ay
be specified multiple times.
Any combination and order of the
s
e options are allowed.
* *file*: `F:
<pathFileName>
` - relative or absolute pathFileName offered for a) download (single), or to be concatenated
in a PDF or ZIP.
...
...
@@ -6317,6 +6317,12 @@ Parameter and (element) sources
* *url*: `u:
<url>
` - any URL, pointing to an internal or external destination.
* *uid*: `uid:
<int>
` - the tt_contents.uid of a QFQ PageContent record (shown on hover in the backend). This will render
only the raw QFQ processed bodytext of the specified PageContent, without additional tags, styles, or CSS includes.
QFQ will retrieve the PageContent's bodytext from the Typo3 database, parse it, and render it as a PDF. Parameters can be
passed: `uid:
<int>
[?arg1=value1][
&
arg2=value2][...]` and will be available in the SIP store for the QFQ PageContent,
or passed as wkhtmltopdf arguments, if applicable.
* *WKHTML Options* for `page`, `urlParam` or `url`:
* The 'HTML to PDF' will be done via `wkhtmltopdf`.
...
...
@@ -6508,33 +6514,23 @@ Injecting data into the Excel file is done in the same way in both modes: a Typo
or
tags
)
contains
one
or
more
Typo3
QFQ
records
.
Those
QFQ
records
will
create
plain
ASCII
output
.
If
the
export
file
has
to
be
customized
(
colors
,
pictures
,
headlines
,
...),
the
`
Template
`
mode
is
the
preferred
option
.
I
T
's much easier to do all cusomizations via Excel and creating a template than by coding in QFQ / Excel export notation.
I
t
's much easier to do all cus
t
omizations via Excel and creating a template than by coding in QFQ / Excel export notation.
Setup
'''''
*
Create
a
special
column
name
`
_excel
`
(
or
`
_link
`
)
in
QFQ
/
Report
.
As
a
source
,
define
a
T3
page
,
which
have
to
deliver
the
dynamic
content
(
also
:
`
excel-export-sample_
`
).
::
SELECT
CONCAT
(
'd:final.xlsx|M:excel|s:1|t:Excel (new)|p:?id=exceldata'
)
AS
_link
*
Create
a
T3
page
which
delivers
the
content
.
*
Disable
all
HTML
header
and
wrapping
code
on
that
page
.
It
'
s
also
a
good
idea
to
limit
access
to
such
page
on
localhost
,
your
development
network
and
your
webserver
address
.
Typoscript
setup
:
::
*
Create
a
special
column
name
`
_excel
`
(
or
`
_link
`
)
in
QFQ
/
Report
.
As
a
source
,
define
a
T3
PageContent
,
which
has
to
deliver
the
dynamic
content
(
also
`
_excel-export-sample
`
).
::
config
.disableAllHeaderCode
=
1
tt_content
.stdWrap
>
page
>
page
=
PAGE
SELECT
CONCAT
(
'd:final.xlsx|M:excel|s:1|t:Excel (new)|uid:43'
)
AS
_link
[
usergroup
=
*]
||
[
IP
=
127
.
0
.
0
.
1
,
192
.
168
.
1
.*,<
webserver
IP
>]
page
.
10
<
styles
.content.get
[
else
]
page
.
10
=
TEXT
page
.
10
.value
=
access
forbidden
[
global
]
*
Create
a
T3
PageContent
which
delivers
the
content
.
*
It
is
recommended
to
use
the
`
uid
:<
int
>
`
syntax
for
excel
imports
,
because
there
should
be
no
html
code
on
the
resulting
content
.
QFQ
will
retrieve
the
PageContent
's bodytext from the Typo3 database, parse it, and pass the
result as the instructions for filling the excel file.
* Parameters can be passed: `uid:43?param=value¶m2=value2` and will be accessible in the SIP Store (S) in the
QFQ PageContent.
* Use the regular QFQ Report syntax to create some output.
* The newline at the end of every line needs to be CHAR(10). To make it simpler, the special column name `... AS _XLS`
(see _XLS, _XLSs, _XLSb, _XLSn) can be used.
...
...
@@ -6605,14 +6601,14 @@ In Report Syntax: ::
Excel export samples: ::
# From scratch (both are the same, one with '
_excel
' the other with '
_link
')
SELECT CONCAT('
d
:new
.xlsx
|
t
:Excel
(
new
)|
p
:?
id
=
exceldata
') AS _excel
SELECT CONCAT('
d
:new
.xlsx
|
t
:Excel
(
new
)|
p
:?
id
=
exceldata
|
M
:excel
|
s
:
1
') AS _link
SELECT CONCAT('
d
:new
.xlsx
|
t
:Excel
(
new
)|
uid
:
54
') AS _excel
SELECT CONCAT('
d
:new
.xlsx
|
t
:Excel
(
new
)|
uid
:
54
|
M
:excel
|
s
:
1
') AS _link
# Template
SELECT CONCAT('
d
:final
.xlsx
|
t
:Excel
(
template
)|
F
:fileadmin
/
template
.xlsx
|
p
:?
id
=
exceldata
') AS _excel
SELECT CONCAT('
d
:final
.xlsx
|
t
:Excel
(
template
)|
F
:fileadmin
/
template
.xlsx
|
uid
:
24
') AS _excel
# With parameter (via SIP) - get the Parameter on page '
exceldata
' with '
{
{
arg1
:
S
}
}
' and '
{
{
arg2
:
S
}
}
'
SELECT CONCAT('
d
:final
.xlsx
|
t
:Excel
(
parameter
)|
p
:?
id
=
exceldata
&
_sip
=
1
&
arg1
=
hello
&
arg2
=
world
') AS _excel
SELECT CONCAT('
d
:final
.xlsx
|
t
:Excel
(
parameter
)|
uid
:
32
&
arg1
=
hello
&
arg2
=
world
') AS _excel
.. _drag_and_drop:
...
...
extension/qfq/qfq/helper/DownloadPage.php
View file @
9de840af
...
...
@@ -40,11 +40,6 @@ class DownloadPage {
$page
=
$baseUrl
.
$page
;
}
// Check php.ini
if
(
ini_get
(
'allow_url_fopen'
)
!=
'1'
)
{
throw
new
UserReportException
(
"php.ini: 'allow_url_fopen' is off and needs to be open to get '
$page
''"
,
ERROR_DOWNLOAD_FOPEN_BLOCKED
);
}
// Download page
$ctx
=
array
(
"ssl"
=>
array
(
...
...
extension/qfq/qfq/report/Download.php
View file @
9de840af
...
...
@@ -135,7 +135,7 @@ class Download {
foreach
(
$files
AS
$filename
)
{
$mimetype
=
mime_content_type
(
$filename
);
if
(
$mimetype
!=
'application/pdf'
)
{
throw
new
d
ownloadException
(
"Error concat file
$filename
. Mimetype 'application/pdf' expected, got:
$mimetype
"
,
ERROR_DOWNLOAD_UNEXPECTED_MIME_TYPE
);
throw
new
D
ownloadException
(
"Error concat file
$filename
. Mimetype 'application/pdf' expected, got:
$mimetype
"
,
ERROR_DOWNLOAD_UNEXPECTED_MIME_TYPE
);
}
}
...
...
@@ -264,10 +264,22 @@ class Download {
$rcData
=
DownloadPage
::
getContent
(
$urlParamString
,
$baseUrl
);
}
}
else
{
// TODO EV get evaluated bodytext like above
// create tmp html document with bodytext
// convert to pdf
$filename
=
$this
->
html2pdf
->
page2pdf
(
$token
,
$value
);
if
(
$token
===
TOKEN_UID
)
{
// create tmp html document with bodytext
$htmlText
=
$this
->
getEvaluatedBodytext
(
$uid
,
$urlParam
);
$tmpFilename
=
HelperFile
::
tempnam
()
.
'.html'
;
$tmpFile
=
fopen
(
$tmpFilename
,
"w"
)
or
die
(
'Cannot create file: '
.
$tmpFilename
);
fwrite
(
$tmpFile
,
$htmlText
);
fclose
(
$tmpFile
);
$rcArgsString
=
KeyValueStringParser
::
unparse
(
$rcArgs
,
'='
,
'&'
);
$url
=
Support
::
mergeUrlComponents
(
''
,
$tmpFilename
,
$rcArgsString
);
}
else
{
$url
=
$value
;
}
$filename
=
$this
->
html2pdf
->
page2pdf
(
$token
,
$url
);
}
break
;
...
...
extension/qfq/qfq/report/Html2Pdf.php
View file @
9de840af
...
...
@@ -121,7 +121,7 @@ class Html2Pdf {
* Converts a Webpage (URL) to a PDF file.
* The URL might be a local Typo3 page (without hostname, starting with the parameter) or a full URL.
*
* @param string $token TOKEN_URL | TOKEN_URL_PARAM
* @param string $token TOKEN_URL | TOKEN_URL_PARAM
| TOKEN_PAGE | TOKEN_UID
* @param string $url id=exportPage&r=123, www.nzz.ch/issue?id=456
*
* @return string rendered file - please delete later
...
...
@@ -135,10 +135,11 @@ class Html2Pdf {
$host
=
''
;
switch
(
$token
)
{
case
TOKEN_UID
:
case
TOKEN_URL
:
$arr
=
explode
(
'?'
,
$url
,
2
);
$host
=
$arr
[
0
];
$urlParamString
=
empty
(
$arr
[
1
]
)
?
''
:
$arr
[
1
]
;
$urlParamString
=
$arr
[
1
]
?
?
''
;
break
;
case
TOKEN_URL_PARAM
:
case
TOKEN_PAGE
:
...
...
@@ -160,11 +161,9 @@ class Html2Pdf {
$urlParamString
=
$this
->
sip
->
queryStringToSip
(
$urlParamString
,
RETURN_URL
);
}
if
(
$urlParamString
!=
''
)
{
$url
=
Support
::
mergeUrlComponents
(
''
,
$host
,
$urlParamString
);
}
$url
=
Support
::
mergeUrlComponents
(
''
,
$host
,
$urlParamString
);
if
(
substr
(
$url
,
0
,
4
)
!=
'http'
)
{
if
(
substr
(
$url
,
0
,
4
)
!=
'http'
&&
$token
!=
TOKEN_UID
)
{
$url
=
'http://'
.
$url
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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