[TASK] Improve TS Template module information on root level list 06/57806/16
authorJoerg Kummer <typo3@enobe.de>
Sat, 4 Aug 2018 13:52:09 +0000 (15:52 +0200)
committerMathias Brodala <mbrodala@pagemachine.de>
Fri, 10 Aug 2018 10:38:37 +0000 (12:38 +0200)
The template tool on root level, which displays an overview of pages
including templates, now displays instead of the count of templates
all related templates of a page with several informations like:
- title
- state (by icon)
- is root or extend
- direct link to edit (with ID ans site-title as link title)
Pages in rootline, which do not includes templates itself are no longer
linked to the template modul.
Database query has been streamlined, and all render logic of
Html specific output has been moved to FLUID templating.
This offers the possibility to add filter or search to this view.
An issue with page sorting in page tree, when rootline pages does not
contain TS templates has been fixed.

Resolves: #81430
Releases: master, 8.7
Change-Id: I5250c53df1acc4a1a29839ce4a472f3e863ae992
Reviewed-on: https://review.typo3.org/57806
Tested-by: TYPO3com <no-reply@typo3.com>
Tested-by: Mona Muzaffar <mona.muzaffar@gmx.de>
Reviewed-by: Mona Muzaffar <mona.muzaffar@gmx.de>
Reviewed-by: Joerg Kummer <typo3@enobe.de>
Tested-by: Joerg Kummer <typo3@enobe.de>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Mathias Brodala <mbrodala@pagemachine.de>
Tested-by: Mathias Brodala <mbrodala@pagemachine.de>
typo3/sysext/core/Documentation/Changelog/master/Deprecation-81430-TypoScriptTemplateModuleControllerrenderList.rst [new file with mode: 0644]
typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php
typo3/sysext/tstemplate/Classes/Controller/TypoScriptTemplateModuleController.php
typo3/sysext/tstemplate/Resources/Private/Templates/PageZero.html

diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-81430-TypoScriptTemplateModuleControllerrenderList.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-81430-TypoScriptTemplateModuleControllerrenderList.rst
new file mode 100644 (file)
index 0000000..f4052d1
--- /dev/null
@@ -0,0 +1,32 @@
+.. include:: ../../Includes.txt
+
+====================================================================
+Deprecation: #81430 - TypoScriptTemplateModuleController::renderList
+====================================================================
+
+See :issue:`81430`
+
+Description
+===========
+
+The PHP method :php:`TypoScriptTemplateModuleController::renderList` has been marked as deprecated and will be removed with TYPO3 v10.
+
+
+Impact
+======
+
+Installations accessing the method will trigger a PHP :php:`E_USER_DEPRECATED` error.
+
+
+Affected Installations
+======================
+
+Instances calling the method.
+
+
+Migration
+=========
+
+No migration available. Remove the method call, implement the required functionality in your own code or unload the extension.
+
+.. index:: Backend, PHP-API, FullyScanned
\ No newline at end of file
index 4229b96..80e7e62 100644 (file)
@@ -652,4 +652,11 @@ return [
             'Deprecation-85796-SaltedPasswordsCleanups.rst',
         ],
     ],
+    'TYPO3\CMS\Tstemplate\Controller\TypoScriptTemplateModuleController::renderList' => [
+        'numberOfMandatoryArguments' => 1,
+        'maximumNumberOfArguments' => 3,
+        'restFiles' => [
+            'Deprecation-81430-TypoScriptTemplateModuleControllerrenderList.rst',
+        ],
+    ],
 ];
index 92c57c0..3b8112e 100644 (file)
@@ -208,27 +208,29 @@ class TypoScriptTemplateModuleController extends BaseScriptClass
                 ->add(GeneralUtility::makeInstance(DeletedRestriction::class))
                 ->add(GeneralUtility::makeInstance(BackendWorkspaceRestriction::class));
 
