Fixed bug #1822: There is no API to list tables in theWeb->Page module (thanks to...
authorSteffen Kamper <info@sk-typo3.de>
Sun, 7 Feb 2010 22:55:53 +0000 (22:55 +0000)
committerSteffen Kamper <info@sk-typo3.de>
Sun, 7 Feb 2010 22:55:53 +0000 (22:55 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@6874 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/cms/layout/class.tx_cms_layout.php
typo3/sysext/cms/layout/db_layout.php

index 4490611..49caa3b 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2010-02-05  Steffen Kamper  <info@sk-typo3.de>
+
+       * Fixed bug #1822: There is no API to list tables in theWeb->Page module (thanks to Franz Holzinger)
+
 2010-02-07  Christian Kuhn  <lolli@schwarzbu.ch>
 
        * Follow-up to #13448: Unset another variable
index a50cb80..642ecba 100755 (executable)
@@ -128,7 +128,7 @@ class tx_cms_layout extends recordList {
        var $ext_function=0;                                    // If set to "1", will link a big button to content element wizard.
        var $doEdit=1;                                                  // If true, elements will have edit icons (probably this is whethere the user has permission to edit the page content). Set externally.
        var $agePrefixes = ' min| hrs| days| yrs';      // Age prefixes for displaying times. May be set externally to localized values.
-       var $externalTables = array();                  // Array of tables which is configured to be listed by the Web > Page module in addition to the default tables.
+       var $externalTables = array();                  // Array of tables to be listed by the Web > Page module in addition to the default tables.
        var $descrTable;                                                // "Pseudo" Description -table name
        var $defLangBinding=FALSE;                              // If set true, the language mode of tt_content elements will be rendered with hard binding between default language content elements and their translations!
 
@@ -183,12 +183,7 @@ class tx_cms_layout extends recordList {
                t3lib_div::loadTCA($table);
 
                if (isset($this->externalTables[$table]))       {
-                       $fList = $this->externalTables[$table][0]['fList'];     // eg. "name;title;email;company,image"
-                       $icon = $this->externalTables[$table][0]['icon'];       // Boolean,
-
-                               // Create listing
-                       $out = $this->makeOrdinaryList($table, $id, $fList, $icon);
-                       return $out;
+                       return $this->getExternalTables($id, $table);
                } else {
                                // Branch out based on table name:
                                // Notice: Most of these tables belongs to other extensions than 'cms'. Each of these tables can be rendered only if the extensions they belong to is loaded.
@@ -230,6 +225,33 @@ class tx_cms_layout extends recordList {
                }
        }
 
+
+       /**
+        * Renders an external table from page id
+        *
+        * @param       integer         Page id
+        * @param       string          name of the table
+        * @return      string          HTML for the listing
+        */
+       function getExternalTables($id, $table) {
+               $type = $GLOBALS['SOBE']->MOD_SETTINGS[$table];
+               if (!isset($type)) {
+                       $type = 0;
+               }
+               
+               $fList = $this->externalTables[$table][$type]['fList']; // eg. "name;title;email;company,image" 
+                                                                                                                       // The columns are separeted by comma ','.
+                                                                                                                       // Values separated by semicolon ';' are shown in the same column. 
+               $icon = $this->externalTables[$table][$type]['icon'];
+               $addWhere = $this->externalTables[$table][$type]['addWhere'];
+               
+                       // Create listing
+               $out = $this->makeOrdinaryList($table, $id, $fList, $icon, $addWhere);
+               return $out;
+       }
+
+
        /**
         * Renders records from the pages table from page id
         * (Used to get information about the page tree content by "Web>Info"!)
index 7424582..969c12b 100755 (executable)
@@ -214,6 +214,7 @@ class SC_db_layout {
        var $MOD_MENU=array();          // Menu configuration
        var $MOD_SETTINGS=array();      // Module settings (session variable)
        var $include_once=array();      // Array, where files to include is accumulated in the init() function
+       var $externalTables = array();  // Array of tables to be listed by the Web > Page module in addition to the default tables
 
                // Internal, dynamic:
        var $content;                           // Module output accumulation
@@ -250,6 +251,7 @@ class SC_db_layout {
                $this->search_levels = t3lib_div::_GP('search_levels');
                $this->showLimit = t3lib_div::_GP('showLimit');
                $this->returnUrl = t3lib_div::_GP('returnUrl');
+               $this->externalTables = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cms']['db_layout']['addTables'];
 
                        // Load page info array:
                $this->pageinfo = t3lib_BEfunc::readPageAccess($this->id,$this->perms_clause);
@@ -317,8 +319,8 @@ class SC_db_layout {
                        'showDescriptions' => '',
                        'disableRTE' => '',
                        'function' => array(
-                               1 => $LANG->getLL('m_function_1'),
                                0 => $LANG->getLL('m_function_0'),
+                               1 => $LANG->getLL('m_function_1'),
                                2 => $LANG->getLL('m_function_2'),
                                3 => $LANG->getLL('pageInformation')
                        ),
@@ -327,6 +329,26 @@ class SC_db_layout {
                        )
                );
 
+               // example settings:
+               //      $TYPO3_CONF_VARS['EXTCONF']['cms']['db_layout']['addTables']['tx_myext'] =
+               //              array ('default' => array(
+               //                              'MENU' => 'LLL:EXT:tx_myext/locallang_db.xml:menuDefault',
+               //                              'fList' =>  'title,description,image',
+               //                              'icon' => TRUE),
+               if (is_array($this->externalTables)) {
+                       foreach ($this->externalTables as $table => $tableSettings) {
+                               // delete the default settings from above
+                               if (is_array($this->MOD_MENU[$table])) {
+                                       unset ($this->MOD_MENU[$table]);
+                               }
+                               if (is_array($tableSettings)) {
+                                       foreach ($tableSettings as $key => $settings) {
+                                               $this->MOD_MENU[$table][$key] = $LANG->sL($settings['MENU']);
+                                       }
+                               }
+                       }
+               }
+
                         // First, select all pages_language_overlay records on the current page. Each represents a possibility for a language on the page. Add these to language selector.
                $res = $this->exec_languageQuery($this->id);
                while($lrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))      {
@@ -950,8 +972,7 @@ class SC_db_layout {
                $dblist->defLangBinding = $this->modTSconfig['properties']['defLangBinding'] ? 1 : 0;
                if (!$dblist->nextThree)        $dblist->nextThree = 1;
 
-               $dblist->externalTables = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cms']['db_layout']['addTables'];
-
+               $dblist->externalTables = $this->externalTables;
 
                        // Create menu for selecting a table to jump to (this is, if more than just pages/tt_content elements are found on the page!)
                $h_menu = $dblist->getTableMenu($this->id);
@@ -1032,8 +1053,12 @@ class SC_db_layout {
                                        break;
                                }
                        } else {
+                               if (isset($this->MOD_SETTINGS) && isset($this->MOD_MENU)) {
+                                       $h_func = t3lib_BEfunc::getFuncMenu($this->id, 'SET[' . $table . ']', $this->MOD_SETTINGS[$table], $this->MOD_MENU[$table], 'db_layout.php', '');
+                               } else {
                                $h_func = '';
                        }
+                       }
 
                                // Start the dblist object:
                        $dblist->itemsLimitSingleTable = 1000;