diff --git a/extension/Documentation/Manual.rst b/extension/Documentation/Manual.rst index 9a885579c6acb17457fa09a2b7535541874c4787..f7a1bdb6a6ac3bfd4584f77a2b506407f1f4600c 100644 --- a/extension/Documentation/Manual.rst +++ b/extension/Documentation/Manual.rst @@ -5840,18 +5840,6 @@ A limited set of attributes is supported: :: Column: _thumbnail ^^^^^^^^^^^^^^^^^^ -+-------+-------------------------------------------------+-------------------------------------------------------------+ -| Token | Example | Comment | -+=======+=================================================+=============================================================+ -| T | T:fileadmin/file3.pdf | File render a thumbnail | -+-------+-------------------------------------------------+-------------------------------------------------------------+ -| W | W:200x, W:x100, W:200x100 | Dimension of the thumbnail: '<width>x<height>. Both | -| | | parameter are otional. If non is given the default is W:150x| -+-------+-------------------------------------------------+-------------------------------------------------------------+ -| s | s:1, s:0 | Optional. Default: `s:1`. If SIP is enabled the rendered URL| -| | | is a link via api/download.php. Else a direct pathfilename | -+-------+-------------------------------------------------+-------------------------------------------------------------+ - A thumbnail of the file `T:<pathFilename>` will be rendered and saved with the given pixel size as specified via `W:<dimension>`. The file is only rendered once and will be rerendered, if the source file is newer than the thumbnail or if the thumbnail dimension changes. @@ -5867,6 +5855,35 @@ scaled. In `config.qfq.ini`_ the exact location of `convert` and `inkscape` can be configured (optional) as well as the directory names for the cached thumbnails. ++-------+--------------------------------+----------------------------------------------------------------------------+ +| Token | Example | Comment | ++=======+================================+============================================================================+ +| T | T:fileadmin/file3.pdf | File render a thumbnail | ++-------+--------------------------------+----------------------------------------------------------------------------+ +| W | W:200x, W:x100, W:200x100 | Dimension of the thumbnail: '<width>x<height>. Both | +| | | parameter are otional. If non is given the default is W:150x | ++-------+--------------------------------+----------------------------------------------------------------------------+ +| s | s:1, s:0 | Optional. Default: `s:1`. If SIP is enabled, the rendered URL | +| | | is a link via `api/download.php?..`. Else a direct pathFilename. | ++-------+--------------------------------+----------------------------------------------------------------------------+ +| r | r:7 | Render Mode. Default 'r:0'. With 'r:7' only the url will be delivered. | ++-------+--------------------------------+----------------------------------------------------------------------------+ + +Example: :: + + # SIP protected, IMG tag, thumbnail width 150px + 10.sql = SELECT 'T:fileadmin/file3.pdf' AS _thumbnail + + # SIP protected, IMG tag, thumbnail width 50px + 20.sql = SELECT 'T:fileadmin/file3.pdf|W:50x' AS _thumbnail + + # No SIP protection, IMG tag, thumbnail width 150px + 30.sql = SELECT 'T:fileadmin/file3.pdf|s:0' AS _thumbnail + + # SIP protected, only the URL to the image, thumbnail width 150px + 40.sql = SELECT 'T:fileadmin/file3.pdf|s:1|r:7' AS _thumbnail + + Dimension ''''''''' @@ -5908,151 +5925,7 @@ QFQ returns a HTML 'img'-tag: :: <img src="{{thumbnailDirPublic:Y}}/<md5 hash>.png"> -.. _column_F: - -Column: _F -^^^^^^^^^^ - -Challenge 1 -''''''''''' - -Due to the limitations of MySQL, reserved column names can't be further concatenated. Assume you want to display an image: - -:: - - # This is valid: - 10.sql = SELECT concat("/static/directory/", p.foto) AS _img FROM person AS p WHERE ... - - # Returns: - <img src=...> - -.. - - - -Now assume you want to wrap the image in a div tag: - -:: - - - # This is valid: - 10.sql = SELECT "<div>", CONCAT("/static/directory/", p.foto) AS _img, "</div>" FROM person AS p WHERE ... - - # Returns: - <div><img src=...></div> - -.. - - - -The example above works fine - however, as soon as you want to use *field wrappers*, things get messy: - -:: - - - # This is valid: - 10.sql = SELECT "<div>", CONCAT("/static/directory/", p.foto) AS _img, "</div>" FROM person AS p WHERE ... - 10.fbeg = <td> - 10.fend = </td> - - # Returns: - <td><div></td><td><img src=...></td><td></div></td> - -.. - - - -To achieve the desired result, one might want to try something like this: - -:: - - - # This is NOT valid: - 10.sql = SELECT CONCAT("<div>", concat("/static/directory/", p.foto) AS _img, "</div>") FROM person AS p WHERE ... - 10.fbeg = <td> - 10.fend = </td> - - # Returns a MySQL error because nesting concat() -functions is not allowed - -.. - - - -Challenge 2 -''''''''''' - -Assume you have multiple columns with reserved names in the same query and want to use one of them in a later query: - -:: - - - 10.sql = SELECT CONCAT("/static/directory/", g.picture) AS _img, CONCAT("/static/preview/", g.thumbnail) AS _img FROM gallery AS g WHERE ... - - 20.sql = SELECT "{{10.img}}", d.text FROM description AS d ... - -.. - - - -The example above will fail because there are two img columns which can not be distinguished. - -Solution -'''''''' - -The reserved column 'F'(=Format) can be used to - -* further wrap columns with a reserved name - -* assign an arbitrary name to a column built through a reserved name to make it accessible in later queries. - -Solution for *#Challenge_1*: - -:: - - - 10.sql = SELECT CONCAT("Q:img|T:div") AS wrappedImg FROM person AS p WHERE ... - 10.fbeg = <td> - 10.fend = </td> - - # Returns: - <td><div><img src=...></div></td> - -.. - - - -Solution for *#Challenge_2*: - -:: - - - 10.sql = SELECT CONCAT("Q:img|V:mypic") AS wrappedImg FROM person AS p WHERE ... - - 20.sql = SELECT "{{10.mypic}}" ... - -.. - - - -+-------------+--------------------------------------------------------------------+--------+ -|**Parameter**|**Description** |Required| -+=============+====================================================================+========+ -|Q |Any of the *reserved column names* | | -+-------------+--------------------------------------------------------------------+--------+ -|Z |Process the column but don't display it | | -+-------------+--------------------------------------------------------------------+--------+ -|X |Strip tags / Remove all tags | | -+-------------+--------------------------------------------------------------------+--------+ -|T |Wrap the column with the defined tag. F.e.: T:tdcolspan="2" | | -+-------------+--------------------------------------------------------------------+--------+ -|V |Define an unambiguous variable name for this colum. F.e.: V:someName| | -+-------------+--------------------------------------------------------------------+--------+ -|* |Add all the parameters required for the column defined with Q: | | -+-------------+--------------------------------------------------------------------+--------+ - - -The above example builds a link to pageB - refer to the :ref:`column-link`-manual for details. The link tells page B to -render the form with name formname and load the record with id id for editing. +Typical QFQ CSS Classes --------------- diff --git a/extension/qfq/qfq/Constants.php b/extension/qfq/qfq/Constants.php index 4a0b27b68cebd2aa2c55285e8b522f77c44d7385..88c88982cc5465f1edea7dbe9a60f1be463a72a5 100644 --- a/extension/qfq/qfq/Constants.php +++ b/extension/qfq/qfq/Constants.php @@ -1302,6 +1302,14 @@ const TOKEN_CLASS_NONE = 'n'; //const TOKEN_CLASS_INTERNAL = 'i'; //const TOKEN_CLASS_EXTERNAL = 'e'; +const RENDER_MODE_1 = '1'; +const RENDER_MODE_2 = '2'; +const RENDER_MODE_3 = '3'; +const RENDER_MODE_4 = '4'; +const RENDER_MODE_5 = '5'; +const RENDER_MODE_6 = '6'; +const RENDER_MODE_7 = '7'; + const WKHTML_OPTION_VIEWPORT = '--viewport-size'; const WKHTML_OPTION_VIEWPORT_VALUE = '1280x1024'; diff --git a/extension/qfq/qfq/report/Link.php b/extension/qfq/qfq/report/Link.php index 83cfd473289f4d5e03c350cbb224619453af9571..57eee7a88309dea534f22b245a27208bd9251215 100644 --- a/extension/qfq/qfq/report/Link.php +++ b/extension/qfq/qfq/report/Link.php @@ -1043,7 +1043,8 @@ EOF; */ private function doThumbnail(array $vars) { - if (empty($vars[NAME_THUMBNAIL])) { + // Check if there is a thumbnail and if it should be rendered + if (empty($vars[NAME_THUMBNAIL]) || $vars[NAME_RENDER] == RENDER_MODE_7) { return ''; } diff --git a/extension/qfq/qfq/report/Thumbnail.php b/extension/qfq/qfq/report/Thumbnail.php index 1a7e1ea5a5f7c7aa7170d00f85941bd8d83e082e..28e3d76b7e49158f698b9635d2c75b57c8dfad7a 100644 --- a/extension/qfq/qfq/report/Thumbnail.php +++ b/extension/qfq/qfq/report/Thumbnail.php @@ -75,7 +75,7 @@ class Thumbnail { $pathFilenameThumbnail = $this->doThumbnail($pathFilenameSource, $pathFilenameThumbnail, $control[TOKEN_THUMBNAIL_DIMENSION]); - return $this->buildImageTag($pathFilenameThumbnail, $control[TOKEN_SIP] == "1"); + return $this->buildImageTag($pathFilenameThumbnail, $control); } /** @@ -202,12 +202,18 @@ class Thumbnail { /** * @param string $pathFilenameThumbnail - * @param bool $flagSecure + * @param array $control * @return string + * @internal param bool $flagSecure */ - private function buildImageTag($pathFilenameThumbnail, $flagSecure) { + private function buildImageTag($pathFilenameThumbnail, array $control) { - $src = $flagSecure ? $this->buildDownloadLink($pathFilenameThumbnail) : $pathFilenameThumbnail; + $src = ($control[TOKEN_SIP] == "1") ? $this->buildDownloadLink($pathFilenameThumbnail) : $pathFilenameThumbnail; + + // With RENDER_MODE_7 return only the URL + if (isset($control[TOKEN_RENDER]) && $control[TOKEN_RENDER] == RENDER_MODE_7) { + return $src; + } $attribute = Support::doAttribute('src', $src);