<?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 = '';

    if ( $regionid == 2 )
    {
      $blockHTML .= '<div align="center"><div style="padding-bottom:1px;"><a href="/index.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="/index.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="/index.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=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;
}

?>
