+ /**
+ * Create default config file if it doesn't exist
+ */
+ public static function setConfigDefault() {
+ if (!self::getConfigFile()) {
+ $config = self::fileHeader() . "CKEDITOR.editorConfig = function( config ) {\n\tconfig.allowedContent = true;\n};\n";
+ // Make sure directories exist
+ if (!is_dir(Civi::paths()->getPath('[civicrm.files]/persist'))) {
+ mkdir(Civi::paths()->getPath('[civicrm.files]/persist'));
+ }
+ $newFileName = Civi::paths()->getPath(self::CONFIG_FILEPATH . 'default.js');
+ file_put_contents($newFileName, $config);
+ }
+ }
+
+ /**
+ * @return string
+ */
+ public static function fileHeader() {
+ return "/**\n"
+ . " * CKEditor config file auto-generated by CiviCRM (" . date('Y-m-d H:i:s') . ").\n"
+ . " *\n"
+ . " * Note: This file will be overwritten if settings are modified at:\n"
+ . " * @link " . CRM_Utils_System::url('civicrm/admin/ckeditor', NULL, TRUE, NULL, FALSE) . "\n"
+ . " */\n";
+ }
+