Reworking dialplan management to be more responive. Heavy use of javascript
authorBen Klang <ben@alkaloid.net>
Tue, 8 Nov 2005 06:12:56 +0000 (06:12 +0000)
committerBen Klang <ben@alkaloid.net>
Tue, 8 Nov 2005 06:12:56 +0000 (06:12 +0000)
and DHTML should make this feel much nicer.

git-svn-id: https://svn.alkaloid.net/gpl/shout/trunk@83 06cd67b6-e706-0410-b29e-9de616bca6e9

andrew.webprj
index.php
lib/Driver/ldap.php
lib/Shout.php
main/dialplan.php
templates/dialplan/contexttree.inc
templates/dialplan/dialplanlist.inc
templates/dialplan/extensiondetail.inc
templates/menu.inc
templates/users/userlist.inc
themes/screen.css

index c627baf..fdd45f6 100644 (file)
@@ -6,48 +6,48 @@
     <item url="config/" uploadstatus="1" />
     <item modified_time="1120073766" url="config/conf.xml" uploadstatus="1" />
     <item url="dialplan/" uploadstatus="1" />
-    <item modified_time="1130769960" url="dialplan/edit.php" uploadstatus="1" />
+    <item modified_time="1130716381" url="dialplan/edit.php" uploadstatus="1" />
     <item url="lib/" uploadstatus="1" />
     <item url="lib/Driver/" uploadstatus="1" />
-    <item modified_time="1131046511" url="lib/Driver/ldap.php" uploadstatus="1" />
-    <item modified_time="1130769961" url="lib/base.php" uploadstatus="1" />
+    <item modified_time="1131310877" url="lib/Driver/ldap.php" uploadstatus="1" />
+    <item modified_time="1130704853" url="lib/base.php" uploadstatus="1" />
     <item modified_time="1121689003" url="lib/Dialplan.php" uploadstatus="1" />
-    <item modified_time="1130769960" url="lib/Driver.php" uploadstatus="1" />
-    <item modified_time="1130769961" url="lib/Shout.php" uploadstatus="1" />
+    <item modified_time="1130762080" url="lib/Driver.php" uploadstatus="1" />
+    <item modified_time="1131265696" 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 modified_time="1130724077" url="lib/User.php" uploadstatus="1" />
     <item url="main/" uploadstatus="1" />
-    <item modified_time="1131050319" url="main/dialplan.php" uploadstatus="1" />
+    <item modified_time="1131267622" url="main/dialplan.php" uploadstatus="1" />
     <item modified_time="1121401845" url="main/moh.php" uploadstatus="1" />
-    <item modified_time="1130769962" url="main/system.php" uploadstatus="1" />
+    <item modified_time="1130716385" url="main/system.php" uploadstatus="1" />
     <item modified_time="1121689003" url="main/users.php" uploadstatus="1" />
     <item url="templates/" uploadstatus="1" />
     <item url="templates/context/" uploadstatus="1" />
     <item modified_time="1120175005" url="templates/context/contextline.inc" uploadstatus="1" />
     <item url="templates/dialplan/" uploadstatus="1" />
-    <item modified_time="1121581526" url="templates/dialplan/dialplanlist.inc" uploadstatus="1" />
+    <item modified_time="1131256680" url="templates/dialplan/dialplanlist.inc" uploadstatus="1" />
     <item modified_time="1121689030" url="templates/dialplan/priority-form-begin.inc" uploadstatus="1" />
     <item modified_time="1121689030" url="templates/dialplan/priority-form-end.inc" uploadstatus="1" />
     <item modified_time="1121689030" url="templates/dialplan/priority-form-line.inc" uploadstatus="1" />
     <item url="templates/users/" uploadstatus="1" />
-    <item modified_time="1121581536" url="templates/users/userlist.inc" uploadstatus="1" />
-    <item modified_time="1120174958" url="templates/common-header.inc" uploadstatus="1" />
+    <item modified_time="1131254217" url="templates/users/userlist.inc" uploadstatus="1" />
+    <item modified_time="1131253175" url="templates/common-header.inc" uploadstatus="1" />
     <item modified_time="1120073766" url="templates/content_page" uploadstatus="1" />
-    <item modified_time="1130864369" url="templates/menu.inc" uploadstatus="1" />
+    <item modified_time="1131408261" url="templates/menu.inc" uploadstatus="1" />
     <item modified_time="1121578596" url="templates/table-limiter-begin.inc" uploadstatus="1" />
     <item modified_time="1121578596" url="templates/table-limiter-end.inc" uploadstatus="1" />
     <item url="themes/" uploadstatus="1" />
     <item url="themes/graphics/" uploadstatus="1" />
     <item modified_time="1121581526" url="themes/graphics/add-extension.gif" uploadstatus="1" />
