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

@ -12,9 +12,9 @@ require_once __DIR__."/configs/conf.php";
require_once 'DB.php'; require_once 'DB.php';
require_once 'Soundcloud.php'; require_once 'Soundcloud.php';
require_once 'MusicDir.php'; //require_once 'MusicDir.php';
require_once 'Playlist.php'; //require_once 'Playlist.php';
require_once 'StoredFile.php'; //require_once 'StoredFile.php';
require_once 'Schedule.php'; require_once 'Schedule.php';
require_once 'Preference.php'; require_once 'Preference.php';
require_once 'Shows.php'; require_once 'Shows.php';
@ -37,6 +37,7 @@ $CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
date_default_timezone_set(Application_Model_Preference::GetTimezone()); date_default_timezone_set(Application_Model_Preference::GetTimezone());
Logging::setLogPath('/var/log/airtime/zendphp.log'); Logging::setLogPath('/var/log/airtime/zendphp.log');
Logging::log("bootstrap");
Zend_Validate::setDefaultNamespaces("Zend"); Zend_Validate::setDefaultNamespaces("Zend");

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,7 +2,7 @@
class NestedDirectoryException extends Exception { } class NestedDirectoryException extends Exception { }
class MusicDir { class Application_Model_MusicDir {
/** /**
* @holds propel database object * @holds propel database object
@ -193,7 +193,7 @@ class MusicDir {
{ {
$dir = CcMusicDirsQuery::create()->findPK($pk); $dir = CcMusicDirsQuery::create()->findPK($pk);
$mus_dir = new MusicDir($dir); $mus_dir = new Application_Model_MusicDir($dir);
return $mus_dir; return $mus_dir;
} }
@ -208,7 +208,7 @@ class MusicDir {
return null; return null;
} }
else{ else{
$mus_dir = new MusicDir($dir); $mus_dir = new Application_Model_MusicDir($dir);
return $mus_dir; return $mus_dir;
} }
} }
@ -222,7 +222,7 @@ class MusicDir {
->find(); ->find();
foreach($dirs as $dir) { foreach($dirs as $dir) {
$result[] = new MusicDir($dir); $result[] = new Application_Model_MusicDir($dir);
} }
return $result; return $result;
@ -234,7 +234,7 @@ class MusicDir {
->filterByType("stor") ->filterByType("stor")
->findOne(); ->findOne();
$mus_dir = new MusicDir($dir); $mus_dir = new Application_Model_MusicDir($dir);
return $mus_dir; return $mus_dir;
} }
@ -272,7 +272,7 @@ class MusicDir {
foreach($dirs as $dir) { foreach($dirs as $dir) {
$directory = $dir->getDirectory(); $directory = $dir->getDirectory();
if (substr($p_filepath, 0, strlen($directory)) === $directory) { if (substr($p_filepath, 0, strlen($directory)) === $directory) {
$mus_dir = new MusicDir($dir); $mus_dir = new Application_Model_MusicDir($dir);
return $mus_dir; return $mus_dir;
} }
} }
@ -282,7 +282,7 @@ class MusicDir {
public static function removeWatchedDir($p_dir){ public static function removeWatchedDir($p_dir){
$p_dir = realpath($p_dir)."/"; $p_dir = realpath($p_dir)."/";
$dir = MusicDir::getDirByPath($p_dir); $dir = Application_Model_MusicDir::getDirByPath($p_dir);
if($dir == NULL){ if($dir == NULL){
return array("code"=>1,"error"=>"'$p_dir' doesn't exist in the watched list."); return array("code"=>1,"error"=>"'$p_dir' doesn't exist in the watched list.");
}else{ }else{

View File

@ -9,7 +9,7 @@ define('INDCH', ' ');
* @copyright 2010 Sourcefabric O.P.S. * @copyright 2010 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt * @license http://www.gnu.org/licenses/gpl.txt
*/ */
class Playlist { class Application_Model_Playlist {
// *** Variable stored in the database *** // *** Variable stored in the database ***
@ -162,7 +162,7 @@ class Playlist {
if($pl === NULL) if($pl === NULL)
return FALSE; return FALSE;
$storedPlaylist = new Playlist(); $storedPlaylist = new Application_Model_Playlist();
$storedPlaylist->id = $id; $storedPlaylist->id = $id;
$storedPlaylist->name = $pl->getDbName(); $storedPlaylist->name = $pl->getDbName();
$storedPlaylist->state = $pl->getDbState(); $storedPlaylist->state = $pl->getDbState();
@ -405,10 +405,10 @@ class Playlist {
foreach ($rows as $row) { foreach ($rows as $row) {
$files[$i] = $row->toArray(BasePeer::TYPE_FIELDNAME, true, true); $files[$i] = $row->toArray(BasePeer::TYPE_FIELDNAME, true, true);
// display only upto 1 decimal place by calling secondsToPlaylistTime // display only upto 1 decimal place by calling secondsToPlaylistTime
$clipSec = Playlist::playlistTimeToSeconds($files[$i]['cliplength']); $clipSec = Application_Model_Playlist::playlistTimeToSeconds($files[$i]['cliplength']);
$files[$i]['cliplength'] = Playlist::secondsToPlaylistTime($clipSec); $files[$i]['cliplength'] = Application_Model_Playlist::secondsToPlaylistTime($clipSec);
$offset += $clipSec; $offset += $clipSec;
$files[$i]['offset'] = Playlist::secondsToPlaylistTime($offset); $files[$i]['offset'] = Application_Model_Playlist::secondsToPlaylistTime($offset);
$i++; $i++;
} }
@ -424,8 +424,8 @@ class Playlist {
return '00:00:00'; return '00:00:00';
// calling two functions to format time to 1 decimal place // calling two functions to format time to 1 decimal place
$sec = Playlist::playlistTimeToSeconds($res); $sec = Application_Model_Playlist::playlistTimeToSeconds($res);
$res = Playlist::secondsToPlaylistTime($sec); $res = Application_Model_Playlist::secondsToPlaylistTime($sec);
return $res; return $res;
} }
@ -466,7 +466,7 @@ class Playlist {
{ {
if ($val && $this->isEdited() !== FALSE) { if ($val && $this->isEdited() !== FALSE) {
return PEAR::raiseError( return PEAR::raiseError(
'Playlist::lock: playlist already locked' 'Application_Model_Playlist::lock: playlist already locked'
); );
} }
$r = $this->setEditFlag($subjid, $val); $r = $this->setEditFlag($subjid, $val);
@ -507,7 +507,7 @@ class Playlist {
public function addAudioClip($p_mediaId, $p_position=NULL, $p_fadeIn=NULL, $p_fadeOut=NULL, $p_clipLength=NULL, $p_cuein=NULL, $p_cueout=NULL) public function addAudioClip($p_mediaId, $p_position=NULL, $p_fadeIn=NULL, $p_fadeOut=NULL, $p_clipLength=NULL, $p_cuein=NULL, $p_cueout=NULL)
{ {
//get audio clip. //get audio clip.
$media = StoredFile::Recall($p_mediaId); $media = Application_Model_StoredFile::Recall($p_mediaId);
if (is_null($media) || PEAR::isError($media)) { if (is_null($media) || PEAR::isError($media)) {
return $media; return $media;
} }
@ -999,430 +999,3 @@ class Playlist {
} }
} // class Playlist } // class Playlist
/**
* @package Airtime
* @subpackage StorageServer
* @copyright 2010 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt
* @todo Rename this class PlaylistTag
*/
class PlaylistTagExport
{
public static function OutputToSmil(&$pl, $plt, $ind='')
{
$ind2 = $ind.INDCH;
$ind3 = $ind2.INDCH;
$ind4 = $ind3.INDCH;
$res = "";
foreach ($plt['children'] as $ple) {
switch ($ple['elementname']) {
case "playlistElement":
$r = PlaylistElementExport::OutputToSmil($pl, $ple, $ind4);
if (PEAR::isError($r)) {
return $r;
}
if (!is_null($r)) {
$res .= $r;
}
break;
case "metadata":
$r = PlaylistMetadataExport::OutputToSmil($pl, $ple, $ind4);
if (PEAR::isError($r)) {
return $r;
}
if (!is_null($r)) {
$res .= $r;
}
break;
default:
}
}
$res = "$ind<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n".
"$ind<smil xmlns=\"http://www.w3.org/2001/SMIL20/Language\">\n".
"$ind2<body>\n".
"$ind3<par>\n".
"$res".
"$ind3</par>\n".
"$ind2</body>\n".
"$ind</smil>\n";
return $res;
}
public static function OutputToM3u(&$pl, $plt, $ind='')
{
$res = "";
foreach ($plt['children'] as $ple) {
switch ($ple['elementname']) {
case"playlistElement":
$r = PlaylistElementExport::OutputToM3u($pl, $ple);
if (PEAR::isError($r)) {
return $r;
}
if (!is_null($r)) {
$res .= $r;
}
break;
}
}
$res = "#EXTM3U\n$res";
return $res;
}
public static function OutputToRss(&$pl, $plt, $ind='')
{
$ind2 = $ind.INDCH;
$ind3 = $ind2.INDCH;
$res = "";
foreach ($plt['children'] as $ple) {
switch ($ple['elementname']) {
case "playlistElement":
$r = PlaylistElementExport::OutputToRss($pl, $ple, $ind3);
if (PEAR::isError($r)) {
return $r;
}
if (!is_null($r)) {
$res .= $r;
}
break;
case "metadata":
$r = PlaylistMetadataExport::OutputToRss($pl, $ple, $ind3);
if (PEAR::isError($r)) {
return $r;
}
if (!is_null($r)) {
$res .= $r;
}
break;
default:
}
}
$res = "$ind<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n".
"$ind<rss version=\"2.0\">\n".
"$ind2<channel>\n".
"$res".
"$ind2</channel>\n".
"$ind</rss>\n";
return $res;
}
}
/**
* @package Airtime
* @subpackage StorageServer
* @copyright 2010 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt
* @todo Rename this class "PlaylistElement"
*/
class PlaylistElementExport {
public static function OutputToSmil(&$pl, $ple, $ind='')
{
$acOrPl = NULL;
$finfo = array('fi'=>0, 'fo'=>0);
$ind2 = $ind.INDCH;
$ind3 = $ind2.INDCH;
$anim = '';
foreach ($ple['children'] as $ac) {
switch ($ac['elementname']) {
case "audioClip":
$r = PlaylistAudioClipExport::OutputToSmil($pl, $ac, $ind2);
if (PEAR::isError($r)) {
return $r;
}
if (!is_null($r)) {
$acOrPl = $r;
}
break;
case "playlist":
$gunid = $ac['attrs']['id'];
$pl2 = StoredFile::RecallByGunid($gunid);
if (is_null($pl2) || PEAR::isError($pl2)) {
return $pl2;
}
$r = $pl2->outputToSmil(FALSE);
if (PEAR::isError($r)) {
return $r;
}
if (!is_null($r)) {
$acOrPl = $r;
}
break;
case "fadeInfo":
$r = PlaylistFadeInfoExport::OutputToSmil($pl, $ac, $ind2);
if (PEAR::isError($r)) {
return $r;
}
if (!is_null($r)) {
$finfo = $r;
}
break;
default:
return PEAR::raiseError(
"PlaylistElementExport::OutputToSmil:".
" unknown tag {$ac['elementname']}"
);
}
}
$beginS = Playlist::playlistTimeToSeconds($ple['attrs']['relativeOffset']);
$playlengthS = Playlist::playlistTimeToSeconds($acOrPl['playlength']);
$fadeOutS = Playlist::playlistTimeToSeconds($finfo['fo']);
$fiBeginS = 0;
$fiEndS = Playlist::playlistTimeToSeconds($finfo['fi']);
$foBeginS = ($playlengthS - $fadeOutS);
$foEndS = Playlist::playlistTimeToSeconds($acOrPl['playlength']);
foreach (array('fi','fo') as $ff) {
if (${$ff."EndS"} - ${$ff."BeginS"} > 0) {
$anim .= "{$ind2}<animate attributeName = \"soundLevel\"\n".
"{$ind3}from = \"".($ff == 'fi' ? 0 : 100)."%\"\n".
"{$ind3}to = \"".($ff == 'fi' ? 100 : 0)."%\"\n".
"{$ind3}calcMode = \"linear\"\n".
"{$ind3}begin = \"{${$ff."BeginS"}}s\"\n".
"{$ind3}end = \"{${$ff."EndS"}}s\"\n".
"{$ind3}fill = \"freeze\"\n".
"{$ind2}/>\n"
;
}
}
$src = $acOrPl['src'];
$str = "$ind<audio src=\"$src\" begin=\"{$beginS}s\"".
($anim ? ">\n$anim$ind</audio>" : " />").
" <!-- {$acOrPl['type']}, {$acOrPl['gunid']}, {$acOrPl['playlength']} -->".
"\n";
return $str;
}
public static function OutputToM3u(&$pl, $ple, $ind='')
{
$acOrPl = NULL;
foreach ($ple['children'] as $ac) {
switch ($ac['elementname']) {
case "audioClip":
$r = PlaylistAudioClipExport::OutputToM3u($pl, $ac);
if (PEAR::isError($r)) {
return $r;
}
if (!is_null($r)) {
$acOrPl = $r;
}
break;
case "playlist":
$gunid = $ac['attrs']['id'];
$pl2 = StoredFile::RecallByGunid($gunid);
if (is_null($pl2) || PEAR::isError($pl2)) {
return $pl2;
}
$r = $pl2->outputToM3u(FALSE);
if (PEAR::isError($r)) {
return $r;
}
if (!is_null($r)) {
$acOrPl = $r;
}
break;
}
}
if (is_null($acOrPl)) {
return '';
}
$playlength = ceil(Playlist::playlistTimeToSeconds($acOrPl['playlength']));
$title = $acOrPl['title'];
$uri = (isset($acOrPl['uri']) ? $acOrPl['uri'] : '???' );
$res = "#EXTINF: $playlength, $title\n";
$res .= "$uri\n";
return $res;
}
public static function OutputToRss(&$pl, $ple, $ind='')
{
$acOrPl = NULL;
$ind2 = $ind.INDCH;
$anim = '';
foreach ($ple['children'] as $ac) {
switch ($ac['elementname']) {
case "audioClip":
$r = PlaylistAudioClipExport::OutputToRss($pl, $ac, $ind2);
if (PEAR::isError($r)) {
return $r;
}
if (!is_null($r)) {
$acOrPl = $r;
}
break;
case "playlist":
$gunid = $ac['attrs']['id'];
$pl2 = StoredFile::RecallByGunid($gunid);
if (is_null($pl2) || PEAR::isError($pl2)) {
return $pl2;
}
$r = $pl2->outputToRss(FALSE);
if (PEAR::isError($r)) {
return $r;
}
if (!is_null($r)) {
$acOrPl = $r;
}
break;
case "fadeInfo":
break;
default:
return PEAR::raiseError(
"PlaylistElementExport::OutputToRss:".
" unknown tag {$ac['elementname']}"
);
}
}
$title = (isset($acOrPl['title']) ? htmlspecialchars($acOrPl['title']) : '' );
$desc = (isset($acOrPl['desc']) ? htmlspecialchars($acOrPl['desc']) : '' );
$link = htmlspecialchars($acOrPl['src']);
$desc = '';
$str = "$ind<item>\n".
"$ind2<title>$title</title>\n".
"$ind2<description>$desc</description>\n".
"$ind2<link>$link</link>\n".
"$ind</item>\n";
return $str;
}
}
/**
* @package Airtime
* @subpackage StorageServer
* @copyright 2010 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt
* @todo Rename this class to PlaylistAudioClip (notice the caps)
*/
class PlaylistAudioClipExport
{
public static function OutputToSmil(&$pl, $plac, $ind='')
{
$gunid = $plac['attrs']['id'];
$ac = StoredFile::RecallByGunid($gunid);
if (is_null($ac) || PEAR::isError($ac)) {
return $ac;
}
$RADext = $ac->getFileExtension();
if (PEAR::isError($RADext)) {
return $RADext;
}
return array(
'type' => 'audioclip',
'gunid' => $gunid,
'src' => AC_URL_RELPATH."$gunid.$RADext",
'playlength' => $plac['attrs']['playlength'],
);
}
public static function OutputToM3u(&$pl, $plac, $ind='')
{
$gunid = $plac['attrs']['id'];
$ac = StoredFile::RecallByGunid($gunid);
if (is_null($ac) || PEAR::isError($ac)) {
return $ac;
}
$RADext = $ac->getFileExtension();
if (PEAR::isError($RADext)) {
return $RADext;
}
return array(
'playlength' => $plac['attrs']['playlength'],
'title' => $plac['attrs']['title'],
'uri' => AC_URL_RELPATH."$gunid.$RADext",
);
}
public static function OutputToRss(&$pl, $plac, $ind='')
{
$id = $plac['attrs']['id'];
$playlist = Playlist::Recall($id);
if (is_null($playlist) || PEAR::isError($playlist)) {
return $playlist;
}
$RADext = $playlist->getFileExtension();
if (PEAR::isError($RADext)) {
return $RADext;
}
$title = $playlist->getName();
$desc = $playlist->getPLMetaData("dc:description");
return array(
'type' => 'audioclip',
'gunid' => $id,
'src' => "http://XXX/YY/$id.$RADext",
'playlength' => $plac['attrs']['playlength'],
'title' => $title,
'desc' => $desc,
);
}
}
/**
* @package Airtime
* @subpackage StorageServer
* @copyright 2010 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt
* @todo Rename this class "PlaylistFadeInfo" (notive the caps)
*/
class PlaylistFadeInfoExport
{
public static function OutputToSmil(&$pl, $plfi, $ind='')
{
$r = array(
'fi'=>$plfi['attrs']['fadeIn'],
'fo'=>$plfi['attrs']['fadeOut'],
);
return $r;
}
public static function OutputToM3u(&$pl, $plfa, $ind='')
{
return '';
}
public static function OutputToRss(&$pl, $plfa, $ind='')
{
return '';
}
}
/**
* @package Airtime
* @subpackage StorageServer
* @copyright 2010 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt
* @todo Rename this class to PlaylistMetadata (notice the caps)
*/
class PlaylistMetadataExport
{
public static function OutputToSmil(&$pl, $md, $ind='')
{
return NULL;
}
public static function OutputToM3u(&$pl, $md, $ind='')
{
return NULL;
}
public static function OutputToRss(&$pl, $md, $ind='')
{
return NULL;
}
}

View File

@ -334,8 +334,8 @@ class Application_Model_Preference
} }
$outputArray['NUM_OF_USERS'] = User::getUserCount(); $outputArray['NUM_OF_USERS'] = User::getUserCount();
$outputArray['NUM_OF_SONGS'] = StoredFile::getFileCount(); $outputArray['NUM_OF_SONGS'] = Application_Model_StoredFile::getFileCount();
$outputArray['NUM_OF_PLAYLISTS'] = Playlist::getPlaylistCount(); $outputArray['NUM_OF_PLAYLISTS'] = Application_Model_Playlist::getPlaylistCount();
$outputArray['NUM_OF_SCHEDULED_PLAYLISTS'] = Schedule::getSchduledPlaylistCount(); $outputArray['NUM_OF_SCHEDULED_PLAYLISTS'] = Schedule::getSchduledPlaylistCount();
$outputArray['NUM_OF_PAST_SHOWS'] = ShowInstance::GetShowInstanceCount(date("Y-m-d H:i:s")); $outputArray['NUM_OF_PAST_SHOWS'] = ShowInstance::GetShowInstanceCount(date("Y-m-d H:i:s"));
$outputArray['UNIQUE_ID'] = Application_Model_Preference::GetUniqueId(); $outputArray['UNIQUE_ID'] = Application_Model_Preference::GetUniqueId();

View File

@ -6,7 +6,7 @@
* @subpackage StorageServer * @subpackage StorageServer
* @copyright 2010 Sourcefabric O.P.S. * @copyright 2010 Sourcefabric O.P.S.
* @license http://www.gnu.org/licenses/gpl.txt * @license http://www.gnu.org/licenses/gpl.txt
* @see StoredFile * @see Application_Model_StoredFile
*/ */
/* ================== Prefs ================== */ /* ================== Prefs ================== */
class Prefs { class Prefs {

View File

@ -1,5 +1,4 @@
<?php <?php
require_once("StoredFile.php");
class ScheduleGroup { class ScheduleGroup {
@ -49,7 +48,7 @@ class ScheduleGroup {
// Schedule a single audio track // Schedule a single audio track
// Load existing track // Load existing track
$track = StoredFile::Recall($p_audioFileId); $track = Application_Model_StoredFile::Recall($p_audioFileId);
if (is_null($track)) { if (is_null($track)) {
return new PEAR_Error("Could not find audio track."); return new PEAR_Error("Could not find audio track.");
} }
@ -80,7 +79,7 @@ class ScheduleGroup {
// Schedule a whole playlist // Schedule a whole playlist
// Load existing playlist // Load existing playlist
$playlist = Playlist::Recall($p_playlistId); $playlist = Application_Model_Playlist::Recall($p_playlistId);
if (is_null($playlist)) { if (is_null($playlist)) {
return new PEAR_Error("Could not find playlist."); return new PEAR_Error("Could not find playlist.");
} }
@ -708,7 +707,7 @@ class Schedule {
$medias = array(); $medias = array();
foreach ($items as $item) foreach ($items as $item)
{ {
$storedFile = StoredFile::Recall($item["file_id"]); $storedFile = Application_Model_StoredFile::Recall($item["file_id"]);
$uri = $storedFile->getFileUrl(); $uri = $storedFile->getFileUrl();
$starts = Schedule::AirtimeTimeToPypoTime($item["starts"]); $starts = Schedule::AirtimeTimeToPypoTime($item["starts"]);

View File

@ -1370,7 +1370,7 @@ class ShowInstance {
$file_id = $this->_showInstance->getDbRecordedFile(); $file_id = $this->_showInstance->getDbRecordedFile();
if(isset($file_id)) { if(isset($file_id)) {
$file = StoredFile::Recall($file_id); $file = Application_Model_StoredFile::Recall($file_id);
if (PEAR::isError($file)) { if (PEAR::isError($file)) {
return null; return null;
@ -1717,7 +1717,7 @@ class ShowInstance {
public function searchPlaylistsForShow($datatables) public function searchPlaylistsForShow($datatables)
{ {
return StoredFile::searchPlaylistsForSchedule($datatables); return Application_Model_StoredFile::searchPlaylistsForSchedule($datatables);
} }
public function getShowListContent() public function getShowListContent()

View File

@ -61,7 +61,7 @@ class SmilPlaylist {
return $lspl; return $lspl;
} }
require_once("Playlist.php"); require_once("Playlist.php");
$pl =& Playlist::create($gb, $plid, "imported_SMIL"); $pl =& Application_Model_Playlist::create($gb, $plid, "imported_SMIL");
if (PEAR::isError($pl)) { if (PEAR::isError($pl)) {
return $pl; return $pl;
} }
@ -220,14 +220,14 @@ class SmilPlaylistAudioElement {
} }
} }
if ($fadeIn > 0 || $fadeOut > 0) { if ($fadeIn > 0 || $fadeOut > 0) {
$fiGunid = StoredFile::CreateGunid(); $fiGunid = Application_Model_StoredFile::CreateGunid();
$fadeIn = Playlist::secondsToPlaylistTime($fadeIn); $fadeIn = Application_Model_Playlist::secondsToPlaylistTime($fadeIn);
$fadeOut = Playlist::secondsToPlaylistTime($fadeOut); $fadeOut = Application_Model_Playlist::secondsToPlaylistTime($fadeOut);
$fInfo = "$ind2<fadeInfo id=\"$fiGunid\" fadeIn=\"$fadeIn\" fadeOut=\"$fadeOut\"/>\n"; $fInfo = "$ind2<fadeInfo id=\"$fiGunid\" fadeIn=\"$fadeIn\" fadeOut=\"$fadeOut\"/>\n";
} else { } else {
$fInfo = ''; $fInfo = '';
} }
$plElGunid = StoredFile::CreateGunid(); $plElGunid = Application_Model_StoredFile::CreateGunid();
$acGunid = $gunid; $acGunid = $gunid;
$type = 'audioClip'; $type = 'audioClip';
if (preg_match("|\.([a-zA-Z0-9]+)$|", $uri, $va)) { if (preg_match("|\.([a-zA-Z0-9]+)$|", $uri, $va)) {
@ -244,7 +244,7 @@ class SmilPlaylistAudioElement {
} }
//break; //break;
default: default:
$ac = StoredFile::RecallByGunid($gunid); $ac = Application_Model_StoredFile::RecallByGunid($gunid);
if (is_null($ac) || PEAR::isError($ac)) { if (is_null($ac) || PEAR::isError($ac)) {
return $ac; return $ac;
} }
@ -257,10 +257,10 @@ class SmilPlaylistAudioElement {
} }
$title = basename($tree->attrs['src']->val); $title = basename($tree->attrs['src']->val);
$offset = Playlist::secondsToPlaylistTime($tree->attrs['begin']->val); $offset = Application_Model_Playlist::secondsToPlaylistTime($tree->attrs['begin']->val);
$clipStart = Playlist::secondsToPlaylistTime($tree->attrs['clipStart']->val); $clipStart = Application_Model_Playlist::secondsToPlaylistTime($tree->attrs['clipStart']->val);
$clipEnd = Playlist::secondsToPlaylistTime($tree->attrs['clipEnd']->val); $clipEnd = Application_Model_Playlist::secondsToPlaylistTime($tree->attrs['clipEnd']->val);
$clipLength = Playlist::secondsToPlaylistTime($tree->attrs['clipLength']->val); $clipLength = Application_Model_Playlist::secondsToPlaylistTime($tree->attrs['clipLength']->val);
$res = "$ind<playlistElement id=\"$plElGunid\" relativeOffset=\"$offset\" clipStart=\"$clipStart\" clipEnd=\"$clipEnd\" clipLength=\"$clipLength\">\n". $res = "$ind<playlistElement id=\"$plElGunid\" relativeOffset=\"$offset\" clipStart=\"$clipStart\" clipEnd=\"$clipEnd\" clipLength=\"$clipLength\">\n".
"$ind2<$type id=\"$acGunid\" playlength=\"$playlength\" title=\"$title\"/>\n". "$ind2<$type id=\"$acGunid\" playlength=\"$playlength\" title=\"$title\"/>\n".
$fInfo. $fInfo.

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* StoredFile class * Application_Model_StoredFile class
* *
* @package Airtime * @package Airtime
* @subpackage StorageServer * @subpackage StorageServer
@ -9,7 +9,7 @@
* @license http://www.gnu.org/licenses/gpl.txt * @license http://www.gnu.org/licenses/gpl.txt
* @see MetaData * @see MetaData
*/ */
class StoredFile { class Application_Model_StoredFile {
/** /**
* @holds propel database object * @holds propel database object
@ -286,7 +286,7 @@ class StoredFile {
$playlists = array(); $playlists = array();
if (is_array($ids) && count($ids) > 0) { if (is_array($ids) && count($ids) > 0) {
foreach ($ids as $id) { foreach ($ids as $id) {
$playlists[] = Playlist::Recall($id); $playlists[] = Application_Model_Playlist::Recall($id);
} }
} }
return $playlists; return $playlists;
@ -310,7 +310,7 @@ class StoredFile {
} }
} }
Playlist::DeleteFileFromAllPlaylists($this->getId()); Application_Model_Playlist::DeleteFileFromAllPlaylists($this->getId());
$this->_file->delete(); $this->_file->delete();
if (isset($res)) { if (isset($res)) {
@ -410,7 +410,7 @@ class StoredFile {
*/ */
public function getFilePath() public function getFilePath()
{ {
$music_dir = MusicDir::getDirByPK($this->_file->getDbDirectory()); $music_dir = Application_Model_MusicDir::getDirByPK($this->_file->getDbDirectory());
$filepath = $this->_file->getDbFilepath(); $filepath = $this->_file->getDbFilepath();
return $music_dir->getDirectory().$filepath; return $music_dir->getDirectory().$filepath;
@ -423,11 +423,11 @@ class StoredFile {
*/ */
public function setFilePath($p_filepath) public function setFilePath($p_filepath)
{ {
$path_info = MusicDir::splitFilePath($p_filepath); $path_info = Application_Model_MusicDir::splitFilePath($p_filepath);
if (is_null($path_info)) { if (is_null($path_info)) {
return -1; return -1;
} }
$musicDir = MusicDir::getDirByPath($path_info[0]); $musicDir = Application_Model_MusicDir::getDirByPath($path_info[0]);
$this->_file->setDbDirectory($musicDir->getId()); $this->_file->setDbDirectory($musicDir->getId());
$this->_file->setDbFilepath($path_info[1]); $this->_file->setDbFilepath($path_info[1]);
@ -459,7 +459,7 @@ class StoredFile {
$file = new CcFiles(); $file = new CcFiles();
$file->setDbGunid(md5(uniqid("", true))); $file->setDbGunid(md5(uniqid("", true)));
$storedFile = new StoredFile(); $storedFile = new Application_Model_StoredFile();
$storedFile->_file = $file; $storedFile->_file = $file;
if(isset($md['MDATA_KEY_FILEPATH'])) { if(isset($md['MDATA_KEY_FILEPATH'])) {
@ -490,7 +490,7 @@ class StoredFile {
* global unique id of file * global unique id of file
* @param string $p_md5sum * @param string $p_md5sum
* MD5 sum of the file * MD5 sum of the file
* @return StoredFile|NULL * @return Application_Model_StoredFile|NULL
* Return NULL if the object doesnt exist in the DB. * Return NULL if the object doesnt exist in the DB.
*/ */
public static function Recall($p_id=null, $p_gunid=null, $p_md5sum=null, $p_filepath=null) public static function Recall($p_id=null, $p_gunid=null, $p_md5sum=null, $p_filepath=null)
@ -509,12 +509,12 @@ class StoredFile {
->findOne(); ->findOne();
} }
else if (isset($p_filepath)) { else if (isset($p_filepath)) {
$path_info = MusicDir::splitFilePath($p_filepath); $path_info = Application_Model_MusicDir::splitFilePath($p_filepath);
if (is_null($path_info)) { if (is_null($path_info)) {
return null; return null;
} }
$music_dir = MusicDir::getDirByPath($path_info[0]); $music_dir = Application_Model_MusicDir::getDirByPath($path_info[0]);
$file = CcFilesQuery::create() $file = CcFilesQuery::create()
->filterByDbDirectory($music_dir->getId()) ->filterByDbDirectory($music_dir->getId())
@ -526,7 +526,7 @@ class StoredFile {
} }
if (isset($file)) { if (isset($file)) {
$storedFile = new StoredFile(); $storedFile = new Application_Model_StoredFile();
$storedFile->_file = $file; $storedFile->_file = $file;
return $storedFile; return $storedFile;
@ -547,34 +547,34 @@ class StoredFile {
* *
* @param string $p_gunid * @param string $p_gunid
* global unique id of file * global unique id of file
* @return StoredFile|NULL * @return Application_Model_StoredFile|NULL
*/ */
public static function RecallByGunid($p_gunid) public static function RecallByGunid($p_gunid)
{ {
return StoredFile::Recall(null, $p_gunid); return Application_Model_StoredFile::Recall(null, $p_gunid);
} }
/** /**
* Fetch the StoredFile by looking up the MD5 value. * Fetch the Application_Model_StoredFile by looking up the MD5 value.
* *
* @param string $p_md5sum * @param string $p_md5sum
* @return StoredFile|NULL * @return Application_Model_StoredFile|NULL
*/ */
public static function RecallByMd5($p_md5sum) public static function RecallByMd5($p_md5sum)
{ {
return StoredFile::Recall(null, null, $p_md5sum); return Application_Model_StoredFile::Recall(null, null, $p_md5sum);
} }
/** /**
* Fetch the StoredFile by looking up its filepath. * Fetch the Application_Model_StoredFile by looking up its filepath.
* *
* @param string $p_filepath path of file stored in Airtime. * @param string $p_filepath path of file stored in Airtime.
* @return StoredFile|NULL * @return Application_Model_StoredFile|NULL
*/ */
public static function RecallByFilepath($p_filepath) public static function RecallByFilepath($p_filepath)
{ {
return StoredFile::Recall(null, null, null, $p_filepath); return Application_Model_StoredFile::Recall(null, null, null, $p_filepath);
} }
public static function searchFilesForPlaylistBuilder($datatables) { public static function searchFilesForPlaylistBuilder($datatables) {
@ -616,7 +616,7 @@ class StoredFile {
(".$fileSelect."id FROM ".$CC_CONFIG["filesTable"]." AS FILES)) AS RESULTS"; (".$fileSelect."id FROM ".$CC_CONFIG["filesTable"]." AS FILES)) AS RESULTS";
return StoredFile::searchFiles($fromTable, $datatables); return Application_Model_StoredFile::searchFiles($fromTable, $datatables);
} }
@ -626,7 +626,7 @@ class StoredFile {
//$datatables["optWhere"][] = "INTERVAL '{$time_remaining}' > INTERVAL '00:00:00'"; //$datatables["optWhere"][] = "INTERVAL '{$time_remaining}' > INTERVAL '00:00:00'";
$datatables["optWhere"][] = "plt.length > INTERVAL '00:00:00'"; $datatables["optWhere"][] = "plt.length > INTERVAL '00:00:00'";
return StoredFile::searchFiles($fromTable, $datatables); return Application_Model_StoredFile::searchFiles($fromTable, $datatables);
} }
public static function searchFiles($fromTable, $data) public static function searchFiles($fromTable, $data)
@ -801,7 +801,7 @@ class StoredFile {
/*$audio_file = $p_targetDir . DIRECTORY_SEPARATOR . $fileName; /*$audio_file = $p_targetDir . DIRECTORY_SEPARATOR . $fileName;
$md5 = md5_file($audio_file); $md5 = md5_file($audio_file);
$duplicate = StoredFile::RecallByMd5($md5); $duplicate = Application_Model_StoredFile::RecallByMd5($md5);
if ($duplicate) { if ($duplicate) {
if (PEAR::isError($duplicate)) { if (PEAR::isError($duplicate)) {
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": ' . $duplicate->getMessage() .'}}'); die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": ' . $duplicate->getMessage() .'}}');
@ -812,7 +812,7 @@ class StoredFile {
} }
} }
$storDir = MusicDir::getStorDir(); $storDir = Application_Model_MusicDir::getStorDir();
$stor = $storDir->getDirectory(); $stor = $storDir->getDirectory();
$stor .= "/organize"; $stor .= "/organize";
@ -827,7 +827,7 @@ class StoredFile {
$audio_file = $p_targetDir . DIRECTORY_SEPARATOR . $fileName; $audio_file = $p_targetDir . DIRECTORY_SEPARATOR . $fileName;
Logging::log('copyFileToStor: moving file '.$audio_file); Logging::log('copyFileToStor: moving file '.$audio_file);
$md5 = md5_file($audio_file); $md5 = md5_file($audio_file);
$duplicate = StoredFile::RecallByMd5($md5); $duplicate = Application_Model_StoredFile::RecallByMd5($md5);
if ($duplicate) { if ($duplicate) {
if (PEAR::isError($duplicate)) { if (PEAR::isError($duplicate)) {
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": ' . $duplicate->getMessage() .'}}'); die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": ' . $duplicate->getMessage() .'}}');
@ -838,7 +838,7 @@ class StoredFile {
} }
} }
$storDir = MusicDir::getStorDir(); $storDir = Application_Model_MusicDir::getStorDir();
$stor = $storDir->getDirectory(); $stor = $storDir->getDirectory();
$stor .= "/organize"; $stor .= "/organize";

View File

@ -182,8 +182,8 @@ class Application_Model_Systemstatus
public static function GetDiskInfo(){ public static function GetDiskInfo(){
/* First lets get all the watched directories. Then we can group them /* First lets get all the watched directories. Then we can group them
* into the same paritions by comparing the partition sizes. */ * into the same paritions by comparing the partition sizes. */
$musicDirs = MusicDir::getWatchedDirs(); $musicDirs = Application_Model_MusicDir::getWatchedDirs();
$musicDirs[] = MusicDir::getStorDir(); $musicDirs[] = Application_Model_MusicDir::getStorDir();
$partions = array(); $partions = array();
@ -218,7 +218,7 @@ class Application_Model_Systemstatus
$status[$arr[0]] = $arr[1]; $status[$arr[0]] = $arr[1];
} }
$storDir = MusicDir::getStorDir()->getDirectory(); $storDir = Application_Model_MusicDir::getStorDir()->getDirectory();
$freeSpace = disk_free_space($storDir); $freeSpace = disk_free_space($storDir);
$totalSpace = disk_total_space($storDir); $totalSpace = disk_total_space($storDir);

View File

@ -232,7 +232,7 @@ class User {
$username = $auth->getIdentity()->login; $username = $auth->getIdentity()->login;
} }
$res = StoredFile::searchFiles($fromTable, $datatables_post); $res = Application_Model_StoredFile::searchFiles($fromTable, $datatables_post);
// mark record which is for the current user // mark record which is for the current user
foreach($res['aaData'] as &$record){ foreach($res['aaData'] as &$record){

View File

@ -12,18 +12,18 @@ class SchedulerExportTests extends PHPUnit_TestCase {
// Add a file // Add a file
$values = array("filepath" => dirname(__FILE__)."/test10001.mp3"); $values = array("filepath" => dirname(__FILE__)."/test10001.mp3");
$this->storedFile = StoredFile::Insert($values, false); $this->storedFile = Application_Model_StoredFile::Insert($values, false);
// Add a file // Add a file
$values = array("filepath" => dirname(__FILE__)."/test10002.mp3"); $values = array("filepath" => dirname(__FILE__)."/test10002.mp3");
$this->storedFile2 = StoredFile::Insert($values, false); $this->storedFile2 = Application_Model_StoredFile::Insert($values, false);
// Clear the schedule table // Clear the schedule table
$sql = "DELETE FROM ".$CC_CONFIG["scheduleTable"]; $sql = "DELETE FROM ".$CC_CONFIG["scheduleTable"];
$CC_DBC->query($sql); $CC_DBC->query($sql);
// Create a playlist // Create a playlist
$playlist = new Playlist(); $playlist = new Application_Model_Playlist();
$playlist->create("Scheduler Unit Test"); $playlist->create("Scheduler Unit Test");
$result = $playlist->addAudioClip($this->storedFile->getId()); $result = $playlist->addAudioClip($this->storedFile->getId());
$result = $playlist->addAudioClip($this->storedFile2->getId()); $result = $playlist->addAudioClip($this->storedFile2->getId());

View File

@ -16,11 +16,11 @@ class SchedulerTests extends PHPUnit_TestCase {
// Add a file // Add a file
$values = array("filepath" => dirname(__FILE__)."/test10001.mp3"); $values = array("filepath" => dirname(__FILE__)."/test10001.mp3");
$this->storedFile = StoredFile::Insert($values, false); $this->storedFile = Application_Model_StoredFile::Insert($values, false);
// Add a file // Add a file
$values = array("filepath" => dirname(__FILE__)."/test10002.mp3"); $values = array("filepath" => dirname(__FILE__)."/test10002.mp3");
$this->storedFile2 = StoredFile::Insert($values, false); $this->storedFile2 = Application_Model_StoredFile::Insert($values, false);
// Clear the schedule table // Clear the schedule table
//$sql = "DELETE FROM ".$CC_CONFIG["scheduleTable"]; //$sql = "DELETE FROM ".$CC_CONFIG["scheduleTable"];
@ -59,7 +59,7 @@ class SchedulerTests extends PHPUnit_TestCase {
function testAddAndRemovePlaylist() { function testAddAndRemovePlaylist() {
// Create a playlist // Create a playlist
$playlist = new Playlist(); $playlist = new Application_Model_Playlist();
$playlist->create("Scheduler Unit Test ".uniqid()); $playlist->create("Scheduler Unit Test ".uniqid());
$result = $playlist->addAudioClip($this->storedFile->getId()); $result = $playlist->addAudioClip($this->storedFile->getId());
$result = $playlist->addAudioClip($this->storedFile2->getId()); $result = $playlist->addAudioClip($this->storedFile2->getId());
@ -84,7 +84,7 @@ class SchedulerTests extends PHPUnit_TestCase {
$this->fail("Did not remove item."); $this->fail("Did not remove item.");
} }
Playlist::Delete($playlist->getId()); Application_Model_Playlist::Delete($playlist->getId());
} }
function testIsScheduleEmptyInRange() { function testIsScheduleEmptyInRange() {

View File

@ -43,7 +43,7 @@ class StoredFileTest extends PHPUnit_TestCase {
// Delete any old data from previous tests // Delete any old data from previous tests
$md5 = md5_file($filePath); $md5 = md5_file($filePath);
$duplicate = StoredFile::RecallByMd5($md5); $duplicate = Application_Model_StoredFile::RecallByMd5($md5);
if ($duplicate) { if ($duplicate) {
$duplicate->delete(); $duplicate->delete();
} }
@ -51,7 +51,7 @@ class StoredFileTest extends PHPUnit_TestCase {
// Test inserting a file by linking // Test inserting a file by linking
$values = array("filepath" => $filePath, $values = array("filepath" => $filePath,
"dc:description" => "Unit test ".time()); "dc:description" => "Unit test ".time());
$storedFile = StoredFile::Insert($values, false); $storedFile = Application_Model_StoredFile::Insert($values, false);
if (PEAR::isError($storedFile)) { if (PEAR::isError($storedFile)) {
$this->fail("Failed to create StoredFile: ".$storedFile->getMessage()); $this->fail("Failed to create StoredFile: ".$storedFile->getMessage());
return; return;
@ -64,7 +64,7 @@ class StoredFileTest extends PHPUnit_TestCase {
} }
// Test loading metadata // Test loading metadata
$f = new StoredFile(); $f = new Application_Model_StoredFile();
$f->__setGunid($storedFile->getGunid()); $f->__setGunid($storedFile->getGunid());
$f->loadMetadata(); $f->loadMetadata();
if (!is_array($md = $f->getMetadata())) { if (!is_array($md = $f->getMetadata())) {
@ -74,7 +74,7 @@ class StoredFileTest extends PHPUnit_TestCase {
//var_dump($md); //var_dump($md);
// Check if the length field has been set. // Check if the length field has been set.
$f2 = StoredFile::RecallByGunid($storedFile->getGunid()); $f2 = Application_Model_StoredFile::RecallByGunid($storedFile->getGunid());
$m2 = $f2->getMetadata(); $m2 = $f2->getMetadata();
if (!isset($m2["length"]) || $m2["length"] == "00:00:00.000000") { if (!isset($m2["length"]) || $m2["length"] == "00:00:00.000000") {
$this->fail("Length not reporting correctly in metadata."); $this->fail("Length not reporting correctly in metadata.");

View File

@ -24,17 +24,17 @@ $CC_DBC->query($sql);
/* /*
// Create a playlist // Create a playlist
$playlist = new Playlist(); $playlist = new Application_Model_Playlist();
$playlist->create("Calendar Load test playlist ".uniqid()); $playlist->create("Calendar Load test playlist ".uniqid());
// Add a file // Add a file
$values = array("filepath" => __DIR__."/test10001.mp3"); $values = array("filepath" => __DIR__."/test10001.mp3");
$storedFile = StoredFile::Insert($values, false); $storedFile = Application_Model_StoredFile::Insert($values, false);
$result = $playlist->addAudioClip($storedFile->getId()); $result = $playlist->addAudioClip($storedFile->getId());
// Add a file // Add a file
$values = array("filepath" => __DIR__."/test10002.mp3"); $values = array("filepath" => __DIR__."/test10002.mp3");
$storedFile2 = StoredFile::Insert($values, false); $storedFile2 = Application_Model_StoredFile::Insert($values, false);
$result = $playlist->addAudioClip($storedFile2->getId()); $result = $playlist->addAudioClip($storedFile2->getId());
$result = $playlist->addAudioClip($storedFile2->getId()); $result = $playlist->addAudioClip($storedFile2->getId());

View File

@ -16,7 +16,7 @@
</ul> </ul>
<?php endif; ?> <?php endif; ?>
</dd> </dd>
<dd class="block-display selected-item"><strong>Current Storage Folder:</strong><?php $stor = MusicDir::getStorDir(); echo $stor->getDirectory(); ?></dd> <dd class="block-display selected-item"><strong>Current Storage Folder:</strong><?php $stor = Application_Model_MusicDir::getStorDir(); echo $stor->getDirectory(); ?></dd>
<dt id="watchedFolder-label" class="block-display"> <dt id="watchedFolder-label" class="block-display">
<label class="required" for="watchedFolder"><?php echo $this->element->getElement('watchedFolder')->getLabel() ?></label> <label class="required" for="watchedFolder"><?php echo $this->element->getElement('watchedFolder')->getLabel() ?></label>
@ -33,7 +33,7 @@
</ul> </ul>
<?php endif; ?> <?php endif; ?>
</dd> </dd>
<?php $watched_dirs = MusicDir::getWatchedDirs(); ?> <?php $watched_dirs = Application_Model_MusicDir::getWatchedDirs(); ?>
<?php if (count($watched_dirs) > 0): ?> <?php if (count($watched_dirs) > 0): ?>
<?php foreach($watched_dirs as $watched_dir): ?> <?php foreach($watched_dirs as $watched_dir): ?>