Example #1
0
function editTemplateCSS()
{
    $kunena_app =& JFactory::getApplication();
    $option = JRequest::getCmd('option');
    $template = JRequest::getVar('id', '', 'method', 'cmd');
    $filename = JRequest::getVar('filename', '', 'method', 'cmd');
    jimport('joomla.filesystem.file');
    if (JFile::getExt($filename) !== 'css') {
        $msg = JText::_('COM_KUNENA_A_TEMPLATE_MANAGER_WRONG_CSS');
        while (@ob_end_clean()) {
        }
        $kunena_app->redirect(JURI::base() . 'index.php?option=' . $option . '&task=chooseCSSTemplate&id=' . $template, $msg, 'error');
    }
    $content = JFile::read(KUNENA_PATH_TEMPLATE . '/' . $template . '/css/' . $filename);
    if ($content !== false) {
        // Set FTP credentials, if given
        jimport('joomla.client.helper');
        $ftp =& JClientHelper::setCredentialsFromRequest('ftp');
        $content = htmlspecialchars($content, ENT_COMPAT, 'UTF-8');
        html_Kunena::editCSSSource($template, $filename, $content, $option, $ftp);
    } else {
        $msg = JText::sprintf('COM_KUNENA_A_TEMPLATE_MANAGER_FAILED_COULD_NOT_OPEN' . $filename);
        while (@ob_end_clean()) {
        }
        $kunena_app->redirect(JURI::base() . 'index.php?option=' . $option . $msg);
    }
}