| 1 |
<?php
|
| 2 |
// $Id: fckeditor.install,v 1.2 2007/11/15 16:15:47 wwalc Exp $
|
| 3 |
|
| 4 |
/*
|
| 5 |
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
|
| 6 |
* Copyright (C) 2003-2007 Frederico Caldeira Knabben
|
| 7 |
*
|
| 8 |
* == BEGIN LICENSE ==
|
| 9 |
*
|
| 10 |
* Licensed under the terms of any of the following licenses at your
|
| 11 |
* choice:
|
| 12 |
*
|
| 13 |
* - GNU General Public License Version 2 or later (the "GPL")
|
| 14 |
* http://www.gnu.org/licenses/gpl.html
|
| 15 |
*
|
| 16 |
* - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
|
| 17 |
* http://www.gnu.org/licenses/lgpl.html
|
| 18 |
*
|
| 19 |
* - Mozilla Public License Version 1.1 or later (the "MPL")
|
| 20 |
* http://www.mozilla.org/MPL/MPL-1.1.html
|
| 21 |
*
|
| 22 |
* == END LICENSE ==
|
| 23 |
|
| 24 |
* Implementation of hook_install()
|
| 25 |
*
|
| 26 |
* This will automatically install the database tables for the FCKeditor module for both the MySQL and PostgreSQL databases.
|
| 27 |
*
|
| 28 |
* If you are using another database, you will have to install the tables by hand, using the queries below as a reference.
|
| 29 |
*
|
| 30 |
* Note that the curly braces around table names are a drupal-specific feature to allow for automatic database table prefixing,
|
| 31 |
* and will need to be removed.
|
| 32 |
*/
|
| 33 |
function fckeditor_install() {
|
| 34 |
|
| 35 |
drupal_install_schema('fckeditor');
|
| 36 |
|
| 37 |
//create two default roles based on previous settings
|
| 38 |
db_query("INSERT INTO {fckeditor_role} (name, rid) VALUES ('%s', %d)",
|
| 39 |
"Default", defined('DRUPAL_ANONYMOUS_RID') ? DRUPAL_ANONYMOUS_RID : 1);
|
| 40 |
db_query("INSERT INTO {fckeditor_role} (name, rid) VALUES ('%s', %d)",
|
| 41 |
"Advanced", defined('DRUPAL_AUTHENTICATED_RID') ? DRUPAL_AUTHENTICATED_RID : 2);
|
| 42 |
|
| 43 |
//insert settings for default role
|
| 44 |
$arr = array();
|
| 45 |
$arr['allow_user_conf'] = "f";
|
| 46 |
$arr['min_rows'] = variable_get('fckeditor_minimum_rows', 1);
|
| 47 |
$arr['excl_mode'] = variable_get('fckeditor_exclude_toggle', 0);
|
| 48 |
|
| 49 |
//appearance
|
| 50 |
$arr['default'] = "t";
|
| 51 |
$arr['show_toggle'] = "t";
|
| 52 |
$arr['popup'] = variable_get('fckeditor_popup', 0) ? "t" : "f";
|
| 53 |
$arr['skin'] = "default";
|
| 54 |
$arr['toolbar'] = variable_get('fckeditor_default_toolbar', 'DrupalBasic');
|
| 55 |
$arr['expand'] = variable_get('fckeditor_toolbar_start_expanded', 1) ? "t" : "f";
|
| 56 |
$arr['width'] = variable_get("fckeditor_width", "100%");
|
| 57 |
$arr['lang'] = "en";
|
| 58 |
$arr['auto_lang'] = "t";
|
| 59 |
|
| 60 |
//output
|
| 61 |
$arr['enter_mode'] = "p";
|
| 62 |
$arr['shift_enter_mode'] = "br";
|
| 63 |
$arr['font_format'] = 'p;div;pre;address;h1;h2;h3;h4;h5;h6';
|
| 64 |
$arr['format_source'] = "t";
|
| 65 |
$arr['format_output'] = "t";
|
| 66 |
|
| 67 |
//css
|
| 68 |
$arr['css_mode'] = "theme";
|
| 69 |
$arr['css_path'] = variable_get("fckeditor_stylesheet", "");
|
| 70 |
|
| 71 |
//upload
|
| 72 |
//get permissions here like in _update_role_permissions
|
| 73 |
$arr['upload_basic'] = variable_get("fckeditor_upload_basic", 0) ? "t" : "f";
|
| 74 |
$arr['upload_advanced'] = variable_get('fckeditor_upload_advanced', 0) ? "t" : "f";
|
| 75 |
$arr['user_choose'] = "f";
|
| 76 |
|
| 77 |
db_query("INSERT INTO {fckeditor_settings} (name, settings) VALUES ('%s', '%s')", "Default", serialize($arr));
|
| 78 |
|
| 79 |
//insert settings for advanced role
|
| 80 |
$arr['toolbar'] = variable_get('fckeditor_advanced_toolbar', 'DrupalFiltered');
|
| 81 |
db_query("INSERT INTO {fckeditor_settings} (name, settings) VALUES ('%s', '%s')", "Advanced", serialize($arr));
|
| 82 |
|
| 83 |
$arr = array();
|
| 84 |
|
| 85 |
//exclude by default some known textareas where HTML is not expected
|
| 86 |
//edit-recipients //contact module
|
| 87 |
//edit-reply //contact module
|
| 88 |
//edit-description //taxonomy module
|
| 89 |
//edit-synonyms //taxonomy module
|
| 90 |
//edit-img-assist-textareas //img assist module
|
| 91 |
$arr['excl_list'] = variable_get("fckeditor_exclude",
|
| 92 |
"edit-user-mail-welcome-body\n".
|
| 93 |
"edit-user-mail-admin-body\n".
|
| 94 |
"edit-user-mail-approval-body\n".
|
| 95 |
"edit-user-mail-pass-body\n".
|
| 96 |
"edit-user-mail-register-admin-created-body\n".
|
| 97 |
"edit-user-mail-register-no-approval-required-body\n".
|
| 98 |
"edit-user-mail-register-pending-approval-body\n".
|
| 99 |
"edit-user-mail-password-reset-body\n".
|
| 100 |
"edit-user-mail-status-activated-body\n".
|
| 101 |
"edit-user-mail-status-blocked-body\n".
|
| 102 |
"edit-user-mail-status-deleted-body\n".
|
| 103 |
"edit-recipients\n".
|
| 104 |
"edit-reply\n".
|
| 105 |
"edit-description\n".
|
| 106 |
"edit-synonyms\n".
|
| 107 |
"edit-img-assist-textareas\n"
|
| 108 |
);
|
| 109 |
|
| 110 |
//force by default simple toolbar on selected textareas
|
| 111 |
$arr['simple_incl_mode'] = 1;
|
| 112 |
$arr['simple_incl_list'] =
|
| 113 |
"edit-signature\n".
|
| 114 |
"edit-site-mission\n".
|
| 115 |
"edit-site-footer\n".
|
| 116 |
"edit-site-offline-message\n".
|
| 117 |
"edit-page-help\n".
|
| 118 |
"edit-user-registration-help\n".
|
| 119 |
"edit-user-picture-guidelines\n";
|
| 120 |
|
| 121 |
db_query("INSERT INTO {fckeditor_settings} (name, settings) VALUES ('%s', '%s')", "FCKeditor Global Profile", serialize($arr));
|
| 122 |
}
|
| 123 |
|
| 124 |
/**
|
| 125 |
* Implementation of hook_schema().
|
| 126 |
*/
|
| 127 |
function fckeditor_schema() {
|
| 128 |
$schema['fckeditor_settings'] = array(
|
| 129 |
'description' => t('Stores FCKeditor profile settings'),
|
| 130 |
'fields' => array(
|
| 131 |
'name' => array(
|
| 132 |
'type' => 'varchar',
|
| 133 |
'not null' => TRUE,
|
| 134 |
'default' => '',
|
| 135 |
'length' => 128,
|
| 136 |
'description' => t('Name of the FCKeditor profile'),
|
| 137 |
),
|
| 138 |
'settings' => array(
|
| 139 |
'type' => 'text',
|
| 140 |
'description' => t('Profile settings'),
|
| 141 |
),
|
| 142 |
),
|
| 143 |
'primary key' => array('name'),
|
| 144 |
);
|
| 145 |
$schema['fckeditor_role'] = array(
|
| 146 |
'description' => t('Stores FCKeditor profile assignments'),
|
| 147 |
'fields' => array(
|
| 148 |
'name' => array(
|
| 149 |
'type' => 'varchar',
|
| 150 |
'not null' => TRUE,
|
| 151 |
'default' => '',
|
| 152 |
'length' => 128,
|
| 153 |
'description' => t('Name of the FCKeditor role'),
|
| 154 |
),
|
| 155 |
'rid' => array(
|
| 156 |
'type' => 'int',
|
| 157 |
'not null' => TRUE,
|
| 158 |
'default' => 0,
|
| 159 |
'description' => t('Drupal role id'),
|
| 160 |
),
|
| 161 |
),
|
| 162 |
'primary key' => array('name', 'rid'),
|
| 163 |
);
|
| 164 |
|
| 165 |
return $schema;
|
| 166 |
}
|
| 167 |
|
| 168 |
/**
|
| 169 |
* Update from 6.x-1.0 to 6.x-1.1
|
| 170 |
*
|
| 171 |
*/
|
| 172 |
function fckeditor_update_6110() {
|
| 173 |
$ret = array();
|
| 174 |
|
| 175 |
$result = db_query('SELECT * FROM {fckeditor_settings}');
|
| 176 |
$global_profile_found = false;
|
| 177 |
while ($data = db_fetch_object($result)) {
|
| 178 |
if ($data->name == "FCKeditor Global Profile") {
|
| 179 |
$global_profile_found = true;
|
| 180 |
}
|
| 181 |
if ($data->settings) {
|
| 182 |
$settings = unserialize($data->settings);
|
| 183 |
}
|
| 184 |
if (isset($settings['excl_mode'], $settings['excl_list']) && !empty($settings['excl_list'])) {
|
| 185 |
switch ($settings['excl_mode']) {
|
| 186 |
case 0:
|
| 187 |
// normal exclusion based on the id
|
| 188 |
$settings['excl_fields'] = $settings['excl_list'];
|
| 189 |
$settings['excl_mode'] = 0;
|
| 190 |
break;
|
| 191 |
case 1:
|
| 192 |
//normal inclusion based on the id
|
| 193 |
$settings['excl_fields'] = $settings['excl_list'];
|
| 194 |
$settings['excl_mode'] = 1;
|
| 195 |
break;
|
| 196 |
case 2:
|
| 197 |
//path exclusion
|
| 198 |
$settings['excl_paths'] = $settings['excl_list'];
|
| 199 |
$settings['excl_mode'] = 0;
|
| 200 |
break;
|
| 201 |
case 3:
|
| 202 |
//path inclusion
|
| 203 |
$settings['excl_paths'] = $settings['excl_list'];
|
| 204 |
$settings['excl_mode'] = 1;
|
| 205 |
break;
|
| 206 |
}
|
| 207 |
unset($settings['excl_list']);
|
| 208 |
}
|
| 209 |
if (isset($settings['simple_incl_mode'], $settings['simple_incl_list']) && !empty($settings['simple_incl_list'])) {
|
| 210 |
switch ($settings['simple_incl_mode']) {
|
| 211 |
case 1:
|
| 212 |
//normal inclusion based on the id
|
| 213 |
$settings['simple_incl_fields'] = $settings['simple_incl_list'];
|
| 214 |
break;
|
| 215 |
case 3:
|
| 216 |
//path inclusion
|
| 217 |
$settings['simple_incl_paths'] = $settings['simple_incl_list'];
|
| 218 |
break;
|
| 219 |
}
|
| 220 |
unset($settings['simple_incl_mode']);
|
| 221 |
unset($settings['simple_incl_list']);
|
| 222 |
}
|
| 223 |
|
| 224 |
db_query("UPDATE {fckeditor_settings} SET settings='%s' WHERE name='%s'", serialize($settings), $data->name);
|
| 225 |
}
|
| 226 |
|
| 227 |
if (!$global_profile_found) {
|
| 228 |
db_query("INSERT INTO {fckeditor_settings} (name, settings) VALUES ('%s', '%s')", "FCKeditor Global Profile", serialize(array()));
|
| 229 |
}
|
| 230 |
return $ret;
|
| 231 |
}
|
| 232 |
|
| 233 |
/**
|
| 234 |
* Implementation of hook_uninstall()
|
| 235 |
*/
|
| 236 |
function fckeditor_uninstall() {
|
| 237 |
drupal_uninstall_schema('fckeditor');
|
| 238 |
}
|