[TYPO3-german] Extension mehrsprachigkeit?!

Andreas Heller t3 at radiortc.de
Fri Apr 28 12:02:33 CEST 2006


Hi,
hier ist der Code... irgendwie funktioniert es nicht... (wird zwar alles 
ausgegeben - aber in allen sprachen...

Gruß
Andy


<?php
/***************************************************************
*  Copyright notice
*
*
*  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!
***************************************************************/
/**


/**
			while($temp = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
         // get the translated record if the content language is not the 
default language
         if ($GLOBALS['TSFE']->sys_language_content) {
                 $OLmode = ($this->sys_language_mode == 
'strict'?'hideNonTranslated':'');
                 $temp = 
$GLOBALS['TSFE']->sys_page->getRecordOverlay('tx_extension', $temp, 
$GLOBALS['TSFE']->sys_language_content, $OLmode);
         }
         $data[] = $temp;
         }
}

*/

require_once(PATH_tslib.'class.tslib_pibase.php');
/* $GLOBALS["TSFE"]->sys_language_uid
*/
class tx_cdcstaff_pi1 extends tslib_pibase {
	var $prefixId = 'tx_cdcstaff_pi1';		// Same as class name
	var $scriptRelPath = 'pi1/class.tx_cdcstaff_pi1.php';	// Path to this 
script relative to the extension dir.
	var $extKey = 'cdc_staff';	// The extension key.
	var $pi_checkCHash = TRUE;
	var $langArr;
	var $sys_language_mode;
	
	

	/**
	 * [Main]
	 */
	function main($content,$conf)	{
		switch((string)$conf['CMD'])	{
			case 'singleView':
				list($t) = explode(':',$this->cObj->currentRecord);
				$this->internal['currentTable']=$t;
				$this->internal['currentRow']=$this->cObj->data;
				return $this->pi_wrapInBaseClass($this->singleView($content,$conf));
			break;			
						default:
				if (strstr($this->cObj->currentRecord,'tt_content'))	{
					$conf['pidList'] = $this->cObj->data['pages'];
					$conf['recursive'] = $this->cObj->data['recursive'];
				}
				return $this->pi_wrapInBaseClass($this->listView($content,$conf));
			break;
		}
		
		
// Die im Backend definierten Sprachen laden und
// die Handhabung für Übersetzungen ermitteln.
$lres = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_language', 
'1=1' . $this->cObj->enableFields('sys_language'));
$this->langArr = array();
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($lres)) {
    $this->langArr[$row['uid']] = $row;
}
$this->sys_language_mode = 
$this->conf['sys_language_mode']?$this->conf['sys_language_mode']:$GLOBALS['TSFE']->sys_language_mode;
	
	
	
	}
	
	/**
	 * [Listenansicht]
	 */
	function listView($content,$conf)	{
		$this->conf=$conf;		// Setting the TypoScript passed to this function 
in $this->conf
		$this->pi_setPiVarDefaults();
		$this->pi_loadLL();		// Loading the LOCAL_LANG values
		
		
				
		$lConf = $this->conf['listView.'];	// Local settings for the listView 
function
	

	
		if ($this->piVars['showUid'])	{	// If a single element should be 
displayed:
			$this->internal['currentTable'] = 'tx_cdcstaff_cdc_staff';
			$this->internal['currentRow'] = 
$this->pi_getRecord('tx_cdcstaff_cdc_staff',$this->piVars['showUid']);
	
			$content = $this->singleView($content,$conf);
			return $content;
		} else {
			$items=array(
				'1'=> $this->pi_getLL('list_mode_1','Mode 1'),
				'2'=> $this->pi_getLL('list_mode_2','Mode 2'),
				'3'=> $this->pi_getLL('list_mode_3','Mode 3'),
			);
			if (!isset($this->piVars['pointer']))	$this->piVars['pointer']=0;
			if (!isset($this->piVars['mode']))	$this->piVars['mode']=1;
			
				// Initializing the query parameters:
			list($this->internal['orderBy'],$this->internal['descFlag']) = 
explode(':',$this->piVars['sort']);
		 
$this->internal['results_at_a_time']=t3lib_div::intInRange($lConf['results_at_a_time'],0,1000,25); 
	// Number of results to show in a listing.
		 
$this->internal['maxPages']=t3lib_div::intInRange($lConf['maxPages'],0,1000,2);; 
	// The maximum number of "pages" in the browse-box: "Page 1", "Page 2", 
etc.
		 
$this->internal['searchFieldList']='name,vorname,title,abteilung,position,telefon,fax,mail';
		 
$this->internal['orderByList']='uid,name,vorname,title,abteilung,position,telefon,fax,mail';
	
				// Get number of records:
			$res = $this->pi_exec_query('tx_cdcstaff_cdc_staff',1);
			list($this->internal['res_count']) = 
$GLOBALS['TYPO3_DB']->sql_fetch_row($res);
	
				// Make listing query, pass query to SQL database:
			$res = $this->pi_exec_query('tx_cdcstaff_cdc_staff');
			$this->internal['currentTable'] = 'tx_cdcstaff_cdc_staff';
	
				// Put the whole list together:
			$fullTable='';	// Clear var;
		#	$fullTable.=t3lib_div::view_array($this->piVars);	// DEBUG: Output 
the content of $this->piVars for debug purposes. REMEMBER to comment out 
the IP-lock in the debug() function in t3lib/config_default.php if 
nothing happens when you un-comment this line!
	
				// Adds the mode selector.
		#	$fullTable.=$this->pi_list_modeSelector($items);
	
				// Adds the whole list table
			$fullTable.=$this->makelist($res);
			

	
				// Adds the search box:
		#	$fullTable.=$this->pi_list_searchBox();
	
				// Adds the result browser:
		#	$fullTable.=$this->pi_list_browseresults();
	
				// Returns the content from the plugin.
			return $fullTable;
		}
		
// WHERE ABFRAGE		
if ($this->sys_language_mode == 'strict' && 
$GLOBALS['TSFE']->sys_language_content) {
    // mode == 'strict': If a certain language is requested, select only 
records from the default language which have a translation.
    $tmpres = $this->cObj->exec_getQuery('user_extension_table', 
array('selectFields' => 'user_extension_table.l18n_parent', 'where' => 
'user_extension_table.sys_language_uid = 
'.$GLOBALS['TSFE']->sys_language_content.$this->enableFields, 
'pidInList' => $this->conf['pidList']));
    $strictUids = array();
    while ($tmprow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($tmpres)) {
        $strictUids[] = $tmprow['l18n_parent'];
    }
    $strStrictUids = implode(',', $strictUids);
    $where .= ' AND (user_extension_table.uid IN (' . 
($strStrictUids?$strStrictUids:0) . ') OR 
user_extension_table.sys_language_uid=-1)';
} else {
    // mode != 'strict': If a certain language is requested, select only 
records in the default language. The translated articles (if they exist) 
will be overlayed later in the list or single function.
    $where .= ' AND user_extension_table.sys_language_uid IN (0,-1)';
} 	

	
	}
	/**
	 * Liste erstellen
	 */
	function makelist($res)	{
		$items=Array();
			// Make list table rows
		while($this->internal['currentRow'] = 
$GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))	{
			$items[]=$this->makeListItem();
		}
	
		$out = '<div'.$this->pi_classParam('listrow').'>
			'.implode(chr(10),$items).'
			</div>';
		return $out;



