Skip to content

Commit

Permalink
Pi2: Working Checkin
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/powermail/trunk@60483 735d13b6-9817-0410-8766-e36946ffe9aa
  • Loading branch information
wunschtacho committed Apr 7, 2012
1 parent 82e3665 commit f184122
Show file tree
Hide file tree
Showing 8 changed files with 171 additions and 20 deletions.
53 changes: 53 additions & 0 deletions Classes/Controller/OutputController.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,59 @@ public function updateAction(Tx_Powermail_Domain_Model_Mails $mail, $field = arr
$this->redirect('edit', null, null, array('mail' => $mail));
}

/**
* Export mails
*
* @param $export Field Array with mails and format
* @dontvalidate $export
* @return void
*/
public function exportAction($export = array()) {
if (!$this->settings['list']['export']) {
return;
}
$mails = $this->mailsRepository->findByUidList($export['fields']);

// get field array for output
$fields = t3lib_div::trimExplode(',', $this->settings['list']['fields'], 1);
if (!$fields) {
$fields = $this->div->getFieldsFromForm($this->settings['main']['form']);
}

if ($export['format'] == 'xls') {
$this->forward('exportXls', NULL, NULL, array('mails' => $mails, 'fields' => $fields));
}
$this->forward('exportCsv', NULL, NULL, array('mails' => $mails, 'fields' => $fields));
}

/**
* Export mails XLS
*
* @param array $mails mails objects
* @param array $fields uid field list
* @dontvalidate $mails
* @dontvalidate $fields
* @return void
*/
public function exportXlsAction($mails = array(), $fields = array()) {
$this->view->assign('mails', $mails);
$this->view->assign('fields', $fields);
}

/**
* Export mails CSV
*
* @param array $mails mails objects
* @param array $fields uid field list
* @dontvalidate $mails
* @dontvalidate $fields
* @return void
*/
public function exportCsvAction($mails = array(), $fields = array()) {
$this->view->assign('mails', $mails);
$this->view->assign('fields', $fields);
}

