1*8c2e8227SGreg Roach<?php 2*8c2e8227SGreg Roachnamespace Fisharebest\Webtrees; 3*8c2e8227SGreg Roach 4*8c2e8227SGreg Roach/** 5*8c2e8227SGreg Roach * webtrees: online genealogy 6*8c2e8227SGreg Roach * Copyright (C) 2015 webtrees development team 7*8c2e8227SGreg Roach * This program is free software: you can redistribute it and/or modify 8*8c2e8227SGreg Roach * it under the terms of the GNU General Public License as published by 9*8c2e8227SGreg Roach * the Free Software Foundation, either version 3 of the License, or 10*8c2e8227SGreg Roach * (at your option) any later version. 11*8c2e8227SGreg Roach * This program is distributed in the hope that it will be useful, 12*8c2e8227SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 13*8c2e8227SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14*8c2e8227SGreg Roach * GNU General Public License for more details. 15*8c2e8227SGreg Roach * You should have received a copy of the GNU General Public License 16*8c2e8227SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 17*8c2e8227SGreg Roach */ 18*8c2e8227SGreg Roach 19*8c2e8227SGreg Roach/** 20*8c2e8227SGreg Roach * Class CkeditorModule 21*8c2e8227SGreg Roach */ 22*8c2e8227SGreg Roachclass CkeditorModule extends Module { 23*8c2e8227SGreg Roach /** {@inheritdoc} */ 24*8c2e8227SGreg Roach public function getTitle() { 25*8c2e8227SGreg Roach return /* I18N: Name of a module. CKEditor is a trademark. Do not translate it? http://ckeditor.com */ I18N::translate('CKEditor™'); 26*8c2e8227SGreg Roach } 27*8c2e8227SGreg Roach 28*8c2e8227SGreg Roach /** {@inheritdoc} */ 29*8c2e8227SGreg Roach public function getDescription() { 30*8c2e8227SGreg Roach return /* I18N: Description of the “CKEditor” module. WYSIWYG = “what you see is what you get” */ I18N::translate('Allow other modules to edit text using a “WYSIWYG” editor, instead of using HTML codes.'); 31*8c2e8227SGreg Roach } 32*8c2e8227SGreg Roach 33*8c2e8227SGreg Roach /** 34*8c2e8227SGreg Roach * Convert <textarea class="html-edit"> fields to CKEditor fields 35*8c2e8227SGreg Roach * 36*8c2e8227SGreg Roach * This function needs to be called *after* we have sent the page header and 37*8c2e8227SGreg Roach * before we have sent the page footer. 38*8c2e8227SGreg Roach * 39*8c2e8227SGreg Roach * @param BaseController $controller 40*8c2e8227SGreg Roach * 41*8c2e8227SGreg Roach * @return void 42*8c2e8227SGreg Roach */ 43*8c2e8227SGreg Roach public static function enableEditor($controller) { 44*8c2e8227SGreg Roach $controller 45*8c2e8227SGreg Roach ->addExternalJavascript(WT_CKEDITOR_BASE_URL . 'ckeditor.js') 46*8c2e8227SGreg Roach ->addExternalJavascript(WT_CKEDITOR_BASE_URL . 'adapters/jquery.js') 47*8c2e8227SGreg Roach // Need to specify the path before we load the libary 48*8c2e8227SGreg Roach ->addInlineJavascript( 49*8c2e8227SGreg Roach 'var CKEDITOR_BASEPATH="' . WT_CKEDITOR_BASE_URL . '";', 50*8c2e8227SGreg Roach BaseController::JS_PRIORITY_HIGH 51*8c2e8227SGreg Roach ) 52*8c2e8227SGreg Roach // Activate the editor 53*8c2e8227SGreg Roach ->addInlineJavascript('jQuery(".html-edit").ckeditor(function(){}, { 54*8c2e8227SGreg Roach language: "' . str_replace('_', '-', strtolower(WT_LOCALE)) . '" 55*8c2e8227SGreg Roach });'); 56*8c2e8227SGreg Roach } 57*8c2e8227SGreg Roach} 58