Announcement

Do not use the forums to submit bug reports, feature requests or patches, submit a New Ticket instead.

#1 2007-11-15 21:27:53

delia
Xinha Community Member
Registered: 2007-11-15
Posts: 25

Xinha and zencart

I've gotten Xinha integrated into the zencart which has always used htmlarea.  My only problem is enabling plugins.  The original code for htmlarea plugins has never worked and I can't get zencart to recognize my new config settings to enable certain plugins.   I would just as rather bypass a separate file and enable them in XinhaCore.js but I don't see how to add them.  I've enabled Xinha in other situations so I'm not a dummy, just stymied! Imagemanager will load and full screen loads no matter what I do. I was trying to get ExtendedFileManager to load as well. Is there something I'm missing here?

the resulting javascript includes this:
<script type="text/javascript">
if (typeof _editor_url == "string") HTMLArea.replaceAll();
}
// -->
</script>
<script type="text/javascript">
   _editor_url = "/zen/editors/xinha/";
    _editor_lang = "en";
</script>
<script type="text/javascript" src="/zen/editors/xinha/XinhaCore.js"></script>
<script type="text/javascript">
      HTMLArea.loadPlugin("TableOperations");
      HTMLArea.loadPlugin("SpellChecker");
      HTMLArea.loadPlugin("ImageManager");
      HTMLArea.loadPlugin("ExtendedFileManager");
      HTMLArea.loadPlugin("FullScreen");
      HTMLArea.loadPlugin("ListType");
      HTMLArea.loadPlugin("CharacterMap");
</script>

Offline

#2 2007-11-16 13:44:42

ray
Xinha Administrator
From: Germany
Registered: 2005-03-23
Posts: 521
Website

Re: Xinha and zencart

I see that your setup can't work this way, but ad hoc I wouldn't know how to solve the issues, unfortunately.
If you want support, I'd ask ask and advise you to load Xinha the way described here: http://xinha.webfactional.com/wiki/NewbieGuide

Offline

#3 2007-11-16 16:30:44

delia
Xinha Community Member
Registered: 2007-11-15
Posts: 25

Re: Xinha and zencart

I tried that but it doesn't acknowledge that code - just pretends it's not there for the other plugins. Since htmlarea can't load plugins either it must be something with how this is integrated. Thanks for responding.

Offline

#4 2007-11-17 17:05:17

delia
Xinha Community Member
Registered: 2007-11-15
Posts: 25

Re: Xinha and zencart

Okay, a little more info.  The full screen plugin comes with xinha so it loads automatically.  ImageManager does load but it is the only one that does which interestingly enough is the only one that that code will load with the htmlarea in the cart. For sure if I removed that "HTMLArea.loadPlugin("ImageManager");" from my file, the imagemanager will not work.

Bizarrely, I've found that this is true for HTMLarea with that same code.  So obviously, I need a a different way of approaching this.  No one at zencart seems interested in this situation with the plugins not working.

I tried including a config file but it doesn't work.  One thing I 'm sure of is that I don't need to name the textarea. It pops up for any textarea in the admin section.  I've used this config file in another situation with no problems so I assume that's not it.

Anybody got an answer to my puzzles?

Offline

#5 2007-11-18 18:21:27

ray
Xinha Administrator
From: Germany
Registered: 2005-03-23
Posts: 521
Website

Re: Xinha and zencart

Hi, I jaust had the chance to have another look at your problem and found that it's really there's a problem converting all textareas with the described method. I fixed the code accordingly

Now, the way to convert all textareas in a document is to put

  xinha_editors = xinha_editors ? xinha_editors : document.getElementsByTagName('textarea');

in your config as Step 1

