Server : LiteSpeed System : Linux server 3.10.0-1160.90.1.el7.x86_64 #1 SMP Thu May 4 15:21:22 UTC 2023 x86_64 User : alsaif ( 1057) PHP Version : 7.4.33 Disable Function : show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/alsaif/public_html/plugins/convertformstools/pdf/fields/ |
<?php
/**
* @package Convert Forms
* @version 4.3.3 Pro
*
* @author Tassos Marinos <info@tassos.gr>
* @link https://www.tassos.gr
* @copyright Copyright © 2023 Tassos All Rights Reserved
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
*/
defined('_JEXEC') or die('Restricted access');
JLoader::register('PDFHelper', __DIR__ . '/helper/pdfhelper.php');
class JFormFieldPDFSubmission extends JFormFieldText
{
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function getInput()
{
$this->disabled = true;
$this->class = 'span12';
$id = $this->form->getData()->get('id');
$modelSubmission = JModelLegacy::getInstance('Conversion', 'ConvertFormsModel', ['ignore_request' => true]);
$submission = $modelSubmission->getItem($id);
// if no value is given, hide the field
if (!$this->value = PDFHelper::getSubmissionPDF($submission))
{
$this->hidden = true;
return;
}
return parent::getInput() . $this->getHelperButtons($this->value);
}
/**
* Renders buttons to view/download the PDF
*
* @param string $pdf_url
*
* @return string
*/
private function getHelperButtons($pdf_url)
{
return '<div style="margin-top: 10px;">' .
'<a href="' . $pdf_url . '" target="_blank" class="btn btn-secondary">' . \JText::_('PLG_CONVERTFORMSTOOLS_PDF_SUBMISSION_VIEW_BTN') . '</a> ' .
'<a href="' . $pdf_url . '" class="btn btn-secondary" download>' . \JText::_('PLG_CONVERTFORMSTOOLS_PDF_SUBMISSION_DOWNLOAD_BTN') . '</a>' .
'</div>';
}
}