Skip to content

Commit

Permalink
Marker Bugfix
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/powermail/trunk@60493 735d13b6-9817-0410-8766-e36946ffe9aa
  • Loading branch information
wunschtacho committed Apr 8, 2012
1 parent c7d80fc commit 0107e4e
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 7 deletions.
70 changes: 70 additions & 0 deletions Classes/Utility/InitialMarker.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

/***************************************************************
* Copyright notice
*
* (c) 2012 Alex Kellner <[email protected]>, in2code.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 3 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!
***************************************************************/


/**
* Class to extend Pi1 field marker e.g. {firstname}
*
* @package powermail
* @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
*
*/
class Tx_Powermail_Utility_InitialMarker {

/**
* Initialy filling of marker field
*
* @param string $status mode of change
* @param string $table the table which gets changed
* @param string $id uid of the record
* @param array $fieldArray the updateArray
* @param array $this obj
* @return an updated fieldArray()
*/
public function processDatamap_postProcessFieldArray($status, $table, $id, &$fieldArray, $pObj) {
if ($table != 'tx_powermail_domain_model_fields') { // stop if not powermail field table
return $fieldArray;
}
if (!empty($fieldArray['marker'])) { // stop if marker field is already filled
return $fieldArray;
}
$fieldArray['marker'] = $this->cleanString($fieldArray['title']);
}

/**
* Clean Marker String ("My Field" => "my_field")
*
* @param string $string Any String
* @return string
*/
private function cleanString($string) {
$string = preg_replace('/[^a-zA-Z0-9_-]/', '', $string);
$string = str_replace(array('-'), '_', $string);
$string = strtolower($string);
return $string;
}
}
?>
8 changes: 4 additions & 4 deletions Classes/Utility/Marker.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@


/**
* Class to extend Pi1 field marker
* Class to extend Pi1 field marker e.g. {firstname}
*
* @package powermail
* @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
Expand All @@ -43,9 +43,9 @@ class Tx_Powermail_Utility_Marker {
*/
public function createMarker($PA, $fobj) {
$content = '';
if (isset($PA['row']['marker']) && !empty($PA['row']['marker'])) {
if (isset($PA['row']['marker']) && !empty($PA['row']['marker'])) { // if entry in db
$marker = $PA['row']['marker'];
} else {
} else { // no entry
$marker = $PA['row']['title'];
}
$marker = preg_replace('/[^a-zA-Z0-9_-]/', '', $marker);
Expand All @@ -67,7 +67,7 @@ public function createMarker($PA, $fobj) {
}

/**
* Workarround to only show a label and no field
* Workarround to only show a label and no field in TCA
*
* @param array Config Array
* @param object Parent Object
Expand Down
4 changes: 2 additions & 2 deletions Resources/Private/Language/locallang_db.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
<label index="tx_powermail_domain_model_fields.sender_name">This field contains the Name of the sender</label>
<label index="tx_powermail_domain_model_fields.marker_title">Variablen</label>
<label index="tx_powermail_domain_model_fields.own_marker">Enter your own Variable Name</label>
<label index="tx_powermail_domain_model_fields.auto_marker">Individual Fieldname to use as Variable (wrapped with {})</label>
<label index="tx_powermail_domain_model_fields.auto_marker">Individual Fieldname to use as Variable (automaticly wrapped with {})</label>
<label index="tx_powermail_domain_model_fields.own_marker_select">Add my own Variable Name</label>
<label index="tx_powermail_domain_model_fields.sheet1">Extended</label>
<label index="tx_powermail_domain_model_fields.sheet2">Marketing</label>
Expand Down Expand Up @@ -234,7 +234,7 @@
<label index="tx_powermail_domain_model_fields.sender_email">Dieses Feld beinhaltet die E-Mail des Absenders</label>
<label index="tx_powermail_domain_model_fields.sender_name">Dieses Feld beinhaltet den Namen des Absenders</label>
<label index="tx_powermail_domain_model_fields.marker_title">Variablen</label>
<label index="tx_powermail_domain_model_fields.own_marker">Variablenname (eingeschlossen in {})</label>
<label index="tx_powermail_domain_model_fields.own_marker">Variablenname (ohne umschließende {})</label>
<label index="tx_powermail_domain_model_fields.auto_marker">Variablenname für dieses Feld</label>
<label index="tx_powermail_domain_model_fields.own_marker_select">Eigenen Variablennamen vergeben</label>
<label index="tx_powermail_domain_model_fields.sheet1">Erweitert</label>
Expand Down
6 changes: 6 additions & 0 deletions ext_localconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info'][$_EXTKEY . '_pi1'][$_EXTKEY] =
'EXT:' . $_EXTKEY . '/Classes/Utility/PluginInfo.php:Tx_Powermail_Utility_PluginInfo->getInfo';

/**
* Hooking for first fill of marker field in backend
*/
$GLOBALS ['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] =
'EXT:' . $_EXTKEY . '/Classes/Utility/InitialMarker.php:Tx_Powermail_Utility_InitialMarker';

/**
* Extra evaluation of TCA fields
*/
Expand Down
2 changes: 1 addition & 1 deletion todos.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ x backend module reporting fields
x backend module reporting marketing
x backend check (session is working, etc...)
o dynamic field preview
o Bugfix Marker Backend
=> Bugfix Marker Backend
x prefill
x all fields marker
x validation js
Expand Down

0 comments on commit 0107e4e

Please sign in to comment.