Пример #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
 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);
 }
Пример #3
0
 public function addrecordingAction()
 {
     if (!$this->view->authenticated) {
         $this->_redirector->gotoRoute(array(), 'login');
     }
     $request = $this->getRequest();
     $form = new Form_Recording();
     if ($request->isPost() && $form->isValid($request->getPost())) {
         $table = new Model_DbTable_Recordings();
         $row = $table->createRow($form->getValues());
         $row->sheet_id = $request->id;
         $row->user_id = $this->view->identity->id;
         $row->created = null;
         $row->save();
         $file = $form->file;
         $file->addFilter('Rename', array('target' => $row->id . '.mp3'));
         $file->receive();
         return $this->_redirector->gotoRoute(array('controller' => 'sheet', 'id' => $request->id), 'view');
     }
     $this->view->headTitle('Add recording');
     $this->view->form = $form;
 }