This patch adds support for nodecomment module (it's automatic and will not interfere if nodecomment is not enabled). It also adds javascript (which can be disabled) that will make the quote link simply add the quote directly to the comment if the comment input textarea is on the same page.

The DruBB project requires both quote and nodecomment, and will need this patch in order for quoting to be valuable. I think this patch generally improves the usability of quote.module, so I hope you'll accept it.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Michelle’s picture

Can I bow down and worship you for a while? LOL! I have been wanting this forever!

Michelle

neclimdul’s picture

coolness. think you forgot to include the quote.js file though.

merlinofchaos’s picture

Whoops. Forgot to fakeadd it. Try this one.

neclimdul’s picture

On pages with a lot posts we're creating a lot of duplicate onload code. I wonder if this would be better fit in a settings variable that could be parsed as needed or as a ahah/ajax callback.

I've talked to merlin about using settings and he feels its "six of one, half a dozen of the other" so I'm going to play with putting it in a settings array since I think it will lower the amount of js added to a page.

neclimdul’s picture

Here's a version that uses the Drupal.settings object.

It also internalizes some of the code using some javascript namespace voodoo.

On a page with 3 replies(4 posts) that where fairly short, the page was just under 1k smaller(911 bytes).

Eidolon Night’s picture

Downloaded the dev, applied the patch just fine (quote.js is there), but the javascript stuff isn't working.

neclimdul’s picture

JS Works great for me. Any more information you can give? information from your js error log, browser you used, etc.

Michelle’s picture

Status: Needs review » Reviewed & tested by the community

#5 works just fine for me.

Michelle

Michelle’s picture

Status: Reviewed & tested by the community » Needs work

I just found a problem with this. It doesn't work with WYSIWYG. I realize that's not a problem for DruBB, which is what this is coming from, but it's a problem in that normal functionality is broken when using a WYSIWYG. Not only does the javascript not work, but then you've lost the old way of it going to a new page with the reply. So the quote button is there but does nothing.

Ideally, this would be made to work with WYSIWYG but I don't have the skills to pull that off. :( If that's not possible, could it be made to detect WYSIWYG and not attempt to use the javascript in that case? Failing all those, I guess it could be set back to RTBC with a note that the javascript option needs to be turned off if you use WYSIWYG but I'm crossing my fingers someone with javascript skills will make it work. :)

Michelle

crea’s picture

Subscribing

TwoD’s picture

Status: Needs review » Needs work
FileSize
7.78 KB

I added support for the Wysiwyg module to the patch in #5.
The only changes are the addition of the below code to the insertAtCursor function.

+    if (Drupal.wysiwyg && Drupal.wysiwyg.instances[object.id] && Drupal.wysiwyg.instances[object.id].insert && Drupal.wysiwyg.instances[object.id].field == object.id) {
+      Drupal.wysiwyg.instances[object.id].insert(text);
+    }
-     if (object.selectionStart || object.selectionStart == '0') {
+    else if (object.selectionStart || object.selectionStart == '0') {

The quote tag is kept intact unless the editor has BBCode output enabled, in which case the original author's name is removed. A possible way to get around that, and also add a nice WYSIWYG touch would be to implement editor plugins which replace the quote tag with a 'rendered' placeholder div, and then back again when the editor is detached. Also note that editors like to wrap text in paragraphs, but that does not seem to be a problem in this case.

The insert method used here is part of the implementation layer of the most common editors like TinyMCE, FCKeditor and CKEditor. It's about to be added for more editors as well and I'm going to push at making it a required method for subsequent releases.

(While writing this I noticed a quirk in the Wysiwyg's 'none' editor (used when another editor is disabled), worked around that using Drupal.wysiwyg.instances[object.id].field == object.id.)

TwoD’s picture

Status: Needs work » Needs review

Didn't see the status.

tom_o_t’s picture

Status: Needs work » Needs review
FileSize
7.78 KB

Lines 111 and 143 of this patch (code from merlinofchaos' original patch) were causing problems for me.

if ($post != $parent_node) {

and

'title' => $parent_node == $post ? t('Quote') : t('quote'),

changed to strict comparison

if ($post !== $parent_node) {

and

'title' => $parent_node === $post ? t('Quote') : t('quote'),

Comparing the two node objects was throwing php error "PHP Fatal error: Nesting level too deep - recursive dependency"

This is a php 5.2 issue.

Einkahumor’s picture

This patch (#13) seems to be working quite well for me. I have a suggestion though I have no idea on how to implement it:

Make it possible to quote only selected text from the post. That way a user can select (highlight with the mouse) some bit of text from a long post and then click Quote and automatically only use the selected text will be quoted.

I'm no code warrior but I know this can be done, a friend of mine once did this with javascript on a custom built forum. I could ask him to dig up how it was done if anyone's interested in trying to implement it.

merlinofchaos’s picture

Hm. I thought the patch I did actually DID select only highlighted text if it was highlighted.

Einkahumor’s picture

That did not work in my tests. Tell me if you need more info on my setup.

Edit: I did a little more testing to be sure. This selected test feature does not work on a raw Drupal setup with only Demo, NodeComment, Poormanscron, Quote (patched) and Views enabled. Tested on Safari 4.0.4 and FireFox 3.6 on Mac OS X 10.5.8.

Are you sure this feature has been implemented?

Michelle’s picture

I just tried it and confirmed that quoting selected text doesn't work for me, either. I didn't even realize it was supposed to so never tried it before. That would be cool to have; I often end up deleting large swaths of what I'm quoting.

Michelle

neclimdul’s picture

The original patch did not insert selected text, it inserts text in the cursor location in the text box. This wasn't ever a feature supported by this patch. Do we need to support it to get the patch in or can it be an additional feature request?

Einkahumor’s picture

I also just noticed (because I just enabled it) that this patch doesn't entirely work with wysiwyg. It does insert the quote text into the comment textarea but it doesn't scroll down to the box, which is very confusing because the user doesn't see anything happen. This might be because of different ID's with wysiwyg+tinymce than without.

Does anyone else have this problem?

TwoD’s picture

I noticed that too now that you pointed it out. When I tested with CKEditor it scrolled down to the beginning of the form, just like it does without an editor, while with most other editors this doesn't seem to happen. I don't think we can control this behavior in Wysiwyg at the moment. Manually triggering a piece of 'scroll to element X'-code after the Drupal.wysiwyg.instances[element X].insert() call would probably take care of it though.

tom_o_t’s picture

G-son/Zen - it would be great to get some feedback on this patch, and what's required to get it committed. It's the last outstanding patch required for the DruBB project (http://drupal.org/project/drubb) so I'd love to do whatever's necessary.

Cheers!

Thomas

tom_o_t’s picture

Any feedback? Any chance of this getting committed?

locomo’s picture

subscribe

Michelle’s picture

Ok, now that Quote has a new version, I had to re-add this patch. I could have sworn that quoting directly to the textbox on the same page was working but now it's not. So here's where we're at:

* This patch is needed to work with Nodecomment. Even if it's not 100% ready, I'd like to see it committed for that reason and we can work on improving it in separate issues.

* Could someone else confirm whether the quote to same page is working for you? For me, quote is taking it to another page. And, yes, I checked that I have the javascript setting checked.

* I'm no longer using WYSIWYG so can't test that. Is the problem I mentioned in #9 resolved?

* Quoting just the selected text would be awesome but seems like it could be in another issue.

Any other thoughts?

Michelle

0liverg’s picture

Patch http://drupal.org/node/496910#comment-1731150 works fine, but unfortunately not for the preview-function.

The behavior is, that clicking preview-button reproduces the original quote and insert it again to the text, each time the preview-button is clicked.

I applied patch http://drupal.org/node/585428 ... but with noch luck :-(
Same behavior occurs ...

Any hints on this ??

THX to merlinofchaos and all others to make "quote" available in node_comments.
It's working in general ... but I need some support in detail, if possible.

Greetings
Oliver

Working with:
Drupal 6.19
Quote 1.1 (patched)
Node Comments 6.x-2.0-beta6
Advanced Forum 6.x-2.0-alpha3
BUEditor 6.x-2.1

zero1eye’s picture

#13 worked well for me with php 5.2

THANK YOU!

Zen’s picture

Status: Needs review » Needs work

Greetings and apologies for the delay in my reply,

I've looked at the patch and while the JavaScript quoting feature is certainly nice to have, accomplishing this by embedding the comment bodies of every comment on the page in the JS is not an efficient solution to say the least.

As for nodecomment, I'd much rather see all the code wrapped in a sub-module or otherwise and keep the changes in Quote as minimal as possible.

-K

Michelle’s picture

Ah, too bad. Since merlinofchaos has moved on, he's not going to rewrite it. Hopefully someone else who knows javascript can pick up this very important patch and run with it.

Michelle

merlinofchaos’s picture

I've looked at the patch and while the JavaScript quoting feature is certainly nice to have, accomplishing this by embedding the comment bodies of every comment on the page in the JS is not an efficient solution to say the least.

But it is necessary, because you need the unfiltered version of the body to quote or you will quote incorrectly. :/

Zen’s picture

Any reason why an AHAH implementation has been discounted?
Also: #264075: Ajax: instant quotes, multiple quotes on a single comment

merlinofchaos’s picture

ahah.js won't really work well in this context. In D7 the framework could do it.

JonoB’s picture

Would it be possible to get this patch in, so that it works with nodecomments?

dunx’s picture

+1

I see Michelle's CouleeRegionOnline doesn't have any quote functionality, so assume this is current a no go and she's just using the BUeditor quote process instead.

Michelle’s picture

Actually, I just forgot to re-apply the patch the last time I updated Quote and haven't gotten to it, yet. The patch works for making it work with Nodecomment. There's just other stuff in the patch that isn't working.

Michelle

Wallack’s picture

EDIT:

Forgot my previous post.

One problem I have. Ajax quote doesn't work if I use panels and nodecomment view to show the comments instead of normal render.

dunx’s picture

Yup, applied the patch at #13 to current version of 6-2a3 ADF and 6-1.2 quote and all works fine once configured.

Remember to turn on quote for your forum and "reply" nodes via the node settings screen and tweak filters so quote is enabled for the relevant filters and arrange the filters (tab on the filter config screen) so quote comes below HTML filter, but above line-break and bbcode filters.

Wallack’s picture

Well I have now this problem:

I want to completely customize the way I show the page.

I have a panel and I would like to use a customized view but I have a problem. If I use a customized view to show the comments, for example, there's no way to show an ajax working link.

I mean, if I write directly a link with the same syntax as the original links, it won't load the comment content into the reply form with the [quote]...[/quote] that's because if you don't use a view with the view-style set as node it won't build the js statements to load the content into the reply box.

I mean this statements:

"quote-link-node-95": { "author": "MGPBuzo", "body": "It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum [b]is that it has a more-or-less normal distribution of le[/b]tters, as opposed to using \'Content here, content here\', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for \'l[b]orem ipsum\' will u[/b]ncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).", "textarea": "#edit-body" },

So what I really want si to be able to have the javascript quoting when using a custom view to show the comments. (creating a node-contentype.tpl isn't an option).

Any idea on how to do this ?

Wallack’s picture

Okay, here is my problem solved. Maybe someone can add it to a module? I don't know how, but when this system I don't really need quote module. Anyways I've integrated it with it, here is my solution:

I use the quote module but I want to put everything by my own in my views. O I have a view to show the original node and a view to show all the comments (with the structure I want).

I add the next link with html format and the class 'quotajax':

http://localhost/node/add/comment/26/103?quote=1#comment-form

Is the same link as the quote system uses. The first number is the main node ID and the second one is the comment node ID (as I use nodecommentes, It WON'T work without nodecomments).

I added the link in a view for each comment shown so I can place it exactly where I want to with full customization via view. What wouldbe nice to be done here, is to add a field to the node type views to be able to add directly a field with the quote link but I don't know how to add fields to the views.

The next part is to add a .js to the theme, going into themename.info:

; $Id: multiflex3.info,v 1.1 2008/06/05 03:04:45 hswong3i Exp $
name = Multiflex-3
description = Tableless, multi-column, fluid width theme.
version = VERSION
core = 6.x
engine = phptemplate
stylesheets[all][] = style.css
stylesheets[all][] = custom.css
<b>scripts[] = quotajax.js</b>

The next part is to develop the quotajax.js file, very simple:

function insertAtCursor(object, text) {
//This is the function from the quote.js patch in #13 I believe
}
//My function
if(Drupal.jsEnabled) 
{
	$(document).ready(function()
	{
		$(".quotajax").click(function(e){
			url = this.href;
			node = url.replace(/.*\/(\d+)\?quote=1.*/g, "$1");
			$.get('/ajax/quotajax.php?node=' + node, function(data) {
				
			// Don't use this behavior if there isn't an edit-body id.

			insertAtCursor($("#edit-body").get(0), data);
			});
			e.preventDefault();
		});
	});
}

The function will run after all quotajax class elements and will add to them the onclick behaviour needed to do an ajax call to a php file.

Here is the simple php file:

$dbhost = "***";
$dbuser = "***";
$dbpass = "***";
$dbname = "***";

$dbconn = mysql_connect($dbhost, $dbuser, $dbpass);
$dblink = mysql_select_db($dbname, $dbconn);
$sql="SELECT node.nid AS nid,
   node_revisions.body AS node_revisions_body,
   node_revisions.format AS node_revisions_format,
   users.name AS users_name,
   users.uid AS users_uid
 FROM node node 
 LEFT JOIN node_revisions node_revisions ON node.vid = node_revisions.vid
 INNER JOIN users users ON node.uid = users.uid
 WHERE node.nid = $_GET[node]";
$sql = mysql_query($sql);
$res = mysql_fetch_array($sql);
echo "[quote=$res[3]]$res[1][/quote]";

This is very simple as is the first try to see if it works. It will return the [quote=authorname]commentbody[/quite] format to the .js file wich is going to add it to the comment textarea.

Now with this JS and PHP I'm able to completely customize where I want to show the quote link.

What I would like to do is to add it to a module. Because I would like to have it fully integrated so ... do anyone know how to integrate it into a module and also make that this new module needs nodecomment and views to work? I'd also like to add a field to the views under the node section something like quote link as now there are edit and delete links.

Thanks and regards.

EDIT: as I said at the start of the post, I've integrated it with the quote module just keeping the quotes links as the quote module has it so if JS don't work you will be redirected to the reply page with the quote already in the textarea.

mr.j’s picture

Wallack, I have been using a similar solution for a couple of years now but for whatever reason it has never been added to the module (Zen linked to it in #30) ...
#264075: Ajax: instant quotes, multiple quotes on a single comment

drupalfan2’s picture

I do not need javascript working here.

But what we all need is a working version of the quote module using advanced forum, node comments and wysiwyg and the preview function.

How can I apply a patch to get this working?

drupalfan2’s picture

Category: feature » bug
Priority: Normal » Major

The preview doubles all quotes: problem #25 still exists. How can this be solved?

At the moment there is no working solution for quote with advanced forum + node_comments + preview button used!

(I applyed patch #11).

Michelle’s picture

Category: bug » feature

This patch is trying to do several things. Of these, the one thing that does work is making Quote work with Node Comments. Could someone who knows javascript please pull out that part of the patch and make an issue with it so we can get that committed? The rest of it is nice to have but making it work with Node Comments is critical to people who use Node Comments.

Thanks,

Michelle

Zen’s picture

Version: 6.x-1.x-dev » 6.x-2.x-dev

The JS quote feature is now being handled at #1082332: Multiquote feature and JS support

crea’s picture

I'm interested in making it work with Node Comments. I have a site with quote module which I plan to migrate to Node Comments. Do we have a summary of what is left to be done ?

Michelle’s picture

The original patch made it work with Node Comments. Unless either module has changed significantly since then, it should still work. I stopped using Quote on my site because I kept forgetting to re-apply the patch and eventually just said heck with it until it got committed. At this rate, I suspect I'll have stopped using Node Comments before the modules work together without patching.

Michelle

crea’s picture

@Michelle Did you know you can keep your own git repo with core and contrib, so when you update core or any module, all patches apply automatically ? I use that workflow for a long time, it's great.

@Zen The only issue I see reported here is it doesn't work with preview button. Is there anything else that is needed to commit this ? Please note I'm also Node Comments maintainer, and I'm very interested in making this work

Michelle’s picture

I suppose I could but that's a bit overkill to keep one module patched. :)

Is Node Comments getting some love again? I thought it had been abandoned...

Michelle

crea’s picture

It was never abandoned. It's minimally maintained, though. But that's off-topic here anyway.

Michelle’s picture

Yeah, definitely OT, sorry. I was just surprised to see it getting any attention. After Sony pulled out I thought it was done for.

So..... back to the patch. :)

Michelle

Zen’s picture

Title: Support for nodecomment module, plus javascript quoting and multi-quoting » Support for nodecomment module

@crea: Please reroll against Quote 6-2 and nodecomment 6-3 sans all the JS stuff. If there's a D7 branch somewhere, a patch against the quote's D7 branch and then a backport is preferable.

Thank you.
-K

ivnish’s picture

Issue summary: View changes
Status: Needs work » Closed (outdated)
ivnish’s picture

Sorry. D6 branch is unsupported