<?php

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

/**
 * get information on block
 */
function amazon_kidspagesbannerblock_info()
{
    // Values
    return array( 'text_type' => 'KidsPagesBanner',
                  'module' => 'Amazon',
                  'text_type_long' => 'Kids\'s Pages Banner Ad',
                  'allow_multiple' => true,
                  'form_content' => false,
                  'form_refresh' => false,
                  'show_preview' => true );
}

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

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

    $blockHTML = ''
        . '<div align="center">'
        . '  <a href="/oldkpindex.php?module=SubmitStuff&func=viewangeltree"><img src="/images/events/angeltree-banner2.jpg" width="150" height="100" border="0"></a>'
//        . '  <div style="padding-top:5px;"><a href="/modules.php?op=modload&name=Sections&file=index&req=viewarticle&artid=5104"><img src="/images/events/LoveAndLogic-2007-02-banner.gif" width="150" height="100" border="0"></a></div>'
//        . '  <a href="/modules.php?op=modload&name=Sections&file=index&req=viewarticle&artid=5015"><img src="/images/banners/FayEvent-2006-02.jpg" width="150" height="200" border="0"></a>'
        . '</div>';

    $output->Text( $blockHTML );

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

/**
 * modify block settings
 */
function amazon_kidspagesbannerblock_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_kidspagesbannerblock_update( $blockinfo )
{
    $vars['numitems'] = pnVarCleanFromInput( 'numitems' );

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

    return $blockinfo;
}

?>
