| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: ckeditor.page.inc,v 1.1.2.3 2010/09/15 15:03:33 wwalc 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_help_delegate($path, $arg) { 34 switch ($path) { 35 case 'admin/settings/help#description': 36 $output = t('Enables the usage of CKEditor (WYSIWYG editor) instead of plain text fields.'); 37 break; 38 39 case 'admin/settings/ckeditor/edit/%': 40 case 'admin/settings/ckeditor/add': 41 $output = '<p>'. t('CKEditor is highly configurable. The most commonly used features are listed below. You can also customize CKEditor to your needs by changing the configuration file: %ckeditor_module_config. This is also the only way to define new toolbar sets.', 42 array( 43 '%ckeditor_module_config' => drupal_get_path('module', 'ckeditor') .'/ckeditor.config.js', 44 )) .'</p>'; 45 $output .= '<p>'. t('It is advised to not edit the configuration file that is distributed with CKEditor: %ckeditor_config_file (%ckeditor_config_path) because you may overwrite it accidentally when you update the editor.', 46 array( 47 '%ckeditor_config_path' => drupal_get_path('module', 'ckeditor') .'/ckeditor/config.js', 48 '%ckeditor_config_file' => 'config.js', 49 )) .'</p>'; 50 break; 51 52 case 'admin/settings/ckeditor/editg': 53 case 'admin/settings/ckeditor/add': 54 $output = '<p>'. t('The Global Profile allows you to define settings that are common for all profiles. Values defined in other profiles will be appended to the global configuration. This way you can avoid repeating some of the settings that are usually the same in each profile.') .'</p>'; 55 break; 56 57 case 'admin/settings/ckeditor': 58 $output = 59 '<p>'. t('The CKEditor module allows Drupal to replace textarea fields with a rich text or !wysiwyg editor. This editor brings many of the powerful functionalities of known desktop editors like Word to the web. It\'s relatively lightweight and doesn\'t require any kind of installation on the client computer.', 60 array( 61 '!wysiwyg' => '<acronym title="'. t('What You See Is What You Get') .'">'. t('WYSIWYG') .'</acronym>', 62 )) .'</p>'. 63 '<p>'. t('More information about the editor is located at the !ckeditorlink. A small !userguidelink is available.', 64 array( 65 '!ckeditorlink' => l(t('CKEditor homepage'), 'http://ckeditor.com'), 66 '!userguidelink' => l(t('user guide'), 'http://docs.cksource.com/FCKeditor_2.x/Users_Guide/Quick_Reference'), 67 )) .'</p>'. 68 '<p>'. t('Profiles can be defined based on user roles. A CKEditor profile can define which pages receive this CKEditor capability, what buttons or themes are enabled for the editor, how the editor is displayed, and a few other editor functions. It is possible also to define the Global Profile that will hold values that will be appended to all other profiles.') .'</p>'. 69 '<p>'. t('Lastly, only users with the %accesspermission !permissionlink will be able to use CKEditor.', 70 array( 71 '%accesspermission' => t('access ckeditor'), 72 '!permissionlink' => l(t('permission'), 'admin/user/permissions') 73 )) .'</p>'; 74 break; 75 76 case 'admin/help#ckeditor': 77 $output = '<p>'. t('The CKEditor module allows Drupal to replace textarea fields with a rich text or !wysiwyg editor. This editor brings many of the powerful functionalities of known desktop editors like Word to the web. It\'s relatively lightweight and doesn\'t require any kind of installation on the client computer.', 78 array( 79 '!wysiwyg' => '<acronym title="'. t('What You See Is What You Get') .'">'. t('WYSIWYG') .'</acronym>', 80 )) .'</p>'; 81 $output .= '<p>'. t('More information about the editor is located at the !ckeditorlink. A small !userguidelink is available.', 82 array( 83 '!ckeditorlink' => l(t('CKEditor homepage'), 'http://ckeditor.com'), 84 '!userguidelink' => l(t('user guide'), 'http://docs.cksource.com/FCKeditor_2.x/Users_Guide/Quick_Reference'), 85 )) .'</p>'. 86 $output .= '<h3>'. t('Configuration') .'</h3>'; 87 $output .= '<ol>'; 88 $output .= '<li>'. t('Go to the !ckeditorlink and download the latest version of CKEditor. Then uncompress the contents of the ckeditor directory of the downloaded file to %ckeditordir.', 89 array( 90 '!ckeditorlink' => l(t('CKEditor homepage'), 'http://ckeditor.com/download'), 91 '%ckeditordir' => base_path() . drupal_get_path('module', 'ckeditor') .'/ckeditor/', 92 )) .'</li>'; 93 $output .= '<li>'. t('Enable the module as usual from Drupal\'s admin pages.') .'</li>'; 94 $output .= '<li>'. t('Grant permissions for use of CKEditor in !adminpath.', 95 array( 96 '!adminpath' => l(t('Administer') .' > '. t('User management') .' > '. t('Permissions'), 'admin/user/permissions'), 97 )) .'</li>'; 98 $output .= '<li>'. t('Under !adminpath, adjust the ckeditor profiles. In each profile you can choose which textareas will be replaced by CKEditor, select default toolbar and configure some more advanced settings.', 99 array( 100 '!adminpath' => l(t('Administer') .' > '. t('Site configuration') .' > '. t('CKEditor'), 'admin/settings/ckeditor'), 101 )) .'</li>'; 102 $output .= '<li>'. t('For the Rich Text Editing to work you also need to configure your !filterlink for the users that may access Rich Text Editing. Either grant those users Full HTML access or use the following list of tags in the HTML filter:', 103 array( 104 '!filterlink' => l(t('filters'), 'admin/settings/filters'), 105 )) . 106 '<br /><code>'. htmlspecialchars('<a> <p> <span> <div> <h1> <h2> <h3> <h4> <h5> <h6> <img> <map> <area> <hr> <br> <br /> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <em> <b> <u> <i> <strong> <font> <del> <ins> <sub> <sup> <quote> <blockquote> <pre> <address> <code> <cite> <embed> <object> <param> <strike> <caption>') .'</code><br />'; 107 $output .= t('If you\'re going to use CKEditor with Filtered HTML input format, please read also "Setting up filters" section in !readme', 108 array( 109 '!readme' => l('README.txt', drupal_get_path('module', 'ckeditor') .'/README.txt') 110 )) .'</li>'; 111 $output .= '<li>'. t('To have a better control over line breaks, you should disable %settingname in the chosen filter (recommended).', 112 array( 113 '%settingname' => t('Line break converter'), 114 )) .'</li>'; 115 $output .= '<li>'. t('Modify the %ckconfig file to your custom needs (optional). Available configuration settings are available in the !apidocs.', 116 array( 117 '%ckconfig' => base_path() . drupal_get_path('module', 'ckeditor') .'/ckeditor/ckeditor.config.js', 118 '!apidocs' => l(t('API documentation'), 'http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html') 119 )) .'</li>'; 120 $output .= '</ol>'; 121 122 $output .= '<a name="fieldinclexcl"></a>'; 123 $output .= '<h3>'. t('Defining field inclusion/exclusions') .'</h3>'; 124 $output .= '<p>'. t('In order to specifically display CKEditor on those text areas on which you need it, the CKEditor module provides a powerfull method to define fields that should be enhanced with CKEditor. The first choice you have to make is whether you want to display CKEditor on all textareas and define a list of exceptions, or if you don\'t want to display CKEditor unless it is specifically enabled. This choice is made in the %settingname setting.', 125 array( 126 '%settingname' => t('Use inclusion or exclusion mode'), 127 )) .'</p>'; 128 $output .= '<p>'. t('Next, the list of exceptions has to be defined. This list follows a specific syntax: the path to a field is defined by specifying the content type followed by @ character, specifying the path followed by dot and appending the field name at the end. You may decide to not use the content type. The field %fieldname on page %pathname would thus be addressed as %result. You can use wildcards * and ? anywhere in this line. If you have a dot in your field name and it causes problems, you can escape it with a slash (\).', 129 array( 130 '%fieldname' => 'edit-log', 131 '%pathname' => 'node/add/page', 132 '%result' => 'node/add/page.edit-log', 133 )) .'</p>'; 134 135 $output .= '<strong>'. t('Some examples:') .'</strong>'; 136 $output .= '<ul>'; 137 $output .= '<li><code>node/add/page</code>: '. t('matches all fields on %pathname', array('%pathname' => 'node/add/page')) .'</li>'; 138 $output .= '<li><code>*.edit-log</code>: '. t('matches all fields called %fieldname on any page', array('%fieldname' => 'edit-log')) .'</li>'; 139 $output .= '<li><code>blog@*.edit-body</code>: '. t('matches all fields called %fieldname on pages related to node type %typename', array('%fieldname' => 'edit-body', '%typename' => 'blog')) .'</li>'; 140 $output .= '<li><code>forum@*.*</code>: '. t('matches all fields on pages related to node type %nodetype', array('%nodetype' => 'forum')) .'</li>'; 141 $output .= '<li><code>node/add/*</code>: '. t('matches all fields on pages such as %pathname1, %pathname2, etc.', array('%pathname1' => 'node/add/page', '%pathname2' => 'node/add/story')) .'</li>'; 142 $output .= '<li><code>node/add/*.edit-log</code>: '. t('matches all %fieldname fields on pages such as %pathname1, %pathname2, etc.', array('%fieldname' => 'edit-log', '%pathname1' => 'node/add/page', '%pathname2' => 'node/add/story')) .'</li>'; 143 $output .= '<li><code>node/add/*.edit-user-*</code>: '. t('matches fields starting with %fieldname on pages starting with %pathname', array('%fieldname' => 'edit-user-', '%pathname' => 'node/add/')) .'</li>'; 144 $output .= '</ul>'; 145 146 $output .= '<h3>'. t('Troubleshooting') .'</h3>'; 147 $output .= '<p>'; 148 $output .= t('Take a look at !listlink when installing CKEditor (or check !troubleshooting).', 149 array( 150 '!listlink' => l(t('the list of common problems'), 'http://drupal.ckeditor.com/troubleshooting'), 151 '!troubleshooting' => l('TROUBLESHOOTING.txt', drupal_get_path('module', 'ckeditor') .'/TROUBLESHOOTING.txt') 152 )); 153 $output .= ' '. t('If you are looking for more information, have any trouble in configuration or if you found an issue, please visit the !officiallink.', array('!officiallink' => l(t('official project page'), 'http://drupal.org/project/ckeditor'))); 154 $output .= ' '. t('More information about how to tune up CKEditor for your theme can be found !herelink.', array('!herelink' => l(t('here'), 'http://drupal.fckeditor.net/tricks'))); 155 $output .= '</p>'; 156 157 $output .= '<h3>'. t('Uploading images and files') .'</h3>'; 158 $output .= '<p>'. t('There are three ways for uploading files:') .'</p>'; 159 $output .= '<ol>'; 160 $output .= '<li>'. t('By using !ckfinder (commercial).', 161 array( 162 '!ckfinder' => l(t('CKFinder'), 'http://ckfinder.com'), 163 )) .'</li>'; 164 $output .= '<li>'. t('By using a module like !imcelink, !iblink or !webfmlink.', 165 array( 166 '!imcelink' => l(t('IMCE'), 'http://drupal.org/project/imce'), 167 '!iblink' => l(t('Image Browser'), 'http://drupal.org/project/imagebrowser'), 168 '!webfmlink' => l(t('Web File Manager'), 'http://drupal.org/project/webfm'), 169 )) .'</li>'; 170 $output .= '<li>'. t('By using the core upload module.') .'</li>'; 171 $output .= '</ol>'; 172 173 break; 174 } 175 return !empty($output) ? $output : ''; 176 } 177 178 /** 179 * AJAX callback - XSS filter 180 */ 181 function ckeditor_filter_xss() { 182 $GLOBALS['devel_shutdown'] = FALSE; 183 184 if (!isset($_POST['text']) || !is_string($_POST['text']) || !is_array($_POST['filters'])) { 185 exit; 186 } 187 188 $text = $_POST['text']; 189 $text = strtr($text, array('<!--' => '__COMMENT__START__', '-->' => '__COMMENT__END__')); 190 191 foreach ($_POST['filters'] as $module_delta) { 192 if (!is_string($module_delta)) { 193 continue; 194 } 195 $module = strtok($module_delta, "/"); 196 $delta = strtok("/"); 197 $format = strtok("/"); 198 199 if (!module_hook($module, 'filter')) { 200 continue; 201 } 202 203 //built-in filter module, a special case where we would like to strip XSS and nothing more 204 if ($module == 'filter' && $delta == 0) { 205 preg_match_all("|</?([a-z][a-z0-9]*)(?:\b[^>]*)>|i", $text, $matches); 206 if ($matches[1]) { 207 $tags = array_unique($matches[1]); 208 $text = filter_xss($text, $tags); 209 } 210 } 211 else { 212 $text = module_invoke($module, 'filter', 'process', $delta, $format, $text); 213 } 214 } 215 216 $text = strtr($text, array('__COMMENT__START__' => '<!--', '__COMMENT__END__' => '-->')); 217 218 echo $text; 219 exit; 220 }
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 |