TYPO3 - Powermail: Unterschied zwischen den Versionen

Aus Wikizone
Wechseln zu: Navigation, Suche
(Die Seite wurde neu angelegt: „Powermail Extension == Snippets == === Formular in Datenbank speichern === <pre> plugin.tx_powermail_pi1{ dbEntry { # Speicherung für Tabelle er…“)
 
Zeile 21: Zeile 21:
 
     }
 
     }
 
}
 
}
 +
</pre>
 +
 +
=== Ausführliches Beispiel ===
 +
 +
Constants
 +
<pre>
 +
plugin.powermail.js.alwaysInclude = 1
 +
plugin.powermail.js.includeJquery = 0
 +
plugin.powermail.js.includeJqueryTools = 0
 +
plugin.powermail.js.includeJqueryToolsTabs = 0
 +
plugin.powermail.allow.email2sender = 0
 +
plugin.powermail.PID.dblog = 0
 +
plugin.powermail.markerALL.hideLabel = 1
 +
plugin.powermail.format.datetime = %d.%m.%Y% %H:%M
 +
plugin.powermail.format.date = %d.%m.%Y
 +
plugin.powermail.debug.output =
 +
</pre>
 +
 +
Setup
 +
<pre>
 +
// CSS Pfad ändern (oder gar nicht erst statisch einbinden ;-)  )
 +
page.includeCSS.powermail_frontend_basic = fileadmin/templates/onlineboerse/powermail.css
 +
</pre>
 +
 +
==== Datenbank Speicherung mit verschiedenen Optionen ====
 +
 +
</pre>
 +
// Powermail DB Storage
 +
// Extra userfunc to convert date to unix timestamp
 +
includeLibs.powermailTimestamp = fileadmin/templates/scripts/user_powermailTimestamp.php
 +
 +
plugin.tx_powermail_pi1.dbEntry{ 
 +
  tx_gbbulletin_bulletin {
 +
 +
    _enable = TEXT
 +
    _enable.value = 1
 +
   
 +
    hidden = TEXT
 +
    hidden.value = 1
 +
   
 +
    pid = TEXT
 +
    pid.value = 102
 +
       
 +
    tstamp = TEXT
 +
    tstamp.data = date:U
 +
       
 +
    crdate = TEXT
 +
    crdate.data = date:U
 +
 +
    title = TEXT
 +
    title.data = TSFE:fe_user|sesData|powermail_214|uid1
 +
 +
    author = TEXT
 +
    author.data = TSFE:fe_user|sesData|powermail_214|uid2
 +
 +
    place = TEXT
 +
    place.data = TSFE:fe_user|sesData|powermail_214|uid3
 +
   
 +
    description = TEXT
 +
    description.data = TSFE:fe_user|sesData|powermail_214|uid4
 +
 +
    contact = TEXT
 +
    contact.data = TSFE:fe_user|sesData|powermail_214|uid5
 +
 +
    qualification = TEXT
 +
    qualification.data = TSFE:fe_user|sesData|powermail_214|uid6
 +
   
 +
    date = USER
 +
    date.userFunc = user_powermailTimestamp->preflight
 +
    date.userFunc.field = uid7
 +
    date.userFunc.formuid = 214
 +
   
 +
    period = TEXT
 +
    period.data = TSFE:fe_user|sesData|powermail_214|uid29
 +
 +
    end_date = USER
 +
    end_date.userFunc = user_powermailTimestamp->preflight
 +
    end_date.userFunc.field = uid14
 +
    end_date.userFunc.formuid = 214
 +
   
 +
    url = TEXT
 +
    url.data = TSFE:fe_user|sesData|powermail_214|uid8
 +
 +
    text1 = TEXT
 +
    text1.data = TSFE:fe_user|sesData|powermail_214|uid9
 +
   
 +
    cluster = TEXT
 +
    cluster.data = TSFE:fe_user|sesData|powermail_214|uid11
 +
   
 +
    # add mm relation to uid 2 of tx_gbbulletin_cluster (via mm table)
 +
    _mm = COA
 +
    _mm.10 = COA
 +
    # 1 is always the mm table
 +
    _mm.10.1 = TEXT
 +
    _mm.10.1.value = tx_gbbulletin_cluster_mm
 +
    # 2 is always the other table
 +
    _mm.10.2 = TEXT
 +
    _mm.10.2.value = tx_gbbulletin_cluster
 +
    # 3 is always the uid of the other table to get a relation to this
 +
    # (in this case uid1 of tx_gbbulletin_cluster)
 +
    _mm.10.3 = TEXT
 +
    _mm.10.3.value = 1
 +
   
 +
    tag = TEXT
 +
    tag.data = TSFE:fe_user|sesData|powermail_214|uid12
 +
 +
  }
 +
 +
}
 +
</pre>
 +
 +
==== Userfunktion zum umwandeln von Datum in Timestamp ====
 +
Diese Funktion wird im obigen Beispiel zu Datenbankspeicherung verwendet
 +
