protected function parseItem($objItem, $strClass = '', $intCount = 0) { // work on a cloned item for supporting multiple reader modules on a single page $objItemTmp = unserialize(serialize($objItem)); // prepare item $objDc = new \DC_Table($this->formHybridDataContainer); $objDc->activeRecord = $objItemTmp; // untransformed values in the raw array $objItemTmp->raw = $objItemTmp->row(); // transform and escape values foreach ($objItemTmp->row() as $strField => $varValue) { if ($strField == 'raw') { continue; } $varValue = FormSubmission::prepareSpecialValueForPrint($varValue, $this->dca['fields'][$strField], $this->formHybridDataContainer, $objDc, $objItemTmp); $objItemTmp->{$strField} = FormHelper::escapeAllEntities($this->formHybridDataContainer, $strField, $varValue); } if ($this->publishedField) { $objItemTmp->isPublished = $this->invertPublishedField ? !$objItemTmp->{$this->publishedField} : $objItemTmp->{$this->publishedField}; } $objTemplate = new \FrontendTemplate($this->itemTemplate ?: 'formhybrid_reader_default'); // items contain module and item params (higher priority: item) $objTemplate->setData($objItemTmp->row() + $this->arrData); $objTemplate->class = $strClass; $objTemplate->formHybridDataContainer = $this->formHybridDataContainer; $objTemplate->useDummyImage = $this->useDummyImage; $objTemplate->dummyImage = $this->dummyImage; $objTemplate->imgSize = deserialize($this->imgSize, true); $this->runBeforeTemplateParsing($objTemplate, $objItemTmp); // HOOK: add custom logic if (isset($GLOBALS['TL_HOOKS']['parseItems']) && is_array($GLOBALS['TL_HOOKS']['parseItems'])) { foreach ($GLOBALS['TL_HOOKS']['parseItems'] as $callback) { $this->import($callback[0]); $this->{$callback}[0]->{$callback}[1]($objTemplate, $objItemTmp, $this); } } return $objTemplate->parse(); }
protected function generateFields($objItem) { $arrItem = array(); $arrDca =& $GLOBALS['TL_DCA'][$this->formHybridDataContainer]; // always add id $arrItem['raw']['id'] = $objItem->id; $objDc = new \DC_Table($this->formHybridDataContainer); $objDc->activeRecord = $objItem; if ($this->isTableList) { foreach ($this->arrTableFields as $strField) { $arrItem['fields'][$strField] = FormSubmission::prepareSpecialValueForPrint($objItem->{$strField}, $this->dca['fields'][$strField], $this->formHybridDataContainer, $objDc, $objItem); if (is_array($arrDca['fields'][$strField]['load_callback'])) { foreach ($arrDca['fields'][$strField]['load_callback'] as $callback) { $this->import($callback[0]); $arrItem['fields'][$strField] = $this->{$callback}[0]->{$callback}[1]($arrItem['fields'][$strField], $objDc); } } // anti-xss: escape everything besides some tags $arrItem['fields'][$strField] = FormHelper::escapeAllEntities($this->formHybridDataContainer, $strField, $arrItem['fields'][$strField]); } } else { foreach ($arrDca['fields'] as $strField => $arrData) { $arrItem['fields'][$strField] = FormSubmission::prepareSpecialValueForPrint($objItem->{$strField}, $this->dca['fields'][$strField], $this->formHybridDataContainer, $objDc, $objItem); // anti-xss: escape everything besides some tags $arrItem['fields'][$strField] = FormHelper::escapeAllEntities($this->formHybridDataContainer, $strField, $arrItem['fields'][$strField]); } } // add raw values foreach ($GLOBALS['TL_DCA'][$this->formHybridDataContainer]['fields'] as $strField => $arrData) { $arrItem['raw'][$strField] = $objItem->{$strField}; } if ($this->publishedField) { $arrItem['isPublished'] = $this->invertPublishedField ? !$objItem->{$this->publishedField} : $objItem->{$this->publishedField}; } return $arrItem; }