blob: 4ef2f727dc0b440c83e3244082bdb3fe54a971b6 [file] [log] [blame]
<?php
########################################################################################################
# Aastra XML API Classes - AastraIPPhoneInputScreen
# Copyright Aastra Telecom 2005-2010
#
# AastraIPPhoneInputScreen object.
#
# Public methods
#
# Inherited from AastraIPPhone
# setTitle(Title) to setup the title of an object (optional)
# @title string
# setTitleWrap() to set the title to be wrapped on 2 lines (optional)
# setCancelAction(uri) to set the cancel parameter with the URI to be called on Cancel (optional)
# @uri string
# setDestroyOnExit() to set DestroyonExit parameter to 'yes', 'no' by default (optional)
# setBeep() to enable a notification beep with the object (optional)
# setLockIn() to set the Lock-in tag to 'yes' (optional)
# setLockInCall() to set the Lock-in tag to 'call' (optional)
# setAllowAnswer() to set the allowAnswer tag to 'yes' (optional only for non softkey phones)
# setAllowDrop() to set the allowDrop tag to 'yes' (optional only for non softkey phones)
# setAllowXfer() to set the allowXfer tag to 'yes' (optional only for non softkey phones)
# setAllowConf() to set the allowConf tag to 'yes' (optional only for non softkey phones)
# setTimeout(timeout) to define a specific timeout for the XML object (optional)
# @timeout integer (seconds)
# addSoftkey(index,label,uri,icon_index) to add custom soktkeys to the object (optional)
# @index integer, softkey number
# @label string
# @uri string
# @icon_index integer, icon number
# setRefresh(timeout,URL) to add Refresh parameters to the object (optional)
# @timeout integer (seconds)
# @URL string
# setEncodingUTF8() to change encoding from default ISO-8859-1 to UTF-8 (optional)
# addIcon(index,icon) to add custom icons to the object (optional)
# @index integer, icon index
# @icon string, icon name or definition
# generate() to return the generated XML for the object
# output(flush) to display the object
# @flush boolean optional, output buffer to be flushed out or not.
#
# Specific to the object - Single Input
# setURL(url) to set the URL to called after the input
# @url string
# setType(type) to set type of input, 'string' by default
# @type enum ('IP', 'string', 'number', 'dateUS'...)
# setDefault(default) to set default value for the input (optional)
# @default string
# setParameter(param) to set the parameter name to be parsed after the input
# @param string
# setInputLanguage(language) to set the language of the input (optional)
# @language enum ("English", "French"....)
# setPassword() to set the Password parameter to 'yes', 'no' by default (optional)
# setNotEditable() to set the editable parameter to 'no', 'yes' by default (optional)
# setEditable() is now replaced by setNotEditable but kept for compatibility reasons (optional)
# setPrompt(prompt) to set the prompt to be displayed for the input.
# @prompt string
#
# Specific to the object - Multiple Inputs
# setURL(url) to set the URL to called after the input
# @url string
# setType(type) to set the default type of input 'string' by default
# @type enum ('IP', 'string', 'number', 'dateUS'...)
# setDefault(default) to set default default value for the input (optional)
# @default string
# setParameter(param) to set the default parameter name to be parsed after the input
# @param string
# setPassword() to set the default Password parameter to 'yes', 'no' by default (optional)
# setNotEditable() to set the default editable parameter to 'no', 'yes' by default (optional)
# setEditable() is now replaced by setNotEditable but kept for compatibility reasons (optional)
# setPrompt(prompt) to set the default prompt to be displayed for the input.
# @prompt string
# setDefaultIndex(index) to define the field index the object will use to start (optional)
# @index integer, optional, default is 1
# setDisplayMode(display) to define the aspect of the display, normal/condensed (optional)
# @display enum ("normal, "condensed"), default is "normal".
# setInputLanguage(language) to set the language of the input (optional)
# @language enum ("English", "French"....)
# addField(type) to add an input field and setting its type
# @type (IP, string, number, dateUS, timeUS,dateInt, timeInt or empty) if the type is an empty string then the type is inherited from the main object.
# setFieldPassword(password) to set the password mode for the input field, overrides the value set by setPassword for the field
# @password enum ("yes", "no")
# setFieldEditable(editable) to set the input field editable mode ('yes', no'), overrides the value set by setEditable or setNotEditable for the field
# @editable enum ("yes", "no")
# setFieldParameter(parameter) to set the parameter name to be parsed after the global input, overrides the value set by setParameter for the field
# @parameter string
# setFieldPrompt(prompt)to set the prompt to be displayed for the input field, overrides the value set by setPrompt for the field
# @prompt string
# setFieldSelection(selection) to set the Selection tag for the field
# @selection string
# setFieldDefault(default) to set default value for the input field, overrides the value set by setDefault for the field
# @default string
# addFieldSoftkey(index,label,uri,icon) to add custom softkeys to the input field, overrides the softkeys set by addSoftkey.
# @index integer, softkey number
# @label string
# @uri string
# @icon integer, icon number
#
# Example 1 - Single Input
# require_once('AastraIPPhoneInputScreen.class.php');
# $input = new AastraIPPhoneInputScreen();
# $input->setTitle('Title');
# $input->setPrompt('Enter your password');
# $input->setParameter('param');
# $input->setType('string');
# $input->setURL('http://myserver.com/script.php');
# $input->setPassword();
# $input->setDestroyOnExit();
# $input->setDefault('Default');
# $input->output();
#
# Example 2 - Multiple Inputs
# require_once('AastraIPPhoneInputScreen.class.php');
# $input = new AastraIPPhoneInputScreen();
# $input->setTitle('Example 2');
# $input->setDisplayMode('condensed');
# $input->setURL('http://myserver.com/script.php');
# $input->setDestroyOnExit();
# $input->addSoftkey('5', 'Done', 'SoftKey:Submit');
# $input->addField('string');
# $input->setFieldPrompt('Username:');
# $input->setFieldParameter('user');
# $input->addFieldSoftkey('3', 'ABC', 'SoftKey:ChangeMode');
# $input->addField('number');
# $input->setFieldPassword('yes');
# $input->setFieldPrompt('Pass:');
# $input->setFieldParameter('passwd');
# $input->output();
#
########################################################################################################
require_once('AastraIPPhone.class.php');
require_once('AastraIPPhoneInputScreenEntry.class.php');
require_once('AastraIPPhoneSoftkeyEntry.class.php');
class AastraIPPhoneInputScreen extends AastraIPPhone {
var $_url;
var $_type='string';
var $_parameter;
var $_prompt;
var $_editable='';
var $_default='';
var $_password='';
var $_defaultindex='';
var $_displaymode='';
var $_inputlanguage='';
function setURL($url)
{
$this->_url=$url;
}
function setType($type)
{
$this->_type=$type;
}
function setEditable()
{
$this->_editable='no';
}
function setNotEditable()
{
$this->_editable='no';
}
function setDefault($default)
{
$this->_default=$default;
}
function setParameter($parameter)
{
$this->_parameter=$parameter;
}
function setPassword()
{
$this->_password='yes';
}
function setPrompt($prompt)
{
$this->_prompt=$prompt;
}
function setDefaultIndex($index)
{
$this->_defaultindex=$index;
}
function setDisplayMode($display)
{
$this->_displaymode=$display;
}
function setInputLanguage($input)
{
$this->_inputlanguage=$input;
}
function addField($type='')
{
$this->_entries[] = new AastraIPPhoneInputScreenEntry($type);
end($this->_entries);
}
function setFieldType($type)
{
$this->_entries[key($this->_entries)]->_type=$type;
}
function setFieldPassword($password='yes')
{
$this->_entries[key($this->_entries)]->_password=$password;
}
function setFieldEditable($editable='yes')
{
$this->_entries[key($this->_entries)]->_editable=$editable;
}
function setFieldParameter($parameter)
{
$this->_entries[key($this->_entries)]->_parameter=$parameter;
}
function setFieldPrompt($prompt)
{
$this->_entries[key($this->_entries)]->_prompt=$this->escape($prompt);
}
function setFieldDefault($default)
{
$this->_entries[key($this->_entries)]->_default=$default;
}
function setFieldSelection($selection)
{
$this->_entries[key($this->_entries)]->_selection=$selection;
}
function addFieldSoftkey($index, $label, $uri, $icon=NULL)
{
$this->_entries[key($this->_entries)]->_softkeys[] = new AastraIPPhoneSoftkeyEntry($index, $this->escape($label), $this->escape($uri), $icon);
}
function render()
{
# Beginning of root tag
$out = "<AastraIPPhoneInputScreen type=\"$this->_type\"";
# Password
if($this->_password == 'yes') $out .= " password=\"yes\"";
# DestroyOnExit
if($this->_destroyOnExit == 'yes') $out .= " destroyOnExit=\"yes\"";
# CancelAction
if($this->_cancelAction != "")
{
$cancelAction = $this->escape($this->_cancelAction);
$out .= " cancelAction=\"{$cancelAction}\"";
}
# Editable
if($this->_editable=='no') $out .= " editable=\"no\"";
# Beep
if($this->_beep=='yes') $out .= " Beep=\"yes\"";
# DefaultIndex
if($this->_defaultindex!='') $out .= " defaultIndex=\"".$this->_defaultindex."\"";
# InputLanguage
if($this->_inputlanguage!='') $out .= " inputLanguage=\"".$this->_inputlanguage."\"";
# Display Mode
if($this->_displaymode!='') $out .= " displayMode=\"".$this->_displaymode."\"";
# Lockin
if($this->_lockin!='') $out .= " LockIn=\"{$this->_lockin}\"";
# AllowAnswer
if($this->_allowAnswer == 'yes') $out .= " allowAnswer=\"yes\"";
# AllowDrop
if($this->_allowDrop == 'yes') $out .= " allowDrop=\"yes\"";
# AllowXfer
if($this->_allowXfer == 'yes') $out .= " allowXfer=\"yes\"";
# AllowConf
if($this->_allowConf == 'yes') $out .= " allowConf=\"yes\"";
# TimeOut
if($this->_timeout!=0) $out .= " Timeout=\"{$this->_timeout}\"";
# End of the root tag
$out .= ">\n";
# Title
if ($this->_title!='')
{
$title = $this->escape($this->_title);
$out .= "<Title";
if ($this->_title_wrap=='yes') $out .= " wrap=\"yes\"";
$out .= ">".$title."</Title>\n";
}
# Prompt
if($this->_prompt != '')
{
$prompt = $this->escape($this->_prompt);
$out .= "<Prompt>{$prompt}</Prompt>\n";
}
# URL
$url = $this->escape($this->_url);
$out .= "<URL>{$url}</URL>\n";
# Parameter
if($this->_parameter != '') $out .= "<Parameter>{$this->_parameter}</Parameter>\n";
# Default
$out .= "<Default>{$this->_default}</Default>\n";
# Multiple input fields
if (isset($this->_entries) && is_array($this->_entries))
{
foreach ($this->_entries as $entry) $out .= $entry->render();
}
# Softkeys
if (isset($this->_softkeys) && is_array($this->_softkeys))
{
foreach ($this->_softkeys as $softkey) $out .= $softkey->render();
}
# Icons
if (isset($this->_icons) && is_array($this->_icons))
{
$IconList=False;
foreach ($this->_icons as $icon)
{
if(!$IconList)
{
$out .= "<IconList>\n";
$IconList=True;
}
$out .= $icon->render();
}
if($IconList) $out .= "</IconList>\n";
}
# End tag
$out .= "</AastraIPPhoneInputScreen>\n";
return $out;
}
}
?>