Merge branch 'saas-dev' into saas-dev-publishing

Conflicts:
	airtime_mvc/public/css/dashboard.css
	airtime_mvc/public/css/styles.css
	airtime_mvc/public/js/airtime/library/library.js
	airtime_mvc/public/js/airtime/library/spl.js
This commit is contained in:
Duncan Sommerville 2015-09-30 16:26:02 -04:00
commit c3c4abdd0c
31 changed files with 427 additions and 206 deletions

View file

@ -138,7 +138,13 @@ class Application_Model_Preference
$st->execute();
}
private static function getValue($key, $isUserValue = false)
/**
* @param string $key the preference key string
* @param bool|false $isUserValue select the preference for the current user
* @param bool|false $forceDefault only look for default (no user ID) values
* @return mixed the preference value
*/
private static function getValue($key, $isUserValue = false, $forceDefault = false)
{
$cache = new Cache();
@ -164,6 +170,8 @@ class Application_Model_Preference
if ($isUserValue) {
$sql .= " AND subjid = :id";
$paramMap[':id'] = $userId;
} else if ($forceDefault) {
$sql .= " AND subjid IS NULL";
}
$result = Application_Common_Database::prepareAndExecute($sql, $paramMap, Application_Common_Database::COLUMN);
@ -1478,4 +1486,20 @@ class Application_Model_Preference
{
self::setValue("lang_tz_setup_complete", $value);
}
public static function getWhatsNewDialogViewed()
{
$val = self::getValue("whats_new_dialog_viewed", true);
if (empty($val)) {
// Check the default (no user ID) value if the user value is empty
// This is so that new stations won't see the popup
$val = self::getValue("whats_new_dialog_viewed", false, true);
}
return empty($val) ? false : $val;
}
public static function setWhatsNewDialogViewed($value)
{
self::setValue("whats_new_dialog_viewed", $value, true);
}
}

View file

@ -1035,7 +1035,11 @@ SQL;
self::createStreamScheduleEvent($data, $item, $media_id, $uri);
}
else {
throw new Exception("Unknown schedule type: ".print_r($item, true));
//throw new Exception("Unknown schedule type: ".print_r($item, true));
//It's currently possible (and normal) to get cc_schedule rows without
//a file_id or stream_id. If you're using linked shows, placeholder rows can be put
//in the schedule when you cancel a track or delete stuff, so we should not throw an exception
//here and instead just ignore it.
}
}

View file

@ -1044,17 +1044,31 @@ SQL;
$event["nowPlaying"] = false;
}
//event colouring
if ($show["color"] != "") {
$event["textColor"] = "#".$show["color"];
}
if (!empty($show["background_color"])) {
$event["color"] = "#" . $show["background_color"];
} else {
$event["color"] = "#" . self::getDefaultBackgroundColor($startsDT);//DEFAULT_SHOW_COLOR;
}
//event colouring
if ($show["color"] != "") {
$event["textColor"] = "#".$show["color"];
} else {
$bg = $event["color"];
//Calculate the text colour (black or white) based on the brightness of the background.
$r = intval(substr($bg, 1, 2), 16);
$g = intval(substr($bg, 3, 2), 16);
$b = intval(substr($bg, 5, 2), 16);
$brightness = 0.299*floatval($r) + 0.587*floatval($g) + 0.114*floatval($b);
if ($brightness > 130) {
$event["textColor"] = "#000000";
} else {
$event["textColor"] = "#fcfcfc";
}
}
foreach ($options as $key => $value) {
$event[$key] = $value;
}
@ -1067,12 +1081,33 @@ SQL;
/** Get a palettized colour for the show. */
private static function getDefaultBackgroundColor($date) {
$basePalette = ['A22BE8', '2FFF8D', 'FF743C', '2ED4FF', 'E8D82B'];
// 'B23F11', 'FF7E4A', 'FF6C31'
/*
$palette = [['42d5a1', '56bd99', '65ab93', '7b938b'],
['42a4d5', '569bbd', '6594ab', '7b8b93'],
['4264d5', '566fbd', '6576ab', '7b8193']];
*/
$palette = [];
for ($baseColorIdx = 0; $baseColorIdx < count($basePalette); $baseColorIdx++) {
$dayPalette = [];
for ($shade = 0.0; $shade < 0.8; $shade += 0.1) {
$origColour = $basePalette[$baseColorIdx];
$r = intval(substr($origColour, 0, 2), 16);
$g = intval(substr($origColour, 2, 2), 16);
$b = intval(substr($origColour, 4, 2), 16);
$r = floatval($r) * (1.0 - $shade);
$g = floatval($g) * (1.0 - $shade);
$b = floatval($b) * (1.0 - $shade);
$color = sprintf("%02x%02x%02x", $r, $g, $b);
array_push($dayPalette, $color);
}
array_push($palette, $dayPalette);
}
//$hashValue = (md5($date->format('d'))[0] % $cols) + ((intval($date->format('h'))/24) % $rows);
$row = intval($date->format('d')) % sizeof($palette);
$row = intval($date->format('w')) % sizeof($palette);
$foo = $date->format('H');
$col = intval(intval($date->format('H'))/24.0 * sizeof($palette[0]));
//$color = $palette[$hashValue % sizeof($palette)];

View file

@ -154,7 +154,9 @@ class Podcast extends BasePodcast
"guid" => $item->get_id(),
"ingested" => in_array($item->get_id(), $episodeIds),
"title" => $item->get_title(),
"author" => $item->get_author()->get_name(),
// From the RSS spec best practices:
// 'An item's author element provides the e-mail address of the person who wrote the item'
"author" => $item->get_author()->get_email(),
"description" => $item->get_description(),
"pub_date" => $item->get_date("Y-m-d H:i:s"),
"link" => $item->get_link(),