public static function api($row_obj, $include_episodes = TRUE) { if ($row_obj instanceof self) { $row = $row_obj->toArray(); $row['stations'] = array(); if ($row_obj->stations) { foreach ($row_obj->stations as $station) { $row['stations'][] = Station::api($station); } } $row['episodes'] = array(); if ($include_episodes && $row_obj->episodes) { foreach ($row_obj->episodes as $episode) { $row['episodes'][] = $episode; } } } else { $row = $row_obj; if (isset($row['stations'])) { $stations_raw = array(); foreach ($row['stations'] as $station) { $stations_raw[] = Station::api($station); } $row['stations'] = $stations_raw; } else { $row['stations'] = array(); } if (!isset($row['episodes'])) { $row['episodes'] = array(); } } $api_row = array('id' => (int) $row['id'], 'name' => $row['name'], 'country' => $row['country'], 'description' => $row['description'], 'image_url' => \PVL\Url::upload(self::getArtistImage($row['image_url'])), 'banner_url' => \PVL\Url::upload($row['banner_url']), 'stations' => (array) $row['stations'], 'is_adult' => (bool) $row['is_adult']); if ($include_episodes) { $api_row['episodes'] = array(); $i = 1; foreach ((array) $row['episodes'] as $ep) { if (is_int($include_episodes) && $i > $include_episodes) { break; } $api_row['episodes'][] = PodcastEpisode::api($ep); $i++; } } $social_types = array_keys(self::getSocialTypes()); foreach ($social_types as $type_key) { $api_row[$type_key] = $row[$type_key]; } return $api_row; }
public static function api($row_raw) { if (empty($row_raw)) { return array(); } if ($row_raw instanceof self) { $row_raw = $row_raw->toArray(); } $row = array('id' => (int) $row_raw['id'], 'station_id' => (int) $row_raw['station_id'], 'guid' => $row_raw['guid'], 'start_time' => (int) $row_raw['start_time'], 'end_time' => (int) $row_raw['end_time'], 'is_all_day' => (bool) $row_raw['is_all_day'], 'title' => $row_raw['title'], 'location' => $row_raw['location'], 'body' => $row_raw['body'], 'banner_url' => $row_raw['banner_url'], 'web_url' => $row_raw['web_url'], 'range' => $row_raw['range'] ?: self::getRangeText($row_raw['start_time'], $row_raw['end_time'], $row_raw['is_all_day']), 'image_url' => \PVL\Url::upload(self::getRowImageUrl($row_raw))); if (isset($row_raw['minutes_until'])) { $row['minutes_until'] = (int) $row_raw['minutes_until']; } // Add station shortcode. if (isset($row_raw['station'])) { $row['station'] = Station::api($row_raw['station']); $shortcode = Station::getStationShortName($row_raw['station']['name']); $row['station_shortcode'] = $shortcode; } return $row; }
public function renderView() { if (empty($this->_previous_value)) { return ''; } $file_rows = array(); $i = 1; foreach ((array) $this->_previous_value as $file) { $file_url = \PVL\Url::upload($file); $file_rows[] = '<div><img class="thumbnail" src="' . $file_url . '" alt="Image #' . $i . '" style="max-width: 300px;"></div>'; $i++; } return implode('', $file_rows); }
public function render($attributes = null) { $return = ''; if (!empty($this->_previous_value)) { $return .= '<div>New uploads will replace your existing files. View existing files: '; $existing_files = array(); foreach ((array) $this->_previous_value as $file) { $file_url = \PVL\Url::upload($file); $existing_files[] = '<a href="' . $file_url . '" target="_blank">Download</a>'; } $return .= implode(', ', $existing_files) . '</div>'; } $return .= parent::render($attributes); return $return; }
public static function api($row) { $coverage_levels = self::getCoverageLevels(); $con = array('id' => $row['id'], 'name' => $row['name'], 'location' => $row['location'], 'coverage' => $row['coverage_level'], 'coverage_details' => $coverage_levels[$row['coverage_level']], 'date_range' => self::getDateRange($row['start_date'], $row['end_date']), 'start_date' => $row['start_date'], 'end_date' => $row['end_date'], 'web_url' => $row['web_url']); if (!empty($row['image_url'])) { $con['image_url'] = \PVL\Url::upload($row['image_url']); } if (!empty($row['thumbnail_url'])) { $con['thumbnail_url'] = \PVL\Url::upload($row['thumbnail_url']); } return $con; }
public function nowplayingAction() { $this->redirect(\PVL\Url::upload('api/nowplaying.json')); return; }
public static function _runScheduleItems(\Phalcon\DiInterface $di) { $news_items = array(); $em = $di->get('em'); // Pull promoted schedule items. $events_raw = $em->createQuery('SELECT st, s FROM \\Entity\\Schedule s JOIN s.station st WHERE (s.end_time >= :current AND s.start_time <= :future) AND (st.banner_url != \'\' AND st.banner_url IS NOT NULL) AND s.is_promoted = 1 ORDER BY s.start_time ASC')->setParameter('current', time())->setParameter('future', strtotime('+1 week'))->getArrayResult(); $promoted_stations = array(); foreach ($events_raw as $event) { $station_id = $event['station_id']; if (isset($promoted_stations[$station_id])) { continue; } else { $promoted_stations[$station_id] = true; } $range = Schedule::getRangeText($event['start_time'], $event['end_time'], $event['is_all_day']); $description = array(); $description[] = 'Coming up on ' . $event['station']['name']; $description[] = $range; if (!empty($event['body'])) { $description[] = $event['body']; } // Manually adjust the sorting timestamp for the event if it is in the future. $sort_timestamp = $event['start_time']; if ($sort_timestamp >= time()) { $sort_timestamp = time() - ($sort_timestamp - time()); } $news_items[] = array('id' => 'schedule_' . $event['guid'], 'title' => trim($event['title']), 'source' => 'station', 'body' => implode('<br>', $description), 'image_url' => \PVL\Url::upload($event['station']['banner_url']), 'web_url' => $event['station']['web_url'], 'layout' => 'vertical', 'tags' => array($event['station']['name'], 'Events'), 'sort_timestamp' => $sort_timestamp, 'display_timestamp' => $event['start_time']); break; } return $news_items; }
public static function api($row) { if ($row instanceof self) { $row = $row->toArray(); } $api = array('id' => (int) $row['id'], 'name' => $row['name'], 'shortcode' => self::getStationShortName($row['name']), 'genre' => $row['genre'], 'category' => $row['category'], 'affiliation' => $row['affiliation'], 'image_url' => \PVL\Url::upload($row['image_url']), 'web_url' => $row['web_url'], 'twitter_url' => $row['twitter_url'], 'irc' => $row['irc'], 'sort_order' => (int) $row['weight']); if (isset($row['streams'])) { $api['streams'] = array(); foreach ((array) $row['streams'] as $stream) { $api['streams'][] = StationStream::api($stream); // Set first stream as default, override if a later stream is explicitly default. if ($stream['is_default'] || !isset($api['default_stream_id'])) { $api['default_stream_id'] = (int) $stream['id']; $api['stream_url'] = $stream['stream_url']; } } } $api['player_url'] = ShortUrl::stationUrl($api['shortcode']); if ($row['requests_enabled']) { $api['request_url'] = \DF\Url::route(array('module' => 'default', 'controller' => 'station', 'action' => 'request', 'id' => $row['id'])); } else { $api['request_url'] = ''; } return $api; }