/** * Create URL for form email button * * @param object $formModel form model * * @since 3.0.6 * * @return string */ public static function emailURL($formModel) { $app = JFactory::getApplication(); $input = $app->input; $package = $app->getUserState('com_fabrik.package', 'fabrik'); if ($app->isAdmin()) { $url = 'index.php?option=com_fabrik&task=emailform.display&tmpl=component&formid=' . $formModel->get('id') . '&rowid=' . $formModel->getRowId(); } else { $url = 'index.php?option=com_' . $package . '&view=emailform&tmpl=component&formid=' . $formModel->get('id') . '&rowid=' . $formModel->getRowId(); } if ($input->get('usekey') !== null) { $url .= '&usekey=' . $input->get('usekey'); } $url .= '&referrer=' . urlencode(JURI::getInstance()->toString()); self::$emailURL = JRoute::_($url); return self::$emailURL; }
/** * Add buttons to the view e.g. print, pdf * * @return void */ protected function _addButtons() { $input = $this->app->input; if ($input->get('format') === 'pdf') { // If we're rendering as PDF, no point showing any buttons $this->showEmail = false; $this->showPrint = false; $this->showPDF = false; return; } $fbConfig = JComponentHelper::getParams('com_fabrik'); /** @var FabrikFEModelForm $model */ $model = $this->getModel(); $params = $model->getParams(); $this->showEmail = $params->get('email', $fbConfig->get('form_email', 0)); $this->emailLink = ''; $this->printLink = ''; $this->pdfLink = ''; $this->pdfURL = ''; $this->emailURL = ''; $this->printURL = ''; $this->showPrint = $params->get('print', $fbConfig->get('form_print', 0)); if ($this->showPrint) { $text = FabrikHelperHTML::image('print.png'); $this->printLink = '<a href="#" class="btn btn-default" class="printlink" onclick="window.print();return false;">' . $text . '</a>'; } if ($input->get('tmpl') != 'component') { if ($this->showEmail) { $this->emailLink = FabrikHelperHTML::emailIcon($model, $params); $this->emailURL = FabrikHelperHTML::emailURL($model); } if ($this->showPrint) { $this->printLink = FabrikHelperHTML::printIcon($model, $params); $this->printURL = FabrikHelperHTML::printURL($model); } } $this->showPDF = $params->get('pdf', $fbConfig->get('form_pdf', false)); if ($this->showPDF) { FabrikWorker::canPdf(); if ($this->app->isAdmin()) { $this->pdfURL = 'index.php?option=com_' . $this->package . '&task=details.view&format=pdf&formid=' . $model->getId() . '&rowid=' . $model->getRowId(); } else { $this->pdfURL = 'index.php?option=com_' . $this->package . '&view=details&formid=' . $model->getId() . '&rowid=' . $model->getRowId() . '&format=pdf'; } $this->pdfURL = JRoute::_($this->pdfURL); $layout = FabrikHelperHTML::getLayout('form.fabrik-pdf-icon'); $pdfDisplayData = new stdClass(); $pdfDisplayData->pdfURL = $this->pdfURL; $pdfDisplayData->tmpl = $this->tmpl; $this->pdfLink = $layout->render($pdfDisplayData); } }
/** * Create URL for form email button * * @param object $formModel form model * * @since 3.0.6 * * @return string */ public static function emailURL($formModel) { if (isset(self::$emailURL)) { return self::$emailURL; } $app = JFactory::getApplication(); if ($app->isAdmin()) { $url = 'index.php?option=com_fabrik&task=emailform.display&tmpl=component&formid=' . $formModel->get('id') . '&rowid=' . $formModel->getRowId(); } else { $url = 'index.php?option=com_fabrik&view=emailform&tmpl=component&formid=' . $formModel->get('id') . '&rowid=' . $formModel->getRowId(); } if (JRequest::getVar('usekey') !== null) { $url .= '&usekey=' . JRequest::getVar('usekey'); } $url .= '&referrer=' . urlencode(JFactory::getURI()->toString()); self::$emailURL = $url; return self::$emailURL; }
/** * Add buttons to the view e.g. print, pdf * * @return void */ protected function _addButtons() { $app = JFactory::getApplication(); if ($app->input->get('format') === 'pdf') { // If we're rendering as PDF, no point showing any buttons $this->showEmail = false; $this->showPrint = false; $this->showPDF = false; return; } $fbConfig = JComponentHelper::getParams('com_fabrik'); $package = $app->getUserState('com_fabrik.package', 'fabrik'); $input = $app->input; $model = $this->getModel(); $params = $model->getParams(); $this->showEmail = $params->get('email', $fbConfig->get('form_email', 0)); $this->emailLink = ''; $this->printLink = ''; $this->pdfLink = ''; $this->pdfURL = ''; $this->emailURL = ''; $this->printURL = ''; $this->showPrint = $params->get('print', $fbConfig->get('form_print', 0)); if ($this->showPrint) { $text = FabrikHelperHTML::image('print.png'); $this->printLink = '<a href="#" class="printlink" onclick="window.print();return false;">' . $text . '</a>'; } if ($input->get('tmpl') != 'component') { if ($this->showEmail) { $this->emailLink = FabrikHelperHTML::emailIcon($model, $params); $this->emailURL = FabrikHelperHTML::emailURL($model); } if ($this->showPrint) { $this->printLink = FabrikHelperHTML::printIcon($model, $params, $model->getRowId()); $this->printURL = FabrikHelperHTML::printURL($model); } } $this->showPDF = $params->get('pdf', $fbConfig->get('form_pdf', false)); $buttonProperties = array('class' => 'fabrikTip', 'opts' => "{notice:true}", 'title' => '<span>' . FText::_('COM_FABRIK_PDF') . '</span>', 'alt' => FText::_('COM_FABRIK_PDF')); if ($this->showPDF) { FabrikWorker::canPdf(); if ($app->isAdmin()) { $this->pdfURL = 'index.php?option=com_' . $package . '&task=details.view&format=pdf&formid=' . $model->getId() . '&rowid=' . $model->getRowId(); } else { $this->pdfURL = 'index.php?option=com_' . $package . '&view=details&formid=' . $model->getId() . '&rowid=' . $model->getRowId() . '&format=pdf'; } $this->pdfURL = JRoute::_($this->pdfURL); $this->pdfLink = '<a href="' . $this->pdfURL . '">' . FabrikHelperHTML::image('pdf.png', 'list', $this->tmpl, $buttonProperties) . '</a>'; } }
/** * Create URL for form email button * * @param object $formModel form model * * @since 3.0.6 * * @return string */ public static function emailURL($formModel) { /** * Comment this out for now, as it causes issues with multiple forms per page. * We could always create a $sig for it, but that would need the info from the form and * table models, which are probably the most 'expensive' aprt of this function anyway. */ /* if (isset(self::$emailURL)) { return self::$emailURL; } */ $app = JFactory::getApplication(); $input = $app->input; $package = $app->getUserState('com_fabrik.package', 'fabrik'); if ($app->isAdmin()) { $url = 'index.php?option=com_fabrik&task=emailform.display&tmpl=component&formid=' . $formModel->get('id') . '&rowid=' . $formModel->getRowId(); } else { $url = 'index.php?option=com_' . $package . '&view=emailform&tmpl=component&formid=' . $formModel->get('id') . '&rowid=' . $formModel->getRowId(); } if ($input->get('usekey') !== null) { $url .= '&usekey=' . $input->get('usekey'); } $url .= '&referrer=' . urlencode(JURI::getInstance()->toString()); self::$emailURL = JRoute::_($url); return self::$emailURL; }
/** * Add buttons to the view e.g. print, pdf * * @return void */ protected function _addButtons() { $fbConfig = JComponentHelper::getParams('com_fabrik'); $model = $this->getModel(); $params = $model->getParams(); $this->showEmail = $params->get('email', $fbConfig->get('form_email', 0)); $this->emailLink = ''; $this->printLink = ''; $this->pdfLink = ''; $this->pdfURL = ''; $this->emailURL = ''; $this->printURL = ''; $this->showPrint = $params->get('print', $fbConfig->get('form_print', 0)); if ($this->showPrint) { $text = JHTML::_('image.site', 'printButton.png', '/images/', null, null, JText::_('Print')); $this->printLink = '<a href="#" class="printlink" onclick="window.print();return false;">' . $text . '</a>'; } if (JRequest::getVar('tmpl') != 'component') { if ($this->showEmail) { $this->emailLink = FabrikHelperHTML::emailIcon($model, $params); $this->emailURL = FabrikHelperHTML::emailURL($model); } if ($this->showPrint) { $this->printLink = FabrikHelperHTML::printIcon($model, $params, $model->_rowId); $this->printURL = FabrikHelperHTML::printURL($model); } } $this->showPDF = $params->get('pdf', $fbConfig->get('form_pdf', false)); $buttonProperties = array('class' => 'fabrikTip', 'opts' => "{notice:true}", 'title' => '<span>' . JText::_('COM_FABRIK_PDF') . '</span>', 'alt' => JText::_('COM_FABRIK_PDF')); if ($this->showPDF) { if (!FabrikWorker::canPdf()) { JError::raiseNotice(500, JText::_('COM_FABRIK_NOTICE_DOMPDF_NOT_FOUND')); } else { $this->pdfURL = JRoute::_('index.php?option=com_fabrik&view=details&format=pdf&formid=' . $model->getId() . '&rowid=' . $model->_rowId); $this->pdfLink = '<a href="' . JRoute::_('index.php?option=com_fabrik&view=details&format=pdf&formid=' . $model->getId()) . '&rowid=' . $this->rowid . '">' . FabrikHelperHTML::image('pdf.png', 'list', $this->tmpl, $buttonProperties) . '</a>'; } } }