Skip to content

Commit

Permalink
fixed: csv export with required filters and a filter set were not exp…
Browse files Browse the repository at this point in the history
…orting correct records.

changed: set plugin _recordInDatabase property to protected
  • Loading branch information
pollen8 committed Sep 18, 2012
1 parent 70ca317 commit 38fc412
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
6 changes: 4 additions & 2 deletions components/com_fabrik/models/element.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class plgFabrik_Element extends FabrikPlugin
*
* @var bol
*/
var $_recordInDatabase = 1;
protected $_recordInDatabase = 1;

/**
* Contain access rights
Expand Down Expand Up @@ -3016,7 +3016,9 @@ protected function getFilterHiddenFields($counter, $elName, $hidden = false)
* $condition = JArrayHelper::getValue($condition, $counter, $this->getFilterCondition());
*/
$condition = $this->getFilterCondition();
$prefix = '<input type="hidden" name="fabrik___filter[list_' . $this->getListModel()->getRenderContext() . ']';

// Need to include class other wise csv export produces incorrect results when exporting
$prefix = '<input type="hidden" class="fabrik_filter" name="fabrik___filter[list_' . $this->getListModel()->getRenderContext() . ']';
$return[] = $prefix . '[condition][' . $counter . ']" value="' . $condition . '" />';
$return[] = $prefix . '[join][' . $counter . ']" value="AND" />';
$return[] = $prefix . '[key][' . $counter . ']" value="' . $elName . '" />';
Expand Down
26 changes: 17 additions & 9 deletions components/com_fabrik/views/list/view.csv.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@
class FabrikViewList extends JView
{

public function display()
/**
* Execute and display a template script.
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return mixed A string if successful, otherwise a JError object.
*/

public function display($tpl = null)
{
$session = JFactory::getSession();
$exporter = JModel::getInstance('Csvexport', 'FabrikFEModel');
Expand All @@ -26,7 +34,7 @@ public function display()
JRequest::setVar('limit' . $model->getId(), $exporter->_getStep());

// $$$ rob moved here from csvimport::getHeadings as we need to do this before we get
// the table total
// the list total
$selectedFields = JRequest::getVar('fields', array(), 'default', 'array');
$model->setHeadingsForCSV($selectedFields);

Expand All @@ -35,13 +43,6 @@ public function display()

$total = $model->getTotalRecords();

if ((int) $total === 0)
{
$notice = new stdClass;
$notice->err = JText::_('COM_FABRIK_CSV_EXPORT_NO_RECORDS');
echo json_encode($notice);
return;
}
$key = 'fabrik.table.' . $model->getId() . 'csv.total';
if (is_null($session->get($key)))
{
Expand All @@ -51,6 +52,13 @@ public function display()
$start = JRequest::getInt('start', 0);
if ($start <= $total)
{
if ((int) $total === 0)
{
$notice = new stdClass;
$notice->err = JText::_('COM_FABRIK_CSV_EXPORT_NO_RECORDS');
echo json_encode($notice);
return;
}
$exporter->writeFile($total);
}
else
Expand Down
10 changes: 8 additions & 2 deletions plugins/fabrik_element/timestamp/timestamp.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,17 @@ class plgFabrik_ElementTimestamp extends plgFabrik_Element
/**
* If the element 'Include in search all' option is set to 'default' then this states if the
* element should be ignored from search all.
*
* @var bool True, ignore in advanced search all.
*/
protected $ignoreSearchAllDefault = true;

var $_recordInDatabase = false;
/**
* Does the element's data get recorded in the db
*
* @var bol
*/
protected $_recordInDatabase = false;

/**
* Get the element's HTML label
Expand Down Expand Up @@ -67,7 +73,7 @@ public function setIsRecordedInDatabase()
* @return string elements html
*/

function render($data, $repeatCounter = 0)
public function render($data, $repeatCounter = 0)
{
$name = $this->getHTMLName($repeatCounter);
$id = $this->getHTMLId($repeatCounter);
Expand Down

0 comments on commit 38fc412

Please sign in to comment.