3 of 4
3
Xinha WYSIWYG Editor Extension Release v1.0
Posted: 14 February 2007 05:04 PM   [ Ignore ]   [ # 37 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  684
Joined  08-19-2006

hi johnboat,

to include the Xinha rte in the wiki (though I haven’t tried it yet), I would think that you would just need to open a file called default.php, located in the themes/wiki_themes/default directory.

When that is opened, scroll down the page a bit, until you see the following code:

<meta name='robots' content='all' />



<
style type='text/css'>

In between these two bits of code, is where you would put the Xinha install code:

<!-- rte -->

<
script type="text/javascript">
        
_editor_url  = "http://www.yourdomain.com/xinha/"  // (preferably absolute) URL (including trailing slash) where Xinha is installed
        
_editor_lang = "en";      // And the language we need to use in the editor.       
        
        
xinha_editors = null;
        
xinha_init    = null;
        
xinha_config  = null;
        
xinha_plugins = null;

        
// This contains the names of textareas we will make into Xinha editors
        
xinha_init = xinha_init ? xinha_init : function()
        
{
        
/** STEP 1 ***************************************************************
        * First, what are the plugins you will be using in the editors on this
        * page.  List all the plugins you will need, even if not all the editors
        * will use all the plugins.
        *
        * The list of plugins below is a good starting point, but if you prefer
        * a must simpler editor to start with then you can use the following
        *
        * xinha_plugins = xinha_plugins ? xinha_plugins : [ ];
        *
        * which will load no extra plugins at all.
        ************************************************************************/

        
xinha_plugins = xinha_plugins ? xinha_plugins :
        
[
        
'CharacterMap',
        
'ContextMenu',
        
'ExtendedFileManager',
        
'FullScreen',
        
'ImageManager',
        
'ListType',
        
'SpellChecker',
        
'Stylist',
        
'SuperClean',
        
'TableOperations'
        
];
             
// THIS BIT OF JAVASCRIPT LOADS THE PLUGINS, NO TOUCHING  :)
             
if(!Xinha.loadPlugins(xinha_plugins, xinha_init)) return;

        
/** STEP 2 ***************************************************************
        * Now, what are the names of the textareas you will be turning into
        * editors?
        ************************************************************************/

        //xinha_editors = xinha_editors ? xinha_editors :
        //[
        //'field_id_5'
        //];

        
var textareas = document.getElementsByTagName("textarea");
        var
xinha_editors = new Array();
                    
        for (var
i in textareas) {
                        
            
if (textareas[i].id) {xinha_editors.push(textareas[i].id);}
        }

        
/** STEP 3 ***************************************************************
        * We create a default configuration to be used by all the editors.
        * If you wish to configure some of the editors differently this will be
        * done in step 5.
        *
        * If you want to modify the default config you might do something like this.
        *
        *   xinha_config = new Xinha.Config();
        *   xinha_config.width  = '640px';
        *   xinha_config.height = '420px';
        *
        *************************************************************************/

        
xinha_config = xinha_config ? xinha_config() : new Xinha.Config();

        
/** STEP 4 ***************************************************************
        * We first create editors for the textareas.
        *
        * You can do this in two ways, either
        *
        *   xinha_editors   = Xinha.makeEditors(xinha_editors, xinha_config, xinha_plugins);
        *
        * if you want all the editor objects to use the same set of plugins, OR;
        *
        *   xinha_editors = Xinha.makeEditors(xinha_editors, xinha_config);
        *   xinha_editors['myTextArea'].registerPlugins(['Stylist','FullScreen']);
        *   xinha_editors['anotherOne'].registerPlugins(['CSS','SuperClean']);
        *
        * if you want to use a different set of plugins for one or more of the
        * editors.
        ************************************************************************/

        
xinha_editors   = Xinha.makeEditors(xinha_editors, xinha_config, xinha_plugins);

        
/** STEP 5 ***************************************************************
        * If you want to change the configuration variables of any of the
        * editors,  this is the place to do that, for example you might want to
        * change the width and height of one of the editors, like this...
        *
        *   xinha_editors.myTextArea.config.width  = '640px';
        *   xinha_editors.myTextArea.config.height = '480px';
        *
        ************************************************************************/


        /** STEP 6 ***************************************************************
        * Finally we "start" the editors, this turns the textareas into
        * Xinha editors.
        ************************************************************************/

        
Xinha.startEditors(xinha_editors);
        
}

        Xinha
.addDom0Event(window,'load',xinha_init);
        
        
</script>
        
<!-- eof rte -->

And I think that that would do it. Make sure that the _editor_url variable at the top is the correct path to your xinha file. Also, the plugins may vary depending on your requirements.

As I say, I haven’t tested this, but I don’t see why it wouldn’t work. Happy to help with any further questions. Hope this helps

Thanks

Patrick

 Signature 

Patrick TT
Aussie Freelancer

Profile
 
 
Posted: 14 February 2007 05:09 PM   [ Ignore ]   [ # 38 ]  
Grad Student
Avatar
Rank
Total Posts:  99
Joined  09-16-2006

Patrick, thanks for the reply. I will give that a shot and post back here with the results. Thanks again.

Profile
 
 
Posted: 14 February 2007 05:34 PM   [ Ignore ]   [ # 39 ]  
Grad Student
Avatar
Rank
Total Posts:  99
Joined  09-16-2006

Well I didn’t have luck with it but it could just be operator error, it’s been a long day. I will give it another try tomorrow. Thanks again.

Profile
 
 
Posted: 14 February 2007 05:46 PM   [ Ignore ]   [ # 40 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  684
Joined  08-19-2006

No problem, if there are any errors displaying, let me know and I will see if I can help. Also, when you say you didn’t have luck, is it just that it doesnt display anything? Or it displays but doesnt work?

I think that it is relatively fragile, in that it doesn’t take much to make it not work! But hopefully all the issues I went through, will help me to help you :D

Patrick

 Signature 

Patrick TT
Aussie Freelancer

Profile
 
 
Posted: 14 February 2007 05:59 PM   [ Ignore ]   [ # 41 ]  
Grad Student
Avatar
Rank
Total Posts:  99
Joined  09-16-2006

Thanks Patrick, I appreciate it. I should have been more specific but as I said, long day.

I did not receive any errors it just didn’t do anything. I troubleshot a little bit (a very little) and found an extra space at the beginning of the script tag, I tried different paths to the Xinha folder (for the intended function of the plugin I had to just put the root folder the Xinha folder was located but not list it specifically) but still no response.

As I said I may just be doing something stupid. I am shutting down today but will look again tomorrow. If I have to just stick to Textile that is ok, but it just means I have some teaching to do grin .

Thanks again.

~john

Profile
 
 
Posted: 14 February 2007 07:48 PM   [ Ignore ]   [ # 42 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  684
Joined  08-19-2006

Ok, I will have a go and see if I can work anything out.. there was an extra space at the beginning of the scriptt ag so it would show int he forums… soryy, should have said :D

The url to the Xinha folder, the _editor_url, if you have the xinha folder in the root directory as suggested by the plugin, then you should just need to amend the domain name in my example above… anyway, as I said, I will give it a go and see what happens.

Thanks

Patrick

 Signature 

Patrick TT
Aussie Freelancer

Profile
 
 
Posted: 14 February 2007 09:36 PM   [ Ignore ]   [ # 43 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  684
Joined  08-19-2006

Hi Again johnboat,

I have got it working smile Im sure you were probably extremely close, but it was my fault that I missed something out on my code :( sorry…

ok, placing the following code into default.php, where I said to put it, a couple of posts back, installed the xinha editor on a test wiki…

<!-- rte -->
<
script type="text/javascript">
    
_editor_url  = "http://www.domain.com/xinha/"  // (preferably absolute) URL (including trailing slash) where Xinha is installed
    
_editor_lang = "en";      // And the language we need to use in the editor.
</script>
< script type="text/javascript" src="http://www.domain.com/xinha/htmlarea.js"></script>    

< script language="javascript">
xinha_editors = null;
xinha_init    = null;
xinha_config  = null;
xinha_plugins = null;

// This contains the names of textareas we will make into Xinha editors
xinha_init = xinha_init ? xinha_init : function()
{
/** STEP 1 ***************************************************************
* First, what are the plugins you will be using in the editors on this
* page.  List all the plugins you will need, even if not all the editors
* will use all the plugins.
*
* The list of plugins below is a good starting point, but if you prefer
* a must simpler editor to start with then you can use the following
*
* xinha_plugins = xinha_plugins ? xinha_plugins : [ ];
*
* which will load no extra plugins at all.
************************************************************************/

xinha_plugins = xinha_plugins ? xinha_plugins :
[
'CharacterMap',
'ContextMenu',
'ExtendedFileManager',
'FullScreen',
'ImageManager',
'ListType',
'SpellChecker',
'Stylist',
'SuperClean',
'TableOperations'
];
     
// THIS BIT OF JAVASCRIPT LOADS THE PLUGINS, NO TOUCHING  :)
     
if(!Xinha.loadPlugins(xinha_plugins, xinha_init)) return;

/** STEP 2 ***************************************************************
* Now, what are the names of the textareas you will be turning into
* editors?
************************************************************************/

//xinha_editors = xinha_editors ? xinha_editors :
//[
//'field_id_5'
//];

var textareas = document.getElementsByTagName("textarea");
var
xinha_editors = new Array();
        
for (var
i in textareas) {
        
    
if (textareas[i].id) {xinha_editors.push(textareas[i].id);}
}

/** STEP 3 ***************************************************************
* We create a default configuration to be used by all the editors.
* If you wish to configure some of the editors differently this will be
* done in step 5.
*
* If you want to modify the default config you might do something like this.
*
*   xinha_config = new Xinha.Config();
*   xinha_config.width  = '640px';
*   xinha_config.height = '420px';
*
*************************************************************************/

xinha_config = xinha_config ? xinha_config() : new Xinha.Config();

/** STEP 4 ***************************************************************
* We first create editors for the textareas.
*
* You can do this in two ways, either
*
*   xinha_editors   = Xinha.makeEditors(xinha_editors, xinha_config, xinha_plugins);
*
* if you want all the editor objects to use the same set of plugins, OR;
*
*   xinha_editors = Xinha.makeEditors(xinha_editors, xinha_config);
*   xinha_editors['myTextArea'].registerPlugins(['Stylist','FullScreen']);
*   xinha_editors['anotherOne'].registerPlugins(['CSS','SuperClean']);
*
* if you want to use a different set of plugins for one or more of the
* editors.
************************************************************************/

xinha_editors   = Xinha.makeEditors(xinha_editors, xinha_config, xinha_plugins);

/** STEP 5 ***************************************************************
* If you want to change the configuration variables of any of the
* editors,  this is the place to do that, for example you might want to
* change the width and height of one of the editors, like this...
*
*   xinha_editors.myTextArea.config.width  = '640px';
*   xinha_editors.myTextArea.config.height = '480px';
*
************************************************************************/


/** STEP 6 ***************************************************************
* Finally we "start" the editors, this turns the textareas into
* Xinha editors.
************************************************************************/

Xinha.startEditors(xinha_editors);
}

Xinha
.addDom0Event(window,'load',xinha_init);

</script>
<!-- eof rte -->

in the previous code I forgot to include htmlarea.js… which actually, according to this post: http://expressionengine.com/forums/viewthread/34818/P18/#205180 should now be XinhaCore.js.

So depending on when you downloaded it, you might need to swap that around.

again, any questions, let me know.

Thanks

Patrick

 Signature 

Patrick TT
Aussie Freelancer

Profile
 
 
Posted: 14 February 2007 09:53 PM   [ Ignore ]   [ # 44 ]  
Grad Student
Avatar
Rank
Total Posts:  99
Joined  09-16-2006

Patrick you rock! Works like a charm. I don’t know if there is a EE Wiki specific forum or something but you should post this there if so. I know others would love this. Thanks again for all the help.

Profile
 
 
Posted: 14 February 2007 10:48 PM   [ Ignore ]   [ # 45 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  684
Joined  08-19-2006

glad it helped, sorry i missed that bit in the first place :D

This solution is almost identical to putting Xinha on the front end of a website, the only difference being where the code is put. smile But basically, as long as the code above is in the head section, any textareas will take on the rte.

Thanks

Patrick

 Signature 

Patrick TT
Aussie Freelancer

Profile
 
 
Posted: 15 February 2007 02:43 PM   [ Ignore ]   [ # 46 ]  
Grad Student
Avatar
Rank
Total Posts:  99
Joined  09-16-2006

Don’t apologize Patrick, your help was fantastic. Works great in the wiki per your solution, I only wish you could link to all of that javascript instead of having it in the head, but hey that is nitpicking. I just need to learn about Xinha now to configure.

I actually have a new problem relating to the intended use of this Extension. I had it working great on my production Mac (MAMP) but when I put it on the live server I get this error (minus my domain info) when I try to activate the Extension:

Notice: Undefined variable: default_settings in mydomain/system/extensions/ext.xinha.php on line 182

Warning
: Cannot modify header information - headers already sent by (output started at mydomain/system/extensions/ext.xinha.php:182) in mydomain/system/core/core.functions.php on line 293

Anyone have any thoughts? It is a Linux web server running Apache 1.3.37 & MySQL 4.1.21. I am running the latest version of EE, 1.5.2. Thanks in advance for the help.

John

Profile
 
 
Posted: 15 February 2007 04:02 PM   [ Ignore ]   [ # 47 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  684
Joined  08-19-2006

by the way, you can put all that javascript into a file, Xinha recommend calling it my_config.js, then just link to it. I haven’t tried this, but apparently it works smile

I’m afraid I cant help you with the extension issue though.. the undefined variable probably isnt too difficult, but not sure what headers it is sending

 Signature 

Patrick TT
Aussie Freelancer

Profile
 
 
Posted: 15 February 2007 04:39 PM   [ Ignore ]   [ # 48 ]  
Grad Student
Avatar
Rank
Total Posts:  99
Joined  09-16-2006

by the way, you can put all that javascript into a file, Xinha recommend calling it my_config.js, then just link to it.

Thanks again Patrick. Will try the linked Javascript.

I’m afraid I cant help you with the extension issue though.. the undefined variable probably isnt too difficult, but not sure what headers it is sending

That’s ok, maybe someone else will have a brainwave. Thanks for looking at it though.

Profile
 
 
Posted: 18 February 2007 04:58 PM   [ Ignore ]   [ # 49 ]  
Grad Student
Avatar
Rank
Total Posts:  99
Joined  09-16-2006

Thought I would try again to see if anyone had any suggestions. When I try to activate the Extension I get an error screen with this:

Notice: Undefined variable: default_settings in mydomain/system/extensions/ext.xinha.php on line 182

Warning
: Cannot modify header information - headers already sent by (output started at mydomain/system/extensions/ext.xinha.php:182) in mydomain/system/core/core.functions.php on line 293

If I pretend that didn’t happen, hit the back button then go to the Publish or Edit sections of the CP I get these error messages at the top of the page:

Notice: Uninitialized string offset: 0 in /home/user/public_html/system/extensions/ext.xinha.php on line 81

Notice
: Uninitialized string offset: 0 in /home/user/public_html/system/extensions/ext.xinha.php on line 89

Notice
: Uninitialized string offset: 0 in /home/user/public_html/system/extensions/ext.xinha.php on line 94

Notice
: Undefined index: CSS_url in /home/user/public_html/system/extensions/ext.xinha.php on line 140

I have tried clearing caches & I have never had TinyMCE or other editors installed. Could this have something to do with Permissions? Funny thing is I have Xinha working great in the Wiki (thanks to Patrick) but just can’t get the extension to work.

Profile
 
 
Posted: 07 March 2007 12:16 PM   [ Ignore ]   [ # 50 ]  
Grad Student
Avatar
Rank
Total Posts:  59
Joined  11-14-2002

I had the same problem as you Johnboat, including the problem on the edit and publish pages.  So I just re-enabled and the second time there were no error messages.  But then again it didn’t work either (didn’t activate).  I’ve gone through the steps earlier in this thread and see the requisite lines in the source file and have cleared the cache both with the extension disabled and with it enabled with no luck.  Sorry I can’t help you out, but just thought I’d let you know (a few weeks later) that you are not alone!

Profile
 
 
Posted: 07 March 2007 02:37 PM   [ Ignore ]   [ # 51 ]  
Grad Student
Avatar
Rank
Total Posts:  59
Joined  11-14-2002

I got the following PM forward from Impeller who does not have posting rights to this forum at present:

I installed the Xinha extension for the first time today in ExpressionEngine Core 1.5.2, and got exactly the same PHP warning/errors as you. I’ve found that going to the extensions settings page, deselecting all Xinha plugins and hitting submit stops the PHP errors from appearing on the EE publish pages.

I found that this also worked for me, so apparently one of the plug-ins is at issue.  I’ll play around some more to see if I can figure out what one, but this at least got me started.

Profile
 
 
Posted: 07 March 2007 02:42 PM   [ Ignore ]   [ # 52 ]  
Grad Student
Avatar
Rank
Total Posts:  99
Joined  09-16-2006

Thanks Chessie, Impeller also PM’d me but I have not had time to come back to this issue and to be honest I forgot about it (out of sight out of mind). I do want to give it a try so if you have any luck I would love to hear about it. Thanks for the help.
John

Profile
 
 
Posted: 07 March 2007 06:53 PM   [ Ignore ]   [ # 53 ]  
Grad Student
Avatar
Rank
Total Posts:  59
Joined  11-14-2002

Another thing that I am playing around with is getting this to work with multiple weblogs that each have their own custom fields.  I’ve started out with the brute force approach and added a field to the ext.xinha.php file in the appropriate place.  With all 4 fields selected in settings the new field didn’t work, and in fact the default ones no longer worked either.  I disabled the new field and the default weblog publish/edit screens once again used Xinha correctly.  Then I disabled the default fields and enabled the new field.  This made it work for the weblog containing the new field, but of course not in the default.  So it would appear at first blush anyway that if any one of the enabled fields does not exist on the page, Xinha isn’t happy.

I think this must be what jtnt was addressing in a different way (not sure what thread that continued from).  That approach looks pretty good…not sure if it would work with changes that have been made to this extension since that time without some modification…maybe I’ll give it a go.

Profile
 
 
Posted: 09 March 2007 10:46 PM   [ Ignore ]   [ # 54 ]  
Grad Student
Avatar
Rank
Total Posts:  59
Joined  11-14-2002

Well, once I got this working I never found myself wanting whatever must have caused my initial error messages.  I also implemented jtnt’s method for selectively deciding which textarea’s to use this with.  It’s working great on my site, with some “configuration” to ensure staying within my selected site styles.  The only part that is a little convoluted is images.  I still prefer to use EE’s native upload capability, but it doesn’t paste into a WYSIWYG textarea.  I have a way around it but do wish it was a simpler process.  That said, this will go a long way to helping my non-techie content folks feel comfortable.

Profile
 
 
   
3 of 4
3
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 66468 Total Logged-in Users: 33
Total Topics: 84864 Total Anonymous Users: 25
Total Replies: 455356 Total Guests: 183
Total Posts: 540220    
Members ( View Memberlist )