/**
  * Gets a jingle of the station.
  *
  * @param	integer	$index	Format index of the jingle in the $audioFormats global variable
  * @return	mixed	Returns the path of the jingle if exist, else return boolean false
  * @use	$audioFormats
  */
 function getJingle($index)
 {
     global $audioFormats;
     $file = $this->getStationDir() . '/jingle_' . sotf_AudioCheck::getFormatFilename($index);
     if (is_file($file) && !is_file($file . '.lock')) {
         return $file;
     } else {
         return false;
         //return new PEAR_Error($stationId . " has no jingle!");
     }
 }
Пример #2
0
 function addProg($prg, $fileid = '')
 {
     if (empty($fileid)) {
         // find a file to listen
         $fileid = $prg->selectFileToListen();
         if (!$fileid) {
             raiseError("no_file_to_listen");
         }
     }
     $file = new sotf_NodeObject("sotf_media_files", $fileid);
     if (!$prg->isLocal()) {
         $node = sotf_Node::getNodeById($file->getNodeId());
         $path = $node->get('url') . "/listen.php?id=" . $prg->id . "&fileid=" . $file->id;
         $this->add(array('path' => $path, 'url' => $path));
         return;
     }
     if ($prg->get('published') != 't' || $file->get('stream_access') != 't') {
         raiseError("no_listen_access");
     }
     $filepath = $prg->getFilePath($file);
     $index = sotf_AudioCheck::getRequestIndex(new sotf_AudioFile($filepath));
     debug("audio index", $index);
     if (!$index) {
         $index = '0';
     }
     // add jingle for station (if exists)
     $station = $prg->getStation();
     $jfile = $station->getJingle($index);
     if ($jfile) {
         $this->add(array('id' => $station->id, 'path' => $jfile, 'jingle' => 1, 'name' => 'station_jingle'));
     }
     // add jingle for series (if exists)
     $series = $prg->getSeries();
     if ($series) {
         $jfile = $series->getJingle($index);
         if ($jfile) {
             $this->add(array('id' => $series->id, 'path' => $jfile, 'jingle' => 1, 'name' => 'series_jingle'));
         }
     }
     // add program file
     $filepath = $prg->getFilePath($file);
     $this->add(array('id' => $prg->id, 'path' => $filepath, 'name' => urlencode($prg->get('title'))));
     // temp: set title
     $title = $prg->get("title");
     $title = preg_replace('/\\s+/', '_', $title);
     $this->name = urlencode($title);
     // save stats
     $prg->addStat($file->get('id'), 'listens');
 }
 /**
  * Gets a jingle of the station.
  *
  * @param	integer	$index	Format index of the jingle in the $config['audioFormats'] global variable
  * @return	mixed	Returns the path of the jingle if exist, else return boolean false
  * @use	$config['audioFormats']
  */
 function getJingle($index = 0)
 {
     global $config;
     $file = $this->getMetaDir() . '/jingle_' . sotf_AudioCheck::getFormatFilename($index);
     debug("searching for", $file);
     if (is_file($file) && !is_file($file . '.lock')) {
         return $file;
     }
     $file = '';
     $jdir = $this->getMetaDir();
     if (is_dir($jdir)) {
         $d = dir($jdir);
         while ($entry = $d->read()) {
             if (substr($entry, 0, 6) == 'jingle_') {
                 $file = $jdir . '/' . $entry;
                 break;
             }
         }
         $d->close();
     }
     debug("2nd round", $file);
     if ($file) {
         return $file;
     } else {
         return false;
     }
 }