From ff8b88c2c1e24b0ee2e3daefd51f70c068198bad Mon Sep 17 00:00:00 2001
From: Tim Steiner <tsteiner2@unl.edu>
Date: Fri, 1 Aug 2008 17:22:43 +0000
Subject: [PATCH] More podcast producer stuff.

---
 library/Unl/Plist.php                   |  1 +
 library/Unl/Service/PodcastProducer.php | 31 ++++++++++++++++++++++---
 2 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/library/Unl/Plist.php b/library/Unl/Plist.php
index 0a7e33bf..82ae14b9 100644
--- a/library/Unl/Plist.php
+++ b/library/Unl/Plist.php
@@ -19,6 +19,7 @@ class Unl_Plist
 	static public function arrayToPlist($array)
 	{
 		$dom = new DOMDocument('1.0', 'UTF-8');
+		$dom->formatOutput = true;
 		$root = $dom->createElement('plist');
 		$root->setAttribute('version', '1.0');
 		$dom->appendChild($root);
diff --git a/library/Unl/Service/PodcastProducer.php b/library/Unl/Service/PodcastProducer.php
index 32fc3eca..12adb576 100644
--- a/library/Unl/Service/PodcastProducer.php
+++ b/library/Unl/Service/PodcastProducer.php
@@ -43,6 +43,17 @@ class Unl_Service_PodcastProducer extends Zend_Service_Abstract
         return Unl_Service_PodcastProducer_Workflow::fromXML($response);
     }
     
+    public function getWorkflow($uuid)
+    {
+    	$selectedWorkflow = null;
+    	foreach ($this->getWorkflows() as $workflow) {
+    		if ($workflow->getUuid() == $uuid) {
+    			$selectedWorkflow = $workflow;
+    		}
+    	}
+    	return $selectedWorkflow;
+    }
+    
     public function getCameras()
     {
         $uri = clone $this->_uri;
@@ -57,6 +68,17 @@ class Unl_Service_PodcastProducer extends Zend_Service_Abstract
         return Unl_Service_PodcastProducer_Camera::fromXML($response);
     }
     
+    public function getCamera($uuid)
+    {
+    	$selectedCamera = null;
+    	foreach ($this->getCameras() as $camera) {
+    		if ($camera->getUuid() == $uuid) {
+    			$selectedCamera = $camera;
+    		}
+    	}
+    	return $selectedCamera;
+    }
+    
     public function getCameraPreview(Unl_Service_PodcastProducer_Camera $camera)
     {
         curl_setopt($this->_curl, CURLOPT_URL, $camera->getPreviewUrl());
@@ -64,7 +86,7 @@ class Unl_Service_PodcastProducer extends Zend_Service_Abstract
         return $response;
     }
     
-    public function createForFile(Unl_Service_PodcastProducer_Workflow $workflow, $filePath)
+    public function createForFile(Unl_Service_PodcastProducer_Workflow $workflow, $filePath, $metadata = array())
     {	
     	$fileContents = file_get_contents($filePath);
     	$fileSize = strlen($fileContents);
@@ -101,13 +123,16 @@ class Unl_Service_PodcastProducer extends Zend_Service_Abstract
         
         echo $response . "\n\n\n";
         
+        $plist = Unl_Plist::arrayToPlist($metadata);
+        $plistLength = strlen($plist);
+        
         curl_setopt($this->_curl, CURLOPT_URL, $uploadUri);
         curl_setopt($this->_curl, CURLOPT_HTTPHEADER, array(
             'File-name: user_metadata.plist',
             'Recording-UUID: ' . $recordingUUID
         ));
         curl_setopt($this->_curl, CURLOPT_POST, true);
-        curl_setopt($this->_curl, CURLOPT_POSTFIELDS, '');
+        curl_setopt($this->_curl, CURLOPT_POSTFIELDS, $plist);
         $response = curl_exec($this->_curl);
         
         echo $response . "\n\n\n";
@@ -118,7 +143,7 @@ class Unl_Service_PodcastProducer extends Zend_Service_Abstract
         curl_setopt($this->_curl, CURLOPT_POST, true);
         curl_setopt($this->_curl, CURLOPT_POSTFIELDS, 
               'submission_uuid=' . $UUID
-            . '&submitted_files=user_metadata.plist:0;' . $fileName . ':' . $fileSize
+            . '&submitted_files=user_metadata.plist:' . $plistLength . ';' . $fileName . ':' . $fileSize
             . '&primary_content_file=' . $fileName
             . '&recording_uuid=' . $recordingUUID
         );
-- 
GitLab