<pre>
 +
<?php
 +
 +
    class user_powermailTimestamp {
 +
   
 +
   
 +
        // Function preflight() will be used from typoscript
 +
        function preflight($content='', $conf=array()) {
 +
            $value = $GLOBALS['TSFE']->fe_user->sesData['powermail_'.$conf['userFunc.']['formuid']][$conf['userFunc.']['field']];
 +
            return $this->getDate($value);
 +
        }
 +
       
 +
       
 +
        // Main getDate() changes a date in any format to an unix timestamp
 +
        function getDate($string, $default = 'now', $timestamp = 1) {
 +
            $error = 0; // no error at the beginning
 +
            $string = str_replace(array('-', '_', ':', '+', ',', ' '), '.', $string); // change 23-12-2009 -> 23.12.2009 AND "05:00 23.01.2009" -> 05.00.23.01.2009
 +
            if (method_exists('t3lib_div', 'trimExplode')) $dateParts = t3lib_div::trimExplode('.', $string, 1); else $dateParts = explode('.', $string); // split at .
 +
       
 +
            if (count($dateParts) === 3) { // only if there are three parts like "23.12.2009"
 +
                if (strlen($dateParts[0]) <= 2 && strlen($dateParts[1]) <= 2 && strlen($dateParts[2]) <= 2) { // xx.xx.xx
 +
                    $string = strtotime($dateParts[2].'-'.$dateParts[1].'-'.$dateParts[0]); // change to timestamp
 +
                }
 +
                elseif (strlen($dateParts[0]) == 4 && strlen($dateParts[1]) <= 2 && strlen($dateParts[2]) <= 2) { // xxxx.xx.xx
 +
                    $string = strtotime($dateParts[0].'-'.$dateParts[1].'-'.$dateParts[2]); // change to timestamp
 +
                }
 +
                elseif (strlen($dateParts[0]) <= 2 && strlen($dateParts[1]) <= 2 && strlen($dateParts[2]) == 4) { // xx.xx.xxxx
 +
                    $string = strtotime($dateParts[2].'-'.$dateParts[1].'-'.$dateParts[0]); // change to timestamp
 +
                }
 +
                else { // error
 +
                    $error = 1; // error
 +
                }
 +
            } elseif (count($dateParts) === 5) { // only if there are five parts like "05.00.23.01.2009"
 +
                $string = strtotime($dateParts[4].'-'.$dateParts[3].'-'.$dateParts[2].' '.$dateParts[0].':'.$dateParts[1].':00'); // change to timestamp
 +
            } else { // more than 3 parts - so error
 +
                $error = 1; // error
 +
            }
 +
            $string = date('Y-m-d', $string); // For default: change 1234567 -> 1.1.1979
 +
            if ($timestamp) $string = strtotime($string); // Change back 1.1.1979 -> 1234567
 +
            if ($error) $string = ($default == 'now' ? time() : $default); // show default value
 +
       
 +
            return $string;
 +
        }
 +
    }
 +
 +
?>
 
</pre>
 
</pre>

Version vom 15. November 2011, 08:52 Uhr

Powermail Extension


Snippets

Formular in Datenbank speichern

