Changed HTML editor processing, added TinyMCE

This commit is contained in:
Deon George
2013-11-20 13:26:02 +11:00
parent 610c223cb8
commit 1ec370f07a
82 changed files with 598 additions and 19 deletions

View File

@@ -88,12 +88,67 @@ abstract class lnApp_Form extends Kohana_Form {
if (! isset($attributes['id']))
$attributes['id'] = preg_replace('/[\[\]]/','_',$name);
if (! isset($attributes['nowysihtml']))
Script::factory()
->type('stdin')
->data('$("#'.$attributes['id'].'").wysihtml5();');
else
unset($attributes['wysihtml']);
if (isset($attributes['editor'])) {
switch ($attributes['editor']) {
case 'tinymce':
Script::factory()
->type('file')
->data('media/vendor/tinymce/js/tinymce/jquery.tinymce.min.js');
Script::factory()
->type('stdin')
->data('$("#'.$attributes['id'].'").tinymce({
script_url : "'.URL::site('media/vendor/tinymce/js/tinymce/tinymce.min.js').'",
theme : "modern",
plugins: [ "code","link","image","preview","table" ],
menubar: "",
toolbar: "undo redo | styleselect | bold italic | link image | table | preview | code",
});');
break;
case 'wysihtml5':
Style::factory()
->type('file')
->data('media/theme/bootstrap/vendor/bootstrap-wysihtml5-0.0.2/bootstrap-wysihtml5-0.0.2.css');
Script::factory()
->type('file')
->data('media/theme/bootstrap/vendor/bootstrap-wysihtml5-0.0.2/libs/js/wysihtml5-0.3.0_rc2.min.js');
Script::factory()
->type('file')
->data('media/theme/bootstrap/vendor/bootstrap-wysihtml5-0.0.2/bootstrap-wysihtml5-0.0.2.min.js');
Script::factory()
->type('stdin')
->data('$("#'.$attributes['id'].'").wysihtml5({
html: true,
parserRules: {
tags: {
p: {},
strong: {},
table: {},
tbody: {},
thead: {},
tr: {},
td: {
check_attributes: {
colspan: "numbers",
rowspan: "numbers",
}
}
}
}
});');
break;
default:
throw new Kohana_Exception('Unknown editor :editor for textarea',array(':editor'=>$attributes['editor']));
}
unset($attributes['edit']);
}
return sprintf(static::_controlgroup($name,$attributes),parent::textarea($name,$body,$attributes,$double_encode));
}