Wenns der Editor nicht hergibt, hier ist meine Version die mit 3.6.0-RC1 funktioniert. Eine Ausnahmen hab ich gefunden. Wenn man mit dieser class.tslib_pibase.php die phpot Extension benutzen will bekommt man die Fehlermeldung das der Header nicht gesendet werden kann... Eventl. hat da jemand noch eine Lösung für.
<?php
/***************************************************************
* Copyright notice
*
* (c) 1999-2003 Kasper Skaarhoj (kasper@typo3.com)
* 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.
* A copy is found in the textfile GPL.txt and important notices to the license
* from the author is found in LICENSE.txt distributed with these scripts.
*
*
* 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!
***************************************************************/
class tslib_pibase {
// Reserved variables:
var $cObj; // The backReference to the mother cObj object set at call time
var $prefixId; // Should be same as classname of the plugin, used for CSS classes, variables
var $scriptRelPath; // Path to the plugin class script relative to extension directory, eg. 'pi1/class.tx_newfaq_pi1.php'
var $extKey; // Extension key.
var $piVars = Array ( // This is the incomming array by name $this->prefixId merged between POST and GET, POST taking precedence. Eg. if the class name is 'tx_myext' then the content of this array will be whatever comes into &tx_myext[...]=...
'pointer' => '', // Used as a pointer for lists
'mode' => '', // List mode
'sword' => '', // Search word
'sort' => '', // [Sorting column]:[ASC=0/DESC=1]
);
var $internal = Array( // Used internally for general storage of values between methods
'res_count' => 0, // Total query count
'results_at_a_time' => 20, // pi_list_browseresults(): Show number of results at a time
'maxPages' => 10, // pi_list_browseresults(): Max number of 'Page 1 - Page 2 - ...' in the list browser
'currentRow' => Array(), // Current result row
'currentTable' => '', // Current table
);
var $LOCAL_LANG = Array(); // Local Language content
var $LOCAL_LANG_loaded = 0; // Flag that tells if the locallang file has been fetch (or tried to be fetched) already.
var $LLkey='default'; // Pointer to the language to use.
var $LLtestPrefix=''; // You can set this during development to some value that makes it easy for you to spot all labels that ARe delivered by the getLL function.
var $LLtestPrefixAlt=''; // Save as LLtestPrefix, but additional prefix for the alternative value in getLL() function calls
var $pi_isOnlyFields = 'mode,pointer';
var $pi_alwaysPrev = 0;
var $pi_lowerThan = 5;
var $pi_moreParams='';
var $pi_listFields='*';
var $pi_autoCacheFields=array();
var $pi_autoCacheEn=0;
var $pi_USER_INT_obj = 0; // If set, then links are 1) not using cHash and 2) allowing pages to be cached.
var $conf = Array();
// internal, don't mess with...
var $pi_EPtemp_cObj;
var $pi_tmpPageId=0;
/***************************
*
* Init functions
*
**************************/
function tslib_pibase() {
if ($this->prefixId) {
$this->piVars = t3lib_div::GParrayMerged($this->prefixId);
}
if ($GLOBALS['TSFE']->config['config']['language']) {
$this->LLkey = $GLOBALS['TSFE']->config['config']['language'];
}
}
function pi_setPiVarDefaults() {
if (is_array($this->conf['_DEFAULT_PI_VARS.'])) {
$this->piVars = t3lib_div::array_merge_recursive_overrule($this->conf['_DEFAULT_PI_VARS.'],is_array($this->piVars)?$this->piVars:array());
}
}
/***************************
*
* Link functions
*
**************************/
function pi_getPageLink($id,$target='',$urlParameters=array()) {
return $this->cObj->getTypoLink_URL($id,$urlParameters,$target); // ?$target:$GLOBALS['TSFE']->sPre
}
function pi_linkToPage($str,$id,$target='',$urlParameters=array()) {
return $this->cObj->getTypoLink($str,$id,$urlParameters,$target); // ?$target:$GLOBALS['TSFE']->sPre
}
function pi_linkTP($str,$urlParameters=array(),$cache=0) {
$conf=array();
$conf['useCacheHash']=$this->pi_USER_INT_obj?0:$cache;
$conf['no_cache']=$this->pi_USER_INT_obj?0:!$cache;
$conf['parameter']=$this->pi_tmpPageId ? $this->pi_tmpPageId : $GLOBALS['TSFE']->id;
$conf['additionalParams']=$this->conf['parent.']['addParams'].t3lib_div::implodeArrayForUrl('',$urlParameters,'',1).$this->pi_moreParams;
return $this->cObj->typoLink($str, $conf);
}
function pi_linkTP_keepPIvars($str,$overrulePIvars=array(),$cache=0,$clearAnyway=0) {
if (is_array($this->piVars) && is_array($overrulePIvars) && !$clearAnyway) {
$piVars = $this->piVars;
unset($piVars['DATA']);
$overrulePIvars = t3lib_div::array_merge_recursive_overrule($piVars,$overrulePIvars);
if ($this->pi_autoCacheEn) {
$cache = $this->pi_autoCache($overrulePIvars);
}
}
$res = $this->pi_linkTP($str,Array($this->prefixId=>$overrulePIvars),$cache);
return $res;
}
function pi_linkTP_keepPIvars_url($overrulePIvars=array(),$cache=0,$clearAnyway=0) {
$this->pi_linkTP_keepPIvars('|',$overrulePIvars,$cache,$clearAnyway);
return $this->cObj->lastTypoLinkUrl;
}
function pi_list_linkSingle($str,$uid,$cache=FALSE,$mergeArr=array(),$urlOnly=FALSE) {
if ($this->prefixId) {
if ($cache) {
$overrulePIvars=$uid?array('showUid'=>$uid):Array();
$overrulePIvars=array_merge($overrulePIvars,$mergeArr);
$str = $this->pi_linkTP($str,Array($this->prefixId=>$overrulePIvars),$cache);
} else {
$overrulePIvars=array('showUid'=>$uid?$uid:'');
$overrulePIvars=array_merge($overrulePIvars,$mergeArr);
$str = $this->pi_linkTP_keepPIvars($str,$overrulePIvars,$cache);
}
// If urlOnly flag, return only URL as it has recently be generated.
if ($urlOnly) {
$str = $this->cObj->lastTypoLinkUrl;
}
}
return $str;
}
function pi_openAtagHrefInJSwindow($str,$winName='',$winParams='width=670,height=500,status=0,menubar=0,scrollbars=1,resizable=1') {
if (eregi('(.*)(<a[^>]*>)(.*)',$str,$match)) {
$aTagContent = t3lib_div::get_tag_attributes($match[2]);
$match[2]='<a href="#" onclick="'.
htmlspecialchars('vHWin=window.open(''.$aTagContent['href'].'',''.($winName?$winName:md5($aTagContent['href'])).'',''.$winParams.'');vHWin.focus();return false;').
'">';
$str=$match[1].$match[2].$match[3];
}
return $str;
}
/***************************
*
* Functions for listing, browsing, searching etc.
*
**************************/
function pi_list_browseresults($showResultCount=1,$tableParams='') {
// Initializing variables:
$pointer=$this->piVars['pointer'];
$count=$this->internal['res_count'];
$results_at_a_time = t3lib_div::intInRange($this->internal['results_at_a_time'],1,1000);
$maxPages = t3lib_div::intInRange($this->internal['maxPages'],1,100);
$max = t3lib_div::intInRange(ceil($count/$results_at_a_time),1,$maxPages);
$pointer=intval($pointer);
$links=array();
// Make browse-table/links:
if ($this->pi_alwaysPrev>=0) {
if ($pointer>0) {
$links[]='
<td nowrap="nowrap"><p>'.$this->pi_linkTP_keepPIvars($this->pi_getLL('pi_list_browseresults_prev','< Previous',TRUE),array('pointer'=>($pointer-1?$pointer-1:'')),0).'</p></td>';
} elseif ($this->pi_alwaysPrev) {
$links[]='
<td nowrap="nowrap"><p>'.$this->pi_getLL('pi_list_browseresults_prev','< Previous',TRUE).'</p></td>';
}
}
for($a=0;$a<$max;$a++) {
$links[]='
<td'.($pointer==$a?$this->pi_classParam('browsebox-SCell'):'').' nowrap="nowrap"><p>'.
$this->pi_linkTP_keepPIvars(trim($this->pi_getLL('pi_list_browseresults_page','Page',TRUE).' '.($a+1)),array('pointer'=>($a?$a:'')),$this->pi_isOnlyFields($this->pi_isOnlyFields)).
'</p></td>';
}
if ($pointer<ceil($count/$results_at_a_time)-1) {
$links[]='
<td nowrap="nowrap"><p>'.
$this->pi_linkTP_keepPIvars($this->pi_getLL('pi_list_browseresults_next','Next >',TRUE),array('pointer'=>$pointer+1)).
'</p></td>';
}
$pR1 = $pointer*$results_at_a_time+1;
$pR2 = $pointer*$results_at_a_time+$results_at_a_time;
$sTables = '
<!--
List browsing box:
-->
<div'.$this->pi_classParam('browsebox').'>'.
($showResultCount ? '
<p>'.sprintf(
str_replace('###SPAN_BEGIN###','<span'.$this->pi_classParam('browsebox-strong').'>',$this->pi_getLL('pi_list_browseresults_displays','Displaying results ###SPAN_BEGIN###%s to %s</span> out of ###SPAN_BEGIN###%s</span>')),
$pR1,
min(array($this->internal['res_count'],$pR2)),
$this->internal['res_count']
).'</p>':''
).
'
<'.trim('table '.$tableParams).'>
<tr>
'.implode('',$links).'
</tr>
</table>
</div>';
return $sTables;
}
function pi_list_searchBox($tableParams='') {
// Search box design:
$sTables = '
<!--
List search box:
-->
<div'.$this->pi_classParam('searchbox').'>
<form action="'.htmlspecialchars(t3lib_div::getIndpEnv('REQUEST_URI')).'" method="post" style="margin: 0 0 0 0;">
<'.trim('table '.$tableParams).'>
<tr>
<td><input type="text" name="'.$this->prefixId.'[sword]" value="'.htmlspecialchars($this->piVars['sword']).'"'.$this->pi_classParam('searchbox-sword').' /></td>
<td><input type="submit" value="'.$this->pi_getLL('pi_list_searchBox_search','Search',TRUE).'"'.$this->pi_classParam('searchbox-button').' /><input type="hidden" name="no_cache" value="1" /></td>
</tr>
</table>
</form>
</div>';
return $sTables;
}
function pi_list_modeSelector($items=array(),$tableParams='') {
$cells=array();
reset($items);
while(list($k,$v)=each($items)) {
$cells[]='
<td'.($this->piVars['mode']==$k?$this->pi_classParam('modeSelector-SCell'):'').'><p>'.
$this->pi_linkTP_keepPIvars(htmlspecialchars($v),array('mode'=>$k),$this->pi_isOnlyFields($this->pi_isOnlyFields)).
'</p></td>';
}
$sTables = '
<!--
Mode selector (menu for list):
-->
<div'.$this->pi_classParam('modeSelector').'>
<'.trim('table '.$tableParams).'>
<tr>
'.implode('',$cells).'
</tr>
</table>
</div>';
return $sTables;
}
function pi_list_makelist($res,$tableParams='') {
// Make list table header:
$tRows=array();
$this->internal['currentRow']='';
$tRows[]=$this->pi_list_header();
// Make list table rows
$c=0;
while($this->internal['currentRow'] = mysql_fetch_assoc($res)) {
$tRows[]=$this->pi_list_row($c);
$c++;
}
$out = '
<!--
Record list:
-->
<div'.$this->pi_classParam('listrow').'>
<'.trim('table '.$tableParams).'>
'.implode('',$tRows).'
</table>
</div>';
return $out;
}
function pi_list_row($c) {
// Dummy
return '<tr'.($c%2 ? $this->pi_classParam('listrow-odd') : '').'><td><p>[dummy row]</p></td></tr>';
}
function pi_list_header() {
return '<tr'.$this->pi_classParam('listrow-header').'><td><p>[dummy header row]</p></td></tr>';
}
/***************************
*
* Stylesheet, CSS
*
**************************/
function pi_getClassName($class) {
return str_replace('_','-',$this->prefixId).($this->prefixId?'-':'').$class;
}
function pi_classParam($class) {
return ' class="'.$this->pi_getClassName($class).'"';
}
function pi_setClassStyle($class,$data,$selector='') {
$GLOBALS['TSFE']->setCSS($this->pi_getClassName($class).($selector?' '.$selector:''),'.'.$this->pi_getClassName($class).($selector?' '.$selector:'').' {'.$data.'}');
}
function pi_wrapInBaseClass($str) {
return '
<!--
BEGIN: Content of extension "'.$this->extKey.'", plugin "'.$this->prefixId.'"
-->
<div class="'.str_replace('_','-',$this->prefixId).'">
'.$str.'
</div>
<!-- END: Content of extension "'.$this->extKey.'", plugin "'.$this->prefixId.'" -->
';
}
/***************************
*
* Frontend editing: Edit panel, edit icons
*
**************************/
function pi_getEditPanel($row='',$tablename='',$label='',$conf=Array()) {
$panel='';
if (!$row || !$tablename) {
$row = $this->internal['currentRow'];
$tablename = $this->internal['currentTable'];
}
if ($GLOBALS['TSFE']->beUserLogin) {
// Create local cObj if not set:
if (!is_object($this->pi_EPtemp_cObj)) {
$this->pi_EPtemp_cObj = t3lib_div::makeInstance('tslib_cObj');
$this->pi_EPtemp_cObj->setParent($this->cObj->data,$this->cObj->currentRecord);
}
// Initialize the cObj object with current row
$this->pi_EPtemp_cObj->start($row,$tablename);
// Setting TypoScript values in the $conf array. See documentation in TSref for the EDITPANEL cObject.
$conf['allow'] = 'edit,new,delete,move,hide';
$panel = $this->pi_EPtemp_cObj->cObjGetSingle('EDITPANEL',$conf,'editpanel');
}
if ($panel) {
if ($label) {
return '<!-- BEGIN: EDIT PANEL --><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td valign="top">'.$label.'</td><td valign="top" align="right">'.$panel.'</td></tr></table><!-- END: EDIT PANEL -->';
} else return '<!-- BEGIN: EDIT PANEL -->'.$panel.'<!-- END: EDIT PANEL -->';
} else return $label;
}
function pi_getEditIcon($content,$fields,$title='',$row='',$tablename='') {
if ($GLOBALS['TSFE']->beUserLogin){
if (!$row || !$tablename) {
$row = $this->internal['currentRow'];
$tablename = $this->internal['currentTable'];
}
$conf=array(
'beforeLastTag'=>1,
'iconTitle' => $title
);
$content=$this->cObj->editIcons($content,$tablename.':'.$fields,$conf,$tablename.':'.$row['uid'],$row,'&viewUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')));
}
return $content;
}
/***************************
*
* Localization, locallang functions
*
**************************/
function pi_getLL($key,$alt='',$hsc=FALSE) {
if (isset($this->LOCAL_LANG[$this->LLkey][$key])) {
$word = $this->LOCAL_LANG[$this->LLkey][$key];
} elseif (isset($this->LOCAL_LANG['default'][$key])) {
$word = $this->LOCAL_LANG['default'][$key];
} else {
$word = $this->LLtestPrefixAlt.$alt;
}
$output = $this->LLtestPrefix.$word;
if ($hsc) $output = htmlspecialchars($output);
return $output;
}
function pi_loadLL() {
if (!$this->LOCAL_LANG_loaded && $this->scriptRelPath) {
$basePath = t3lib_extMgm::siteRelPath($this->extKey).dirname($this->scriptRelPath).'/locallang.php';
if (@is_file($basePath)) {
include('./'.$basePath);
$this->LOCAL_LANG = $LOCAL_LANG;
if (is_array($this->conf['_LOCAL_LANG.'])) {
reset($this->conf['_LOCAL_LANG.']);
while(list($k,$lA)=each($this->conf['_LOCAL_LANG.'])) {
if (is_array($lA)) {
$k = substr($k,0,-1);
$this->LOCAL_LANG[$k] = t3lib_div::array_merge_recursive_overrule(is_array($this->LOCAL_LANG[$k])?$this->LOCAL_LANG[$k]:array(), $lA);
}
}
}
}
}
$this->LOCAL_LANG_loaded = 1;
}
/***************************
*
* Database, queries
*
**************************/
function pi_list_query($table,$count=0,$addWhere='',$mm_cat='',$groupBy='',$orderBy='',$query='') {
// Begin Query:
if (!$query) {
// Fetches the list of PIDs to select from.
// TypoScript property .pidList is a comma list of pids. If blank, current page id is used.
// TypoScript property .recursive is a int+ which determines how many levels down from the pids in the pid-list subpages should be included in the select.
$pidList = $this->pi_getPidList($this->conf['pidList'],$this->conf['recursive']);
if (is_array($mm_cat)) {
$query='FROM '.$table.','.$mm_cat['table'].','.$mm_cat['mmtable'].chr(10).
' WHERE '.$table.'.uid='.$mm_cat['mmtable'].'.uid_local AND '.$mm_cat['table'].'.uid='.$mm_cat['mmtable'].'.uid_foreign '.chr(10).
(strcmp($mm_cat['catUidList'],'')?' AND '.$mm_cat['table'].'.uid IN ('.$mm_cat['catUidList'].')':'').chr(10).
' AND '.$table.'.pid IN ('.$pidList.')'.chr(10).
$this->cObj->enableFields($table).chr(10); // This adds WHERE-clauses that ensures deleted, hidden, starttime/endtime/access records are NOT selected, if they should not! Almost ALWAYS add this to your queries!
} else {
$query='FROM '.$table.' WHERE pid IN ('.$pidList.')'.chr(10).
$this->cObj->enableFields($table).chr(10); // This adds WHERE-clauses that ensures deleted, hidden, starttime/endtime/access records are NOT selected, if they should not! Almost ALWAYS add this to your queries!
}
}
// Add '$addWhere'
if ($addWhere) {$query.=' '.$addWhere.chr(10);}
// Search word:
if ($this->piVars['sword'] && $this->internal['searchFieldList']) {
$query.=$this->cObj->searchWhere($this->piVars['sword'],$this->internal['searchFieldList'],$table).chr(10);
}
if ($count) {
$query = 'SELECT count(*) '.chr(10).$query;
} else {
if ($groupBy) $query.=' '.$groupBy;
// Order by data:
if ($orderBy) {
$query.=' '.$orderBy;
} else {
if (t3lib_div::inList($this->internal['orderByList'],$this->internal['orderBy'])) {
$query.= ' ORDER BY '.$table.'.'.$this->internal['orderBy'].($this->internal['descFlag']?' DESC':'').chr(10);
}
}
// Limit data:
$pointer=$this->piVars['pointer'];
$pointer=intval($pointer);
$results_at_a_time = t3lib_div::intInRange($this->internal['results_at_a_time'],1,1000);
$query.= ' LIMIT '.($pointer*$results_at_a_time).','.$results_at_a_time.chr(10);
// Add 'SELECT'
$query = 'SELECT '.$this->pi_prependFieldsWithTable($table,$this->pi_listFields).' '.chr(10).$query;
}
return $query;
}
function pi_getRecord($table,$uid,$checkPage=0) {
return $GLOBALS['TSFE']->sys_page->checkRecord($table,$uid,$checkPage);
}
function pi_getPidList($pid_list,$recursive=0) {
if (!strcmp($pid_list,'')) $pid_list = $GLOBALS['TSFE']->id;
$recursive = t3lib_div::intInRange($recursive,0);
$pid_list_arr = array_unique(t3lib_div::trimExplode(',',$pid_list,1));
$pid_list='';
reset($pid_list_arr);
while(list(,$val)=each($pid_list_arr)) {
$val = t3lib_div::intInRange($val,0);
if ($val) $pid_list.=$val.','.$this->cObj->getTreeList($val,$recursive);
}
return ereg_replace(',$','',$pid_list);
}
function pi_prependFieldsWithTable($table,$fieldList) {
$list=t3lib_div::trimExplode(',',$fieldList,1);
$return=array();
while(list(,$listItem)=each($list)) {
$return[]=$table.'.'.$listItem;
}
return implode(',',$return);
}
function pi_getCategoryTableContents($table,$pid,$addWhere='') {
$query = 'SELECT * FROM '.$table.' WHERE pid='.intval($pid).$this->cObj->enableFields($table).' '.$addWhere;
$outArr = array();
$res = mysql(TYPO3_db,$query);
while($row=mysql_fetch_assoc($res)) {
$outArr[$row['uid']]=$row;
}
return $outArr;
}
/***************************
*
* Various
*
**************************/
function pi_isOnlyFields($fList,$lowerThan=-1) {
$lowerThan = $lowerThan==-1 ? $this->pi_lowerThan : $lowerThan;
$fList = t3lib_div::trimExplode(',',$fList,1);
$tempPiVars = $this->piVars;
while(list(,$k)=each($fList)) {
if (!t3lib_div::testInt($tempPiVars[$k]) || $tempPiVars[$k]<$lowerThan) unset($tempPiVars[$k]);
}
if (!count($tempPiVars)) return 1;
}
function pi_autoCache($inArray) {
if (is_array($inArray)) {
reset($inArray);
while(list($fN,$fV)=each($inArray)) {
if (!strcmp($inArray[$fN],'')) {
unset($inArray[$fN]);
} elseif (is_array($this->pi_autoCacheFields[$fN])) {
if (is_array($this->pi_autoCacheFields[$fN]['range'])
&& intval($inArray[$fN])>=intval($this->pi_autoCacheFields[$fN]['range'][0])
&& intval($inArray[$fN])<=intval($this->pi_autoCacheFields[$fN]['range'][1])) {
unset($inArray[$fN]);
}
if (is_array($this->pi_autoCacheFields[$fN]['list'])
&& in_array($inArray[$fN],$this->pi_autoCacheFields[$fN]['list'])) {
unset($inArray[$fN]);
}
}
}
}
if (!count($inArray)) return 1;
}
function pi_RTEcssText($str) {
$parseFunc = $GLOBALS['TSFE']->tmpl->setup['lib.']['parseFunc_RTE.'];
if (is_array($parseFunc)) $str = $this->cObj->parseFunc($str, $parseFunc);
return $str;
}
/*******************************
*
* FlexForms related functions
*
*******************************/
function pi_initPIflexForm() {
// Converting flexform data into array:
if (!is_array($this->cObj->data['pi_flexform']) && $this->cObj->data['pi_flexform']) {
$this->cObj->data['pi_flexform'] = t3lib_div::xml2array($this->cObj->data['pi_flexform']);
if (!is_array($this->cObj->data['pi_flexform'])) $this->cObj->data['pi_flexform']=array();
}
}
function pi_getFFvalue($T3FlexForm_array,$fieldName,$sheet='sDEF',$lang='lDEF',$value='vDEF') {
$sheetArray = $T3FlexForm_array['data'][$sheet][$lang];
if (is_array($sheetArray)) {
return $this->pi_getFFvalueFromSheetArray($sheetArray,explode('/',$fieldName),$value);
}
}
function pi_getFFvalueFromSheetArray($sheetArray,$fieldNameArr,$value) {
$tempArr=$sheetArray;
foreach($fieldNameArr as $k => $v) {
if (t3lib_div::testInt($v)) {
if (is_array($tempArr)) {
$c=0;
foreach($tempArr as $values) {
if ($c==$v) {
debug($values);
$tempArr=$values;
break;
}
$c++;
}
}
} else {
$tempArr = $tempArr[$v];
}
}
return $tempArr[$value];
}
}
// NO extension of class - does not make sense here.
?>