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