-    <item modified_time="1130861777" url="themes/graphics/add-user.gif" uploadstatus="1" />
-    <item modified_time="1131050251" url="themes/screen.css" uploadstatus="1" />
+    <item modified_time="1131068895" url="themes/graphics/add-user.gif" uploadstatus="1" />
+    <item modified_time="1131430274" url="themes/screen.css" uploadstatus="1" />
     <item url="users/" uploadstatus="1" />
     <item modified_time="1122704539" url="users/add.php" uploadstatus="1" />
     <item modified_time="1122704539" url="users/delete.php" uploadstatus="1" />
-    <item modified_time="1130769962" url="users/edit.php" uploadstatus="1" />
-    <item modified_time="1130769962" url="users/save.php" uploadstatus="1" />
-    <item modified_time="1131044239" url="dialplan.php" uploadstatus="1" />
-    <item modified_time="1129871121" url="index.php" uploadstatus="1" />
+    <item modified_time="1130716394" url="users/edit.php" uploadstatus="1" />
+    <item modified_time="1130724223" url="users/save.php" uploadstatus="1" />
+    <item modified_time="1131068894" url="dialplan.php" uploadstatus="1" />
+    <item modified_time="1131254692" url="index.php" uploadstatus="1" />
     <item modified_time="1122704475" url="users.php" uploadstatus="1" />
     <item url="" uploadstatus="1" />
     <uploadprofiles showtreeviews="true" defaultProfile="Shout" >
       <profile remote_host="picasso.v-office.biz" remote_port="22" remote_path="/srv/vhost/users/alkaloid/sites/intranet.v-office.biz/shout" remote_protocol="sftp" user="alkaloid" name="Shout" >
         <uploadeditem upload_time="0" url="config/" />
         <uploadeditem upload_time="1120073766" url="config/conf.xml" />
-        <uploadeditem upload_time="1131044239" url="dialplan.php" />
+        <uploadeditem upload_time="1131068894" url="dialplan.php" />
         <uploadeditem upload_time="0" url="dialplan/" />
-        <uploadeditem upload_time="1130769960" url="dialplan/edit.php" />
-        <uploadeditem upload_time="1129871121" url="index.php" />
+        <uploadeditem upload_time="1130716381" url="dialplan/edit.php" />
+        <uploadeditem upload_time="1131254692" url="index.php" />
         <uploadeditem upload_time="0" url="lib/" />
         <uploadeditem upload_time="1121689003" url="lib/Dialplan.php" />
-        <uploadeditem upload_time="1130769960" url="lib/Driver.php" />
+        <uploadeditem upload_time="1130762080" url="lib/Driver.php" />
         <uploadeditem upload_time="0" url="lib/Driver/" />
-        <uploadeditem upload_time="1131046511" url="lib/Driver/ldap.php" />
-        <uploadeditem upload_time="1130769961" url="lib/Shout.php" />
+        <uploadeditem upload_time="1131310877" url="lib/Driver/ldap.php" />
+        <uploadeditem upload_time="1131265696" url="lib/Shout.php" />
         <uploadeditem upload_time="1121689003" url="lib/System.php" />
-        <uploadeditem upload_time="1130769961" url="lib/User.php" />
-        <uploadeditem upload_time="1130862539" url="lib/api.php" />
-        <uploadeditem upload_time="1130769961" url="lib/base.php" />
-        <uploadeditem upload_time="1131045729" url="lib/defines.php" />
+        <uploadeditem upload_time="1130724077" url="lib/User.php" />
+        <uploadeditem upload_time="1131068895" url="lib/api.php" />
+        <uploadeditem upload_time="1130704853" url="lib/base.php" />
+        <uploadeditem upload_time="1131068895" url="lib/defines.php" />
         <uploadeditem upload_time="0" url="main/" />
-        <uploadeditem upload_time="1131050319" url="main/dialplan.php" />
+        <uploadeditem upload_time="1131267622" url="main/dialplan.php" />
         <uploadeditem upload_time="1121401845" url="main/moh.php" />
-        <uploadeditem upload_time="1130769962" url="main/system.php" />
+        <uploadeditem upload_time="1130716385" url="main/system.php" />
         <uploadeditem upload_time="1121689003" url="main/users.php" />
         <uploadeditem upload_time="0" url="templates/" />
-        <uploadeditem upload_time="1120174958" url="templates/common-header.inc" />
+        <uploadeditem upload_time="1131253200" url="templates/common-footer.inc" />
+        <uploadeditem upload_time="1131253175" url="templates/common-header.inc" />
         <uploadeditem upload_time="1120073766" url="templates/content_page" />
         <uploadeditem upload_time="0" url="templates/context/" />
         <uploadeditem upload_time="1120175005" url="templates/context/contextline.inc" />
         <uploadeditem upload_time="0" url="templates/dialplan/" />
