When I try to turn this on, I get the following:

Warning: Invalid argument supplied for foreach() in /home/martin/public_html/sites/www.hyperlogos.org/modules/linktocontent/plugins/linktonode/extensions/linktonode_category.inc on line 87

Warning: Cannot modify header information - headers already sent by (output started at /home/martin/public_html/sites/www.hyperlogos.org/modules/linktocontent/plugins/linktonode/extensions/linktonode_category.inc:87) in /home/martin/public_html/includes/common.inc on line 266

It does appear to have turned on, and I can now check the boxes and save. This happens reliably; if I turn it off, that works fine, but when I turn it on, it throws this error and doesn't load anything else. I have to manually reload the page, at which point I can see that the settings have been saved.

I've now been waiting for about five minutes for the plugin to build the list of linkable documents, and it hasn't made any visible progress.

Comments

stborchert’s picture

Assigned: Unassigned » stborchert

Hi.
Sorry, but I can't reproduce this error. :-{
I have created tow screenshots of the settings page ([1] & [2]).
If I understand you right, you can't enable the category extension without this error and don't see the page in second image? Hmm.
Please try to use the current version in cvs (linktonode_category.inc v1.5). I've changed it a little (checking whether the form value is an array).

[1] default enabled
[2] category enabled

hyperlogos’s picture

Hi, I just installed the CVS version and am having the same symptoms precisely.

stborchert’s picture

Do you used the whole package (linktocontent_cvs.tar.gz) or only replaced linktonode_category.inc?
I've changed only the category-extension so you should now see a different error message (if there is one).
In line 87 the values of the checkboxes are read. At first save the array does not exists and $values[...] isn't an array so this error occurs.
But now I changed the call a little, so please try again with current versoin of linktonode_category.inc (v 1.5 2006/08/24 18:26:44).

hyperlogos’s picture

Okay, I no longer get the error. It still searches forever, though, or at least a hell of a lot longer than I'm willing to wait, which was something like half an hour. Sorry, I hadn't replaced the file properly. I have just upgraded the whole thing to cvs to see if that makes any difference. I clicked the button at 9:45 AM PST... Now it's 10:00 AM with no apparent progress... Now it's 10:36 AM, and I'm closing that tab and giving up on it.

stborchert’s picture

The search should be finished within seconds. Any JavaScript errors?

ssteinem’s picture

At my installation I have the same problem with a never ending search. The "invalid argument" error could be fixed with the newest version, thanks.
The search ever ends undependent of the extension setting (default or category). Any help is appreciated.

stborchert’s picture

Could you please give some more information:
- are there any javascript errors?
- which drupal version do you use?
- are the modules located in /modules?
- ...

ssteinem’s picture

Sorry - here the details:
Drupal version 4.7.3, modules are at /sites/default/modules/...,
the java console shows lots of "unknown properties ... filter, declaration ignored" and the following exception:
Fehler: uncaught exception: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMNSHTMLTextAreaElement.selectionStart]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: http:///cgi-bin/drupal1/sites/default/modules/img_assist/img_assist_textarea.js :: insertToEditor :: line 88" data: no]

ssteinem’s picture

uppps - forget the javascript errors in the last posting, that was for another module: here the correct error message in the java console:
error: document.getElementById(obj) has no properties
Quelldatei: http://www.kirchestettlen.ch/cgi-bin/drupal1/sites/default/modules/tinym...
Zeile: 230

stborchert’s picture

Ok, thanks.
On your last but one posting I thought "ugh? What's this? That could not be caused by my module." :-)

It seems, the XMLHttpRequest does not return "ok" (status 200). Does your browser support ajax (and/or XMLHttpRequests)?
If you change line 230 of functions.js from
document.getElementById( obj ).innerHTML = "loadData error:\n" + req.statusText;
to
alert(req.statusText);
which message do you get?

PS: if you prefer talking in german please contact me (I'm from germany, so this should be no problem ;-) )

ssteinem’s picture

a popup returns: not found

PS: I hope that the URL in the error message gave me away, not my english...it's fine here in english

stborchert’s picture

PS: I hope that the URL in the error message gave me away, not my english

;-) The url gave the hint.

a popup returns: not found

Ah, that sounds good. Err, I mean now I know the problem. Have a look at line 176:
var url = tinyMCE.baseURL.substring( 0, tinyMCE.baseURL.indexOf( 'modules/' ) );
I expected the modules at "drupal_inst/modules" but your (and certainly many others, too) are at "sites/default/modules".
So the request is misleadingly sent to "http://your_site/sites/default/ltc/linktonode/" instead of "http://your_site/ltc/linktonode/".

