Log in | Register | Lost password

Bottom
Sharing other Files? Like PDF?
  • Posted: 06.09.2006, 14:07
     
    Converted
    rank:
    12
    registered:
     March 2009
    Status:
    offline
    last visit:
    Posts:
    0

    Code

    <?php

    // $Id: pnmedia_pdfapi.php,v 1.0 2006/09/06 10:01:54 jensp Exp $

    // =======================================================================

    // Mediashare by Jorn Lind-Nielsen (C) 2005.

    // ----------------------------------------------------------------------

    // For POST-NUKE Content Management System

    // Copyright (C) 2002 by the PostNuke Development Team.

    // http://www.postnuke.com/

    // ----------------------------------------------------------------------

    // LICENSE

    //

    // This program is free software; you can redistribute it and/or

    // modify it under the terms of the GNU General Public License (GPL)

    // as published by the Free Software Foundation; either version 2

    // of the License, or (at your option) any later version.

    //

    // This program is distributed in the hope that it will be useful,

    // but WIthOUT ANY WARRANTY; without even the implied warranty of

    // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

    // GNU General Public License for more details.

    //

    // To read the license ***** visit http://www.gnu.org/copyleft/gpl.html

    // =======================================================================



    //require_once 'modules/mediashare/mediaHandler.php';





    class mediashare_pdfHandler

    {

    function getTitle()

    {

    return 'Mediashare PDF Handler';

    }





    function getMediaTypes()

    {

    return array(

    array('mimeType' => 'application/pdf', 'fileType' => 'pdf', 'foundMimeType' => 'application/pdf', 'foundFileType' => 'pdf')

    );

    }





    function createPreviews($args, $previews)

    {

    $mediaFilename = $args['mediaFilename'];

    $mimeType = $args['mimeType'];

    $mediaFileType = $args['fileType'];



    $result = array();



    foreach ($previews as $preview)

    {

    if ($preview['isThumbnail'])

    {

    copy('modules/mediashare/pnimages/logo_pdf_appl.png', $preview['outputFilename']);

    $imPreview = @imagecreatefrompng($preview['outputFilename']);

    $result[] = array('fileType' => 'png',

    'mimeType' => 'image/png',

    'width' => imagesx($imPreview),

    'height' => imagesy($imPreview),

    'bytes' => filesize($preview['outputFilename']));

    imagedestroy($imPreview);

    }

    else

    {

    $width = $preview['imageSize'];

    $height = $preview['imageSize'];

    if ( array_key_exists('width', $args) && (int)$args['width'] > 0

    && array_key_exists('height', $args) && (int)$args['height'] > 0)

    {

    $w = (int)$args['width'];

    $h = (int)$args['height'];



    if ($w < $width || $h < $height)

    {

    $width = $w;

    $height = $h;

    }

    else if ($w > $h)

    $height = ($h/$w) * $height;

    else

    $width = ($w/$h) * $width;

    }



    $result[] = array('fileType' => $mediaFileType,

    'mimeType' => $mimeType,

    'width' => $width,

    'height' => $height,

    'useOriginal' => true,

    'bytes' => filesize($preview['outputFilename']));

    }

    }



    $width = (array_key_exists('width', $args) && (int)$args['width'] > 0 ? (int)$args['width'] : $preview['imageSize']);

    $height = (array_key_exists('height', $args) && (int)$args['height'] > 0 ? (int)$args['height'] : $preview['imageSize']);



    $result[] = array('fileType' => $mediaFileType,

    'mimeType' => $mimeType,

    'width' => $width,

    'height' => $height,

    'bytes' => filesize($mediaFilename));



    return $result;

    }





    function getMediaDisplayHtml($url, $width, $height, $id, $args)

    {

    //$width="100px"; $height="100px";

    $widthHtml = ($width == null ? '' : " width=\"$width\"");

    $heightHtml = ($height == null ? '' : " height=\"$height\"");



    return "

    <param name=\"src\" value=\"$url\">

    <a href=\"$url\">Link</a>

    ";

    }





    // Internal functions

    };





    function mediashare_media_pdfapi_buildHandler($args)

    {

    return new mediashare_pdfHandler();

    }

    ?>


    i copied the file named pnmedia_pdfapi.php in the mediashare directory but it won't work any suggestions?

    greetz

    Jens



    edited by: pjsb, Sep 06, 2006 - 03:07 PM
  • Posted: 07.09.2006, 11:50
     
    Converted
    rank:
    12
    registered:
     March 2009
    Status:
    offline
    last visit:
    Posts:
    0
    You need to regenerate the list of plugins in Mediashare's admin section.
  • Posted: 10.09.2006, 18:19
     
    Converted
    rank:
    12
    registered:
     March 2009
    Status:
    offline
    last visit:
    Posts:
    0
    Thanks for sharing! I have added it to CVS.
  • Posted: 04.03.2008, 11:31
     
    Converted
    rank:
    12
    registered:
     March 2009
    Status:
    offline
    last visit:
    Posts:
    0
    I have updated the PDF Media Handler to show PDFs with an embedded PDF reader. This allows you to browse through them almost like you do with pictures.

    Code

    <?php

    // $Id: pnmedia_pdfapi.php,v 1.1 2006/09/10 17:19:36 jornlind Exp $

    // =======================================================================

    // Mediashare by Jorn Lind-Nielsen (C) 2005.

    // ----------------------------------------------------------------------

    // For POST-NUKE Content Management System

    // Copyright (C) 2002 by the PostNuke Development Team.

    // http://www.postnuke.com/

    // ----------------------------------------------------------------------

    // LICENSE

    //

    // This program is free software; you can redistribute it and/or

    // modify it under the terms of the GNU General Public License (GPL)

    // as published by the Free Software Foundation; either version 2

    // of the License, or (at your option) any later version.

    //

    // This program is distributed in the hope that it will be useful,

    // but WIthOUT ANY WARRANTY; without even the implied warranty of

    // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

    // GNU General Public License for more details.

    //

    // To read the license ***** visit http://www.gnu.org/copyleft/gpl.html

    // =======================================================================



    //require_once 'modules/mediashare/mediaHandler.php';





    class mediashare_pdfHandler

    {

    function getTitle()

    {

    return 'Mediashare PDF Handler';

    }





    function getMediaTypes()

    {

    return array(

    array('mimeType' => 'application/pdf', 'fileType' => 'pdf',

    'foundMimeType' => 'application/pdf', 'foundFileType' => 'pdf')

    );

    }





    function createPreviews($args, $previews)

    {

    $mediaFilename = $args['mediaFilename'];

    $mimeType = $args['mimeType'];

    $mediaFileType = $args['fileType'];



    $result = array();



    foreach ($previews as $preview)

    {

    if ($mimeType == 'application/pdf' && $preview['isThumbnail'])

    {

    copy('modules/mediashare/pnimages/logo_pdf_appl.gif', $preview['outputFilename']);

    $imPreview = @imagecreatefrompng($preview['outputFilename']);

    $result[] = array('fileType' => 'png',

    'mimeType' => 'image/png',

    'width' => imagesx($imPreview),

    'height' => imagesy($imPreview),

    'bytes' => filesize($preview['outputFilename']));

    imagedestroy($imPreview);

    }

    else

    {

    $width = $preview['imageSize'];

    $height = $preview['imageSize'];

    if ( array_key_exists('width', $args) && (int)$args['width'] > 0

    && array_key_exists('height', $args) && (int)$args['height'] > 0)

    {

    $w = (int)$args['width'];

    $h = (int)$args['height'];



    if ($w < $width || $h < $height)

    {

    $width = $w;

    $height = $h;

    }

    else if ($w > $h)

    $height = ($h/$w) * $height;

    else

    $width = ($w/$h) * $width;

    }



    $result[] = array('fileType' => $mediaFileType,

    'mimeType' => $mimeType,

    'width' => $width,

    'height' => $height,

    'useOriginal' => true,

    'bytes' => filesize($preview['outputFilename']));

    }

    }



    $width = (array_key_exists('width', $args) && (int)$args['width'] > 0 ? (int)$args['width'] : $preview['imageSize']);

    $height = (array_key_exists('height', $args) && (int)$args['height'] > 0 ? (int)$args['height'] : $preview['imageSize']);



    $result[] = array('fileType' => $mediaFileType,

    'mimeType' => $mimeType,

    'width' => $width,

    'height' => $height,

    'bytes' => filesize($mediaFilename));



    return $result;

    }





    function getMediaDisplayHtml($url, $width, $height, $id, $args)

    {

    //$width="100px"; $height="100px";

    $widthHtml = ($width == null ? '' : " width=\"$width\"");

    $heightHtml = ($height == null ? '' : " height=\"$height\"");



    return "

    <a href=\"$url\" target=\"blank\">Open in a new window</a>

    <!--[literal]--><!--[if !IE]> --><!--[/literal]-->



    <param name=\"src\" value=\"$url\">

    <param name=\"pluginurl\" value=\"http://www.adobe.com/\">



    <!--[literal]--><!-- <![endif]--><!--[/literal]-->



    <!--[literal]--><!--[if IE]><!--[/literal]-->

    <embed src=\"$url\" type=\"application/pdf\" height=\"350\" width=\"640\">

    </embed>

    <!--[literal]--><!--><!----><!--[/literal]-->

    ";

    }





    // Internal functions

    };





    function mediashare_media_pdfapi_buildHandler($args)

    {

    return new mediashare_pdfHandler();

    }



    ?>
  • Posted: 28.03.2008, 17:38
     
    Converted
    rank:
    12
    registered:
     March 2009
    Status:
    offline
    last visit:
    Posts:
    0
    Thanks thilo.

    Works fine with Firefox. Unfortunately not with IE 7. The pdf object does not show.
  • Posted: 28.03.2008, 21:02
     
    Converted
    rank:
    12
    registered:
     March 2009
    Status:
    offline
    last visit:
    Posts:
    0

    Quote

    Works fine with Firefox. Unfortunately not with IE 7. The pdf object does not show.

    I don't have IE 7. Anyone out there able to test and improve this?

Template courtesy of Designs By Darren.