Fixed an old ckEditor extension and I added a File Browser to Upload and insert images on any given path. Great for CMS.
Requirements ¶
Yii 1.1 or above)...
Usage ¶
$this->widget('application.extensions.editor.CKkceditor',array(
"model"=>$model, # Data-Model
"attribute"=>'descripcion', # Attribute in the Data-Model
"height"=>'400px',
"width"=>'100%',
"filespath"=>(!$model->isNewRecord)?Yii::app()->basePath."/../media/paquetes/".$model->idpaquete."/":"",
"filesurl"=>(!$model->isNewRecord)?Yii::app()->baseUrl."/media/paquetes/".$model->idpaquete."/":"",
)
);
Secure
Is there any protection so that nobody can access the file manager directly and upload files remotely ?
Protection
Yes and Limited.
Because the way the kcFinder works session variables are set from the extension that the filemanager reads and picks up where to upload the files, those are not in the URL and the visitor is not able to modify where they will upload the files. Perhaps if someone hijacked the session there could be an issue but then again the whole session itself not just the extension.
There is one drawback there is a scenario where the SAME user opens up two windows and they end up showing the same filebrowser path; because as I mentioned session variables are pass-on, I would have to change the kcFinder code in order to achieve passing on direct values; but I wanted to keep it untouched because of the upgrades.
Tell me what you think.
more details
In order to use this i need a bit more info, sorry for not downloading it yet.
Please tell me exaclty what variables you set and against which variables you are doing the check and in what way .
Don't get me wrong, but the file managers tend to be very insecure, and i need to know before i add it to my projects .
One more thing.
What are the chances to use this with the session saved to database ?
Source
You can view the source code at :
http://code.google.com/p/yii-wysiwyg/source/browse/trunk/editor/CKkceditor.php
The kcFinder is an unmodified version sames goes for the ckeditor.
License
although up top right here it says New BSD license the downloaded CKkceditor.php file has a an LGPL license listed in the header.
Other wise so far it works well. Thanks.
small typo
in file CKkceditor.php
79 foreach ($this->config as $key=>$value) 80 { 81 $oCKeditor->Config[$key] = $value; 82 }
line 81 should have lower-case c in config:
else you won't be able to set any config settings for the editor.
expample about toolbar
how to customize toolbar? I try different way, but all not work.
see my code
<?php $this->widget('application.extensions.editor.CKkceditor',array( "model"=>$model, # Data-Model "attribute"=>'news_desc', # Attribute in the Data-Model "height"=>'400px', "width"=>'100%', "config"=> array( "config.toolbar"=> 'Full', "config.toolbar_Full"=>"[ ['Source','-','Save','NewPage','Preview','-','Templates'], ['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print', 'SpellChecker', 'Scayt'], ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'], ['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'], '/', ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'], ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'], ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'], ['BidiLtr', 'BidiRtl'], ['Link','Unlink','Anchor'], ['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak','Iframe'], '/', ['Styles','Format','Font','FontSize'], ['TextColor','BGColor'], ['Maximize', 'ShowBlocks','-','About'] ]", ), ));?>
Toolbar
Toolbar Config not work.
Toolbar
Toolbar Config not work.
Config problem.
To make config work, change:
line 81 from:
$oCKeditor->Config[$key] = $value;
to
$oCKeditor->config[$key] = $value;
Customizing toolbars
To customize the toolbar, you must use PHP arrays and not a string containing JavaScript arrays. Like so:
'config' => array( 'toolbar' => array( array('BidiLtr', 'BidiRtl' ), array('Link','Unlink','Anchor'), '/', array('Styles','Format','Font','FontSize'), array('TextColor','BGColor'), array('Maximize', 'ShowBlocks','-','About') ), ),
Also, don't for get the bug mentioned by huanito and undsoft.
Bugs Fixed
I have fixed the bugs pointed out and switched to github; you can download from there.
Troubles With thaccess, kcfinder breaks site
KCfinder puts htaccess which turns off PHP 8((
Can't understand why does it put it in wrong folder
Trouble displaying editor
I'm sure i am missing something simple but i cannot get editor to display. Elements are created and JS loaded but editor does not display.
I am trying a simple test
$this->widget('application.extensions.editor.CKkceditor',array( "model"=>Person::model()->findByPk(2), # Data-Model "attribute"=>'last_name', # Attribute in the Data-Model "height"=>'400px', "width"=>'100%', "config"=>array( 'toolbar' => array( array('Link','Unlink','Anchor'), array('Styles','Format','Font','FontSize'), array('TextColor','BGColor'), array('Maximize', 'ShowBlocks','-','About') ) //"filespath"=>(!$model->isNewRecord)?Yii::app()->basePath."/../media/paquetes/".$model->idpaquete."/":"", //"filesurl"=>(!$model->isNewRecord)?Yii::app()->baseUrl."/media/paquetes/".$model->idpaquete."/":"", ) ));
One thing i find suspicious is that the text area created does not contain an id attribute
<textarea cols="60" rows="8" name="Person[last_name]" style="display: none;">Nguyen</textarea> <script type="text/javascript">//<![CDATA[ CKEDITOR.replace('Person[last_name]', { "height": "400px", "width": "100%", "toolbar": [ [ "Link", "Unlink", "Anchor" ], [ "Styles", "Format", "Font", "FontSize" ], [ "TextColor", "BGColor" ], [ "Maximize", "ShowBlocks", "-", "About" ] ] }); //]]> </script>
What am i missing? Any thoughts?
When update - content doesn't loading
Hi!
Editor is ok, but when I getting UPDATE action, content which should be in editor area, isn't there... why?
how to fix this?
License
Why is this licensed under GPL?? Yii is licensed BSD and anything like this should be also.
Re: License
Probably because CKeditor uses GPL/LGPL, see: http://ckeditor.com/license
KCFinder with CDbHttpSession
I'm wondering how to use KCFinder with CDbHttpSession?
@Vedran session problem ! when use another session saving strategy,may meet some problem
may be i found the solution ,but haven't tried it :
please read this doc carefully : http://kcfinder.sunhater.com/docs/integrate
in the kcfinder-2.51\core dir there is a autoload.php file. you should implements your own's SessionSaveHandler , this should be same logic with the yii's CDbHttpSession , so you should read the yii's session table and operate it from the SessionSaveHandler class these two class share the same table , yes may be this is the key!! but i haven't tried it . hope it help you!
@yiqing95 KCFinder with CDbHttpSession
I am also thinking about the same solution. I think this might solve the problem. I'll try your advise and post about it here. thanks.
Basic Toolbar
For anyone trying to figure out how to use the "Basic" toolbar set, add this to your config:
'config' => array('toolbar' => 'Basic'),
fire only kcfinder
Hi,
is there a way to fire only kcfinder with a button to pick an image and populate a form field by example? Is somebody using this possibility ?
thanks in advance.
yiiframework.com comment editor
I wonder if yii developers who used this editor below on commenting field could share it with us as an extension )
meanwhile, this extension works great except that file browser works only when updating and not when creating post..
so this part:
"filespath"=>(!$model->isNewRecord)?Yii::app()->basePath."/../media/paquetes/".$model->idpaquete."/":"", "filesurl"=>(!$model->isNewRecord)?Yii::app()->baseUrl."/media/paquetes/".$model->idpaquete."/":"", )
i changed to this:
"filespath"=>Yii::app()->basePath."/../media/paquetes/".$model->idpaquete."/", "filesurl"=>Yii::app()->baseUrl."/media/paquetes/".$model->idpaquete."/", )
and now it works fine
download missing?
erm what happened to this extension?
in reply to #8604
TL;DR: its on github now,
see Here
and also click on the link above that says project page...
KCFinder with CDbHttpSession
I wrote a how-to about syncing the sessions between Yii and KCFinder when using CDbHttpSession
extraPlugins
I find how to insert my own made plugin..
Is there any way to d that?
Add id to element
To add an id attribute to the generated textarea element. in the file ckeditor_php5.php (or ckeditor_php4.php), change the line :
$out = "<textarea name=\"" . $name . "\"" . $attr . ">" . htmlspecialchars($value) . "</textarea>\n";
to
$element_id = str_replace("[", "_", $name); $element_id = str_replace("]", "", $element_id); $out = "<textarea name=\"" . $name . "\" id=\"" . $element_id . "\" " . $attr . ">" . htmlspecialchars($value) . "</textarea>\n";
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.