Skip to content

Commit

Permalink
Add export modes
Browse files Browse the repository at this point in the history
  • Loading branch information
nilshoerrmann committed Jun 22, 2014
1 parent cd98856 commit 81c71be
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
7 changes: 5 additions & 2 deletions extension.meta.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@
</author>
</authors>
<releases>
<release version="1.4.0" date="2013-06-22" min="2.3">
- Added export modes
</release>
<release version="1.3.1" date="2013-02-16" min="2.3">
- Allow reflection field to recalculate data when field is toggled from publish indexes
- Fix issue when an installation has no Utilities
</release>
<release version="1.3" date="2012-08-08" min="2.3">
<release version="1.3.0" date="2012-08-08" min="2.3">
- Made compatible with Symphony 2.3
</release>
<release version="1.2" date="2011-07-26" min="2.2" max="2.3" />
<release version="1.2.0" date="2011-07-26" min="2.2" max="2.3" />
<release version="1.0.11" date="2011-04-11" min="2.2">
- Force tables to be created with the MyISAM table engine.
</release>
Expand Down
41 changes: 40 additions & 1 deletion fields/field.reflection.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

if (!defined('__IN_SYMPHONY__')) die('<h2>Symphony Error</h2><p>You cannot directly access this file</p>');
require_once FACE . '/interface.exportablefield.php';

class FieldReflection extends Field {
class FieldReflection extends Field implements ExportableField {
protected static $compiling = 0;

/*-------------------------------------------------------------------------
Expand Down Expand Up @@ -285,6 +286,44 @@ public function prepareTableValue($data, XMLElement $link = null) {
), $link
);
}
/*-------------------------------------------------------------------------
Export:
-------------------------------------------------------------------------*/

/**
* Return a list of supported export modes for use with `prepareExportValue`.
*
* @return array
*/
public function getExportModes()
{
return array(
'getValue' => ExportableField::VALUE,
'getFormatted' => ExportableField::FORMATTED
);
}

/**
* Give the field some data and ask it to return a value using one of many
* possible modes.
*
* @param mixed $data
* @param integer $mode
* @param integer $entry_id
* @return string|null
*/
public function prepareExportValue($data, $mode, $entry_id = null)
{
$modes = (object)$this->getExportModes();

if ($mode === $modes->getValue) {
return $data['value'];
} elseif($mode === $modes->getFORMATTED) {
return $data['value_formatted'];
}

return null;
}

/*-------------------------------------------------------------------------
Compile:
Expand Down

0 comments on commit 81c71be

Please sign in to comment.