示例#1
0
 public function indexAction()
 {
     $request = $this->getRequest();
     if ($request->ext == 'mp3') {
         $table = new Model_DbTable_Recordings();
         $select = $table->select()->where('id = ?', $request->id);
         $path = UPLOAD_PATH . '/recordings/' . $request->id . '.mp3';
         if (($row = $table->fetchRow($select)) && file_exists($path)) {
             $pattern = array('/ - /', '/\\s+/');
             $replace = array('-', '_');
             $filename = preg_replace($pattern, $replace, $row->title) . '.mp3';
             $this->_helper->sendFile($path, 'audio/mpeg', array('filename' => $filename));
         }
     } elseif (in_array($request->ext, array('pdf', 'mid'))) {
         $table = new Model_DbTable_Downloads();
         $select = $table->select()->where('id = ?', $request->id)->where('type = ?', $request->ext == 'pdf' ? 'PDF' : 'MIDI');
         $path = UPLOAD_PATH . '/sheets/' . $request->id . '.' . $request->ext;
         $mime = $request->ext == 'pdf' ? 'application/pdf' : 'audio/midi';
         if (($row = $table->fetchRow($select)) && file_exists($path)) {
             $pattern = array('/ - /', '/\\s+/');
             $replace = array('-', '_');
             $filename = preg_replace($pattern, $replace, $row->title) . '.' . $request->ext;
             $this->_helper->sendFile($path, $mime, array('filename' => $filename));
         }
     }
     exit;
 }
示例#2
0
文件: Row.php 项目: hollusion/Netons
 public function getRecordings()
 {
     $table = new Model_DbTable_Recordings();
     $select = $table->select();
     $select->where('sheet_id = ?', $this->id);
     $select->order('created ASC');
     return $table->fetchAll($select);
 }