Merge branch 'master' of dev.sourcefabric.org:campcaster
This commit is contained in:
commit
9509dc52e0
13 changed files with 395 additions and 434 deletions
|
@ -115,7 +115,7 @@ class PluploadController extends Zend_Controller_Action
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$metadata = camp_get_audio_metadata($audio_file);
|
$metadata = Metadata::LoadFromFile($audio_file);
|
||||||
|
|
||||||
if (PEAR::isError($metadata)) {
|
if (PEAR::isError($metadata)) {
|
||||||
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": ' + $metadata->getMessage() + '}}');
|
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": ' + $metadata->getMessage() + '}}');
|
||||||
|
|
|
@ -188,7 +188,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
|
|
||||||
$this->view->showContent = $show->getShowContent();
|
$this->view->showContent = $show->getShowContent();
|
||||||
$this->view->timeFilled = $show->getTimeScheduled();
|
$this->view->timeFilled = $show->getTimeScheduled();
|
||||||
$this->view->percentFilled = $show->getPercentScheduledInRange();
|
$this->view->percentFilled = $show->getPercentScheduled();
|
||||||
|
|
||||||
$this->view->chosen = $this->view->render('schedule/scheduled-content.phtml');
|
$this->view->chosen = $this->view->render('schedule/scheduled-content.phtml');
|
||||||
unset($this->view->showContent);
|
unset($this->view->showContent);
|
||||||
|
@ -237,7 +237,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
|
|
||||||
$this->view->showContent = $show->getShowContent();
|
$this->view->showContent = $show->getShowContent();
|
||||||
$this->view->timeFilled = $show->getTimeScheduled();
|
$this->view->timeFilled = $show->getTimeScheduled();
|
||||||
$this->view->percentFilled = $show->getPercentScheduledInRange();
|
$this->view->percentFilled = $show->getPercentScheduled();
|
||||||
$this->view->chosen = $this->view->render('schedule/scheduled-content.phtml');
|
$this->view->chosen = $this->view->render('schedule/scheduled-content.phtml');
|
||||||
unset($this->view->showContent);
|
unset($this->view->showContent);
|
||||||
}
|
}
|
||||||
|
@ -268,7 +268,7 @@ class ScheduleController extends Zend_Controller_Action
|
||||||
$this->view->timeFilled = $show->getTimeScheduled();
|
$this->view->timeFilled = $show->getTimeScheduled();
|
||||||
$this->view->showName = $show->getName();
|
$this->view->showName = $show->getName();
|
||||||
$this->view->showLength = $show->getShowLength();
|
$this->view->showLength = $show->getShowLength();
|
||||||
$this->view->percentFilled = $show->getPercentScheduledInRange();
|
$this->view->percentFilled = $show->getPercentScheduled();
|
||||||
|
|
||||||
$this->view->s_wday = $dateInfo_s['weekday'];
|
$this->view->s_wday = $dateInfo_s['weekday'];
|
||||||
$this->view->s_month = $dateInfo_s['month'];
|
$this->view->s_month = $dateInfo_s['month'];
|
||||||
|
|
|
@ -443,11 +443,10 @@ class BasicStor {
|
||||||
//"dc:creator" => "artist_name",
|
//"dc:creator" => "artist_name",
|
||||||
//dc:description
|
//dc:description
|
||||||
|
|
||||||
global $g_metadata_xml_to_db_mapping;
|
|
||||||
$plSelect = "SELECT ";
|
$plSelect = "SELECT ";
|
||||||
$fileSelect = "SELECT ";
|
$fileSelect = "SELECT ";
|
||||||
$_SESSION["br"] = "";
|
$_SESSION["br"] = "";
|
||||||
foreach ($g_metadata_xml_to_db_mapping as $key => $val){
|
foreach (Metadata::GetMapMetadataXmlToDb() as $key => $val){
|
||||||
$_SESSION["br"] .= "key: ".$key." value:".$val.", ";
|
$_SESSION["br"] .= "key: ".$key." value:".$val.", ";
|
||||||
if($key === "dc:title"){
|
if($key === "dc:title"){
|
||||||
$plSelect .= "name AS ".$val.", ";
|
$plSelect .= "name AS ".$val.", ";
|
||||||
|
|
|
@ -75,7 +75,8 @@ class Application_Model_Nowplaying
|
||||||
$type = "b";
|
$type = "b";
|
||||||
} else if (strtotime($item['item_ends']) < strtotime($timeNow)){
|
} else if (strtotime($item['item_ends']) < strtotime($timeNow)){
|
||||||
$type = "p";
|
$type = "p";
|
||||||
} else if (strtotime($item['item_starts']) < strtotime($timeNow) && strtotime($timeNow) < strtotime($item['item_ends'])){
|
} else if (strtotime($item['item_starts']) < strtotime($timeNow) && strtotime($timeNow) < strtotime($item['item_ends'])
|
||||||
|
&& strtotime($item['show_starts']) < strtotime($timeNow) && strtotime($timeNow) < strtotime($item['show_ends'])){
|
||||||
$type = "c";
|
$type = "c";
|
||||||
} else {
|
} else {
|
||||||
$type = "n";
|
$type = "n";
|
||||||
|
|
|
@ -278,12 +278,11 @@ class Schedule {
|
||||||
return ($count == '0');
|
return ($count == '0');
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getTimeUnScheduledInRange($s_datetime, $e_datetime) {
|
public static function getTimeUnScheduledInRange($instance_id, $s_datetime, $e_datetime) {
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG, $CC_DBC;
|
||||||
|
|
||||||
$sql = "SELECT SUM(clip_length) FROM ".$CC_CONFIG["scheduleTable"]."
|
$sql = "SELECT SUM(clip_length) FROM $CC_CONFIG[scheduleTable]"
|
||||||
WHERE (starts >= '{$s_datetime}')
|
." WHERE instance_id = $instance_id";
|
||||||
AND (ends <= '{$e_datetime}')";
|
|
||||||
|
|
||||||
$time = $CC_DBC->GetOne($sql);
|
$time = $CC_DBC->GetOne($sql);
|
||||||
|
|
||||||
|
@ -314,6 +313,20 @@ class Schedule {
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function GetTotalShowTime($instance_id) {
|
||||||
|
global $CC_CONFIG, $CC_DBC;
|
||||||
|
|
||||||
|
$sql = "SELECT SUM(clip_length) FROM $CC_CONFIG[scheduleTable]"
|
||||||
|
." WHERE instance_id = $instance_id";
|
||||||
|
|
||||||
|
$res = $CC_DBC->GetOne($sql);
|
||||||
|
|
||||||
|
if(is_null($res))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
public static function getPercentScheduledInRange($s_datetime, $e_datetime) {
|
public static function getPercentScheduledInRange($s_datetime, $e_datetime) {
|
||||||
|
|
||||||
$time = Schedule::getTimeScheduledInRange($s_datetime, $e_datetime);
|
$time = Schedule::getTimeScheduledInRange($s_datetime, $e_datetime);
|
||||||
|
@ -337,6 +350,25 @@ class Schedule {
|
||||||
return $percent;
|
return $percent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function GetPercentScheduled($instance_id, $s_datetime, $e_datetime){
|
||||||
|
$time = Schedule::GetTotalShowTime($instance_id);
|
||||||
|
|
||||||
|
$s_epoch = strtotime($s_datetime);
|
||||||
|
$e_epoch = strtotime($e_datetime);
|
||||||
|
|
||||||
|
$con = Propel::getConnection(CcSchedulePeer::DATABASE_NAME);
|
||||||
|
$sql = "SELECT EXTRACT(EPOCH FROM INTERVAL '{$time}')";
|
||||||
|
$r = $con->query($sql);
|
||||||
|
$i_epoch = $r->fetchColumn(0);
|
||||||
|
|
||||||
|
$percent = ceil(($i_epoch / ($e_epoch - $s_epoch)) * 100);
|
||||||
|
|
||||||
|
if ($percent > 100)
|
||||||
|
$percent = 100;
|
||||||
|
|
||||||
|
return $percent;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return TRUE if file is going to be played in the future.
|
* Return TRUE if file is going to be played in the future.
|
||||||
|
@ -490,7 +522,8 @@ class Schedule {
|
||||||
." WHERE st.playlist_id = pt.id"
|
." WHERE st.playlist_id = pt.id"
|
||||||
." AND st.file_id = ft.id"
|
." AND st.file_id = ft.id"
|
||||||
." AND st.instance_id = si.id"
|
." AND st.instance_id = si.id"
|
||||||
." AND si.show_id = show.id";
|
." AND si.show_id = show.id"
|
||||||
|
." AND st.starts < si.ends";
|
||||||
|
|
||||||
if ($timePeriod < 0){
|
if ($timePeriod < 0){
|
||||||
$sql .= " AND st.ends < TIMESTAMP '$timeStamp'"
|
$sql .= " AND st.ends < TIMESTAMP '$timeStamp'"
|
||||||
|
|
|
@ -456,6 +456,10 @@ class ShowInstance {
|
||||||
return $showInstance->getDbShowId();
|
return $showInstance->getDbShowId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getShowInstanceId() {
|
||||||
|
return $this->_instanceId;
|
||||||
|
}
|
||||||
|
|
||||||
public function getName() {
|
public function getName() {
|
||||||
$show = CcShowQuery::create()->findPK($this->getShowId());
|
$show = CcShowQuery::create()->findPK($this->getShowId());
|
||||||
return $show->getDbName();
|
return $show->getDbName();
|
||||||
|
@ -635,11 +639,8 @@ class ShowInstance {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTimeScheduled() {
|
public function getTimeScheduled() {
|
||||||
|
$instance_id = $this->getShowInstanceId();
|
||||||
$start_timestamp = $this->getShowStart();
|
$time = Schedule::GetTotalShowTime($instance_id);
|
||||||
$end_timestamp = $this->getShowEnd();
|
|
||||||
|
|
||||||
$time = Schedule::getTimeScheduledInRange($start_timestamp, $end_timestamp);
|
|
||||||
|
|
||||||
return $time;
|
return $time;
|
||||||
}
|
}
|
||||||
|
@ -648,8 +649,9 @@ class ShowInstance {
|
||||||
|
|
||||||
$start_timestamp = $this->getShowStart();
|
$start_timestamp = $this->getShowStart();
|
||||||
$end_timestamp = $this->getShowEnd();
|
$end_timestamp = $this->getShowEnd();
|
||||||
|
$instance_id = $this->getShowInstanceId();
|
||||||
|
|
||||||
$time = Schedule::getTimeUnScheduledInRange($start_timestamp, $end_timestamp);
|
$time = Schedule::getTimeUnScheduledInRange($instance_id, $start_timestamp, $end_timestamp);
|
||||||
|
|
||||||
return $time;
|
return $time;
|
||||||
}
|
}
|
||||||
|
@ -662,6 +664,14 @@ class ShowInstance {
|
||||||
return Schedule::getPercentScheduledInRange($start_timestamp, $end_timestamp);
|
return Schedule::getPercentScheduledInRange($start_timestamp, $end_timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getPercentScheduled(){
|
||||||
|
$start_timestamp = $this->getShowStart();
|
||||||
|
$end_timestamp = $this->getShowEnd();
|
||||||
|
$instance_id = $this->getShowInstanceId();
|
||||||
|
|
||||||
|
return Schedule::GetPercentScheduled($instance_id, $start_timestamp, $end_timestamp);
|
||||||
|
}
|
||||||
|
|
||||||
public function getShowLength(){
|
public function getShowLength(){
|
||||||
global $CC_DBC;
|
global $CC_DBC;
|
||||||
|
|
||||||
|
@ -794,6 +804,7 @@ class Show_DAL{
|
||||||
." WHERE ((si.starts < TIMESTAMP '$timeNow' - INTERVAL '$start seconds' AND si.ends > TIMESTAMP '$timeNow' - INTERVAL '$start seconds')"
|
." WHERE ((si.starts < TIMESTAMP '$timeNow' - INTERVAL '$start seconds' AND si.ends > TIMESTAMP '$timeNow' - INTERVAL '$start seconds')"
|
||||||
." OR (si.starts > TIMESTAMP '$timeNow' - INTERVAL '$start seconds' AND si.ends < TIMESTAMP '$timeNow' + INTERVAL '$end seconds')"
|
." OR (si.starts > TIMESTAMP '$timeNow' - INTERVAL '$start seconds' AND si.ends < TIMESTAMP '$timeNow' + INTERVAL '$end seconds')"
|
||||||
." OR (si.starts < TIMESTAMP '$timeNow' + INTERVAL '$end seconds' AND si.ends > TIMESTAMP '$timeNow' + INTERVAL '$end seconds'))"
|
." OR (si.starts < TIMESTAMP '$timeNow' + INTERVAL '$end seconds' AND si.ends > TIMESTAMP '$timeNow' + INTERVAL '$end seconds'))"
|
||||||
|
." AND (st.starts < si.ends)"
|
||||||
." ORDER BY st.starts";
|
." ORDER BY st.starts";
|
||||||
|
|
||||||
return $CC_DBC->GetAll($sql);
|
return $CC_DBC->GetAll($sql);
|
||||||
|
|
|
@ -4,8 +4,9 @@ require_once(dirname(__FILE__)."/../../library/getid3/var/getid3.php");
|
||||||
require_once("BasicStor.php");
|
require_once("BasicStor.php");
|
||||||
require_once("Schedule.php");
|
require_once("Schedule.php");
|
||||||
|
|
||||||
global $g_metadata_xml_to_db_mapping;
|
class Metadata {
|
||||||
$g_metadata_xml_to_db_mapping = array(
|
|
||||||
|
private static $MAP_METADATA_XML_TO_DB = array(
|
||||||
"ls:type" => "ftype",
|
"ls:type" => "ftype",
|
||||||
"dc:format" => "format",
|
"dc:format" => "format",
|
||||||
"ls:bitrate" => "bit_rate",
|
"ls:bitrate" => "bit_rate",
|
||||||
|
@ -52,6 +53,10 @@ $g_metadata_xml_to_db_mapping = array(
|
||||||
"dc:contributor" => "contributor",
|
"dc:contributor" => "contributor",
|
||||||
"dc:language" => "language");
|
"dc:language" => "language");
|
||||||
|
|
||||||
|
public static function GetMapMetadataXmlToDb() {
|
||||||
|
return Metadata::$MAP_METADATA_XML_TO_DB;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Track numbers in metadata tags can come in many formats:
|
* Track numbers in metadata tags can come in many formats:
|
||||||
* "1 of 20", "1/20", "20/1". This function parses the track
|
* "1 of 20", "1/20", "20/1". This function parses the track
|
||||||
|
@ -61,7 +66,7 @@ $g_metadata_xml_to_db_mapping = array(
|
||||||
* @param string $p_trackNumber
|
* @param string $p_trackNumber
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
function camp_parse_track_number($p_trackNumber)
|
public static function ParseTrackNumber($p_trackNumber)
|
||||||
{
|
{
|
||||||
$num = trim($p_trackNumber);
|
$num = trim($p_trackNumber);
|
||||||
if (!is_numeric($num)) {
|
if (!is_numeric($num)) {
|
||||||
|
@ -84,8 +89,7 @@ function camp_parse_track_number($p_trackNumber)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add data to the global array $mdata, also sets global variables
|
* Add data to the array $p_mdata.
|
||||||
* $titleHaveSet and $titleKey.
|
|
||||||
*
|
*
|
||||||
* Converts the given string ($val) into UTF-8.
|
* Converts the given string ($val) into UTF-8.
|
||||||
*
|
*
|
||||||
|
@ -98,7 +102,7 @@ function camp_parse_track_number($p_trackNumber)
|
||||||
* @param string $p_inputEncoding
|
* @param string $p_inputEncoding
|
||||||
* Encoding type of the input value.
|
* Encoding type of the input value.
|
||||||
*/
|
*/
|
||||||
function camp_add_metadata(&$p_mdata, $p_key, $p_val, $p_inputEncoding='iso-8859-1')
|
public static function AddToArray(&$p_mdata, $p_key, $p_val, $p_inputEncoding='iso-8859-1')
|
||||||
{
|
{
|
||||||
if (!is_null($p_val)) {
|
if (!is_null($p_val)) {
|
||||||
$data = $p_val;
|
$data = $p_val;
|
||||||
|
@ -143,7 +147,7 @@ function camp_add_metadata(&$p_mdata, $p_key, $p_val, $p_inputEncoding='iso-8859
|
||||||
* to the return array.
|
* to the return array.
|
||||||
* @return array|PEAR_Error
|
* @return array|PEAR_Error
|
||||||
*/
|
*/
|
||||||
function camp_get_audio_metadata($p_filename, $p_testonly = false)
|
public static function LoadFromFile($p_filename, $p_testonly = false)
|
||||||
{
|
{
|
||||||
$getID3 = new getID3();
|
$getID3 = new getID3();
|
||||||
$infoFromFile = $getID3->analyze($p_filename);
|
$infoFromFile = $getID3->analyze($p_filename);
|
||||||
|
@ -289,9 +293,9 @@ function camp_get_audio_metadata($p_filename, $p_testonly = false)
|
||||||
|
|
||||||
// Special case handling for track number
|
// Special case handling for track number
|
||||||
if ($key == "ls:track_num") {
|
if ($key == "ls:track_num") {
|
||||||
$data = camp_parse_track_number($data);
|
$data = Metadata::ParseTrackNumber($data);
|
||||||
}
|
}
|
||||||
camp_add_metadata($mdata, $key, $data, $enc);
|
Metadata::AddToArray($mdata, $key, $data, $enc);
|
||||||
if ($key == $titleKey) {
|
if ($key == $titleKey) {
|
||||||
$titleHaveSet = TRUE;
|
$titleHaveSet = TRUE;
|
||||||
}
|
}
|
||||||
|
@ -304,10 +308,11 @@ function camp_get_audio_metadata($p_filename, $p_testonly = false)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$titleHaveSet || trim($mdata[$titleKey]) == '') {
|
if (!$titleHaveSet || trim($mdata[$titleKey]) == '') {
|
||||||
camp_add_metadata($mdata, $titleKey, basename($p_filename));
|
Metadata::AddToArray($mdata, $titleKey, basename($p_filename));
|
||||||
}
|
}
|
||||||
return $mdata;
|
return $mdata;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -316,7 +321,7 @@ function camp_get_audio_metadata($p_filename, $p_testonly = false)
|
||||||
* Airtime file storage support class.<br>
|
* Airtime file storage support class.<br>
|
||||||
* Represents one virtual file in storage. Virtual file has up to two parts:
|
* Represents one virtual file in storage. Virtual file has up to two parts:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>metadata in database - represented by MetaData class</li>
|
* <li>metadata in database </li>
|
||||||
* <li>binary media data in real file</li>
|
* <li>binary media data in real file</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
|
@ -456,9 +461,9 @@ class StoredFile {
|
||||||
*/
|
*/
|
||||||
public static function xmlCategoryToDbColumn($p_category)
|
public static function xmlCategoryToDbColumn($p_category)
|
||||||
{
|
{
|
||||||
global $g_metadata_xml_to_db_mapping;
|
$map = Metadata::GetMapMetadataXmlToDb();
|
||||||
if (array_key_exists($p_category, $g_metadata_xml_to_db_mapping)) {
|
if (array_key_exists($p_category, $map)) {
|
||||||
return $g_metadata_xml_to_db_mapping[$p_category];
|
return $map[$p_category];
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -472,8 +477,7 @@ class StoredFile {
|
||||||
*/
|
*/
|
||||||
public static function dbColumnToXmlCatagory($p_dbColumn)
|
public static function dbColumnToXmlCatagory($p_dbColumn)
|
||||||
{
|
{
|
||||||
global $g_metadata_xml_to_db_mapping;
|
$str = array_search($p_dbColumn, Metadata::GetMapMetadataXmlToDb());
|
||||||
$str = array_search($p_dbColumn, $g_metadata_xml_to_db_mapping);
|
|
||||||
// make return value consistent with xmlCategoryToDbColumn()
|
// make return value consistent with xmlCategoryToDbColumn()
|
||||||
if ($str === FALSE) {
|
if ($str === FALSE) {
|
||||||
$str = null;
|
$str = null;
|
||||||
|
@ -607,7 +611,7 @@ class StoredFile {
|
||||||
if (isset($p_values["metadata"])) {
|
if (isset($p_values["metadata"])) {
|
||||||
$metadata = $p_values['metadata'];
|
$metadata = $p_values['metadata'];
|
||||||
} else {
|
} else {
|
||||||
$metadata = camp_get_audio_metadata($p_values["filepath"]);
|
$metadata = Metadata::LoadFromFile($p_values["filepath"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$storedFile->name = isset($p_values['filename']) ? $p_values['filename'] : $p_values["filepath"];
|
$storedFile->name = isset($p_values['filename']) ? $p_values['filename'] : $p_values["filepath"];
|
||||||
|
@ -906,24 +910,6 @@ class StoredFile {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Analyze file with getid3 module.<br>
|
|
||||||
* Obtain some metadata stored in media file.<br>
|
|
||||||
* This method should be used for prefilling metadata input form.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
* hierarchical hasharray with information about media file
|
|
||||||
*/
|
|
||||||
public function analyzeFile()
|
|
||||||
{
|
|
||||||
if (!$this->exists) {
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
$ia = camp_get_audio_metadata($this->filepath);
|
|
||||||
return $ia;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create instance of StoredFile object and make copy of existing file
|
* Create instance of StoredFile object and make copy of existing file
|
||||||
*
|
*
|
||||||
|
@ -1511,7 +1497,7 @@ class StoredFile {
|
||||||
*/
|
*/
|
||||||
public function getMime()
|
public function getMime()
|
||||||
{
|
{
|
||||||
$a = $this->analyzeFile();
|
$a = Metadata::LoadFromFile($this->filepath);
|
||||||
if (PEAR::isError($a)) {
|
if (PEAR::isError($a)) {
|
||||||
return $a;
|
return $a;
|
||||||
}
|
}
|
||||||
|
@ -1621,13 +1607,13 @@ class StoredFile {
|
||||||
return $CC_CONFIG['accessDir']."/$p_token.$p_ext";
|
return $CC_CONFIG['accessDir']."/$p_token.$p_ext";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function searchFilesForPlaylistBuilder($datatables) {
|
|
||||||
|
|
||||||
global $CC_CONFIG, $g_metadata_xml_to_db_mapping;
|
public static function searchFilesForPlaylistBuilder($datatables) {
|
||||||
|
global $CC_CONFIG;
|
||||||
|
|
||||||
$plSelect = "SELECT ";
|
$plSelect = "SELECT ";
|
||||||
$fileSelect = "SELECT ";
|
$fileSelect = "SELECT ";
|
||||||
foreach ($g_metadata_xml_to_db_mapping as $key => $val){
|
foreach (Metadata::GetMapMetadataXmlToDb() as $key => $val){
|
||||||
|
|
||||||
if($key === "dc:title"){
|
if($key === "dc:title"){
|
||||||
$plSelect .= "name AS ".$val.", ";
|
$plSelect .= "name AS ".$val.", ";
|
||||||
|
@ -1667,16 +1653,15 @@ class StoredFile {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function searchPlaylistsForSchedule($p_length, $datatables) {
|
public static function searchPlaylistsForSchedule($p_length, $datatables) {
|
||||||
|
|
||||||
$fromTable = "cc_playlist AS pl LEFT JOIN cc_playlisttimes AS plt USING(id) LEFT JOIN cc_subjs AS sub ON pl.editedby = sub.id";
|
$fromTable = "cc_playlist AS pl LEFT JOIN cc_playlisttimes AS plt USING(id) LEFT JOIN cc_subjs AS sub ON pl.editedby = sub.id";
|
||||||
|
$datatables["optWhere"][] = "INTERVAL '{$p_length}' > INTERVAL '00:00:00'";
|
||||||
$datatables["optWhere"][] = "plt.length <= INTERVAL '{$p_length}'";
|
|
||||||
$datatables["optWhere"][] = "plt.length > INTERVAL '00:00:00'";
|
$datatables["optWhere"][] = "plt.length > INTERVAL '00:00:00'";
|
||||||
|
|
||||||
return StoredFile::searchFiles($fromTable, $datatables);
|
return StoredFile::searchFiles($fromTable, $datatables);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function searchFiles($fromTable, $data)
|
public static function searchFiles($fromTable, $data)
|
||||||
{
|
{
|
||||||
global $CC_CONFIG, $CC_DBC;
|
global $CC_CONFIG, $CC_DBC;
|
||||||
|
@ -1694,16 +1679,12 @@ class StoredFile {
|
||||||
|
|
||||||
// Where clause
|
// Where clause
|
||||||
if(isset($data["optWhere"])) {
|
if(isset($data["optWhere"])) {
|
||||||
|
|
||||||
$where[] = join(" AND ", $data["optWhere"]);
|
$where[] = join(" AND ", $data["optWhere"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($searchTerms)) {
|
if(isset($searchTerms)) {
|
||||||
|
|
||||||
$searchCols = array();
|
$searchCols = array();
|
||||||
|
|
||||||
for($i=0; $i<$data["iColumns"]; $i++) {
|
for($i=0; $i<$data["iColumns"]; $i++) {
|
||||||
|
|
||||||
if($data["bSearchable_".$i] == "true") {
|
if($data["bSearchable_".$i] == "true") {
|
||||||
$searchCols[] = $columnsDisplayed[$i];
|
$searchCols[] = $columnsDisplayed[$i];
|
||||||
}
|
}
|
||||||
|
@ -1712,7 +1693,6 @@ class StoredFile {
|
||||||
$outerCond = array();
|
$outerCond = array();
|
||||||
|
|
||||||
foreach($searchTerms as $term) {
|
foreach($searchTerms as $term) {
|
||||||
|
|
||||||
$innerCond = array();
|
$innerCond = array();
|
||||||
|
|
||||||
foreach($searchCols as $col) {
|
foreach($searchCols as $col) {
|
||||||
|
@ -1738,12 +1718,9 @@ class StoredFile {
|
||||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ORDERED);
|
$CC_DBC->setFetchMode(DB_FETCHMODE_ORDERED);
|
||||||
|
|
||||||
if(isset($where)) {
|
if(isset($where)) {
|
||||||
|
|
||||||
$where = join(" AND ", $where);
|
$where = join(" AND ", $where);
|
||||||
|
|
||||||
$sql = $selectorCount." FROM ".$fromTable." WHERE ".$where;
|
$sql = $selectorCount." FROM ".$fromTable." WHERE ".$where;
|
||||||
$totalDisplayRows = $CC_DBC->getOne($sql);
|
$totalDisplayRows = $CC_DBC->getOne($sql);
|
||||||
|
|
||||||
$sql = $selectorRows." FROM ".$fromTable." WHERE ".$where." ORDER BY ".$orderby." OFFSET ".$data["iDisplayStart"]." LIMIT ".$data["iDisplayLength"];
|
$sql = $selectorRows." FROM ".$fromTable." WHERE ".$where." ORDER BY ".$orderby." OFFSET ".$data["iDisplayStart"]." LIMIT ".$data["iDisplayLength"];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1762,79 +1739,6 @@ class StoredFile {
|
||||||
}
|
}
|
||||||
|
|
||||||
return array("sEcho" => intval($data["sEcho"]), "iTotalDisplayRecords" => $totalDisplayRows, "iTotalRecords" => $totalRows, "aaData" => $results);
|
return array("sEcho" => intval($data["sEcho"]), "iTotalDisplayRecords" => $totalDisplayRows, "iTotalRecords" => $totalRows, "aaData" => $results);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
$match = array(
|
|
||||||
"0" => "ILIKE",
|
|
||||||
"1" => "=",
|
|
||||||
"2" => "<",
|
|
||||||
"3" => "<=",
|
|
||||||
"4" => ">",
|
|
||||||
"5" => ">=",
|
|
||||||
"6" => "!=",
|
|
||||||
);
|
|
||||||
|
|
||||||
$or_cond = array();
|
|
||||||
$inner = $quick ? 'OR':'AND';
|
|
||||||
$outer = $quick ? 'AND':'OR';
|
|
||||||
foreach (array_keys($md) as $group) {
|
|
||||||
|
|
||||||
if(strpos($group, 'group') === false) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$and_cond = array();
|
|
||||||
foreach (array_keys($md[$group]) as $row) {
|
|
||||||
|
|
||||||
$string = $g_metadata_xml_to_db_mapping[$md[$group][$row]["metadata"]];
|
|
||||||
|
|
||||||
$string = $string ." ".$match[$md[$group][$row]["match"]];
|
|
||||||
|
|
||||||
if ($md[$group][$row]["match"] === "0")
|
|
||||||
$string = $string." '%". $md[$group][$row]["search"]."%'";
|
|
||||||
else
|
|
||||||
$string = $string." '". $md[$group][$row]["search"]."'";
|
|
||||||
|
|
||||||
$and_cond[] = $string;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(count($and_cond) > 0) {
|
|
||||||
$or_cond[] = "(".join(" ".$inner." ", $and_cond).")";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(count($or_cond) > 0) {
|
|
||||||
$where = " WHERE ". join(" ".$outer." ", $or_cond);
|
|
||||||
$sql = $sql . $where;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($count) {
|
|
||||||
return $CC_DBC->getOne($sql);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!is_null($order)) {
|
|
||||||
$ob = " ORDER BY ".$g_metadata_xml_to_db_mapping[$order["category"]]." ".$order["order"].", id ";
|
|
||||||
$sql = $sql . $ob;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
$ob = " ORDER BY artist_name asc, id";
|
|
||||||
$sql = $sql . $ob;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!is_null($page) && !is_null($limit)) {
|
|
||||||
$offset = $page * $limit - ($limit);
|
|
||||||
$paginate = " LIMIT ".$limit. " OFFSET " .$offset;
|
|
||||||
$sql = $sql . $paginate;
|
|
||||||
}
|
|
||||||
//echo var_dump($md);
|
|
||||||
//echo $sql;
|
|
||||||
*/
|
|
||||||
|
|
||||||
//return $CC_DBC->getAll($sql);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ class StoredFileTest extends PHPUnit_TestCase {
|
||||||
|
|
||||||
function testGetAudioMetadata() {
|
function testGetAudioMetadata() {
|
||||||
$filePath = dirname(__FILE__)."/ex1.mp3";
|
$filePath = dirname(__FILE__)."/ex1.mp3";
|
||||||
$metadata = camp_get_audio_metadata($filePath);
|
$metadata = Metadata::LoadFromFile($filePath);
|
||||||
if (PEAR::isError($metadata)) {
|
if (PEAR::isError($metadata)) {
|
||||||
$this->fail($metadata->getMessage());
|
$this->fail($metadata->getMessage());
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
<div id="show_progressbar"></div>
|
<div id="show_progressbar"></div>
|
||||||
<span id="show_length" class="time"><?php echo $this->showLength; ?></span>
|
<span id="show_length" class="time"><?php echo $this->showLength; ?></span>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="show_time_warning"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -18,7 +18,6 @@ if (isset($arr["DOCUMENT_ROOT"]) && ($arr["DOCUMENT_ROOT"] != "") ) {
|
||||||
createAPIKey();
|
createAPIKey();
|
||||||
|
|
||||||
require_once(dirname(__FILE__).'/../application/configs/conf.php');
|
require_once(dirname(__FILE__).'/../application/configs/conf.php');
|
||||||
require_once(dirname(__FILE__).'/../application/models/GreenBox.php');
|
|
||||||
require_once(dirname(__FILE__).'/installInit.php');
|
require_once(dirname(__FILE__).'/installInit.php');
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,8 +35,8 @@ function rand_string($len=20, $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789')
|
||||||
function createAPIKey(){
|
function createAPIKey(){
|
||||||
|
|
||||||
$api_key = rand_string();
|
$api_key = rand_string();
|
||||||
updateINIKeyValues('../build/airtime.conf', 'api_key', $api_key);
|
updateINIKeyValues(__DIR__.'/../build/airtime.conf', 'api_key', $api_key);
|
||||||
updateINIKeyValues('../pypo/config.cfg', 'api_key', "'$api_key'");
|
updateINIKeyValues(__DIR__.'/../pypo/config.cfg', 'api_key', "'$api_key'");
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkIfRoot(){
|
function checkIfRoot(){
|
||||||
|
|
|
@ -22,6 +22,15 @@ function setScheduleDialogHtml(json) {
|
||||||
|
|
||||||
$("#show_time_filled").empty().append(json.timeFilled);
|
$("#show_time_filled").empty().append(json.timeFilled);
|
||||||
$("#show_progressbar").progressbar( "value" , json.percentFilled );
|
$("#show_progressbar").progressbar( "value" , json.percentFilled );
|
||||||
|
|
||||||
|
var showFilled = $("#show_time_filled").text().split('.')[0];
|
||||||
|
var showLength = $("#show_length").text();
|
||||||
|
|
||||||
|
if (showFilled > showLength){
|
||||||
|
$("#show_time_warning").text("Shows longer than their scheduled time will be cut off by a following show.");
|
||||||
|
} else {
|
||||||
|
$("#show_time_warning").empty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setScheduleDialogEvents(dialog) {
|
function setScheduleDialogEvents(dialog) {
|
||||||
|
|
|
@ -60,7 +60,7 @@ var columns = [{"sTitle": "type", "bVisible":false},
|
||||||
{"sTitle":"Album"},
|
{"sTitle":"Album"},
|
||||||
{"sTitle":"Playlist"},
|
{"sTitle":"Playlist"},
|
||||||
{"sTitle":"Show"},
|
{"sTitle":"Show"},
|
||||||
{"sTitle":"instance_id", "bVisible":true}];
|
{"sTitle":"instance_id", "bVisible":false}];
|
||||||
|
|
||||||
function getDateString(){
|
function getDateString(){
|
||||||
var date0 = $("#datepicker").datepicker("getDate");
|
var date0 = $("#datepicker").datepicker("getDate");
|
||||||
|
|
|
@ -40,6 +40,10 @@ end
|
||||||
def add_skip_command(s)
|
def add_skip_command(s)
|
||||||
# A command to skip
|
# A command to skip
|
||||||
def skip(_)
|
def skip(_)
|
||||||
|
l = list.hd(server.execute("queue.queue"))
|
||||||
|
l = string.split(separator=" ",l)
|
||||||
|
list.iter(fun (rid) -> ignore(server.execute("queue.ignore #{rid}")), l)
|
||||||
|
|
||||||
source.skip(s)
|
source.skip(s)
|
||||||
"Done!"
|
"Done!"
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue