Listing 6.1: Aktivierung eines eigenen HTML-Templates für das Backend-Login
$GLOBALS['TBE_STYLES']['htmlTemplates']['templates/login.html'] = 'sysext/t3skin/templates/login.html';
Listing 6.2: Angaben zum Pfad zu den Icons in ext_tables.php
$TBE_STYLES['skinImgAutoCfg'] = array(
   'absDir'             => t3lib_extMgm::extPath($_EXTKEY).'icons/',
   'relDir'             => t3lib_extMgm::extRelPath($_EXTKEY).'icons/',
   'forceFileExtension' => 'gif',   // Force to look for PNG alternatives...
#     'scaleFactor'        => 2/3,  // Scaling factor, default is 1
   'iconSizeWidth'      => 16,
   'iconSizeHeight'     => 16,
);
Listing 6.3: Pfad zum überschreiben spezieller Icons in ext_tables.php
$TBE_STYLES['skinImg'] = array_merge($presetSkinImgs, array (
   'MOD:web/website.gif'  => array($extPath.'icons/module_web.gif','width="24" height="24"'),
));
Listing 6.4: Alternative CSS-Dateien und -Definitionen angeben in ext_tables.php
      // Setting up stylesheets (See template() constructor!)
#  $TBE_STYLES['stylesheet']                   = $temp_eP.'stylesheets/stylesheet.css';         // Alternative stylesheet to the default "typo3/stylesheet.css" stylesheet.
#  $TBE_STYLES['stylesheet2']                  = $temp_eP.'stylesheets/stylesheet.css';         // Additional stylesheet (not used by default).  Set BEFORE any in-document styles
   $TBE_STYLES['styleSheetFile_post']          = $temp_eP.'stylesheets/stylesheet_post.css';    // Additional stylesheet. Set AFTER any in-document styles
#  $TBE_STYLES['inDocStyles_TBEstyle']         = '* {text-align: right;}';                   // Additional default in-document styles.
   $TBE_STYLES['stylesheets']['modulemenu']    = $temp_eP.'stylesheets/modulemenu.css';
   $TBE_STYLES['stylesheets']['backend-style'] = $temp_eP.'stylesheets/backend-style.css';
   $TBE_STYLES['stylesheets']['admPanel'] = $temp_eP.'stylesheets/admPanel.css';
