/** * Save categories record */ function save() { $option = JRequest::getCmd('option'); // Check for request forgeries JRequest::checkToken() or jexit('Invalid Token'); $content = JRequest::getVar('content', '', 'post', 'string', JREQUEST_ALLOWRAW); $file = JRequest::getVar('file', ''); $folder = JRequest::getVar('folder', ''); $template = JAVoiceHelpers::checkFileTemplate($file, 'html', $folder); if ($template) { $path = $template; } else { $path = JPATH_COMPONENT_SITE . DS . 'views' . DS . $folder . DS . 'tmpl' . DS . $file; } $msg = ''; if (JFile::exists($path)) { $res = JFile::write($path, $content); if ($res) { $msg = JText::_('SAVE_DATA_SUCCESSFULLY') . ': ' . $file; } else { JError::raiseWarning(1001, JText::_("ERROR_OCCURRED_DATA_NOT_SAVED") . " " . $file); } } else { JError::raiseWarning(1001, JText::_("FILE_NOT_FOUND_TO_EDIT")); } switch ($this->_task) { case 'apply': $this->setRedirect("index.php?option={$option}&view=customtmpl&task=edit&file={$file}&folder={$folder}", $msg); break; case 'save': default: $this->setRedirect("index.php?option={$option}&view=customtmpl", $msg); break; } return TRUE; }
/** * Display edit form */ function displayForm() { $option = JRequest::getCmd('option'); $file = JRequest::getVar('file', ''); $template = JAVoiceHelpers::checkFileTemplate($file); $content = ''; if ($template) { $content = JFile::read($template); } else { $filename = JPATH_COMPONENT_SITE . '/asset/css/' . $file; if (JFile::exists($filename)) { $content = JFile::read($filename); } } $this->assignRef('content', $content); $this->assignRef('file', $file); $this->assignRef('filename', $filename); $this->assignRef('option', $option); }