Topic: [FAQ] Using CKeditor instead of RTE

if you dould set up a demo cutenews that uses this hack as prove, i could move it to the hack forum, that or a couple of people need to have confirmed this to be working.

Re: [FAQ] Using CKeditor instead of RTE

i know, i'm lazy, and could just as well try the code. But i'm lazy...

Re: [FAQ] Using CKeditor instead of RTE

funpic.de is the worst host ever.
If you have a hard drive of 2 giga, they give out a total of disk space higher then the actual disk. so many users upload to a full hard drive, while their account still allows more.

Topic splitted and moved

Re: [FAQ] Using CKeditor instead of RTE

This hack works with 1.4.6.
http://cutephp.com/forum/style_emoticons/default/laugh.gif

Re: [FAQ] Using CKeditor instead of RTE

Hi Damoor,
thank you for testing with CN 1.4.6 http://cutephp.com/forum/style_emoticons/default/smile.gif No code changes had to be made?


Thank you!


Worked perfectly without any code changes.
Great hack Filou83!

Re: [FAQ] Using CKeditor instead of RTE

Well some years ago I wrote too this hack, but seems it's deleted from board. Thanks Filou for rewriting this script.
And I integrated ckfinder into ckeditor and into images.mdu, maybe I repost it here some day if interested.

Re: [FAQ] Using CKeditor instead of RTE

Well some years ago I wrote too this hack, but seems it's deleted from board. Thanks Filou for rewriting this script.
And I integrated ckfinder into ckeditor and into images.mdu, maybe I repost it here some day if interested.


Yes, you did hanska, and it is here:
http://cutephp.com/forum/index.php?showtop...mp;#entry130754
I still use it.

Re: [FAQ] Using CKeditor instead of RTE

Indeed, there was a ckeditor post from hanska in the feedback forum too.
And yes it probably got deleted like all older posts in the forums.

Re: [FAQ] Using CKeditor instead of RTE

OK

I'll try to recover that ckfinder integration post today-tomorrow.
Stay tuned http://cutephp.com/forum/style_emoticons/default/wink.gif

10 (edited by 2012-02-29 06:56:50)

Re: [FAQ] Using CKeditor instead of RTE

OK, here it comes. I haven't time for test it yet.
Requirements: [WYSIWYG] Using CKeditor instead of RTE, Replaces RTE by ckeditor and A copy of CKFinder from ckfinder.com

Before modifing any files, backup them first (addnews.mdu, editnews.mdu and images.mdu).

At 1st make new directory inside cutnews’s data dir named upfiles (where upimages dir is, you can copy all images from upimages to upfiles/images) and chmod it to be rewritable (ex. 777)

Open config.php from ckfinder’s directory.
1. Find:


 
function CheckAuthentication()
{
// WARNING : DO NOT simply return "true". By doing so, you are allowing
// "anyone" to upload and list the files in your server. You must implement
// some kind of session validation here. Even something very simple as...

// return isset($_SESSION['IsAuthorized']) && $_SESSION['IsAuthorized'];

// ... where $_SESSION['IsAuthorized'] is set to "true" as soon as the
// user logs in your system. To be able to use session variables don't
// forget to add session_start() at the top of this file.

return false;
}

Replace with:

function CheckAuthentication()
{
// WARNING : DO NOT simply return "true". By doing so, you are allowing
// "anyone" to upload and list the files in your server. You must implement
// some kind of session validation here. Even something very simple as...

// return isset($_SESSION['IsAuthorized']) && $_SESSION['IsAuthorized'];

// ... where $_SESSION['IsAuthorized'] is set to "true" as soon as the
// user logs in your system. To be able to use session variables don't
// forget to add session_start() at the top of this file.

return true;
}

2. Find:

ATTENTION: The trailing slash is required.
*/
$baseUrl = '/ckfinder/userfiles/';
/*


Replace with :

ATTENTION: The trailing slash is required.
*/
$baseUrl = 'http://www.yourdomain.com/path to cutenews/data/upfiles';
/*

3. Find:

 
ATTENTION: The trailing slash is required.
*/
$baseDir = resolveUrl($baseUrl);

/*


Replace with :

ATTENTION: The trailing slash is required.
*/
$baseDir = '/home/login/public_html/path to cutenews/data/upfiles ';

