<h1>Project "FreeSWITCH user-contributed scripts, etc" received a push.</h1>

<h2>branch: master updated</h2>
<pre>
       via: 9ecdde39b5fb94c4708b530a7c90e82900ff15ed (commit)
      from: 69415c934e4b3dc70b22816aa847706336c442f5 (commit)


</pre>= COMMIT LOG ===========================================================
<div class="highlight"><pre>committer: Mathieu Parent
comments: 
MediaBrotha: various enhancements
<span style="color: #A00000">- add a HTML frontend</span>
<span style="color: #A00000">- frontend choosen automaticaly depending on browser</span>
<span style="color: #A00000">- handling of parent media</span>
<span style="color: #A00000">- max length for metadata and display_name</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 d142ff5..137b409 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">@@ -35,7 +35,11 @@ require_once(&#39;MediaBrotha/Core.php&#39;);</span>
 
 // Init
 MediaBrotha_Core::init();
<span style="color: #A00000">-MediaBrotha_Core::connectFrontend(&#39;CiscoXML&#39;, Array(&#39;push_url&#39; =&gt; &#39;http://cisco:cisco@192.168.0.220/CGI/Execute&#39;));</span>
<span style="color: #00A000">+if (CiscoIPPhone::userAgentIsCiscoIPPhone()) {</span>
<span style="color: #00A000">+        MediaBrotha_Core::connectFrontend(&#39;CiscoXML&#39;, Array(&#39;push_url&#39; =&gt; &#39;http://cisco:cisco@192.168.0.220/CGI/Execute&#39;));</span>
<span style="color: #00A000">+} else {</span>
<span style="color: #00A000">+        MediaBrotha_Core::connectFrontend(&#39;HTML&#39;);</span>
<span style="color: #00A000">+}</span>
 
 // Backends
 MediaBrotha_Core::loadBackend(&#39;FileSystem&#39;, Array(&#39;base_path&#39; =&gt; &#39;/home/share/music/&#39;));
<span style="color: #800080; font-weight: bold">@@ -51,10 +55,9 @@ $ldap_connect_config = Array(</span>
 MediaBrotha_Core::loadBackend(&#39;LDAP&#39;, Array(&#39;ldap_connect_config&#39; =&gt; $ldap_connect_config));
 
 // Roots
<span style="color: #A00000">-MediaBrotha_Core::addRootMedia(&#39;file:///home/share/music/&#39;, Array(&#39;name&#39;=&gt; &#39;Fichiers&#39;));</span>
<span style="color: #A00000">-MediaBrotha_Core::addRootMedia(&#39;ldap:///&#39;, Array(&#39;name&#39;=&gt; &#39;Annuaire&#39;));</span>
<span style="color: #00A000">+MediaBrotha_Core::addRootMedia(&#39;file:///home/share/music/&#39;, Array(&#39;display_name&#39;=&gt; &#39;Fichiers&#39;));</span>
<span style="color: #00A000">+MediaBrotha_Core::addRootMedia(&#39;ldap:///&#39;, Array(&#39;display_name&#39;=&gt; &#39;Annuaire&#39;));</span>
 
 MediaBrotha_Core::go();
 
 
<span style="color: #A00000">-</span>
<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 c711f9c..216aad6 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">@@ -23,6 +23,12 @@ This file is part of XML services for Cisco IP Phones.</span>
 /**
  * @author Mathieu Parent
  */
<span style="color: #00A000">+class CiscoIPPhone {</span>
<span style="color: #00A000">+        static public function userAgentIsCiscoIPPhone() {</span>
<span style="color: #00A000">+                return preg_match(&#39;/^Allegro-Software-WebClient\//&#39;, $_SERVER[&#39;HTTP_USER_AGENT&#39;]);</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+}</span>
 
 class CiscoXMLField {
         private $_allowed_fields = NULL;
<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 84a6a89..28a8441 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">@@ -71,12 +71,17 @@ class MediaBrotha_Backend {</span>
         }
 
         // Actions
<span style="color: #A00000">-        public function getMediaActions($uri = NULL, $mime_type = NULL, $mime_encoding = NULL) {</span>
<span style="color: #00A000">+        public function getMediaActions(MediaBrotha_Media $media) {</span>
                 return Array();
         }
 
         public function doMediaAction($action, MediaBrotha_Media $media) {
                 return false;
         }
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        // Populate</span>
<span style="color: #00A000">+        public function populateMedia(MediaBrotha_Media $media) {</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/Backend/FileSystem.php b/sathieu/cisco-xml/lib/MediaBrotha/Backend/FileSystem.php</span>
<span style="color: #000080; font-weight: bold">index 39928b4..006814b 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">@@ -40,10 +40,13 @@ class MediaBrotha_Backend_FileSystem extends MediaBrotha_Backend {</span>
         // Browsing
         public function mediaFromBufferItem($file) {
                 if ($file) {
<span style="color: #00A000">+                        if ($file-&gt;getFilename() === &#39;..&#39;) {</span>
<span style="color: #00A000">+                                return NULL;</span>
<span style="color: #00A000">+                        }</span>
                         $media = new MediaBrotha_Media(
                                 &#39;file://&#39;.realpath($file-&gt;getPathname()),
                                 Array(
<span style="color: #A00000">-                                        &#39;name&#39; =&gt; $file-&gt;getFilename(),</span>
<span style="color: #00A000">+                                        &#39;display_name&#39; =&gt; $file-&gt;getFilename(),</span>
                                         &#39;hidden&#39; =&gt; !$file-&gt;isReadable() || preg_match(&#39;/^\.([^.]|$)/&#39;, $file-&gt;getFilename()),
                                 )
                         );
<span style="color: #800080; font-weight: bold">@@ -59,31 +62,47 @@ class MediaBrotha_Backend_FileSystem extends MediaBrotha_Backend {</span>
         }
 
         public function fetch(MediaBrotha_Media $media) {
<span style="color: #A00000">-                $uri =$media-&gt;getURI();</span>
<span style="color: #00A000">+                $uri = $media-&gt;getURI();</span>
                 if ((parse_url($uri, PHP_URL_SCHEME) != &#39;file&#39;) || !$this-&gt;isURISafe($uri)) {
<span style="color: #A00000">-                        $uri = &#39;file://&#39;.$this-&gt;getMetadata(&#39;base_path&#39;);</span>
<span style="color: #00A000">+                        $uri = &#39;file://&#39;.$this-&gt;getParam(&#39;base_path&#39;);</span>
                 }
                 $path = parse_url($uri, PHP_URL_PATH);
                 if (is_dir($path)) {
                         return new MediaBrotha_MediaIterator($this, $media, new DirectoryIterator($path));
                 } else {
<span style="color: #A00000">-                        $this-&gt;setURI(NULL);</span>
                         return false;
                 }
         }
 
         // Actions
<span style="color: #A00000">-        public function getMediaActions($uri = NULL, $mime_type = NULL, $mime_encoding = NULL) {</span>
<span style="color: #A00000">-                if ($mime_type === &#39;application/x-directory&#39;) {</span>
<span style="color: #A00000">-                        return Array(</span>
<span style="color: #A00000">-                                &#39;browse&#39;,</span>
<span style="color: #A00000">-                        );</span>
<span style="color: #A00000">-                } elseif ($uri &amp;&amp; (substr($uri, 0, 7) === &#39;file://&#39;)) {</span>
<span style="color: #00A000">+        protected function _isHandled(MediaBrotha_Media $media) {</span>
<span style="color: #00A000">+                return ($media-&gt;getMimeType() === &#39;application/x-directory&#39;)</span>
<span style="color: #00A000">+                        || (substr($media-&gt;getURI(), 0, 7) === &#39;file://&#39;);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        public function getMediaActions(MediaBrotha_Media $media) {</span>
<span style="color: #00A000">+                if ($this-&gt;_isHandled($media)) {</span>
                         return Array(
                                 &#39;browse&#39;,
                         );
                 } else {
<span style="color: #A00000">-                        return parent::getMediaActions($uri, $mime_type, $mime_encoding);</span>
<span style="color: #00A000">+                        return parent::getMediaActions($media);</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        // Populate</span>
<span style="color: #00A000">+        public function populateMedia(MediaBrotha_Media $media) {</span>
<span style="color: #00A000">+                if ($this-&gt;_isHandled($media)) {</span>
<span style="color: #00A000">+                        $parent_path = &#39;file://&#39;.dirname(parse_url($media-&gt;getURI(), PHP_URL_PATH));</span>
<span style="color: #00A000">+                        if ($this-&gt;isURISafe($parent_path)) {</span>
<span style="color: #00A000">+                                $media-&gt;setParent(</span>
<span style="color: #00A000">+                                        new MediaBrotha_Media($parent_path,</span>
<span style="color: #00A000">+                                                Array(</span>
<span style="color: #00A000">+                                                        &#39;display_name&#39; =&gt; &#39;..&#39;,</span>
<span style="color: #00A000">+                                                )</span>
<span style="color: #00A000">+                                        )</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/Backend/LDAP.php b/sathieu/cisco-xml/lib/MediaBrotha/Backend/LDAP.php</span>
<span style="color: #000080; font-weight: bold">index c882dd7..365e78e 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">@@ -54,7 +54,7 @@ class MediaBrotha_Backend_LDAP extends MediaBrotha_Backend {</span>
                         $media = new MediaBrotha_Media(
                                 &#39;ldap:///&#39;.$entry-&gt;dn(),
                                 Array(
<span style="color: #A00000">-                                        &#39;name&#39; =&gt; $entry-&gt;dn(), //$entry-&gt;getValue(&#39;sn&#39;, &#39;single&#39;),</span>
<span style="color: #00A000">+                                        &#39;display_name&#39; =&gt; $entry-&gt;dn(), //$entry-&gt;getValue(&#39;sn&#39;, &#39;single&#39;),</span>
                                 ),
                                 &#39;text/directory&#39;
                                 //$finfo-&gt;file($file-&gt;getPathname(), FILEINFO_MIME_ENCODING);
<span style="color: #800080; font-weight: bold">@@ -79,17 +79,18 @@ class MediaBrotha_Backend_LDAP extends MediaBrotha_Backend {</span>
                 return true;
         }
         // Actions
<span style="color: #A00000">-        public function getMediaActions($uri = NULL, $mime_type = NULL, $mime_encoding = NULL) {</span>
<span style="color: #A00000">-                if ($mime_type === &#39;text/directory&#39;) {</span>
<span style="color: #A00000">-                        return Array(</span>
<span style="color: #A00000">-                                &#39;browse&#39;,</span>
<span style="color: #A00000">-                        );</span>
<span style="color: #A00000">-                } elseif ($uri &amp;&amp; (substr($uri, 0, 7) === &#39;ldap://&#39;)) {</span>
<span style="color: #00A000">+        protected function _isHandled(MediaBrotha_Media $media) {</span>
<span style="color: #00A000">+                return ($media-&gt;getMimeType() === &#39;text/directory&#39;)</span>
<span style="color: #00A000">+                        || (substr($media-&gt;getURI(), 0, 7) === &#39;ldap://&#39;);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        public function getMediaActions(MediaBrotha_Media $media) {</span>
<span style="color: #00A000">+                if ($this-&gt;_isHandled($media)) {</span>
                         return Array(
                                 &#39;browse&#39;,
                         );
                 } else {
<span style="color: #A00000">-                        return parent::getMediaActions($uri, $mime_type, $mime_encoding);</span>
<span style="color: #00A000">+                        return parent::getMediaActions($media);</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 addba42..9616be8 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">@@ -30,11 +30,18 @@ class MediaBrotha_Backend_Root extends MediaBrotha_Backend {</span>
 
         public function __construct($params = NULL) {
                 parent::__construct($params);
<span style="color: #A00000">-                $this-&gt;_media = new MediaBrotha_Media(&#39;MediaBrotha:///&#39;);</span>
<span style="color: #00A000">+                $this-&gt;_media = new MediaBrotha_Media(&#39;MediaBrotha:///&#39;,</span>
<span style="color: #00A000">+                        Array(</span>
<span style="color: #00A000">+                                &#39;display_name&#39; =&gt; &#39;Root&#39;,</span>
<span style="color: #00A000">+                        )</span>
<span style="color: #00A000">+                );</span>
                 $this-&gt;_media_iterator = new MediaBrotha_MediaIterator($this, $this-&gt;_media);
         }
 
<span style="color: #A00000">-        public function addRootMedia($media) {</span>
<span style="color: #00A000">+        public function addRootMedia($URI, array $metadata = Array(), $mime_type = NULL, $mime_encoding = NULL) {</span>
<span style="color: #00A000">+                $this-&gt;addRootMediaObj(new MediaBrotha_Media($URI, $metadata, $mime_type,$mime_encoding));</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        public function addRootMediaObj($media) {</span>
                 $this-&gt;_media_iterator-&gt;bufferAdd($media);
         }
 
<span style="color: #800080; font-weight: bold">@@ -42,13 +49,6 @@ class MediaBrotha_Backend_Root extends MediaBrotha_Backend {</span>
         public function fetch(MediaBrotha_Media $media) {
                 return $this-&gt;_media_iterator;
         }
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        // Actions</span>
<span style="color: #A00000">-        public function getMediaActions($uri = NULL, $mime_type = NULL, $mime_encoding = NULL) {</span>
<span style="color: #A00000">-                return Array(</span>
<span style="color: #A00000">-                );</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-</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 2b4e7c6..8c3208e 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">@@ -50,17 +50,13 @@ class MediaBrotha_Backend_VLC extends MediaBrotha_Backend {</span>
         }
 
         // Actions
<span style="color: #A00000">-        public function getMediaActions($uri = NULL, $mime_type = NULL, $mime_encoding = NULL) {</span>
<span style="color: #A00000">-                if (in_array($mime_type, Array($this::$_supported_mime_types))) {</span>
<span style="color: #A00000">-                        return Array(</span>
<span style="color: #A00000">-                                &#39;play_media&#39;,</span>
<span style="color: #A00000">-                                &#39;pause_media&#39;,</span>
<span style="color: #A00000">-                                &#39;stop_media&#39;,</span>
<span style="color: #A00000">-                                &#39;enqueue_media&#39;,</span>
<span style="color: #A00000">-                                &#39;next_media&#39;,</span>
<span style="color: #A00000">-                                &#39;previous_media&#39;,</span>
<span style="color: #A00000">-                        );</span>
<span style="color: #A00000">-                } elseif ($uri &amp;&amp; (substr($uri, 0, 7) === &#39;file://&#39;)) {</span>
<span style="color: #00A000">+        protected function _isHandled(MediaBrotha_Media $media) {</span>
<span style="color: #00A000">+                return in_array($media-&gt;getMimeType(), Array($this::$_supported_mime_types))</span>
<span style="color: #00A000">+                        || (substr($media-&gt;getURI(), 0, 7) === &#39;file://&#39;);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        public function getMediaActions(MediaBrotha_Media $media) {</span>
<span style="color: #00A000">+                if ($this-&gt;_isHandled($media)) {</span>
                         return Array(
                                 &#39;play_media&#39;,
                                 &#39;pause_media&#39;,
<span style="color: #800080; font-weight: bold">@@ -70,7 +66,7 @@ class MediaBrotha_Backend_VLC extends MediaBrotha_Backend {</span>
                                 &#39;previous_media&#39;,
                         );
                 } else {
<span style="color: #A00000">-                        return parent::getMediaActions($uri, $mime_type, $mime_encoding);</span>
<span style="color: #00A000">+                        return parent::getMediaActions($media);</span>
                 }
         }
         public function doMediaAction($action, MediaBrotha_Media $media) {
<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 5ec90e8..8997a7c 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">@@ -34,47 +34,17 @@ class MediaBrotha_Core {</span>
         private static $_backends = Array();
         private static $_media = NULL;
         
<span style="color: #00A000">+        /*</span>
<span style="color: #00A000">+         * Core</span>
<span style="color: #00A000">+         */</span>
         public static function init() {
                 if (!session_start()) {
                         die(&#39;Unable to start session&#39;);
                 }
<span style="color: #A00000">-                if (!isset($_SESSION[&#39;HASHES&#39;])) {</span>
<span style="color: #A00000">-                        $_SESSION[&#39;HASHES&#39;] = Array();</span>
<span style="color: #A00000">-                }</span>
<span style="color: #A00000">-                if (isset($_SERVER[&quot;QUERY_STRING&quot;])) {</span>
<span style="color: #A00000">-                        $tmp = explode(&#39;&amp;&#39;, $_SERVER[&quot;QUERY_STRING&quot;]);</span>
<span style="color: #A00000">-                        foreach ($tmp as $h) {</span>
<span style="color: #A00000">-                                if (preg_match(&#39;/^[a-z0-9]+$/&#39;, $h)) {</span>
<span style="color: #A00000">-                                        if ($s = MediaBrotha_Core::hash2string($h)) {</span>
<span style="color: #A00000">-                                                parse_str($s, $output);</span>
<span style="color: #A00000">-                                                $_GET = array_merge($_GET, $output);</span>
<span style="color: #A00000">-                                        }</span>
<span style="color: #A00000">-                                }</span>
<span style="color: #A00000">-                        }</span>
<span style="color: #A00000">-                }</span>
<span style="color: #00A000">+                MediaBrotha_Core::_unhashRequest();</span>
                 MediaBrotha_Core::loadBackend(&#39;Root&#39;);
         }
 
<span style="color: #A00000">-        public static function hash2string($h) {</span>
<span style="color: #A00000">-                if (isset($_SESSION[&#39;HASHES&#39;][$h])) {</span>
<span style="color: #A00000">-                        return $_SESSION[&#39;HASHES&#39;][$h];</span>
<span style="color: #A00000">-                } else {</span>
<span style="color: #A00000">-                        //print &#39;NO string for hash &#39;.$h;</span>
<span style="color: #A00000">-                        return NULL;</span>
<span style="color: #A00000">-                }</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-        public static function string2hash($s) {</span>
<span style="color: #A00000">-                for($hash_length = 1 ; $hash_length &lt;=41 ; $hash_length++) {</span>
<span style="color: #A00000">-                        $h = substr(sha1($s), 0, $hash_length);</span>
<span style="color: #A00000">-                        if (!isset($_SESSION[&#39;HASHES&#39;][$h]) || ($_SESSION[&#39;HASHES&#39;][$h] === $s)) {</span>
<span style="color: #A00000">-                                break;</span>
<span style="color: #A00000">-                        }</span>
<span style="color: #A00000">-                }</span>
<span style="color: #A00000">-                $_SESSION[&#39;HASHES&#39;][$h] = $s;</span>
<span style="color: #A00000">-                return $h;</span>
<span style="color: #A00000">-        }</span>
<span style="color: #A00000">-</span>
         public static function go() {
                 $current_backend = MediaBrotha_Core::getCurrentBackend();
                 $current_media = MediaBrotha_Core::getCurrentMedia();
<span style="color: #800080; font-weight: bold">@@ -82,7 +52,7 @@ class MediaBrotha_Core {</span>
                         if ($media_iterator = $current_backend-&gt;fetch($current_media)) {
                                 MediaBrotha_Core::$_frontend-&gt;begin($current_media);
                                 foreach ($media_iterator as $item) {
<span style="color: #A00000">-                                        if ($item-&gt;isHidden()) {</span>
<span style="color: #00A000">+                                        if (($item === NULL) || $item-&gt;isHidden()) {</span>
                                                 continue;
                                         }
                                         MediaBrotha_Core::$_frontend-&gt;addItem($item);
<span style="color: #800080; font-weight: bold">@@ -97,10 +67,9 @@ class MediaBrotha_Core {</span>
         }
 
         public function addRootMedia($URI, array $metadata = Array(), $mime_type = NULL, $mime_encoding = NULL) {
<span style="color: #A00000">-                MediaBrotha_Core::$_backends[&#39;Root&#39;]-&gt;addRootMedia(</span>
<span style="color: #A00000">-                        new MediaBrotha_Media($URI, $metadata, $mime_type,$mime_encoding)</span>
<span style="color: #A00000">-                );</span>
<span style="color: #00A000">+                MediaBrotha_Core::$_backends[&#39;Root&#39;]-&gt;addRootMedia($URI, $metadata, $mime_type, $mime_encoding);</span>
         }
<span style="color: #00A000">+</span>
         /*
          * Backends
          */
<span style="color: #800080; font-weight: bold">@@ -120,22 +89,7 @@ class MediaBrotha_Core {</span>
         public static function getBackends() {
                 return MediaBrotha_Core::$_backends;
         }
<span style="color: #A00000">-        public static function getCurrentBackend() {</span>
<span style="color: #A00000">-                if (!empty($_GET[&#39;backend&#39;]) &amp;&amp; !empty(MediaBrotha_Core::$_backends[$_GET[&#39;backend&#39;]])) {</span>
<span style="color: #A00000">-                        return MediaBrotha_Core::$_backends[$_GET[&#39;backend&#39;]];</span>
<span style="color: #A00000">-                }</span>
<span style="color: #A00000">-                foreach (MediaBrotha_Core::getBackends() as $backend) {</span>
<span style="color: #A00000">-                        foreach ($backend-&gt;getMediaActions(MediaBrotha_Core::getCurrentURI()) as $action) {</span>
<span style="color: #A00000">-                                if ($backend-&gt;getBackendName() == &#39;Root&#39;) {</span>
<span style="color: #A00000">-                                        continue;</span>
<span style="color: #A00000">-                                }</span>
<span style="color: #A00000">-                                if ($action === MediaBrotha_Core::getAction()) {</span>
<span style="color: #A00000">-                                        return $backend;</span>
<span style="color: #A00000">-                                }</span>
<span style="color: #A00000">-                        }</span>
<span style="color: #A00000">-                }</span>
<span style="color: #A00000">-                return MediaBrotha_Core::$_backends[&#39;Root&#39;];</span>
<span style="color: #A00000">-        }</span>
<span style="color: #00A000">+</span>
         /*
          * Frontend
          */
<span style="color: #800080; font-weight: bold">@@ -151,8 +105,26 @@ class MediaBrotha_Core {</span>
                 MediaBrotha_Core::$_frontend = new $class_name($args);
         }
         /*
<span style="color: #A00000">-         * ...</span>
<span style="color: #00A000">+         * Current *</span>
          */
<span style="color: #00A000">+        public static function getCurrentBackend() {</span>
<span style="color: #00A000">+                if (!empty($_GET[&#39;backend&#39;]) &amp;&amp; !empty(MediaBrotha_Core::$_backends[$_GET[&#39;backend&#39;]])) {</span>
<span style="color: #00A000">+                        return MediaBrotha_Core::$_backends[$_GET[&#39;backend&#39;]];</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+                $current_media = MediaBrotha_Core::getCurrentMedia();</span>
<span style="color: #00A000">+                foreach (MediaBrotha_Core::getBackends() as $backend) {</span>
<span style="color: #00A000">+                        foreach ($backend-&gt;getMediaActions($current_media) as $action) {</span>
<span style="color: #00A000">+                                if ($backend-&gt;getBackendName() == &#39;Root&#39;) {</span>
<span style="color: #00A000">+                                        continue;</span>
<span style="color: #00A000">+                                }</span>
<span style="color: #00A000">+                                if ($action === MediaBrotha_Core::getAction()) {</span>
<span style="color: #00A000">+                                        return $backend;</span>
<span style="color: #00A000">+                                }</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+                return MediaBrotha_Core::$_backends[&#39;Root&#39;];</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
         public static function getAction() {
                 if (!empty($_GET[&#39;action&#39;])) {
                         return $_GET[&#39;action&#39;];
<span style="color: #800080; font-weight: bold">@@ -161,17 +133,63 @@ class MediaBrotha_Core {</span>
                 }
         }
 
<span style="color: #A00000">-        public static function getCurrentURI() {</span>
<span style="color: #A00000">-                if (!empty($_GET[&#39;uri&#39;])) {</span>
<span style="color: #A00000">-                        return (string) $_GET[&#39;uri&#39;];</span>
<span style="color: #A00000">-                }</span>
<span style="color: #A00000">-        }</span>
         public static function getCurrentMedia() {
                 if (empty(MediaBrotha_Core::$_media)) {
<span style="color: #A00000">-                        MediaBrotha_Core::$_media = new MediaBrotha_Media(MediaBrotha_Core::getCurrentURI());</span>
<span style="color: #00A000">+                        if (!empty($_GET[&#39;uri&#39;])) {</span>
<span style="color: #00A000">+                                MediaBrotha_Core::$_media = new MediaBrotha_Media($_GET[&#39;uri&#39;]);</span>
<span style="color: #00A000">+                        } else {</span>
<span style="color: #00A000">+                                MediaBrotha_Core::$_media = new MediaBrotha_Media(&#39;MediaBrotha:///&#39;);</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+                        foreach (MediaBrotha_Core::getBackends() as $backend) {</span>
<span style="color: #00A000">+                                $backend-&gt;populateMedia(MediaBrotha_Core::$_media);</span>
<span style="color: #00A000">+                        }</span>
                 }
                 return MediaBrotha_Core::$_media;
         }
 
<span style="color: #00A000">+        /*</span>
<span style="color: #00A000">+         * helper functions</span>
<span style="color: #00A000">+         */</span>
<span style="color: #00A000">+        /* hashes */</span>
<span style="color: #00A000">+        public static function hash2value($h) {</span>
<span style="color: #00A000">+                if (isset($_SESSION[&#39;HASHES&#39;][$h])) {</span>
<span style="color: #00A000">+                        return $_SESSION[&#39;HASHES&#39;][$h];</span>
<span style="color: #00A000">+                } else {</span>
<span style="color: #00A000">+                        return NULL;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        public static function value2hash($v) {</span>
<span style="color: #00A000">+                for($hash_length = 1 ; $hash_length &lt;=41 ; $hash_length++) {</span>
<span style="color: #00A000">+                        $h = substr(sha1($v), 0, $hash_length);</span>
<span style="color: #00A000">+                        if (!isset($_SESSION[&#39;HASHES&#39;][$h]) || ($_SESSION[&#39;HASHES&#39;][$h] === $v)) {</span>
<span style="color: #00A000">+                                break;</span>
<span style="color: #00A000">+                        }</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+                $_SESSION[&#39;HASHES&#39;][$h] = $v;</span>
<span style="color: #00A000">+                return $h;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        public static function hash2array($h) {</span>
<span style="color: #00A000">+                if ($v = MediaBrotha_Core::hash2value($h)) {</span>
<span style="color: #00A000">+                        parse_str($v, $output);</span>
<span style="color: #00A000">+                        return $output;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        private static function _unhashRequest() {</span>
<span style="color: #00A000">+                if (!isset($_SESSION[&#39;HASHES&#39;])) {</span>
<span style="color: #00A000">+                        $_SESSION[&#39;HASHES&#39;] = Array();</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+                if (isset($_SERVER[&quot;QUERY_STRING&quot;])) {</span>
<span style="color: #00A000">+                        $tmp = explode(&#39;&amp;&#39;, $_SERVER[&quot;QUERY_STRING&quot;]);</span>
<span style="color: #00A000">+                        foreach ($tmp as $h) {</span>
<span style="color: #00A000">+                                if (preg_match(&#39;/^[a-z0-9]+$/&#39;, $h)) {</span>
<span style="color: #00A000">+                                        $_GET = array_merge($_GET, MediaBrotha_Core::hash2array($h));</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">+</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 2baa6af..914e6ee 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">@@ -30,12 +30,15 @@ class MediaBrotha_Frontend_CiscoXML extends MediaBrotha_Frontend_HTTP {</span>
         private $_xml = NULL;
         public function begin($item) {
                 $this-&gt;_xml = new CiscoIPPhoneMenu();
<span style="color: #A00000">-                $this-&gt;_xml-&gt;setCiscoElement(&#39;Title&#39;, $item-&gt;getDisplayName());</span>
<span style="color: #00A000">+                $this-&gt;_xml-&gt;setCiscoElement(&#39;Title&#39;, $item-&gt;getDisplayName(32));</span>
                 $this-&gt;_xml-&gt;setCiscoElement(&#39;Prompt&#39;, substr($item-&gt;getURI(), -32));
<span style="color: #00A000">+                if ($parent = $item-&gt;getParent()) {</span>
<span style="color: #00A000">+                        $this-&gt;addItem($parent);</span>
<span style="color: #00A000">+                }</span>
         }
         public function addItem($item) {
                 $url = $this-&gt;rootURL().&#39;?&#39;.
<span style="color: #A00000">-                        MediaBrotha_Core::string2hash(</span>
<span style="color: #00A000">+                        MediaBrotha_Core::value2hash(</span>
                                 &#39;mime_type=&#39;.urlencode($item-&gt;getMimeType()).&#39;&amp;&#39;.
                                 ($item-&gt;getMimeEncoding() ? (&#39;mime_encoding=&#39;.urlencode($item-&gt;getMimeEncoding()).&#39;&amp;&#39;) : &#39;&#39;).
                                 &#39;uri=&#39;.urlencode($item-&gt;getURI()));
<span style="color: #800080; font-weight: bold">@@ -49,10 +52,10 @@ class MediaBrotha_Frontend_CiscoXML extends MediaBrotha_Frontend_HTTP {</span>
                         &#39;URL&#39; =&gt; &#39;SoftKey:Select&#39;,
                         &#39;Position&#39; =&gt; $pos++));
                 foreach (MediaBrotha_Core::getBackends() as $backend) {
<span style="color: #A00000">-                        foreach ($backend-&gt;getMediaActions(MediaBrotha_Core::getCurrentURI()) as $action) {</span>
<span style="color: #00A000">+                        foreach ($backend-&gt;getMediaActions(MediaBrotha_Core::getCurrentMedia()) as $action) {</span>
                                 $this-&gt;_xml-&gt;setCiscoElement(&#39;SoftKeyItem&#39;,
                                         Array(&#39;Name&#39; =&gt; $action,
<span style="color: #A00000">-                                        &#39;URL&#39; =&gt; &#39;QueryStringParam:&#39;.MediaBrotha_Core::string2hash(&#39;action=&#39;.$action.&#39;&amp;backend=&#39;.$backend-&gt;getBackendName()),</span>
<span style="color: #00A000">+                                        &#39;URL&#39; =&gt; &#39;QueryStringParam:&#39;.MediaBrotha_Core::value2hash(&#39;action=&#39;.$action.&#39;&amp;backend=&#39;.$backend-&gt;getBackendName()),</span>
                                         &#39;Position&#39; =&gt; $pos++));
                         }
                 }
<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 6efd1db..7964473 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">@@ -25,14 +25,15 @@ This file is part of MediaBrotha.</span>
  */
 
 class MediaBrotha_Media {
<span style="color: #A00000">-        private $_metadata = Array();</span>
<span style="color: #A00000">-</span>
         private $_URI = NULL;
<span style="color: #00A000">+        private $_metadata = Array();</span>
         private $_mimeType = NULL;
         private $_mimeEncoding = NULL;
 
<span style="color: #00A000">+        private $_parent = NULL;</span>
<span style="color: #00A000">+</span>
         public function __construct($URI, array $metadata = Array(), $mime_type = NULL, $mime_encoding = NULL) {
<span style="color: #A00000">-                 $this-&gt;setURI($URI);</span>
<span style="color: #00A000">+                 $this-&gt;_URI = $URI;</span>
                  $this-&gt;setMetadata($metadata);
                  $this-&gt;setMimeType($mime_type);
                  $this-&gt;setMimeEncoding($mime_encoding);
<span style="color: #800080; font-weight: bold">@@ -42,16 +43,17 @@ class MediaBrotha_Media {</span>
         public function getURI() {
                 return $this-&gt;_URI;
         }
<span style="color: #A00000">-        public function setURI($URI) {</span>
<span style="color: #A00000">-                $this-&gt;_URI = $URI;</span>
<span style="color: #A00000">-        }</span>
 
         /* metadata */
<span style="color: #A00000">-        public function getMetadata($name = NULL) {</span>
<span style="color: #00A000">+        public function getMetadata($name = NULL, $max_length = NULL) {</span>
                 if ($name === NULL) {
                         return $this-&gt;_metadata;
                 } elseif (isset($this-&gt;_metadata[$name])) {
<span style="color: #A00000">-                        return $this-&gt;_metadata[$name];</span>
<span style="color: #00A000">+                        if ($max_length) {</span>
<span style="color: #00A000">+                                return substr($this-&gt;_metadata[$name], 0, $max_length);</span>
<span style="color: #00A000">+                        } else {</span>
<span style="color: #00A000">+                                return $this-&gt;_metadata[$name];</span>
<span style="color: #00A000">+                        }</span>
                 } else {
                         return NULL;
                 }
<span style="color: #800080; font-weight: bold">@@ -60,6 +62,17 @@ class MediaBrotha_Media {</span>
                 if (is_array($name)) {
                         $this-&gt;_metadata = $name;
                 } else {
<span style="color: #00A000">+                        switch($name) {</span>
<span style="color: #00A000">+                                case &#39;hidden&#39;:</span>
<span style="color: #00A000">+                                case &#39;display_name&#39;:</span>
<span style="color: #00A000">+                                case &#39;Array&#39;:</span>
<span style="color: #00A000">+                                //music</span>
<span style="color: #00A000">+                                case &#39;artist&#39;:</span>
<span style="color: #00A000">+                                case &#39;album&#39;:</span>
<span style="color: #00A000">+                                        break;</span>
<span style="color: #00A000">+                                default:</span>
<span style="color: #00A000">+                                        print &quot;Unusual metadata &#39;$name&#39;.\n&quot;;</span>
<span style="color: #00A000">+                        }</span>
                         $this-&gt;_metadata[$name] = $value;
 
                 }
<span style="color: #800080; font-weight: bold">@@ -81,10 +94,22 @@ class MediaBrotha_Media {</span>
                 $this-&gt;_mimeEncoding = $mime_encoding;
         }
 
<span style="color: #00A000">+        /* parent */</span>
<span style="color: #00A000">+        public function getParent() {</span>
<span style="color: #00A000">+                return $this-&gt;_parent;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        public function setParent($parent) {</span>
<span style="color: #00A000">+                $this-&gt;_parent = $parent;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
         /* Most used metadata */
<span style="color: #A00000">-        public function getDisplayName($max_length = 0) {</span>
<span style="color: #A00000">-                if ($name = $this-&gt;getMetadata(&#39;name&#39;)) {</span>
<span style="color: #A00000">-                        return $name;</span>
<span style="color: #00A000">+        public function getDisplayName($max_length = NULL) {</span>
<span style="color: #00A000">+                if ($name = $this-&gt;getMetadata(&#39;display_name&#39;)) {</span>
<span style="color: #00A000">+                        if ($max_length) {</span>
<span style="color: #00A000">+                                return substr($name, 0, $max_length);</span>
<span style="color: #00A000">+                        } else {</span>
<span style="color: #00A000">+                                return $name;</span>
<span style="color: #00A000">+                        }</span>
                 } else {
                         return &#39;?&#39;;
                 }
<span style="color: #800080; font-weight: bold">@@ -97,13 +122,3 @@ class MediaBrotha_Media {</span>
         }
 }
 
<span style="color: #A00000">-/*</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-Mandatory metadata:</span>
<span style="color: #A00000">-uri</span>
<span style="color: #A00000">-name</span>
<span style="color: #A00000">-</span>
<span style="color: #A00000">-Usual metadata:</span>
<span style="color: #A00000">-artist</span>
<span style="color: #A00000">-album</span>
<span style="color: #A00000">-*/</span>
</pre></div>
========================================================================<pre>

Summary of changes:
 sathieu/cisco-xml/browser/index.php                |   11 +-
 sathieu/cisco-xml/lib/Cisco-XML/Cisco-XML.php      |    6 +
 sathieu/cisco-xml/lib/MediaBrotha/Backend.php      |    7 +-
 .../lib/MediaBrotha/Backend/FileSystem.php         |   41 ++++--
 sathieu/cisco-xml/lib/MediaBrotha/Backend/LDAP.php |   17 ++-
 sathieu/cisco-xml/lib/MediaBrotha/Backend/Root.php |   18 ++--
 sathieu/cisco-xml/lib/MediaBrotha/Backend/VLC.php  |   20 +--
 sathieu/cisco-xml/lib/MediaBrotha/Core.php         |  140 +++++++++++---------
 .../lib/MediaBrotha/Frontend/CiscoXML.php          |   11 +-
 sathieu/cisco-xml/lib/MediaBrotha/Media.php        |   57 +++++---
 10 files changed, 197 insertions(+), 131 deletions(-)
</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>