/** * Save the presets * @param $context */ public function savePresets($context) { if (isset($_POST['ckeditor_sections'])) { // Save the sections to the config-file $sectionStr = implode(',', $_POST['ckeditor_sections']); Symphony::Configuration()->set('sections', $sectionStr, 'ckeditor'); if (version_compare(Administration::Configuration()->get('version', 'symphony'), '2.2.5', '>')) { // 2.3 and up: Symphony::Configuration()->write(); } else { // Earlier versions: Administration::instance()->saveConfig(); } } else { // If no sections are selected, delete the file: Symphony::Configuration()->remove('sections', 'ckeditor'); Administration::instance()->saveConfig(); } if (isset($_POST['ckeditor_link_templates'])) { // Save the link templates to the database: Symphony::Database()->query("DELETE FROM `tbl_ckeditor_link_templates`"); $shortcuts = $_POST['ckeditor_link_templates']; unset($_POST['ckeditor_link_templates']); if (!empty($shortcuts)) { foreach ($shortcuts as $i => $shortcut) { Symphony::Database()->insert($shortcut, "tbl_ckeditor_link_templates"); } } } }
/** * Save the presets * @param $context */ public function savePresets($context) { if (isset($_POST['ckeditor_sections'])) { // Save the sections to the config-file $sectionStr = implode(',', $_POST['ckeditor_sections']); Symphony::Configuration()->set('sections', $sectionStr, 'ckeditor'); if (version_compare(Administration::Configuration()->get('version', 'symphony'), '2.2.5', '>')) { // 2.3 and up: Symphony::Configuration()->write(); } else { // Earlier versions: Symphony::Configuration()->write(); } } else { // If no sections are selected, delete the file: Symphony::Configuration()->remove('sections', 'ckeditor'); Symphony::Configuration()->write(); } if (isset($_POST['ckeditor_link_templates'])) { // Save the link templates to the database: Symphony::Database()->query("DELETE FROM `tbl_ckeditor_link_templates`"); $shortcuts = $_POST['ckeditor_link_templates']; unset($_POST['ckeditor_link_templates']); if (!empty($shortcuts)) { foreach ($shortcuts as $i => $shortcut) { Symphony::Database()->insert($shortcut, "tbl_ckeditor_link_templates"); } } } if (isset($_POST['ckeditor']['styles'])) { Symphony::Configuration()->set('styles', General::sanitize($_POST['ckeditor']['styles']), 'ckeditor'); Symphony::Configuration()->write(); } else { Symphony::Configuration()->remove('styles', 'ckeditor'); Symphony::Configuration()->write(); } // Presets: if (isset($_POST['ckeditor_presets'])) { // Delete formatter references from DB: Symphony::Database()->query("DELETE FROM `tbl_ckeditor_presets`"); // Delete formatter files: $formatters = glob(EXTENSIONS . '/ckeditor/text-formatters/formatter.*.php'); foreach ($formatters as $formatter) { unlink($formatter); } // Create it all new: foreach ($_POST['ckeditor_presets'] as $preset) { Symphony::Database()->insert($preset, 'tbl_ckeditor_presets'); // Create text formatter file: $str = file_get_contents(EXTENSIONS . '/ckeditor/text-formatters/template.ckeditor.php'); $handle = 'ckeditor_' . General::createHandle($preset['name'], 255, '_'); $str = str_replace(array('{{NAME}}', '{{HANDLE}}'), array($preset['name'], $handle), $str); file_put_contents(EXTENSIONS . '/ckeditor/text-formatters/formatter.' . $handle . '.php', $str); } } }