//TRANSLATE
		$this->internal["currentRow"] = 
$this->pi_getRecord("user_extension_tabelle",$uid);
// get the translated record if the content language is not the default 
language
if ($GLOBALS['TSFE']->sys_language_content) {
   $OLmode = ($this->sys_language_mode == 'strict'?'hideNonTranslated':'');
   $this->internal["currentRow"] = 
$GLOBALS['TSFE']->sys_page->getRecordOverlay('user_extension_tabelle', 
$this->internal["currentRow"], $GLOBALS['TSFE']->sys_language_content, 
$OLmode);
}


	}
	
	/**
	 *AUSGABE
	 */
	function makeListItem()	{
		
		$out='<p></p><table width="100%"  border="0" cellspacing="2" 
cellpadding="2">
   <tr>
     <td align="left" width="450">
				<p 
class="headline3">'.$this->getFieldContent('title').'&nbsp;'.$this->getFieldContent('vorname').'&nbsp;'.$this->getFieldContent('name').'</p></td>
				<td rowspan="6" align="left" 
valign="top"><p'.$this->pi_classParam('listrowField-bild').'>'.$this->getFieldContent('bild').'</p></td></tr>
				<tr>
     <td align="left">'.$this->getFieldContent('abteilung').'</td>
   </tr>
				<tr>
     <td align="left">'.$this->getFieldContent('position').'</td>
   </tr>
				<tr>
     <td align="left"><img align="absmiddle" 
src="typo3conf/ext/cdc_staff/phone.gif">'.$this->getFieldContent('telefon').'</td>
   </tr>
				<tr>
     <td align="left"><img align="absmiddle" 
src="typo3conf/ext/cdc_staff/fax.gif">'.$this->getFieldContent('fax').'</td>
   </tr>
				<tr>
     <td align="left"><img align="absmiddle" 
src="typo3conf/ext/cdc_staff/mail.gif"><a 
href="mailto:'.$this->getFieldContent('mail').'">'.$this->getFieldContent('mail').'</td>
   </tr>
			</table><p></p>
			';
		return $out;
	}

	/**
	 * [Put your description here]
	 */
	function getFieldContent($fN)	{
		switch($fN) {
			case 'uid':
				return 
$this->pi_list_linkSingle($this->internal['currentRow'][$fN],$this->internal['currentRow']['uid'],1); 
// The "1" means that the display of single items is CACHED! Set to zero 
to disable caching.
			break;

			case 'bild':
			$imgTSConfig = $this->conf['bildCObject.'];
			$imgTSConfig['file'] = 
'uploads/tx_cdcstaff/'.$this->internal["currentRow"][$fN];
			return $this->cObj->IMAGE($imgTSConfig);
			break;

			default:
				return $this->internal['currentRow'][$fN];
			break;
		}
	}
	/**
	 * [Put your description here]
	 */
	function getFieldHeader($fN)	{
		switch($fN) {
			case "title":
				return $this->pi_getLL('listFieldHeader_title','<em>title</em>');
			break;
			

			
			
			default:
				return $this->pi_getLL('listFieldHeader_'.$fN,'['.$fN.']');
			break;
		}
	}
	
	/**
	 * [Put your description here]
	 */
	function getFieldHeader_sortLink($fN)	{
		return 
$this->pi_linkTP_keepPIvars($this->getFieldHeader($fN),array('sort'=>$fN.':'.($this->internal['descFlag']?0:1)));
	}
}



if (defined('TYPO3_MODE') && 
$TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/cdc_staff/pi1/class.tx_cdcstaff_pi1.php']) 
{
	include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/cdc_staff/pi1/class.tx_cdcstaff_pi1.php']);
}

?>



More information about the TYPO3-german mailing list