Project "FreeSWITCH user-contributed scripts, etc" received a push.

branch: master updated

       via: d9ed290a32fd5dfd4401b02652e07c892126d7c6 (commit)
      from: 078d663ef932223e27db8166e074cc4f4542a339 (commit)


= COMMIT LOG ===========================================================
committer: Mathieu Parent
comments: 
MediaBrotha: LDAP search form
And more:
- callback
- rework of actions
- exceptions handling
- forms

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

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%)

this email was generated because of /git/your-repo.git/hooks/post-receive by the file /git-core/contrib/hooks/post-receive-email
For more info, see http://blog.chomperstomp.com/?p=630 --
FreeSWITCH user-contributed scripts, etc