PHP-Code:
<?php
/***************************************************************
* Copyright notice
*
* (c) 2008 matin <office@matin.at>
* 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!
***************************************************************/
require_once(PATH_tslib.'class.tslib_pibase.php');
/**
* Plugin 'TP Plugin' for the 'tp_test' extension.
*
* @author matin <office@matin.at>
* @package TYPO3
* @subpackage tx_tptest
*/
class tx_tptest_pi1 extends tslib_pibase {
var $prefixId = 'tx_tptest_pi1'; // Same as class name
var $scriptRelPath = 'pi1/class.tx_tptest_pi1.php'; // Path to this script relative to the extension dir.
var $extKey = 'tp_test'; // The extension key.
var $pi_checkCHash = true;
var $template;
var $id;
/**
* The main method of the PlugIn
*
* @param string $content: The PlugIn content
* @param array $conf: The PlugIn configuration
* @return The content that is displayed on the website
*/
function main($content,$conf) {
$this->conf=$conf;
$this->pi_setPiVarDefaults();
$this->pi_loadLL();
#ein paar Vorbelegungen
$this->id=$GLOBALS['TSFE']->id;
$this->template=$this->cObj->fileResource('EXT:tp_test/template.html');
#welche Ansicht?
if($this->piVars['item']) {
$content = $this->detailView();
} else {
$content = $this->listView();
}
return $this->pi_wrapInBaseClass($content);
}
function listView() {
#unser Subpart
$subpart=$this->cObj->getSubpart($this->template,'###LISTVIEW###');
#eine einzelne Reihe
$singlerow=$this->cObj->getSubpart($subpart,'###ROW###');
#Datensätze holen
$res=$GLOBALS['TYPO3_DB']->exec_SELECTquery(
'*', #select
'tx_tptest', #from
'hidden=0 and deleted=0 and pid='.$this->id, #where
$groupBy='',
$orderBy='',
$limit='');
if($res) {
$liste='';
while($row=$GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$markerArray['###LINK###']=$this->pi_linkTP($row['title'],array($this->prefixId.'[item]'=> $row['uid']));
$markerArray['###LINKTEXT###']=$this->pi_linkTP($this->pi_getLL('weiterlesen'),array($this->prefixId.'[item]'=> $row['uid']));
$markerArray['###TEXT###']=$this->pi_RTEcssText($row['text']);
$config = array();
$config['file'] = 'uploads/tx_tptest/'.$row['image'];
$config['file.']['maxW'] = '140';
$config['altText'] = $row['title'];
$config['titleText'] = $row['title'];
$img = $this->cObj->IMAGE($config);
$markerArray['###IMAGE###']=$img;
//Image als Link zu Detailseite:
$config1 = array();
$config1['file'] = 'uploads/tx_tptest/'.$row['image'];
$config1['file.']['maxW'] = '40';
$img1 = $this->cObj->IMAGE($config1);
$markerArray['###LINKIMAGE###']=$this->pi_linkTP($img1,array($this->prefixId.'[item]'=> $row['uid']));
if (!isset($this->piVars['pointer'])) $this->piVars['pointer']=0;
if (!isset($this->piVars['mode'])) $this->piVars['mode']=1;
// Initializing the query parameters:
$this->internal['currentTable'] = 'tx_tptest';
//ur: list ($this->internal['orderBy'], $this->internal['descFlag']) = explode(':', $this->piVars['sort']);
$this->internal['descFlag'] = '0';
$this->internal['orderBy'] = 'title';
$this->internal['results_at_a_time'] = t3lib_div :: intInRange($lConf['results_at_a_time'], 0, 1000, 3); // 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'] = 'title';
$this->internal['orderByList'] = 'title';
// Get number of records:
$res = $this->pi_exec_query('tx_tptest', 1, $addWhere);
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_tptest', 0, $addWhere);
$this->internal['currentTable'] = 'tx_tptest';
// 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 search box:
$fullTable .= $this->pi_list_searchBox();
// Adds the whole list table
$fullTable .= $this->pi_list_makelist($res);
//ur t3lib_div :: debug($fullTable, 'fullTable');
$fullTable .= $this->pi_list_browseresults();
$liste .= $this->cObj->substituteMarkerArrayCached($singlerow,$markerArray);
}
$subpartArray['###ROW###']=$liste;
$markerArray['###BROWSERESULTS###']=$this->pi_list_browseresults();
} else {
return $this->pi_getLL('nodata');
}
return $this->cObj->substituteMarkerArrayCached($subpart,$markerArray,$subpartArray,array());
}
function detailView() {
#unser Subpart
$subpart=$this->cObj->getSubpart($this->template,'###DETAILVIEW###');
#Datensatz holen
$record=$this->pi_getRecord('tx_tptest',$this->piVars['item']);
#Marker füllen
$markerArray['###TITLE###']=$record['title'];
$markerArray['###DATUM###']=date('d.m.Y',$record['date']);
$markerArray['###TEXT###']=$this->pi_RTEcssText($record['text']);
#Bild verkleinern
$config = array();
$config['file'] = 'uploads/tx_tptest/'.$record['image'];
$config['file.']['maxW'] = '140';
// check if lightbox ext. is installed and init
if (t3lib_extMgm::isLoaded('kj_imagelightbox2'))
{
$config['imageLightbox2'] = 1;
$config['imageLightbox2.']['caption'] = htmlentities($record['title']);
}
$img = $this->cObj->IMAGE($config);
$markerArray['###IMAGE###']=$img;
$markerArray['###GROSS###']=$this->pi_RTEcssText($record['grossestextfeld']);
$markerArray['###LINK###']=$this->cObj->typolink($record['link'],array(
'parameter' => $record['link'],
'extTarget' => '_blank',
));
#backlink als einfachen Link ohne Parameter
$markerArray['###BACKLINK###']=$this->pi_linkToPage($this->pi_getLL('back'),$this->id);
return $this->cObj->substituteMarkerArrayCached($subpart,$markerArray,array(),array());
}
}
?>