Perhaps you could try the following code until i submit a patch:

176:     var url = tinyMCE.baseURL.substring( 0, tinyMCE.baseURL.indexOf( 'modules/' ) );
177:     if (url.indexOf('sites/') > -1) {
178:       url = url.substring(0, url.indexOf('sites/'));
179:     }
180:     url = url + 'ltc/linktonode';
ssteinem’s picture

Thanks for the code. In the meantime I moved the module... with the same result. Adding the patch code does not change anything, either.

Fehler: document.getElementById(obj) has no properties
Quelldatei: http://myhomepage/cgi-bin/drupal1/modules/tinymce/tinymce/jscripts/tiny_...
Zeile: 235

The code around 176 looks like this (so 235 is the original line 230)
// error correction of: var url = tinyMCE.baseURL.substring( 0, tinyMCE.baseURL.indexOf( 'modules/' ) );
var url = tinyMCE.baseURL.substring( 0, tinyMCE.baseURL.indexOf( 'modules/' ) );
if (url.indexOf('sites/') > -1) {
url = url.substring(0, url.indexOf('sites/'));
}
url = url + 'ltc/linktonode';
// end of correction

// native XMLHttpRequest object
if (window.XMLHttpRequest)

stborchert’s picture

It's weird.
I will build a debug version so you can follow each step the plugin does.

stborchert’s picture

By the way: which result do you get on calling http://myhomepage/cgi-bin/drupal1/ltc/linktonode?
Something like this?

{ "category": [ { "vid": "62", "tid": "62", "title": "vocabulary #11" }, 
  { "vid": "83", "tid": "83", "title": "vocabulary #2" }, 
  { "vid": "51", "tid": "51", "title": "vocabulary #1" } ], 
 "node": {  } 
}

(Its a check, whether linktocontent.module returns correct results to the tinymce-plugin.)

ssteinem’s picture

I cannot activate "clean URL" on my homepage (ISP restriction). Using ?q=... I get the following response:
{ "category": [ { "vid": "9", "tid": "9", "title": "Checklist" }, { "vid": "7", "tid": "7", "title": "Forums" }, { "vid": "6", "tid": "6", "title": "Image Galleries" }, { "vid": "4", "tid": "4", "title": "Teilnehmerkreis" }, { "vid": "5", "tid": "5", "title": "Themenkreis" }, { "vid": "3", "tid": "3", "title": "Veranstaltungstyp" } ], "node": { } }

stborchert’s picture

This looks good and shows linktocontent.module is working as expected.
So we have to focus on the tinymce plugin (linktocontent) and escpecially functions.js.

stborchert’s picture

StatusFileSize
new10.14 KB

Well, same procedure as on this bug:

The attached file displays several alerts on opening the plugin window. They should be like the following:

- "loadCategories called"
- "tinyMCE.baseURL: http://.../modules/tinymce/tinymce/jscripts/tiny_mce
   requestURL: http://.../ltc/linktocontent"