Listing 6.5: Angabe einer neuen Stilgruppe und Verwendung für das Feld title: ext_tables.php
$TBE_STYLES['colorschemes'][7]='-|class-main71,-|class-main72,-|class-main73,-|class-main74,-|class-main75';
$TBE_STYLES['inDocStyles_TBEstyle'] .= 'tr.class-main71 td {background-color: red;color:white;}';
t3lib_div::loadTCA("pages");
$TCA['pages']['types']['1']['showitem'] = 'hidden;;;;1-1-1, doktype;;2;button, title;;3;;7-7-7';
Listing 6.6: Auswertung des Parameters tablesInPageModule
if($confArr['tablesInPageModule']) {
   $tablesInPageModule = explode('|',$confArr['tablesInPageModule']);
}
if (is_array($tablesInPageModule))  {
   foreach($tablesInPageModule as $tableLine)   {
      $tableData = explode(':',trim($tableLine));
         // set the localconfvar for each table
      $TYPO3_CONF_VARS['EXTCONF']['cms']['db_layout']['addTables'][trim($tableData[0])][0] = array(
         'fList' => trim($tableData[1]),
         'icon' => TRUE,
      );
   }
}
Listing 6.7: Feld abstract auf dem Seitentyp Standard anzeigen
t3lib_div::loadTCA('pages');
t3lib_extMgm::addToAllTCAtypes('pages','shortcut','1','after:title');
Listing 6.8: Direktes Verändern der Konfiguration mit showitem
t3lib_div::loadTCA('pages');
$TCA['pages']['types']['1']['showitem'] = 'hidden;;;;1-1-1, doktype;;2;button';
Listing 6.9: Felder gezielt zu Paletten hinzufügen
t3lib_extMgm::addNewFieldsToAllPalettesOfField($table, $field,
$addFields, $insertionPosition = '');
t3lib_extMgm::addNewFieldsToPalette($table, $palette, $addFields,
$insertionPosition = '');
Listing 6.10: Anpassung der Beschriftung des Buttons für die indizierte Suche
plugin.tx_indexedsearch {
   _LOCAL_LANG.default {
      submit_button_label = go for it!
   }
   _LOCAL_LANG.de {
      submit_button_label = hols dir!
   }
}
Listing 6.11: Anpassung der Texte von Auswahlfeldern
TCEFORM.pages.doktype {
   altLabels.1 = normale Seite
}
Listing 6.12: Anpassung der Texte von Auswahlfeldern mit Mehrsprachigkeit über eine eigene Extension, hier abz_eff_labels
TCEFORM.pages.doktype {
   altLabels.1 = LLL:EXT:abz_eff_labels/locallang_be.php:altLabel.pageStandard
}
Listing 6.13: Angabe in der Datei ext_localconf.php
$TYPO3_CONF_VARS['BE']['XLLfile']['EXT:lang/locallang_core.php']=
'EXT:abz_eff_labels/locallang_db.php';
Listing 6.14: Änderung des Logout-Buttons im Backend
$LOCAL_LANG = Array (
   'default' => Array (
      'buttons.logout' => 'end my session',
   ),
   'de' => Array (
      'buttons.logout' => 'Session verlassen',
   ),
);
Listing 6.15: Selbst erstellte Sprachdatei locallang_db.php
$LOCAL_LANG = Array (
   'default' => Array (
         //label from EXT:lang/locallang_core.php
      'buttons.logout' => 'end session',
         //label from EXT:cms/locallang_tca.php
      'pages.doktype.I.0' => 'advanced page',
      'pages.hidden' => 'hide on website',
         //label from EXT:cms/locallang_ttc.php
      'CType.I.0' => 'only Header',
         //version with Page TS, see tsconfig_page.txt
      'altLabel.pageStandard.1' => 'basic page',
   ),
   'de' => Array (
      'buttons.logout' => 'Session verlassen',
      'pages.doktype.I.0' => 'erweiterte Seite',
      'pages.hidden' => 'auf Webseite verstecken',
      'CType.I.0' => 'nur ?berschrift',
      'altLabel.pageStandard.1' => '0815 Seite',
   ),
);
Listing 6.16: Einbindung der neuen Sprachdatei
$TYPO3_CONF_VARS['BE']['XLLfile']['EXT:lang/locallang_core.php']='EXT:abz_eff_labels/locallang_db.php';
$TYPO3_CONF_VARS['BE']['XLLfile']['EXT:cms/locallang_ttc.php']='EXT:abz_eff_labels/locallang_db.php';
$TYPO3_CONF_VARS['BE']['XLLfile']['EXT:cms/locallang_tca.php']='EXT:abz_eff_labels/locallang_db.php';
Listing 6.17: Inhalt der Datei locallang_csh_refitems.php
<?php
$LOCAL_LANG = Array (
   'default' => Array (
      'category.description' => 'Die Kategorie entscheidet ?ber den Erscheinungsort der Referenz.',
      'category.details' => 'Durch die Auswahl der Kategorie k?nnen Sie festlegen, wo genau die Referenz im Frontend auftauchen wird.<br />Falls Sie eine neue Kategorie ben?tigen, setzen Sie sich mit Ihrem TYPO3-Administrator in Verbindung.',
   ),
);
?>
Listing 6.18: $TCA-Konfiguration für sys_language:static_lang_isocode
$TCA['sys_language']['columns']['static_lang_isocode']['config'] = array(
   'type' => 'select',
   'items' => array(
      array('',0),
   ),
   #'foreign_table' => 'static_languages',
   #'foreign_table_where' => 'AND static_languages.pid=0 ORDER BY static_languages.lg_name_en',
   'itemsProcFunc' => 'tx_staticinfotables_div->selectItemsTCA',
   'itemsProcFunc_config' => array(
      'table' => 'static_languages',
      'indexField' => 'uid',
      // I think that will make more sense in the future
      // 'indexField' => 'lg_iso_2',
      'prependHotlist' => 1,
      // defaults:
      //'hotlistLimit' => 8,
      //'hotlistSort' => 1,
      //'hotlistOnly' => 0,
      //'hotlistApp' => TYPO3_MODE,
   ),
   'size' => 1,
   'minitems' => 0,
   'maxitems' => 1,
);
Listing 6.19: Auszug aus der Funktion selectItemsTCA, die von itemsProcFunc aufgerufen wird
function selectItemsTCA($params) {
   global $TCA;
   $table = $params['config']['itemsProcFunc_config']['table'];
 
   if ($table) {
      $indexField = $params['config']['itemsProcFunc_config']['indexField'];
      $indexField = $indexField ? $indexField : 'uid';
 
      $lang = strtolower(tx_staticinfotables_div::getCurrentLanguage());
      $titleFields = tx_staticinfotables_div::getTCAlabelField($table, TRUE, $lang);
#[...]
      if ($params['config']['itemsProcFunc_config']['prependHotlist']) {
#[...]
         foreach ($rows as $index => $title) {
            $params['items'][] = array($title, $index, '');
            $cnt++;
         }
         if($cnt && !$params['config']['itemsProcFunc_config']['hotlistOnly']) {
            $params['items'][] = array('--------------', '', '');
         }
      }
#[...]
   }
}
Listing 6.20: Hinzufügen des Wizards zu bestimmten Feldern: ext_tables.php
   // Create wizard configuration:
