<h1>Project "FreeSWITCH user-contributed scripts, etc" received a push.</h1>
<h2>branch: master updated</h2>
<pre>
via: c780da02444472e37aee420dbb3087c232094d4e (commit)
via: d9ed290a32fd5dfd4401b02652e07c892126d7c6 (commit)
from: 90edbdd8fa5095b59024bbe41e3291c460d5a929 (commit)
</pre>= COMMIT LOG ===========================================================
<div class="highlight"><pre>committer: Mitch Capper
comments:
Merge branch 'master' of ssh://git.freeswitch.org/freeswitch-contrib
</pre></div>
<div class="highlight"><pre>committer: Mathieu Parent
comments:
MediaBrotha: LDAP search form
And more:
<span style="color: #A00000">- callback</span>
<span style="color: #A00000">- rework of actions</span>
<span style="color: #A00000">- exceptions handling</span>
<span style="color: #A00000">- forms</span>
<span style="color: #000080; font-weight: bold">diff --git a/sathieu/cisco-xml/browser/index.php b/sathieu/cisco-xml/browser/index.php</span>
<span style="color: #000080; font-weight: bold">index 137b409..c3286fa 100644</span>
<span style="color: #A00000">--- a/sathieu/cisco-xml/browser/index.php</span>
<span style="color: #00A000">+++ b/sathieu/cisco-xml/browser/index.php</span>
<span style="color: #800080; font-weight: bold">@@ -25,7 +25,7 @@ This file is part of XML services for Cisco IP Phones.</span>
*/
//* Debug
<span style="color: #A00000">-ini_set('error_reporting', E_ALL | E_STRUCT);</span>
<span style="color: #00A000">+ini_set('error_reporting', E_ALL);</span>
ini_set('display_errors', 1);
// */
<span style="color: #000080; font-weight: bold">diff --git a/sathieu/cisco-xml/lib/Cisco-XML/Cisco-XML.php b/sathieu/cisco-xml/lib/Cisco-XML/Cisco-XML.php</span>
<span style="color: #000080; font-weight: bold">index 216aad6..0da1cc3 100644</span>
<span style="color: #A00000">--- a/sathieu/cisco-xml/lib/Cisco-XML/Cisco-XML.php</span>
<span style="color: #00A000">+++ b/sathieu/cisco-xml/lib/Cisco-XML/Cisco-XML.php</span>
<span style="color: #800080; font-weight: bold">@@ -25,7 +25,9 @@ This file is part of XML services for Cisco IP Phones.</span>
*/
class CiscoIPPhone {
        static public function userAgentIsCiscoIPPhone() {
<span style="color: #A00000">-                return preg_match('/^Allegro-Software-WebClient\//', $_SERVER['HTTP_USER_AGENT']);</span>
<span style="color: #00A000">+                if (isset($_SERVER['HTTP_USER_AGENT'])) {</span>
<span style="color: #00A000">+                        return preg_match('/^Allegro-Software-WebClient\//', $_SERVER['HTTP_USER_AGENT']);</span>
<span style="color: #00A000">+                }</span>
        }
}
<span style="color: #000080; font-weight: bold">diff --git a/sathieu/cisco-xml/lib/MediaBrotha/Backend.php b/sathieu/cisco-xml/lib/MediaBrotha/Backend.php</span>
<span style="color: #000080; font-weight: bold">index 28a8441..8e56562 100644</span>
<span style="color: #A00000">--- a/sathieu/cisco-xml/lib/MediaBrotha/Backend.php</span>
<span style="color: #00A000">+++ b/sathieu/cisco-xml/lib/MediaBrotha/Backend.php</span>
<span style="color: #800080; font-weight: bold">@@ -26,8 +26,8 @@ This file is part of MediaBrotha.</span>
require_once('MediaBrotha/Media.php');
<span style="color: #A00000">-class MediaBrotha_Backend {</span>
<span style="color: #A00000">-        protected $_params = NULL;</span>
<span style="color: #00A000">+abstract class MediaBrotha_Backend {</span>
<span style="color: #00A000">+        private $_params = NULL;</span>
        public function __construct($params = NULL) {
                $this->setParam($params);
<span style="color: #800080; font-weight: bold">@@ -35,7 +35,7 @@ class MediaBrotha_Backend {</span>
        }
        /* params */
<span style="color: #A00000">-        public function getParam($name = NULL) {</span>
<span style="color: #00A000">+        final public function getParam($name = NULL) {</span>
                if ($name === NULL) {
                        return $this->_params;
                } elseif (isset($this->_params[$name])) {
<span style="color: #800080; font-weight: bold">@@ -44,7 +44,7 @@ class MediaBrotha_Backend {</span>
                        return NULL;
                }
        }
<span style="color: #A00000">-        public function setParam($name, $value = NULL) {</span>
<span style="color: #00A000">+        final public function setParam($name, $value = NULL) {</span>
                if (is_array($name)) {
                        $this->_params = $name;
                } else {
<span style="color: #800080; font-weight: bold">@@ -66,10 +66,6 @@ class MediaBrotha_Backend {</span>
                return $item;
        }
<span style="color: #A00000">-        public function fetch(MediaBrotha_Media $media) {</span>
<span style="color: #A00000">-                return false;</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-</span>
        // Actions
        public function getMediaActions(MediaBrotha_Media $media) {
                return Array();
<span style="color: #000080; font-weight: bold">diff --git a/sathieu/cisco-xml/lib/MediaBrotha/Backend/FileSystem.php b/sathieu/cisco-xml/lib/MediaBrotha/Backend/FileSystem.php</span>
<span style="color: #000080; font-weight: bold">index 006814b..c23a86f 100644</span>
<span style="color: #A00000">--- a/sathieu/cisco-xml/lib/MediaBrotha/Backend/FileSystem.php</span>
<span style="color: #00A000">+++ b/sathieu/cisco-xml/lib/MediaBrotha/Backend/FileSystem.php</span>
<span style="color: #800080; font-weight: bold">@@ -61,19 +61,6 @@ class MediaBrotha_Backend_FileSystem extends MediaBrotha_Backend {</span>
                }
        }
<span style="color: #A00000">-        public function fetch(MediaBrotha_Media $media) {</span>
<span style="color: #A00000">-                $uri = $media->getURI();</span>
<span style="color: #A00000">-                if ((parse_url($uri, PHP_URL_SCHEME) != 'file') || !$this->isURISafe($uri)) {</span>
<span style="color: #A00000">-                        $uri = 'file://'.$this->getParam('base_path');</span>
<span style="color: #A00000">-                }</span>
<span style="color: #A00000">-                $path = parse_url($uri, PHP_URL_PATH);</span>
<span style="color: #A00000">-                if (is_dir($path)) {</span>
<span style="color: #A00000">-                        return new MediaBrotha_MediaIterator($this, $media, new DirectoryIterator($path));</span>
<span style="color: #A00000">-                } else {</span>
<span style="color: #A00000">-                        return false;</span>
<span style="color: #A00000">-                }</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-</span>
        // Actions
        protected function _isHandled(MediaBrotha_Media $media) {
                return ($media->getMimeType() === 'application/x-directory')
<span style="color: #800080; font-weight: bold">@@ -83,6 +70,7 @@ class MediaBrotha_Backend_FileSystem extends MediaBrotha_Backend {</span>
        public function getMediaActions(MediaBrotha_Media $media) {
                if ($this->_isHandled($media)) {
                        return Array(
<span style="color: #00A000">+                                '_default',</span>
                                'browse',
                        );
                } else {
<span style="color: #800080; font-weight: bold">@@ -90,6 +78,25 @@ class MediaBrotha_Backend_FileSystem extends MediaBrotha_Backend {</span>
                }
        }
<span style="color: #00A000">+        public function doMediaAction($action, MediaBrotha_Media $media) {</span>
<span style="color: #00A000">+                switch($action) {</span>
<span style="color: #00A000">+                        case '_default':</span>
<span style="color: #00A000">+                        case 'browse':</span>
<span style="color: #00A000">+                                $uri = $media->getURI();</span>
<span style="color: #00A000">+                                if ((parse_url($uri, PHP_URL_SCHEME) != 'file') || !$this->isURISafe($uri)) {</span>
<span style="color: #00A000">+                                        $uri = 'file://'.$this->getParam('base_path');</span>
<span style="color: #00A000">+                                }</span>
<span style="color: #00A000">+                                $path = parse_url($uri, PHP_URL_PATH);</span>
<span style="color: #00A000">+                                if (is_dir($path)) {</span>
<span style="color: #00A000">+                                        return new MediaBrotha_MediaIterator($this, new DirectoryIterator($path));</span>
<span style="color: #00A000">+                                } else {</span>
<span style="color: #00A000">+                                        return false;</span>
<span style="color: #00A000">+                                }</span>
<span style="color: #00A000">+                        default:</span>
<span style="color: #00A000">+                                return parent::doMediaAction($action, $media);</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
        // Populate
        public function populateMedia(MediaBrotha_Media $media) {
                if ($this->_isHandled($media)) {
<span style="color: #000080; font-weight: bold">diff --git a/sathieu/cisco-xml/lib/MediaBrotha/Backend/LDAP.php b/sathieu/cisco-xml/lib/MediaBrotha/Backend/LDAP.php</span>
<span style="color: #000080; font-weight: bold">index 365e78e..2b04351 100644</span>
<span style="color: #A00000">--- a/sathieu/cisco-xml/lib/MediaBrotha/Backend/LDAP.php</span>
<span style="color: #00A000">+++ b/sathieu/cisco-xml/lib/MediaBrotha/Backend/LDAP.php</span>
<span style="color: #800080; font-weight: bold">@@ -63,21 +63,6 @@ class MediaBrotha_Backend_LDAP extends MediaBrotha_Backend {</span>
                }
        }
<span style="color: #A00000">-        public function fetch(MediaBrotha_Media $media) {</span>
<span style="color: #A00000">-                $uri = $media->getURI();</span>
<span style="color: #A00000">-                if (($this::parseLDAPURI($uri, PHP_URL_SCHEME) != 'ldap') || !$this->isURISafe($uri)) {</span>
<span style="color: #A00000">-                        $ldap_connect_config = $this->getParam('ldap_connect_config');</span>
<span style="color: #A00000">-                        $uri = 'ldap:///'.$ldap_connect_config['basedn'];</span>
<span style="color: #A00000">-                }</span>
<span style="color: #A00000">-                $basedn = $this::parseLDAPURI($uri, PHP_URL_PATH);</span>
<span style="color: #A00000">-                if ($basedn && ($basedn{0} = '/')) {</span>
<span style="color: #A00000">-                        $basedn = substr($basedn, 1);</span>
<span style="color: #A00000">-                }</span>
<span style="color: #A00000">-                $ldap_search = $this->_ldap->search($basedn, NULL,</span>
<span style="color: #A00000">-                        Array());</span>
<span style="color: #A00000">-                return new MediaBrotha_MediaIterator($this, $media, $ldap_search);</span>
<span style="color: #A00000">-                return true;</span>
<span style="color: #A00000">-        }</span>
        // Actions
        protected function _isHandled(MediaBrotha_Media $media) {
                return ($media->getMimeType() === 'text/directory')
<span style="color: #800080; font-weight: bold">@@ -87,12 +72,74 @@ class MediaBrotha_Backend_LDAP extends MediaBrotha_Backend {</span>
        public function getMediaActions(MediaBrotha_Media $media) {
                if ($this->_isHandled($media)) {
                        return Array(
<span style="color: #00A000">+                                '_default',</span>
                                'browse',
<span style="color: #00A000">+                                'search',</span>
                        );
                } else {
                        return parent::getMediaActions($media);
                }
        }
<span style="color: #A00000">-</span>
<span style="color: #00A000">+        public function doMediaAction($action, MediaBrotha_Media $media) {</span>
<span style="color: #00A000">+                switch($action) {</span>
<span style="color: #00A000">+                        case 'browse':</span>
<span style="color: #00A000">+                                $uri = $media->getURI();</span>
<span style="color: #00A000">+                                if (($this::parseLDAPURI($uri, PHP_URL_SCHEME) != 'ldap') || !$this->isURISafe($uri)) {</span>
<span style="color: #00A000">+                                        $ldap_connect_config = $this->getParam('ldap_connect_config');</span>
<span style="color: #00A000">+                                        $uri = 'ldap:///'.$ldap_connect_config['basedn'];</span>
<span style="color: #00A000">+                                }</span>
<span style="color: #00A000">+                                $basedn = $this::parseLDAPURI($uri, PHP_URL_PATH);</span>
<span style="color: #00A000">+                                if ($basedn && ($basedn{0} = '/')) {</span>
<span style="color: #00A000">+                                        $basedn = substr($basedn, 1);</span>
<span style="color: #00A000">+                                }</span>
<span style="color: #00A000">+                                $ldap_search = $this->_ldap->search($basedn, NULL,</span>
<span style="color: #00A000">+                                        Array());</span>
<span style="color: #00A000">+                                return new MediaBrotha_MediaIterator($this, $ldap_search);</span>
<span style="color: #00A000">+                        case '_default':</span>
<span style="color: #00A000">+                        case 'search':</span>
<span style="color: #00A000">+                                $form = new MediaBrotha_Form();</span>
<span style="color: #00A000">+                                $form->setTitle('search');</span>
<span style="color: #00A000">+                                $search_fields = Array(</span>
<span style="color: #00A000">+                                        'sn' => Array('display_name' => 'last name'),</span>
<span style="color: #00A000">+                                        'givenName' => Array('display_name' => 'first name'),</span>
<span style="color: #00A000">+                                        'telephoneNumber' => Array('display_name' => 'phone', 'filter' => '(telephoneNumber=*%s*)'),</span>
<span style="color: #00A000">+                                        //'o' => Array('display_name' => 'organization'),</span>
<span style="color: #00A000">+                                        //'mobile' => Array('display_name' => 'mobile'),</span>
<span style="color: #00A000">+                                        //'facsimileTelephoneNumber' => Array('display_name' => 'fax'),</span>
<span style="color: #00A000">+                                        //'l' => Array('display_name' => 'location'),</span>
<span style="color: #00A000">+                                        //'st' => Array('display_name' => 'department'),</span>
<span style="color: #00A000">+                                        //'roomNumber' => Array('display_name' => 'room number'),</span>
<span style="color: #00A000">+                                );</span>
<span style="color: #00A000">+                                $ldap_connect_config = $this->getParam('ldap_connect_config');</span>
<span style="color: #00A000">+                                $filter = $ldap_connect_config['filter'];</span>
<span style="color: #00A000">+                                foreach ($search_fields as $attribute_name => $field) {</span>
<span style="color: #00A000">+                                        $field['name'] = $attribute_name;</span>
<span style="color: #00A000">+                                        if (!empty($_GET[$attribute_name])) {</span>
<span style="color: #00A000">+                                                $field['value'] = $_GET[$attribute_name];</span>
<span style="color: #00A000">+                                                if(empty($infos['filter'])) {</span>
<span style="color: #00A000">+                                                        $filter="(&$filter($attribute_name=".$_GET[$attribute_name]."*))";</span>
<span style="color: #00A000">+                                                } else {</span>
<span style="color: #00A000">+                                                        $filter="(&$filter".sprintf($infos['filter'], $_GET[$attribute_name]).")";</span>
<span style="color: #00A000">+                                                }</span>
<span style="color: #00A000">+                                        }</span>
<span style="color: #00A000">+                                        $form->addField($field);</span>
<span style="color: #00A000">+                                }</span>
<span style="color: #00A000">+                                if (empty($_GET['ldap_search'])) {</span>
<span style="color: #00A000">+                                        MediaBrotha_Core::addCallback('MediaBrotha_Backend_LDAP::searchCallback');</span>
<span style="color: #00A000">+                                        return $form;</span>
<span style="color: #00A000">+                                } else {</span>
<span style="color: #00A000">+                                        $ldap_search = $this->_ldap->search(NULL, $filter,</span>
<span style="color: #00A000">+                                                Array('scope' => 'sub'));</span>
<span style="color: #00A000">+                                        return new MediaBrotha_MediaIterator($this, $ldap_search);</span>
<span style="color: #00A000">+                                }</span>
<span style="color: #00A000">+                        default:</span>
<span style="color: #00A000">+                                return parent::doMediaAction($action, $media);</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        static public function searchCallback() {</span>
<span style="color: #00A000">+                $_GET['backend'] = 'LDAP';</span>
<span style="color: #00A000">+                $_GET['action'] = 'search';</span>
<span style="color: #00A000">+                $_GET['ldap_search'] = '1';</span>
<span style="color: #00A000">+        }</span>
}
<span style="color: #000080; font-weight: bold">diff --git a/sathieu/cisco-xml/lib/MediaBrotha/Backend/Root.php b/sathieu/cisco-xml/lib/MediaBrotha/Backend/Root.php</span>
<span style="color: #000080; font-weight: bold">index 9616be8..613ce17 100644</span>
<span style="color: #A00000">--- a/sathieu/cisco-xml/lib/MediaBrotha/Backend/Root.php</span>
<span style="color: #00A000">+++ b/sathieu/cisco-xml/lib/MediaBrotha/Backend/Root.php</span>
<span style="color: #800080; font-weight: bold">@@ -35,7 +35,7 @@ class MediaBrotha_Backend_Root extends MediaBrotha_Backend {</span>
                                'display_name' => 'Root',
                        )
                );
<span style="color: #A00000">-                $this->_media_iterator = new MediaBrotha_MediaIterator($this, $this->_media);</span>
<span style="color: #00A000">+                $this->_media_iterator = new MediaBrotha_MediaIterator($this);</span>
        }
        public function addRootMedia($URI, array $metadata = Array(), $mime_type = NULL, $mime_encoding = NULL) {
<span style="color: #800080; font-weight: bold">@@ -45,9 +45,15 @@ class MediaBrotha_Backend_Root extends MediaBrotha_Backend {</span>
                $this->_media_iterator->bufferAdd($media);
        }
<span style="color: #A00000">-        // Browsing</span>
<span style="color: #A00000">-        public function fetch(MediaBrotha_Media $media) {</span>
<span style="color: #A00000">-                return $this->_media_iterator;</span>
<span style="color: #00A000">+        // Actions</span>
<span style="color: #00A000">+        public function doMediaAction($action, MediaBrotha_Media $media) {</span>
<span style="color: #00A000">+                switch($action) {</span>
<span style="color: #00A000">+                        case '_default':</span>
<span style="color: #00A000">+                        case 'browse':</span>
<span style="color: #00A000">+                                return $this->_media_iterator;</span>
<span style="color: #00A000">+                        default:</span>
<span style="color: #00A000">+                                return parent::doMediaAction($action, $media);</span>
<span style="color: #00A000">+                }</span>
        }
}
<span style="color: #000080; font-weight: bold">diff --git a/sathieu/cisco-xml/lib/MediaBrotha/Backend/VLC.php b/sathieu/cisco-xml/lib/MediaBrotha/Backend/VLC.php</span>
<span style="color: #000080; font-weight: bold">index 8c3208e..d881850 100644</span>
<span style="color: #A00000">--- a/sathieu/cisco-xml/lib/MediaBrotha/Backend/VLC.php</span>
<span style="color: #00A000">+++ b/sathieu/cisco-xml/lib/MediaBrotha/Backend/VLC.php</span>
<span style="color: #800080; font-weight: bold">@@ -43,12 +43,6 @@ class MediaBrotha_Backend_VLC extends MediaBrotha_Backend {</span>
                print $output.'<!--'.$url."-->\n";
        }
<span style="color: #A00000">-        // Browsing</span>
<span style="color: #A00000">-        public function fetch(MediaBrotha_Media $media) {</span>
<span style="color: #A00000">-                $this->_buffer[] = $media;</span>
<span style="color: #A00000">-                return true;</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-</span>
        // Actions
        protected function _isHandled(MediaBrotha_Media $media) {
                return in_array($media->getMimeType(), Array($this::$_supported_mime_types))
<span style="color: #000080; font-weight: bold">diff --git a/sathieu/cisco-xml/lib/MediaBrotha/Core.php b/sathieu/cisco-xml/lib/MediaBrotha/Core.php</span>
<span style="color: #000080; font-weight: bold">index 8997a7c..f241c66 100644</span>
<span style="color: #A00000">--- a/sathieu/cisco-xml/lib/MediaBrotha/Core.php</span>
<span style="color: #00A000">+++ b/sathieu/cisco-xml/lib/MediaBrotha/Core.php</span>
<span style="color: #800080; font-weight: bold">@@ -28,6 +28,7 @@ require_once('MediaBrotha/Backend.php');</span>
require_once('MediaBrotha/Frontend.php');
require_once('MediaBrotha/Media.php');
require_once('MediaBrotha/MediaIterator.php');
<span style="color: #00A000">+require_once('MediaBrotha/Form.php');</span>
class MediaBrotha_Core {
        private static $_frontend = NULL;
<span style="color: #800080; font-weight: bold">@@ -38,20 +39,26 @@ class MediaBrotha_Core {</span>
         * Core
         */
        public static function init() {
<span style="color: #A00000">-                if (!session_start()) {</span>
<span style="color: #A00000">-                        die('Unable to start session');</span>
<span style="color: #00A000">+                try {</span>
<span style="color: #00A000">+                        if (!session_start()) {</span>
<span style="color: #00A000">+                                throw new Exception('Unable to start session');</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+                        MediaBrotha_Core::_unhashRequest();</span>
<span style="color: #00A000">+                        MediaBrotha_Core::loadBackend('Root');</span>
<span style="color: #00A000">+                } catch (Exception $e) {</span>
<span style="color: #00A000">+                        die($e);</span>
                }
<span style="color: #A00000">-                MediaBrotha_Core::_unhashRequest();</span>
<span style="color: #A00000">-                MediaBrotha_Core::loadBackend('Root');</span>
        }
        public static function go() {
<span style="color: #A00000">-                $current_backend = MediaBrotha_Core::getCurrentBackend();</span>
<span style="color: #A00000">-                $current_media = MediaBrotha_Core::getCurrentMedia();</span>
<span style="color: #A00000">-                if (MediaBrotha_Core::getAction() == 'browse') {</span>
<span style="color: #A00000">-                        if ($media_iterator = $current_backend->fetch($current_media)) {</span>
<span style="color: #00A000">+                try {</span>
<span style="color: #00A000">+                        MediaBrotha_Core::runCallback();</span>
<span style="color: #00A000">+                        $current_backend = MediaBrotha_Core::getCurrentBackend();</span>
<span style="color: #00A000">+                        $current_media = MediaBrotha_Core::getCurrentMedia();</span>
<span style="color: #00A000">+                        $result = $current_backend->doMediaAction(MediaBrotha_Core::getAction(), $current_media);</span>
<span style="color: #00A000">+                        if (is_a($result, 'MediaBrotha_MediaIterator')) {</span>
                                MediaBrotha_Core::$_frontend->begin($current_media);
<span style="color: #A00000">-                                foreach ($media_iterator as $item) {</span>
<span style="color: #00A000">+                                foreach ($result as $item) {</span>
                                        if (($item === NULL) || $item->isHidden()) {
                                                continue;
                                        }
<span style="color: #800080; font-weight: bold">@@ -59,17 +66,32 @@ class MediaBrotha_Core {</span>
                                }
                                MediaBrotha_Core::$_frontend->finish($current_media);
                                MediaBrotha_Core::$_frontend->render($current_media);
<span style="color: #00A000">+                        } elseif (is_a($result, 'MediaBrotha_Form')) {</span>
<span style="color: #00A000">+                                MediaBrotha_Core::$_frontend->renderForm($result);</span>
<span style="color: #00A000">+                        } elseif (is_a($result, 'Exception')) {</span>
<span style="color: #00A000">+                                throw $result;</span>
                        } else {
<span style="color: #00A000">+                                throw new Exception("Got unexpected result '$result'.");</span>
                        }
<span style="color: #A00000">-                } else {</span>
<span style="color: #A00000">-                        $current_backend->doMediaAction(MediaBrotha_Core::getAction(), $current_media);</span>
<span style="color: #00A000">+                } catch (Exception $e) {</span>
<span style="color: #00A000">+                        MediaBrotha_Core::$_frontend->renderException($e);</span>
                }
        }
<span style="color: #A00000">-        public function addRootMedia($URI, array $metadata = Array(), $mime_type = NULL, $mime_encoding = NULL) {</span>
<span style="color: #00A000">+        public static function addRootMedia($URI, array $metadata = Array(), $mime_type = NULL, $mime_encoding = NULL) {</span>
                MediaBrotha_Core::$_backends['Root']->addRootMedia($URI, $metadata, $mime_type, $mime_encoding);
        }
<span style="color: #00A000">+        public static function addCallback($callback, $arg = NULL) {</span>
<span style="color: #00A000">+                $_SESSION['CALLBACK'][] = Array($callback, $arg);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        public static function runCallback() {</span>
<span style="color: #00A000">+                while($callback_info = array_shift($_SESSION['CALLBACK'])) {</span>
<span style="color: #00A000">+                        call_user_func($callback_info[0],$callback_info[1]);</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
        /*
         * Backends
         */
<span style="color: #800080; font-weight: bold">@@ -129,7 +151,7 @@ class MediaBrotha_Core {</span>
                if (!empty($_GET['action'])) {
                        return $_GET['action'];
                } else {
<span style="color: #A00000">-                        return 'browse';</span>
<span style="color: #00A000">+                        return '_default';</span>
                }
        }
<span style="color: #000080; font-weight: bold">diff --git a/sathieu/cisco-xml/lib/MediaBrotha/Frontend.php b/sathieu/cisco-xml/lib/MediaBrotha/Form.php</span>
similarity index 60%
copy from sathieu/cisco-xml/lib/MediaBrotha/Frontend.php
copy to sathieu/cisco-xml/lib/MediaBrotha/Form.php
<span style="color: #000080; font-weight: bold">index 2cc6060..08dd4c6 100644</span>
<span style="color: #A00000">--- a/sathieu/cisco-xml/lib/MediaBrotha/Frontend.php</span>
<span style="color: #00A000">+++ b/sathieu/cisco-xml/lib/MediaBrotha/Form.php</span>
<span style="color: #800080; font-weight: bold">@@ -24,11 +24,31 @@ This file is part of MediaBrotha.</span>
* @author Mathieu Parent
*/
<span style="color: #A00000">-class MediaBrotha_Frontend {</span>
<span style="color: #A00000">-        protected $_infos = NULL;</span>
<span style="color: #00A000">+class MediaBrotha_Field {</span>
<span style="color: #00A000">+        private $_attrs;</span>
<span style="color: #A00000">-        public function __construct(array $args = Array()) {</span>
<span style="color: #A00000">-                $this->_infos = $args;</span>
<span style="color: #00A000">+        public function __construct(array $attrs) {</span>
<span style="color: #00A000">+                $this->_attrs = $attrs;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        public function get($name) {</span>
<span style="color: #00A000">+                if (isset($this->_attrs[$name])) {</span>
<span style="color: #00A000">+                        return $this->_attrs[$name];</span>
<span style="color: #00A000">+                }        </span>
        }
}
<span style="color: #00A000">+class MediaBrotha_Form extends ArrayIterator {</span>
<span style="color: #00A000">+        private $_title;</span>
<span style="color: #00A000">+        public function getTitle() {</span>
<span style="color: #00A000">+                return $this->_title;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        public function setTitle($title) {</span>
<span style="color: #00A000">+                $this->_title = $title;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        public function addField(array $args) {</span>
<span style="color: #00A000">+                $this[] = new MediaBrotha_Field($args);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+}</span>
<span style="color: #000080; font-weight: bold">diff --git a/sathieu/cisco-xml/lib/MediaBrotha/Frontend.php b/sathieu/cisco-xml/lib/MediaBrotha/Frontend.php</span>
<span style="color: #000080; font-weight: bold">index 2cc6060..be427fa 100644</span>
<span style="color: #A00000">--- a/sathieu/cisco-xml/lib/MediaBrotha/Frontend.php</span>
<span style="color: #00A000">+++ b/sathieu/cisco-xml/lib/MediaBrotha/Frontend.php</span>
<span style="color: #800080; font-weight: bold">@@ -24,11 +24,19 @@ This file is part of MediaBrotha.</span>
* @author Mathieu Parent
*/
<span style="color: #A00000">-class MediaBrotha_Frontend {</span>
<span style="color: #00A000">+abstract class MediaBrotha_Frontend {</span>
        protected $_infos = NULL;
        public function __construct(array $args = Array()) {
                $this->_infos = $args;
        }
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        public function renderException(Exception $e) {</span>
<span style="color: #00A000">+                print $e;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        public function renderForm(MediaBrotha_Form $form) {</span>
<span style="color: #00A000">+                throw new Exception(__FUNCTION__ .' not implemented in class "'.get_class($this).'"');</span>
<span style="color: #00A000">+        }</span>
}
<span style="color: #000080; font-weight: bold">diff --git a/sathieu/cisco-xml/lib/MediaBrotha/Frontend/CiscoXML.php b/sathieu/cisco-xml/lib/MediaBrotha/Frontend/CiscoXML.php</span>
<span style="color: #000080; font-weight: bold">index 914e6ee..1bf85b7 100644</span>
<span style="color: #A00000">--- a/sathieu/cisco-xml/lib/MediaBrotha/Frontend/CiscoXML.php</span>
<span style="color: #00A000">+++ b/sathieu/cisco-xml/lib/MediaBrotha/Frontend/CiscoXML.php</span>
<span style="color: #800080; font-weight: bold">@@ -52,7 +52,7 @@ class MediaBrotha_Frontend_CiscoXML extends MediaBrotha_Frontend_HTTP {</span>
                        'URL' => 'SoftKey:Select',
                        'Position' => $pos++));
                foreach (MediaBrotha_Core::getBackends() as $backend) {
<span style="color: #A00000">-                        foreach ($backend->getMediaActions(MediaBrotha_Core::getCurrentMedia()) as $action) {</span>
<span style="color: #00A000">+                        foreach ($backend->getMediaActions($item) as $action) {</span>
                                $this->_xml->setCiscoElement('SoftKeyItem',
                                        Array('Name' => $action,
                                        'URL' => 'QueryStringParam:'.MediaBrotha_Core::value2hash('action='.$action.'&backend='.$backend->getBackendName()),
<span style="color: #800080; font-weight: bold">@@ -70,5 +70,25 @@ class MediaBrotha_Frontend_CiscoXML extends MediaBrotha_Frontend_HTTP {</span>
                        print $this->_xml->execute($this->_infos['push_url']);
                }
        }
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        public function renderForm(MediaBrotha_Form $form) {</span>
<span style="color: #00A000">+                $xml = new CiscoIPPhoneInput();</span>
<span style="color: #00A000">+                $xml->setCiscoElement('Title', $form->getTitle());</span>
<span style="color: #00A000">+                //$xml->setCiscoElement('Prompt', ...);</span>
<span style="color: #00A000">+                $xml->setCiscoElement('URL', $this->rootURL());</span>
<span style="color: #00A000">+                foreach($form as $field) {</span>
<span style="color: #00A000">+                        $xml->setCiscoElement('InputItem',</span>
<span style="color: #00A000">+                                Array(</span>
<span style="color: #00A000">+                                        'DisplayName' => $field->get('display_name'),</span>
<span style="color: #00A000">+                                        'QueryStringParam' => $field->get('name'),</span>
<span style="color: #00A000">+                                        'DefaultValue' => $field->get('value'),</span>
<span style="color: #00A000">+                                        'InputFlags' => '',</span>
<span style="color: #00A000">+                                )</span>
<span style="color: #00A000">+                        );</span>
<span style="color: #00A000">+                        </span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+                CiscoXMLObject::HttpHeader();</span>
<span style="color: #00A000">+                print $xml;</span>
<span style="color: #00A000">+        }</span>
}
<span style="color: #000080; font-weight: bold">diff --git a/sathieu/cisco-xml/lib/MediaBrotha/Frontend/HTML.php b/sathieu/cisco-xml/lib/MediaBrotha/Frontend/HTML.php</span>
<span style="color: #000080; font-weight: bold">index 6d09e1b..f6d4015 100644</span>
<span style="color: #A00000">--- a/sathieu/cisco-xml/lib/MediaBrotha/Frontend/HTML.php</span>
<span style="color: #00A000">+++ b/sathieu/cisco-xml/lib/MediaBrotha/Frontend/HTML.php</span>
<span style="color: #800080; font-weight: bold">@@ -54,7 +54,7 @@ class MediaBrotha_Frontend_HTML extends MediaBrotha_Frontend_HTTP {</span>
                }
        }
<span style="color: #A00000">-        public function begin($item) {</span>
<span style="color: #00A000">+        private function _createHTMLDocument($title) {</span>
                $this->_xml = new DOMDocument('1.0');
                $root = $this->_xml->createElement('html');
                $root = $this->_xml->appendChild($root);
<span style="color: #800080; font-weight: bold">@@ -62,11 +62,10 @@ class MediaBrotha_Frontend_HTML extends MediaBrotha_Frontend_HTTP {</span>
                $head = $this->_xml->createElement('head');
                $head = $root->appendChild($head);
<span style="color: #A00000">-                $title = $this->_xml->createElement('title');</span>
<span style="color: #A00000">-                $title = $head->appendChild($title);</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-                $text = $this->_xml->createTextNode($item->getDisplayName());</span>
<span style="color: #A00000">-                $text = $title->appendChild($text);</span>
<span style="color: #00A000">+                $titleElement = $this->_xml->createElement('title');</span>
<span style="color: #00A000">+                $titleElement = $head->appendChild($titleElement);</span>
<span style="color: #00A000">+                $text = $this->_xml->createTextNode($title);</span>
<span style="color: #00A000">+                $text = $titleElement->appendChild($text);</span>
                $style = $this->_xml->createElement('link');
                $style = $head->appendChild($style);
<span style="color: #800080; font-weight: bold">@@ -82,7 +81,10 @@ class MediaBrotha_Frontend_HTML extends MediaBrotha_Frontend_HTTP {</span>
                $this->_body = $this->_xml->createElement('body');
                $this->_body = $root->appendChild($this->_body);
                $this->_body->setAttribute('onload', 'bodyLoaded();');
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        public function begin($item) {</span>
<span style="color: #00A000">+                $this->_createHTMLDocument($item->getDisplayName());</span>
                $this->_mediaListElement = $this->_xml->createElement('ul');
                $this->_mediaListElement = $this->_body->appendChild($this->_mediaListElement);
                $this->_mediaListElement->setAttribute('id', 'mediaListElement');
<span style="color: #800080; font-weight: bold">@@ -123,5 +125,60 @@ class MediaBrotha_Frontend_HTML extends MediaBrotha_Frontend_HTTP {</span>
        public function render() {
                print $this->_xml->saveHTML();
        }
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        public function renderForm(MediaBrotha_Form $form) {</span>
<span style="color: #00A000">+                $this->_createHTMLDocument($form->getTitle());</span>
<span style="color: #00A000">+                $formElement = $this->_xml->createElement('form');</span>
<span style="color: #00A000">+                $formElement = $this->_body->appendChild($formElement);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                $tableElement = $this->_xml->createElement('table');</span>
<span style="color: #00A000">+                $tableElement = $formElement->appendChild($tableElement);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                foreach($form as $field) {</span>
<span style="color: #00A000">+                        $trElement = $this->_xml->createElement('tr');</span>
<span style="color: #00A000">+                        $trElement = $tableElement->appendChild($trElement);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                        $tdElement1 = $this->_xml->createElement('th');</span>
<span style="color: #00A000">+                        $tdElement1 = $trElement->appendChild($tdElement1);</span>
<span style="color: #00A000">+                        $text1 = $this->_xml->createTextNode($field->get('display_name'));</span>
<span style="color: #00A000">+                        $text1 = $tdElement1->appendChild($text1);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                        $tdElement2 = $this->_xml->createElement('td');</span>
<span style="color: #00A000">+                        $tdElement2 = $trElement->appendChild($tdElement2);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                        $inputElement = $this->_xml->createElement('input');</span>
<span style="color: #00A000">+                        $inputElement = $tdElement2->appendChild($inputElement);</span>
<span style="color: #00A000">+                        $inputElement->setAttribute('name', $field->get('name'));</span>
<span style="color: #00A000">+                        $inputElement->setAttribute('value', $field->get('value'));</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                $trElement = $this->_xml->createElement('tr');</span>
<span style="color: #00A000">+                $trElement = $tableElement->appendChild($trElement);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                $tdElement = $this->_xml->createElement('td');</span>
<span style="color: #00A000">+                $tdElement = $trElement->appendChild($tdElement);</span>
<span style="color: #00A000">+                $tdElement->setAttribute('colspan', 2);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                $inputElement = $this->_xml->createElement('input');</span>
<span style="color: #00A000">+                $inputElement = $tdElement->appendChild($inputElement);</span>
<span style="color: #00A000">+                $inputElement->setAttribute('type', 'submit');</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                print $this->_xml->saveHTML();</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        public function renderException(Exception $e) {</span>
<span style="color: #00A000">+                $this->_createHTMLDocument('Error');</span>
<span style="color: #00A000">+                $divElement = $this->_xml->createElement('pre');</span>
<span style="color: #00A000">+                $divElement = $this->_body->appendChild($divElement);</span>
<span style="color: #00A000">+                $text = $this->_xml->createTextNode($e->getMessage());</span>
<span style="color: #00A000">+                $text = $divElement->appendChild($text);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                $divElement = $this->_xml->createElement('pre');</span>
<span style="color: #00A000">+                $divElement = $this->_body->appendChild($divElement);</span>
<span style="color: #00A000">+                $text = $this->_xml->createTextNode($e->getTraceAsString());</span>
<span style="color: #00A000">+                $text = $divElement->appendChild($text);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+                print $this->_xml->saveHTML();</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
}
<span style="color: #000080; font-weight: bold">diff --git a/sathieu/cisco-xml/lib/MediaBrotha/Frontend/HTTP.php b/sathieu/cisco-xml/lib/MediaBrotha/Frontend/HTTP.php</span>
<span style="color: #000080; font-weight: bold">index de19bf7..f225175 100644</span>
<span style="color: #A00000">--- a/sathieu/cisco-xml/lib/MediaBrotha/Frontend/HTTP.php</span>
<span style="color: #00A000">+++ b/sathieu/cisco-xml/lib/MediaBrotha/Frontend/HTTP.php</span>
<span style="color: #800080; font-weight: bold">@@ -24,10 +24,14 @@ This file is part of MediaBrotha.</span>
* @author Mathieu Parent
*/
<span style="color: #A00000">-class MediaBrotha_Frontend_HTTP extends MediaBrotha_Frontend {</span>
<span style="color: #00A000">+abstract class MediaBrotha_Frontend_HTTP extends MediaBrotha_Frontend {</span>
        public function rootURL() {
<span style="color: #A00000">-                $url = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['SCRIPT_NAME'];</span>
<span style="color: #A00000">-                $url = preg_replace('/index\.php$/', '', $url);</span>
<span style="color: #00A000">+                if (isset($_SERVER['SERVER_NAME'])) {</span>
<span style="color: #00A000">+                        $url = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['SCRIPT_NAME'];</span>
<span style="color: #00A000">+                        $url = preg_replace('/index\.php$/', '', $url);</span>
<span style="color: #00A000">+                } else {</span>
<span style="color: #00A000">+                        $url = $_SERVER['SCRIPT_NAME'];</span>
<span style="color: #00A000">+                }</span>
                return $url;
        }
}
<span style="color: #000080; font-weight: bold">diff --git a/sathieu/cisco-xml/lib/MediaBrotha/Media.php b/sathieu/cisco-xml/lib/MediaBrotha/Media.php</span>
<span style="color: #000080; font-weight: bold">index 7964473..d32ee48 100644</span>
<span style="color: #A00000">--- a/sathieu/cisco-xml/lib/MediaBrotha/Media.php</span>
<span style="color: #00A000">+++ b/sathieu/cisco-xml/lib/MediaBrotha/Media.php</span>
<span style="color: #800080; font-weight: bold">@@ -24,7 +24,7 @@ This file is part of MediaBrotha.</span>
* @author Mathieu Parent
*/
<span style="color: #A00000">-class MediaBrotha_Media {</span>
<span style="color: #00A000">+final class MediaBrotha_Media {</span>
        private $_URI = NULL;
        private $_metadata = Array();
        private $_mimeType = NULL;
<span style="color: #000080; font-weight: bold">diff --git a/sathieu/cisco-xml/lib/MediaBrotha/MediaIterator.php b/sathieu/cisco-xml/lib/MediaBrotha/MediaIterator.php</span>
<span style="color: #000080; font-weight: bold">index 096759a..e862661 100644</span>
<span style="color: #A00000">--- a/sathieu/cisco-xml/lib/MediaBrotha/MediaIterator.php</span>
<span style="color: #00A000">+++ b/sathieu/cisco-xml/lib/MediaBrotha/MediaIterator.php</span>
<span style="color: #800080; font-weight: bold">@@ -28,13 +28,11 @@ require_once('MediaBrotha/Media.php');</span>
class MediaBrotha_MediaIterator implements Iterator {
        private $_backend = NULL;
<span style="color: #A00000">-        private $_media = NULL;</span>
        private $_handle = NULL;
        protected $_buffer = NULL;
<span style="color: #A00000">-        public function __construct(MediaBrotha_Backend $backend, MediaBrotha_Media $media, $buffer = NULL) {</span>
<span style="color: #00A000">+        public function __construct(MediaBrotha_Backend $backend, $buffer = NULL) {</span>
                $this->_backend = $backend;
<span style="color: #A00000">-                $this->_media = $media;</span>
                if ($buffer) {
                        $this->_buffer = $buffer;
                } else {
</pre></div>
========================================================================<pre>
Summary of changes:
sathieu/cisco-xml/browser/index.php | 2 +-
sathieu/cisco-xml/lib/Cisco-XML/Cisco-XML.php | 4 +-
sathieu/cisco-xml/lib/MediaBrotha/Backend.php | 12 +--
.../lib/MediaBrotha/Backend/FileSystem.php | 33 +++++---
sathieu/cisco-xml/lib/MediaBrotha/Backend/LDAP.php | 79 ++++++++++++++++----
sathieu/cisco-xml/lib/MediaBrotha/Backend/Root.php | 14 +++-
sathieu/cisco-xml/lib/MediaBrotha/Backend/VLC.php | 6 --
sathieu/cisco-xml/lib/MediaBrotha/Core.php | 48 +++++++++---
.../lib/MediaBrotha/{Frontend.php => Form.php} | 28 ++++++-
sathieu/cisco-xml/lib/MediaBrotha/Frontend.php | 10 ++-
.../lib/MediaBrotha/Frontend/CiscoXML.php | 22 +++++-
.../cisco-xml/lib/MediaBrotha/Frontend/HTML.php | 69 ++++++++++++++++--
.../cisco-xml/lib/MediaBrotha/Frontend/HTTP.php | 10 ++-
sathieu/cisco-xml/lib/MediaBrotha/Media.php | 2 +-
.../cisco-xml/lib/MediaBrotha/MediaIterator.php | 4 +-
15 files changed, 262 insertions(+), 81 deletions(-)
copy sathieu/cisco-xml/lib/MediaBrotha/{Frontend.php => Form.php} (60%)
</pre>
<p>this email was generated because of /git/your-repo.git/hooks/post-receive by the file /git-core/contrib/hooks/post-receive-email<br />
For more info, see <a href="http://blog.chomperstomp.com/?p=630">http://blog.chomperstomp.com/?p=630</a>
-- <br />
FreeSWITCH user-contributed scripts, etc</p>