Code: // CKEditor code for text editor
// $toolbar choices = Admin - Basic - User
function text_editor ($field_name, $value, $toolbar = "Basic", $cols = "90%", $rows = 10) {
global $context, $nukeurl;
// DO NOT CHANGE THESE VALUES!
// "36" is the current version (3.6.4)
include_once('./includes/ckeditor36/ckeditor.php');
$CKEditor = new CKEditor();
$CKEditor->basePath = 'includes/ckeditor36/';
$CKEditor->returnOutput = true; // Do not print the code directly to the browser, return it instead
// Values below may be modified, but please be careful.
// Set the graphical look of CKEditor.
//$config['skin'] = 'office2003'; // default skin is -> kama --> available skins: kama, office2003, v2 --- uncomment line to use
// User Interface Color, works only on default skin: kama
$config['uiColor'] = '#AABBCC'; // User Interface Color ... sets CKEditor's toolbar gradient color
// set up Width and Height of CKEditor
$config['width'] = $cols; // width can be set to pixels or percentage... For Example: $config['width'] = 600; -OR- $config['width'] = '90%';
$config['height'] = $rows * 17; // Height is set in pixels. Each row is approximately 17 pixels tall. --> % DOES NOT WORK!
// Remove the toolbar collapse and resize defaults
$config['toolbarCanCollapse'] = false;
$config['removePlugins'] = 'resize';
$config['resize_enabled '] = false;
#####################################################################################
// LOCATION FOR IMAGE UPLOADS: --> Default: /userfiles/
// change code-located in file --> includes/ckfilemanager/connectors/php/config.php --- around line 34
// Set CKEditor Language --- Default language is 'en' (English)
//$config['defaultLanguage']= 'en'; // replace -en- with the language you wish to use as default, and then "uncomment" this line.
// Languages located in folder: includes/ckeditor36/lang
// By default CKEditor has a "Language Auto Detection" code built in. If you do not wish to use this, but instead, want the editor to be only one
// specific language, you will need to change the code line below to the desired language. (make sure to "uncomment" the line if you do this)
//$config['language'] = 'en'; // to use, change "en" to desired language and uncomment this line.
#####################################################################################
// TOOLBARS --- '/', = line break
// Currently there are 3 Toolbars: Admin, User, and Basic
// Admin toolbar has 'Flash' and 'Styles'. User toolbar does not. Otherwise both are the same.
if ($toolbar == "Admin") {
$config['toolbar'] = array(
array('Source','-','Save','NewPage','Preview','-','Templates'),
array('Cut','Copy','Paste','PasteText','PasteFromWord','-','Print'),
'/',
array('Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'),
array('Maximize', 'ShowBlocks'),
array('BidiLtr', 'BidiRtl'),
'/',
array('Bold','Italic','-','Subscript','Superscript'),
array('NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'),
array('JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'),
'/',
array('Link','Unlink','Anchor'),
array('Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'),
array('TextColor','BGColor'),
'/',
array('Styles','Format','Font','FontSize'), // Styles is removed on the User toolbar below.
array('About')
);
}
if ($toolbar == "User") {
$config['toolbar'] = array(
array('Source','-','Save','NewPage','Preview','-','Templates'),
array('Cut','Copy','Paste','PasteText','PasteFromWord','-','Print'),
'/',
array('Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'),
array('Maximize', 'ShowBlocks'),
array('BidiLtr', 'BidiRtl'),
'/',
array('Bold','Italic','-','Subscript','Superscript'),
array('NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'),
array('JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'),
'/',
array('Link','Unlink','Anchor'),
array('Image','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'),
array('TextColor','BGColor'),
'/',
array('Format','Font','FontSize'),
//array('Styles','Format','Font','FontSize'), // Styles (css) can potentially be dangerous, so it is removed in the above line.
array('About')
);
}
if ($toolbar == "Basic") {
$config['toolbar'] = array(
array( 'Source','-','Cut', 'Copy', 'PasteText', 'PasteFromWord', '-', 'Undo','Redo','-','BidiLtr', 'BidiRtl'),
'/',
array( 'Bold', 'Italic', '-', 'HorizontalRule', '-', 'NumberedList','BulletedList','-','OrderedList','UnorderedList','-','Link','Unlink','Anchor','-','About')
);
}
// Set up the filemanager/image upload system. Only Users and Admin can use this feature.
$config['filebrowserBrowseUrl'] = 'includes/ckfilemanager/browser/default/browser.html?Connector='.$nukeurl.'/includes/ckfilemanager/connectors/php/connector.php';
$config['filebrowserImageBrowseUrl'] = 'includes/ckfilemanager/browser/default/browser.html?Type=Image&Connector='.$nukeurl.'/includes/ckfilemanager/connectors/php/connector.php';
$config['filebrowserFlashBrowseUrl'] = 'includes/ckfilemanager/browser/default/browser.html?Type=Flash&Connector='.$nukeurl.'/includes/ckfilemanager/connectors/php/connector.php';
$config['filebrowserUploadUrl'] = $nukeurl.'/includes/ckfilemanager/connectors/php/upload.php?Type=File';
$config['filebrowserImageUploadUrl'] = $nukeurl.'/includes/ckfilemanager/connectors/php/upload.php?Type=Image';
$config['filebrowserFlashUploadUrl'] = $nukeurl.'/includes/ckfilemanager/connectors/php/upload.php?Type=Flash';
if ($context['user']['is_logged']) {
$CKEditor->Config['Enabled'] = true; // for session checking --- "connector" enabled, but only for logged in members
$CKEditor->Config['ImageBrowser'] = true;
$CKEditor->Config['ImageUpload'] = true;
} elseif ($context['user']['is_nukeadmin']) {
$CKEditor->Config['Enabled'] = true; // for session checking --- "connector" enabled, but only for logged in members
$CKEditor->Config['ImageBrowser'] = true;
$CKEditor->Config['ImageUpload'] = true;
$CKEditor->Config['LinkBrowser'] = true;
$CKEditor->Config['FlashBrowser'] = true;
$CKEditor->Config['LinkUpload'] = true;
$CKEditor->Config['FlashUpload'] = true;
} elseif ($context['user']['is_guest']) { // guests are not allowed to see or do anything...
$CKEditor->Config['Enabled'] = false;
$CKEditor->Config['ImageBrowser'] = false;
$CKEditor->Config['ImageUpload'] = false;
}
// Create editor instance.
echo $CKEditor->editor($field_name, $value, $config);
} // end function text_editor
|