/** * Format element answer data into an array * Include links in PDF files for the file and thumbnail * * @param array $elementAnswers * * @return array */ public function formatApplicantArray(array $elementAnswers) { $arr = parent::formatApplicantArray($elementAnswers); $arr['filePath'] = false; $arr['thumbnailPath'] = false; foreach ($elementAnswers as $elementAnswer) { $arr['values'][] = $this->arrayValue($elementAnswer); } if ($arr['values'][0]['value']) { $base = $this->_element->getTitle() . '_' . $elementAnswer['id']; //remove slashes in path to fix an apache issues with encoding slashes in redirects $base = str_replace(array('/', '\\'), 'slash', $base); $name = $base . '.pdf'; \Jazzee\Globals::getFileStore()->createSessionFile($name, $arr['values'][0]['value']); $arr['filePath'] = \Jazzee\Globals::path('file/' . \urlencode($name)); if (!empty($arr['values'][1]['value'])) { $name = $base . '.png'; \Jazzee\Globals::getFileStore()->createSessionFile($name, $arr['values'][1]['value']); $arr['thumbnailPath'] = \Jazzee\Globals::path('file/' . \urlencode($name)); } else { $arr['thumbnailPath'] = \Jazzee\Globals::path('resource/foundation/media/default_pdf_logo.png'); } $arr['displayValue'] = "<a href='{$arr['filePath']}'><img src='{$arr['thumbnailPath']}' /></a>"; } return $arr; }