-            $result = $queryBuilder->select('pages.uid')
-                ->addSelectLiteral(
-                    $queryBuilder->expr()->count('*', 'count'),
-                    $queryBuilder->expr()->max('sys_template.root', 'root_max_val'),
-                    $queryBuilder->expr()->min('sys_template.root', 'root_min_val')
+            $result = $queryBuilder->select('sys_template.uid')
+                ->addSelect(
+                    'sys_template.pid',
+                    'sys_template.title',
+                    'sys_template.sitetitle',
+                    'sys_template.root',
+                    'sys_template.hidden',
+                    'sys_template.starttime',
+                    'sys_template.endtime'
                 )
-                ->from('pages')
                 ->from('sys_template')
-                ->where($queryBuilder->expr()->eq('pages.uid', $queryBuilder->quoteIdentifier('sys_template.pid')))
-                ->groupBy('pages.uid', 'pages.pid', 'pages.sorting')
-                ->orderBy('pages.pid')
-                ->addOrderBy('pages.sorting')
+                ->orderBy('sys_template.pid')
+                ->addOrderBy('sys_template.sorting')
                 ->execute();
-
             $pArray = [];
             while ($record = $result->fetch()) {
-                $this->setInPageArray($pArray, BackendUtility::BEgetRootLine($record['uid'], 'AND 1=1'), $record);
+                $additionalFieldsForRootline = ['sorting', 'hidden', 'fe_group', 'starttime', 'endtime', 'shortcut', 'nav_hide', 'module', 'content_from_pid'];
+                $rootline = BackendUtility::BEgetRootLine($record['pid'], '', true, $additionalFieldsForRootline);
+                $this->setInPageArray($pArray, $rootline, $record);
             }
 
             $view->getRenderingContext()->setControllerAction('PageZero');
-            $view->assign('templateList', $this->renderList($pArray));
+            $view->assign('pageTree', $pArray);
 
             // RENDER LIST of pages with templates, END
             // Setting up the buttons and markers for docheader
@@ -535,13 +537,13 @@ page.10.value = HELLO WORLD!
         return $tce->substNEWwithIDs['NEW'];
     }
 
-    // RENDER LIST of pages with templates, BEGIN
     /**
      * Set page in array
+     * To render list of page tree with templates
      *
-     * @param array $pArray
-     * @param array $rlArr
-     * @param array $row
+     * @param array $pArray Multidimensional array of page tree with template records
+     * @param array $rlArr Rootline array
+     * @param array $row Record of sys_template
      */
     public function setInPageArray(&$pArray, $rlArr, $row)
     {
@@ -551,18 +553,21 @@ page.10.value = HELLO WORLD!
             array_shift($rlArr);
         }
         $cEl = current($rlArr);
