CC-2833: Use ClassLoaders for PHP Files

-made MusicDir, Playlist and StoredFile autoload
This commit is contained in:
martin 2011-09-22 12:24:17 -04:00
parent 4e79a88adc
commit 2be0960ed5
22 changed files with 124 additions and 551 deletions

View file

@ -97,7 +97,7 @@ class ApiController extends Zend_Controller_Action
$filename = $this->_getParam("file");
$file_id = substr($filename, 0, strpos($filename, "."));
if (ctype_alnum($file_id) && strlen($file_id) == 32) {
$media = StoredFile::RecallByGunid($file_id);
$media = Application_Model_StoredFile::RecallByGunid($file_id);
if ($media != null && !PEAR::isError($media)) {
$filepath = $media->getFilePath();
if(is_file($filepath)){
@ -330,9 +330,9 @@ class ApiController extends Zend_Controller_Action
}
$upload_dir = ini_get("upload_tmp_dir");
StoredFile::uploadFile($upload_dir);
Application_Model_StoredFile::uploadFile($upload_dir);
$fileName = isset($_REQUEST["name"]) ? $_REQUEST["name"] : '';
StoredFile::copyFileToStor($upload_dir, $fileName);
Application_Model_StoredFile::copyFileToStor($upload_dir, $fileName);
}
public function uploadRecordedAction()
@ -356,7 +356,7 @@ class ApiController extends Zend_Controller_Action
$showCanceled = false;
$file = StoredFile::Recall($file_id);
$file = Application_Model_StoredFile::Recall($file_id);
//$show_instance = $this->_getParam('show_instance');
$show_name = null;
@ -435,9 +435,9 @@ class ApiController extends Zend_Controller_Action
exit;
}
$this->view->stor = MusicDir::getStorDir()->getDirectory();
$this->view->stor = Application_Model_MusicDir::getStorDir()->getDirectory();
$watchedDirs = MusicDir::getWatchedDirs();
$watchedDirs = Application_Model_MusicDir::getWatchedDirs();
$watchedDirsPath = array();
foreach($watchedDirs as $wd){
$watchedDirsPath[] = $wd->getDirectory();
@ -475,10 +475,10 @@ class ApiController extends Zend_Controller_Action
$filepath = $md['MDATA_KEY_FILEPATH'];
$filepath = str_replace("\\", "", $filepath);
$file = StoredFile::RecallByFilepath($filepath);
$file = Application_Model_StoredFile::RecallByFilepath($filepath);
if (is_null($file)) {
$file = StoredFile::Insert($md);
$file = Application_Model_StoredFile::Insert($md);
}
else {
$this->view->error = "File already exists in Airtime.";
@ -488,7 +488,7 @@ class ApiController extends Zend_Controller_Action
else if ($mode == "modify") {
$filepath = $md['MDATA_KEY_FILEPATH'];
$filepath = str_replace("\\", "", $filepath);
$file = StoredFile::RecallByFilepath($filepath);
$file = Application_Model_StoredFile::RecallByFilepath($filepath);
//File is not in database anymore.
if (is_null($file)) {
@ -502,7 +502,7 @@ class ApiController extends Zend_Controller_Action
}
else if ($mode == "moved") {
$md5 = $md['MDATA_KEY_MD5'];
$file = StoredFile::RecallByMd5($md5);
$file = Application_Model_StoredFile::RecallByMd5($md5);
if (is_null($file)) {
$this->view->error = "File doesn't exist in Airtime.";
@ -518,7 +518,7 @@ class ApiController extends Zend_Controller_Action
else if ($mode == "delete") {
$filepath = $md['MDATA_KEY_FILEPATH'];
$filepath = str_replace("\\", "", $filepath);
$file = StoredFile::RecallByFilepath($filepath);
$file = Application_Model_StoredFile::RecallByFilepath($filepath);
if (is_null($file)) {
$this->view->error = "File doesn't exist in Airtime.";
@ -544,7 +544,7 @@ class ApiController extends Zend_Controller_Action
}
$dir_id = $request->getParam('dir_id');
$this->view->files = StoredFile::listAllFiles($dir_id);
$this->view->files = Application_Model_StoredFile::listAllFiles($dir_id);
}
public function listAllWatchedDirsAction() {
@ -561,8 +561,8 @@ class ApiController extends Zend_Controller_Action
$result = array();
$arrWatchedDirs = MusicDir::getWatchedDirs();
$storDir = MusicDir::getStorDir();
$arrWatchedDirs = Application_Model_MusicDir::getWatchedDirs();
$storDir = Application_Model_MusicDir::getStorDir();
$result[$storDir->getId()] = $storDir->getDirectory();
@ -587,7 +587,7 @@ class ApiController extends Zend_Controller_Action
exit;
}
$this->view->msg = MusicDir::addWatchedDir($path);
$this->view->msg = Application_Model_MusicDir::addWatchedDir($path);
}
public function removeWatchedDirAction() {
@ -604,7 +604,7 @@ class ApiController extends Zend_Controller_Action
exit;
}
$this->view->msg = MusicDir::removeWatchedDir($path);
$this->view->msg = Application_Model_MusicDir::removeWatchedDir($path);
}
public function setStorageDirAction() {
@ -621,7 +621,7 @@ class ApiController extends Zend_Controller_Action
exit;
}
$this->view->msg = MusicDir::setStorDir($path);
$this->view->msg = Application_Model_MusicDir::setStorDir($path);
}
public function getStreamSettingAction() {

View file

@ -81,7 +81,7 @@ class LibraryController extends Zend_Controller_Action
$id = $this->_getParam('id');
$file_id = $this->_getParam('id', null);
$file = StoredFile::Recall($file_id);
$file = Application_Model_StoredFile::Recall($file_id);
$url = $file->getRelativeFileUrl($baseUrl).'/api_key/'.$CC_CONFIG["apiKey"][0].'/download/true';
$menu[] = array('action' => array('type' => 'gourl', 'url' => $url),
@ -132,7 +132,7 @@ class LibraryController extends Zend_Controller_Action
if ($user->isAdmin()) {
if (!is_null($id)) {
$file = StoredFile::Recall($id);
$file = Application_Model_StoredFile::Recall($id);
if (PEAR::isError($file)) {
$this->view->message = $file->getMessage();
@ -163,12 +163,12 @@ class LibraryController extends Zend_Controller_Action
public function contentsAction()
{
$post = $this->getRequest()->getPost();
$datatables = StoredFile::searchFilesForPlaylistBuilder($post);
$datatables = Application_Model_StoredFile::searchFilesForPlaylistBuilder($post);
//format clip lengh to 1 decimal
foreach($datatables["aaData"] as &$data){
$sec = Playlist::playlistTimeToSeconds($data[5]);
$data[5] = Playlist::secondsToPlaylistTime($sec);
$sec = Application_Model_Playlist::playlistTimeToSeconds($data[5]);
$data[5] = Application_Model_Playlist::secondsToPlaylistTime($sec);
}
die(json_encode($datatables));
@ -180,7 +180,7 @@ class LibraryController extends Zend_Controller_Action
$form = new Application_Form_EditAudioMD();
$file_id = $this->_getParam('id', null);
$file = StoredFile::Recall($file_id);
$file = Application_Model_StoredFile::Recall($file_id);
$form->populate($file->getDbColMetadata());
if ($request->isPost()) {
@ -206,12 +206,12 @@ class LibraryController extends Zend_Controller_Action
$type = $this->_getParam('type');
if($type == "au") {
$file = StoredFile::Recall($id);
$file = Application_Model_StoredFile::Recall($id);
$this->view->type = $type;
$this->view->md = $file->getMetadata();
}
else if($type == "pl") {
$file = Playlist::Recall($id);
$file = Application_Model_Playlist::Recall($id);
$this->view->type = $type;
$this->view->md = $file->getAllPLMetaData();
$this->view->contents = $file->getContents();

View file

@ -33,7 +33,7 @@ class PlaylistController extends Zend_Controller_Action
if(isset($pl_sess->id)) {
$pl = Playlist::Recall($pl_sess->id);
$pl = Application_Model_Playlist::Recall($pl_sess->id);
if($pl === FALSE) {
unset($pl_sess->id);
return;
@ -48,7 +48,7 @@ class PlaylistController extends Zend_Controller_Action
if(isset($pl_sess->id)) {
$pl = Playlist::Recall($pl_sess->id);
$pl = Application_Model_Playlist::Recall($pl_sess->id);
if($pl !== FALSE) {
$this->closePlaylist($pl);
}
@ -56,7 +56,7 @@ class PlaylistController extends Zend_Controller_Action
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$pl = Playlist::Recall($pl_id);
$pl = Application_Model_Playlist::Recall($pl_id);
if($pl === FALSE) {
return FALSE;
}
@ -92,7 +92,7 @@ class PlaylistController extends Zend_Controller_Action
$pl_sess = $this->pl_sess;
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$pl = new Playlist();
$pl = new Application_Model_Playlist();
$pl->create("Untitled Playlist");
$pl->setPLMetaData('dc:creator', $userInfo->login);
@ -285,11 +285,11 @@ class PlaylistController extends Zend_Controller_Action
public function deleteAction()
{
$id = $this->_getParam('id', null);
$pl = Playlist::Recall($id);
$pl = Application_Model_Playlist::Recall($id);
if ($pl !== FALSE) {
Playlist::Delete($id);
Application_Model_Playlist::Delete($id);
$pl_sess = $this->pl_sess;
@ -305,7 +305,7 @@ class PlaylistController extends Zend_Controller_Action
public function deleteActiveAction()
{
$pl = $this->getPlaylist();
Playlist::Delete($pl->getId());
Application_Model_Playlist::Delete($pl->getId());
$pl_sess = $this->pl_sess;
unset($pl_sess->id);

View file

@ -26,7 +26,7 @@ class PluploadController extends Zend_Controller_Action
public function uploadAction()
{
$upload_dir = ini_get("upload_tmp_dir") . DIRECTORY_SEPARATOR . "plupload";
StoredFile::uploadFile($upload_dir);
Application_Model_StoredFile::uploadFile($upload_dir);
die('{"jsonrpc" : "2.0"}');
}
@ -34,7 +34,7 @@ class PluploadController extends Zend_Controller_Action
public function copyfileAction(){
$upload_dir = ini_get("upload_tmp_dir") . DIRECTORY_SEPARATOR . "plupload";
$filename = $this->_getParam('name');
StoredFile::copyFileToStor($upload_dir, $filename);
Application_Model_StoredFile::copyFileToStor($upload_dir, $filename);
die('{"jsonrpc" : "2.0"}');
}

View file

@ -240,7 +240,7 @@ class PreferenceController extends Zend_Controller_Action
$element = $this->getRequest()->getParam("element");
$watched_dirs_form = new Application_Form_WatchedDirPreferences();
$res = MusicDir::setStorDir($chosen);
$res = Application_Model_MusicDir::setStorDir($chosen);
if($res['code'] != 0){
$watched_dirs_form->populate(array('storageFolder' => $chosen));
$watched_dirs_form->getElement($element)->setErrors(array($res['error']));
@ -255,7 +255,7 @@ class PreferenceController extends Zend_Controller_Action
$element = $this->getRequest()->getParam("element");
$watched_dirs_form = new Application_Form_WatchedDirPreferences();
$res = MusicDir::addWatchedDir($chosen);
$res = Application_Model_MusicDir::addWatchedDir($chosen);
if($res['code'] != 0){
$watched_dirs_form->populate(array('watchedFolder' => $chosen));
$watched_dirs_form->getElement($element)->setErrors(array($res['error']));
@ -268,7 +268,7 @@ class PreferenceController extends Zend_Controller_Action
{
$chosen = $this->getRequest()->getParam("dir");
$dir = MusicDir::removeWatchedDir($chosen);
$dir = Application_Model_MusicDir::removeWatchedDir($chosen);
$watched_dirs_form = new Application_Form_WatchedDirPreferences();
$this->view->subform = $watched_dirs_form->render();

View file

@ -290,8 +290,8 @@ class ScheduleController extends Zend_Controller_Action
$playlists = $show->searchPlaylistsForShow($post);
foreach( $playlists['aaData'] as &$data){
// calling two functions to format time to 1 decimal place
$sec = Playlist::playlistTimeToSeconds($data[4]);
$data[4] = Playlist::secondsToPlaylistTime($sec);
$sec = Application_Model_Playlist::playlistTimeToSeconds($data[4]);
$data[4] = Application_Model_Playlist::secondsToPlaylistTime($sec);
}
//for datatables
@ -744,7 +744,7 @@ class ScheduleController extends Zend_Controller_Action
$id = $this->_getParam('id');
$file_id = $this->_getParam('id', null);
$file = StoredFile::Recall($file_id);
$file = Application_Model_StoredFile::Recall($file_id);
$url = $file->getFileURL().'/api_key/'.$CC_CONFIG["apiKey"][0].'/download/true';
$menu[] = array('action' => array('type' => 'gourl', 'url' => $url),