CodeIgniter Forums
Submitting data from ckeditor tags are cut - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Submitting data from ckeditor tags are cut (/thread-61018.html)



Submitting data from ckeditor tags are cut - El Forum - 08-29-2014

[eluser]mstdmstd[/eluser]
Hi all,
I want to include ckeditor in my ci 2.2 project, I do it with JS code like
Code:
jQuery(document).ready(function ($) {
            CKEDITOR.replace('content_textarea', {
                on: {
                    pluginsLoaded: function (evt) {
                        var doc = CKEDITOR.document, ed = evt.editor;
                        if (!ed.getCommand('bold'))
                            doc.getById('exec-bold').hide();
                        if (!ed.getCommand('link'))
                            doc.getById('exec-link').hide();
                    }
                }
            });
        });
it work but submitting the form the html tags are cut when submitting data to database
In config file I set value
Code:
$config['global_xss_filtering'] = false;
but result was the same. How to fix it ?
If theere is something better of ckeditor for CI project? ckeditor is power and easy...



Submitting data from ckeditor tags are cut - El Forum - 08-29-2014

[eluser]ivantcholakov[/eluser]
Are there form_validation rules for the textarea? strip_tags or similar filter?


Submitting data from ckeditor tags are cut - El Forum - 08-29-2014

[eluser]ivantcholakov[/eluser]
Also, see this page http://ckeditor.com/ckeditor_4.3_beta/samples/datafiltering.html

The configuration option config.allowedContent is interesting, set it to true. See their example there:

Code:
CKEDITOR.replace( textarea_id, {
allowedContent: true
} );

Edit: If it works, then you need to decide what tags are to be allowed and to enumerate them.

But... this is javascript implemented protection that is easy to be bypassed. I prefer to set config.allowedContent to true and then to apply my filter as a form validation rule, a server-side filter. Have a look at http://htmlpurifier.org/


Submitting data from ckeditor tags are cut - El Forum - 08-29-2014

[eluser]InsiteFX[/eluser]
You do not need all of that here is how to load ckeditor just using a css class.

Code:
<!-- Textareas and Editor Content -->                                                       |
<form action="contoller/method" method="post" class="form-horizontal" false;">

    <!-- CKEditor, just add the class 'ckeditor' to your textarea -->
    <!-- More info can be found at http://ckeditor.com -->
    <div class="form-group">
        <label class="col-md-2 control-label" for="textarea-editor">CKEditor</label>
        <div class="col-md-10">
            &lt;textarea id="textarea-editor" name="textarea-editor" class="ckeditor"&gt;&lt;/textarea>
        </div>
    </div>

&lt;/form&gt;

false in the form tag should be on submit return false you know how it goes

Simple to load it.

If you need to add anything add in the ckeditor/config.js file



Submitting data from ckeditor tags are cut - El Forum - 08-29-2014

[eluser]mstdmstd[/eluser]
Yes, thanks, it works with
Code:
allowedContent: true,
As for htmlpurifier I see example of using it with CI here:
https://github.com/EllisLab/CodeIgniter/wiki/htmlpurifier

My question are
1) which are most common settings for htmlpurifier for most common case, when content editor filles some articles?

2) Are there some convinient CI/ckeditor plugings ? After short review I would like to have possibility to select images from some specific directory.
Say, some article can have several imaghes uploaded, and I want user could select and insert images into article etc...




Submitting data from ckeditor tags are cut - El Forum - 08-30-2014

[eluser]ivantcholakov[/eluser]
In htmlpurifier's page this is mentioned: https://github.com/refringe/codeigniter-htmlpurifier. It is a helper, showing how you can make filters based on HTMLPurifier.

In general, I have made this good for me integration:
CKEditor + HTMLPurifier based filters + KCFinder (with some compatibility modifications, uploads images, etc.) + easy configuration of all the things (editor's toolbars should match to the allowed HTML-tags). It is a complex implementation, I don't know whether you be able to reproduce it within your project.

I don't know other solutions for CodeIgniter with such features.

See this page:
http://iridadesign.com/starter-public-edition-3/www/playground/online-editor/user-mode

In this example, If you choose "Online Editor - Admin Mode", you may test uploading images within content.