Merge branch 'devel' of dev.sourcefabric.org:airtime into devel
This commit is contained in:
commit
685e5e03c4
9 changed files with 86 additions and 110 deletions
|
@ -202,32 +202,6 @@ class ApiController extends Zend_Controller_Action
|
|||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function todayInfoAction()
|
||||
{
|
||||
if (Application_Model_Preference::GetAllow3rdPartyApi()){
|
||||
// disable the view and the layout
|
||||
$this->view->layout()->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender(true);
|
||||
|
||||
$date = new Application_Model_DateHelper;
|
||||
$utcTimeNow = $date->getUtcTimestamp();
|
||||
$utctimeEnd = Application_Model_DateHelper::GetDayEndTimestampInUtc();
|
||||
|
||||
$result = array("env"=>APPLICATION_ENV,
|
||||
"schedulerTime"=>gmdate("Y-m-d H:i:s"),
|
||||
"nextShow"=>Application_Model_Show::GetNextShows($utcTimeNow, 5, $utcTimeEnd));
|
||||
|
||||
Application_Model_Show::ConvertToLocalTimeZone($result["nextShow"], array("starts", "ends", "start_timestamp", "end_timestamp"));
|
||||
|
||||
header("Content-type: text/javascript");
|
||||
echo $_GET['callback'].'('.json_encode($result).')';
|
||||
} else {
|
||||
header('HTTP/1.0 401 Unauthorized');
|
||||
print 'You are not allowed to access this resource. ';
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function weekInfoAction()
|
||||
{
|
||||
|
|
|
@ -1,42 +1,42 @@
|
|||
<?php
|
||||
|
||||
class Zend_Filter_ImageSize implements Zend_Filter_Interface {
|
||||
|
||||
public function filter($value) {
|
||||
if(!file_exists($value)) {
|
||||
public function filter($value) {
|
||||
if (!file_exists($value)) {
|
||||
throw new Zend_Filter_Exception('Image does not exist: ' . $value);
|
||||
}
|
||||
|
||||
|
||||
$image = imageCreateFromString(file_get_contents($value));
|
||||
if(false === $image) {
|
||||
if (false === $image) {
|
||||
throw new Zend_Filter_Exception('Can\'t load image: ' . $value);
|
||||
}
|
||||
|
||||
|
||||
// find ratio to scale down to
|
||||
// TODO: pass 600 as parameter in the future
|
||||
$origWidth = imagesx($image);
|
||||
$origHeight = imagesy($image);
|
||||
$ratio = max($origWidth, $origHeight) / 600;
|
||||
if($ratio < 1) {
|
||||
return;
|
||||
|
||||
if ($ratio > 1) {
|
||||
// img too big! create a scaled down image
|
||||
$newWidth = round($origWidth / $ratio);
|
||||
$newHeight = round($origHeight / $ratio);
|
||||
$resized = imagecreatetruecolor($newWidth, $newHeight);
|
||||
imagecopyresampled($resized, $image, 0, 0, 0, 0, $newWidth, $newHeight, $origWidth, $origHeight);
|
||||
|
||||
// determine type and store to disk
|
||||
$explodeResult = explode(".", $value);
|
||||
$type = strtolower($explodeResult[count($explodeResult) - 1]);
|
||||
$writeFunc = 'image' . $type;
|
||||
if ($type == 'jpeg' || $type == 'jpg') {
|
||||
imagejpeg($resized, $value, 100);
|
||||
} else {
|
||||
$writeFunc($resized, $value);
|
||||
}
|
||||
}
|
||||
|
||||
// create a scaled down image
|
||||
$newWidth = round($origWidth / $ratio);
|
||||
$newHeight = round($origHeight / $ratio);
|
||||
$resized = imagecreatetruecolor($newWidth, $newHeight);
|
||||
imagecopyresampled($resized, $image, 0, 0, 0, 0, $newWidth, $newHeight, $origWidth, $origHeight);
|
||||
|
||||
// determine type and store to disk
|
||||
$explodeResult = explode(".", $value);
|
||||
$type = $explodeResult[count($explodeResult) - 1];
|
||||
$writeFunc = 'image' . $type;
|
||||
if($type == 'jpeg' || $type == 'jpg') {
|
||||
imagejpeg($resized, $value, 100);
|
||||
} else {
|
||||
$writeFunc($resized, $value);
|
||||
}
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -1191,12 +1191,39 @@ class Application_Model_Show {
|
|||
|
||||
self::createRebroadcastInstances($rebroadcasts, $currentUtcTimestamp, $show_id, $show_instance_id, $start, $duration, $timezone);
|
||||
|
||||
$dt = new DateTime($start, new DateTimeZone($timezone));
|
||||
$dt->add(new DateInterval($p_interval));
|
||||
$start = $dt->format("Y-m-d H:i:s");
|
||||
|
||||
$dt->setTimezone(new DateTimeZone('UTC'));
|
||||
$utcStartDateTime = $dt;
|
||||
if ($p_interval == 'P1M'){
|
||||
/* When adding months, there is a problem if we are on January 31st and add one month with PHP.
|
||||
* What ends up happening is that since February 31st doesn't exist, the date returned is
|
||||
* March 3rd. For now let's ignore the day and assume we are always working with the
|
||||
* first of each month, and use PHP to add 1 month to this (this will take care of rolling
|
||||
* over the years 2011->2012, etc.). Then let's append the actual day, and use the php
|
||||
* checkdate() function, to see if it is valid. If not, then we'll just skip this month. */
|
||||
|
||||
$startDt = new DateTime($start, new DateTimeZone($timezone));
|
||||
|
||||
/* pass in only the year and month (not the day) */
|
||||
$dt = new DateTime($startDt->format("Y-m"), new DateTimeZone($timezone));
|
||||
|
||||
/* Keep adding 1 month, until we find the next month that contains the day
|
||||
* we are looking for (31st day for example) */
|
||||
do {
|
||||
$dt->add(new DateInterval($p_interval));
|
||||
} while(!checkdate($dt->format("m"), $startDt->format("d"), $dt->format("Y")));
|
||||
$dt->setDate($dt->format("Y"), $dt->format("m"), $startDt->format("d"));
|
||||
|
||||
$start = $dt->format("Y-m-d H:i:s");
|
||||
|
||||
$dt->setTimezone(new DateTimeZone('UTC'));
|
||||
$utcStartDateTime = $dt;
|
||||
} else {
|
||||
$dt = new DateTime($start, new DateTimeZone($timezone));
|
||||
$dt->add(new DateInterval($p_interval));
|
||||
$start = $dt->format("Y-m-d H:i:s");
|
||||
|
||||
$dt->setTimezone(new DateTimeZone('UTC'));
|
||||
$utcStartDateTime = $dt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -28,8 +28,6 @@ $(document).ready(function(){
|
|||
|
||||
$("#combo-box").change(function(eventObject){
|
||||
var elem = $("#combo-box option:selected");
|
||||
console.log(elem);
|
||||
|
||||
setjPlayer(elem.attr("data-url"), elem.attr("data-type"), elem.attr("server-type"));
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue