From 9e51a7351b5eb80aba882b1b955b93997214d2ac Mon Sep 17 00:00:00 2001 From: Ingo Renner <ingo.renner@typo3.org> Date: Fri, 16 Nov 2007 09:54:15 +0000 Subject: [PATCH] added feature #6545: Hook Request: db_list git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@2728 709f56b5-9817-0410-a4d7-c38de5d9e867 --- ChangeLog | 4 ++ ...face.t3lib_localrecordlistgettablehook.php | 52 +++++++++++++++++++ typo3/class.db_list_extra.inc | 23 ++++++-- 3 files changed, 74 insertions(+), 5 deletions(-) create mode 100644 t3lib/interfaces/interface.t3lib_localrecordlistgettablehook.php diff --git a/ChangeLog b/ChangeLog index b5def06a87ac..4a22a45992cf 100755 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2007-11-16 Ingo Renner <ingo@typo3.org> + + * added feature #6545: Hook Request: db_list + 2007-11-15 Ingmar Schlecht <ingmar@typo3.org> * Release of TYPO3 4.2.0alpha2 diff --git a/t3lib/interfaces/interface.t3lib_localrecordlistgettablehook.php b/t3lib/interfaces/interface.t3lib_localrecordlistgettablehook.php new file mode 100644 index 000000000000..aaa50e9914af --- /dev/null +++ b/t3lib/interfaces/interface.t3lib_localrecordlistgettablehook.php @@ -0,0 +1,52 @@ +<?php +/*************************************************************** +* Copyright notice +* +* (c) 2007 Ingo Renner <ingo@typo3.org> +* All rights reserved +* +* This script is part of the TYPO3 project. The TYPO3 project is +* free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* The GNU General Public License can be found at +* http://www.gnu.org/copyleft/gpl.html. +* A copy is found in the textfile GPL.txt and important notices to the license +* from the author is found in LICENSE.txt distributed with these scripts. +* +* +* This script is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* This copyright notice MUST APPEAR in all copies of the script! +***************************************************************/ + + +/** + * interface for classes which hook into localRecordList and do additional getTable processing + * + * @author Ingo Renner <ingo@typo3.org> + * @package TYPO3 + * @subpackage t3lib + */ +interface t3lib_localRecordListGetTableHook { + + /** + * modifies the DB list query + * + * @param string the current database table + * @param integer the record's unique ID + * @param string an additional WHERE clause + * @param string comma separated list of selected fields + * @param localRecordList parent localRecordList object + * @return void + */ + public function getDBlistQuery($table, $uid, $additionalWhereClause, $selectedFieldsList, $parentObject); + +} + +?> \ No newline at end of file diff --git a/typo3/class.db_list_extra.inc b/typo3/class.db_list_extra.inc index 9d9d6b003ffe..f6794c697cad 100755 --- a/typo3/class.db_list_extra.inc +++ b/typo3/class.db_list_extra.inc @@ -306,7 +306,7 @@ class localRecordList extends recordList { * @return string HTML table with the listing for the record. */ function getTable($table,$id,$rowlist) { - global $TCA; + global $TCA, $TYPO3_CONF_VARS; // Loading all TCA details for this table: t3lib_div::loadTCA($table); @@ -388,6 +388,19 @@ class localRecordList extends recordList { $selectFields = array_intersect($selectFields,$this->makeFieldList($table,1)); // Making sure that the fields in the field-list ARE in the field-list from TCA! $selFieldList = implode(',',$selectFields); // implode it into a list of fields for the SQL-statement. + // DB-List getTable-Hook + if(is_array($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list_extra.inc']['getTable'])) { + foreach($TYPO3_CONF_VARS['SC_OPTIONS']['typo3/class.db_list_extra.inc']['getTable'] as $classData) { + $hookObject = &t3lib_div::getUserObj($classData); + + if(!($hookObject instanceof t3lib_localRecordListGetTableHook)) { + throw new UnexpectedValueException('$hookObject must implement interface t3lib_localRecordListGetTableHook', 1195114460); + } + + $hookObject->getDBlistQuery($table, $id, $addWhere, $selFieldList, $this); + } + } + // Create the SQL query for selecting the elements in the listing: $queryParts = $this->makeQueryArray($table, $id,$addWhere,$selFieldList); // (API function from class.db_list.inc) $this->setTotalItems($queryParts); // Finding the total amount of records on the page (API function from class.db_list.inc) @@ -460,10 +473,10 @@ class localRecordList extends recordList { $prevPrevUid = 0; $accRows = array(); // Accumulate rows here while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { - + // In offline workspace, look for alternative record: t3lib_BEfunc::workspaceOL($table, $row, $GLOBALS['BE_USER']->workspace, TRUE); - + if (is_array($row)) { $accRows[] = $row; $currentIdList[] = $row['uid']; @@ -520,7 +533,7 @@ class localRecordList extends recordList { foreach($translations as $lRow) { // In offline workspace, look for alternative record: t3lib_BEfunc::workspaceOL($table, $lRow, $GLOBALS['BE_USER']->workspace); - + if (is_array($lRow) && $GLOBALS['BE_USER']->checkLanguageAccess($lRow[$TCA[$table]['ctrl']['languageField']])) { $currentIdList[] = $lRow['uid']; $iOut.=$this->renderListRow($table,$lRow,$cc,$titleCol,$thumbsCol,18); @@ -991,7 +1004,7 @@ class localRecordList extends recordList { $stat.=t3lib_div::callUserFunction($_funcRef,$_params,$this); } $cells[] = $stat; - } + } // Compile items into a DIV-element: return ' -- GitLab