---
title: "Mailformplus 4.0.5 Singelview"
url: "https://www.typo3.net/d/75100-mailformplus-405-singelview"
source: "typo3.net"
tags: ["Extensions","Frage"]
created: "2008-03-20"
last_reply: "2008-03-20"
replies: 2
solved: false
page: 1
pages: 1
lang: "de"
---

# Mailformplus 4.0.5 Singelview

Extensions · 2 Antworten · gestartet 2008-03-20

## Eröffnungsbeitrag

**alexliebe** · 2008-03-20 · [Beitrag #1](https://www.typo3.net/d/75100-mailformplus-405-singelview/1)

Hi Profs,

hab noch ein Problem mit mailformplus: die Singelweiv funkt nicht.

Typo3-Version: 4.1.6
mailformplus: 4.0.5

in der class.tx_thmailformplus_pi2.php findet man:

```php
/******************************************************************
 * Creating the single view of uid document
 *****************************************************************/
	function create_single($uid2Show='') {
		if (!$uid2Show) return;
		$single = '';
		$query = 'SELECT * FROM tx_thmailformplus_log WHERE uid='.strval($uid2Show);

		$this->res = $GLOBALS['TYPO3_DB']->sql(TYPO3_db, $query);
		if (mysql_error())    debug(array(mysql_error(),$query));

		$this->template_ref = $this->cObj->getSubpart($this->template, "###MFPSINGLEVIEW###");

		$single .= $this->subst_markers(-1);
  		$single = $this->cObj->substituteSubpart ($this->template, "###MFPSINGLEVIEW###", $single);

		return $single;
	}
```

Das liefert folgende URL: .../singelview.html?tx_thmailformplus_pi2%5BshowUid%5D=50

Dies liefert jedoch immer nur den letzten Datensatz und nicht den Datensatz (wie hier) mit der Uid=50

Vergleiche ich nun andere Extensions (ich bin kein Programmierer) finde ich Urls für Einzelansichten wie z.B.:

.../news_einzelansicht.html?tx_cwtpresscenter_pi1%5BshowUid%5D=37**&cHash=437bd899r5**

Suche ich nun mittels Phpmyadmin den Wert des Feldes "logdate" und ergänze die Url der Singelview von mailformplus manuel wie folgt:

.../singelview.html?tx_thmailformplus_pi2%5BshowUid%5D=50**&cHash=1205937487**

bekomme ich das richtige Ergebnis. Könnte das ein Bug sein? Ich bin leider nicht in der Lage die oben erwähnte Funktion umzuprogrammieren, da mir die Kenntnisse fehlen. Vielleicht kann mir jemand von Euch helfen.

Liebe Grüße,
Alex

PS: ich finde es schade, dass über diese Extension so wenig zu finden ist (google und so weiter..). Besonders über die Tiefen findet man so gut wie nichts. Ich halte diese Extension für eine der besten und bedanke mich an dieser Stelle bei den Authoren von Typoheads.

## Antworten

### [#2](https://www.typo3.net/d/75100-mailformplus-405-singelview/2) · alexliebe · 2008-03-20

ja mehr ich mich mit dem Script auseinander setze, desto eher scheint mir dieser Code dafür verantwortlich zu sein:

```php
			if ($singlePid > 0) 	
			$l2s = $this->pi_list_linkSingle($linkvar, $row[0], $cache=FALSE, $mergeArr=array(), $urlOnly=FALSE, $altPageId=$singlePid);
			$userMarkers["###LINK2SHOW###"] = $l2s;
```

Zur Sicherheit hier das ganze Script class.tx_thmailformplus_pi2.php

```php
<?php
/***************************************************************
*  Copyright notice
*
*  (c) 2007 Kurt Kunig <kurt.kunig@gmx.de>
*  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 'Mailformplus list' for the 'th_mailformplus' extension.
 *
 * @author	Kurt Kunig <kurt.kunig@gmx.de>
 * @package	TYPO3
 * @subpackage	tx_thmailformplus
 */
class tx_thmailformplus_pi2 extends tslib_pibase {
	var $prefixId      = 'tx_thmailformplus_pi2';		// Same as class name
	var $scriptRelPath = 'pi2/class.tx_thmailformplus_pi2.php';	// Path to this script relative to the extension dir.
	var $extKey        = 'th_mailformplus';	// The extension key.


	/**
	 * 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
	 */

// public Definitions of variables:
	var $template;
	var $template_ref;
	var $res;
	var $strListLink;
	var $sourcePagePID;
	var $TR_EVENODD = array('', '<tr class="tr-odd">', '<tr class="tr-even">');

	function main($content,$conf)	{
		

		$this->conf=$conf;
		$this->pi_setPiVarDefaults();
		$this->pi_loadLL();        
		$this->pi_USER_INT_obj=1;	// Configuring so caching is not expected. This value means that no cHash params are ever set. We do this, because it's a USER_INT object!
		$this->pi_initPIflexForm();

      	$this->strListLink = trim($conf["linkVars"]);
		$this->sourcePagePID = trim($conf["sourcePagePID"]);
		
		$this->langFile = '';
		if (isset($conf['langFile']) && $conf['langFile'] != '') {
			$this->langFile = $conf['langFile'];
		}

		$mailformplus_id = $this->cObj->data['pages'];
		
		# default: display the form from the page where the plugin is inserted
		if (!$mailformplus_id) $mailformplus_id = $this->cObj->data['pid'];
      
		# Initializing the query parameters:
		$query = "SELECT * FROM tx_thmailformplus_main WHERE pid IN (".$mailformplus_id.") LIMIT 0,1";
		$this->res = $GLOBALS['TYPO3_DB']->sql(TYPO3_db, $query);
		if (mysql_error())      debug(array(mysql_error(),$query));
		$this->internal["currentTable"] = "tx_thmailformplus_main";
		$this->internal["currentRow"] = mysql_fetch_array($this->res);
		
		
		$singlePid = intval($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'singlepid', 'sDEFAULT'));
		
		$showAs = intval($this->pi_getFFvalue($this->cObj->data['pi_flexform'], "contenttype", 'sDEFAULT'));
		$this->template = $this->cObj->fileResource($conf["template"]);
		parse_str($_SERVER['QUERY_STRING']);   

		if ($showAs == 0) {
		   $this->template = $this->cObj->getSubpart($this->template, "###MFP_LIST###");
		   $content .= $this->create_list($singlePid);
		} else {
		   $this->template = $this->cObj->getSubpart($this->template, "###MFP_SINGLE###");
		   $content = $this->create_single($tx_thmailformplus_pi2['showUid']);
		}
		$langMarkers = $this->substituteLangMarkers($content);
		$content = $this->cObj->substituteMarkerArray($content,$langMarkers);
	   return $this->pi_wrapInBaseClass($content);
	}
	
	/*function sanitizeValues($markerArray) {
		$allowedTags = $this->conf['allowedTags'];
		$sanitizedArray = array();
		if (function_exists('t3lib_div::removeXSS')) {
			foreach ($markerArray as $key => $value) {
				$value = strip_tags($value,$allowedTags);
				$sanitizedArray[$key] = t3lib_div::removeXSS($value);
			}
		} else {
			require_once(t3lib_extMgm::extPath('th_mailformplus')."RemoveXSS.php");
			foreach ($markerArray as $key => $value) {
				$value = strip_tags($value,$allowedTags);
				$sanitizedArray[$key] = RemoveXSS::RemoveXSS($value);
			}
		}
		return $sanitizedArray;
	}*/


/******************************************************************
 * Creating the single view of uid document
 *****************************************************************/
	function create_single($uid2Show='') {
		if (!$uid2Show) return;
		$single = '';
		$query = 'SELECT * FROM tx_thmailformplus_log WHERE uid='.strval($uid2Show);

		$this->res = $GLOBALS['TYPO3_DB']->sql(TYPO3_db, $query);
		if (mysql_error())    debug(array(mysql_error(),$query));

		$this->template_ref = $this->cObj->getSubpart($this->template, "###MFPSINGLEVIEW###");

		$single .= $this->subst_markers(-1);
  		$single = $this->cObj->substituteSubpart ($this->template, "###MFPSINGLEVIEW###", $single);

		return $single;
	}


/******************************************************************
 * Creating the list of all (resp. $maxRows) mailformplus-entries
 *****************************************************************/
	function create_list($singlePid) {

		$this->template_ref = $this->cObj->getSubpart($this->template, "###MFPLISTE###");

		$maxRows = intval($this->pi_getFFvalue($this->cObj->data['pi_flexform'], "maxrows", 'sDEFAULT'));
		if ($maxRows <= 0) $limits = '';
		else $limits = ' LIMIT 0,' . strval($maxRows) . ';';

		$where = '';
		if (intval($this->sourcePagePID > 0)) $where = " WHERE pid = $this->sourcePagePID ";
		
		$query = 'SELECT * FROM tx_thmailformplus_log' . $where . ' ORDER BY logdate DESC ' . $limits;

		$this->res = $GLOBALS['TYPO3_DB']->sql(TYPO3_db, $query);
		if (mysql_error())    debug(array(mysql_error(),$query));

		$list = '';
		$list .= $this->subst_markers($singlePid);
  		$list = $this->cObj->substituteSubpart ($this->template, "###MFPLISTE###", $list);
  		
		return $list;
	}

/**************************************************************
 * All existing and possible field markers are generated:
****************************************************************/
	function subst_markers($singlePid) {

	   $s = '';
		$marker = array();
		
      $linkvar = $this->strListLink;
      if ($linkvar == '') $linkvar = 'X';
         
		$switcher = 1;
		while ($row = mysql_fetch_row ($this->res)) {
		   $x = explode(chr(10), $row[2], 2);
		   $y = explode(';', $x[0]);
		   $z = str_replace (';','',$x[1]);             // in $x[1] the message content is in
		   $z = str_replace ('\\','',$z);
		   $z = str_replace (chr(13),'<br />',$z);      // replace CRLF with "<br />"
		   $z = explode('~', $z);

		   $i = 0;
		   foreach ($y as $value){
  				$mark = strtoupper('###VALUE_' . $value . '###');
  				if(strstr($this->template_ref,$mark)) {
  					$userMarkers[$mark] = $z[$i];
  				}
  				else {
  					$autoMarkers[$value] = $z[$i];
  				}
  				$i++;
			}
		  
			$sendingtime = date("d.m.y H:i", $row[3]);
			$userMarkers["###VALUE_DATE###"] = $sendingtime;
			

         
			if ($singlePid > 0) 	
			$l2s = $this->pi_list_linkSingle($linkvar, $row[0], $cache=FALSE, $mergeArr=array(), $urlOnly=FALSE, $altPageId=$singlePid);
			$userMarkers["###LINK2SHOW###"] = $l2s;
			
			$userMarkers["###GO_BACK###"] = '<a href="'.$_SERVER['HTTP_REFERER'].'">'.$this->pi_getLL('back', $alt='Hui', $hsc=FALSE).'</a>';
			#$userMarkers = $this->sanitizeValues($userMarkers);
			$s .= $this->cObj->substituteMarkerArrayCached ($this->template_ref, $userMarkers);
			if ($this->cObj->getSubpart($s,'###FIELD_REPEAT###')) {
				foreach($autoMarkers as $fieldname=>$value) {
					$repeatCode = $this->cObj->getSubpart($s,'###FIELD_REPEAT###');
					if (trim($GLOBALS['TSFE']->sL('LLL:'.$this->langFile.':'.$fieldname)) != '') {
						$markerArray['###title###'] = trim($GLOBALS['TSFE']->sL('LLL:'.$this->langFile.':'.$fieldname));
						$markerArray['###TITLE###'] = trim($GLOBALS['TSFE']->sL('LLL:'.$this->langFile.':'.$fieldname));
					} else {
						$markerArray['###title###'] = $fieldname;
						$markerArray['###TITLE###'] = $fieldname;
					}
					$markerArray['###value###'] = $value;
					
					$markerArray['###VALUE###'] = $value;
					#$markerArray = $this->sanitizeValues($markerArray);
					$subpart .= $this->cObj->substituteMarkerArray($repeatCode,$markerArray);
				}
				$s = $this->cObj->substituteSubpart ($s, '###FIELD_REPEAT###',$subpart);
			}
			
		}
		return $s;
	}
	
	/**
	 * finds markers (###LLL:[markername]###) in given template Code
	 * @param		string		$templCode		the template code in which the markers should be searched for
	 * @return		array						the found language markers with translation text
	 */
	function substituteLangMarkers($templCode) {
		global $LANG;
		$langMarkers = array();
		if ($this->langFile != '') {
			$aLLMarkerList = array();
			preg_match_all('/###LLL:.+?###/Ssm', $templCode, $aLLMarkerList);

			if (debug == 1) {
				print "Found language markers: <br>";
				print_r($aLLMarkerList);
			}
			
			foreach($aLLMarkerList[0] as $LLMarker){
				$llKey =  strtolower(substr($LLMarker,7,strlen($LLMarker)-10));
				$langMarkers['###LLL:'.$llKey.'###'] = trim($GLOBALS['TSFE']->sL('LLL:'.$this->langFile.':'.$llKey));
			}
		}
	    return $langMarkers;
	}

}

if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/th_mailformplus/pi2/class.tx_thmailformplus_pi2.php'])	{
	include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/th_mailformplus/pi2/class.tx_thmailformplus_pi2.php']);
}

?>
```

LG, Alex

### [#3](https://www.typo3.net/d/75100-mailformplus-405-singelview/3) · alexliebe · 2008-03-20

Ich hab´s!!!  #angry#

Für alle die das auch mal an den Rand des .... bringen.

Alle SingelView-Seiten **müssen** in den Seiteneigenschaften unbedingt "**Nicht cachen**" aktiviert haben.

Irgendwie logisch - wäre dennoch eine gute Ergänzung im Manual.

LG, Alex

---

Quelle: „Mailformplus 4.0.5 Singelview“, typo3.net, https://www.typo3.net/d/75100-mailformplus-405-singelview
Beiträge von Mitgliedern des Forums. Bitte mit Link auf die Diskussion zitieren.
