/**
* TODO
*/
- public function getMenuInfo()
+ public function getMenus()
{
try {
- $vars = $this->_vars;
$shout = $GLOBALS['registry']->getApiInstance('shout', 'application');
$account = $_SESSION['shout']['curaccount'];
$menus = $shout->storage->getMenus($account);
- $menu = $vars->menu;
- if (!isset($menus[$menu])) {
- Horde::logMessage("User requested a menu that does not exist.", 'ERR');
- //$GLOBALS['notification']->push(_("That menu does not exist."), 'horde.error');
- // FIXME notifications
- return false;
+ foreach ($menus as $menu => $info) {
+ // Fill in the actions for each menu
+ $menus[$menu]['actions'] = $shout->dialplan->getMenuActions($account, $menu);
}
-
- $data['meta'] = $menus[$menu];
- $data['actions'] = $shout->dialplan->getMenuActions($account, $menu);
- return $data;
+ return $menus;
} catch (Exception $e) {
//FIXME: Create a way to notify the user of the failure.
die(var_dump($e));
$vars = $this->_vars;
$shout = $GLOBALS['registry']->getApiInstance('shout', 'application');
$account = $_SESSION['shout']['curaccount'];
- $actions = Shout::getMenuActions($contex, $menu);
+ $actions = Shout::getMenuActions();
return $actions;
} catch (Exception $e) {
//FIXME: Create a way to notify the user of the failure.
<div id="dialplan">
- <table id="menuInfo" class="striped">
- </table>
+ <div id="menuInfo">
+ <table class="striped">
+ <tr>
+ <td class="metaStatName">Menu</td>
+ <td class="metaStatInfo"><select id="menu.select" onchange="refreshMenu()"></select></td>
+ </tr>
+ <tr>
+ <td class="metaStatName">Description</td>
+ <td class="metaStatInfo" id="menu.description"></td>
+ </tr>
+ <tr>
+ <td class="metaStatName">Sound File</td>
+ <td class="metaStatInfo"><span id="menu.soundfile"></span></td>
+ </tr>
+ </table>
+ <br style="clear:both;">
+ <ul id="controls">
+ <?php
+ $addurl = Horde::applicationUrl('dialplan.php');
+ $addurl = Horde_Util::addParameter($addurl, 'action', 'add');
+
+ ?>
+ <li class="button"><a href="<?php echo $addurl; ?>">
+ <?php echo Horde::img('add-menu.png'); ?> New Menu
+ </a>
+ </li>
+ </ul>
+ </div>
<div id="digitpad">
<div id="editActionOverlay">
<script type="text/javascript">
<!--
var ajax_url = '<?php echo Horde::getServiceLink('ajax', 'shout') ?>';
-var menu = '<?php echo $menu['name']; ?>';
+var curmenu = null;
var menuInfo = $H();
var menuActions = $H(<?php echo Horde_Serialize::serialize(Shout::getMenuActions(), Horde_Serialize::JSON, Horde_Nls::getCharset()); ?>);
var destinations = $H(<?php echo Horde_Serialize::serialize($destinations, Horde_Serialize::JSON, Horde_Nls::getCharset()); ?>);
{
method: 'post',
parameters: $H({
- 'menu': menu
+ 'menu': curmenu
}),
onSuccess: function(r) {
menuInfo = $H(r.responseJSON.response);
function refreshMenu()
{
- var row;
- var col;
- var img;
- var text;
- empty('menuInfo');
-
- var meta = menuInfo.get('meta');
+ curmenu = $('menu.select').value;
+ if (!curmenu || !menuInfo.get(curmenu)) {
+ // TODO Show an error of some kind
+ return false;
+ }
- // Draw the menu metainfo box
- row = getMetaRow('<?php echo _("Menu Name"); ?>', meta.name);
- $('menuInfo').appendChild(row);
- row = getMetaRow('<?php echo _("Description"); ?>', meta.description);
- $('menuInfo').appendChild(row);
+ var text = document.createTextNode(menuInfo.get(curmenu).description);
+ empty('menu.description');
+ $('menu.description').appendChild(text);
- // Handle the soundfile row specially
- row = document.createElement('tr');
- col = document.createElement('td');
- col.className = 'menuStatName';
- text = document.createTextNode('<?php echo _("Sound file"); ?>');
- col.appendChild(text);
- row.appendChild(col);
- col = document.createElement('td');
- col.id = 'editSound';
- col.className='menuStatValue';
- text = document.createTextNode(meta.soundfile);
- col.appendChild(text);
- img = document.createElement('img');
- img.src = '<?php echo Horde_Themes::img('edit.png') ?>';
- img.alt = '<?php echo _("Change Sound File"); ?>';
- img.setAttribute('onclick', 'changeSoundFile()');
- col.appendChild(img);
- img = document.createElement('img');
- img.src = '<?php echo Horde_Themes::img('recordings.png') ?>';
- img.alt = '<?php echo _("Play Sound File"); ?>';
- img.setAttribute('onclick', 'playSoundFile()');
- img.setAttribute("style", img.getAttribute("style") + "; float:right; ");
- col.appendChild(img);
- row.appendChild(col);
- $('menuInfo').appendChild(row);
+ var text = document.createTextNode(menuInfo.get(curmenu).soundfile);
+ empty('menu.soundfile');
+ $('menu.soundfile').appendChild(text);
// Fill in the actions
$H(menuInfo.get('actions')).each(function (pair) {
}
$('editActionOverlay').hide();
-new Ajax.Request(ajax_url + 'getMenuInfo',
+new Ajax.Request(ajax_url + 'getMenus',
{
- method: 'post',
- parameters: $H({
- 'menu': menu
- }),
+ method: 'get',
onSuccess: function(r) {
menuInfo = $H(r.responseJSON.response);
+ menuInfo.each(function (item) {
+ var option = document.createElement('option');
+ option.value = item.key;
+ var text = document.createTextNode(item.value.name);
+ option.appendChild(text);
+ $('menu.select').appendChild(option);
+ })
refreshMenu();
}
});
+++ /dev/null
-<div class="header">
- Account: <?php echo $_SESSION['shout']['accounts'][$curaccount]; ?>
-</div>
-<?php
-$editurl = Horde::applicationUrl('dialplan.php');
-$editurl = Horde_Util::addParameter($editlink, 'action', 'edit');
-?>
-<div id="extensionList">
- <table width="100%" cellspacing="0" class="striped">
- <tr>
- <th width="15%" class="uheader">Menu Name</th>
- <th width="85%" class="uheader">Description</th>
- </tr>
- <?php foreach ($menus as $menu) {
- $url = Horde_Util::addParameter($editurl, 'menu', $menu['name']);
- ?>
- <tr>
- <td><?php echo Horde::link($url) . $menu['name'] . '</a>'; ?></td>
- <td><?php echo $menu['description']; ?></td>
- </tr>
- <?php } ?>
- </table>
-</div>
-<ul id="controls">
- <?php
- $addurl = Horde::applicationUrl('dialplan.php');
- $addurl = Horde_Util::addParameter($addurl, 'action', 'add');
-
- ?>
- <li class="button"><a href="<?php echo $addurl; ?>">
- <?php echo Horde::img('add-menu.png'); ?> New Menu
- </a>
- </li>
-</ul>
\ No newline at end of file