SAAS-1061 - implement podcast list view skeleton; small bugfixes

This commit is contained in:
Duncan Sommerville 2015-09-14 18:26:28 -04:00
parent fe5db4761e
commit 0fcf6a8dac
16 changed files with 512 additions and 439 deletions

View file

@ -0,0 +1,47 @@
<?php
/**
* Basic enumeration implementation; from http://stackoverflow.com/questions/254514/php-and-enumerations
*
* Class Enum
*/
abstract class Enum {
const __default = NULL;
private static $constCacheArray = NULL;
private function __construct() {}
private static function getConstants() {
if (self::$constCacheArray == NULL) {
self::$constCacheArray = [];
}
$calledClass = get_called_class();
if (!array_key_exists($calledClass, self::$constCacheArray)) {
$reflect = new ReflectionClass($calledClass);
self::$constCacheArray[$calledClass] = $reflect->getConstants();
}
return self::$constCacheArray[$calledClass];
}
public static function isValidName($name, $strict = false) {
$constants = self::getConstants();
if ($strict) {
return array_key_exists($name, $constants);
}
$keys = array_map('strtolower', array_keys($constants));
return in_array(strtolower($name), $keys);
}
public static function isValidValue($value) {
$values = array_values(self::getConstants());
return in_array($value, $values, $strict = true);
}
public static function getDefault() {
return static::__default;
}
}

View file

@ -0,0 +1,14 @@
<?php
require_once "Enum.php";
final class MediaType extends Enum {
const __default = self::FILE;
const FILE = 1;
const PLAYLIST = 2;
const BLOCK = 3;
const WEBSTREAM = 4;
const PODCAST = 5;
}