コード例 #1
0
ファイル: IndexController.php プロジェクト: Lavoaster/PVLive
 protected function _initStations()
 {
     $this->view->station_id = $station_id = $this->getParam('id', NULL);
     $this->view->volume = $this->hasParam('volume') ? (int) $this->getParam('volume') : NULL;
     $this->categories = Station::getCategories();
     $stations_raw = Station::fetchArray();
     // Limit to a single station if requested.
     if ($station_id && $this->getParam('showonlystation', false) == 'true') {
         foreach ($stations_raw as $station) {
             if ($station['id'] == $station_id) {
                 $stations_raw = array($station);
                 break;
             }
         }
     }
     $this->stations = array();
     foreach ($stations_raw as $station) {
         // Build multi-stream directory.
         $streams = array();
         $current_stream_id = NULL;
         foreach ((array) $station['streams'] as $stream) {
             if (!$stream['hidden_from_player'] && $stream['is_active']) {
                 if ($stream['is_default']) {
                     $station['default_stream_id'] = $stream['id'];
                     $current_stream_id = $stream['id'];
                 }
                 $streams[$stream['id']] = $stream;
             }
         }
         // Pull from user preferences to potentially override defaults.
         $default_streams = (array) \PVL\Customization::get('stream_defaults');
         if (isset($default_streams[$station['id']])) {
             $stream_id = (int) $default_streams[$station['id']];
             if (isset($streams[$stream_id])) {
                 $current_stream_id = $stream_id;
             }
         }
         $station['current_stream_id'] = $current_stream_id;
         $station['streams'] = $streams;
         // Only show stations with at least one usable stream.
         if (count($streams) > 0) {
             $this->stations[$station['id']] = $station;
         }
     }
     foreach ($this->stations as $station) {
         if (isset($this->categories[$station['category']])) {
             $this->categories[$station['category']]['stations'][] = $station;
         }
     }
     $this->view->stations = $this->stations;
     $this->view->categories = $this->categories;
 }
コード例 #2
0
 /**
  * Customize the default active stream for a station.
  */
 public function streamAction()
 {
     $this->doNotRender();
     $station_id = (int) $this->getParam('station', 0);
     $stream_id = (int) $this->getParam('stream', 0);
     $default_streams = (array) \PVL\Customization::get('stream_defaults');
     $default_streams[$station_id] = $stream_id;
     \PVL\Customization::set('stream_defaults', $default_streams);
     echo 'OK';
 }
コード例 #3
0
ファイル: bootstrap.php プロジェクト: Lavoaster/PVLive
    } catch (\Exception $e) {
        throw new \DF\Exception\Bootstrap($e->getMessage());
    }
});
// InfluxDB
$di->setShared('influx', function () use($config) {
    $opts = $config->influx->toArray();
    return new \PVL\Service\InfluxDb($opts);
});
// Auth and ACL
$di->setShared('auth', '\\DF\\Auth\\Model');
$di->setShared('acl', '\\PVL\\Acl\\Instance');
$di->setShared('cache', '\\DF\\Cache');
// Register URL handler.
$di->set('url', function () use($config) {
    $url = new \Phalcon\Mvc\Url();
    $url->setBaseUri('/');
    $url->setStaticBaseUri('/static/');
    return $url;
});
// Set Session handler.
$session_pool = \DF\Cache::getCache('session');
if (!$session_pool->getDriver() instanceof \Stash\Driver\Ephemeral) {
    $session = new \Stash\Session($session_pool);
    \Stash\Session::registerHandler($session);
}
// Register view helpers.
$di->setShared('viewHelper', '\\DF\\Phalcon\\Service\\ViewHelper');
// PVL-specific customization.
$system_tz = \PVL\Customization::get('timezone');
@date_default_timezone_set($system_tz);