All pastes #99840 Raw Edit

Untitled

public text v1 · immutable
#99840 ·published 2006-07-25 18:30 UTC
rendered paste body
<?php
/***************************************************************
*  Copyright notice
*
*  (c) 2006 Michael Gebhart <m.gebhart@netprojects.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!
***************************************************************/
/**
 * Plugin 'Partner-Modul' for the 'partner' extension.
 *
 * @author	Christoph Stubhann <christoph.stubhann@gmx.at>
 */


require_once(PATH_tslib.'class.tslib_pibase.php');

class tx_partner_pi1 extends tslib_pibase {
	# T3 settings
	var $prefixId = 'tx_partner_pi1';		// Same as class name
	var $scriptRelPath = 'pi1/class.tx_partner_pi1.php';	// Path to this script relative to the extension dir.
	var $extKey = 'partner';	// The extension key.
	var $pi_checkCHash = TRUE;
	
	# custom plugin settings
	var $page = array(
		'entries' => 25,
		'number'  => 1,
	);
	
	/**
	 * 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();
		
		$GLOBALS["TSFE"]->set_no_cache(); 
		
		# turn on output buffer
		ob_start();
		
		# getting the branche details
		$branches = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tx_partnerbranche_daten', 'pid = 23');
		$b_count = $GLOBALS['TYPO3_DB']->sql_num_rows($branches);
		
		# creating the branche select box
		print <<<HTM
			<h3>Partner</h3>
			<p>Branche ausw&auml;hlen:</p>
			<form action="select.htm">
			<select name="branchen" size="1">
		HTM;
		
		# creating all the select fields
		while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($branches)) {
			print <<<HTM
				<option value="$row['uid']">$row['branche']</option>
			HTM;
		}
		
		# closing the select field html code
		print <<<HTM
			</select>
			</form>
			<table>
		HTM;
		
		# calculcating the page navigation
		$page = (is_numeric($_GET['page']) && $_GET['page'] > 0) ? $_GET['page'] : $this->page['number'];
		$_start = ($page == 1) ? 1 : (($page - 1) * $this->page['entries']) + 1;
		$_end = ($page == 1) ? $this->page['entries'] : $page * $this->page['entries'];
		
		# getting the partner details
		$partners = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tx_partner_daten', 'pid = 23 LIMIT '.$start.', '.$end);
		$p_count = $GLOBALS['TYPO3_DB']->sql_num_rows($partners);
		
		# creating the table rows
		while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($partners)) {
			$LD = $GLOBALS['TSFE']->tmpl->linkData($GLOBALS['TSFE']->page,'', '', '', '', '&partner='.$row['uid']);
			
			print <<<HTM
				<tr>
				<td>(Logo)</td>
				<td>$row['partnername']</td>
				<td><a target="_parent" href="$LD['totalURL']">Detailinfo</a></td>
				</tr>
			HTM;
		}
		
		# closing the table html code
		print <<<HTM
			</table>
		HTM;
		
		# display the page navigation
		$page_count = ceil($partner_count / $this->page['entries']);
		
		if($page_count > 1) {
			print <<<HTM
				<table>
				<tr>
			HTM;
			
			for ($i = 0; $i < $page_count; $i++) {
				$page = $i++;
				$LD = $GLOBALS['TSFE']->tmpl->linkData($GLOBALS['TSFE']->page,'', '', '', '', '&page='.$i);
				
				print <<<HTM
					<td><a target="_parent" href="$LD['totalURL']">Seite $page</a></td>
				HTM;
			}
			
			print <<<HTM
				</tr>
				</table>
			HTM;
		}
		
		
			
/*			<form action="'.$this->pi_getPageLink($GLOBALS['TSFE']->id).'" method="POST">
				<input type="hidden" name="no_cache" value="1">
				<input type="text" name="'.$this->prefixId.'[input_field]" value="'.htmlspecialchars($this->piVars['input_field']).'">
				<input type="submit" name="'.$this->prefixId.'[submit_button]" value="'.htmlspecialchars($this->pi_getLL('submit_button_label')).'">
			</form>
			<br />
			<p>You can click here to '.$this->pi_linkToPage('get to this page again',$GLOBALS['TSFE']->id).'</p>
*/
		
		$content .= ob_get_clean();
		return $this->pi_wrapInBaseClass($content);
	}
		
	
}



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

?>