JomSocial – HWDVideoShare activity feed filter

Symptom:

We have a Joomla/JomSocial installation with HWDVideoShare component and the Activity Filter plugin. I have hacked the ‘video’ activity filter to display the HWDVideoShare activities in the feed instead of the default JomSocial video activities.

Clicking on the filter causes an AJAX request which returns 500 (Internal Server Error).
With error reporting turned on it returns 400 (OK) but with the following error message:

Fatal error: Call to undefined method JDocumentRAW::addCustomTag() in /{path}/{to}/{domain}/components/com_hwdvideoshare/hwdvideoshare.class.php on line 1739

Cause:

An AJAX call returns a raw document type, as it’s not properly formatted HTML – often not even HTML at all
HWD weren’t counting on their data being requested in quite this way it would seem, so when a document was created by their component, they called a function that doesn’t exist for RAW documents
Surprising it didn’t cause a problem for the main stream though

Solution:

componentscom_hwdvideosharehwdvideoshare.class.php

1739c1739,1741<                     $doc->addCustomTag(" <script type="text/javascript">// <![CDATA[ function roll_over(img_name, img_src) { document[img_name].src = img_src; } // ]]></script> <script type='text/javascript'>function roll_over(img_name, img_src) { document[img_name].src = img_src; }</script>");--->                     if($doc->getType() != 'raw'){>                         $doc->addCustomTag(" <script type="text/javascript">// <![CDATA[ function roll_over(img_name, img_src) { document[img_name].src = img_src; } // ]]></script> <script type='text/javascript'>function roll_over(img_name, img_src) { document[img_name].src = img_src; }</script>");>                     }

(Unix diff formatting)

The end effect is cutting out a javascript rollover which isn’t really necessary for the stream.

Resource:

Google Groups : Joomla! General Development – “Call to undefined method JDocumentRAW::addCustomTag()” while writing plugin [new window]