private function getRealData()
{
// no search term = no search
if (!$this->term) {
return;
}
// set url
$this->pagination['url'] = FrontendNavigation::getURLForBlock('Search') . '?form=search&q=' . $this->term;
// populate calculated fields in pagination
$this->pagination['limit'] = $this->limit;
$this->pagination['offset'] = $this->offset;
$this->pagination['requested_page'] = $this->requestedPage;
// get items
$this->items = FrontendSearchModel::search($this->term, $this->pagination['limit'], $this->pagination['offset']);
// populate count fields in pagination
// this is done after actual search because some items might be
// activated/deactivated (getTotal only does rough checking)
$this->pagination['num_items'] = FrontendSearchModel::getTotal($this->term);
$this->pagination['num_pages'] = (int) ceil($this->pagination['num_items'] / $this->pagination['limit']);
// num pages is always equal to at least 1
if ($this->pagination['num_pages'] == 0) {
$this->pagination['num_pages'] = 1;
}
// error if the request page doesn't exist
if ($this->requestedPage > $this->pagination['num_pages'] || $this->requestedPage < 1) {
throw new FrontendException('the request page doesn\'t exist');
}
// debug mode = no cache
if (!SPOON_DEBUG) {
// set cache content
$filesystem = new Filesystem();
$filesystem->dumpFile($this->cacheFile, "<?php\n" . '$pagination = ' . var_export($this->pagination, true) . ";\n" . '$items = ' . var_export($this->items, true) . ";\n?>");
}
}