- "XMLHttpRequest: [Object XMLHttpRequest]"
- "send request: http://.../ltc/linktocontent/"
- "request state: 1"
(- possibly "request state: 2" and "request state: 3")
- "request state: 4"
- "request status: 200" (guess, you'll not get this, but "not found")
- {"category": [{...}], "nodes": [{...}]}

If its all ok a drop down is inserted in the plugin window which contains your top level categories (vocabularies).
If not: please write down which alert aren't shown.

ssteinem’s picture

OK - "loadCategories called"
OK - "tinyMCE.baseURL: http://.../modules/tinymce/tinymce/jscripts/tiny_mce
requestURL: http://.../ltc/linktocontent"
OK - "XMLHttpRequest: [Object XMLHttpRequest]"
OK - "send request: http://.../ltc/linktocontent/"
OK - "request state: 1"
OK - "request state: 1" <== twice
OK - "request state: 2"
OK - "request state: 3"
OK - "request state: 4"
404 - "not found"

ssteinem’s picture

upps ... didn't like the "less than" sign. Here all the lines:

OK - "loadCategories called"
OK - "tinyMCE.baseURL: http://.../modules/tinymce/tinymce/jscripts/tiny_mce
requestURL: http://.../ltc/linktocontent"
OK - "XMLHttpRequest: [Object XMLHttpRequest]"
OK - "send request: http://.../ltc/linktocontent/"
OK - "request state: 1"
OK - "request state: 1" ! twice !
OK - "request state: 2"
OK - "request state: 3"
OK - "request state: 4"
404 - "not found"

stborchert’s picture

StatusFileSize
new9.64 KB

OK - "request state: 1"
OK - "request state: 1" ! twice !

Its ok (status 1 means it is loading).

OK - "request state: 4"
404 - "not found"

Request is completed but returns "not found"!?

Ahh, think I got it! In #16 you said

I cannot activate "clean URL" on my homepage

. But the request calls ".../ltc/linktonode", not ".../?q=ltc/linktonode"
Please try the attached file (there should be only an alert in case of an error).

ssteinem’s picture

There is one message: send request: /cgi-bin/drupal1/?=ltc/linktonode/
I believe the q is missing after ?
Otherwise the search now stops and displays... no documents

stborchert’s picture

I believe the q is missing after ?

Argh, you're right.

Otherwise the search now stops and displays... no documents

With or without "q"?

We're one the way to get it :-)

ssteinem’s picture

With my limited php knowledge I inserted to "q". Now I get the nodes as expected.

But so far no link is inserted in the text if I say "insert".

stborchert’s picture

Well, we are close to the solution.
What message do you get if you modify functions.js like this (around line 32)

    var sel_option = form.nodelist.options[form.nodelist.selectedIndex];
    alert(sel_option);
    if ( sel_option == null )
      return;
ssteinem’s picture

with Firefox (insert of node/79):
[object HTMLOptionElement] ; the link is inserted and looks like this
<a href="/cgi-bin/drupal1/">text </a>
with IE 7 Beta 2:
[object] 
and no link is inserted (the text is formatted with underline (when hovering over it as defined in the style sheet) and a changed color; changing to HTML shows NO code, though).
stborchert’s picture

StatusFileSize
new7.44 KB

Argh, really annoying, isn't it!?
Please try (lines 38ff.)

var nid = sel_option.value;
alert("option.value: " + sel_option.value + "\noption.text: " + sel_option.text +
  "\noptions?" + form.nodelist.options +
  "\nselectedIndex" + form.nodelist.options.selectedIndex +
  " - " + form.nodelist.selectedIndex);
  if (inst.selection.getSelectedText().length == 0)
  {
    alert("insert new link");
    insertText = sel_option.text;
    tinyMCEPopup.execCommand("mceInsertContent", false, '<a href="' + nid + '">' + insertText + '</a>');
  } else
  {
    alert("modify text");
    if ( tinyMCE.isSafari )

.
It should look like the attached screenshot.

stborchert’s picture

Ups, tinyMCEPopup should look like this:
tinyMCEPopup.execCommand("mceInsertContent", false, '<a href="' + nid + '">' + insertText + '</a>');

ssteinem’s picture

StatusFileSize
new14.6 KB

Well, attached the popup. I believe that a few lines got dropped:

    if ( sel_option == null )
      return;

    var insertText = '';
    var nid = sel_option.value;

I inserted these lines.

Now, inserting without selecting text works in both IE and Firefox. Inserting a link when text is selected causes firefox to insert the link without the ?q=node/.... IE changes the appearence of the text but no link is inserted.

stborchert’s picture

StatusFileSize
new7.95 KB

Grml, near to solution but not yet completed...
What happens if you try the attached version?
I've removed half of the "insertAction" method and reduced it to nearly

if (inst.selection.getSelectedText().length == 0)
{
  insertText = sel_option.text;
  tinyMCEPopup.execCommand("mceInsertContent", false,
    '<a href="' + nid + '">' + insertText + '</a>');
} else
{
  tinyMCEPopup.execCommand("mceInsertContent", false,
    '<a href="' + nid + '">' + inst.selection.getSelectedHTML() + '</a>');
}

Hopefully it sometimes will work better with jQuery.

ssteinem’s picture

Category: bug » feature

That looks much better (after inserting the ?q= in the URL string again). It now works for both IE and Firebox, inserting and modifying text.
But, no, I won't shut up just yet:
1. There is a maximum of 3 articles shown, even if there would be more than three. Can this easily be changed?
2. Can there be more text then just the title (something like a date would help if there is more than one entry with the same title)?
Thanks, anyway.

stborchert’s picture

That looks much better (after inserting the ?q= in the URL string again).
Argh. Never change an old version. Grml, it's not good to have multiple versions and don't know which is the current one :-{

But, no, I won't shut up just yet
You haven't to. I'm happy that someone can use it and give hints and suggestions to me.

1. There is a maximum of 3 articles shown, even if there would be more than three. Can this easily be changed?
I do not exactly know what you are meaning. Do you mean the node list in the popup only shows 3 items?
If so could you please create a new bug report (because I would mark this one as closed then).

2. Can there be more text then just the title (something like a date would help if there is more than one entry with the same title)?
I created a feature request and will see what I can do for you.

stborchert’s picture

Status: Active » Closed (fixed)