Firefox PHP

Module: Post Previews

Posted by Joe Curia 
Module: Post Previews
October 17, 2008 04:26PM
This module adds AJAX post previews to all links which point to posts on this forum.

Special thanks go to Maurice Makaay for his wonderful AJAX api.

Installation and Usage:
This module requires Phorum 5.2.8 or greater to use the AJAX api.

By default the post previews are shown in a 500px by 50px div with the background color set to the default alternate background color (seen in every other message on the list page). Also by default, the post is shown formatted as it would be on the read page. These defaults can be changed from the settings page.

The admin can also enable the option for users to disable the previews, which they would then do from the Control Center->Forum Settings page. When this setting is enabled, the admin can also enable a help message which will appear above the message preview to explain this feature. This feature will not work in the Opera browser and thus will not be shown to visitors using Opera.

One final option for the admin is to show a vertical scrollbar in the preview area. This option fixes a FireFox display bug when a video is embedded in a message. I would recommend only enabling this option if your forum allows embedded videos in messages.

The admin can also allow logged-in users to mark the previewed message read with a CTRL+Right-Click or the previewed messages entire thread with a CTRL+Shift+Right-Click. When this setting is enabled, the admin can also enable a help message which will appear above the message preview to explain this feature. This feature will not work in the Opera browser and thus will not be shown to visitors using Opera.

The previews and the code to show the previews are all done through javascript, so there is no need to edit templates.

Todo:
- Use AJAX to update the new message flags.

- Add other options for previews. One possibility is a non-popup version which would display beneath each subject in the list page.

- Add further features as requested or as they pop into my head

Changelog:
v5.2.1.07 Oliver Riesen-Mallmann <oliver@riesen.org>
    - Made XHTML 1.0 Transitional compliant.
    - Changed htmlspecialchars option from ENT_COMPAT to ENT_QUOTES.
v5.2.1.06 Oliver Riesen (oliver@riesen.org)
    - Fixed PHP Notice, Undefined index: body.
    - German language files added.
v5.2.1.05
    - Enhancement: Added support for templates in the control center.  Added 
      Classic, Emerald, Lightweight, and Simple Rounded template support.
    - Enhancement: Added compatibility for embedded Phorum installations.
v5.2.1.04
    - Enhancement: Added the option to disable showing previews by default 
      (only registered users who actively enable previews will see them).  
      Thanks go to Phorum user Skye for suggesting this feature.
    - Bugfix: Added to option to display a vertical scrollbar in the preview 
      area.  Enabling this option fixes a FireFox display bug when a video is 
      embedded in a message.  Thanks go to Phorum user noe for pointing out the 
      need for this fix.
v5.2.1.03
    - Enhancement: Added the ability for a logged-in user to mark the previewed 
      message read with a CTRL+Right-click or the previewed message's entire 
      thread with a CTRL+Shift+Right-click.  A help message can be enabled to 
      appear above the preview area and explain this feature.
    - Enhancement: Add the option to show an alert pop-up if an AJAX error 
      occurs.  This should only be used for debugging.
    - Enhancement: Message_id gathering now centralized in one function to avoid 
      repeated code.
    - Bugfix: All Javascript functions are now properly named to avoid 
      possible, if unlikely, collisions.
v5.2.1.02
    - Enhancement: Support added for the French language by Phorum user manuvb.
    - Bugfix: Post previews would not show for threads on the list page if 
      cookies were disabled, requiring session ids to be added to the urls.  
      Thanks go to Phorum user higphorum for reporting this bug.
v5.2.1.01
    - Bugfix: Sites with a dash in their address would fail to generate previews. 
      Thanks go to Phorum user John Shallo for catching this bug.
v5.2.1.00
    - Initial release.


