diff --git a/include/admin/Settings/CKEditor.php b/include/admin/Settings/CKEditor.php index 2e19335..ccb5b2d 100644 --- a/include/admin/Settings/CKEditor.php +++ b/include/admin/Settings/CKEditor.php @@ -27,6 +27,7 @@ class CKEditor extends \gp\special\Base{ $this->subpages = array( '' => $langmessage['Manage Plugins'], 'Config' => $langmessage['configuration'], + 'CK_Skin' => 'Skin', // /* 425 */ 'Example' => 'Example', ); @@ -67,6 +68,8 @@ class CKEditor extends \gp\special\Base{ case 'Example': $this->Example(); break; + case 'CK_Skin': + $this->CKSkins(); case 'Config': $this->CustomConfigForm(); $this->DisplayCurrent(); @@ -416,6 +419,89 @@ class CKEditor extends \gp\special\Base{ } +/* --------cke skinselector -------------- */ + +public function saveskins() { + global $langmessage; + + if (isset($_POST['skin_select']) && !empty($_POST['skin_select'])) { + + $selected_skin = $_POST['skin_select']; + $config_file = 'include/thirdparty/ckeditor/config.js'; + + // Read the current content of the config file + $current_content = file_get_contents($config_file); + + // Remove any existing config.skin lines + $new_content = preg_replace('/^\s*config\.skin\s*=.*$/m', '', $current_content); + + // Add the new config.skin line after the function opening + $new_content = preg_replace( + '/(CKEDITOR\.editorConfig\s*=\s*function\s*\(?\s*config\s*\)?\s*\{)/i', + "$1\n\tconfig.skin = '$selected_skin';", + $new_content + ); + + // Remove any empty lines that might have been created + $new_content = preg_replace('/^\s*[\r\n]/m', '', $new_content); + + // Write the updated content back to the config file + if (file_put_contents($config_file, $new_content) !== false) { + echo '
' . $langmessage['SAVED'] . ': ' . $selected_skin . '
'; + } else { + echo '
' . $langmessage['OOPS'] . ': ' . $langmessage['COULD_NOT_SAVE'] . '
'; + } + } + } + + /** + * Ckeditor custom skin + * 71 + **/ +public function CKSkins() { + global $langmessage; + $skins_dir = 'include/thirdparty/ckeditor/skins'; + $skin_directories = array_diff(scandir($skins_dir), array('..', '.')); + $selected_skin = ''; + + if (isset($_POST['skin_select']) && in_array($_POST['skin_select'], $skin_directories)) { + $selected_skin = $_POST['skin_select']; + } else { + // Read the current skin from the config file + $config_file = 'include/thirdparty/ckeditor/config.js'; + $config_content = file_get_contents($config_file); + preg_match('/config\.skin\s*=\s*[\'"](\w+)[\'"]/', $config_content, $matches); + $selected_skin = isset($matches[1]) ? $matches[1] : 'moono-lisa'; + } + + echo '
'; + echo ' '; + echo ' '; + echo ''; + echo '
'; + echo '
'; + /* if (isset($_POST['save_button'])) { saveskins(); } */ + + if ($_SERVER['REQUEST_METHOD'] === 'POST') { + if (isset($_POST['save_button'])) { + $this->saveskins(); + } + } +} + + + public function run() { + // A minimal run function to trigger things, needed for extended \gp\special\Base classes + $this->CKSkins(); + } + /** * Show a CKEditor instance