[eluser]Tom Glover[/eluser]
Just finished creating a tinyMCE library, well more of a helper. Basic at the moment as it only has two functions, creating the Head JS, and the Creating the input forms.
All the Code is Commented and easy to read. and it is very simple to integrate. To start you need tinyMCE JS and to take the folder called tinyMCE an place it with in a folder "js" folder in your doc root. the scructure shoul be like this:
Code: -js/
-js/tinymce/
-js/tinymce/tinymce.js "- Main JS
-js/tinymce/...
-system/...
-system/application/libraries/Tinymce.php "- File Below"
...
Library file: Tinymce.php
Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
* TinyMCE Inclusion Class
*
* @package CodeIgniter
* @subpackage Libraries
* @category WYSIWUG
* @author WackyWebs.net - Tom Glover
* @link http://ellislab.com/codeigniter/user-guide/libraries/zip.html
*/
class Tinymce {
/*
* Create Head Code - this converts $mode value to TinyMCE editors
* $Mode is the mode TinyMCE runs in - Please view TinyMCE manual for more detail
* $Theme is this style of running, eg advance or basic, defult advance
* $ToolLoc is the vertical location of the toolbar, Defult = 'top'
* $ToolAligh is the Horizontal Location of the toolbar, DeFult = 'left'
* $Resizeabe - Can the Client resize it on there web page.
* use in controllers like so:
* $data ['head'] = $this->tinymce->createhead('mode','theme','toolbar loc','toolbar align','resizable')
*/
function Createhead($Mode = 'textareas', $Theme = 'advanced', $ToolLoc = 'Top', $ToolAlign = 'left', $Resizable = FALSE)
{
$ci =& get_instance();
$baseJs = $ci->config->item('base_url').'/js';
return <<<EOF
tinyMCE.init({
// General options
mode : "$Mode",
theme : "$Theme",
plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups",
// Theme options
theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
theme_advanced_toolbar_location : "$ToolLoc",
theme_advanced_toolbar_align : "$ToolAlign",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : $Resizable,
// Example word content CSS (should be your site CSS) this one removes paragraph margins
content_css : "css/word.css",
// Drop lists for link/image/media/template dialogs
template_external_list_url : "lists/template_list.js",
external_link_list_url : "lists/link_list.js",
external_image_list_url : "lists/image_list.js",
media_external_list_url : "lists/media_list.js",
}
});
EOF;
}
/*
* Create Text Box
* Does not have to use variable in creation as can just return textarea, without
* $FullCode - True = Outputs full text area codein form tag! False = just the Tag no
* Form Wrap - Defult = False
* $Methord - Post or Get - Required if FC=True - String
* $Action - Controller to Call on Submission - Required if FC=True - String - Can use
* URL Helper
* $data ['head'] = $this->tinymce->createhead('Fullcode','Methord','Action')
*/
function Textarea($FullCode = FALSE, $Methord = "POST", $Action = '')
{
if ($FullCode === TRUE){
$mce = "<form action=\"$Action\" method=\"$Methord\"></form>";
$mce .= "<textarea name=\"TinyMCE\" cols=\"30\" rows=\"50\"></textarea>";
$mce .= "<input name=\"Submit\" type=\"button\" value=\"Submit\">";
$mce .= "</form>";
return $mce ;// Outputs to view file - String
}else{
$mce = "<textarea name=\"TinyMCE\" cols=\"30\" rows=\"50\"></textarea>";
return $mce ;// Outputs to view file - String
}
}
}
?>
Controller file:
Code: <?php
class Welcome extends Controller {
function Welcome()
{
parent::Controller();
}
function index()
{
$this->load->library('tinymce');
$data['head'] = $this->tinymce->createhead();
$data['mce'] = $this->tinymce->textarea(TRUE);
$this->load->view('welcome_message',$data);
}
}
?>
View File:
Code: <html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Title Here</title>
<?php echo $head?>
</head>
<body>
<?php echo $mce?>
</body>
</html>
Hope this helps you example of how to use are included in the code above, with details on what the options are and how to use them.
[eluser]Tom Glover[/eluser]
I am now no longer supporting this library as I have too many other commitments,please either continue to develop this or use the new plugin that is being developed to integrate tinyMCE and CI.
[eluser]CARP[/eluser]
[quote author="WackyWebs.net" date="1206493365"].. or use the new plugin that is being developed to integrate tinyMCE and CI.[/quote]
where's the new plugin? I'd like to try it
|