-        $pArray[$cEl['uid']] = $cEl['title'];
+        if (empty($pArray[$cEl['uid']])) {
+            $pArray[$cEl['uid']] = $cEl;
+        }
         array_shift($rlArr);
         if (!empty($rlArr)) {
-            $key = $cEl['uid'] . '.';
-            if (empty($pArray[$key])) {
-                $pArray[$key] = [];
+            if (empty($pArray[$cEl['uid']]['_nodes'])) {
+                $pArray[$cEl['uid']]['_nodes'] = [];
             }
-            $this->setInPageArray($pArray[$key], $rlArr, $row);
+            $this->setInPageArray($pArray[$cEl['uid']]['_nodes'], $rlArr, $row);
         } else {
-            $key = $cEl['uid'] . '_';
-            $pArray[$key] = $row;
+            $pArray[$cEl['uid']]['_templates'][] = $row;
         }
+        uasort($pArray, function ($a, $b) {
+            return $a['sorting'] - $b['sorting'];
+        });
     }
 
     /**
@@ -572,6 +577,7 @@ page.10.value = HELLO WORLD!
      * @param array $lines
      * @param int $c
      * @return array
+     * @deprecated since TYPO3 v9.4, will be removed in TYPO3 v10.0
      */
     public function renderList($pArray, $lines = [], $c = 0)
     {
index aa5c4f1..f709741 100644 (file)
@@ -1,3 +1,4 @@
+<html xmlns:core="http://typo3.org/ns/TYPO3/CMS/Core/ViewHelpers" data-namespace-typo3-fluid="true">
 <h1><f:translate key="moduleTitle" /></h1>
 <div>
     <p class="lead"><f:translate key="overview" /></p>
@@ -12,8 +13,8 @@
             </tr>
         </thead>
         <tbody>
-            <f:for each="{templateList}" as="line">
-                <f:render section="PageZeroTableRow" arguments="{line: line}" />
+            <f:for each="{pageTree}" as="page">
+                <f:render section="PageZeroTableRow" arguments="{page: page, level: 0, template: page._templates.0}" />
             </f:for>
         </tbody>
         </table>
 </div>
 
 <f:section name="PageZeroTableRow">
-    <tr class="{line.class}">
+    <f:variable name="maxCharacters" value="30" />
+    <tr class="{f:if(condition: page.hidden, then: 'inactive')}">
         <td class="nowrap">
-            <span style="width: 1px; height: 1px; display:inline-block; margin-left: {line.marginLeft}px"></span>
-            <a href="{line.href}" title="{line.title}">
-                <f:format.raw>{line.icon}</f:format.raw>
-                {line.pageTitle}
-            </a>
+            <span style="width: 1px; height: 1px; display:inline-block; margin-left: {level * 20}px"></span>
+            <f:if condition="{page}">
+                <f:then>
+                    <f:if condition="{page._templates}">
+                        <f:then>
+                            <a href="{f:be.uri(route:'web_ts', parameters:{id: page.uid})}"
+                               title="ID: {page.uid}">
+                                <core:IconForRecord table="pages" row="{page}" />
+                                {page.title -> f:format.crop(maxCharacters: maxCharacters)}
+                            </a>
+                        </f:then>
+                        <f:else>
+                            <span title="ID: {page.uid}">
+                                <core:IconForRecord table="pages" row="{page}" />
+                                {page.title -> f:format.crop(maxCharacters: maxCharacters)}
+                            </span>
+                        </f:else>
+                    </f:if>
+                </f:then>
+                <f:else>
+                    &nbsp;
+                </f:else>
+            </f:if>
+        </td>
+        <td>
+            <f:if condition="{template}">
+                <f:then>
+                    <f:variable name="web_ts_parameters"
+                                value="{id: template.pid, 'SET[templatesOnPage]': template.uid}" />
+                    <a href="{f:be.uri(route:'web_ts', parameters:web_ts_parameters)}"
+                       title="ID: {template.uid} {template.sitetitle}">
+                        <core:IconForRecord table="sys_template" row="{template}" />
+                        {template.title -> f:format.crop(maxCharacters: maxCharacters)}
+                    </a>
+                </f:then>
+                <f:else>
+                    &nbsp;
+                </f:else>
+            </f:if>
+        </td>
+        <td>
+            <f:if condition="{template}">
+                {f:if(condition: "{template.root}", then: "{core:icon(identifier: 'status-status-checked')}" )}
+            </f:if>
+        </td>
+        <td>
+            <f:if condition="{template}">
+                {f:if(condition: "!{template.root}", then: "{core:icon(identifier: 'status-status-checked')}" )}
+            </f:if>
         </td>
-        <td>{line.count}</td>
-        <td><f:format.raw>{line.root_max_val}</f:format.raw></td>
-        <td><f:format.raw>{line.root_min_val}</f:format.raw></td>
     </tr>
+    <f:if condition="{page}">
+        <!-- Additional templates -->
+        <f:if condition="{f:count({page._templates})}">
+            <f:for each="{page._templates}" as="template" iteration="i">
+                <f:if condition="{i.index} > 0">
+                    <f:render section="PageZeroTableRow" arguments="{page: 0, level: level, template: template}" />
+                </f:if>
+            </f:for>
+        </f:if>
+        <!-- Subpages -->
+        <f:if condition="{f:count({page._nodes})}">
+            <f:for each="{page._nodes}" as="page">
+                <f:render section="PageZeroTableRow" arguments="{page: page, level: '{level + 1}', template: page._templates.0}" />
+            </f:for>
+        </f:if>
+    </f:if>
 </f:section>
+</html>
\ No newline at end of file