#!/usr/local/bin/php
<?php
    
/**
    * o------------------------------------------------------------------------------o
    * | This package is dual licensed as GPL and a commercial license.               |
    * | If you use the code commercially (or if you don't want to be restricted by   |
    * | the GPL license), you will need the commercial license. It's only £49 (GBP - |
    * | roughly $98 depending on the exchange rate) and helps me out a lot. Thanks.  |
    * o------------------------------------------------------------------------------o
    *
    * © Copyright Richard Heyes
    */

    /**
    * Console test script
    */

    
require_once('Console.php');

    
$config = new Config();

    
/**
    * Setup the menu items
    */
    
$items[] = array('identifier' => 1, 'text' => 'Set email address', 'callback' => array($config, 'SetEmail'));
    
$items[] = array('identifier' => 2, 'text' => 'Set forename', 'callback' => array($config, 'SetForename'));
    
$items[] = array('identifier' => 3, 'text' => 'Set surname', 'callback' => array($config, 'SetSurname'));
    
$items[] = array('identifier' => 4, 'text' => 'Show current configuration', 'callback' => array($config, 'ShowConfig'));
    
$items[] = array('identifier' => 5, 'text' => 'Quit');

    
/**
    * Main loop of program show the menu
    */
    
while (true) {
        
Console::ClearScreen();
    
        echo
"\n    Simple Configuration Example\n    ============================\n\n";
        
$id = Console::ShowMenu($items);
        
        if (
$id == '5') {
            exit;
        }
    }
    
    
    
    
/**
    * Sample configuration class
    */
    
class Config
    
{
        private
$email;
        private
$forename;
        private
$surname;
        
        public function
__construct()
        {
            
$email = $forename = $surname = '';
        }
        
        public function
SetEmail()
        {
            
Console::ClearScreen();
            
            echo
"Please enter your email address: ";
            
$this->email = rtrim(Console::GetLine());
        }
        
        public function
SetForename()
        {
            
Console::ClearScreen();
            
            echo
"Please enter your forename: ";
            
$this->forename = rtrim(Console::GetLine());
        }
        
        public function
SetSurname()
        {
            
Console::ClearScreen();
            
            echo
"Please enter your surname: ";
            
$this->surname = rtrim(Console::GetLine());
        }
        
        public function
ShowConfig()
        {
            
Console::ClearScreen();
            
            echo
"    Current Configuration\n    =====================\n\n";
            
            echo
"Email........: ", $this->email, "\n";
            echo
"Forename.....: ", $this->forename, "\n";
            echo
"Surname......: ", $this->surname, "\n";
            echo
"\n\nPlease press enter to continue... [Enter]";
            
            
Console::Pause();
        }
    }
?>