示例#1
0
文件: file.php 项目: Jazzee/Jazzee
 /**
  * Output a single file
  * @param string $name
  */
 public function actionGet($name)
 {
     if ($file = \Jazzee\Globals::getFileStore()->getSessionFile($name)) {
         $file->output();
     }
     //send a 404
     $request = new Lvc_Request();
     $request->setControllerName('error');
     $request->setActionName('index');
     $request->setActionParams(array('error' => '404', 'message' => 'File Not Found'));
     // Get a new front controller without any routers, and have it process our handmade request.
     $frontController = new Lvc_FrontController();
     $frontController->processRequest($request);
     exit(0);
 }
示例#2
0
 /**
  * Render a single answer in the PDF
  * @param \Jazzee\ApplicantPDF $pdf
  * @param \Jazzee\Entity\Page $page
  * @param \Jazzee\Entity\Answer $answer
  */
 protected function renderPdfAnswerFromArray(\Jazzee\Entity\Page $page, \Jazzee\ApplicantPDF $pdf, array $answerData)
 {
     foreach ($page->getElements() as $element) {
         $element->getJazzeeElement()->setController($this->_controller);
         $value = $element->getJazzeeElement()->pdfValueFromArray($answerData, $pdf);
         if (!empty($value)) {
             $pdf->addText("{$element->getTitle()}: ", 'b');
             $pdf->addText("{$value}\n", 'p');
         }
     }
     if ($attachment = $answerData['attachment']) {
         $pdf->addPdf(\Jazzee\Globals::getFileStore()->getFileContents($attachment["attachmentHash"]));
     }
 }
示例#3
0
 /**
  * PDF a full single applicant using the display array
  * @param \Jazzee\Entity\Application $application
  * @param array $applicant
  * @return string the PDF buffer suitable for display
  */
 public function pdfFromApplicantArray(\Jazzee\Entity\Application $application, array $applicant)
 {
     $this->pdf->set_info("Title", $this->pdf->convert_to_unicode('utf8', $applicant["fullName"], '') . ' Application');
     $this->addText($applicant["fullName"] . "\n", 'h1');
     $this->addText('Email Address: ' . $applicant["email"] . "\n", 'p');
     if ($applicant["isLocked"]) {
         switch ($applicant["decision"]["status"]) {
             case 'finalDeny':
                 $status = 'Denied';
                 break;
             case 'finalAdmit':
                 $status = 'Admited';
                 break;
             case 'acceptOffer':
                 $status = 'Accepted';
                 break;
             case 'declineOffer':
                 $status = 'Declined';
                 break;
             default:
                 $status = 'No Decision';
         }
     } else {
         $status = 'Not Locked';
     }
     $this->addText("Admission Status: {$status}\n", 'p');
     $this->write();
     $pages = array();
     foreach ($applicant['pages'] as $pageArray) {
         $pages[$pageArray['id']] = $pageArray['answers'];
     }
     foreach ($application->getApplicationPages(\Jazzee\Entity\ApplicationPage::APPLICATION) as $applicationPath) {
         if ($applicationPath->getJazzeePage() instanceof \Jazzee\Interfaces\PdfPage) {
             $applicationPath->getJazzeePage()->setController($this->_controller);
             $pageData = array_key_exists($applicationPath->getPage()->getId(), $pages) ? $pages[$applicationPath->getPage()->getId()] : array();
             $applicationPath->getJazzeePage()->renderPdfSectionFromArray($pageData, $this);
         }
     }
     $this->write();
     $this->pdf->end_page_ext("");
     foreach ($applicant["attachments"] as $attachment) {
         $blob = \Jazzee\Globals::getFileStore()->getFileContents($attachment["attachmentHash"]);
         $this->addPdf($blob);
         $blob = null;
     }
     $this->attachPdfs();
     $this->pdf->end_document("");
     return $this->pdf->get_buffer();
 }
示例#4
0
 /**
  * When removing an element answer remove its file association as well
  * @param \Jazzee\Entity\ElementAnswer $elementAnswer
  */
 public function removeElementAnswer(\Jazzee\Entity\ElementAnswer $elementAnswer)
 {
     if ($elementAnswer->getEShortString()) {
         \Jazzee\Globals::getFileStore()->removeFile($elementAnswer->getEShortString());
     }
 }
示例#5
0
 /**
  * Get the temporary path to the PDF file
  * @return string
  */
 public function getTmpFilePath()
 {
     return \Jazzee\Globals::getFileStore()->getFilePath($this->fileHash);
 }
示例#6
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;
 }
示例#7
0
 /**
  * Remove any attachmetn file pointers
  * @PreRemove
  */
 public function preRemove()
 {
     if ($this->thumbnailHash) {
         \Jazzee\Globals::getFileStore()->removeFile($this->thumbnailHash);
     }
     \Jazzee\Globals::getFileStore()->removeFile($this->attachmentHash);
 }
示例#8
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;
 }
示例#9
0
<?php

/**
 * 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 
示例#10
0
 /**
  * Render a single answer in the PDF
  * @param \Jazzee\ApplicantPDF $pdf
  * @param \Jazzee\Entity\Page $page
  * @param \Jazzee\Entity\Answer $answer
  */
 protected function renderPdfAnswerFromArray(\Jazzee\Entity\Page $page, \Jazzee\ApplicantPDF $pdf, array $answerData)
 {
     if (!empty($answerData['elements'])) {
         $pdf->addText("{$this->_applicationPage->getPage()->getVar('branchingElementLabel')}: ", 'b');
         $pdf->addText("{$answerData['elements'][0]['displayValue']}\n", 'p');
         foreach ($page->getChildren() as $childPage) {
             $jazzeePage = $childPage->getApplicationPageJazzeePage();
             $jazzeePage->setController($this->_controller);
             $jazzeePage->renderPdfAnswerFromArray($childPage, $pdf, $answerData);
         }
         if ($attachment = $answerData['attachment']) {
             $pdf->addPdf(\Jazzee\Globals::getFileStore()->getFileContents($attachment["attachmentHash"]));
         }
     } else {
         if (!empty($answerData['children'][0])) {
             $childAnswer = $answerData['children'][0];
             $childPage = $page->getChildById($childAnswer['page_id']);
             $pdf->addText("{$this->_applicationPage->getPage()->getVar('branchingElementLabel')}: ", 'b');
             $pdf->addText("{$childPage->getTitle()}\n", 'p');
             $jazzeePage = $childPage->getApplicationPageJazzeePage();
             $jazzeePage->setController($this->_controller);
             $jazzeePage->renderPdfAnswerFromArray($childPage, $pdf, $childAnswer);
         }
     }
 }