Ejemplo n.º 1
0
 public function testGetMediaFileExtension()
 {
     $media = new Media();
     $media->setProviderReference('https://sonata-project.org/bundles/sonatageneral/images/logo-small.png?some-query-string=1');
     $this->assertSame('png', $media->getExtension(), 'extension should not contain query strings');
     $media->setProviderReference('https://sonata-project.org/bundles/sonatageneral/images/logo-small.png#some-hash');
     $this->assertSame('png', $media->getExtension(), 'extension should not contain hashes');
     $media->setProviderReference('https://sonata-project.org/bundles/sonatageneral/images/logo-small.png?some-query-string=1#with-some-hash');
     $this->assertSame('png', $media->getExtension(), 'extension should not contain query strings or hashes');
 }
Ejemplo n.º 2
0
 function getFileURL()
 {
     if ($this->type == 'image') {
         // we get the area instance
         $url = SITE_WEB_DIRECTORY . MEDIA_BASE_DIRECTORY . '/' . $this->area_id . '/' . $this->filename;
     } else {
         if ($this->access == 'STREAMING') {
             include_class('config');
             $conf = new Config();
             $streamingAudioServerURL = $conf->getSetting('streamingAudioServerURL');
             $url = $streamingAudioServerURL . '/' . basename($this->protected_filename, Media::getExtension($this->protected_filename)) . 'pls';
         } else {
             $url = SITE_WEB_DIRECTORY . MEDIA_ORIGINALS_DIRECTORY . '/' . date('Ymd', strtotime($this->date_time)) . '/' . $this->filename_original;
         }
     }
     return $url;
 }
Ejemplo n.º 3
0
 function generateAudioFilename($filename)
 {
     // takes a track ID, generates a unique audio filename that makes sense for that track
     // compilation of track name w/underscores, track number, and a random number (if necessary)
     // we assume the track ID is valid
     require_once CLASSES . '/m2.php';
     $title = $this->getNumber() . '_' . Media::sanitizeFile($this->getTitle()) . '.' . Media::getExtension($filename);
     if (file_exists(AUDIO_DIRECTORY . '/' . $title)) {
         $rand = rand('0000', '9999');
         $title = $rand . $title;
     }
     return $title;
 }