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

@ -1,7 +1,7 @@
<?php
/**
* StoredFile class
* Application_Model_StoredFile class
*
* @package Airtime
* @subpackage StorageServer
@ -9,7 +9,7 @@
* @license http://www.gnu.org/licenses/gpl.txt
* @see MetaData
*/
class StoredFile {
class Application_Model_StoredFile {
/**
* @holds propel database object
@ -286,7 +286,7 @@ class StoredFile {
$playlists = array();
if (is_array($ids) && count($ids) > 0) {
foreach ($ids as $id) {
$playlists[] = Playlist::Recall($id);
$playlists[] = Application_Model_Playlist::Recall($id);
}
}
return $playlists;
@ -310,7 +310,7 @@ class StoredFile {
}
}
Playlist::DeleteFileFromAllPlaylists($this->getId());
Application_Model_Playlist::DeleteFileFromAllPlaylists($this->getId());
$this->_file->delete();
if (isset($res)) {
@ -410,7 +410,7 @@ class StoredFile {
*/
public function getFilePath()
{
$music_dir = MusicDir::getDirByPK($this->_file->getDbDirectory());
$music_dir = Application_Model_MusicDir::getDirByPK($this->_file->getDbDirectory());
$filepath = $this->_file->getDbFilepath();
return $music_dir->getDirectory().$filepath;
@ -423,11 +423,11 @@ class StoredFile {
*/
public function setFilePath($p_filepath)
{
$path_info = MusicDir::splitFilePath($p_filepath);
$path_info = Application_Model_MusicDir::splitFilePath($p_filepath);
if (is_null($path_info)) {
return -1;
}
$musicDir = MusicDir::getDirByPath($path_info[0]);
$musicDir = Application_Model_MusicDir::getDirByPath($path_info[0]);
$this->_file->setDbDirectory($musicDir->getId());
$this->_file->setDbFilepath($path_info[1]);
@ -459,7 +459,7 @@ class StoredFile {
$file = new CcFiles();
$file->setDbGunid(md5(uniqid("", true)));
$storedFile = new StoredFile();
$storedFile = new Application_Model_StoredFile();
$storedFile->_file = $file;
if(isset($md['MDATA_KEY_FILEPATH'])) {
@ -490,7 +490,7 @@ class StoredFile {
* global unique id of file
* @param string $p_md5sum
* MD5 sum of the file
* @return StoredFile|NULL
* @return Application_Model_StoredFile|NULL
* 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)
@ -509,12 +509,12 @@ class StoredFile {
->findOne();
}
else if (isset($p_filepath)) {
$path_info = MusicDir::splitFilePath($p_filepath);
$path_info = Application_Model_MusicDir::splitFilePath($p_filepath);
if (is_null($path_info)) {
return null;
}
$music_dir = MusicDir::getDirByPath($path_info[0]);
$music_dir = Application_Model_MusicDir::getDirByPath($path_info[0]);
$file = CcFilesQuery::create()
->filterByDbDirectory($music_dir->getId())
@ -526,7 +526,7 @@ class StoredFile {
}
if (isset($file)) {
$storedFile = new StoredFile();
$storedFile = new Application_Model_StoredFile();
$storedFile->_file = $file;
return $storedFile;
@ -547,34 +547,34 @@ class StoredFile {
*
* @param string $p_gunid
* global unique id of file
* @return StoredFile|NULL
* @return Application_Model_StoredFile|NULL
*/
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
* @return StoredFile|NULL
* @return Application_Model_StoredFile|NULL
*/
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.
* @return StoredFile|NULL
* @return Application_Model_StoredFile|NULL
*/
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) {
@ -616,7 +616,7 @@ class StoredFile {
(".$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"][] = "plt.length > INTERVAL '00:00:00'";
return StoredFile::searchFiles($fromTable, $datatables);
return Application_Model_StoredFile::searchFiles($fromTable, $datatables);
}
public static function searchFiles($fromTable, $data)
@ -801,7 +801,7 @@ class StoredFile {
/*$audio_file = $p_targetDir . DIRECTORY_SEPARATOR . $fileName;
$md5 = md5_file($audio_file);
$duplicate = StoredFile::RecallByMd5($md5);
$duplicate = Application_Model_StoredFile::RecallByMd5($md5);
if ($duplicate) {
if (PEAR::isError($duplicate)) {
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 .= "/organize";
@ -827,7 +827,7 @@ class StoredFile {
$audio_file = $p_targetDir . DIRECTORY_SEPARATOR . $fileName;
Logging::log('copyFileToStor: moving file '.$audio_file);
$md5 = md5_file($audio_file);
$duplicate = StoredFile::RecallByMd5($md5);
$duplicate = Application_Model_StoredFile::RecallByMd5($md5);
if ($duplicate) {
if (PEAR::isError($duplicate)) {
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 .= "/organize";