Joe Curia (aka Azumandias)
Modules: l0Admin Mass Email00000000l000000Automatic Time Zones000ll.l00000Enhanced Custom Profiles0.00Google Calendar0000l.l000000Post Previews
000000000Admin Security Suite000000000000Check Modules for Upgrades0000External Authentication000000Group Auto-Email00000.00000Private Message Alerts
000000000Attachment Download Counter0000Custom Attachment Icons000ll.ll00Favorite Forums000000.00000Highlighted Search Terms0000Self-Delete Posts Option
000000000Attachment Watermarks0l00000000Custom Language Database00l.l.0Forum Lockdown00000.00000Ignore Forums0000000000000Threaded Tree View
000000000Automatic Message Pruning00.llll.00Easy Color Scheme Manager0l.l00Forum Subscriptions0000lll000Moderated User Group
Templates:lGeneric Integration000000000 0000Simple Rounded000000 00000000Tabbed Emerald




Edited 5 time(s). Last edit at 08/31/2016 03:21PM by Oliver Riesen-Mallmann.


Attachments:
open | download - post_previews-5.2.1.07.zip (16.2 KB)
Re: Module: Post Previews
October 17, 2008 04:35PM
Quote

Special thanks go to Maurice Makaay for his wonderful AJAX api.

And special thanks to Azumandias for recognizing the potential! ;-) For future versions, a message handling API is planned. This API will also be made accessible using standard Ajax call implementations in include/ajax/*. By then, you could strip this module a bit by calling the core Ajax calls.

Good job!


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: Module: Post Previews
October 22, 2008 04:47PM
Hi, I was excited to discover this Mod. I want to implement it on our forum, but my site Owner asked me if this will slow down the site at all? Some members have slow connections. Thanks for the Mod and all your help. (I lurk mostly and the answers here have been so great, I rarely need to ask anything.)
Re: Module: Post Previews
October 22, 2008 05:25PM
This mod uses AJAX to display the post previews. Thus, until a user hovers over the link, no extra data is pulled onto the page. Further, the preview only displays after the full data has been retrieved. Thus, if the user's connection is slow the preview may take longer to load, but they can still simply click on the link and go to the message without waiting for the preview.

Finally, you can allow the users to disable post previews from their Control Center->Forum Settings page if they feel the previews are slowing down their personal experience, while still allowing the rest of your users to see the previews. (This, of course, only works for registered users).


Joe Curia (aka Azumandias)
Modules: l0Admin Mass Email00000000l000000Automatic Time Zones000ll.l00000Enhanced Custom Profiles0.00Google Calendar0000l.l000000Post Previews
000000000Admin Security Suite000000000000Check Modules for Upgrades0000External Authentication000000Group Auto-Email00000.00000Private Message Alerts
000000000Attachment Download Counter0000Custom Attachment Icons000ll.ll00Favorite Forums000000.00000Highlighted Search Terms0000Self-Delete Posts Option
000000000Attachment Watermarks0l00000000Custom Language Database00l.l.0Forum Lockdown00000.00000Ignore Forums0000000000000Threaded Tree View
000000000Automatic Message Pruning00.llll.00Easy Color Scheme Manager0l.l00Forum Subscriptions0000lll000Moderated User Group
Templates:lGeneric Integration000000000 0000Simple Rounded000000 00000000Tabbed Emerald
Re: Module: Post Previews
October 22, 2008 05:33PM
Thanks again! Sounds perfect. It also gives us yet another reason to encourage users to register, which is one of our goals.
Re: Module: Post Previews
October 22, 2008 06:26PM
Quote
ImpalaLove
It also gives us yet another reason to encourage users to register, which is one of our goals.
I think we all share that goal. To be clear though, unregistered users will also get the previews. Registered users are the only ones who can disable the previews if you allow it.


Joe Curia (aka Azumandias)
Modules: l0Admin Mass Email00000000l000000Automatic Time Zones000ll.l00000Enhanced Custom Profiles0.00Google Calendar0000l.l000000Post Previews
000000000Admin Security Suite000000000000Check Modules for Upgrades0000External Authentication000000Group Auto-Email00000.00000Private Message Alerts
000000000Attachment Download Counter0000Custom Attachment Icons000ll.ll00Favorite Forums000000.00000Highlighted Search Terms0000Self-Delete Posts Option
000000000Attachment Watermarks0l00000000Custom Language Database00l.l.0Forum Lockdown00000.00000Ignore Forums0000000000000Threaded Tree View
000000000Automatic Message Pruning00.llll.00Easy Color Scheme Manager0l.l00Forum Subscriptions0000lll000Moderated User Group
Templates:lGeneric Integration000000000 0000Simple Rounded000000 00000000Tabbed Emerald
Re: Module: Post Previews
October 22, 2008 06:59PM
Yes, that part was clear. I'll be adding it into our FAQ, "If you are a registered user, you can..." Hopefully, people who like to customize their own settings will want to at least check out the different options. This feature plus the Search Phorum provides gives us an advantage over other forums in our little niche.
Re: Module: Post Previews
October 31, 2008 08:09PM
I've just installed this on 5.2.9a but nothing seems to be happening. Does the AJAX API need to be turned on somewhere separately?

The module is enabled at [www.cantonese.sheik.co.uk] (excuse the colour scheme, still in the process of upgrading from 5.1 :-) )

Cheers,

/\dam

--
My notable Phorum sites:
Movie Deaths Database - "review comments" system mostly powered by Phorum
Learn Chinese! - integrated forum quiz
Re: Module: Post Previews
October 31, 2008 08:19PM
In the header.js file for this mod, please edit this line:
"onFailure"     : function (error) { showerror = false; if (showerror) alert("Error: " + error); }
to read:
"onFailure"     : function (error) { showerror = true; if (showerror) alert("Error: " + error); }

This should send up an alert to let us know what is going wrong. (hmm, may need to add that to the settings page as a debug option...)


Joe Curia (aka Azumandias)
Modules: l0Admin Mass Email00000000l000000Automatic Time Zones000ll.l00000Enhanced Custom Profiles0.00Google Calendar0000l.l000000Post Previews
000000000Admin Security Suite000000000000Check Modules for Upgrades0000External Authentication000000Group Auto-Email00000.00000Private Message Alerts
000000000Attachment Download Counter0000Custom Attachment Icons000ll.ll00Favorite Forums000000.00000Highlighted Search Terms0000Self-Delete Posts Option
000000000Attachment Watermarks0l00000000Custom Language Database00l.l.0Forum Lockdown00000.00000Ignore Forums0000000000000Threaded Tree View
000000000Automatic Message Pruning00.llll.00Easy Color Scheme Manager0l.l00Forum Subscriptions0000lll000Moderated User Group
Templates:lGeneric Integration000000000 0000Simple Rounded000000 00000000Tabbed Emerald
Re: Module: Post Previews
October 31, 2008 08:25PM
When I look at the traffic that is generated by the module (using Firebug under Firefox), I see the following response from the server:
<b>Fatal error</b>:  Call to undefined function:  json_decode() in <b>/usr/local/home/httpd/vhtdocs/cantonese
/phorum/include/api/json.php</b> on line <b>62</b><br />

The json PHP extension not be enabled on the server, causing the json_encode() and json_decode() functions to be missing out. I thought I had taken care of that in the json API code, but it looks like something is going wrong in there. We need some debugging here.

Please open include/api/json.php. In that file, you should see the following code:
if (!function_exists('json_encode')) {
    require_once('./include/api/json-pear.php');
    $PHORUM['API']['PEARJSON'] = new Services_JSON();
}

What I'm suspecting, is that $PHORUM is not in global scope here, causing the json extension detection to get lost in the rest of the API code. Try changing this code to:
if (!function_exists('json_encode')) {
    require_once('./include/api/json-pear.php');
    $GLOBALS['PHORUM']['API']['PEARJSON'] = new Services_JSON();
}

See if that makes the interface work. If it does, then I'll update the core code to represent this change.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Sorry, only registered users may post in this forum.

Click here to login