<!DOCTYPE webproject>
<webproject>
- <project usePreviewPrefix="0" type="Local" previewPrefix="" usePersistentBookmarks="0" name="Shout" encoding="iso 8859-1" enableEvents="true" >
+ <project usePreviewPrefix="0" previewPrefix="" type="Local" usePersistentBookmarks="0" name="Shout" encoding="iso 8859-1" enableEvents="true" >
<upload/>
<defaultDTD>-//w3c//dtd xhtml 1.0 strict//en</defaultDTD>
<item url="config/" uploadstatus="1" />
<item url="lib/Driver/" uploadstatus="1" />
<item modified_time="1131765770" url="lib/Driver/ldap.php" uploadstatus="1" />
<item modified_time="1131497449" url="lib/base.php" uploadstatus="1" />
- <item modified_time="1131786947" url="lib/Dialplan.php" uploadstatus="1" />
+ <item modified_time="1131851216" url="lib/Dialplan.php" uploadstatus="1" />
<item modified_time="1130769960" url="lib/Driver.php" uploadstatus="1" />
- <item modified_time="1131789833" url="lib/Shout.php" uploadstatus="1" />
+ <item modified_time="1131826057" url="lib/Shout.php" uploadstatus="1" />
<item modified_time="1121689003" url="lib/System.php" uploadstatus="1" />
<item modified_time="1130769961" url="lib/User.php" uploadstatus="1" />
<item url="main/" uploadstatus="1" />
<uploadeditem upload_time="1130769960" url="dialplan/edit.php" />
<uploadeditem upload_time="1131593241" url="index.php" />
<uploadeditem upload_time="0" url="lib/" />
- <uploadeditem upload_time="1131786947" url="lib/Dialplan.php" />
+ <uploadeditem upload_time="1131851216" url="lib/Dialplan.php" />
<uploadeditem upload_time="1130769960" url="lib/Driver.php" />
<uploadeditem upload_time="0" url="lib/Driver/" />
<uploadeditem upload_time="1131765770" url="lib/Driver/ldap.php" />
- <uploadeditem upload_time="1131789833" url="lib/Shout.php" />
+ <uploadeditem upload_time="1131826057" url="lib/Shout.php" />
<uploadeditem upload_time="1121689003" url="lib/System.php" />
<uploadeditem upload_time="1130769961" url="lib/User.php" />
<uploadeditem upload_time="1131600576" url="lib/api.php" />
<uploadeditem upload_time="1121689030" url="templates/dialplan/priority-form-end.inc" />
<uploadeditem upload_time="1121689030" url="templates/dialplan/priority-form-line.inc" />
<uploadeditem upload_time="0" url="templates/javascript/" />
- <uploadeditem upload_time="1131790763" url="templates/javascript/dialplan.js" />
+ <uploadeditem upload_time="1131864070" url="templates/javascript/dialplan.js" />
<uploadeditem upload_time="1131772201" url="templates/menu.inc" />
<uploadeditem upload_time="1121578596" url="templates/table-limiter-begin.inc" />
<uploadeditem upload_time="1121578596" url="templates/table-limiter-end.inc" />
</teamdata>
<events/>
<item modified_time="1131045729" url="lib/defines.php" uploadstatus="1" />
- <item modified_time="1131767776" url="templates/dialplan/extensiondetail.inc" uploadstatus="1" />
<item modified_time="1131497712" url="security.php" uploadstatus="1" />
<item url="templates/javascript/" uploadstatus="1" />
- <item modified_time="1131790763" url="templates/javascript/dialplan.js" uploadstatus="1" />
+ <item modified_time="1131864070" url="templates/javascript/dialplan.js" uploadstatus="1" />
<item modified_time="1131784175" url="templates/dialplan/manager.inc" uploadstatus="1" />
<treestatus>
<openfolder url="lib" />
function generateAppList()
{
- # $applist = Shout::getApplist();
+ $applist = Shout::getApplist();
print '<script language="JavaScript" type="text/javascript">'."\n";
print '<!--'."\n";
print 'var shout_dialplan_applist_'.$this->_instance.' = new Array();'."\n";
$i = 0;
- $app = "APPLICATION";
- # foreach ($applist as $app) {
+ foreach ($applist as $app => $appdata) {
print 'shout_dialplan_applist_'.$this->_instance.'['.$i.'] = \''.$app.'\''."\n";
- # }
+ $i++;
+ }
print '//-->'."\n";
print '</script>'."\n";
return true;
print '//-->'."\n";
print '</script>'."\n";
+ print '<form id="shout_dialplan_'.$this->_instance.'">'."\n";
print '<div id="extensionDetail">'."\n";
$e = 0;
foreach($this->_dialplan['extensions'] as $extension => $priorities) {
print '<div class="extension" ';
print 'id="extension_'.$extension.'" ';
- print '<a name="'.$extension.'" />'."\n";
- print '<div class="extensionBox" ';
- print 'id="eBox-'.$extension.'" ';
- print 'onclick="javascript:shout_dialplan_object_'.$this->_instance.'.highlightExten';
- print '(\''.$extension.'\');">'."\n";
+ print '<div class="extensionBox" ';
+ print 'id="eBox-'.$extension.'" ';
+ print 'onclick="javascript:shout_dialplan_object_'.$this->_instance.'.highlightExten';
+ print '(\''.$extension.'\');">'."\n";
+ print '<a name="'.$extension.'">'."\n";
print Shout::exten2name($extension);
- print '</div>'."\n";
+ print '</a>'."\n";
+ print '</div>'."\n";
print '<div id="pList-'.$extension.'">'."\n";
print '</div>'."\n";
$e++;
print '</script>'."\n";
}
print '</div>'."\n";
+ print '</form>'."\n";
}
}
}
\ No newline at end of file
// {{{ Class Shout
class Shout
{
+ var $applist = array();
+ var $_applist_curapp = '';
+ var $_applist_curfield = '';
// {{{ getMenu method
/**
}
}
- function xml2applist()
+ function getApplist()
{
+ if (isset($_SESSION['shout']['applist'])) {
+ return $_SESSION['shout']['applist'];
+ }
+
$file = SHOUT_BASE . '/config/applist.xml';
$xml_parser = xml_parser_create();
$ShoutObject = new Shout;
xml_set_element_handler($xml_parser,
- array($ShoutObject, '_xml2applist_startElement'),
- array($ShoutObject, '_xml2applist_startElement'));
+ array(&$ShoutObject, '_xml2applist_startElement'),
+ array(&$ShoutObject, '_xml2applist_startElement'));
xml_set_character_data_handler($xml_parser,
- array($ShoutObject, '_xml2applist_characterData'));
+ array(&$ShoutObject, '_xml2applist_characterData'));
if (!$fp = fopen($file, 'r')) {
return PEAR::raiseError('Unable to open applist.xml for reading');
xml_get_current_line_number($xml_parser)));
}
}
+ ksort($ShoutObject->applist);
xml_parser_free($xml_parser);
+ $_SESSION['shout']['applist'] = $ShoutObject->applist;
+ unset($ShoutObject);
+ return $_SESSION['shout']['applist'];
}
function _xml2applist_startElement($parser, $name, $attrs = array())
{
- print "Name: $name<br />\n";
- print_r($attrs);
- print "<br />\n";
- print "<br />\n";
+ if (count($attrs) > 1) { print_r($attrs); }
+ switch($name) {
+ case 'APPLICATION':
+ if (isset($attrs['NAME'])) {
+ $this->_applist_curapp = $attrs['NAME'];
+ if (!isset($this->applist[$name])) {
+ $this->applist[$this->_applist_curapp] = array();
+ }
+ $this->_applist_curfield = '';
+ }
+ break;
+ case 'SYNOPSIS':
+ case 'USAGE':
+ $this->_applist_curfield = $name;
+ if (!isset($this->applist[$name])) {
+ $this->applist[$this->_applist_curapp][$name] = "";
+ }
+ break;
+ }
}
function _xml2applist_endElement($parser, $name)
{
- echo '';
+ print ''; #NOOP
}
function _xml2applist_characterData($parser, $string)
{
- print "Data: $string<br />\n";
+ $string = preg_replace('/^\s+/', '', $string);
+ $string = preg_replace('/\s+$/', '', $string);
+ if (strlen($string) > 1) {
+ $field = $this->_applist_curfield;
+ $app = $this->_applist_curapp;
+ $this->applist[$app][$field] .= "$string ";
+ }
}
}
// }}}
\ No newline at end of file
this.curPrio = prio;
document.getElementById('priority-'+exten+'-'+prio).className = 'priorityHighlight';
document.getElementById('pButtons-'+exten+'-'+prio).style['visibility'] = 'visible';
- // document.getElementById('pButtons-'+exten+'-'+prio).className = 'pButtonsHighlight';
- // document.getElementById('pNumber-'+exten+'-'+prio).className = 'pElementHighlight';
- // document.getElementById('pApp-'+exten+'-'+prio).className = 'pElementHighlight';
- // document.getElementById('pArgs-'+exten+'-'+prio).className = 'pElementHighlight';
+
} else {
var form = '';
//form += '<form id="renumber">';
if (this.curPrio && document.getElementById('pButtons-'+this.curExten+'-'+this.curPrio)) {
document.getElementById('priority-'+this.curExten+'-'+this.curPrio).className = 'priority';
document.getElementById('pButtons-'+this.curExten+'-'+this.curPrio).style['visibility'] = 'hidden';
-// document.getElementById('pButtons-'+this.curExten+'-'+this.curPrio).className = 'pButtons';
-// document.getElementById('pNumber-'+this.curExten+'-'+this.curPrio).className = 'pElement';
-// document.getElementById('pApp-'+this.curExten+'-'+this.curPrio).className = 'pElement';
-// document.getElementById('pArgs-'+this.curExten+'-'+this.curPrio).className = 'pElement';
}
}
alert('Must first choose an extension to draw');
return false;
}
- //alert(document.getElementById('pList-'+exten).innerHTML);
for (var p in this.dp[exten]['priorities']) {
table += '<div class="priority" id="priority-'+exten+'-'+p+'">\n';
table += ' <span class="pButtons" id="pButtons-'+exten+'-'+p+'"\n';
table += ' <span class="pElement" id="pApp-'+exten+'-'+p+'"\n';
table += ' name="pApp-'+exten+'-'+p+'">\n';
table += ' <span class="applicationBox"></span>\n';
- table += ' <select name="app['+exten+']['+p+']">\n';;
+ table += ' <select name="app['+exten+']['+p+']">\n';
table += this.genAppList(this.dp[exten]['priorities'][p]['application']);
table += ' </select>\n';
table += ' </span>\n';
table += ' <span class="pElement" id="pArgs-'+exten+'-'+p+'"\n';
table += ' name="pArgs-'+exten+'-'+p+'">\n';
table += ' <span class="argBox" id="args-'+exten+'-'+p+'"\n';
- table += ' name="args-'+exten+'-'+p+'">ARGS</span>\n';
+ table += ' name="args-'+exten+'-'+p+'">';
+ table += this.dp[exten]['priorities'][p]['args']+'</span>\n';
table += ' </span>\n';
table += '</div>\n';
}
- //alert(table);
document.getElementById('pList-'+exten).innerHTML = table;
}
Dialplan.prototype.genAppList = function (app)
{
- applist = '<option value="APPLICATION">APPLICATION</option>\n';
- return applist;
+ var appstring = '';
+ for (var a in this.applist) {
+ appstring += '<option value="'+this.applist[a]+'"';
+ if (this.applist[a] == app) {
+ appstring += ' selected';
+ }
+ appstring += '>'+this.applist[a]+'</option>\n';
+ }
+ return appstring;
}
Dialplan.prototype.addExten = function (exten, extenName)
{
prio = Number(prio);
if (this.dp[exten]['priorities'][prio] != 'undefined') {
- this._incrPrio(exten, prio);
+ // Due to javascript's inability to remove an array element while maintaining
+ // associations, we copy the elements into a tmp array and ultimately replace
+ // the object's copy. We will also have to sort the resulting array manually
+ // so it renders correctly.
+ var tmp = new Array();
+ var plist = new Array();
+ var i = 0;
+ var p;
+
+ for (p in this.dp[exten]['priorities']) {
+ p = Number(p);
+ prio = Number(prio);
+ // Make a notch for the new priority by incrementing all priorities greater
+ // than the requested one. Try to exclude error handling priorities
+ // which are unrelated to the changed extension. See README for
+ // more information.
+ // TODO: Make a decision about whether this is the best way to handle
+ // error handling priorities.
+ if (p > prio && (p < prio + 90 || p > prio + 100)) {
+ tmp[p + 1] = this.dp[exten]['priorities'][p];
+ plist[i] = p + 1;
+ } else {
+ tmp[p] = this.dp[exten]['priorities'][p];
+ plist[i] = p;
+ }
+ i++;
+ }
+
+ // Seed the new priority
+ var newP = Number(prio) + 1;
+ tmp[newP] = new Array();
+ tmp[newP]['application'] = '';
+ tmp[newP]['args'] = '';
+ plist[i] = newP;
+
+
+ // Empty the original array
+ this.dp[exten]['priorities'] = new Array();
+
+ // Sort the priorities and put them back into the original array
+ plist.sort(this._numCompare);
+ for (i = 0; i < plist.length; i++) {
+
+ p = Number(plist[i]);
+ this.dp[exten]['priorities'][p] = tmp[p];
+ }
+ }
+ this.curPrio = 0;
+ this.drawPrioTable(exten);
+}
+
+Dialplan.prototype.delPrio = function(exten, prio)
+{
+ prio = Number(prio);
+ if (this.dp[exten]['priorities'][prio] != 'undefined') {
+ // Due to javascript's inability to remove an array element while maintaining
+ // associations, we copy the elements into a tmp array and ultimately replace
+ // the object's copy. We will also have to sort the resulting array manually
+ // so it renders correctly.
+ var tmp = new Array();
+ var plist = new Array();
+ var i = 0;
+ var p;
+
+ for (p in this.dp[exten]['priorities']) {
+ // Notch out the old priority by decrementing all priorities greater
+ // than the requested one. Try to exclude error handling priorities
+ // which are unrelated to the changed extension. See README for
+ // more information.
+ // TODO: Make a decision about whether this is the best way to handle
+ // error handling priorities.
+ p = Number(p);
+ if (p != prio) {
+ if (p > prio && (p < prio + 90 || p > prio + 100)) {
+ p = Number(p) - 1;
+ }
+ tmp[p] = this.dp[exten]['priorities'][p];
+ plist[i++] = p;
+ }
+ }
+
+ // Empty the original array
+ this.dp[exten]['priorities'] = new Array();
+
+ // Sort the priorities and put them back into the original array
+ plist.sort(this._numCompare);
+ for (i = 0; i < plist.length; i++) {
+ p = Number(plist[i]);
+ this.dp[exten]['priorities'][p] = tmp[p];
+ }
}
- this.dp[exten]['priorities'][prio] = new Array();
this.curPrio = 0;
this.drawPrioTable(exten);
}
Dialplan.prototype._incrPrio = function (exten, prio)
{
- // Due to javascript's inability to remove an array element while maintaining
- // associations, we copy the elements into a tmp array and ultimately replace
- // the object's copy. We will also have to sort the resulting array manually
- // so it renders correctly.
- var tmp = new Array();
- var plist = new Array();
- var i = 0;
- var p;
-
- for (p in this.dp[exten]['priorities']) {
- p = Number(p);
- prio = Number(prio);
- // Make a notch for the new priority by incrementing all priorities greater
- // than the requested one. Try to exclude error handling priorities
- // which are unrelated to the changed extension. See README for
- // more information.
- if (p > prio && (p < 101 || p > prio + 100)) {
- tmp[p + 1] = this.dp[exten]['priorities'][p];
- plist[i] = p + 1;
- } else {
- tmp[p] = this.dp[exten]['priorities'][p];
- plist[i] = p;
- }
- i++;
- }
- // Seed the new priority
- prio = Number(prio) + 1;
- tmp[prio] = new Array();
- tmp[prio]['application'] = '';
- tmp[prio]['args'] = '';
- plist[i] = prio;
-
- // Empty the original array
- this.dp[exten]['priorities'] = new Array();
-
- // Sort the priorities and put them back into the original array
- plist.sort(this._numCompare);
- for (i = 0; i < plist.length; i++) {
- p = Number(plist[i]);
- this.dp[exten]['priorities'][p] = tmp[p];
- }
+
return true;
}
\ No newline at end of file