示例#1
0
 /**
  * Format an answer attachment
  * @param \array $attachment
  * @param \Jazzee\Entity\Page $page
  * 
  * @return array
  */
 protected function arrayAnswerAttachment(array $attachment, \Jazzee\Entity\Page $page)
 {
     $attachment['filePath'] = false;
     $attachment['thumbnailPath'] = false;
     $base = $page->getTitle() . '_attachment_' . $attachment['id'];
     //remove slashes in path to fix an apache issues with encoding slashes in redirects
     $base = str_replace(array('/', '\\'), 'slash', $base);
     $pdfName = $base . '.pdf';
     $pngName = $base . 'preview.png';
     \Jazzee\Globals::getFileStore()->createSessionFile($pdfName, $attachment['attachmentHash']);
     $attachment['filePath'] = \Jazzee\Globals::path('file/' . \urlencode($pdfName));
     if (!empty($attachment['thumbnailHash'])) {
         \Jazzee\Globals::getFileStore()->createSessionFile($pngName, $arr['thumbnailHash']);
         $attachment['thumbnailPath'] = \Jazzee\Globals::path('file/' . \urlencode($pngName));
     } else {
         $attachment['thumbnailPath'] = \Jazzee\Globals::path('resource/foundation/media/default_pdf_logo.png');
     }
     $attachment['displayValue'] = "<a href='{$attachment['filePath']}'><img src='{$attachment['thumbnailPath']}' /></a>";
     return $attachment;
 }
示例#2
0
 /**
  * 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;
 }
示例#3
0
 /**
  * Format applicant Array removing non-display values so the resulting array 
  * is smaller
  *
  * @param array $applicant
  * 
  * @return array
  */
 public function formatApplicantDisplayArray(array $applicant)
 {
     $applicant = $this->formatApplicantArray($applicant);
     $fileStore = \Jazzee\Globals::getFileStore();
     $attachments = array();
     foreach ($applicant['attachments'] as $attachment) {
         $base = $applicant['fullName'] . '_attachment_' . '_' . $attachment['id'];
         //remove slashes in path to fix an apache issues with encoding slashes in redirects
         $base = str_replace(array('/', '\\'), 'slash', $base);
         $name = $base . '.pdf';
         $fileStore->createSessionFile($name, $attachment['attachmentHash']);
         $attachment['filePath'] = \Jazzee\Globals::path('file/' . \urlencode($name));
         if ($attachment['thumbnailHash'] != null) {
             $name = $base . '.png';
             $fileStore->createSessionFile($name, $attachment['thumbnailHash']);
             $attachment['thumbnailPath'] = \Jazzee\Globals::path('file/' . \urlencode($name));
         } else {
             $attachment['thumbnailPath'] = \Jazzee\Globals::path('resource/foundation/media/default_pdf_logo.png');
         }
         $attachment['displayValue'] = "<a href='{$attachment['filePath']}'><img src='{$attachment['thumbnailPath']}' /></a>";
         $attachments[] = $attachment;
     }
     $applicant['attachments'] = $attachments;
     return $applicant;
 }
示例#4
0
 /**
  * Get an applicants pdfs
  * @param \Jazzee\Entity\Applicant $applicant
  */
 public function getAttachments(\Jazzee\Entity\Applicant $applicant)
 {
     $attachments = array('attachments' => array(), 'allowAttach' => $this->checkIsAllowed($this->controllerName, 'attachApplicantPdf'), 'allowDelete' => $this->checkIsAllowed($this->controllerName, 'deleteApplicantPdf'));
     foreach ($applicant->getAttachments() as $attachment) {
         $base = $applicant->getFullName() . '_attachment_' . $attachment->getId();
         //remove slashes in path to fix an apache issues with encoding slashes in redirects
         $base = str_replace(array('/', '\\'), 'slash', $base);
         $pdfName = $base . '.pdf';
         $pngName = $base . 'preview.png';
         \Jazzee\Globals::getFileStore()->createSessionFile($pdfName, $attachment->getAttachmentHash());
         if ($attachment->getThumbnailHash() != null) {
             \Jazzee\Globals::getFileStore()->createSessionFile($pngName, $attachment->getThumbnailHash());
             $thumbnailPath = \Jazzee\Globals::path('file/' . \urlencode($pngName));
         } else {
             $thumbnailPath = \Jazzee\Globals::path('resource/foundation/media/default_pdf_logo.png');
         }
         $attachments['attachments'][] = array('id' => $attachment->getId(), 'filePath' => $this->path('file/' . \urlencode($pdfName)), 'previewPath' => $this->path('file/' . $thumbnailPath));
     }
     return $attachments;
 }
示例#5
0
/**
 * render the attachment piece of a single answer
 * Displayes the png preview and the delete link
 */
if ($attachment = $answer->getAttachment()) {
    $base = $answer->getPage()->getTitle() . '_attachment_' . $attachment->getId();
    //remove slashes in path to fix an apache issues with encoding slashes in redirects
    $base = str_replace(array('/', '\\'), 'slash', $base);
    $pdfName = $base . '.pdf';
    $pngName = $base . 'preview.png';
    \Jazzee\Globals::getFileStore()->createSessionFile($pdfName, $attachment->getAttachmentHash());
    if ($attachment->getThumbnailHash() != null) {
        \Jazzee\Globals::getFileStore()->createSessionFile($pngName, $attachment->getThumbnailHash());
        $thumbnailPath = \Jazzee\Globals::path('file/' . \urlencode($pngName));
    } else {
        $thumbnailPath = \Jazzee\Globals::path('resource/foundation/media/default_pdf_logo.png');
    }
    ?>
  <a href="<?php 
    print $this->path('file/' . \urlencode($pdfName));
    ?>
"><img src="<?php 
    print $thumbnailPath;
    ?>
" /></a>
  <?php 
    if ($this->controller->checkIsAllowed('applicants_single', 'deleteAnswerPdf')) {
        ?>
    <br /><a href='<?php 
        print $this->path('applicants/single/' . $answer->getApplicant()->getId() . '/deleteAnswerPdf/' . $answer->getId());
        ?>