/*

close and save config.php
open addnews.mdu
1. Find :

if($use_wysiwyg){
    echo '
<script type=\"text/javascript\" src=\"path to ckeditor/ckeditor.js\"></script>
    ';


replace with - and be sure to replace " path to ckfinder " by "../ckfinder" or "cutenews/ckfinder":

if($use_wysiwyg){
    echo '
<script type=\"text/javascript\" src=\" path to ckeditor /ckeditor.js\"></script>
<script type=\"text/javascript\" src=\" path to ckfinder /ckfinder.js\"></script>
    ';


2. Find:

echo '<textarea rows=\"12\" cols=\"74\" id=\"full_story\" name=\"full_story\" tabindex=5></textarea>';

if($use_wysiwyg){
    
    $showsmilies = explode(',', $config_smilies);
    foreach($showsmilies as $showsmile){
        $showsmile = trim($showsmile);
        $showsmiliesdecriptions .= "'".$showsmile."', ";
        $showsmiliesoutput .= "'".$showsmile.".gif', ";
    }
    echo "<script type=\"text/javascript\">
    //<![CDATA[
    (function()
    {
        var settings = {
            customConfig: '',
            entities_latin: false,
            entities_greek: false,
            toolbar: [
                    ['Source','Scayt','-','Copy','Paste','PasteText','PasteFromWord','Cut'],
                    ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
                    ['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar'],
                    ['Link','Unlink','Anchor'],
                    '/',
                    ['Format','FontSize','TextColor','BGColor'],
                    ['Bold','Italic','Strike'],
                    ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
                    ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
                    ['Maximize','About']
            ],
            smiley_path: '".$config_http_script_dir."/data/emoticons/',
            smiley_images: [".$showsmiliesoutput."],
            smiley_descriptions: [".$showsmiliesdecriptions."]
        };
        CKEDITOR.replace ('short_story', settings);
        CKEDITOR.replace ('full_story', settings);
    })();
    //]]>
    </script>";
}


replace with:

echo '<textarea rows=\"12\" cols=\"74\" id=\"full_story\" name=\"full_story\" tabindex=5></textarea>
';

if($use_wysiwyg){
    
    $showsmilies = explode(',', $config_smilies);
    foreach($showsmilies as $showsmile){
        $showsmile = trim($showsmile);
        $showsmiliesdecriptions .= "'".$showsmile."', ";
        $showsmiliesoutput .= "'".$showsmile.".gif', ";
    }
    echo "
<script type=\"text/javascript\">
    //<![CDATA[
    (function()
    {
        var settings = {
            customConfig: '',
            entities_latin: false,
            entities_greek: false,
            toolbar: [
                    ['Source','Scayt','-','Copy','Paste','PasteText','PasteFromWord','Cut'],
                    ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
                    ['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar'],
                    ['Link','Unlink','Anchor'],
                    '/',
                    ['Format','FontSize','TextColor','BGColor'],
                    ['Bold','Italic','Strike'],
                    ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
                    ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
                    ['Maximize','About']
            ],
            smiley_path: '".$config_http_script_dir."/data/emoticons/',
            smiley_images: [".$showsmiliesoutput."],
            smiley_descriptions: [".$showsmiliesdecriptions."]
        };

var editor_short = CKEDITOR.replace('short_story', settings);
editor_short.setData( '' );
CKFinder.setupCKEditor( editor_short, '../ckfinder/' );

var editor_full = CKEDITOR.replace('full_story', settings);
editor_full.setData( '' );
CKFinder.setupCKEditor( editor_full, '../ckfinder/' );
    })();
    //]]>
    </script>

";
}

save and close addnews.mdu

open editnews.mdu
1. Find:

if($use_wysiwyg){
    echo '
<script type=\"text/javascript\" src=\"path to ckeditor/ckeditor.js\"></script>
    ';
}

replace with - and be sure to replace " path to ckfinder " by "../ckfinder" or "cutenews/ckfinder":

if($use_wysiwyg){
    echo '
<script type=\"text/javascript\" src=\" path to ckeditor /ckeditor.js\"></script>
<script type=\"text/javascript\" src=\" path to ckfinder /ckfinder.js\"></script>
    ';


2. Find:

echo "<textarea rows=\"12\" cols=\"74\" id=\"full_story\" name=\"full_story\" tabindex=4>$item_db[4]</textarea>";

if($use_wysiwyg){
    
    $showsmilies = explode(',', $config_smilies);
    foreach($showsmilies as $showsmile){
        $showsmile = trim($showsmile);
        $showsmiliesdecriptions .= "'".$showsmile."', ";
        $showsmiliesoutput .= "'".$showsmile.".gif', ";
    }
    echo "<script type=\"text/javascript\">
    //<![CDATA[
    (function()
    {
        var settings = {
            customConfig: '',
            entities_latin: false,
            entities_greek: false,
            toolbar: [
                    ['Source','Scayt','-','Copy','Paste','PasteText','PasteFromWord','Cut'],
                    ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
                    ['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar'],
                    ['Link','Unlink','Anchor'],
                    '/',
                    ['Format','FontSize','TextColor','BGColor'],
                    ['Bold','Italic','Strike'],
                    ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
                    ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
                    ['Maximize','About']
            ],
            smiley_path: '".$config_http_script_dir."/data/emoticons/',
            smiley_images: [".$showsmiliesoutput."],
            smiley_descriptions: [".$showsmiliesdecriptions."]
        };
        CKEDITOR.replace ('short_story', settings);
        CKEDITOR.replace ('full_story', settings);
    })();
    //]]>
    </script>";
}

replace with:

echo "<textarea rows=\"12\" cols=\"74\" id=\"full_story\" name=\"full_story\" tabindex=4>$item_db[4]</textarea>";

if($use_wysiwyg){
    
    $showsmilies = explode(',', $config_smilies);
    foreach($showsmilies as $showsmile){
        $showsmile = trim($showsmile);
        $showsmiliesdecriptions .= "'".$showsmile."', ";
        $showsmiliesoutput .= "'".$showsmile.".gif', ";
    }
    echo "<script type=\"text/javascript\">
    //<![CDATA[
    (function()
    {
        var settings = {
            customConfig: '',
            entities_latin: false,
            entities_greek: false,
            toolbar: [
                    ['Source','Scayt','-','Copy','Paste','PasteText','PasteFromWord','Cut'],
                    ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
                    ['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar'],
                    ['Link','Unlink','Anchor'],
                    '/',
                    ['Format','FontSize','TextColor','BGColor'],
                    ['Bold','Italic','Strike'],
                    ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
                    ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
                    ['Maximize','About']
            ],
            smiley_path: '".$config_http_script_dir."/data/emoticons/',
            smiley_images: [".$showsmiliesoutput."],
            smiley_descriptions: [".$showsmiliesdecriptions."]
        };
var editor_short = CKEDITOR.replace('short_story', settings);
CKFinder.setupCKEditor( editor_short, '../ckfinder/' );

var editor_full = CKEDITOR.replace('full_story', settings);
CKFinder.setupCKEditor( editor_full, '../ckfinder/' );
    })();
    //]]>
    </script>";
}

save and close editnews.mdu

open images.mdu

just replace all with this code (and change ckfinder paths) :

<?PHP

if($member_db[1] > 3){ msg("error", "Access Denied", "You don't have permission to add/edit files"); }




// **************
// Show Images List
// **************

echoheader("images","Manage Files");



// *************
// Upload Image(s)
// *************

            echo"
<br/>
<br/>
<script type=\"text/javascript\">

// This is a sample function which is called when a file is selected in CKFinder.
function ShowFileInfo( fileUrl, data )
{
var msg = 'The selected URL is: ' + fileUrl + 'nn';
// Display additional information available in the "data" object.
// For example, the size of a file (in KB) is available in the data["fileSize"] variable.
if ( fileUrl != data['fileUrl'] )
  msg += 'File url: ' + data['fileUrl'] + 'n';
msg += 'File size: ' + data['fileSize'] + 'KBn';
msg += 'Last modifed: ' + data['fileDate'];

alert( msg );
}

</script>

<p style=\"padding-left: 5px; padding-right: 5px;\">
<table>
<tr>
<td>
";

require_once 'path to ckfinder/ckfinder.php';

// You can use the "CKFinder" class to render CKFinder in a page:
$finder = new CKFinder();
$finder->BasePath = 'path to ckfinder/'; // The path for the installation of CKFinder (default = "/ckfinder/").
$finder->Width = 700;
$finder->SelectFunction = 'ShowFileInfo';
$finder->Create();

// It can also be done in a single line, calling the "static"
// Create( basePath, width, height, selectFunction ) function:
// CKFinder::CreateStatic( '../../', null, null, 'ShowFileInfo' );
            echo"
</td>
</tr>
</table>




";




echofooter();




?>

Enjoy  http://cutephp.com/forum/style_emoticons/default/cool.gif

11 (edited by 2012-02-28 14:19:07)

Re: [FAQ] Using CKeditor instead of RTE

That should do it :
code removed, because not working.
I'm working on it.

Maybe FUN can tell us, how to check cookies/sessions ?

12 (edited by 2012-02-28 19:50:11)

Re: [FAQ] Using CKeditor instead of RTE

Dear hanska,

nice one. Thank you very much!

There is still one problem left (the same I had with my attempts): It's not secure to only set "return true;" because someone could open ckfinder directly without logging on to cutenews, to upload and (more important) to delete files and images:


Is there a way to pass cutenews authentication to ckfinder?

I deleted _samples directory in ckfinder, so users can't access to ckfinder demo's. And you can't acces to it through cutenews too if not logged in.

Re: [FAQ] Using CKeditor instead of RTE

maybe i could, There' isn't really an over login script.
The check just happens in index.php before any of the inc files are included.
Which isn't such a safe way to do in the first place.

Only way would be by using a php $_SESSION
but not all CN installations use sessions and rely on cookies only.
And for cookies, a match against the database is needed.

Sessions would be the only good solution and quick solution i can think of.

14 (edited by 2012-02-29 11:27:05)

Re: [FAQ] Using CKeditor instead of RTE

Made to work with sessions and specific username.

session_start();
function CheckAuthentication()
{
    // WARNING : DO NOT simply return "true". By doing so, you are allowing
    // "anyone" to upload and list the files in your server. You must implement
    // some kind of session validation here. Even something very simple as...

    // return isset($_SESSION['IsAuthorized']) && $_SESSION['IsAuthorized'];

    // ... where $_SESSION['IsAuthorized'] is set to "true" as soon as the
    // user logs in your system. To be able to use session variables don't
    // forget to add session_start() at the top of this file.

if(isset($_SESSION['username']) && $_SESSION['username'] == "your username here"){
 return true;
 }else{
 return false;
 }
}

replace your username here

in index.php (cutenews dir) change :

$config_use_sessions = TRUE;

Re: [FAQ] Using CKeditor instead of RTE

Oh, btw I found old topic:

http://web.archive.org/web/20101028081009/...showtopic=35482

Re: [FAQ] Using CKeditor instead of RTE

 echo "<script type="text/javascript">

needs to be replaced with

 echo "<script type=\"text/javascript\">

Re: [FAQ] Using CKeditor instead of RTE

 echo "<script type="text/javascript">

needs to be replaced with

 echo "<script type=\"text/javascript\">


Yes indeed, seems that this forum removes \

Re: [FAQ] Using CKeditor instead of RTE

Made to work with sessions and specific username.


Well done hanska, it works.  http://cutephp.com/forum/style_emoticons/default/smile.gif
You need to put
session_start();
at the top of config.php as stated in the note
Also you must set
$config_use_sessions = TRUE;
in line 18 of cutenews.index.php

Re: [FAQ] Using CKeditor instead of RTE

Well done hanska, it works.  http://cutephp.com/forum/style_emoticons/default/smile.gif
You need to put
session_start();
at the top of config.php as stated in the note
Also you must set
$config_use_sessions = TRUE;
in line 18 of cutenews.index.php

Oops, sorry.
Forgot to add it here, thanks for pointing it.
I'll edited that post.

Re: [FAQ] Using CKeditor instead of RTE

After installing CKeditor and CKfinder you need to take the usual precautions to protect the new directories by putting a blank index.html file in each to prevent directory listing. If you have added a new upfiles directory for uploading  images this also needs to be protected in the same way or by using an .htaccess file. I have put the upfiles directory into the cutenews data directory which is already protected.

Re: [FAQ] Using CKeditor instead of RTE

That's what I wrote on my post.

At 1st make new directory inside cutnews’s data dir named upfiles

Re: [FAQ] Using CKeditor instead of RTE

I have noticed that some of the toolbar settings have not been included.
There is a list of the ones that you can include here:
http://docs.cksource.com/CKEditor_3.x/Deve...s_Guide/Toolbar
I have added in underline, spellcheck instead of check-as-you-type and font.
http://cutephp.com/forum/style_emoticons/default/biggrin.gif

23 (edited by 2012-03-09 15:34:00)

Re: [FAQ] Using CKeditor instead of RTE

I will also add the abilitiy to use the default images.mdu for uploading and integrating pictures with ckeditor later today. I've figured out how to use it http://cutephp.com/forum/style_emoticons/default/biggrin.gif

Brilliant Filou83. Well done. I prefer the images.mdu .
http://cutephp.com/forum/style_emoticons/default/laugh.gif