For this to work at the moment you have to change the code of XinhaCore.js. Open the the file, locate the function Xinha.makeEditors and replace it by the following code (or simply put it at the end of the file, doesn't actually matter)

Xinha.makeEditors = function(editor_names, default_config, plugin_names)
{
  if ( !Xinha.isSupportedBrowser ) return;
  
  if ( typeof default_config == 'function' )
  {
    default_config = default_config();
  }

  var editors = {};
  var textarea;
  for ( var x = 0; x < editor_names.length; x++ )
  {
    if ( typeof editor_names[x] == 'string' ) // the regular case, an id of a textarea
    {
      textarea = Xinha.getElementById('textarea', editor_names[x] );
      if (!textarea) // the id may be specified for a textarea that is maybe on another page; we simply skip it and go on
      {
        editor_names[x] = null;
        continue;
      }
    }
     // make it possible to pass a reference instead of an id, for example from  document.getElementsByTagName('textarea')
    else if ( typeof editor_names[x] == 'object' && editor_names[x].tagName && editor_names[x].tagName.toLowerCase() == 'textarea' )
    {
      textarea =  editor_names[x];
      if ( !textarea.id ) // we'd like to have the textarea have an id
      {
        textarea.id = 'xinha_id_' + x;
      } 
    }
    var editor = new Xinha(textarea, Xinha.cloneObject(default_config));
    editor.registerPlugins(plugin_names);
    editors[textarea.id] = editor;
  }
  return editors;
};

Offline

#6 2007-11-20 10:20:31

delia
Xinha Community Member
Registered: 2007-11-15
Posts: 25

Re: Xinha and zencart

Nope, that makes no difference - the config file is being ignored completely.

Last edited by delia (2007-11-20 10:23:42)

Offline

#7 2007-11-20 10:36:32

delia
Xinha Community Member
Registered: 2007-11-15
Posts: 25

Re: Xinha and zencart

I found why the textareas are working with xinha - javascript statement =

(typeof _editor_url == "string") HTMLArea.replaceAll();

would that interfere with the config file? I'm thinking it would but I just don't know javascript very well to be able to make an eductated guess.

Offline

#8 2007-11-20 10:39:59

delia
Xinha Community Member
Registered: 2007-11-15
Posts: 25

Re: Xinha and zencart

ah, wait, if the editors are being started without the config file then the makeEditor statement gets ignored, right?

Offline

#9 2007-11-25 12:19:45

delia
Xinha Community Member
Registered: 2007-11-15
Posts: 25

Re: Xinha and zencart

I'm getting there slowly.  Don't know why the config statement wasn't working but now it is and plugins are loading, etc.

Only one problem left for you - now that I've got all textareas with editors, there's one that shouldn't have the editor.  How do I exclude textareas?

Offline

#10 2007-11-26 19:54:54

ray
Xinha Administrator
From: Germany
Registered: 2005-03-23
Posts: 521
Website

Re: Xinha and zencart

Well from here on the thing starts to get a general JavaScript question, as opposed to a Xinha one. But here we go

if (!xinha_editors) // the init function may be executed several times during plugin loading, but we want to define the array only once
{
  xinhas_editors = []; //new Array
  var allTextareas = document.getElementsByTagName('textarea');
  for (var i=0;i<allTextareas.length;i++) // iterate through the array
  {
    if (allTextareas[i].id != 'exclude') // check whatever condition you need to exclude your textarea
    {
      xinhas_editors.push(allTextareas[i]); // add the others to the array
    }
  }
}

Offline

#11 2007-11-26 20:00:09

delia
Xinha Community Member
Registered: 2007-11-15
Posts: 25

Re: Xinha and zencart

thanks - as I am a php person and hate javascript - your help is invaluable.  I'm very close to having everypage integrated into zencart - only one problem page remains due to the code.  I've found that if the form start and end tags are between table elements, Xinha will not work.  That's pretty crappy php coding and I've let them know!

Offline

#12 2007-11-26 20:10:50

ray
Xinha Administrator
From: Germany
Registered: 2005-03-23
Posts: 521
Website

Re: Xinha and zencart

That's a pretty frequent source for syntax errors

Offline

#13 2007-11-26 20:34:08

delia
Xinha Community Member
Registered: 2007-11-15
Posts: 25

Re: Xinha and zencart

Yeah, well, I don't know how to debug javascript but I do know what to look for in code!  It really gripes me when I see a coder dynamically produce lousy html.

Offline

#14 2007-11-28 13:51:23

delia
Xinha Community Member
Registered: 2007-11-15
Posts: 25

Re: Xinha and zencart

I finally had time to insert this .  Uh, I must not be doing it right.  I put the name of the content area to be excluded in the brackets and with apostrophes - 'content' but it seems to have no effect. I left in the other editors initiate statement:

xinha_editors = xinha_editors ? xinha_editors : document.getElementsByTagName('textarea');

I also tried comments  out that line.  No dice.

Offline

Board footer

Powered by FluxBB