plugin.tx_powermail_pi1{
    dbEntry {

        # Speicherung für Tabelle ermöglichen
        tt_address._enable = TEXT
        tt_address._enable.value = 1

        #  "tt_address.name" mit dem Wert des Powermail felds ausfüllen
        tt_content uid 88, field uid18 (###uid18###)
        tt_address.name = TEXT
        tt_address.name.data = TSFE:fe_user|sesData|powermail_88|uid18

    }
}

Ausführliches Beispiel

Constants

plugin.powermail.js.alwaysInclude = 1
plugin.powermail.js.includeJquery = 0
plugin.powermail.js.includeJqueryTools = 0
plugin.powermail.js.includeJqueryToolsTabs = 0
plugin.powermail.allow.email2sender = 0
plugin.powermail.PID.dblog = 0
plugin.powermail.markerALL.hideLabel = 1
plugin.powermail.format.datetime = %d.%m.%Y% %H:%M
plugin.powermail.format.date = %d.%m.%Y
plugin.powermail.debug.output = 

Setup

// CSS Pfad ändern (oder gar nicht erst statisch einbinden ;-)  )
page.includeCSS.powermail_frontend_basic = fileadmin/templates/onlineboerse/powermail.css

Datenbank Speicherung mit verschiedenen Optionen

// Powermail DB Storage // Extra userfunc to convert date to unix timestamp includeLibs.powermailTimestamp = fileadmin/templates/scripts/user_powermailTimestamp.php

plugin.tx_powermail_pi1.dbEntry{

 tx_gbbulletin_bulletin {
   _enable = TEXT
   _enable.value = 1
    
   hidden = TEXT
   hidden.value = 1
    
   pid = TEXT
   pid.value = 102
       
   tstamp = TEXT
   tstamp.data = date:U
        
   crdate = TEXT
   crdate.data = date:U
   title = TEXT
   title.data = TSFE:fe_user|sesData|powermail_214|uid1
   author = TEXT
   author.data = TSFE:fe_user|sesData|powermail_214|uid2
   place = TEXT
   place.data = TSFE:fe_user|sesData|powermail_214|uid3
   
   description = TEXT
   description.data = TSFE:fe_user|sesData|powermail_214|uid4
   contact = TEXT
   contact.data = TSFE:fe_user|sesData|powermail_214|uid5
   qualification = TEXT
   qualification.data = TSFE:fe_user|sesData|powermail_214|uid6
   
   date = USER
   date.userFunc = user_powermailTimestamp->preflight
   date.userFunc.field = uid7
   date.userFunc.formuid = 214
   
   period = TEXT
   period.data = TSFE:fe_user|sesData|powermail_214|uid29
   end_date = USER
   end_date.userFunc = user_powermailTimestamp->preflight
   end_date.userFunc.field = uid14
   end_date.userFunc.formuid = 214
   
   url = TEXT
   url.data = TSFE:fe_user|sesData|powermail_214|uid8
   text1 = TEXT
   text1.data = TSFE:fe_user|sesData|powermail_214|uid9
   
   cluster = TEXT
   cluster.data = TSFE:fe_user|sesData|powermail_214|uid11
   
   # add mm relation to uid 2 of tx_gbbulletin_cluster (via mm table)
   _mm = COA
   _mm.10 = COA
   # 1 is always the mm table
   _mm.10.1 = TEXT
   _mm.10.1.value = tx_gbbulletin_cluster_mm
   # 2 is always the other table
   _mm.10.2 = TEXT
   _mm.10.2.value = tx_gbbulletin_cluster
   # 3 is always the uid of the other table to get a relation to this
   # (in this case uid1 of tx_gbbulletin_cluster)
   _mm.10.3 = TEXT
   _mm.10.3.value = 1
   
   tag = TEXT
   tag.data = TSFE:fe_user|sesData|powermail_214|uid12
 }

}

Userfunktion zum umwandeln von Datum in Timestamp

Diese Funktion wird im obigen Beispiel zu Datenbankspeicherung verwendet

<?php 

    class user_powermailTimestamp { 
     
     
        // Function preflight() will be used from typoscript 
        function preflight($content='', $conf=array()) { 
            $value = $GLOBALS['TSFE']->fe_user->sesData['powermail_'.$conf['userFunc.']['formuid']][$conf['userFunc.']['field']]; 
            return $this->getDate($value); 
        } 
         
         
        // Main getDate() changes a date in any format to an unix timestamp 
        function getDate($string, $default = 'now', $timestamp = 1) { 
            $error = 0; // no error at the beginning 
            $string = str_replace(array('-', '_', ':', '+', ',', ' '), '.', $string); // change 23-12-2009 -> 23.12.2009 AND "05:00 23.01.2009" -> 05.00.23.01.2009 
            if (method_exists('t3lib_div', 'trimExplode')) $dateParts = t3lib_div::trimExplode('.', $string, 1); else $dateParts = explode('.', $string); // split at . 
         
            if (count($dateParts) === 3) { // only if there are three parts like "23.12.2009" 
                if (strlen($dateParts[0]) <= 2 && strlen($dateParts[1]) <= 2 && strlen($dateParts[2]) <= 2) { // xx.xx.xx 
                    $string = strtotime($dateParts[2].'-'.$dateParts[1].'-'.$dateParts[0]); // change to timestamp 
                } 
                elseif (strlen($dateParts[0]) == 4 && strlen($dateParts[1]) <= 2 && strlen($dateParts[2]) <= 2) { // xxxx.xx.xx 
                    $string = strtotime($dateParts[0].'-'.$dateParts[1].'-'.$dateParts[2]); // change to timestamp 
                } 
                elseif (strlen($dateParts[0]) <= 2 && strlen($dateParts[1]) <= 2 && strlen($dateParts[2]) == 4) { // xx.xx.xxxx 
                    $string = strtotime($dateParts[2].'-'.$dateParts[1].'-'.$dateParts[0]); // change to timestamp 
                } 
                else { // error 
                    $error = 1; // error 
                } 
            } elseif (count($dateParts) === 5) { // only if there are five parts like "05.00.23.01.2009" 
                $string = strtotime($dateParts[4].'-'.$dateParts[3].'-'.$dateParts[2].' '.$dateParts[0].':'.$dateParts[1].':00'); // change to timestamp 
            } else { // more than 3 parts - so error 
                $error = 1; // error 
            } 
            $string = date('Y-m-d', $string); // For default: change 1234567 -> 1.1.1979 
            if ($timestamp) $string = strtotime($string); // Change back 1.1.1979 -> 1234567 
            if ($error) $string = ($default == 'now' ? time() : $default); // show default value 
         
            return $string; 
        } 
    } 

?>