dierklandmann schriebmit ersetzt ich "user_calendar_pi1" aus deinem Code???
Mit dem Namen der Extension, die gerendert werden soll (z.B. tx_mininews_p1).
dierklandmann schriebmit ersetzt ich "user_calendar_pi1" aus deinem Code???
Mit dem Namen der Extension, die gerendert werden soll (z.B. tx_mininews_p1).
Ich habe folgenden Code in main_plaintext() eingefügt:
case "list":
if ($this->cObj->data["list_type"]=="tx_ttnews"){
$str = $this->cObj->USER($this->conf["tx_ttnews."]);
$lines[]=$this->breakContent(strip_tags($this->parseBody($str)));
}
break;
Die anderen case Elemente (Image...) habe ich heraus genommen. Leider bleibt der Contentbereich der Plainmail weiterhin ungefüllt. Ich arbeite mit dem normalen News Modul (nicht mit Mininews).
Ich bin mir unsicher, ob ich deinen Code richtig verändert habe??? Stimmt die tx_ttnews? Muß ich list_type ändern?
Im Template des Newsletters habe ich die alt.plaintext hinzugefügt. Das sollte in Ordnung sein!!!
Danke und schönes RestWochenende
Dierk
Also die extension heißt tt_news. Dann würde ich auch tx_tt_news schreiben. Oder warum schreibst du dann tx_ttnews?
C.
Oh... ich sage da nur: wer schreiben und lesen kann ist klar im Vorteil. Habe meine Mißgeschick geändert. Aber, es wird trotzdem das List Element noch nicht gerendert. Die PlainTextMail bleibt bis auf Header und Footer leer.
Irgenwo ist der Wurm drin... Ich bin gleich satt von diesem Newsletter. Wenn es überhaupt nicht geht, mache ich in das Template (Plaintext) einen Link zur Newsletter Seite und erledigt... Ist zwar nicht Sinn und Zweck der Sache. Aber das funktioniert.
Vielleicht fällt ja jemanden noch etwas ein, oder vielleicht löse ich ja das Problem....
Danke an Alle
Dierk Landmann
case "list":
$str = $this->cObj->USER($this->conf["tt_news"]);
$lines[]=$this->breakContent(strip_tags($this->parseBody($str)));
schreib mal nur das da rein (if - abfrage raus). und gucken was passert. ansonsten mußt du mal davor ein debug($this->conf) machen, und schauen wie tt_news wirklich heißt. hab leider nicht soviel zeit sonst würde ich das selbst ausprobieren...
aber ist nur 5 min arbeit. vielleicht mache ich das heute abend mal.
c.
Es geht einfach nicht....
Die Extension ist "tt_news". Was trage ich denn in der main_plaintext() ein. Ich denke mal mir fehlt nur der korrekte Name. Wenn ich mit normalen text die ganze Sache teste - funktioniert alles.
Danke an Alle
Dierk Landmann
Hallo Dierk,
ich habe jetzt das gleiche Problem, das funktioniert leider nicht so. Die News Extension hat interessanterweise den Namen "9".
Also mit
if ($this->cObj->data["list_type"]=="9"){
...
...
}
bekommst du die news. aber der aufruf danach ist irgendwie falsch.
$str = $this->cObj->USER($this->conf["tt_news"]);
funktioniert nicht, wüste auch nicht wieso es bei ihm überhaupt funktioniert hat. So wie ich das verstehe, soll hier dann die news klasse aufgerufen werden. leider kapier ich tslib_cObj::USER nicht so ganz. Ich melde mich, wenn ich was gefunden habe.
Gruß,
Chi
Eigentlich hat die tt_news laut Object Browser den Namen tx_ttnews. Oder??? Geht nicht. Wieso "9". Geht bei mir auch nicht.
Also irgendwie will der newsletter nicht klappen...
Ich bin aber optimistisch. Wir werden das schon schaffen...
das ist schon richtig, aber in der Variable list steht nun mal 9, wenn du die routine debuggst wirst du es sehen. also muß du 9 in die if-abfrage reinschreiben, sonst bekommst du alles mögliche aber nicht das news-plugin auf deiner seite. verstehste du? aber der aufruf danach(!) stimmt noch nicht.
c.
@Marek: Das kann gar nicht funktionieren. Melde dich mal bitte!
Seltsam, bei mir funktioniert der Versand von Plaintext-Newslettern seit einigen Wochen.
Ich habe vielleicht am Wochenende etwas Zeit, dann kann ich noch mal genauer nachsehen. Welches News-Modul verwendest du? tt_news?
Hallo Marek,
ich will das nicht in erster Linie für das newsmodul machen. Ich habe eine eigene Extension geschrieben, die nur text gerendert werden soll. ich verstehe auch gar nicht wieso das bei dir funktionieren kann, weil USER function eigentlich nur classen user_ aufrufen kann. und außerdem steht in $this->conf["meineextension"] auch nix drin. Ich habe mir $this->conf per debug ausgeben lassen, da steht alles mögliche drin aber nicht daten über die extension die ich aufrufen will.
ich habe einen tip bekommen, mit
$myObj = t3lib_div::makeInstance ('tx_chna_pi1'); meine klasse zu createn, und mit
$str = $myObj->myFunction ($this->conf["tx_chna_pi1."]);
methoden meiner klasse aufzurufen, aber es funktioniert nicht, weil
1. in $this->conf["tx_chna_pi1."]) steht nix
2. die main methode meiner klasse lautet:
function main($content,$conf) {
...
...
}
(Ich glaube, wie bei allen plugins. )
Meine Frage ist: Was ist $content und $conf genau, wo finde ich das, und wie übergebe ich das meinem plugin?
Das Plugin funktioniert einwandfrei, bloß halt nicht mit plaintextlib zusammen.
Vielen Dank,
Chi
$myObj = t3lib_div::makeInstance ('tx_chna_pi1');
$str = $myObj->main($content,$conf);
und dann habe ich aus meiner extension noch was rausgeschmissen, jetzt funktioniert es!!
Ist aber totaler Freestyle, weil der standart code um die pid rauszukriegen lief dann nicht:
$this->config["pid_list"] = trim($this->cObj->stdWrap($this->conf["pid_list"],$this->conf["pid_list."]));
//$this->config["pid_list"] = $this->config["pid_list"] ? implode(t3lib_div::intExplode(",",$this->config["pid_list"]),",") : $this->cObj->data["pages"];
habe ich entfernt, stattdessen:
$pid=$GLOBALS["TSFE"]->id;
Aber es funktioniert! Hurra!
Gruß,
Chi
Hat nun schon jemand eine Lösung für das Newsletter- News(1.6) -Plaintest Problem?
und das selbe zb. mit dem calender.?
Habe das heute mal versucht irgendwie einzubauen aber das klappt nicht.
Wär klasse wenn jemand das Posten könnte der es am laufen hat.
Hallo,
ich habe meine plaintextLib.inc folgendermaßen erweitert:
case "list":
$myObj = new tx_ttnews;
$myObj->cObj = $this->cObj;
$str = $myObj->main_news($content,$conf);
$lines[]=$this->breakContent(strip_tags($this->parseBody($str)));
break;
Angezeigt wird:
News
Codes
You must insert a code in the CODE field of the "List" content element before the news module will work. The code tells the news module what to do. ....
Die html-Ansicht funktioniert einwandfrei, nur bei type=99 kommt dieser Fehler. Ansehen kann man das ganze unter:
http://www.umweltwissenschaften.de/infernum/index.php?id=927 bzw. http://www.umweltwissenschaften.de/infernum/index.php?id=927&type=99
Es scheint, als müsste ich nur noch den Code, also Latest oder List oder Single, irgendwie da 'reinbringen.
Ich hab' aber keine Ahnung, wie ich das anstellen soll. Hat jemand eine Idee?
Um die News dynamisch in einen Plain-Text-Newsletter zu bringen, sind die Typo3-Bordmittel vollkommen ungeeignet.
Viel simpler ist es, ausserhalb von Typo3 eine Datenbankabfrage durchzuführen. Dazu legen wir im Webroot eine Seite "news_plain.php" mit folgendem Inhalt an:
<?php
$db = mysql_connect(localhost,db_benutzername,passwort);
$res = mysql_db_query("typo3",
"SELECT tt_news.title,tt_news.short,tt_news.bodytext,tt_news.links FROM `tt_news` WHERE `hidden` = 0 AND `category` = 4 AND `archivedate` >= UNIX_TIMESTAMP() ORDER BY UID DESC;");
$datum = date("d.n.y");
$num = mysql_num_rows($res);
echo "Newsletter vom $datum (Textversion)
";
echo "====================================================
";
echo "Inhalt:
";
for ($i=0; $i<$num; $i++)
{
$title = mysql_result($res, $i, "title");
$short = mysql_result($res, $i, "short");
$bodytext = mysql_result($res, $i, "bodytext");
$links = mysql_result($res, $i, "links");
echo "$title : $short
";
}
echo "====================================================
";
for ($i=0; $i<$num; $i++)
{
$title = mysql_result($res, $i, "title");
$short = mysql_result($res, $i, "short");
$bodytext = mysql_result($res, $i, "bodytext");
$links = mysql_result($res, $i, "links");
echo "$title
";
echo "$short
";
echo "$bodytext
";
echo "$links
";
}
mysql_close($db);
?>
In Zeile 2 wird die Verbindung zur DB aufgebaut. "db_benutzername" und "passwort" müssen durch die entsprechenden Angaben ersetzt werden. Ebenso muss die Kategorie angepasst werden.
Diese Seite ruft man dann innerhalb von T3 auf, wenn man den Plaint-Text-Newsletter versenden will, und zwar mit "http://www.domain.de/news_plain.php", ohne Zusatz irgendwelcher Anhängsel wie "&type=99".
Dies funktioniert, sofern zu allen News ein Archivdatum angegeben wird, ansonsten muss der Code leicht modifiziert werden.
Um Umlaute und html-Tags aus dem Newsletter zu entfernen, sollten vielleicht noch einige ereg-replace's in den php-Code eingefügt werden.
Hi,
@Tsoukis
Finde ich super klasse, dass du dieses Script veröffendlicht hast. Ein paar Modifikationen im Select Befehl und man kann dies auch für den normalen Newsletterversand benutzen. Bei mir war nähmlich das Problem, dass das Newslettermodul Plaintext Mails immer ohne Content gesendet hat. Die Platzhalter wie ###CONTENT### wurden nicht ersetzt. Nun kann ich aber die Daten separat aus der DB auslesen und an die Zielgruppe senden.
THX dafür
MfG
Mendossa
Hallo
den marker content füllen kann man mit
alt_plaintext.10.marks.CONTENT >
alt_plaintext.10.marks.CONTENT = COA
alt_plaintext.10.marks.CONTENT {
10 < styles.content.get
10.renderObj = < lib.alt_plaintext.renderObj
20 < styles.content.getBorder
20.renderObj = < lib.alt_plaintext.renderObj
}
tschö
So ... war sauer genug mit der plaintextLib.inc
hier meine Version die tt_news(2.2.13) und jw_calender(1.3.20) unterstützt ...
viel Spass ;-)
<?php
/***************************************************************
* Copyright notice
*
* (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@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!
***************************************************************/
/**
* Generating plain text content of content elements for Direct Mails
*
* $Id: plaintextLib.inc,v 1.9 2005/04/01 14:37:15 typo3 Exp $
* Revised for TYPO3 3.6 June/2003 by Kasper Skaarhoj
*
* @author Kasper Skaarhoj <kasperyyyy@typo3.com>
*/
/**
* [CLASS/FUNCTION INDEX of SCRIPT]
*
*
*
* 123: class user_plaintext
* 137: function main_plaintext($content,$conf)
* 209: function getMenuSitemap()
* 220: function getShortcut()
* 231: function getHTML($str=array())
* 241: function getHeader()
* 251: function getImages()
* 262: function parseBody($str)
* 284: function renderUploads($str,$upload_path='uploads/media/')
* 302: function renderHeader($str,$type=0)
* 353: function pad($lines,$preLineChar,$len)
* 369: function breakContent($str)
* 385: function breakBulletlist($str)
* 416: function breakTable($str)
* 472: function addDiv($messure,$content,$divChar,$joinChar,$cols)
* 488: function traverseTable($tableLines)
* 515: function renderImages($str,$links,$caption,$upload_path='uploads/pics/')
* 554: function getLink($ll)
* 571: function breakLines($str,$implChar="\n",$charWidth=0)
* 583: function getString($str)
* 595: function userProcess($mConfKey,$passVar)
* 613: function atag_to_http($content,$conf)
* 632: function typolist($content,$conf)
* 647: function typohead($content,$conf)
* 666: function typocode($content,$conf)
*
* TOTAL FUNCTIONS: 24
* (This index is automatically created/updated by the extension "extdeveval")
*
*/
/**
* Alternative rendering of content elements for Plain Text emails. That means text-only output. No HTML at all. Used by the Direct Mail extension.
* Normally the plain text output should appear with type=99.
* To use this library you can include the static template "plugin.alt.plaintext"
*
* ## Insert DMailer Boundaries for all elements.
* config.insertDmailerBoundaries = 1
* includeLibs.plaintextLib = media/scripts/plaintextLib.inc
*
* ## Set up page/type number:
* alt_plaintext >
* alt_plaintext = PAGE
* alt_plaintext.typeNum=99
* alt_plaintext.config.disableAllHeaderCode = 1
* alt_plaintext.10 = TEMPLATE
* alt_plaintext.10 {
* template = FILE
* template.file = {$plugin.alt.plaintext.file.template}
* marks.CONTENT < styles.content.get
* marks.CONTENT.renderObj = < lib.alt_plaintext.renderObj
* marks.DATE = TEXT
* marks.DATE.data = date:U
* marks.DATE.strftime = %e. %B %Y
* }
*
* (And then also "lib.alt_plaintext.renderObj" is configured extensively - basically with the TypoScript options passed to this class. See the static template "plugin.alt.plaintext")
*
* @author Kasper Skaarhoj <kasperyyyy@typo3.com>
* @package TYPO3
* @subpackage tslib
* @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=398&cHash=e3024de334
*/
class user_plaintext {
var $cObj;
var $conf=array();
var $charWidth=76;
/**
* Main function, called from TypoScript
* A content object that renders "tt_content" records. See the comment to this class for TypoScript example of how to trigger it.
* This detects the CType of the current content element and renders it accordingly. Only wellknown types are rendered.
*
* @param string Empty, ignore.
* @param array TypoScript properties for this content object/function call
* @return string Plain text content
*/
function main_plaintext($content,$conf) {
$this->pi_initPIflexForm();
$this->conf = $conf;
$this->siteUrl=$conf['siteUrl'];
$lines = array();
$CType= (string)$this->cObj->data['CType'];
switch($CType) {
case 'header':
$lines[]=$this->getHeader();
if ($this->cObj->data['subheader']) {
$lines[]=$this->breakContent(strip_tags($this->cObj->data['subheader']));
}
break;
case 'text':
$lines[]=$this->getHeader();
$lines[]=$this->breakContent(strip_tags($this->parseBody($this->cObj->data['bodytext'])));
break;
case 'textpic':
$lines[]=$this->getHeader();
if ($CType=='textpic' && !($this->cObj->data['imageorient']&24)) {
$lines[]=$this->getImages();
$lines[]='';
}
$lines[]=$this->breakContent(strip_tags($this->parseBody($this->cObj->data['bodytext'])));
if ($CType=='textpic' && ($this->cObj->data['imageorient']&24)) {
$lines[]='';
$lines[]=$this->getImages();
}
break;
case 'image':
$lines[]=$this->getHeader();
$lines[]=$this->getImages();
break;
case 'uploads':
$lines[]=$this->getHeader();
$lines[]=$this->renderUploads($this->cObj->data['media']);
break;
case 'menu':
$lines[]=$this->getHeader();
$lines[]=$this->getMenuSitemap();
break;
case 'shortcut':
$lines[]=$this->getShortcut();
break;
case 'bullets':
$lines[]=$this->getHeader();
$lines[]=$this->breakBulletlist(strip_tags($this->parseBody($this->cObj->data['bodytext'])));
break;
case 'table':
$lines[]=$this->getHeader();
$lines[]=$this->breakTable(strip_tags($this->parseBody($this->cObj->data['bodytext'])));
break;
case 'html':
$lines[]=$this->getHTML();
break;
case 'list':
if($this->cObj->data["list_type"]==9){// 9 = tt_news
$lines[]=$this->getHeader();
$lines[]=$this->getNews();
}
if($this->cObj->data["list_type"]=="jw_calendar_pi1"){
$lines[]=$this->getHeader();
$lines[]=$this->getJWCalendar();
}
break;
default:
$defaultOutput = $this->getString($this->conf['defaultOutput']);
if ($defaultOutput) {
$lines[]=str_replace('###CType###',$CType,$defaultOutput);
}
break;
}
$lines[]=''; // First break.
$content = implode(chr(10),$lines);
// User processing:
$content=$this->userProcess('userProc',$content);
return $content;
}
/*******************************
*
* FlexForms related functions
*
*******************************/
/**
* Converts $this->cObj->data['pi_flexform'] from XML string to flexForm array.
*
* @return void
*/
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();
}
}
/**
* Return value from somewhere inside a FlexForm structure
*
* @param array FlexForm data
* @param string Field name to extract. Can be given like "test/el/2/test/el/field_templateObject" where each part will dig a level deeper in the FlexForm data.
* @param string Sheet pointer, eg. "sDEF"
* @param string Language pointer, eg. "lDEF"
* @param string Value pointer, eg. "vDEF"
* @return string The content.
*/
function pi_getFFvalue($T3FlexForm_array,$fieldName,$sheet='sDEF',$lang='lDEF',$value='vDEF') {
$sheetArray = is_array($T3FlexForm_array) ? $T3FlexForm_array['data'][$sheet][$lang] : '';
if (is_array($sheetArray)) {
return $this->pi_getFFvalueFromSheetArray($sheetArray,explode('/',$fieldName),$value);
}
}
/**
* Returns part of $sheetArray pointed to by the keys in $fieldNameArray
*
* @param array Multidimensiona array, typically FlexForm contents
* @param array Array where each value points to a key in the FlexForms content - the input array will have the value returned pointed to by these keys. All integer keys will not take their integer counterparts, but rather traverse the current position in the array an return element number X (whether this is right behavior is not settled yet...)
* @param string Value for outermost key, typ. "vDEF" depending on language.
* @return mixed The value, typ. string.
* @access private
* @see pi_getFFvalue()
*/
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];
}
/**
* Creates tt_news depending on type "LATEST" or "LIST"
*
* @return string Content
*/
function getJWCalendar(){
$cat= $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'categorySelection','sDEF');
$mode= $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'viewmode','sDEF');
if(!$mode){
$content="No or wrong jw_calendar mode";
}
else{
$where_clause='event.hidden = 0 AND event.deleted = 0';
if($cat)$where_clause.=' AND event.category = '.$cat;
$where_clause.=' AND event.location_id=location.uid AND event.organizer_id=organizer.uid';
if($mode=='LIST'){
$twoweeksago=time()-(14*24*3600);
$where_clause.=' AND event.begin >='.$twoweeksago;
}
$res= $GLOBALS['TYPO3_DB']->exec_SELECTquery('event.title,event.teaser,event.description,event.begin,event.end,location.location,location.name,location.zip,location.street,location.city,location.phone,location.email,organizer.name AS o_name,organizer.phone AS o_phone,organizer.email AS o_email','tx_jwcalendar_events AS event,tx_jwcalendar_location AS location,tx_jwcalendar_organizer AS organizer',$where_clause,$groupBy='',$orderBy='begin DESC',$limit);
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$content.=$this->breakContent(html_entity_decode($row[title])).chr(10).chr(10);
$content.=$this->breakContent(html_entity_decode($row[teaser])).chr(10).chr(10);
$content.=$this->breakContent(html_entity_decode($row[description])).chr(10).chr(10);
$content.='Beginn: ';
$content.=strftime("%A, %d.%m.%Y %H:%M",$row[begin]).chr(10);
$content.='Ende : ';
$content.=strftime("%A, %d.%m.%Y %H:%M",$row[end]).chr(10).chr(10);
$content.='Ort: '.chr(10);
$content.=$row[location].chr(10);
$content.=$row[street].chr(10);
$content.=$row[zip].' ';
$content.=$row[city].chr(10);
$content.='Tel.: '.$row[phone].chr(10);
$content.='Email: '.$row[email].chr(10).chr(10);
$content.='Veranstalter: '.chr(10);
$content.=$row[o_name].chr(10);
$content.='Tel.: '.$row[o_phone].chr(10);
$content.='Email: '.$row[o_email].chr(10).chr(10);
$content.='----------------------------------------------------------------------------'.chr(10);
}
if(!$content)$content='Keine Termine jünger als 14 Tage!';
}
return $content;
}
/**
* Creates tt_news depending on type "LATEST" or "LIST"
*
* @return string Content
*/
function getNews(){
$cat= $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'categorySelection','sDEF');
$mode= $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'what_to_display','sDEF');
if(!$mode){
$content="No or wrong tt_news mode";
}
else{
$where_clause='news.hidden = 0 AND cat.uid_foreign = '.$cat.' AND cat.uid_local = news.uid';
if($mode=='LATEST')$limit='1';
if($mode=='LIST'){
$limit='1,10';
$twoweeksago=time()-(14*24*3600);
$where_clause.=' AND news.datetime >='.$twoweeksago;
}
$res=
$GLOBALS['TYPO3_DB']->exec_SELECTquery('news.title,news.bodytext,news.datetime','tt_news AS news,tt_news_cat_mm AS cat',$where_clause,$groupBy='',$orderBy='news.datetime DESC',$limit);
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$content.=strftime("%A, %d.%m.%Y %H:%M",$row[datetime]).chr(10);
$content.=$this->breakContent(html_entity_decode($row[title])).chr(10).chr(10);
$content.=$this->breakContent(html_entity_decode($row[bodytext])).chr(10);
$content.='----------------------------------------------------------------------------'.chr(10);
}
if(!$content)$content='Keine weiteren Meldungen jünger als 14 Tage!';
}
return $content;
}
/**
* Creates a menu/sitemap
*
* @return string Content
*/
function getMenuSitemap() {
$str = $this->cObj->cObjGetSingle($this->conf['menu'],$this->conf['menu.']);
$str = $this->breakBulletlist(trim(strip_tags(eregi_replace('<br[>',chr(10),$this->parseBody($str)))));
return $str;
}
/**
* Creates a shortcut ("Insert Records")
*
* @return string Content
*/
function getShortcut() {
$str = $this->cObj->cObjGetSingle($this->conf['shortcut'],$this->conf['shortcut.']);
return $str;
}
/**
* Creates an HTML element (stripping tags of course)
*
* @param string HTML content to process. If not passed along, the bodytext field is used.
* @return string Content
*/
function getHTML($str=array()) {
return $this->breakContent(strip_tags(eregi_replace('<br[>',chr(10),$this->parseBody(is_string($str)?$str:$this->cObj->data['bodytext']))));
}
/**
* Creates a header (used for most elements)
*
* @return string Content
* @see renderHeader()
*/
function getHeader() {
// links...
return $this->renderHeader($this->cObj->data['header'],$this->cObj->data['header_layout']);
}
/**
* Get images found in the "image" field of "tt_content"
*
* @return string Content
*/
function getImages() {
$images = $this->renderImages($this->cObj->data['image'],!$this->cObj->data['image_zoom']?$this->cObj->data['image_link']:'',$this->cObj->data['imagecaption']);
return $images;
}
/**
* Parsing the bodytext field content, removing typical entities and <br /> tags.
*
* @param string Field content from "bodytext"
* @return string Processed content
*/
function parseBody($str) {
// First, regular parsing:
$str = eregi_replace('<br[>',' ',$str);
$str = $this->cObj->stdWrap($str,$this->conf['bodytext.']['stdWrap.']);
// Then all a-tags:
$aConf = array();
$aConf['parseFunc.']['tags.']['a']='USER';
$aConf['parseFunc.']['tags.']['a.']['userFunc']='user_plaintext->atag_to_http';
$aConf['parseFunc.']['tags.']['a.']['siteUrl'] = $this->siteUrl;
$str = $this->cObj->stdWrap($str,$aConf);
$str = str_replace(' ',' ',t3lib_div::htmlspecialchars_decode($str));
return $str;
}
/**
* Creates a list of links to uploaded files.
*
* @param string List of uploaded filenames from "uploads/media/" (or $upload_path)
* @param string Alternative path value
* @return string Content
*/
function renderUploads($str,$upload_path='uploads/media/') {
$files = explode(',',$str);
reset($files);
$lines=array();
if ($this->conf['uploads.']['header']) {$lines[]=$this->getString($this->conf['uploads.']['header']);}
while(list($k,$file)=each($files)) {
$lines[]=$this->siteUrl.$upload_path.$file;
}
return implode(chr(10),$lines);
}
/**
* Renders a content element header, observing the layout type giving different header formattings
*
* @param string The header string
* @param integer The layout type of the header (in the content element)
* @return string Content
*/
function renderHeader($str,$type=0) {
if ($str) {
$hConf = $this->conf['header.'];
$defaultType = t3lib_div::intInRange($hConf['defaultType'],1,5);
$type=t3lib_div::intInRange($type,0,6);
if (!$type) $type=$defaultType;
if ($type!=6) { // not hidden
$tConf = $hConf[$type.'.'];
$lines=array();
$blanks = t3lib_div::intInRange($tConf['preBlanks'],0,1000);
if ($blanks) {
$lines[]=str_pad('', $blanks-1, chr(10));
}
$lines=$this->pad($lines,$tConf['preLineChar'],$tConf['preLineLen']);
$blanks = t3lib_div::intInRange($tConf['preLineBlanks'],0,1000);
if ($blanks) {$lines[]=str_pad('', $blanks-1, chr(10));}
if ($this->cObj->data['date']) {$lines[] = $this->getString($hConf['datePrefix']).date($hConf['date']?$hConf['date']:'d-m-Y',$this->cObj->data['date']);}
$prefix='';
$str=$this->getString($tConf['prefix']).$str;
if ($tConf['autonumber']) $str=$this->cObj->parentRecordNumber.$str;
if ($this->cObj->data['header_position']=='right') {$prefix=str_pad(' ',($this->charWidth-strlen($str)));}
if ($this->cObj->data['header_position']=='center') {$prefix=str_pad(' ',floor(($this->charWidth-strlen($str))/2));}
$lines[]=$this->cObj->stdWrap($prefix.$str,$tConf['stdWrap.']);
if ($this->cObj->data['header_link']) {$lines[] = $this->getString($hConf['linkPrefix']).$this->getLink($this->cObj->data['header_link']);}
$blanks = t3lib_div::intInRange($tConf['postLineBlanks'],0,1000);
if ($blanks) {$lines[]=str_pad('', $blanks-1, chr(10));}
$lines=$this->pad($lines,$tConf['postLineChar'],$tConf['postLineLen']);
$blanks = t3lib_div::intInRange($tConf['postBlanks'],0,1000);
if ($blanks) {$lines[]=str_pad('', $blanks-1, chr(10));}
return implode(chr(10),$lines);
}
}
}
/**
* Function used to repeat a char pattern in head lines (like if you want "********" above/below a header)
*
* @param array Array of existing lines to which the new char-pattern should be added
* @param string The character pattern to repeat. Default is "-"
* @param integer The length of the line. $preLineChar will be repeated to fill in this length.
* @return array The input array with a new line added.
* @see renderHeader()
*/
function pad($lines,$preLineChar,$len) {
$strPad = t3lib_div::intInRange($len,0,1000);
$strPadChar = $preLineChar?$preLineChar:'-';
if ($strPad) {
$lines[]=str_pad('', $strPad, $strPadChar);
}
return $lines;
}
/**
* Function used to wrap the bodytext field content (or image caption) into lines of a max length of
*
* @param string The content to break
* @return string Processed value.
* @see main_plaintext(), breakLines()
*/
function breakContent($str) {
$cParts = explode(chr(10),$str);
reset($cParts);
$lines=array();
while(list(,$substrs)=each($cParts)) {
$lines[]=$this->breakLines($substrs);
}
return implode(chr(10),$lines);
}
/**
* Breaks content lines into a bullet list
*
* @param string Content string to make into a bullet list
* @return string Processed value
*/
function breakBulletlist($str) {
$type = $this->cObj->data['layout'];
$type=t3lib_div::intInRange($type,0,3);
$tConf = $this->conf['bulletlist.'][$type.'.'];
$cParts = explode(chr(10),$str);
reset($cParts);
$lines=array();
$c=0;
while(list(,$substrs)=each($cParts)) {
$c++;
$bullet = $tConf['bullet'] ? $this->getString($tConf['bullet']) : ' - ';
$bLen=strlen($bullet);
$bullet = substr(str_replace('#',$c,$bullet),0,$bLen);
$secondRow = substr($tConf['secondRow']?$this->getString($tConf['secondRow']):str_pad('',strlen($bullet),' '),0,$bLen);
$lines[]=$bullet.$this->breakLines($substrs,chr(10).$secondRow,$this->charWidth-$bLen);
$blanks = t3lib_div::intInRange($tConf['blanks'],0,1000);
if ($blanks) {$lines[]=str_pad('', $blanks-1, chr(10));}
}
return implode(chr(10),$lines);
}
/**
* Formatting a table in plain text (based on the paradigm of lines being content rows and cells separated by "|")
*
* @param string Content string
* @return string Processed value
*/
function breakTable($str) {
$cParts = explode(chr(10),$str);
reset($cParts);
$lines=array();
$cols = intval($this->conf['cols']) ? intval($this->conf['cols']) : 0 ;
$c=0;
while(list(,$substrs)=each($cParts)) {
$c++;
if (trim($substrs)) {
$lineParts=explode('|',$substrs);
if (!$cols) $cols=count($lineParts);
for ($a=0;$a<$cols;$a++) {
$jdu = explode(chr(10),$this->breakLines($lineParts[$a],chr(10),ceil($this->charWidth/$cols)));
$lines[$c][$a]=$jdu;
}
}
}
$messure = $this->traverseTable($lines);
$divChar='-';
$joinChar='+';
$colChar='|';
// Make table:
$outLines = array();
$outLines[]=$this->addDiv($messure,'',$divChar,$joinChar,$cols);
reset($lines);
while(list($k,$v)=each($lines)) {
$top = intval($messure[1][$k]);
for ($aa=0;$aa<$top;$aa++) {
$tempArr=array();
for ($bb=0;$bb<$cols;$bb++) {
$tempArr[$bb]=str_pad($v[$bb][$aa],$messure[0][$bb],' ');
}
$outLines[]=$colChar.implode($colChar,$tempArr).$colChar;
}
$outLines[]=$this->addDiv($messure,'',$divChar,$joinChar,$cols);
}
return implode(chr(10),$outLines);
}
/**
* Subfunction for breakTable(): Adds a divider line between table rows.
*
* @param array Some information about sizes
* @param string Empty string.
* @param string Character to use for the divider line, typically "-"
* @param string Join character, typically "+"
* @param integer Number of table columns
* @return string Divider line for the table
* @access private
* @see breakTable()
*/
function addDiv($messure,$content,$divChar,$joinChar,$cols) {
$tempArr=array();
for ($a=0;$a<$cols;$a++) {
$tempArr[$a]=str_pad($content,$messure[0][$a],$divChar);
}
return $joinChar.implode($joinChar,$tempArr).$joinChar;
}
/**
* Traverses the table lines/cells and creates arrays with statistics for line numbers and lengths
*
* @param array Array with [table rows] [table cells] [lines in cell]
* @return array Statistics (max lines/lengths)
* @access private
* @see breakTable()
*/
function traverseTable($tableLines) {
$maxLen=array();
$maxLines=array();
reset($tableLines);
while(list($k,$v)=each($tableLines)) {
reset($v);
while(list($kk,$vv)=each($v)) {
reset($vv);
while(list($lk,$lv)=each($vv)) {
if (strlen($lv)>intval($maxLen[$kk])) $maxLen[$kk]=strlen($lv);
}
if (count($vv)>intval($maxLines[$k])) $maxLines[$k]=count($vv);
}
}
return array($maxLen,$maxLines);
}
/**
* Render block of images - which means creating lines with links to the images.
*
* @param string List of image filenames (from "image" field in tt_content records)
* @param string Link value from the "image_link" field in tt_content records
* @param string Caption text
* @param string Alternative relative path for the files listed in $str
* @return string Content
* @see getImages()
*/
function renderImages($str,$links,$caption,$upload_path='uploads/pics/') {
$images = explode(',',$str);
$linksArr = explode(',',$links);
reset($images);
$lines=array();
if ($this->conf['images.']['header']) {$lines[]=$this->getString($this->conf['images.']['header']);}
while(list($k,$file)=each($images)) {
$lines[]=$this->siteUrl.$upload_path.$file;
if ($links && count($linksArr)>1) {
if (isset($linksArr[$k])) {
$ll=$linksArr[$k];
} else {
$ll=$linksArr[0];
}
$theLink = $this->getLink($ll);
if ($theLink) {$lines[]=$this->getString($this->conf['images.']['linkPrefix']).$theLink;}
}
}
if ($links && count($linksArr)==1) {
$theLink = $this->getLink($links);
if ($theLink) {$lines[]=$this->getString($this->conf['images.']['linkPrefix']).$theLink;}
}
if ($caption) {
$lines[]='';
$cHeader = trim($this->getString($this->conf['images.']['captionHeader']));
if ($cHeader) $lines[]=$cHeader;
$lines[]=$this->breakContent($caption);
}
return implode(chr(10),$lines);
}
/**
* Returns a typolink URL based on input.
*
* @param string Parameter to typolink
* @return string The URL returned from $this->cObj->getTypoLink_URL(); - possibly it prefixed with the URL of the site if not present already
*/
function getLink($ll) {
$theLink=$this->cObj->getTypoLink_URL($ll);
if (substr($theLink,0,4)!='http') {
$theLink=$this->siteUrl.$theLink;
}
return $theLink;
}
/**
* Breaking lines into fixed length lines, using t3lib_div::breakLinesForEmail()
*
* @param string The string to break
* @param string Line break character
* @param integer Length of lines, default is $this->charWidth
* @return string Processed string
* @see t3lib_div::breakLinesForEmail()
*/
function breakLines($str,$implChar="\n",$charWidth=0) {
return t3lib_div::breakLinesForEmail($str,$implChar,$charWidth?$charWidth:$this->charWidth);
}
/**
* Explodes a string with "|" and if the second part is found it will return this, otherwise the first part.
* Used for many TypoScript properties used in this class since they need preceeding whitespace to be preserved.
*
* @param string Input string
* @return string Output string
* @access private
*/
function getString($str) {
$parts = explode('|',$str);
return strcmp($parts[1],'')?$parts[1]:$parts[0];
}
/**
* Calls a user function for processing of data
*
* @param string TypoScript property name, pointing to the definition of the user function to call (from the TypoScript array internally in this class). This array is passed to the user function. Notice that "parentObj" property is a reference to this class ($this)
* @param mixed Variable to process
* @return mixed The processed $passVar as returned by the function call
*/
function userProcess($mConfKey,$passVar) {
if ($this->conf[$mConfKey]) {
$funcConf = $this->conf[$mConfKey.'.'];
$funcConf['parentObj']=&$this;
$passVar = $GLOBALS['TSFE']->cObj->callUserFunction($this->conf[$mConfKey], $funcConf, $passVar);
}
return $passVar;
}
/**
* Function used by TypoScript "parseFunc" to process links in the bodytext.
* Extracts the link and shows it in plain text in a parathesis next to the link text. If link was relative the site URL was prepended.
*
* @param string Empty, ignore.
* @param array TypoScript parameters
* @return string Processed output.
* @see parseBody()
*/
function atag_to_http($content,$conf) {
$this->conf = $conf;
$this->siteUrl=$conf['siteUrl'];
$theLink = trim($this->cObj->parameters['href']);
if (strtolower(substr($theLink,0,7))=='mailto:') {
$theLink=substr($theLink,7);
} elseif (substr($theLink,0,4)!='http') {
$theLink=$this->siteUrl.$theLink;
}
return $this->cObj->getCurrentVal().' (Link: '.$theLink.' )';
}
/**
* User function (called from TypoScript) for generating a bullet list (used in parsefunc)
*
* @param string Empty, ignore.
* @param array TypoScript parameters
* @return string Processed output.
*/
function typolist($content,$conf) {
$this->conf = $this->cObj->mergeTSRef($conf,'bulletlist');
$this->siteUrl=$conf['siteUrl'];
$str = trim($this->cObj->getCurrentVal());
$this->cObj->data['layout'] = $this->cObj->parameters['type'];
return $this->breakBulletlist($str);
}
/**
* User function (called from TypoScript) for generating a typo header tag (used in parsefunc)
*
* @param string Empty, ignore.
* @param array TypoScript parameters
* @return string Processed output.
*/
function typohead($content,$conf) {
$this->conf = $this->cObj->mergeTSRef($conf,'header');
$this->siteUrl=$conf['siteUrl'];
$str = trim($this->cObj->getCurrentVal());
$this->cObj->data['header_layout'] = $this->cObj->parameters['type'];
$this->cObj->data['header_position'] = $this->cObj->parameters['align'];
$this->cObj->data['header']=$str;
return $this->getHeader();
}
/**
* User function (called from TypoScript) for generating a code listing (used in parsefunc)
*
* @param string Empty, ignore.
* @param array TypoScript parameters
* @return string Processed output.
*/
function typocode($content,$conf) {
// Nothing is really done here...
$this->conf = $conf;
$this->siteUrl=$conf['siteUrl'];
return $this->cObj->getCurrentVal();
}
}
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['media/scripts/plaintextLib.inc']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['media/scripts/plaintextLib.inc']);
}
?>
Hi!
Mir fehlen auch die News für den Plaintext Newsletter.
Wenn ich keine Flexforms benutze, durch was muß ich den die Abfrage ersetzen?
Vielen Dank im Voraus!
#
function getNews(){
#
#
$cat= $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'categorySelection','sDEF');
#
$mode= $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'what_to_display','sDEF');
#
#
if(!$mode){
#
$content="No or wrong tt_news mode";
#
}
#
else{
#
#
$where_clause='news.hidden = 0 AND cat.uid_foreign = '.$cat.' AND cat.uid_local = news.uid';
#
if($mode=='LATEST')$limit='1';
#
if($mode=='LIST'){
#
$limit='1,10';
#
$twoweeksago=time()-(14*24*3600);
#
$where_clause.=' AND news.datetime >='.$twoweeksago;
#
}
#
$res=
#
$GLOBALS['TYPO3_DB']->exec_SELECTquery('news.title,news.bodytext,news.datetime','tt_news AS news,tt_news_cat_mm AS cat',$where_clause,$groupBy='',$orderBy='news.datetime DESC',$limit);
#
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
#
$content.=strftime("%A, %d.%m.%Y %H:%M",$row[datetime]).chr(10);
#
$content.=$this->breakContent(html_entity_decode($row[title])).chr(10).chr(10);
#
$content.=$this->breakContent(html_entity_decode($row[bodytext])).chr(10);
#
$content.='----------------------------------------------------------------------------'.chr(10);
#
}
#
if(!$content)$content='Keine weiteren Meldungen jünger als 14 Tage!';
#
}
#
#
return $content;
#
}