Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/lib/zend/Zend/Gdata/App/MediaFileSource.php
Go to the documentation of this file.
00001 <?php
00002 
00027 require_once 'Zend/Gdata/App/BaseMediaSource.php';
00028 
00038 class Zend_Gdata_App_MediaFileSource extends Zend_Gdata_App_BaseMediaSource
00039 {
00045     protected $_filename = null;
00046 
00052     protected $_contentType = null;
00053 
00059     public function __construct($filename)
00060     {
00061         $this->setFilename($filename);
00062     }
00063 
00070     public function encode()
00071     {
00072         if ($this->getFilename() !== null &&
00073             is_readable($this->getFilename())) {
00074 
00075             // Retrieves the file, using the include path
00076             $fileHandle = fopen($this->getFilename(), 'r', true);
00077             $result = fread($fileHandle, filesize($this->getFilename()));
00078             if ($result === false) {
00079                 require_once 'Zend/Gdata/App/IOException.php';
00080                 throw new Zend_Gdata_App_IOException("Error reading file - " .
00081                         $this->getFilename() . '. Read failed.');
00082             }
00083             fclose($fileHandle);
00084             return $result;
00085         } else {
00086             require_once 'Zend/Gdata/App/IOException.php';
00087             throw new Zend_Gdata_App_IOException("Error reading file - " .
00088                     $this->getFilename() . '. File is not readable.');
00089         }
00090     }
00091 
00097     public function getFilename()
00098     {
00099         return $this->_filename;
00100     }
00101 
00108     public function setFilename($value)
00109     {
00110         $this->_filename = $value;
00111         return $this;
00112     }
00113 
00119     public function getContentType()
00120     {
00121         return $this->_contentType;
00122     }
00123 
00130     public function setContentType($value)
00131     {
00132         $this->_contentType = $value;
00133         return $this;
00134     }
00135 
00141     public function __toString()
00142     {
00143         return $this->getFilename();
00144     }
00145 
00146 }
 All Data Structures Namespaces Files Functions Variables Enumerations