3 * FusionForge Plugin FCKeditor Plugin Class
5 * Copyright 2005 (c) Daniel A. PĂ©rez <daniel@gforgegroup.com> , <danielperez.arg@gmail.com>
6 * Copyright 2011, Franck Villaume - TrivialDev
8 * This file is part of FusionForge-plugin-fckeditor
10 * FusionForge-plugin-fckeditor is free software; you can redistribute it
11 * and/or modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2 of
13 * the License, or (at your option) any later version.
15 * FusionForge-plugin-fckeditor is distributed in the hope that it will
16 * be useful, but WITHOUT ANY WARRANTY; without even the implied
17 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 * See the GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 * The fckeditorPlugin class. It implements the Hooks for the presentation
27 * of the text editor whenever needed
30 class fckeditorPlugin extends Plugin {
31 function fckeditorPlugin () {
33 $this->name = "fckeditor" ;
34 $this->text = _("HTML editor");
35 $this->_addHook("groupisactivecheckbox");
36 $this->_addHook("groupisactivecheckboxpost");
37 $this->_addHook('userisactivecheckbox');
38 $this->_addHook('userisactivecheckboxpost');
39 $this->_addHook("text_editor"); // shows the editor
43 * The function to be called for a Hook
45 * @param String $hookname The name of the hookname that has been happened
46 * @param String $params The params of the Hook
49 function CallHook($hookname, &$params) {
52 if (file_exists ("/usr/share/fckeditor/fckeditor.php")) {
53 $use_system_fckeditor = true;
54 require_once '/usr/share/fckeditor/fckeditor.php';
56 $use_system_fckeditor = false;
57 require_once $GLOBALS['gfplugins'].'fckeditor/www/fckeditor.php';
60 if ($hookname == "text_editor") {
62 if (isset($params['group'])) {
63 $group_id=$params['group']; // get the project id
64 $project = group_get_object($group_id);
65 if ( (!$project) || (!is_object($project)) || ($project->isError()) || (!$project->isProject()) ) {
68 if ( $project->usesPlugin ( $this->name ) ) { // only if the plugin is activated for the project show the fckeditor box
71 } elseif (isset($params['user_id'])) {
72 $userid = $params['user_id'];
73 $user = user_get_object($userid);
74 if ($user->usesPlugin($this->name)) {
79 $name = isset($params['name'])? $params['name'] : 'body';
80 $oFCKeditor = new FCKeditor($name) ;
81 if ($use_system_fckeditor) {
82 $oFCKeditor->BasePath = util_make_uri('/fckeditor/');
83 $oFCKeditor->Config['CustomConfigurationsPath'] = "/plugins/fckeditor/fckconfig.js" ;
85 $oFCKeditor->BasePath = util_make_uri('/plugins/' . $this->name . '/');
87 $oFCKeditor->Value = $params['body'];
88 if (isset($params['width'])) $oFCKeditor->Width = $params['width'];
89 $oFCKeditor->Height = $params['height'];
90 $oFCKeditor->ToolbarSet = isset($params['toolbar']) ? $params['toolbar']: 'FusionForge';
91 $h = '<input type="hidden" name="_'.$name.'_content_type" value="html" />'."\n";
92 $h .= $oFCKeditor->CreateHtml() ;
94 // If content is present, return the html code in content.
95 if (isset($params['content'])) {
96 $params['content'] = $h;
98 $GLOBALS['editor_was_set_up'] = true;
108 // c-file-style: "bsd"