Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest sNews - sNews 1.7 - with its own forums - for discussion and user mods.

Pages: [1] 2 3

Author Topic: [MOD] Toggle button - Simple Editor / FCKeditor (sNews 1.5RC3)  (Read 19595 times)

sevir

  • Newbie
  • *
  • Karma: 0
  • Posts: 21
    • http://www.sevir.org
[MOD] Toggle button - Simple Editor / FCKeditor (sNews 1.5RC3)
« on: October 11, 2006, 01:30:02 AM »

Well, as you can see I posted a similar solution with TinyMCE but I found that Tiny fuck my XHTML valid code and I have rewrite the code with the Simple Editor more times :(.

Then I try FCKeditor, the latest version generate XHTML 1.0 valid :D perfect!!! OK let's go with the toogle button.

This solution is different than keyrocks solution http://www.solucija.com/forum/viewtopic.php?id=1597 , and repair some mismatch in the output of sNews using WYSIWYG editors (the problem with ENTERs).

1. I download FCKeditor http://www.fckeditor.net/
2. I add the toogle button in sNews code:

  Line 1157:
    html_input('button', '', '', 'Include', '', 'button', 'onclick="tags(\'include\')"', '', '', '', '', '', '', '', '');

  I changed for:
    html_input('button', '', '', 'Include', '', 'button', 'onclick="tags(\'include\')"', '', '', '', '', '', '', '', '');
    if (isset($_GET["richarea"])){
      html_input('button', '', '', 'Simple Editor', '', 'button', 'onclick="document.location=document.location.href.substr(0,document.location.href.indexOf(\'&richarea=\'))"', '', '', '', '', '', '', '', '');
   }else{
      html_input('button', '', '', 'Word Editor', '', 'button', 'onclick="document.location=document.location + \'&richarea=\'"', '', '', '', '', '', '', '', '');
   }

3. I decompress fckeditor in the snews root folder
4. I add the call of fkceditor inside snews code:

  Line 1864:
      </script>
   I changed for:
       </script>
   
<?php
   if (isset($_GET["richarea"])){
?>
   <script type="text/javascript" src="fckeditor/fckeditor.js"></script>
   <script type="text/javascript">

      window.onload = function()
      {
         var oFCKeditor = new FCKeditor( 'txt' ) ;
         oFCKeditor.BasePath = 'fckeditor/' ;   // '/fckeditor/' is the default value.
         oFCKeditor.ReplaceTextarea() ;
      }

   </script>
<?php
   }
?>


5. I want repair the problem with ENTER's, sNews change ENTER pulsations "\n" for "
", is nice if you only use the simple editor but FCKeditor format the code adding ENTER pulsations by example if you write <h1>title</h1>(\n)text . The result is that really what you write is NOT what you see :P. I'm trying to repair this.

   Line 1312:
     $text = str_replace("\n", "
", $text);
   I simply comment this line:
     //$text = str_replace("\n", "
", $text);

Now works!!!

6. By the end you can enable the php file manager of FCKeditor, in the file fckeditor/editor/filemanager/browser/default/connectors/php/config.php change the lines:
$Config['Enabled'] = true ;
$Config['UserFilesPath'] = '/path/repository/' ;

Of course, in your /path/repository/ folder you have 777 permission for upload files.

in the file fckeditor/fckconfig.js I change the lines:
var _FileBrowserLanguage   = 'php' ;
var _QuickUploadLanguage   = 'php' ;

Ok finally that's all

You can download the mod version here:
http://www.sevir.org/pub/tools/snews+FCKeditor.zip

And watch a screencast demo here:
http://www.sevir.org/pub/tools/snews_fckeditor.htm
« Last Edit: October 13, 2007, 10:11:26 PM by Keyrocks »
Logged

Lucian

  • Newbie
  • *
  • Karma: 0
  • Posts: 7
    • http://www.editiaspeciala.com
[MOD] Toggle button - Simple Editor / FCKeditor (sNews 1.5RC3)
« Reply #1 on: November 04, 2006, 01:39:19 AM »

Sevir, it just does not work in 1.5RC3 - i have done all the needed modifications and i still can not make it work :( I was so looking forward to use fckeditor on snews :(
Logged

sevir

  • Newbie
  • *
  • Karma: 0
  • Posts: 21
    • http://www.sevir.org
[MOD] Toggle button - Simple Editor / FCKeditor (sNews 1.5RC3)
« Reply #2 on: November 04, 2006, 02:01:05 PM »

Quote from: lbordea
Sevir, it just does not work in 1.5RC3 - i have done all the needed modifications and i still can not make it work :( I was so looking forward to use fckeditor on snews :(
I see, I have downloaded the new code. There are some changes in the core functions and you have to change a bit my code.

Well this is the change for sNews1.5RC3:

Now Javascript is in
1. Look find for "// JAVASCRIPT FUNCTIONS
function js() { ?>" at the end of the snews.php code

I paste the script fckeditor call:
function js(){?>

    if (isset($_GET["richarea"])){
?>
   
   
    }
?>

2. the core function html_input has changed the params order. I look for the line:
html_input('button', 'include', '', 'Include', '', 'button', 'onclick="tag(\'include\')"', '', '', '', '', '', '', '', '');

And I paste the code modify:
html_input('button', 'include', '', 'Include', '', 'button', 'onclick="tag(\'include\')"', '', '', '', '', '', '', '', '');
     if (isset($_GET["richarea"])){
        html_input('button', 'SimpleEditor', '', 'Simple Editor', '', 'button', 'onclick="document.location=document.location.href.substr(0,document.location.href.indexOf(\'&richarea=\'))"', '', '', '', '', '', '', '', '');
    }else{
        html_input('button', 'RichEditor', '', 'Rich Editor', '', 'button', 'onclick="document.location=document.location + \'&richarea=\'"', '', '', '', '', '', '', '', '');
    }

Now you have working FCKEditor in sNews 1.5RC3
Logged

Lucian

  • Newbie
  • *
  • Karma: 0
  • Posts: 7
    • http://www.editiaspeciala.com
[MOD] Toggle button - Simple Editor / FCKeditor (sNews 1.5RC3)
« Reply #3 on: November 04, 2006, 09:23:14 PM »

I'm sorry - I must be doing something wrong - because I can not make it work - I get this error :

syntax error
fckeditor.js (line 1)


It seems that it does not find the fckeditor.js? there is the file located into snews directory and named fckeditor (the default value).

What am I doing wrong?

Updated :
I guess that the code added by my free hosting (banners :( ) are scrambling my code :( - too bad - I just wanted a free hosting to play with snews :( - you are the first ones (snews developers and users) that made me look into php applications - I'm a asp / asp.net programmer :).

Off-topic - do you know another free hosting for me to try for snews playing? :)
Logged

sevir

  • Newbie
  • *
  • Karma: 0
  • Posts: 21
    • http://www.sevir.org
[MOD] Toggle button - Simple Editor / FCKeditor (sNews 1.5RC3)
« Reply #4 on: November 05, 2006, 12:52:42 AM »

Quote from: lbordea
I'm sorry - I must be doing something wrong - because I can not make it work - I get this error :

syntax error
fckeditor.js (line 1)


It seems that it does not find the fckeditor.js? there is the file located into snews directory and named fckeditor (the default value).

What am I doing wrong?
I have my fckeditor.js in my snews directory /fckeditor/fckeditor.js, check if you path is correct.

One question, the syntax error is from php? or javascript error?

About free hosting with banners, you can hide the banners using CSS and JavaScript.

if the banner is
Logged

cleocadio

  • Newbie
  • *
  • Karma: 0
  • Posts: 4
[MOD] Toggle button - Simple Editor / FCKeditor (sNews 1.5RC3)
« Reply #5 on: November 07, 2006, 02:59:25 PM »

About the Javascript part, i should substitute for what is there?

From:

function js(){?>

to

    </script>
<?php
    }
?>

--------

I get this error:

Code: [Select]
Parse error: syntax error, unexpected $end in /home/wdesigni/public_html/snews/snews.php on line 1684I just copied it all:

// JAVASCRIPT FUNCTIONS
function js(){?>

<?php
    if (isset($_GET["richarea"])){
?>
    <script type="text/javascript" src="fckeditor/fckeditor.js"></script>
    <script type="text/javascript">

        window.onload = function()
        {
            var oFCKeditor = new FCKeditor( 'txt' ) ;
            oFCKeditor.BasePath = 'fckeditor/' ;    
         // '/fckeditor/' is the default value.
            oFCKeditor.ReplaceTextarea() ;
        }

    </script>
<?php
    }
?>
« Last Edit: October 13, 2007, 10:12:08 PM by Keyrocks »
Logged

cleocadio

  • Newbie
  • *
  • Karma: 0
  • Posts: 4
[MOD] Toggle button - Simple Editor / FCKeditor (sNews 1.5RC3)
« Reply #6 on: November 07, 2006, 06:13:42 PM »

ok, i downloaded your php file modified with the code, but the toggle butos just does not appear.

www.wdesign-it.com/snews

I even downloaded an older pack of snews, the first 1.5

Help
Logged

Lucian

  • Newbie
  • *
  • Karma: 0
  • Posts: 7
    • http://www.editiaspeciala.com
[MOD] Toggle button - Simple Editor / FCKeditor (sNews 1.5RC3)
« Reply #7 on: November 07, 2006, 09:10:40 PM »

I have managed to hide the div with banner and still the FCKEditor does not work - if I write the full address for the js file - I find it ok - so it's ok.
When I see the source code of the edit page the script for loading the FCKEditor appears:


Finally I found out that the onload was replaced by another function created by added hosting banners -> so I changed the function to use it in body onLoad - but no result.

I tried to use the function to call it at the end of the index.php but still no result :(. I have no idea what to do next :(

Any implementantion for FCKEditor php in 1.5RC3 instead of js version?
Logged

Lucian

  • Newbie
  • *
  • Karma: 0
  • Posts: 7
    • http://www.editiaspeciala.com
[MOD] Toggle button - Simple Editor / FCKeditor (sNews 1.5RC3)
« Reply #8 on: November 07, 2006, 10:05:34 PM »

I am trying now to use the php implementation for fckEditor so I changed in function form_articles($contents)

this line:
   html_input('textarea', 'text', 'txt', $frm_text, l('text'), '', '', '', '', '', '2', '100', '', '', '');

into:
    include("FCKeditor/fckeditor.php");
    $oFCKeditor = new FCKeditor('txt') ;
    $oFCKeditor->BasePath = 'FCKeditor/';
    $oFCKeditor->Value = 'Hello'; // just for TEST
    $oFCKeditor->Create() ;

but still no positive result :( :(

i get this error : Warning: form_articles(FCKeditor/fckeditor.php): failed to open stream: No such file or directory in
and then after 3 warnings like this:
Fatal error: Cannot instantiate non-existent class: fckeditor in ....

Any ideas?
Logged

sevir

  • Newbie
  • *
  • Karma: 0
  • Posts: 21
    • http://www.sevir.org
[MOD] Toggle button - Simple Editor / FCKeditor (sNews 1.5RC3)
« Reply #9 on: November 08, 2006, 11:39:54 AM »

Finally I have decided upload the original sNews 1.5RC3 with the changes and FCKEditor latest version included.

the Javascript line window.onload = function... replace allways the event handler. So you need not replace rather append a new event handler. I have used jQuery library because the syntax is incredible simple.

windows.onload = function....

It is converted in
$(document).ready(function(){

});

So the new handler is appended and works with the banner code (window.onload).

The zip include sNews1.5RC3 with the changes posted before, FCKEditor and jQuery library.
http://www.sevir.org/pub/tools/sNews15RC3+FCKEditor.zip

Quote from: lbordea
I have managed to hide the div with banner and still the FCKEditor does not work - if I write the full address for the js file - I find it ok - so it's ok.
When I see the source code of the edit page the script for loading the FCKEditor appears:


Finally I found out that the onload was replaced by another function created by added hosting banners -> so I changed the function to use it in body onLoad - but no result.

I tried to use the function to call it at the end of the index.php but still no result :(. I have no idea what to do next :(

Any implementantion for FCKEditor php in 1.5RC3 instead of js version?
Logged

cleocadio

  • Newbie
  • *
  • Karma: 0
  • Posts: 4
[MOD] Toggle button - Simple Editor / FCKeditor (sNews 1.5RC3)
« Reply #10 on: November 08, 2006, 12:55:24 PM »

Well, i have two snews instaled:

http://www.wdesign-it.com/snews   and http://www.wdesign-it.com/noticias

In the 1º i have the 1.5 version that sevir gave. It does not apear the rich editor button.

On the 2º, the new pack sevir put here, it has the button, but i click and it stays the same. Nothing appears.

use test if you want to try it.

Thank you.
Logged

sevir

  • Newbie
  • *
  • Karma: 0
  • Posts: 21
    • http://www.sevir.org
[MOD] Toggle button - Simple Editor / FCKeditor (sNews 1.5RC3)
« Reply #11 on: November 08, 2006, 02:54:37 PM »

Quote from: cleocadio
Well, i have two snews instaled:

http://www.wdesign-it.com/snews   and http://www.wdesign-it.com/noticias

In the 1º i have the 1.5 version that sevir gave. It does not apear the rich editor button.

On the 2º, the new pack sevir put here, it has the button, but i click and it stays the same. Nothing appears.

use test if you want to try it.

Thank you.
Ok, in the 1º, I think that You have the original 1.5 version without changes, I can't see the php file but the output don't shows any of