forum.coppermine-gallery.net

Support => cpg1.4 plugins => cpg1.4.x Support => Older/other versions => cpg1.4 plugin contributions => Topic started by: Abbas Ali on August 13, 2008, 02:37:39 pm

Title: Scribd Document Viewer Plugin
Post by: Abbas Ali on August 13, 2008, 02:37:39 pm
You have quite a few documents (txt, doc, pdf etc..) in your gallery? and you want to display them in a better way? If yes then this is the plugin for you.

For those of you who are not familiar with Scribd, take a look at this (http://www.scribd.com/doc/17730/PHP-5-OO). This is how you can display the documents in your coppermine installation too. Here (http://dev.abbasali.net/cpg14x/displayimage.php?pos=-4) is a working demo after installing the plugin.

First you will have to register an account on Scribd (http://www.scribd.com) and get the API key and secret phrase. You can do so from here (http://www.scribd.com/platform/).

After you get the API key and secret phrase install the attached plugin and your are all done.

Unfortunately cpg lacks a few plugin hooks which is needed by this plugin, So you will have to add those hooks manually i.e. you will have to add a few lines of code manually before installing the plugin.

Edit include/picmgmt.inc.php (function add_picture)
Add

Code: [Select]
    $CURRENT_PIC_DATA['pid'] = mysql_insert_id();
    CPGPluginAPI::filter('add_file_data_success',$CURRENT_PIC_DATA);

just before

Code: [Select]
    return $result;
}

Edit delete.php (function delete_picture)
Add

Code: [Select]
    $pic['pid'] = $pid;
    CPGPluginAPI::filter('before_delete_file', $pic);

just before

Code: [Select]
    $query = "DELETE FROM {$CONFIG['TABLE_PICTURES']} WHERE pid='$pid' LIMIT 1";
    $result = cpg_db_query($query);

Edit editpics.php (function process_post_data)

Add

Code: [Select]
       $pic['pid'] = $pid;
       CPGPluginAPI::filter('before_delete_file', $pic);

just before

Code: [Select]
                        $query = "DELETE FROM {$CONFIG['TABLE_PICTURES']} WHERE pid='$pid' LIMIT 1";
                        $result = cpg_db_query($query);

Thats it. After making the above changes you can install the plugin. The configure screen of plugin will ask you the Scribd API key and Secret phrase.

Supported formats are txt, doc, ppt, xls, pdf and rtf

Note:

Cheers,
Abbas
Title: Re: Scribd Document Viewer Plugin
Post by: Joachim Müller on August 13, 2008, 11:05:44 pm
Wow, that's cool. Are you going to add the "missing" hooks to cpg1.5.x, so it can be used with that version easily?
Title: Re: Scribd Document Viewer Plugin
Post by: Abbas Ali on August 14, 2008, 06:45:47 am
Yes i will. Actually i was thinking to add them in cpg14x as well. Perhaps i will create a separate thread to discuss this.
Title: Re: Scribd Document Viewer Plugin
Post by: valsg on April 08, 2009, 07:35:54 pm
Indeed this is a great plugin :) I am however experiencing a strange issue with it. The plugin itself is working wonderfully alone but as soon as a bridge is installed, any newly uploaded file is not processed by it but instead is displayed regularly. I first noticed this after installing the phpBB3 bridge and thought this might be because of the bridge itself thus had it uninstalled. Once uninstalled, scribd plugin started working fine again and processed newly uploaded files correctly. I have then installed the SMF bridge and again, scribd plugin stopped processing new files.

Am I missing something and is there any way I can make the plugin work with either phpBB3 or SMF bridged? I guess this might be due to the custom hooks that I had to add to the files as described in th post above, but since I don't really know the code that well, I can't determine what might be causing it. Any help on that topic will be appreciated.

Thank you in advance!
Title: Re: Scribd Document Viewer Plugin
Post by: Myles on April 22, 2009, 02:55:37 pm
I have the same problem as in the above post.
The plugin works perfectly, but when I enable my bridge with phpbb3 the plugin is disabled. I have also bridged with SMF and the same thing happened. I'd be grateful if someone else would try it too.
Here is the site (the bridges are currently disabled so that I can make use of the plugin):

www.isbcreative.org (http://www.isbcreative.org) 


For info: it's a school site and we are aiming for students to be able to upload their work to the gallery and also discuss it in a bridged forum. Ideally, I'd also like to include a bridge with b2evolution, which would create something quite special. So any help with this will be much appreciated.
Title: Re: Scribd Document Viewer Plugin
Post by: Nibbler on April 22, 2009, 03:15:07 pm
Edit codebase.php, find

Code: [Select]
// We will only consider those extenstions which are supported by Scribd
global $scribd_valid_extensions;
$scribd_valid_extensions = array('pdf', 'txt', 'rtf', 'ppt', 'doc', 'xls');

Change to

Code: [Select]
// Add page_start action
$thisplugin->add_action('page_start', 'scribd_init');

function scribd_init()
{
    // We will only consider those extenstions which are supported by Scribd
    global $scribd_valid_extensions;
    $scribd_valid_extensions = array('pdf', 'txt', 'rtf', 'ppt', 'doc', 'xls');
}

That's the only thing I can see that might be an issue when bridging.
Title: Re: Scribd Document Viewer Plugin
Post by: Myles on April 26, 2009, 04:48:49 am
Thanks for your help. I have tried that, but the problem remains. (Each time I enable the smf bridge the plugin stops working.)

This is a copy of my codebase.php file as it is now http://www.isbcreative.org/test/codebase.txt (http://www.isbcreative.org/test/codebase.txt)