Ich verwende unter Typo3 4 die Extension thpdfarchive 0.6.3.
Dabei möchte ich den Bereich auch in der Listendarstellung anzeigen lassen, das bekomme ich aber nicht zustande.
Ich habe dazu class.tx_thpdfarchive_pi1.php modifiziert und das Feld division (für den Bereich) an diversen Stellen eingefügt, aber da wird nichts dargestellt.
<?php
/***************************************************************
* Copyright notice
*
* (c) 2005 Unilog-Avinci - a logicaCMG company GmbH (thomas.hartmann@logicacmg.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.
*
* 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!
***************************************************************/
/**
* Plugin 'Press archive' for the 'thpdfarchive' extension.
*
* Thanks to Steffen Ritter for his change proposals and code commitment
* Displaying downloadlists of chronological classified publications for example PDF or WORD documents,
* that are indexed and searchable by the t3 indexed search engine.
* The indexed search could be restricted to certain pages.
*
* "I'm sure that some xclass changes here are not a really smart way to solve our problem ...
* but without a proper documentation or proper comments inside the origial extension it's
* to much effort to do it smarter" - Thomas
*
* @author Thomas Hartmann <thomas.hartmann@logicacmg.com>
* @co-author Felix Krüger <felix.krueger@logicacmg.com>
*/
require_once(PATH_tslib.'class.tslib_pibase.php');
class tx_thpdfarchive_pi1 extends tslib_pibase {
var $prefixId = 'tx_thpdfarchive_pi1'; // Same as class name
var $scriptRelPath = 'pi1/class.tx_thpdfarchive_pi1.php'; // Path to this script relative to the extension dir.
var $extKey = 'thpdfarchive'; // The extension key.
var $pi_checkCHash = TRUE;
var $divisionCache = array();
var $templateCode;
var $globSorting;
var $lConf; //Flexforms config
/**
* Main function
*
* @return string Returns the complete page
*/
function main($content,$conf) {
//Getting the Flexformsvalues and processing the content into $lconf
$this->pi_initPIflexform();
$piFlexForm = $this->cObj->data['pi_flexform'];
// Traverse the entire array based on the language...
// and assign each configuration option to $this->lConf array...
foreach ( $piFlexForm['data'] as $sheet => $data )
foreach ( $data as $lang => $value )
foreach ( $value as $key => $val )
$this->lConf[$key] = $this->pi_getFFvalue($piFlexForm, $key, $sheet);
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->lConf['pages'];
$conf['code'] = $this->lConf['category'];
}
return $this->pi_wrapInBaseClass($this->listView($content,$conf));
break;
}
return $this->pi_wrapInBaseClass($content);
}
/**
* List methode -> Shows an overview of all recordsets limited by cobj->code entry
*
* @param array
* @param array
* @return string The complete content table
*/
function listView($content,$conf) {
global $TYPO3_CONF_VARS;
$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_thpdfarchive_document';
$this->internal['currentRow'] = $this->pi_getRecord('tx_thpdfarchive_document',$this->piVars['showUid']);
$content = $this->singleView($content,$conf);
return $content;
} else {
if (!isset($this->piVars['pointer'])) $this->piVars['pointer']=0;
if (!isset($this->piVars['mode'])) $this->piVars['mode']=0;
// EDIT by Steffen Ritter
// ShowAll Param of Flexform: if ShowAll is set, sYear will be left --> all files will be shown
// if ShowAll is not set sYear will be set to current year...
if (!isset($this->piVars['sYear']) && ($this->lConf['showAll'] == 0)) $this->piVars['sYear'] = date('Y',time());
$sorting = $this->piVars['sorting'] == '' ? 'DESC' : $this->piVars['sorting'];
$this->piVars['row'] = $this->piVars['row'] == '' ? 'date' : $this->piVars['row'];
// 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,20); // 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,teaser,date';
$this->internal['orderByList']='date';
// Get number of records:
$res = (isset($this->conf['code']) && $this->piVars['sYear'] != 0) ? $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'count(*)',
'tx_thpdfarchive_document,tx_thpdfarchive_division',
$this->sqlWhere($this->conf['code'],$this->piVars['sYear'])
) : $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)','tx_thpdfarchive_document,tx_thpdfarchive_division',$this->sqlWhere($this->conf['code'],''));
list($this->internal['res_count']) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
$res = (isset($this->conf['code']) ) ? $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'*','tx_thpdfarchive_document,tx_thpdfarchive_division',
$this->sqlWhere($this->conf['code'],$this->piVars['sYear']),'',$this->piVars['row'].' '.$sorting
) : $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'*','tx_thpdfarchive_document,tx_thpdfarchive_division',
'','',$this->piVars['row'].' '.$sorting
);
$this->internal['currentTable'] = 'tx_thpdfarchive_document';
// Put the whole list together:
$fullTable=''; // Clear var;
$id = $GLOBALS['TSFE']->id;
$link = $this->pi_getPageLink($id);
// Timerestrictions - filtering the records by year
$stopYear = intval($this->lConf['startYear']) == 0 ? date('Y',time()) : $this->lConf['startYear'];
$currentYear = date('Y',time());
$targetParams = array('id' => $uid, 'sYear' => 0,'sorting' => $this->globSorting);
$fullTable .= $this->pi_linkTP_keepPIvars($this->pi_getLL('pi_all_divisions','all divisions'),
$targetParams,1,1);
$fullTable .= ' ';
for ($i = intval($currentYear); $i >= intval($stopYear); $i--) {
$targetParams = array('id' => $uid, 'sYear' => $i,'sorting' => $this->globSorting);
$fullTable .= $this->pi_linkTP_keepPIvars(
strval($i),
$targetParams,1,1);
$fullTable .= ' ';
}
/* ohne Startleiste */
$fullTable ='<br />';
$fullTable .= '<div class="separator"></div>';
// Adds the mode selector.
$fullTable.=$this->pi_list_modeSelector();
// Adds the whole list table
$fullTable.=$this->pi_list_makelist($res,'width="100%" border="0" cellspacing="0" cellpadding="0"');
// Adds the search box:
if($this->lConf['searchbox']>0) $fullTable .= '<p>'.$this->searchField().'</p>';
// Adds the result browser:
$this->internal['showFirstLast'] = 1;
$this->internal['dontLinkActivePage'] = 1;
$this->internal['showRange'] = 1;
$fullTable .= $this->pi_list_browseresults(1);
// Returns the content from the plugin.
return $fullTable;
}
}
/**
* Creating arguments for the sql WHERE statements
*
* @param string Resctrict the results by division
* @param string Restrict the results by year
* @return string Arguments for a WHERE statement or an empty string
*/
function sqlWhere($sBereich,$sYear){
$retValue = ' tx_thpdfarchive_division.uid = tx_thpdfarchive_document.division';
// lets do it for the division - rock'n'roll
if (intval($sBereich) == 0 || $sBereich == ''){
$retValue .= '';
} else {
$retValue .= ' AND tx_thpdfarchive_document.division = '.intval($sBereich).' ';
}
// lets do it for the year - rock'n'roll
if (intval($sYear) == 0 || $sYear == ''){
$retValue .= '';
} else {
$startValue = mktime(0,0,0,1,1,intval($sYear));
$stopValue = mktime(0,0,0,1,1,intval($sYear)+1);
$retValue .= ' AND tx_thpdfarchive_document.date >= '. $startValue .' AND tx_thpdfarchive_document.date < '.$stopValue;
}
return $retValue;
}
/**
* Returns the list of items based on the input SQL result pointer
* For each result row the internal var, $this->internal['currentRow'], is set with the row returned.
* $this->pi_list_header() makes the header row for the list
* $this->pi_list_row() is used for rendering each row
* Notice that these two functions are typically ALWAYS defined in the extension class of the plugin since they are directly concerned with the specific layout for that plugins purpose.
*
* @param pointer Result pointer to a SQL result which can be traversed.
* @param string Attributes for the table tag which is wrapped around the table rows containing the list
* @return string Output HTML, wrapped in <div>-tags with a class attribute
* @see pi_list_row(), pi_list_header()
*/
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;
echo mysql_error();
while($this->internal['currentRow'] = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$tRows[] = $this->pi_list_row($c);
$c++;
}
echo mysql_error();
$out = '
<!--
Record list:
-->
<div'.$this->pi_classParam('listrow').'>
<'.trim('table '.$tableParams).'>
'.implode('',$tRows).'
</table>
</div>';
return $out;
}
/**
* Rendering the searchfield template and returning content for a searchbox
*
* @return string HTML Code for a searchbox
*/
function searchField(){
$this->templateCode = $this->cObj->fileResource($this->conf["templateFile"]);
//echo $this->templateCode;
$template = $this->cObj->getSubpart($this->templateCode, $templateMarker);
$templateMarker = "###TEMPLATE###";
$template = array();
$template = $this->cObj->getSubpart($this->templateCode, $templateMarker);
// create the content by replacing the marker in the template
$markerArray = array();
$markerArray["###HEADLINE###"] = $this->pi_getLL('headline');
$markerArray["###ADVANCED###"] = '<a href="'.$this-">pi_getPageLink($this->conf['pidSearchpage'],"_self",array("tx_indexedsearch[ext]" => 1, "L" => $GLOBALS["TSFE"]->sys_language_uid)).'">'.$this->pi_getLL('advanced').'</a>';
$markerArray["###RETRICTPID###"] = $GLOBALS['TSFE']->id;
$markerArray["###SUBMIT###"] = $this->pi_getLL('submit');
$markerArray["###ACTLANG###"] = $GLOBALS["TSFE"]->sys_language_uid;
$markerArray["###SEARCHPID###"] = $this->pi_getPageLink($this->conf['pidSearchpage'],"_self",array("L" => $GLOBALS["TSFE"]->sys_language_uid));
// buid content from template + array
return $this->cObj->substituteMarkerArrayCached($template, array(), $markerArray , array());
}
/**
* Indexes the targetfile before opening
*
* @param array
* @param array
* @return string The complete content table
*/
function singleView($content,$conf) {
$this->conf=$conf;
$this->pi_setPiVarDefaults();
$this->pi_loadLL();
//print_r($this->internal['currentRow']);
// This sets the title of the page for use in indexed search results:
if ($this->internal['currentRow']['title']) $GLOBALS['TSFE']->indexedDocTitle=$this->internal['currentRow']['title'];
$content='<div'.$this->pi_classParam('singleView').'>';
//Link to File
$content .= '<div style="\'background:#d9d9d9;" margin-top:10px="" padding:5px="">';
$content .= '<b>'.$this->pi_getLL('singleViewFile','File').'</b></b>:<br /> <br />';
$link = $this->cObj->getTypoLink($this->internal['currentRow']['title'], $this->getFieldContent('uploadquery').$this->internal['currentRow']['upload'],'','_blank');
$content .= $link;
$content .= '</div>';
//Description of the single PDF
$content .= '<div style="\'background-color:#C4C4C6;" margin-top:10px="" padding:5px="">';
$content .='<b>'.$this->pi_getLL('singleViewDesc','Description').'</b>:<br />';
$content .= $this->internal['currentRow']['teaser'];
$content .= '</div>';
$content .= '<p>'.$this->pi_list_linkSingle($this->pi_getLL('back','Back'),0).'</p></div>'.
$this->pi_getEditPanel();
return $content;
}
function doSearch(){
}
/**
* Creating a single result row
*
* @return string Returns a result row
*/
function pi_list_row($c) {
$editPanel = $this->pi_getEditPanel();
if ($editPanel) $editPanel='<td>'.$editPanel.'</td>';
return '<tr'.($c%2 classmore_articles1="" :="" classmore_articles2="">
<td valign="top"><p>'.$this->getFieldContent('title').' </p></td>
<td valign="top"><p>'.$this->getFieldContent('division').'</p></td>
<td valign="top"><p>'.$this->getFieldContent('date').'</p></td>
</tr>';
}
/**
* Creating the header for the result table
*
* @return string Retuns HTML Code for a table header
*/
function pi_list_header() {
// Default values for fe view
$front .= '<td nowrap=""><p><b>';
$back .= '</b></p></td>';
$content = '<tr'.$this->pi_classParam('listrow-header').'>';
//get sorting
$sorting = $this->piVars['sorting'] == 'DESC' ? 'ASC' : 'DESC';
/*
$paramsDivision = array('id' => $this->getCurrentPageID(), 'row' => 'uid','sorting' => $sorting);
$content .= $front.$this->pi_linkTP_keepPIvars($this->getFieldHeader('uid'),$paramsDivision,1,1).$back;
*/
$paramsDivision = array('id' => $this->getCurrentPageID(), 'row' => 'title','sorting' => $sorting);
$content .= $front.$this->pi_linkTP_keepPIvars($this->getFieldHeader('title'),$paramsDivision,1,1).$back;
$paramsDivision = array('id' => $this->getCurrentPageID(), 'row' => 'division','sorting' => $sorting);
$content .= $front.$this->pi_linkTP_keepPIvars($this->getFieldHeader('division'),$paramsDivision,1,1).$back;
$paramsDivision = array('id' => $this->getCurrentPageID(), 'row' => 'date','sorting' => $sorting);
$content .= $front.$this->pi_linkTP_keepPIvars($this->getFieldHeader('date'),$paramsDivision,1,1).$back;
$content .= '</tr>';
return $content;
}
/**
* Returns the name of the currentpage plus additional strings
*
* @param string Page ID
*/
function getCurrentPageID(){
return $GLOBALS['TSFE']->id;
}
/**
* Returns the content for each content column
*
* @param string Column name
* @return string Column content
*/
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 "date":
// For a numbers-only date, use something like: %d-%m-%y
$returnValue = '';
if($this->internal['currentRow']['date'] > 0)
$returnValue = strftime('%d.%m.%y',$this->internal['currentRow']['date']);
return $returnValue;
break;
case "title":
if (intval($this->lConf['showDescriptionPage']) > 0) {
return $this->pi_list_linkSingle($this->internal['currentRow']['title'],$this->internal['currentRow']['uid'],1);
} else {
return $this->cObj->getTypoLink($this->internal['currentRow']['title'], $this->internal['currentRow']['uploadfolder'].$this->internal['currentRow']['upload'],'','_blank');
}
break;
case "division_id":
$this->internal['currentRow']['division'];
break;
case "division":
if (!count($this->divisionCache)) {
$res= $this->pi_exec_query("tx_thpdfarchive_division");
$query='SELECT * FROM tx_thpdfarchive_division WHERE pid='.intval($GLOBALS["TSFE"]->id).$this->cObj->enableFields('tx_thpdfarchive_division');
while ($row= $GLOBALS['TYPO3_DB']->sql_fetch_assoc ($res)) {
$this->divisionCache[$row['uid']]=$row;
}
return htmlspecialchars($this->divisionCache[$this->internal["currentRow"]['division']]['division']);
}
break;
case "uploadquery":
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'*',
'tx_thpdfarchive_division',
' uid = '.$this->internal['currentRow']['division']);
$result = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
return $result['uploadfolder'];
break;
case "uploadfolder":
return $this->internal['currentRow']['uploadfolder'];
break;
default:
return $this->internal['currentRow'][$fN];
break;
}
}
/**
* Returns content for field header
*
* @param string header title
* @return string header content
*/
function getFieldHeader($fN) {
switch($fN) {
case "title":
return $this->pi_getLL('listFieldHeader_title','<em>title</em>');
break;
case "division":
return $this->pi_getLL('listFieldHeader_division','<em>division</em>');
break;
case "date":
return $this->pi_getLL('listFieldHeader_date','<em>date</em>');
break;
default:
return $this->pi_getLL('listFieldHeader_'.$fN,''.$fN.'');
break;
}
}
/**
* Don't needed
*/
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/thpdfarchive/pi1/class.tx_thpdfarchive_pi1.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/thpdfarchive/pi1/class.tx_thpdfarchive_pi1.php']);
}
?>
Wer kann mir da helfen?