Created
June 7, 2013 08:39
-
-
Save pumatertion/5727903 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Contains translation tools | |
* | |
* @author Kasper Skaarhoj <[email protected]> | |
* @package TYPO3 | |
* @subpackage tx_l10nmgr | |
*/ | |
class tx_l10nmgr_tools { | |
/** | |
* Selecting records from a table from a page which are candidates to be translated. | |
* | |
* @param string Table name | |
* @param integer Page id | |
* @return array Array of records from table (with all fields selected) | |
*/ | |
function getRecordsToTranslateFromTable($table, $pageId) { | |
global $TCA; | |
// First, select all records that are default language OR international: | |
$allRows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows( | |
$table . '.*', | |
$table, | |
$table . '.pid=' . intval($pageId) . | |
' AND ' . $table . '.' . $TCA[$table]['ctrl']['languageField'] . '<=0' . | |
/** This part is wrong because if you created a new tt_content element f.e. in a workspace wich it has the t3ver_state=1 and will not be found by this query. t3ver_state<=0 OR t3ver_wsid=$currentworkspace is what is needed here and this is exactly what t3lib_BEfunc::versioningPlaceholderClause($table) does. so there is no need for this additional where statement for t3ver_state<=0 */ | |
##################### Wrong ######################### | |
# ($GLOBALS['TCA'][$table]['ctrl']['versioningWS'] ? ' AND ' . $table . '.t3ver_state<=0' : '') . | |
##################### /Wrong ######################## | |
$hiddenClause . | |
t3lib_BEfunc::deleteClause($table) . | |
t3lib_BEfunc::versioningPlaceholderClause($table) | |
); | |
return $allRows; | |
} | |
} | |
/** | |
* Selecting single record from a table filtering whether it is a default language / international element. | |
* | |
* @param string Table name | |
* @param integer Record uid | |
* @return array Record array if found, otherwise FALSE | |
*/ | |
function getSingleRecordToTranslate($table, $uid) { | |
global $TCA; | |
if ($this->t8Tools->isTranslationInOwnTable($table)) { | |
// First, select all records that are default language OR international: | |
$allRows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows( | |
'*', | |
$table, | |
'uid=' . intval($uid) . | |
' AND ' . $TCA[$table]['ctrl']['languageField'] . '<=0' . | |
/** This part is wrong because if you created a new tt_content element f.e. in a workspace wich it has the t3ver_state=1 and will not be found by this query. t3ver_state<=0 OR t3ver_wsid=$currentworkspace is what is needed here and this is exactly what t3lib_BEfunc::versioningPlaceholderClause($table) does. so there is no need for this additional where statement for t3ver_state<=0 */ | |
##################### Wrong ######################### | |
# ($GLOBALS['TCA'][$table]['ctrl']['versioningWS'] ? ' AND ' . $table . '.t3ver_state<=0' : '') . | |
##################### /Wrong ######################## | |
t3lib_BEfunc::deleteClause($table) . | |
t3lib_BEfunc::versioningPlaceholderClause($table) | |
); | |
return is_array($allRows) && count($allRows) ? $allRows[0] : false; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment