| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: ckeditor.user.inc,v 1.1.2.1 2010/03/04 08:26:41 mephir Exp $ 3 /** 4 * CKEditor - The text editor for Internet - http://ckeditor.com 5 * Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. 6 * 7 * == BEGIN LICENSE == 8 * 9 * Licensed under the terms of any of the following licenses at your 10 * choice: 11 * 12 * - GNU General Public License Version 2 or later (the "GPL") 13 * http://www.gnu.org/licenses/gpl.html 14 * 15 * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") 16 * http://www.gnu.org/licenses/lgpl.html 17 * 18 * - Mozilla Public License Version 1.1 or later (the "MPL") 19 * http://www.mozilla.org/MPL/MPL-1.1.html 20 * 21 * == END LICENSE == 22 * 23 * @file 24 * CKEditor Module for Drupal 6.x 25 * 26 * This module allows Drupal to replace textarea fields with CKEditor. 27 * 28 * This HTML text editor brings to the web many of the powerful functionalities 29 * of known desktop editors like Word. It's really lightweight and doesn't 30 * require any kind of installation on the client computer. 31 */ 32 33 function ckeditor_user_delegate($type, $edit, &$user, $category = NULL) { 34 if ($type == 'form' && $category == 'account' && user_access('access ckeditor')) { 35 module_load_include('inc', 'ckeditor', 'includes/ckeditor.lib'); 36 37 $profile = ckeditor_user_get_profile($user); 38 $toolbar_options = ckeditor_load_toolbar_options(); 39 $skin_options = ckeditor_load_skin_options(); 40 $lang_options = ckeditor_load_lang_options(); 41 42 // because the settings are saved as strings we need to test for the string 'true' 43 if ($profile->settings['allow_user_conf'] == 't') { 44 $form['ckeditor'] = array( 45 '#type' => 'fieldset', 46 '#title' => t('Rich text editor settings'), 47 '#weight' => 10, 48 '#collapsible' => TRUE, 49 '#collapsed' => TRUE 50 ); 51 52 $form['ckeditor']['ckeditor_default'] = array( 53 '#type' => 'radios', 54 '#title' => t('Default state'), 55 '#default_value' => isset($user->ckeditor_default) ? $user->ckeditor_default : (isset($profile->settings['default']) ? $profile->settings['default'] : 'f'), 56 '#options' => array( 57 't' => t('Enabled'), 58 'f' => t('Disabled') 59 ), 60 '#description' => t('Should rich-text editing be enabled or disabled by default in textarea fields? If disabled, rich text editor may still be enabled using toggle or popup window.'), 61 ); 62 63 $form['ckeditor']['ckeditor_show_toggle'] = array( 64 '#type' => 'radios', 65 '#title' => t('Show disable/enable rich text editor toggle'), 66 '#default_value' => isset($user->ckeditor_show_toggle) ? $user->ckeditor_show_toggle : (isset($profile->settings['show_toggle']) ? $profile->settings['show_toggle'] : 't'), 67 '#options' => array( 68 't' => t('Yes'), 69 'f' => t('No') 70 ), 71 '#description' => t('Whether or not to show the disable/enable rich text editor toggle below the textarea. Works only if CKEditor is not running a popup window (see below).'), 72 ); 73 74 if (user_access('administer ckeditor')) { 75 $form['ckeditor']['ckeditor_show_fieldnamehint'] = array( 76 '#type' => 'radios', 77 '#title' => t('Show field name hint below each rich text editor'), 78 '#default_value' => !empty($user->ckeditor_show_fieldnamehint) ? $user->ckeditor_show_fieldnamehint : 't', 79 '#options' => array( 80 't' => t('Yes'), 81 'f' => t('No') 82 ), 83 ); 84 } 85 86 $form['ckeditor']['ckeditor_popup'] = array( 87 '#type' => 'radios', 88 '#title' => t('Use CKEditor in a popup window'), 89 '#default_value' => isset($user->ckeditor_popup) ? $user->ckeditor_popup : (isset($profile->settings['popup']) ? $profile->settings['popup'] : 'f'), 90 '#options' => array( 91 'f' => t('No'), 92 't' => t('Yes') 93 ), 94 '#description' => t('If this option is enabled a link to a popup window will be used instead of a textarea replace.'), 95 ); 96 97 $form['ckeditor']['ckeditor_skin'] = array( 98 '#type' => 'select', 99 '#title' => t('Skin'), 100 '#default_value' => isset($user->ckeditor_skin) ? $user->ckeditor_skin : (isset($profile->settings['skin']) ? $profile->settings['skin'] : 'default'), 101 '#options' => $skin_options, 102 '#description' => t('Choose a CKEditor skin.'), 103 ); 104 105 $form['ckeditor']['ckeditor_toolbar'] = array( 106 '#type' => 'select', 107 '#title' => t('Toolbar'), 108 '#default_value' => isset($user->ckeditor_toolbar) ? $user->ckeditor_toolbar : (isset($profile->settings['toolbar']) ? $profile->settings['toolbar'] : 'default'), 109 '#options' => $toolbar_options, 110 '#description' => t('Choose a CKEditor toolbar set.'), 111 ); 112 113 $form['ckeditor']['ckeditor_expand'] = array( 114 '#type' => 'select', 115 '#title' => t('Start the toolbar expanded'), 116 '#default_value' => isset($user->ckeditor_expand) ? $user->ckeditor_expand : (isset($profile->settings['expand']) ? $profile->settings['expand'] : 't'), 117 '#options' => array( 118 't' => t('Expanded'), 119 'f' => t('Collapsed') 120 ), 121 '#description' => t('The toolbar start expanded or collapsed.'), 122 ); 123 124 $form['ckeditor']['ckeditor_width'] = array( 125 '#type' => 'textfield', 126 '#title' => t('Width'), 127 '#default_value' => isset($user->ckeditor_width) ? $user->ckeditor_width : (isset($profile->settings['width']) ? $profile->settings['width'] : '100%'), 128 '#description' => t('Width in pixels or percent.') .' '. t('Example') .': 400 '. t('or') .' 100%.', 129 '#size' => 40, 130 '#maxlength' => 128, 131 ); 132 133 $form['ckeditor']['ckeditor_lang'] = array( 134 '#type' => 'select', 135 '#title' => t('Language'), 136 '#default_value' => isset($user->ckeditor_lang) ? $user->ckeditor_lang : (isset($profile->settings['lang']) ? $profile->settings['lang'] : 'en'), 137 '#options' => $lang_options, 138 '#description' => t('The language for the CKEditor interface.') 139 ); 140 141 $form['ckeditor']['ckeditor_auto_lang'] = array( 142 '#type' => 'radios', 143 '#title' => t('Auto-detect language'), 144 '#default_value' => isset($user->ckeditor_auto_lang) ? $user->ckeditor_auto_lang : (isset($profile->settings['auto_lang']) ? $profile->settings['auto_lang'] : 't'), 145 '#options' => array( 146 't' => t('Yes'), 147 'f' => t('No') 148 ), 149 '#description' => t('Use auto detect user language feature.') 150 ); 151 152 return array('ckeditor' => $form); 153 } 154 } 155 156 if ($type == 'validate') { 157 if (isset($edit['ckeditor_default'], $edit['ckeditor_popup']) && $edit['ckeditor_default'] == 't' && $edit['ckeditor_popup'] == 't') { 158 form_set_error('ckeditor_popup', t('If CKEditor is enabled by default, popup window must be disabled.')); 159 } 160 161 if (isset($edit['ckeditor_show_toggle'], $edit['ckeditor_popup']) && $edit['ckeditor_show_toggle'] == 't' && $edit['ckeditor_popup'] == 't') { 162 form_set_error('ckeditor_popup', t('If toggle is enabled, popup window must be disabled.')); 163 } 164 165 if (isset($edit['ckeditor_width']) && !preg_match('/^\d+%?$/', $edit['ckeditor_width'])) { 166 form_set_error('ckeditor_width', t('Enter valid width.') .' '. t('Example') .': 400 '. t('or') .' 100%.'); 167 } 168 } 169 170 return NULL; 171 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Mar 24 11:18:33 2011 | Cross-referenced by PHPXref 0.7 |