function export() { $cid = JRequest::getVar('cid', array(), '', 'array'); JArrayHelper::toInteger($cid, array(0)); if (!$cid) { JError::raiseWarning(1, JText::_('PLEASE_SELECT_EMAIL_TEMPLATE')); return $this->setRedirect("index.php?option=com_javocie&view=emailtemplates"); } $cid = implode(',', $cid); $model = $this->getModel('emailtemplates'); $items = $model->getItemsbyWhere($cid); if (!$items) { JError::raiseWarning(1, JText::_('PLEASE_SELECT_EMAIL_TEMPLATE')); return $this->setRedirect("index.php?option=com_javocie&view=emailtemplates"); } $content = ''; foreach ($items as $item) { $content .= JAVoiceHelpers::temp_export($item); } $filename = 'javoice_email_templates.ini'; $ctype = "text/plain"; if ($content) { header("Pragma: public"); // required header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private", false); // required for certain browsers header("Content-Type: {$ctype}; name=\"" . basename($filename) . "\";"); header("Content-Disposition: attachment; filename=\"" . basename($filename) . "\";"); header("Content-Transfer-Encoding: utf-8"); header("Content-Length: " . strlen($content)); echo $content; exit; } else { JError::raiseWarning(1, JText::_('CONTENT_IS_EMPTY')); return $this->setRedirect("index.php?option=com_javocie&view=emailtemplates"); } }