Rename airtime_mvc/ to legacy/
This commit is contained in:
parent
f0879322c2
commit
3e18d42c8b
1316 changed files with 0 additions and 0 deletions
28
legacy/application/models/formatters/BitrateFormatter.php
Normal file
28
legacy/application/models/formatters/BitrateFormatter.php
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
class BitrateFormatter
|
||||
{
|
||||
/**
|
||||
* @string length
|
||||
*/
|
||||
private $_bitrate;
|
||||
|
||||
/*
|
||||
* @param string $bitrate (bits per second)
|
||||
*/
|
||||
public function __construct($bitrate)
|
||||
{
|
||||
$this->_bitrate = $bitrate;
|
||||
}
|
||||
|
||||
public function format()
|
||||
{
|
||||
$kbps = bcdiv($this->_bitrate, 1000, 0);
|
||||
|
||||
if ($kbps == 0) {
|
||||
return "";
|
||||
} else {
|
||||
return "$kbps Kbps";
|
||||
}
|
||||
}
|
||||
}
|
58
legacy/application/models/formatters/LengthFormatter.php
Normal file
58
legacy/application/models/formatters/LengthFormatter.php
Normal file
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
class LengthFormatter
|
||||
{
|
||||
/**
|
||||
* @string length
|
||||
*/
|
||||
private $_length;
|
||||
|
||||
/*
|
||||
* @param string $length formatted H:i:s.u (can be > 24 hours)
|
||||
*/
|
||||
public function __construct($length)
|
||||
{
|
||||
$this->_length = $length;
|
||||
}
|
||||
|
||||
public function format()
|
||||
{
|
||||
if (!preg_match("/^[0-9]{2}:[0-9]{2}:[0-9]{2}/", $this->_length)) {
|
||||
return $this->_length;
|
||||
}
|
||||
|
||||
$pieces = explode(":", $this->_length);
|
||||
|
||||
$seconds = round($pieces[2], 1);
|
||||
$seconds = number_format($seconds, 1);
|
||||
list($seconds, $milliStr) = explode(".", $seconds);
|
||||
|
||||
if (intval($pieces[0]) !== 0) {
|
||||
$hours = ltrim($pieces[0], "0");
|
||||
}
|
||||
|
||||
$minutes = $pieces[1];
|
||||
//length is less than 1 hour
|
||||
if (!isset($hours)) {
|
||||
|
||||
if (intval($minutes) !== 0) {
|
||||
$minutes = ltrim($minutes, "0");
|
||||
}
|
||||
//length is less than 1 minute
|
||||
else {
|
||||
unset($minutes);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($hours) && isset($minutes) && isset($seconds)) {
|
||||
$time = sprintf("%d:%02d:%02d.%s", $hours, $minutes, $seconds, $milliStr);
|
||||
} elseif (isset($minutes) && isset($seconds)) {
|
||||
$time = sprintf("%d:%02d.%s", $minutes, $seconds, $milliStr);
|
||||
} else {
|
||||
$time = sprintf("%d.%s", $seconds, $milliStr);
|
||||
}
|
||||
|
||||
return $time;
|
||||
}
|
||||
|
||||
}
|
24
legacy/application/models/formatters/SamplerateFormatter.php
Normal file
24
legacy/application/models/formatters/SamplerateFormatter.php
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
class SamplerateFormatter
|
||||
{
|
||||
/**
|
||||
* @string sample rate
|
||||
*/
|
||||
private $_samplerate;
|
||||
|
||||
/*
|
||||
* @param string $samplerate Hz
|
||||
*/
|
||||
public function __construct($samplerate)
|
||||
{
|
||||
$this->_samplerate = $samplerate;
|
||||
}
|
||||
|
||||
public function format()
|
||||
{
|
||||
$kHz = bcdiv($this->_samplerate, 1000, 1);
|
||||
|
||||
return "{$kHz} kHz";
|
||||
}
|
||||
}
|
54
legacy/application/models/formatters/TimeFilledFormatter.php
Normal file
54
legacy/application/models/formatters/TimeFilledFormatter.php
Normal file
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
class TimeFilledFormatter
|
||||
{
|
||||
/**
|
||||
* @string seconds
|
||||
*/
|
||||
private $_seconds;
|
||||
|
||||
/*
|
||||
* @param string $seconds
|
||||
*/
|
||||
public function __construct($seconds)
|
||||
{
|
||||
$this->_seconds = $seconds;
|
||||
}
|
||||
|
||||
public function format()
|
||||
{
|
||||
$formatted = "";
|
||||
$sign = ($this->_seconds < 0) ? "-" : "+";
|
||||
$perfect = true;
|
||||
|
||||
$time = Application_Common_DateHelper::secondsToPlaylistTime(abs($this->_seconds));
|
||||
$info = explode(":", $time);
|
||||
|
||||
$formatted .= $sign;
|
||||
|
||||
if (intval($info[0]) > 0) {
|
||||
$info[0] = ltrim($info[0], "0");
|
||||
$formatted .= " {$info[0]}h";
|
||||
$perfect = false;
|
||||
}
|
||||
|
||||
if (intval($info[1]) > 0) {
|
||||
$info[1] = ltrim($info[1], "0");
|
||||
$formatted .= " {$info[1]}m";
|
||||
$perfect = false;
|
||||
}
|
||||
|
||||
if (intval($info[2]) > 0) {
|
||||
$sec = round($info[2], 0);
|
||||
$formatted .= " {$sec}s";
|
||||
$perfect = false;
|
||||
}
|
||||
|
||||
//0 over/under lap of content.
|
||||
if ($perfect === true) {
|
||||
$formatted = "+ 0s";
|
||||
}
|
||||
|
||||
return $formatted;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue