Skip to content
Snippets Groups Projects
Commit f2da9b88 authored by jaapjansma's avatar jaapjansma
Browse files

Added Field Output Handler for clean file names.

parent d153f055
No related branches found
No related tags found
No related merge requests found
# Version 1.32 (not yet released)
# Version 1.32
* Added Field Output Handler for clean file names. E.g. change `Expense/2/receipt_802fd5cd009e0a39cf2202f4bfb9c0b4.pdf`
into `receipt.pdf`.
# Version 1.31
......
......@@ -160,6 +160,7 @@ class Factory {
$this->addjoinType('simple_join', new Definition('Civi\DataProcessor\DataFlow\MultipleDataFlows\SimpleJoin'), E::ts('Select fields to join on'));
$this->addjoinType('simple_non_required_join', new Definition('Civi\DataProcessor\DataFlow\MultipleDataFlows\SimpleNonRequiredJoin'), E::ts('Select fields to join on (not required)'));
$this->addOutputHandler('raw', new Definition('Civi\DataProcessor\FieldOutputHandler\RawFieldOutputHandler'), E::ts('Raw field value'));
$this->addOutputHandler('cleanfilename', new Definition('Civi\DataProcessor\FieldOutputHandler\CleanFileNameFieldOutputHandler'), E::ts('Clean File Name'));
$this->addOutputHandler('markup', new Definition('Civi\DataProcessor\FieldOutputHandler\MarkupFieldOutputHandler'), E::ts('Markup/Html field value'));
$this->addOutputHandler('formatted_address', new Definition('Civi\DataProcessor\FieldOutputHandler\FormattedAddressFieldOutputHandler'), E::ts('Formatted Address'));
$this->addOutputHandler('worldregion', new Definition('Civi\DataProcessor\FieldOutputHandler\WorldRegionFieldOutputHandler'), E::ts('Worldregion'));
......
<?php
/**
* @author Jaap Jansma <jaap.jansma@civicoop.org>
* @license AGPL-3.0
*/
namespace Civi\DataProcessor\FieldOutputHandler;
use CRM_Dataprocessor_ExtensionUtil as E;
class CleanFileNameFieldOutputHandler extends AbstractSimpleFieldOutputHandler {
/**
* Returns the formatted value
*
* @param $rawRecord
* @param $formattedRecord
*
* @return \Civi\DataProcessor\FieldOutputHandler\FieldOutput
*/
public function formatField($rawRecord, $formattedRecord) {
$value = $rawRecord[$this->inputFieldSpec->alias];
$value = \CRM_Utils_File::cleanFileName(basename($value));
return new FieldOutput($value);
}
/**
* Returns the label of the field for selecting a field.
*
* This could be override in a child class.
*
* @return string
*/
protected function getFieldTitle() {
return E::ts('Filename/Path/Uri Field');
}
}
......@@ -14,8 +14,8 @@
<url desc="Documentation">https://lab.civicrm.org/extensions/dataprocessor/blob/master/README.md</url>
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2021-02-08</releaseDate>
<version>1.32-dev</version>
<releaseDate>2021-02-09</releaseDate>
<version>1.32</version>
<develStage>stable</develStage>
<compatibility>
<ver>4.7</ver>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment