/** * Processes the form of this table, will execute the model query and assign the result to the values * of this table * @return boolean If the form was already processed, nothing is done and false returned. Otherwise the form * will be processed and true returned */ public function processForm() { if (!parent::processForm()) { return false; } if (!$this->pageRows || $this->pageRows && $this->countRows) { $this->values = $this->query->query(); } return true; }
/** * Gets the result from the query * @param zibo\library\orm\model\Model $model * @param zibo\library\orm\query\ModelQuery $query * @param joppa\content\model\ContentProperties $properties * @return array Array with Content objects */ private function getResult($model, $query, ContentProperties $contentProperties) { $result = $query->query(); if (!$result) { return $result; } $meta = $model->getMeta(); $modelTable = $meta->getModelTable(); $dataFormatter = $meta->getDataFormatter(); $titleFormat = $contentProperties->getContentTitleFormat(); if (!$titleFormat && $modelTable->hasDataFormat(DataFormatter::FORMAT_TITLE)) { $titleFormat = $modelTable->getDataFormat(DataFormatter::FORMAT_TITLE)->getFormat(); } $teaserFormat = $contentProperties->getContentTeaserFormat(); if (!$teaserFormat && $modelTable->hasDataFormat(DataFormatter::FORMAT_TEASER)) { $teaserFormat = $modelTable->getDataFormat(DataFormatter::FORMAT_TEASER)->getFormat(); } $imageFormat = $modelTable->getDataFormat(DataFormatter::FORMAT_IMAGE, false); if ($imageFormat) { $imageFormat = $imageFormat->getFormat(); } $dateFormat = $modelTable->getDataFormat(DataFormatter::FORMAT_DATE, false); if ($dateFormat) { $dateFormat = $dateFormat->getFormat(); } try { $mapper = ContentFacade::getInstance()->getMapper($model->getName()); } catch (ZiboException $e) { $mapper = null; } foreach ($result as $index => $data) { $title = $dataFormatter->formatData($data, $titleFormat); $url = null; $teaser = null; $image = null; $date = null; if ($teaserFormat) { $teaser = $dataFormatter->formatData($data, $teaserFormat); } if ($imageFormat) { $image = $dataFormatter->formatData($data, $imageFormat); } if ($dateFormat) { $date = $dataFormatter->formatData($data, $dateFormat); } if ($mapper) { $url = $mapper->getUrl($data); } $content = new Content($title, $url, $teaser, $image, $date, $data); $result[$index] = $content; } return $result; }