<?php
// $Id: readerresponse.php,v 1.1.1.1 2002/09/15 22:26:15 root Exp $
// ----------------------------------------------------------------------
// POST-NUKE Content Management System
// Copyright (C) 2001 by the Post-Nuke Development Team.
// http://www.postnuke.com/
// ----------------------------------------------------------------------
// Based on:
// PHP-NUKE Web Portal System - http://phpnuke.org/
// Thatware - http://thatware.org/
// ----------------------------------------------------------------------
// 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 please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------

/**
 * initialise block
 */
function amazon_readerresponseblock_init()
{
    // Security
    pnSecAddSchema( 'Amazon:ReaderResponseblock:', 'Block title::' );
}

/**
 * get information on block
 */
function amazon_readerresponseblock_info()
{
    // Values
    return array( 'text_type' => 'ReaderResponse',
                  'module' => 'Amazon',
                  'text_type_long' => 'Reader Response',
                  'allow_multiple' => true,
                  'form_content' => false,
                  'form_refresh' => false,
                  'show_preview' => true );
}

/**
 * display block
 */
function amazon_readerresponseblock_display( $blockinfo )
{
    // Security check
    if ( !pnSecAuthAction( 0,
                           'Amazon:ReaderResponseblock:',
                           "$blockinfo[title]::",
                           ACCESS_READ ) )
    {
        return;
    }

    $output = new pnHTML();
    $output->SetInputMode( _PNH_VERBATIMINPUT );

    $regionid = getRegionIDCcookie();

    $blockHTML = '';

    $blockHTML .=
<<<EOT

<script type="text/JavaScript">
<!--
  function launch_sidebar_ebook(url){
    new_window = window.open(url,'ebook','scrollbars=no,toolbars=no,resizable=yes');
    new_window.focus();
  }
//-->
</script>

EOT
;

//    $best_places_num = mt_rand(0, 2);
//
//    $best_places = array( 
//      "BestPlaces2008-Vote-01.gif",
//      "BestPlaces2008-Vote-02.gif",
//      "BestPlaces2008-Vote-03.gif",
//    );
//
//
//    $best_places_ad = $best_places[$best_places_num];

    $best_places_ad = "BestPlaces2008-Vote-anim3.gif";

    if ( $regionid == 2 )
    {
//      $blockHTML .= '<div align="center"><div style="padding-bottom:1px;"><a href="/oldkpindex.php?module=SubmitStuff&func=viewangeltree"><img src="/images/events/angeltree-banner2.jpg" width="150" height="100" border="0" alt="Kids\' Pages Cares Angel Tree" title="Kids\' Pages Cares Angel Tree"></a></div></div><hr style="height:10px;margin:0px; padding:0px; color: #fff;border:0px solid #FFF;"/>';
//      $blockHTML .= '<div align="center"><div style="padding-bottom:1px;"><a href="/modules.php?op=modload&name=Sections&file=index&req=viewarticle&artid=5008"><img src="/images/banners/ThankYouDonors-2007.gif" width="150" height="70" border="0" alt="Thank You to Our 2007 Donors!" title="Thank You to Our 2007 Donors!"></a></div></div><hr style="height:10px;margin:0px; padding:0px; color: #fff;border:0px solid #FFF;"/>';
//      $blockHTML .= '<div align="center"><div style="padding-bottom:1px;"><a href="/modules.php?op=modload&name=Sections&file=index&req=viewarticle&artid=5176"><img src="/images/events/LoveAndLogic-2008-02_03.gif" width="150" height="100" border="0" alt="Click for Parenting with Love and Logic!" title="Click for Parenting with Love and Logic!"></a></div></div><hr style="height:10px;margin:0px; padding:0px; color: #fff;border:0px solid #FFF;"/>';

      $blockHTML .= '<div align="center"><div style="padding-bottom:1px;"><a href="/modules.php?op=modload&name=Sections&file=index&req=viewarticle&artid=5015"><img src="/images/cover/newsite/thisthursday.gif" width="171" height="284" border="0" alt="Click for more event info." title="Click for more event info."></a></div></div><hr style="height:10px;margin:0px; padding:0px; color: #fff;border:0px solid #FFF;"/>';
      $blockHTML .= '<div align="center"><div style="padding-bottom:1px;"><a href="/modules.php?op=modload&name=Sections&file=index&req=viewarticle&artid=5201"><img src="/images/articles/2008-09/classesandlessons/classesandlessonsbanner.gif" width="170" height="100" border="0" alt="Click to see Classes & Lessons Guide - 2008" title="Click to see Classes & Lessons Guide - 2008"></a></div></div><hr style="height:10px;margin:0px; padding:0px; color: #fff;border:0px solid #FFF;"/>';

//      $blockHTML .= '<div align="center"><div style="padding-bottom:1px;"><a href="javascript:launch_sidebar_ebook(\'/ebooks/2008-06/denver/flash.html#/15/\');"><img src="/images/bestof2008/' . $best_places_ad . '" width="150" height="116" border="0" alt="Click for Best Places for Families 2008!" title="Click for Best Places for Families 2008!"></a></div></div><hr style="height:10px;margin:0px; padding:0px; color: #fff;border:0px solid #FFF;"/>';
//      $blockHTML .= '<div align="center"><div style="padding-bottom:1px;"><a href="/oldkpindex.php?module=SubmitStuff&func=viewgasraffle"><img src="/images/raffle/gas-2008-07/GasRaffleTicket.gif" width="150" height="150" border="0" alt="Win a $500 Gas Card!" title="Win a $500 Gas Card!"></a></div></div><hr style="height:10px;margin:0px; padding:0px; color: #fff;border:0px solid #FFF;"/>';
//      $blockHTML .= '<div align="center"><div style="padding-bottom:1px;"><a href="/oldkpindex.php?module=SubmitStuff&func=viewcarraffle"><img src="/images/raffle/car-2008-03/CarRaffleBanner03.gif" width="150" height="154" border="0" alt="Win This Car!" title="Win This Car!"></a></div></div><hr style="height:10px;margin:0px; padding:0px; color: #fff;border:0px solid #FFF;"/>';

//      $blockHTML .= '<div align="center"><div style="padding-bottom:1px;"><a href="/modules.php?op=modload&name=Sections&file=index&req=viewarticle&artid=5184"><img src="/images/events/FamilyFestival-2008-banner2.jpg" width="150" height="100" border="0" alt="Click for Family Festival & Information Fairs - 2008!" title="Click for Family Festival & Information Fairs - 2008!"></a></div></div><hr style="height:10px;margin:0px; padding:0px; color: #fff;border:0px solid #FFF;"/>';
//      $blockHTML .= '<div align="center"><div style="padding-bottom:1px;"><a href="/oldkpindex.php?module=SubmitStuff&func=viewsub"><img src="/images/banners/Subscription-2007-09.jpg" width="150" height="203" border="0" alt="Subscribe to Kids\' Pages!"></a></div></div>';
    }
    else
    {
//      $blockHTML .= '<div align="center"><div style="padding-bottom:1px;"><a href="/modules.php?op=modload&name=Sections&file=index&req=viewarticle&artid=5008"><img src="/images/banners/ThankYouDonors-2007.gif" width="150" height="70" border="0" alt="Thank You to Our 2007 Donors!" title="Thank You to Our 2007 Donors!"></a></div></div><hr style="height:10px;margin:0px; padding:0px; color: #fff;border:0px solid #FFF;"/>';
//      $blockHTML .= '<div align="center"><div style="padding-bottom:1px;"><a href="/oldkpindex.php?module=SubmitStuff&func=viewangeltree"><img src="/images/events/angeltree-banner2.jpg" width="150" height="100" border="0" alt="Kids\' Pages Cares Angel Tree" title="Kids\' Pages Cares Angel Tree"></a></div></div><hr style="height:10px;margin:0px; padding:0px; color: #fff;border:0px solid #FFF;"/>';
//      $blockHTML .= '<div align="center"><div style="padding-bottom:1px;"><a href="/modules.php?op=modload&name=Sections&file=index&req=viewarticle&artid=5164"><img src="/images/cover/2007-10/MedicalListings.gif" width="150" height="100" border="0" alt="Click for Winners!" title="Family-Friendly Medical Listings"></a></div></div><hr style="height:10px;margin:0px; padding:0px; color: #fff;border:0px solid #FFF;"/>';
//      $blockHTML .= '<div align="center"><div style="padding-bottom:1px;"><a href="/modules.php?op=modload&name=Sections&file=index&req=viewarticle&artid=5176"><img src="/images/events/LoveAndLogic-2008-02_03.gif" width="150" height="100" border="0" alt="Click for Parenting with Love and Logic!" title="Click for Parenting with Love and Logic!"></a></div></div><hr style="height:10px;margin:0px; padding:0px; color: #fff;border:0px solid #FFF;"/>';

      $blockHTML .= '<div align="center"><div style="padding-bottom:1px;"><a href="/modules.php?op=modload&name=Sections&file=index&req=viewarticle&artid=5015"><img src="/images/cover/newsite/thisthursday.gif" width="171" height="284" border="0" alt="Click for more event info." title="Click for more event info."></a></div></div><hr style="height:10px;margin:0px; padding:0px; color: #fff;border:0px solid #FFF;"/>';
      $blockHTML .= '<div align="center"><div style="padding-bottom:1px;"><a href="/modules.php?op=modload&name=Sections&file=index&req=viewarticle&artid=5201"><img src="/images/articles/2008-09/classesandlessons/classesandlessonsbanner.gif" width="170" height="100" border="0" alt="Click to see Classes & Lessons Guide - 2008" title="Click to see Classes & Lessons Guide - 2008"></a></div></div><hr style="height:10px;margin:0px; padding:0px; color: #fff;border:0px solid #FFF;"/>';

//      $blockHTML .= '<div align="center"><div style="padding-bottom:1px;"><a href="javascript:launch_sidebar_ebook(\'/ebooks/2008-06/denver/flash.html#/15/\');"><img src="/images/bestof2008/' . $best_places_ad . '" width="150" height="116" border="0" alt="Click for Best Places for Families 2008!" title="Click for Best Places for Families 2008!"></a></div></div><hr style="height:10px;margin:0px; padding:0px; color: #fff;border:0px solid #FFF;"/>';
//      $blockHTML .= '<div align="center"><div style="padding-bottom:1px;"><a href="/oldkpindex.php?module=SubmitStuff&func=viewgasraffle"><img src="/images/raffle/gas-2008-07/GasRaffleTicket.gif" width="150" height="150" border="0" alt="Win a $500 Gas Card!" title="Win a $500 Gas Card!"></a></div></div><hr style="height:10px;margin:0px; padding:0px; color: #fff;border:0px solid #FFF;"/>';
//      $blockHTML .= '<div align="center"><div style="padding-bottom:1px;"><a href="/oldkpindex.php?module=SubmitStuff&func=viewcarraffle"><img src="/images/raffle/car-2008-03/CarRaffleBanner03.gif" width="150" height="154" border="0" alt="Win This Car!" title="Win This Car!"></a></div></div><hr style="height:10px;margin:0px; padding:0px; color: #fff;border:0px solid #FFF;"/>';

//      $blockHTML .= '<div align="center"><div style="padding-bottom:1px;"><a href="/modules.php?op=modload&name=Sections&file=index&req=viewarticle&artid=5184"><img src="/images/events/FamilyFestival-2008-banner2.jpg" width="150" height="100" border="0" alt="Click for Family Festival & Information Fairs - 2008!" title="Click for Family Festival & Information Fairs - 2008!"></a></div></div><hr style="height:10px;margin:0px; padding:0px; color: #fff;border:0px solid #FFF;"/>';
//      $blockHTML .= '<div align="center"><div style="padding-bottom:1px;"><a href="/modules.php?op=modload&name=Sections&file=index&req=viewarticle&artid=5159"><img src="/images/banners/ClassesAndLessons-banner.jpg" width="150" height="100" border="0" alt="Click for the Guide!" title="Click for the Guide!"></a></div></div><hr style="height:10px;margin:0px; padding:0px; color: #fff;border:0px solid #FFF;"/>';
    }

    $output->Text( $blockHTML );

    // Populate block info and pass to theme
    $blockinfo['content'] = $output->GetOutput();
    return themesideblock( $blockinfo );
}

/**
 * modify block settings
 */
function amazon_readerresponseblock_modify( $blockinfo )
{
    // Create output object
    $output = new pnHTML();

    // Get current content
    $vars = pnBlockVarsFromContent( $blockinfo['content'] );

    // Defaults
    if ( empty( $vars['numitems'] ) )
    {
        $vars['numitems'] = 5;
    }

    // Create row
    $row = array();
    $output->SetOutputMode( _PNH_RETURNOUTPUT );
    $row[] = $output->Text( _NUMITEMS );
    $row[] = $output->FormText( 'numitems',
                                pnVarPrepForDisplay( $vars['numitems'] ),
                                5,
                                5 );
    $output->SetOutputMode( _PNH_KEEPOUTPUT );

    // Add row
    $output->SetInputMode( _PNH_VERBATIMINPUT );
    $output->TableAddRow( $row, 'left' );
    $output->SetInputMode( _PNH_PARSEINPUT );

    // Return output
    return $output->GetOutput();
}

/**
 * update block settings
 */
function amazon_readerresponseblock_update( $blockinfo )
{
    $vars['numitems'] = pnVarCleanFromInput( 'numitems' );

    $blockinfo['content'] = pnBlockVarsToContent( $vars );

    return $blockinfo;
}

?>
