Advertisement
Guest User

Untitled

a guest
Jan 20th, 2014
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.58 KB | None | 0 0
  1. <?php
  2.  
  3. /***************************************************************
  4.  *  Copyright notice
  5.  *
  6.  *  (c) 2013 Stephan Schuler <[email protected]>
  7.  *
  8.  *  All rights reserved
  9.  *
  10.  *  This script is part of the TYPO3 project. The TYPO3 project is
  11.  *  free software; you can redistribute it and/or modify
  12.  *  it under the terms of the GNU General Public License as published by
  13.  *  the Free Software Foundation; either version 3 of the License, or
  14.  *  (at your option) any later version.
  15.  *
  16.  *  The GNU General Public License can be found at
  17.  *  http://www.gnu.org/copyleft/gpl.html.
  18.  *
  19.  *  This script is distributed in the hope that it will be useful,
  20.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  21.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  22.  *  GNU General Public License for more details.
  23.  *
  24.  *  This copyright notice MUST APPEAR in all copies of the script!
  25.  ***************************************************************/
  26.  
  27. /**
  28.  * A Storage backend
  29.  *
  30.  * @package Nxl10nhelpers
  31.  * @subpackage Persistence\Storage
  32.  */
  33. class Tx_Nxl10nhelpers_Persistence_Storage_Typo3DbBackend extends Tx_Extbase_Persistence_Storage_Typo3DbBackend {
  34.  
  35.  
  36.     /**
  37.      * Builds the language field statement
  38.      *
  39.      * In contrast to the parent::addSysLanguageStatement() method, this one allows
  40.      * for having native language records that are no language overlays, too. No
  41.      * matter if the target record is default language, "all" or native, all of those
  42.      * are required to have the l10n_parent field poiting to "0", which indicates
  43.      * that they are no overlay records.
  44.      *
  45.      * @param string $tableName The database table name
  46.      * @param array &$sql The query parts
  47.      * @return void
  48.      */
  49.     protected function addSysLanguageStatement($tableName, array &$sql) {
  50.         if (is_array($GLOBALS['TCA'][$tableName]['ctrl'])) {
  51.             if(isset($GLOBALS['TCA'][$tableName]['ctrl']['languageField']) && $GLOBALS['TCA'][$tableName]['ctrl']['languageField'] !== NULL) {
  52.  
  53.                 $allowedLanguages = array_unique(array(0, -1, (int) $GLOBALS['TSFE']->sys_language_uid, (int) $GLOBALS['TSFE']->sys_language_content));
  54.                 $sql['additionalWhereClause'][] = $tableName . '.' . $GLOBALS['TCA'][$tableName]['ctrl']['languageField'] . ' IN (' . join(',', $allowedLanguages) . ')';
  55.  
  56.             }
  57.  
  58.             if(isset($GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField']) && $GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField'] !== NULL) {
  59.  
  60.                 $sql['additionalWhereClause'][] = $tableName . '.' . $GLOBALS['TCA'][$tableName]['ctrl']['transOrigPointerField'] . ' = 0';
  61.  
  62.             }
  63.         }
  64.     }
  65.  
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement