';
return [
'html' => $table,
'countRows' => $totalRows,
'countPages' => $totalPages
];
}
catch (NotFoundException $e) {
$this->getLog()->info('Request failed for dataSet id=%d. Widget=%d. Due to %s', $dataSetId, $this->getWidgetId(), $e->getMessage());
$this->getLog()->debug($e->getTraceAsString());
return '';
}
}
/**
* Does this module have a DataSet yet?
* @return bool
*/
private function hasDataSet()
{
return (v::notEmpty()->validate($this->getOption('dataSetId')));
}
/** @inheritdoc */
public function isValid()
{
if ($this->getUseDuration() == 1 && $this->getDuration() == 0)
throw new InvalidArgumentException(__('Please enter a duration'), 'duration');
if (!is_numeric($this->getOption('upperLimit')) || !is_numeric($this->getOption('lowerLimit')))
throw new InvalidArgumentException(__('Limits must be numbers'), 'limit');
if ($this->getOption('upperLimit') < 0 || $this->getOption('lowerLimit') < 0)
throw new InvalidArgumentException(__('Limits cannot be lower than 0'), 'limit');
// Check the bounds of the limits
if ($this->getOption('upperLimit') != 0 && $this->getOption('upperLimit') < $this->getOption('lowerLimit'))
throw new InvalidArgumentException(__('Upper limit must be higher than lower limit'), 'limit');
if ($this->getOption('updateInterval') !== null && !v::intType()->min(0)->validate($this->getOption('updateInterval', 0)))
throw new InvalidArgumentException(__('Update Interval must be greater than or equal to 0'), 'updateInterval');
// Make sure we haven't entered a silly value in the filter
if (strstr($this->getOption('filter'), 'DESC'))
throw new InvalidArgumentException(__('Cannot user ordering criteria in the Filter Clause'), 'filter');
return ($this->hasDataSet()) ? self::$STATUS_VALID : self::$STATUS_INVALID;
}
/** @inheritdoc */
public function getModifiedDate($displayId)
{
$widgetModifiedDt = $this->widget->modifiedDt;
$dataSetId = $this->getOption('dataSetId');
$dataSet = $this->dataSetFactory->getById($dataSetId);
// Set the timestamp
$widgetModifiedDt = ($dataSet->lastDataEdit > $widgetModifiedDt) ? $dataSet->lastDataEdit : $widgetModifiedDt;
// Remote dataSets are kept "active" by required files
$dataSet->setActive();
return $this->getDate()->parse($widgetModifiedDt, 'U');
}
/** @inheritdoc */
public function getCacheDuration()
{
return $this->getOption('updateInterval', 120) * 60;
}
/** @inheritdoc */
public function getCacheKey($displayId)
{
// DataSetViews are display specific
return $this->getWidgetId() . '_' . $displayId;
}
/** @inheritdoc */
public function isCacheDisplaySpecific()
{
return true;
}
/** @inheritdoc */
public function getLockKey()
{
// Lock to the dataSetId, because our dataSet might have external images which are downloaded.
return $this->getOption('dataSetId');
}
}