243 lines
9.0 KiB
PHP
243 lines
9.0 KiB
PHP
<?
|
|
|
|
########################################################################################################
|
|
# Aastra XML API Classes - AastraIPPhoneInputScreen
|
|
# Copyright Aastra Telecom 2007
|
|
#
|
|
# AastraIPPhoneInputScreen object.
|
|
#
|
|
# Public methods
|
|
#
|
|
# Inherited from AastraIPPhone
|
|
# setTitle(Title) to setup the title of an object (optional)
|
|
# setTitleWrap() to set the title to be wrapped on 2 lines (optional)
|
|
# setDestroyOnExit() to set DestroyonExit parameter to 'yes', 'no' by default (optional)
|
|
# setCancelAction(uri) to set the cancel parameter with the URI to be called on Cancel (optional)
|
|
# setBeep() to enable a notification beep with the object (optional)
|
|
# setLockIn() to set the Lock-in tag to 'yes' (optional)
|
|
# setAllowAnswer() to set the allowAnswer tag to 'yes' (optional)
|
|
# setTimeout(timeout) to define a specific timeout for the XML object (optional)
|
|
# addSoftkey(index,label,uri,icon_index) to add custom softkeys to the object (optional)
|
|
# addIcon(index,icon) to add custom icons to the object (optional)
|
|
# generate() to return the object content
|
|
# output() to display the object
|
|
#
|
|
# Specific to the object - Single Input
|
|
# setURL(url) to set the URL to called after the input
|
|
# setType(type) to set type of input ('IP', 'string'or 'number'), 'string' by default
|
|
# setDefault(default) to set default value for the input (optional)
|
|
# setParameter(param) to set the parameter name to be parsed after the input
|
|
# 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.
|
|
#
|
|
# Specific to the object - Multiple Inputs
|
|
# setURL(url) to set the URL to called after the input
|
|
# setType(type) to set the default type of input ('IP', 'string'or 'number'), 'string' by default
|
|
# setDefault(default) to set default default value for the input (optional)
|
|
# setParameter(param) to set the default parameter name to be parsed after the input
|
|
# 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.
|
|
# setDefaultIndex(index) to define the field index the object will use to start (optional) default is 1
|
|
# setDisplayMode(display) to define the aspect of the display, normal/condensed (optional) default is normal.
|
|
# addField(type) to add an input field and setting its 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 ('yes', no'), overrides the value set by setPassword for the field
|
|
# setFieldEditable(editable) to set the input field editable mode ('yes', no'), overrides the value set by setEditable or setNotEditable for the field
|
|
# setFieldParameter(parameter) to set the parameter name to be parsed after the global input, overrides the value set by setParameter for the field
|
|
# setFieldPrompt(prompt)to set the prompt to be displayed for the input field, overrides the value set by setPrompt for the field
|
|
# setFieldDefault(default) to set default value for the input field, overrides the value set by setDefault for the field
|
|
# addFieldSoftkey(index,label,uri,icon) to add custom softkeys to the input field, overrides the softkeys set by addSoftkey.
|
|
#
|
|
# 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='';
|
|
|
|
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 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 addFieldSoftkey($index, $label, $uri, $icon=NULL)
|
|
{
|
|
$this->_entries[key($this->_entries)]->_softkeys[] = new AastraIPPhoneSoftkeyEntry($index, $this->escape($label), $this->escape($uri), $icon);
|
|
}
|
|
|
|
|
|
function render()
|
|
{
|
|
$prompt = $this->escape($this->_prompt);
|
|
$url = $this->escape($this->_url);
|
|
$out = '';
|
|
$out .= "<AastraIPPhoneInputScreen type=\"$this->_type\"";
|
|
if($this->_password == 'yes') $out .= " password=\"yes\"";
|
|
if($this->_destroyOnExit == 'yes') $out .= " destroyOnExit=\"yes\"";
|
|
if($this->_cancelAction != "")
|
|
{
|
|
$cancelAction = $this->escape($this->_cancelAction);
|
|
$out .= " cancelAction=\"{$cancelAction}\"";
|
|
}
|
|
if($this->_editable=='no') $out .= " editable=\"no\"";
|
|
if($this->_beep=='yes') $out .= " Beep=\"yes\"";
|
|
if($this->_defaultindex!='') $out .= " defaultIndex=\"".$this->_defaultindex."\"";
|
|
if($this->_displaymode!='') $out .= " displayMode=\"".$this->_displaymode."\"";
|
|
if($this->_lockin=='yes') $out .= " LockIn=\"yes\"";
|
|
if($this->_allowAnswer == 'yes') $out .= " allowAnswer=\"yes\"";
|
|
if($this->_timeout!=0) $out .= " Timeout=\"{$this->_timeout}\"";
|
|
$out .= ">\n";
|
|
if ($this->_title!='')
|
|
{
|
|
$title = $this->escape($this->_title);
|
|
$out .= "<Title";
|
|
if ($this->_title_wrap=='yes') $out .= " wrap=\"yes\"";
|
|
$out .= ">".$title."</Title>\n";
|
|
}
|
|
if($this->_prompt != '') $out .= "<Prompt>{$prompt}</Prompt>\n";
|
|
$out .= "<URL>{$url}</URL>\n";
|
|
if($this->_parameter != '') $out .= "<Parameter>{$this->_parameter}</Parameter>\n";
|
|
$out .= "<Default>{$this->_default}</Default>\n";
|
|
foreach ($this->_entries as $entry) $out .= $entry->render();
|
|
foreach ($this->_softkeys as $softkey) $out .= $softkey->render();
|
|
$IconList=0;
|
|
foreach ($this->_icons as $icon)
|
|
{
|
|
if($IconList==0)
|
|
{
|
|
$out .= "<IconList>\n";
|
|
$IconList=1;
|
|
}
|
|
$out .= $icon->render();
|
|
}
|
|
if($IconList!=0) $out .= "</IconList>\n";
|
|
$out .= "</AastraIPPhoneInputScreen>\n";
|
|
return $out;
|
|
}
|
|
}
|
|
?>
|