/**
* Deactivate errormessages in flashmessages
*
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Repository/MailsRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public function findFirstInPid($pid = 0) {
* @param array Sorting array('field' => 'asc')
* @return Query Object
*/
public function findByUidList($uidList, $sorting) {
public function findByUidList($uidList, $sorting = array()) {
// settings
$uids = t3lib_div::trimExplode(',', $uidList, 1);
$query = $this->createQuery(); // initialize query
Expand Down
30 changes: 30 additions & 0 deletions Classes/ViewHelpers/String/ImplodeUidViewHelper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

/**
* View helper to implode objects to a list
*
* @package TYPO3
* @subpackage Fluid
*/
class Tx_Powermail_ViewHelpers_String_ImplodeUidViewHelper extends Tx_Fluid_ViewHelpers_Form_AbstractFormFieldViewHelper {

/**
* View helper to explode a list
*
* @param objects Any objects with submethod getUid()
* @param string Separator sign (e.g. ",")
* @return string
*/
public function render($objects, $separator = ',') {
$string = '';
foreach ($objects as $object) {
if (method_exists($object, 'getUid')) {
$string .= $object->getUid();
$string .= $separator;
}
}
return substr($string, 0, (-1 * strlen($separator)));
}
}

?>
4 changes: 2 additions & 2 deletions Configuration/FlexForms/flexform_pi2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
<items type="array">
<numIndex index="0" type="array">
<numIndex index="0">LLL:EXT:powermail/Resources/Private/Language/locallang_db.xml:flexform_pi2.main.switchableControllerActions.0</numIndex>
<numIndex index="1">Output->list;Output->show;</numIndex>
<numIndex index="1">Output->list;Output->show;Output->export;</numIndex>
</numIndex>
<numIndex index="1" type="array">
<numIndex index="0">LLL:EXT:powermail/Resources/Private/Language/locallang_db.xml:flexform_pi2.main.switchableControllerActions.1</numIndex>
<numIndex index="1">Output->list;Output->show;</numIndex>
<numIndex index="1">Output->list;Output->show;Output->export;</numIndex>
</numIndex>
<numIndex index="2" type="array">
<numIndex index="0">LLL:EXT:powermail/Resources/Private/Language/locallang_db.xml:flexform_pi2.main.switchableControllerActions.2</numIndex>
Expand Down
10 changes: 2 additions & 8 deletions Resources/Private/Partials/Module/ExportBe.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,8 @@ <h4 class="extended_export_title close">
</div>
</div>

<input type="hidden" name="tx_powermail_web_powermailm1[export][fields]"
value="<f:for each="{firstMail.answers}" as="answer" iteration="index">{answer.field}<f:if condition="{index.isLast}"><f:else>,</f:else></f:if></f:for>"
id="export_fields" />

<input type="hidden" name="tx_powermail_web_powermailm1[export][mails]"
value="<f:for each="{mails}" as="mail" iteration="index">{mail.uid}<f:if condition="{index.isLast}"><f:else>,</f:else></f:if></f:for>"
id="export_mails" />

<f:form.hidden property="fields" value="{vh:String.ImplodeUid(objects: '{firstMail.answers}')}" id="export_fields" />
<f:form.hidden property="mails" value="{vh:String.ImplodeUid(objects: '{mails}')}" id="export_mails" />
<f:form.hidden property="format" value="xls" id="export_format" />

<f:if condition="{piVars.sorting}">
Expand Down
9 changes: 2 additions & 7 deletions Resources/Private/Partials/Output/Export.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,8 @@
<f:image src="{f:uri.resource(path: 'Image/icon_csv.gif')}" alt="CSV" class="export_icon export_icon_csv" />
</f:if>

<f:for each="{mails}" as="{mail}">
<input type="hidden" name="tx_powermail_pi2[export][fields]"
value="<f:for each="{mails}" as="mail" iteration="index">{mail.uid}<f:if condition="{index.isLast}"><f:else>,</f:else></f:if></f:for>"
id="export_fields" />
</f:for>

<f:form.hidden name="format" value="" id="export_format" />
<f:form.hidden name="export[fields]" value="{vh:String.ImplodeUid(objects: '{mails}')}" id="export_mails" />
<f:form.hidden name="export[format]" value="" id="export_format" />

<div class="clear"></div>
</div>
Expand Down
79 changes: 79 additions & 0 deletions Resources/Private/Templates/Output/ExportXls.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{namespace vh=Tx_Powermail_ViewHelpers}
<f:layout name="Export" />

Render Powermail XLS Export
{mails} All Mails for exporting
{fields} Fields to export (drag'n drop settings in module)

<f:section name="main">

<vh:String.Utf8Decode>
<table>
<f:for each="{mails}" as="mail" iteration="index">
<f:if condition="{index.isFirst}">
<tr>
<f:for each="{fields}" as="field">
<th>
<f:if condition="{vh:Condition.IsNumber(val: '{field}')}">
<f:then>
<vh:Getter.GetFieldLabelFromUid uid="{field}" />
</f:then>
<f:else>
<f:translate key="Tx_Powermail_Domain_Model_Mails.{vh:String.UnderscoredToLowerCamelCase(val: '{field}')}" />
</f:else>
</f:if>
</th>
</f:for>
</tr>
</f:if>


<tr>
<f:for each="{fields}" as="field">
<td>
<f:if condition="{vh:Condition.IsNumber(val: '{field}')}">
<f:then>
<f:for each="{mail.answers}" as="answer">
<f:if condition="{field} == {answer.field}">
{answer.value}
</f:if>
</f:for>
</f:then>
<f:else>
<f:if condition="{vh:Condition.IsDateTimeVariableInVariable(obj: '{mail}', prop: '{field}')}">
<f:then>
<f:if condition="{0 : field} == {0 : 'crdate'}">
<f:then>
<f:format.date format="d.m.Y H:i:s"><vh:Misc.VariableInVariable obj="{mail}" prop="{field}" /></f:format.date>
<f:translate key="Clock" />
</f:then>
<f:else>
<f:format.date format="H:i:s"><vh:Misc.VariableInVariable obj="{mail}" prop="{field}" /></f:format.date>
</f:else>
</f:if>
</f:then>
<f:else>
<f:if condition="{0 : field} == {0 : 'marketing_funnel'}">
<f:then>
<f:if condition="{vh:Condition.IsArray(val: '{vh:Misc.VariableInVariable(obj: \'{mail}\', prop: \'{field}\')}')}">
<f:for each="{vh:Misc.VariableInVariable(obj: '{mail}', prop: '{field}')}" as="pid" iteration="pageIndex">
<vh:Getter.GetPageNameFromUid uid="{pid}" /><f:if condition="{pageIndex.isLast}"><f:else> &gt; </f:else></f:if>
</f:for>
</f:if>
</f:then>
<f:else>
<vh:Misc.VariableInVariable obj="{mail}" prop="{field}" />
</f:else>
</f:if>
</f:else>
</f:if>
</f:else>
</f:if>
</td>
</f:for>
</tr>
</f:for>
</table>
</vh:String.Utf8Decode>

</f:section>
4 changes: 2 additions & 2 deletions ext_localconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
$_EXTKEY,
'Pi2',
array(
'Output' => 'list, show, edit, update'
'Output' => 'list, show, edit, update, export'
),
array(
'Output' => 'list, edit, update'
'Output' => 'list, edit, update, export'
)
);

Expand Down

0 comments on commit f184122

Please sign in to comment.