$wizConfig = array(
   'type' => 'userFunc',
   'userFunc' => 'EXT:lorem_ipsum/class.tx_loremipsum_wiz.php:tx_loremipsum_wiz->main',
   'params' => array()
);
 
   // Load affected tables (except "pages"):
t3lib_div::loadTCA('tt_content');
t3lib_div::loadTCA('pages_language_overlay');
t3lib_div::loadTCA('sys_language');
   // *********************
   // Apply wizards to:
   // *********************
   // Titles:
$TCA['pages']['columns']['title']['config']['wizards']['tx_loremipsum'] =
$TCA['pages']['columns']['nav_title']['config']['wizards']['tx_loremipsum'] =
$TCA['pages_language_overlay']['columns']['title']['config']['wizards']['tx_loremipsum'] =
$TCA['pages_language_overlay']['columns']['nav_title']['config']['wizards']['tx_loremipsum'] =
   array_merge($wizConfig,array('params'=>array(
      'type' => 'title'
   )));
Listing 6.21: Auszug aus class.tx_loremipsum_wiz.php
/**
 * Main function for TCEforms wizard.
 *
 * @param   array    Parameter array for "userFunc" wizard type
 * @param   object      Parent object
 * @return  string      HTML for the wizard.
 */
function main($PA,$pObj)   {
      // Detect proper LR file source:
   $this->setLRfile($PA);
      // Load Lorem Ipsum sources from text file:
   $this->loadLoremIpsumArray();
   switch($PA['params']['type']) {
      case 'title':
      case 'header':
      case 'description':
      case 'word':
      case 'paragraph':
      case 'loremipsum':
         $onclick = $this->getHeaderTitleJS(
               "document.".$PA['formName']."['".$PA['itemName']."'].value",
               $PA['params']['type'],
               $PA['params']['endSequence'],
               $PA['params']['add'],
               t3lib_div::intInRange($PA['params']['count'],2,100,10),
               "document.".$PA['formName']."['".$PA['itemName']."']"
            ).';'.
            implode('',$PA['fieldChangeFunc']).    // Necessary to tell TCEforms that the value is updated.
            'return false;';
         $output.= '<a href="#" onclick="'.htmlspecialchars($onclick).'">'.
               $this->getIcon($PA['params']['type'],$this->backPath).
               '</a>';
      break;
#[...]
   return $output;
}
Listing 6.22: Wizard lorem ipsum für tt_news-Datensätze: ext_tables.php
if (TYPO3_MODE=='BE')   {
      // Load additional affected tables (except "pages"):
   t3lib_div::loadTCA('tt_news');
      // *********************
      // Apply wizards to:
      // *********************
      // Titles:
   $TCA['tt_news']['columns']['title']['config']['wizards']['tx_loremipsum'] =
      array_merge($wizConfig,array('params'=>array(
         'type' => 'title'
      )));
      // Description / Abstract:
   $TCA['tt_news']['columns']['short']['config']['wizards']['tx_loremipsum'] =
      array_merge($wizConfig,array('params'=>array(
         'type' => 'description',
         'endSequence' => '46,32',
         'add' => TRUE
      )));
      // Bodytext field in Content Elements:
   $TCA['tt_news']['columns']['bodytext']['config']['wizards']['_VERTICAL'] = 1;
   $TCA['tt_news']['columns']['bodytext']['config']['wizards']['tx_loremipsum_2'] =
      array_merge($wizConfig,array('params'=>array(
         'type' => 'loremipsum',
         'endSequence' => '32',
         'add'=>TRUE
      )));
   $TCA['tt_news']['columns']['bodytext']['config']['wizards']['tx_loremipsum'] =
      array_merge($wizConfig,array('params'=>array(
         'type' => 'paragraph',
         'endSequence' => '10',
         'add'=>TRUE
      )));
   
   $TCA['tt_news']['columns']['image']['config']['wizards']['_POSITION'] = 'bottom';
   $TCA['tt_news']['columns']['image']['config']['wizards']['tx_loremipsum'] =
      array_merge($wizConfig,array('params'=>array(
         'type' => 'images'
      )));
}
Listing 6.23: Daten-Array mithilfe der TCE einspielen
$tce->start($pageTree,array());
$tce->process_datamap();
Listing 6.24: Die Klasse tx_datarules_evalIntegerList
class tx_datarules_evalIntegerList {
 
   /*
    * return the JavaScript-Code for clientside evaluation
    * just dummy, we do evaluation only on server side
    *
    * @return string
    */
   public function returnFieldJS() {
      return '
         return value;
      ';
   }
 
   /*
    * evaluates the value and returns the resulting value
    * @param string Is-in string for 'is_in' evaluation
    * @param boolean modification of value is allowed if TRUE
    *
    * @return string
    */
   public function evaluateFieldValue($value, $is_in, $set) {
      if (!$set) {
         return $value;
      }
 
      $tempIntegerArray = t3lib_div::intExplode(',',$value,TRUE);
      $integerArray = array();
      foreach ($tempIntegerArray as $singleValue) {
         if ($singleValue > 0) {
            $integerArray[] = $singleValue;
         }
      }
      $value = join(',',$integerArray);
      if (!$value) {
         $value = '';
      }
      return $value;
   }
 
   /*
    * DEMO: set the value in mask different from value in DB
    * @param array parameters for the hook
    *
    * @return array
    */
   public function deevaluateFieldValue($params) {
      return $params['value'] .= 'xxx';
   }
}
Listing 6.25: Registrierung der Klasse in ext_localconf.php
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals']['tx_datarules_evalIntegerList'] =
'EXT:datarules/class.tx_datarules_evalintegerlist.php';
Listing 6.26: Nutzung der neuen Evaluierungsregel für das Feld selector2
$TCA['tx_datarules_rule']['columns']['selector2']['eval'] => 'tx_datarules_evalIntegerList';
Listing 6.27: Einbindung der serverseitigen Evaluierung in t3lib_TCEmain::checkValue_text_Eval
if (substr($func, 0, 3) == 'tx_')   {
   $evalObj = t3lib_div::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$func].':&'.$func);
   if (is_object($evalObj) && method_exists($evalObj, 'evaluateFieldValue'))  {
      $value = $evalObj->evaluateFieldValue($value, $is_in, $set);
   }
}
Listing 6.28: Einbindung der clientseitigen Evaluierung in t3lib_TCEforms ::getSingleField_typeInput()
foreach ($evalList as $evalData) {
   if (substr($evalData, 0, 3) == 'tx_')  {
      $evalObj = t3lib_div::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$evalData].':&'.$evalData);
      if(is_object($evalObj) && method_exists($evalObj, 'returnFieldJS'))  {
         $this->extJSCODE .= "\n\nfunction ".$evalData."(value) {\n".$evalObj->returnFieldJS()."\n}\n";
      }
   }
}
Listing 6.29: Inhalt der Datei ext_tables.sql
#
# Table structure for table 'pages'
#
CREATE TABLE pages (
    tx_extname_artikelnr tinytext,
    tx_extname_subcat tinytext,
    tx_extname_url tinytext,
);
Listing 6.30: TCA der Tabelle pages um die neuen Felder zu erweitern (in ext_tables.php)
$tempColumns = Array (
   "tx_extname_ artikelnr" => Array (
      "label" => "LLL:EXT:extname/locallang_db.xml:pages.tx_extname_ artikelnr",
      "config" => Array (
         "type" => "text",
         "size" => 30,
      )
   ),
   ...
);
t3lib_div::loadTCA("pages");
t3lib_extMgm::addTCAcolumns("pages",$tempColumns,1);
t3lib_extMgm::addToAllTCAtypes('pages','--div--;###Label###, tx_extname_artikelnr;;;;1-1-1, tx_extname_subcat, tx_extname_url');
Listing 6.31: Anlegen und Konfigurieren eines neuen Seitentyps
  1. $TCA['pages']['types']['42']['showitem'] = 'doktype;;;;1-1-1, title;;;;1-1-1, tx_extname_artikelnr, tx_extname_subcat, tx_extname_url';
  2. $TCA['pages']['columns']['doktype']['config']['items'][] = Array(
  3. '0' => 'Produkt',
  4. '1' => 42,
  5. '2' => 'i/icon_tx_extname_product.gif',
  6. );
  7. $PAGES_TYPES['42'] = Array (
  8. 'icon' => '../typo3conf/ext/extname/icons/icon_tx_extname_product.gif',
  9. 'allowedTables' => 'pages_language_overlay',
  10. 'onlyAllowedTables' => '0'
  11. );
Listing 6.32: Anlegen eines Dividers
$TCA['pages']['columns']['doktype']['config']['items'][] = Array (
      '0' => 'PRODUKTE',
      '1' => '--div--',
);
Listing 6.33: Label für Tabelle pages erweitern
	// label
$TCA['pages']['ctrl']['label'] = 'tx_extname_subcat';
$TCA['pages']['ctrl']['label_alt'] = 'title';
$TCA['pages']['ctrl']['label_alt_force'] = 1;
Listing 6.34: Backend sperren in TYPO3 4.2 und älter
//nur Zugang f?r Admins
$TYPO3_CONF_VARS['BE']['adminOnly'] = 1;
   //Backend wird komplett gesperrt
$TYPO3_CONF_VARS['BE']['adminOnly'] = -1;
Listing 6.35: Sperren und Entsperren des Backends per CLI-Script
   //sperren mit redirect
/[yourpath]/typo3/dispatch.phpsh lowlevel_admin setBElock --redirect http://www.ihrziel.de
   //entsperren
/[yourpath]/typo3/dispatch.phpsh lowlevel_admin clearBElock