blob: 50f21e74f162d691b60ca542dbebe9650c2a2b89 [file] [log] [blame]
<?php
##
# Copyright 2013 by James Bottomley
##
# Base abstract class for building up XML actions
##
require_once('AastraAsterisk.class.php');
abstract class BaseAastra {
var $asm;
var $user;
var $url; /* without query strings */
var $fullurl;
var $title;
var $do = null;
var $back = null;
static final function exception_handler($e) {
require_once('AastraIPPhoneTextScreen.class.php');
$object=new AastraIPPhoneTextScreen();
$object->setDestroyOnExit();
$object->SetTitle("Error");
$object->SetText($e->getMessage());
$object->output();
}
function __construct() {
header('Content-type: text/xml');
set_exception_handler('BaseAastra::exception_handler');
$this->asm=new AGI_AsteriskManager();
$this->asm->connect();
$this->url = 'http';
if (isset($_SERVER['HTTPS'])) {$this->url .= 's';}
$this->url .= '://'.$_SERVER["SERVER_NAME"];
$pos = strpos($_SERVER["REQUEST_URI"], '?');
if ($pos !== false) {
$baseurl = substr($_SERVER['REQUEST_URI'], 0, $pos);
} else {
$baseurl = $_SERVER['REQUEST_URI'];
}
if ($_SERVER["SERVER_PORT"] != "80") {
$this->url .= ":".$_SERVER["SERVER_PORT"];
}
$this->fullurl = $this->url . $_SERVER['REQUEST_URI'];
$this->url .= $baseurl;
$this->user = $this->asm->get_user();
}
function init() {
if (isset($_GET['action'])) {
$this->$_GET['action']();
} else {
$this->start();
}
if (!$this->do) {
require_once('AastraIPPhoneExecute.class.php');
$this->do = new AastraIPPhoneExecute();
$this->do->addEntry('');
$this->do->setTriggerDestroyOnExit();
}
$this->do->output();
}
function yesno() {
$this->do->addSoftkey('1', 'Yes', $this->fullurl.'&yesno=yes');
$this->do->addSoftkey('2', 'No', $this->fullurl.'&yesno=no');
}
function displayObject($o) {
$this->do = $o;
$o->setTitle($this->title);
$o->setDestroyOnExit();
if($this->back) {
$o->setCancelAction($this->back);
}
}
abstract function start();
}