| [ 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 * This module allows Drupal to replace textarea fields with CKEditor. 26 * 27 * CKEditor is an online rich text editor that can be embedded inside web pages. 28 * It is a WYSIWYG (What You See Is What You Get) editor which means that the 29 * text edited in it looks as similar as possible to the results end users will 30 * see after the document gets published. It brings to the Web popular editing 31 * features found in desktop word processors such as Microsoft Word and 32 * OpenOffice.org Writer. CKEditor is truly lightweight and does not require any 33 * kind of installation on the client computer. 34 */ 35 36 /** 37 * Implementation of hook_features_export_options() 38 */ 39 function ckeditor_profile_features_export_options() { 40 $options = array(); 41 $profiles = (array) ckeditor_profile_load(); 42 foreach ($profiles as $name => $profile) { 43 $options[$name] = $profile->name; 44 } 45 return $options; 46 } 47 48 /** 49 * Implementation of hook_features_export() 50 */ 51 function ckeditor_profile_features_export($data, &$export, $module_name = '') { 52 $pipe = array(); 53 foreach ((array)$data as $name) { 54 $profile = ckeditor_profile_load($name); 55 if ($profile) { 56 $export['features']['ckeditor_profile'][$name] = $name; 57 58 // Write dependencies on all the roles referenced by this profile 59 foreach ((array) $profile->rids as $rid => $role_name) { 60 $pipe['user_role'][] = $role_name; 61 } 62 } 63 } 64 $export['dependencies'][] = 'ckeditor'; 65 return $pipe; 66 } 67 68 /** 69 * Implementation of hook_features_export_render() 70 */ 71 function ckeditor_profile_features_export_render($module_name, $data) { 72 $profiles = array(); 73 $roles = user_roles(); 74 foreach ($data as $name) { 75 $profile = (array) ckeditor_profile_load($name); 76 77 // Convert Role IDs into role names only 78 $roles = array_values((array) $profile['rids']); 79 if (empty($roles)) { 80 $profile['roles'] = array(); 81 } 82 else { 83 $profile['roles'] = array_combine($roles, $roles); 84 } 85 unset($profile['rids']); 86 87 $profiles[$name] = $profile; 88 } 89 $code = ' $data = '. features_var_export($profiles, ' ') .';'. PHP_EOL; 90 $code .= ' return $data;'; 91 92 return array('ckeditor_profile_defaults' => $code); 93 } 94 95 /** 96 * Implementation of hook_features_revert() 97 */ 98 function ckeditor_profile_features_revert($module) { 99 $data = module_invoke($module, 'ckeditor_profile_defaults'); 100 $roles = user_roles(); 101 foreach ($data as $name => $profile) { 102 // Restore the profile settings 103 db_query("DELETE FROM {ckeditor_settings} WHERE name = '%s'", $name); 104 db_query("INSERT INTO {ckeditor_settings} (name, settings) VALUES('%s', '%s')", $name, serialize($profile['settings'])); 105 106 // Restore the profile roles 107 foreach ($roles as $rid => $role_name) { 108 if (in_array($role_name, (array) $profile['roles'])) { 109 if (!db_result(db_query("SELECT rid FROM {ckeditor_role} WHERE rid = %d AND name = '%s'", $rid, $name))) { 110 db_query("INSERT INTO {ckeditor_role} (rid, name) VALUES(%d, '%s')", $rid, $name); 111 } 112 } 113 else { 114 // Make sure they don't have access 115 db_query("DELETE FROM {ckeditor_role} WHERE rid = %d AND name = '%s'", $rid, $name); 116 } 117 } 118 } 119 }
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 |