Project

General

Profile

Feature #17606 » class.tx_majalabelrename_tceforms_xclass.php

Administrator Admin, 2007-09-18 18:51

 
<?php
/***************************************************************
* Copyright notice
*
* (c) 2007 Malte Jansen (m a i l ( ? t ) m a l t e j a n s e n . d e)
* 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.
*
* 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!
***************************************************************/

/**
* Extends the TCEforms with the LOCALLANG-Functions (like replacing a file)
*
*/

class ux_t3lib_TCEforms extends t3lib_TCEforms {
var $LLLconf; //Saves all LOCALLANG-Configurations
/**
* Added registerLLL to the class
*
* @param String $table
* @param Array $row
* @param unknown_type $depth
* @return unknown
*/
function getMainFields($table,$row,$depth=0) {
$this->registerLLL($table,$row);
return parent::getMainFields($table,$row,$depth);
}
/**
*
* Adds the pre- and postProcess functions.
*
* @see parent::sL()
*
* @param unknown_type $str
* @return String
*/
function sL($str) {
$postProcess = false;
if (count($this->LLLconf) > 0 && is_array($this->LLLconf)) {
$tempStr = explode(":",$str);
$LLfile = $tempStr[0].":".$tempStr[1].":".$tempStr[2];
if (array_key_exists($LLfile,$this->LLLconf)) {
$postProcess = true;
foreach($this->LLLconf[$LLfile] AS $action => $properties) {
$str = $this->preProcessLLL($LLfile,$str,$properties,$action);
}
}
}
$str = parent::sL($str);
if ($postProcess) {
foreach($this->LLLconf[$LLfile] AS $action => $properties) {
$str = $this->postProcessLLL($LLfile,$str,$properties,$action);
}
}
return $str;
}

/**
* Registers the Locallang-Configurations.
*
* @param String $table
* @param Array $row
*/
function registerLLL($table,$row) {
if (empty($this->LLLconf)) {
$this->LLLconf = array();
list($TScID,$cPid) = t3lib_BEfunc::getTSCpid($table,$row['uid'],$row['pid']);
$rootLine = t3lib_BEfunc::BEgetRootLine($TScID,'',TRUE);
if ($TScID >= 0) {
$tempTSconfig = t3lib_BEfunc::getPagesTSconfig($TScID,$rootLine);
$tempConf = $GLOBALS['BE_USER']->getTSConfig('TCEFORM.LOCALLANG',$tempTSconfig);
if (count($tempConf["properties"]) > 0 && is_array($tempConf["properties"])) {
foreach (array_keys($tempConf["properties"]) AS $key) {
if (preg_match('|^[0-9+]$|',$key)) {
$TSConfig = $GLOBALS['BE_USER']->getTSConfig("TCEFORM.LOCALLANG.{$key}",$tempTSconfig);
if ($this->isLLLformat($TSConfig["value"])) {
$this->LLLconf[$TSConfig["value"]] = $TSConfig["properties"];
}
}
}
}
}
}
}
/**
* Function for checking a String for the LLL-Format
*
* @param String $value
* @return Boolean
*/
function isLLLformat($value) {
return preg_match('|^LLL\:EXT\:(.+)\/locallang(.*)\.([a-z]{3})(.*)$|',$value);
}
/**
* PreProcessing Actions for the Locallang
*
* @param String $LLfile
* @param String $str
* @param Mixed $properties
* @param String $action
* @return String
*/
function preProcessLLL($LLfile,$str,$properties,$action) {
switch ($action) {
case 'replace':
return $this->preProcessLLL_replace($LLfile,$str,$properties);
}
return $str;
}

/**
* PostProcessing Actions for the Locallang
*
* @param String $LLfile
* @param String $str
* @param Mixed $properties
* @param String $action
* @return String
*/
function postProcessLLL($LLfile,$str,$properties,$action) {
return $str;
}
/**
* The Function replaces a LL-File with a new one
*
* @param String $LLfile
* @param String $str
* @param Mixed $properties
* @return String
*/
function preProcessLLL_replace($LLfile,$str,$properties) {
if ($this->isLLLformat($properties)) {
$newstr = $properties.":".substr($str,strlen($LLfile)+1);
$newstr_sL = parent::sL($newstr);
$str = (empty($newstr_sL) ? $str : $newstr);
}
return $str;
}
}

/**
* Dummy for extension Manager
*
*/
class tx_majalabelrename_tceforms_xclass {
}
?>
(2-2/4)