-        <uploadeditem upload_time="1131050005" url="templates/dialplan/contexttree.inc" />
-        <uploadeditem upload_time="1121581526" url="templates/dialplan/dialplanlist.inc" />
-        <uploadeditem upload_time="1131050271" url="templates/dialplan/extensiondetail.inc" />
+        <uploadeditem upload_time="1131429808" url="templates/dialplan/contexttree.inc" />
+        <uploadeditem upload_time="1131256680" url="templates/dialplan/dialplanlist.inc" />
+        <uploadeditem upload_time="1131430269" url="templates/dialplan/extensiondetail.inc" />
         <uploadeditem upload_time="1121689030" url="templates/dialplan/priority-form-begin.inc" />
         <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="1130864369" url="templates/menu.inc" />
+        <uploadeditem upload_time="1131408261" url="templates/menu.inc" />
         <uploadeditem upload_time="1121578596" url="templates/table-limiter-begin.inc" />
         <uploadeditem upload_time="1121578596" url="templates/table-limiter-end.inc" />
         <uploadeditem upload_time="0" url="templates/users/" />
-        <uploadeditem upload_time="1121581536" url="templates/users/userlist.inc" />
+        <uploadeditem upload_time="1131254217" url="templates/users/userlist.inc" />
         <uploadeditem upload_time="0" url="themes/" />
         <uploadeditem upload_time="0" url="themes/graphics/" />
         <uploadeditem upload_time="1121581526" url="themes/graphics/add-extension.gif" />
-        <uploadeditem upload_time="1130861777" url="themes/graphics/add-user.gif" />
-        <uploadeditem upload_time="1131050251" url="themes/screen.css" />
+        <uploadeditem upload_time="1131068895" url="themes/graphics/add-user.gif" />
+        <uploadeditem upload_time="1131430274" url="themes/screen.css" />
         <uploadeditem upload_time="1122704475" url="users.php" />
         <uploadeditem upload_time="0" url="users/" />
         <uploadeditem upload_time="1122704539" url="users/add.php" />
         <uploadeditem upload_time="1122704539" url="users/delete.php" />
-        <uploadeditem upload_time="1130769962" url="users/edit.php" />
-        <uploadeditem upload_time="1130769962" url="users/save.php" />
+        <uploadeditem upload_time="1130716394" url="users/edit.php" />
+        <uploadeditem upload_time="1130724223" url="users/save.php" />
       </profile>
     </uploadprofiles>
     <templates>templates/</templates>
     <toolbars>toolbars/</toolbars>
-    <item modified_time="1130862539" url="lib/api.php" uploadstatus="1" />
+    <item modified_time="1131068895" url="lib/api.php" uploadstatus="1" />
     <author>Ben Klang</author>
     <email>ben@alkaloid.net</email>
     <debuggerclient>No Debugger</debuggerclient>
       <mailinglist address="" />
     </teamdata>
     <events/>
-    <item modified_time="1131045729" url="lib/defines.php" uploadstatus="1" />
-    <item modified_time="1131050005" url="templates/dialplan/contexttree.inc" />
-    <item modified_time="1131050271" url="templates/dialplan/extensiondetail.inc" />
+    <item modified_time="1131068895" url="lib/defines.php" uploadstatus="1" />
+    <item modified_time="1131429808" url="templates/dialplan/contexttree.inc" uploadstatus="1" />
+    <item modified_time="1131430269" url="templates/dialplan/extensiondetail.inc" uploadstatus="1" />
+    <item modified_time="1131253200" url="templates/common-footer.inc" uploadstatus="1" />
     <treestatus>
       <openfolder url="config" />
       <openfolder url="dialplan" />
       <openfolder url="main" />
       <openfolder url="templates" />
       <openfolder url="templates/dialplan" />
+      <openfolder url="templates/users" />
       <openfolder url="themes" />
       <openfolder url="users" />
     </treestatus>
