126 lines
4.1 KiB
PHP
126 lines
4.1 KiB
PHP
<?
|
|
|
|
########################################################################################################
|
|
# Aastra XML API Classes - AastraIPPhoneDirectory
|
|
# Copyright Aastra Telecom 2007
|
|
#
|
|
# AastraIPPhoneDirectory 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)
|
|
# 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)
|
|
# setRefresh(timeout,URL) to add Refresh parameters to the object (optional)
|
|
# generate() to return the object content
|
|
# output() to display the object
|
|
#
|
|
# Specific to the object
|
|
# setNext(next) to set URI of the next page (optional)
|
|
# setPrevious(previous) to set URI of the previous page (optional)
|
|
# addEntry(name,phone) to add an element in the list to be displayed, at least one is needed.
|
|
# natsortbyname() to order the list
|
|
#
|
|
# Example
|
|
# require_once('AastraIPPhoneDirectory.class.php');
|
|
# $directory = new AastraIPPhoneDirectory();
|
|
# $directory->setTitle('Title');
|
|
# $directory->setNext('http://myserver.com/script.php?page=2');
|
|
# $directory->setPrevious('http://myserver.com/script.php?page=0');
|
|
# $directory->setDestroyOnExit();
|
|
# $directory->addEntry('John Doe', '200');
|
|
# $directory->addEntry('Jane Doe', '201');
|
|
# $directory->natsortByName();
|
|
# $directory->addSoftkey('1', 'Label', 'http://myserver.com/script.php?action=1');
|
|
# $directory->addSoftkey('6', 'Exit', 'SoftKey:Exit');
|
|
# $directory->output();
|
|
#
|
|
########################################################################################################
|
|
|
|
require_once('AastraIPPhone.class.php');
|
|
require_once('AastraIPPhoneDirectoryEntry.class.php');
|
|
|
|
class AastraIPPhoneDirectory extends AastraIPPhone {
|
|
var $_next="";
|
|
var $_previous="";
|
|
|
|
function setNext($next)
|
|
{
|
|
$this->_next = $next;
|
|
}
|
|
|
|
function setPrevious($previous)
|
|
{
|
|
$this->_previous = $previous;
|
|
}
|
|
|
|
function addEntry($name, $telephone)
|
|
{
|
|
$this->_entries[] = new AastraIPPhoneDirectoryEntry($name, $telephone);
|
|
}
|
|
|
|
function natsortByName()
|
|
{
|
|
$tmpary = array();
|
|
foreach ($this->_entries as $id => $entry) {
|
|
$tmpary[$id] = $entry->getName();
|
|
}
|
|
natsort($tmpary);
|
|
foreach ($tmpary as $id => $name) {
|
|
$newele[] = $this->_entries[$id];
|
|
}
|
|
$this->_entries = $newele;
|
|
}
|
|
|
|
function render()
|
|
{
|
|
$out = '';
|
|
$out .= "<AastraIPPhoneDirectory";
|
|
if($this->_previous!="")
|
|
{
|
|
$previous = $this->escape($this->_previous);
|
|
|
|
$out .= " previous=\"$previous\"";
|
|
}
|
|
if($this->_next!="")
|
|
{
|
|
$next = $this->escape($this->_next);
|
|
$out .= " next=\"$next\"";
|
|
}
|
|
if($this->_destroyOnExit == 'yes') $out .= " destroyOnExit=\"yes\"";
|
|
if($this->_allowAnswer == 'yes') $out .= " allowAnswer=\"yes\"";
|
|
if($this->_cancelAction != "")
|
|
{
|
|
$cancelAction = $this->escape($this->_cancelAction);
|
|
$out .= " cancelAction=\"{$cancelAction}\"";
|
|
}
|
|
if($this->_beep=='yes') $out .= " Beep=\"yes\"";
|
|
if($this->_lockin=='yes') $out .= " LockIn=\"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";
|
|
}
|
|
$index=0;
|
|
foreach ($this->_entries as $entry) {
|
|
if($index<15) $out .= $entry->render();
|
|
$index++;
|
|
}
|
|
foreach ($this->_softkeys as $softkey) $out .= $softkey->render();
|
|
$out .= "</AastraIPPhoneDirectory>\n";
|
|
return $out;
|
|
}
|
|
}
|
|
?>
|