[TYPO3-core] 0001822: There is no API to list tables in the Web->Page module
Ingmar Schlecht
ingmar at typo3.org
Mon Dec 5 15:27:44 CET 2005
Hi Franz,
that looks like a good idea to me.
I just looked briefly at the code, too briefly to give a "+1".
Here are my comments:
> $TYPO3_CONF_VARS['EXTCONF']['cms']['db_layout']['addTables']['tt_products']
> =
> array ('default' => array(
> 'MENU' => 'LLL:EXT:tt_products/locallang.php:m_default',
> 'fList' => 'title,itemnumber,price,image',
> // 'fList' =>
> 'title;itemnumber;price;price2;inStock;category,image,note',
> 'icon' => TRUE),
> 'ext' => array (
> 'MENU' => 'LLL:EXT:tt_products/locallang.php:m_ext',
> 'fList' => 'title,price2,category;inStock;weight;tax',
> 'icon' => TRUE),
> 'variants' => array (
> 'MENU' =>
> 'LLL:EXT:tt_products/locallang.php:m_variants',
> 'fList' => 'title,color;size;gradings',
> 'icon' => TRUE)
> );
> $TYPO3_CONF_VARS['EXTCONF']['cms']['db_layout']['addTables']['tt_products_articles']
> =
> array ('default' => array(
> 'MENU' => 'LLL:EXT:tt_products/locallang.php:m_default',
> 'fList' => 'title,itemnumber,price,inStock',
> 'icon' => TRUE),
> 'ext' => array (
> 'MENU' => 'LLL:EXT:tt_products/locallang.php:m_ext',
> 'fList' => 'title;price2,color;size;gradings',
> 'icon' => TRUE)
> );
> $TYPO3_CONF_VARS['EXTCONF']['cms']['db_layout']['addTables']['tt_products_cat']
> =
> array ('default' => array(
> 'MENU' => 'LLL:EXT:tt_products/locallang.php:m_default',
> 'fList' => 'title,image',
> 'icon' => TRUE));
> }
>
> $LOCAL_LANG = Array (
> 'default' => Array (
> 'plugins_title' => 'Shop System',
> 'plugins_description' => 'Add a shopping system plugin to the
> page. This is a part of the built-in shop and requires the page to
> contain product elements in the database.',
> 'm_default' => 'default',
> 'm_ext' => 'extended',
> 'm_variants' => 'variants',
> ),
This example (which, I suppose, will be included in tt_products?) is not
correctly indented.
I have attached two example files (a good and a bad one) that show how
indentation of multi-dimensional arrays should be done.
> [franz at localhost layout]$ diff -ru /var/www/html/typo3cvs/TYPO3core/typo3/sysext/cms/layout/db_layout.php /var/www/html/typo3/sysext/
> cms/layout/db_layout.php
> --- /var/www/html/typo3cvs/TYPO3core/typo3/sysext/cms/layout/db_layout.php 2005-11-24 01:10:36.000000000 +0100
> +++ /var/www/html/typo3/sysext/cms/layout/db_layout.php 2005-12-05 14:34:46.586008616 +0100
> @@ -213,6 +213,8 @@
> 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 which is configured to be listed by the Web > Page module in addition to t
> he default tables.
Remove the words "which is configured" so it's "Array of tables to be
listed by..."
> +
> // Internal, dynamic:
> var $content; // Module output accumulation
> var $topFuncMenu; // Function menu temporary storage
> @@ -249,6 +251,9 @@
> $this->showLimit = t3lib_div::_GP('showLimit');
> $this->returnUrl = t3lib_div::_GP('returnUrl');
>
> + // local variables
> + $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);
>
> @@ -315,8 +320,8 @@
> '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')
> ),
> @@ -325,6 +330,27 @@
> )
> );
>
> + // example settings:
> + // $TYPO3_CONF_VARS['EXTCONF']['cms']['db_layout']['addTables']['tt_products'] =
> + // array ('default' => array(
> + // 'MENU' => 'LLL:EXT:tt_products/locallang.php:m_default',
> + // 'fList' => 'title,itemnumber,price,image',
> + // 'icon' => TRUE),
Wrong array indentation. See attached example file
"correct-indentation.txt".
> + /**
> + * Renders an external table from page id
> + * NOTICE: Requires the tt_products extension to be loaded.
The notice "Requires the tt_products extension" is probably wrong.
> + *
> + * @param integer Page id
The second parameter is missing documentation.
> + * @return string HTML for the listing
> + */
> + function getTable_external($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"
Is the comme in "company,image" intended, when everything else is a
semicolon?
> + $icon = $this->externalTables[$table][$type]['icon']; // Boolean,
Get rid of the comma after "Boolean,".
> + $addWhere = $this->externalTables[$table][$type]['addWhere'];
> +
> + // Create listing
> + $out = $this->makeOrdinaryList($table, $id, $fList, $addWhere);
> + return $out;
> + }
Apart from these minor comments, I think this is a very useful patch.
But I haven't tested it, so I can't give a "+1".
cheers,
Ingmar
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: wrong-indentation.txt
Url: http://lists.netfielders.de/pipermail/typo3-team-core/attachments/20051206/796c208c/attachment.txt
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: correct-indentation.txt
Url: http://lists.netfielders.de/pipermail/typo3-team-core/attachments/20051206/796c208c/attachment-0001.txt
More information about the TYPO3-team-core
mailing list