<?php
/*************************
  Coppermine Photo Gallery
  ************************
  Copyright (c) 2003-2009 Coppermine Dev Team
  v1.1 originally written by Gregory DEMAR

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License version 3
  as published by the Free Software Foundation.

  ********************************************
  Coppermine version: 1.5.1
  $HeadURL: https://coppermine.svn.sourceforge.net/svnroot/coppermine/trunk/cpg1.5.x/plugins/sample/codebase.php $
  $Revision: 5589 $
  $LastChangedBy: gaugau $
  $Date: 2009-01-06 09:42:39 +0100 (Di, 06 Jan 2009) $
**********************************************/

if (!defined('IN_COPPERMINE')) die('Not in Coppermine...');
if (!defined('CORE_PLUGIN')) {
	define('CORE_PLUGIN', true);
}

// Add an install action
$thisplugin->add_action('plugin_install','sample_install');

// Add a configure action
$thisplugin->add_action('plugin_configure','sample_configure');

// Add a filter for the gallery header
$thisplugin->add_filter('gallery_header','sample_header');

$thisplugin->add_filter('plugin_block','sample_block_mgr');


// Sample function to modify gallery header html
function sample_header($html) {
    global $thisplugin, $lang_plugin_php;
    $return = '<strong style="color:red;">'.$lang_plugin_php['sample_output'].'</strong>'.$html;
    return $return;
}

function sample_block_mgr($block) {
    return $block;
}


// Install function
// Checks if uid is 'foo' and pwd is 'bar'; If so, then install the plugin
function sample_install() {
	
	// Create the super cage
	$superCage = Inspekt::makeSuperCage();
    // Install
    if ($superCage->post->getAlpha('uid')=='foo' && $superCage->post->getAlpha('pwd') == 'bar') {

        return true;

    // Loop again
    } else {

        return 1;
    }
}

// Configure function
// Displays the form
function sample_configure() {
	global $lang_plugin_php, $lang_common;
	// Create the super cage
	$superCage = Inspekt::makeSuperCage();

    echo <<< EOT
    <form name="cpgform" id="cpgform" action="{$superCage->server->getEscaped('REQUEST_URI')}" method="post">
            <table border="0" cellspacing="0" cellpadding="0" width="100%">
              <tr>
                <td class="tableh2" colspan="2">
                  <h3>{$lang_plugin_php['sample_install_explain']}</h3>
                </td>
              </tr>
              <tr>
                <td class="tableb" align="right">
                  {$lang_plugin_php['sample_install_username']}:
                </td>
                <td class="tableb">
                  <input type="text" name="uid" class="textinput" style="width:100%" />
                </td>
              </tr>
              <tr>
                <td class="tableb tableb_alternate" align="right">
                  {$lang_plugin_php['sample_install_password']}:
                </td>
                <td class="tableb tableb_alternate">
                  <input type="password" name="pwd" class="textinput" style="width:100%" />
                </td>
              </tr>
              <tr>
                <td class="tablef" colspan="2">
                  <input type="submit" value="{$lang_common['go']}" class="button" />
                </td>
              </tr>
            </table>
    </form>
EOT;
}
?>