index 896c7c4..8d29eae 100644 (file)
--- a/index.php
+++ b/index.php
@@ -49,11 +49,9 @@ if (!$section) {
 require SHOUT_TEMPLATES . '/common-header.inc';
 require SHOUT_TEMPLATES . '/menu.inc';
 
-
-echo "<br />";
 // if (!$section) {
 //     $section =
-
+print '<div style="width:95%;left:10px;position:relative">';
 echo $tabs->render($section);
 switch ($section) {
     case "conference":
@@ -77,9 +75,12 @@ switch ($section) {
 
     default:
         require SHOUT_TEMPLATES . '/common-footer.inc';
+        require $registry->get('templates', 'horde') . '/common-footer.inc';
         exit();
         break;
 }
 
 require "main/$section.php";
+print '</div>';
+require SHOUT_TEMPLATES . '/common-footer.inc';
 require $registry->get('templates', 'horde') . '/common-footer.inc';
\ No newline at end of file
index 362df8f..b2c9168 100644 (file)
@@ -313,11 +313,15 @@ for $context"));
      *
      * @param string $context Context to return extensions for
      *
+     * @param boolean $preprocess Parse includes and barelines and add their
+     *                            information into the extensions array
+     *
      * @return array Multi-dimensional associative array of extensions data
      *
      */
-    function &getDialplan($context)
+    function &getDialplan($context, $preprocess = false)
     {
+        # FIXME Implement preprocess functionality.  Don't forget to cache!
         static $dialplans = array();
         if (isset($dialplans[$context])) {
             return $dialplans[$context];
@@ -349,26 +353,30 @@ for $context"));
                     if (strlen($line) < 5) {
                         break;
                     }
-                    # Can't use strtok here because there may be ','s in the arg
-                    # string
+                    # Can't use strtok here because there may be commass in the
+                    # arg string
 
                     # Get the extension
                     $token1 = strpos($line, ',');
                     $token2 = strpos($line, ',', $token1 + 1);
+                    $token3 = strpos($line, '(', $token2 + 1);
 
                     $extension = substr($line, 0, $token1);
-                    if (!isset($dialplans[$context][$extension])) {
-                        $dialplan[$context][$extension] = array();
+                    if (!isset($dialplans[$context]['extensions'][$extension])) {
+                        $dialplan[$context]['extensions'][$extension] = array();
                     }
                     $token1++;
                     # Get the priority
                     $priority = substr($line, $token1, $token2 - $token1);
-                    $dialplans[$context][$extension][$priority] = array();
+                    $dialplans[$context]['extensions'][$extension][$priority] =
+                        array();
                     $token2++;
 
                     # Get Application and args
                     $application = substr($line, $token2);
 
+                    #$args = strpos($)
+
                     # Merge all that data into the returning array
                     $dialplans[$context]['extensions'][$extension][$priority] =
                         $application;
@@ -380,7 +388,8 @@ for $context"));
                     $extension => $data) {
                     ksort($dialplans[$context]['extensions'][$extension]);
                 }
-                ksort($dialplans[$context]['extensions']);
+                uksort($dialplans[$context]['extensions'],
+                    array(new Shout, "extensort"));
             }
             # Handle include lines
             if (isset($res[$i]['asteriskincludeline'])) {
@@ -764,6 +773,16 @@ for $context"));
     }
     // }}}
 
+
+    /* Needed because uksort can't take a classed function as its callback arg */
+    function _sortexten($e1, $e2)
+    {
+        print "$e1 and $e2\n";
+        $ret =  Shout::extensort($e1, $e2);
+        print "returning $ret";
+        return $ret;
+    }
+
     // {{{ connect method
     /**
      * Attempts to open a connection to the LDAP server.
index 26cfdd0..fe927ba 100644 (file)
@@ -223,5 +223,104 @@ class Shout
         return $array[$int];
     }
 
+    /**
+     * Convert Asterisk's special extensions to friendly names
+     *
+     * @param string $extension  Extension to search for friendly name.
+     */
+    function exten2name($exten)
+    {
+        # Cast as a string to avoid misinterpreted digits
+        switch((string)$exten) {
+        case 'i':
+            $nodetext = 'Invalid Handler';
+            break;
+        case 's':
+            $nodetext = 'Entry Point';
+            break;
+        case 't':
+            $nodetext = 'Timeout Handler';
+            break;
+        case 'o':
+            $nodetext = 'Operator';
+            break;
+        case 'h':
+            $nodetext = 'Hangup Handler';
+            break;
+        case 'fax':
+            $nodetext = 'FAX Detection';
+            break;
+        default:
+            $nodetext = "Extension $exten";
+            break;
+        }
+
+        return $nodetext;
+    }
+
+    /**
+     * Compare two inputs as extensions and return them in the following order:
+     * 's', numbers (low to high), single chars, multi-chars
+     * 's' comes first because in Asterisk it is commonly the 'starting' exten.
+     * This function is expected to be used with uksort()
+     *
+     * @param string $e1
+     *
+     * @param string $e2
+     *
+     * @return int Relation of $e1 to $e2
+     */
+    function extensort($e1, $e2)
+    {
+        # Assumptions: We don't have to deal with negative numbers.  If we do
+        # they'll sort as strings
+        $e1 = (string)$e1;
+        $e2 = (string)$e2;
+        # Try to return quickly if either extension is 's'
+        if ($e1 == 's' || $e2 == 's') {
+            if ($e1 == $e2) {
+                # They are both s?
+                # FIXME Should we warn here?  Or assume the rest of the app
+                # is smart enough to handle this condition?
+                return 0;
+            }
+
+            return ($e1 == 's') ? -1 : 1;
+        }
+
+        # Next check for numeric extensions
+        if (preg_match('/^[*#0-9]+$/', $e1)) {
+            # e1 is a numeric extension
+            if (preg_match('/^[*#0-9]+$/', $e2)) {
+                # e2 is also numeric
+                if (strlen($e1) == 1 || strlen($e2) == 1) {
+                    if (strlen($e1) == strlen($e2)) {
+                        # Both are 1 digit long
+                        return ($e1 < $e2) ? -1 : 1;
+                    } else {
+                        return (strlen($e1) == 1) ? -1 : 1;
+                    }
+                }
+                return ($e1 < $e2) ? -1 : 1;
+            } else {
+                # e2 is not a numeric extension so it must sort after e1
+                return -1;
+            }
+        } elseif (preg_match('/^[*#0-9]+$/', $e2)) {
+            # e2 is numeric but e1 is not.  e2 must sort before e1
+            return 1;
+        }
+
+        # e1 and e2 are both strings
+        if (strlen($e1) == 1 || strlen($e2) == 1) {
+            # e1 or e2 is a single char extension (reserved in Asterisk)
+            return (strlen($e1) == 1) ? -1 : 1;
+        } else {
+            # e1 and e2 are both multi-char strings.  Sort them equally.
+            # FIXME Should add logic to make one multi-char take precedence
+            # over another?
+            return 0;
+        }
+    }
 }
 // }}}
\ No newline at end of file
index e9cd3f7..5e399e7 100644 (file)
@@ -20,36 +20,23 @@ require_once 'Horde/Block/Collection.php';
 
 // Set up the tree.
 $tree = &Horde_Tree::singleton('shout_dialplan_menu', 'javascript');
-
 foreach ($dialplan as $linetype => $linedata) {
     switch($linetype) {
         case 'extensions':
-            $tree->addNode('extensions', null, 'Extensions', null);
+            $url = '#top';
+            $tree->addNode('extensions', null, 'Extensions', null, array('url' => $url));
             foreach ($linedata as $extension => $priorities) {
-                switch($extension) {
-                    case 'i':
-                        $nodetext = 'Invalid Extension';
-                        break;
-                    case 's':
-                        $nodetext = 'Main';
-                        break;
-                    case 't':
-                        $nodetext = 'Timeout';
-                        break;
-                    case 'o':
-                        $nodetext = 'Operator';
-                        break;
-                    case 'h':
-                        $nodetext = 'Hangup';
-                        break;
-                    default:
-                        $nodetext = $extension;
-                        break;
-                    }
+                $nodetext = Shout::exten2name($extension);
                 $url = Horde::applicationUrl('index.php?section=dialplan' .
                     '&extension=' . $extension . '&context=' . $context);
-                $tree->addNode($extension, 'extensions', $nodetext, null, false,
-                    array('url' => $url));
+                $url = "#$extension";
+                $tree->addNode("extension_".$extension, 'extensions', $nodetext,
+                    null, false,
+                    array(
+                        'url' => $url,
+                        'onclick' => 'highlightExten(\''.$extension.'\')',
+                    )
+                );
 //                 foreach ($priorities as $priority => $application) {
 //                     $tree->addNode("$extension-$priority", $extension, "$priority: $application", null);
 //                 }
@@ -60,25 +47,26 @@ foreach ($dialplan as $linetype => $linedata) {
             $tree->addNode('includes', null, 'Includes', null);
             foreach ($linedata as $include) {
                 $url = Horde::applicationUrl('index.php?section=dialplan&context='.$include);
-                $tree->addNode($include, 'includes', $include, null, true, array('url' => $url));
+                $tree->addNode("include_$include", 'includes', $include, null,
+                    true, array('url' => $url));
             }
             break;
 
         # TODO Ignoring ignorepat lines for now
+
         case 'barelines':
             $tree->addNode('barelines', null, 'Extra Settings', null);
+            $i = 0;
             foreach ($linedata as $bareline) {
-                $tree->addNode($bareline, 'barelines', $bareline, null);
+                $tree->addNode("bareline_".$i, 'barelines', $bareline, null);
+                $i++;
             }
             break;
     }
 }
 
 require SHOUT_TEMPLATES . '/dialplan/contexttree.inc';
-
-if ($extension = Util::getFormData('extension')) {
-    require SHOUT_TEMPLATES . '/dialplan/extensiondetail.inc';
-}
+require SHOUT_TEMPLATES . '/dialplan/extensiondetail.inc';
 
 // Horde::addScriptFile('httpclient.js', 'horde', true);
 // Horde::addScriptFile('hideable.js', 'horde', true);
index 101326a..6b40cc4 100644 (file)
@@ -1,3 +1,55 @@
-<div class='contextTree'>
-<?php $tree->renderTree(); ?>
-</div>
\ No newline at end of file
+<script language="JavaScript" type="text/javascript">
+<!--
+var curExten;
+function highlightExten(exten)
+{
+    if (curExten && curExten != exten) {
+        deactivatePriority();
+
+        document.getElementById('eBox-' + curExten).className = 'extensionBox';
+        document.getElementById('pList-' + curExten).className = 'pList';
+    }
+
+    curExten = exten;
+    document.getElementById("eBox-" + exten).className = 'extensionBoxHighlight';
+    document.getElementById("pList-" + exten).className = 'pListHighlight';
+}
+
+var curPrio;
+function activatePriority(exten, prio)
+{
+    if (curExten) {
+        deactivatePriority();
+    }
+
+    if (exten != curExten) {
+        highlightExten(exten);
+    }
+    curPrio = prio;
+    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';
+}
+
+function deactivatePriority()
+{
+    if (curPrio) {
+        document.getElementById('pButtons-'+curExten+'-'+curPrio).className = 'pButtons';
+        document.getElementById('pNumber-'+curExten+'-'+curPrio).className = 'pElement';
+        document.getElementById('pApp-'+curExten+'-'+curPrio).className = 'pElement';
+        document.getElementById('pArgs-'+curExten+'-'+curPrio).className = 'pElement';
+    }
+}
+-->
+</script>
+
+<div class="header">
+    <div class="contextHeader">Context: <?php echo $context; ?></div>
+</div>
+
+<div id='contextTree'>
+<?php $tree->renderTree(true); ?>
+<br />
+<a href="#top" class="small">Back to Top</a>
+</div>
index 8e7f6b6..7ede9d8 100644 (file)
     if (isset($dialplan['extensions']) &&
         (count($dialplan['extensions']) > 0)) {
         foreach ($dialplan['extensions'] as $extension => $priorities) {
-            unset($extname);
-            # Cast as a string to avoid misinterpreted digits
-            switch ((string)$extension) {
-                case "h":
-                    $extname = "Hangup";
-                    break;
-                case "i":
-                    $extname = "Invalid";
-                    break;
-                case "t":
-                    $extname = "Timeout";
-                    break;
-                case "s":
-                    $extname = "Start";
-                    break;
-                case "o":
-                    $extname = "Operator";
-                    break;
-                default:
-                    break;
-            }
+            $extname = Shout::exten2name($extension);
             ?>
             <tr class="header">
               <th colspan="2" class="header">
index e931bcf..426273a 100644 (file)
@@ -1 +1,87 @@
-<div class='extensiondetail'>This is where extension details will be printed.</div>
\ No newline at end of file
+<?php
+if(!isset($dialplan['extensions'])) {
+    ?>
+    <div id="extensionDetail">
+        <div class="extensionBox">No Configured Extensions</div>
+    </div>
+    <?php
+} else {
+    ?>
+    <table id='extensionDetail' cellspacing="0">
+    <?
+    $e = 0;
+    foreach($dialplan['extensions'] as $extension => $priorities) { ?>
+        <tr class="extension"
+            id="extension_<?php echo $extension; ?>"
+            name="extension_<?php echo $extension; ?>">
+            <a name="<?php echo $extension; ?>">
+                <td class="extensionBox"
+                    name="<?php echo "eBox-$extension"; ?>"
+                    id="<?php echo "eBox-$extension"; ?>">
+                    <span onclick="javascript:highlightExten('<?php echo $extension; ?>');">
+                        <?php echo Shout::exten2name($extension); ?>
+                    </span>
+                </td>
+            </a>
+        </tr>
+
+        <tr>
+            <td>
+                <table class="pList" cellspacing="0"
+                    name="<?php echo "pList-$extension"; ?>"
+                    id="<?php echo "pList-$extension"; ?>">
+                    <?php
+                    $p = 0;
+                    foreach($priorities as $priority => $application) {
+                        ?>
+                        <tr class="priority">
+                            <td class="pButtons"
+                                id="<?php echo "pButtons-$extension-$priority"; ?>"
+                                name="<?php echo "pButtons-$extension-$priority"; ?>">
+                                <span class="add">+</span>
+                                <span class="remove">-</span>
+                            </td>
+                            <td class="pElement"
+                                id="<?php echo "pNumber-$extension-$priority"; ?>"
+                                name="<?php echo "pNumber-$extension-$priority"; ?>"
+                                onclick="javascript:activatePriority('<?php
+                                    echo $extension; ?>', '<?php
+                                    echo $priority; ?>')">
+                                <span class="priorityBox">
+                                    <?php echo $priority; ?>
+                                </span>
+                            </td>
+                            <td class="pElement"
+                                id="<?php echo "pApp-$extension-$priority"; ?>"
+                                name="<?php echo "pApp-$extension-$priority"; ?>">
+                                <span class="applicationBox">
+                                    <select
+                                        name="app[<?php echo $extension; ?>][<?php echo $priority; ?>]"
+                                        id="app[<?php echo $extension; ?>][<?php echo $priority; ?>]">
+                                        <option value="APPID"><?php echo "APPLICATION"; ?></option>
+                                    </select>
+                                </span>
+                            </td>
+                            <td class="pElement"
+                                id="<?php echo "pArgs-$extension-$priority"; ?>"
+                                name="<?php echo "pArgs-$extension-$priority"; ?>">
+                                <span class="argBox">
+                                    <?php echo $application; ?>
+                                </span>
+                            </td>
+                        </tr>
+                        <?php
+                        $p++;
+                    }
+                    ?>
+                </table>
+                <br />
+            </td>
+        </tr>
+        <?php
+        $e++;
+    } ?>
+    </table>
+    <?php
+}
+?>
index 3297c0c..80e0324 100644 (file)
@@ -1,3 +1,4 @@
+<a name="top"></a>
 <?php
 $accesskey = $prefs->getValue('widget_accesskey') ?
     Horde::getAccessKey(_("Select _Context")) : '';
@@ -14,7 +15,7 @@ $menu_view = $prefs->getValue('menu_view');
      <?php
         $contexts = &$shout->getContexts();
         foreach ($contexts as $c => $cdata) {
-            print "<option name=\"$c\"";
+            print "<option name=\"$c\" value=\"$c\"";
             if ($c == $context) {
                 print " selected";
             }
@@ -51,8 +52,8 @@ $menu_view = $prefs->getValue('menu_view');
 var loading;
 function contextSubmit(clear)
 {
-    if (document.menu.context[document.menu.context.selectedIndex].value !=
-'') {
+
+    if (document.menu.context[document.menu.context.selectedIndex].name != '') {
         if ((loading == null) || (clear != null)) {
             loading = true;
             document.menu.submit();
index 6200502..f5f6e7e 100644 (file)
@@ -1,49 +1,38 @@
-<table width="95%" border="0" cellpadding="0" cellspacing="0" class="header">
-  <tr valign="bottom">
-    <td width="8%"><div align="center"><font size="1">
-      &nbsp;
-    </td>
-    <td width="20%"><div align="center"></div></td>
-    <td width="45%">&nbsp;</td>
-    <td width="27%"><font size="3">Context: <?php echo $context; ?></font></td>
-  </tr>
-</table>
+<div class="header">
+    <span class="contextHeader">Context: <?php echo $context; ?></span>
+</div>
 
-<table width="95%" border="0" cellpadding="0" cellspacing="0">
-  <tbody>
-    <tr class="class">
-        <td width="7%"><strong>Ext.</strong></td>
-        <td colspan="2"><strong>Name</strong></td>
-        <td><strong>Email</strong></td>
-    </tr>
-    <?php
-        $line = 0;
-        foreach ($users as $extension => $user) {
-            $rowcolor = $line % 2;
-            $line++;
-            $url = Horde::applicationUrl("users.php");
-            $url = Util::addParameter($url, array('context' => $context,
-                                                  'extension' => $extension));
-            $editurl = Util::addParameter($url, "action=edit");
-            $deleteurl = Util::addParameter($url, "action=delete");
-    ?>
-    <tr class="item<?php echo $rowcolor; ?>">
-        <td width="7%"><?php echo Horde::link($editurl); echo $extension; ?></a>
-        </td>
-        <td><?php echo Horde::link($editurl); echo $user['name']; ?></a>
-        </td>
-        <td width="100">
-            <div align="center">
-                <?php echo Horde::link($editurl, '', 'darkhint'); ?>edit</a>
-                &nbsp;|&nbsp;
-                <?php echo Horde::link($deleteurl, '', 'darkhint'); ?>delete</a>
-            </div>
-            <div align="center"></div>
-        </td>
-    <td><?php echo $user['email']; ?></td>
-    </tr>
-    <?php
-        }
-    ?>
-  </tbody>
-</table>
+<div id="userlist">
+    <table cellspacing="0">
+        <tr class="header">
+            <td>Extension</td>
+            <td>Name</td>
+            <td>E-Mail Address</td>
+        </tr>
+        <?php
+            $line = 0;
+            foreach ($users as $extension => $user) {
+                $rowcolor = $line % 2;
+                $line++;
+                $url = Horde::applicationUrl("users.php");
+                $url = Util::addParameter($url, array('context' => $context,
+                                                    'extension' => $extension));
+                $editurl = Util::addParameter($url, "action=edit");
+                $deleteurl = Util::addParameter($url, "action=delete");
+        ?>
+        <tr class="item<?php echo $rowcolor; ?>">
+            <td style="width: 20%">
+                <?php echo Horde::link($editurl); echo $extension; ?></a>
+            </td>
+            <td style="width: 35%;">
+                <?php echo Horde::link($editurl); echo $user['name']; ?></a>
+            </td>
+            <td style="width: 45%">
+                <?php echo $user['email']; ?>
+            </td>
+        </tr>
+        <?php
+            }
+        ?>
+    </table>
+</div>
\ No newline at end of file
index 34df6da..5246a3b 100644 (file)
 .lighthint {
     color: #ffffff;
     font-size: 10px;
-}
+  }
+
 
 .darkhint {
-    color: #770000;
+    color: #700;
+    font-size: 10px;
+  }
+
+.contextHeader {
+    color: #fff;
+    font-size: 15px;
+    right: auto;
+    position: relative;
+}
+
+#userList table {
+    width: 100%;
+}
+
+#userList .header {
+    color: #777;
+    background: #fff;
+}
+
+#userList .headerText {
+    font-style: italic;
+    font-weight: bold;
+    font-size: 14px;
+}
+
+#contextTree {
+    width: 180px;
+    left: 12px;
+    position: fixed;
+    top: 108px;
+    background: #fbb;
+    border: 1px solid #a22;
+    padding: 5px;
+  }
+
+
+#extensionDetail {
+    left: 200px;
+    position: absolute;
+    top: 50px;
+    background: #ccc;
+    border: 1px solid #000;
+    padding: 15px;
+  }
+
+#extensionDetail .lightHint {
+    background: #888;
+    color: #ddd;
+}
+
+#extensionDetail .darkHint{
+     background: #797
+     color: #fff;
+}
+
+#extensionDetail .extension {
+    border: 2px solid #000;
+    background: inherit;
+    padding: 5px;
+    padding-bottom: 20px;
+}
+
+#extensionDetail .extensionHighlight {
+    border: 2px solid #a22;
+    padding: 5px;
+    padding-bottom: 20px;
+    background: #fbb;
+}
+
+#extensionDetail .extensionBox {
+    background: #fff;
+    color: #a22;
+    font-weight: bold;
+    font-size: 14px;
+    border: 2px solid #787;
+    padding: 5px;
+}
+
+#extensionDetail .extensionBoxHighlight {
+    background: #fbb;
+    color: #000;
+    font-weight: bold;
+    font-size: 14px;
+    border: 2px solid #fff;
+    padding: 5px;
+}
+
+#extensionDetail .pList {
+    border: 1px solid #787;
+    background: inherit;
+    left: 10px;
+    position: relative;
+}
+
+#extensionDetail .pListHighlight{
+    border: 1px solid #fff;
+    background: #fbb;
+    left: 10px;
+    position: relative;
+}
+
+#extensionDetail .priority {
+    padding: 3px;
+    left: 20px;
+    position: relative;
+    background: inherit;
+}
+
+#extensionDetail .pElement {
+    background: inherit;
+    padding: 3px;
+}
+#extensionDetail .pElementHighlight {
+    background: #ccf;
+    padding: 3px;
+    border-bottom: 1px solid #000;
+    border-top: 1px solid #000;
+    text-decoration: none;
+    font-color: #000;
+}
+
+#extensionDetail .priorityBox {
+    background: #fff;
+    color: #a22;
+    padding: 3px;
+    border: 1px solid #000;
+    width: 120px;
+    height: 16px;
+    text-align: center;
+    vertical-align: middle;
+    text-decoration: underline;
+}
+
+#extensionDetail .add {
+    border: 1px solid #000;
+    font-size: 10px;
+    font-weight: bold;
+    padding: 1px;
+    padding-left: 5px;
+    padding-right: 5px;
+}
+
+#extensionDetail .remove {
+    border: 1px solid #000;
     font-size: 10px;
+    font-weight: bold;
+    padding: 1px;
+    padding-left: 5px;
+    padding-right: 5px;
 }
 
-.contexttree {
-    float: left;
-    width: 50px;
+#extensionDetail .pButtons {
+    visibility: hidden;
+    padding: 3px;
 }
 
-.extensiondetail {
-    float: right;
+#extensionDetail .pButtonsHighlight {
+    visibility: visible;
+    background: #ccf;
+    padding: 3px;
+    border-bottom: 1px solid #000;
+    border-top: 1px solid #000;
 }
\ No newline at end of file