Example #1
0
 /**
  * New messenger method:
  * Uses an expandable array of options and supports direct template rendering and subject prepending.
  *
  * @param array $message_options An array of message options.
  * @return bool|void
  */
 public static function send($message_options)
 {
     $di = \Phalcon\Di::getDefault();
     $config = $di->get('config');
     $default_options = array('reply_to' => NULL, 'delivery_date' => NULL, 'options' => NULL);
     $options = array_merge($default_options, $message_options);
     // Render the template as the message if a template is specified.
     if (isset($options['template'])) {
         $previous_sp_setting = \DF\Url::getSchemePrefixSetting();
         \DF\Url::forceSchemePrefix(TRUE);
         $view = \DF\Phalcon\View::getView(array('views_dir' => 'messages', 'layouts_dir' => '../templates', 'layout' => 'message'));
         $view->subject = $options['subject'];
         $view->setVars((array) $options['vars']);
         $options['message'] = $view->getRender('', $options['template']);
         \DF\Url::forceSchemePrefix($previous_sp_setting);
     } else {
         if (isset($options['body']) && !isset($options['message'])) {
             $options['message'] = $options['body'];
             unset($options['body']);
         }
     }
     // Append the system name as a prefix to the message.
     if (!isset($options['no_prefix']) || $options['no_prefix'] == FALSE) {
         $app_name = $config->application->name;
         $options['subject'] = $app_name . ': ' . $options['subject'];
     }
     return self::sendMail($options);
 }
Example #2
0
 /**
  * @return A string containing the icon's image tag.
  */
 public function icon($params)
 {
     if (!is_array($params)) {
         $params = array('image' => $params);
     }
     // Default values for icons.
     $defaults = array('type' => 'png', 'alt' => '(Icon)', 'class' => 'icon');
     $params = array_merge($defaults, $params);
     if (substr($params['image'], 0, 5) == "icon-") {
         $params['class'] .= ' ' . $params['image'];
         unset($params['type'], $params['image']);
         return $this->iconComposeTag('i', $params);
     } else {
         if ($params['type'] == "png") {
             $params['class'] .= ' ui-silk ui-silk-' . str_replace('_', '-', $params['image']);
             unset($params['type'], $params['image']);
             return $this->iconComposeTag('span', $params);
         } else {
             $icon_name = str_replace('.png', '', $params['image']) . '.png';
             $params['src'] = \DF\Url::content('common/icons/' . $params['type'] . '/' . $icon_name);
             unset($params['size'], $params['image'], $params['type']);
             return $this->iconComposeTag('img', $params, '');
         }
     }
 }
Example #3
0
 public function indexAction()
 {
     $id = $this->getParam('id');
     if (empty($id)) {
         $this->redirectHome();
     }
     $record = Song::find($id);
     if (!$record instanceof Song) {
         throw new \DF\Exception\DisplayOnly('Song not found!');
     }
     $song_info = array();
     $song_info['record'] = $record;
     // Get external provider information.
     $song_info['external'] = $record->getExternal();
     // Get album art and lyrics from all providers.
     $adapters = Song::getExternalAdapters();
     $external_fields = array('lyrics', 'purchase_url', 'description');
     foreach ($external_fields as $field_name) {
         $song_info[$field_name] = NULL;
         foreach ($adapters as $adapter_name => $adapter_class) {
             if (!empty($song_info['external'][$adapter_name][$field_name])) {
                 $song_info[$field_name] = $song_info['external'][$adapter_name][$field_name];
                 break;
             }
         }
     }
     $song_info['image_url'] = $record->image_url;
     if (!$song_info['image_url']) {
         $song_info['image_url'] = \DF\Url::content('images/song_generic.png');
     }
     $song_info['description'] = $this->_cleanUpText($song_info['description']);
     $song_info['lyrics'] = $this->_cleanUpText($song_info['lyrics']);
     // Get most recent playback information.
     $history_raw = $this->em->createQuery('
         SELECT sh, st
         FROM Entity\\SongHistory sh JOIN sh.station st
         WHERE sh.song_id = :song_id AND st.category IN (:categories) AND sh.timestamp >= :threshold
         ORDER BY sh.timestamp DESC')->setParameter('song_id', $record->id)->setParameter('categories', array('audio', 'video'))->setParameter('threshold', strtotime('-1 week'))->getArrayResult();
     $history = array();
     $last_row = NULL;
     foreach ($history_raw as $i => $row) {
         if ($last_row && $row['station_id'] == $last_row['station_id']) {
             $timestamp_diff = abs($row['timestamp'] - $last_row['timestamp']);
             if ($timestamp_diff < 60) {
                 continue;
             }
         }
         $history[] = $row;
         $last_row = $row;
     }
     $song_info['recent_history'] = $history;
     // Get requestable locations.
     $song_info['request_on'] = $this->em->createQuery('
         SELECT sm, st
         FROM Entity\\StationMedia sm JOIN sm.station st
         WHERE sm.song_id = :song_id
         GROUP BY sm.station_id')->setParameter('song_id', $record->id)->getArrayResult();
     $this->view->song = $song_info;
 }
Example #4
0
 public static function run($force = false)
 {
     $di = \Phalcon\Di::getDefault();
     \DF\Url::forceSchemePrefix(true);
     self::_runNetworkNews($di, $force);
     self::_runStationEvents($di, $force);
     self::_runPodcastEpisodes($di, $force);
 }
Example #5
0
 public static function getFileUrl($file_name)
 {
     if (defined('DF_UPLOAD_URL')) {
         return DF_UPLOAD_URL . '/' . $file_name;
     } else {
         return \DF\Url::content($file_name);
     }
 }
Example #6
0
 /**
  * Return the remote URL of the file (or local fallback).
  *
  * @param $remote_file_path
  * @return string
  */
 public static function url($remote_file_path)
 {
     if (self::isEnabled()) {
         return DF_UPLOAD_URL . '/' . $remote_file_path;
     } else {
         return \DF\Url::content($remote_file_path);
     }
 }
Example #7
0
 public static function generate()
 {
     set_time_limit(60);
     // Fix DF\URL // prefixing.
     \DF\Url::forceSchemePrefix(true);
     $nowplaying = self::loadNowPlaying();
     // Post statistics to official record (legacy for duplication, for now)
     // Analytics::post($nowplaying['api']);
     // Post statistics to InfluxDB.
     $influx = self::getInflux();
     $influx->setDatabase('pvlive_stations');
     $active_shortcodes = Station::getShortNameLookup();
     $total_overall = 0;
     foreach ($nowplaying['api'] as $short_code => $info) {
         $listeners = (int) $info['listeners']['current'];
         $station_id = $info['station']['id'];
         if (isset($active_shortcodes[$short_code])) {
             $total_overall += $listeners;
         }
         $influx->insert('station.' . $station_id . '.listeners', ['value' => $listeners]);
     }
     $influx->insert('all.listeners', ['value' => $total_overall]);
     // Clear any records that are not audio/video category.
     $api_categories = array('audio', 'video');
     foreach ($nowplaying['api'] as $station_shortcode => $station_info) {
         if (!in_array($station_info['station']['category'], $api_categories)) {
             unset($nowplaying['api'][$station_shortcode]);
             unset($nowplaying['legacy'][$station_shortcode]);
         }
     }
     // Generate PVL legacy nowplaying file.
     $nowplaying_feed = json_encode($nowplaying['legacy'], JSON_UNESCAPED_SLASHES);
     $pvl_file_path = \PVL\Service\AmazonS3::path('api/nowplaying.json');
     @file_put_contents($pvl_file_path, $nowplaying_feed);
     $legacy_file_path = DF_INCLUDE_STATIC . '/api/nowplaying.json';
     @file_put_contents($legacy_file_path, $nowplaying_feed);
     // Generate PVL API cache.
     $np_api = $nowplaying['api'];
     foreach ($np_api as $station => $np_info) {
         $np_api[$station]['cache'] = 'hit';
     }
     Cache::save($np_api, 'api_nowplaying_data', array('nowplaying'), 60);
     foreach ($np_api as $station => $np_info) {
         $np_api[$station]['cache'] = 'flatfile';
     }
     // Generate PVL API nowplaying file.
     $file_path_api = \PVL\Service\AmazonS3::path('api/nowplaying_api.json');
     $nowplaying_api = json_encode(array('status' => 'success', 'result' => $np_api), JSON_UNESCAPED_SLASHES);
     @file_put_contents($file_path_api, $nowplaying_api);
     // Push to live-update service.
     PvlNode::push('nowplaying', $nowplaying['api']);
     return $pvl_file_path;
 }
Example #8
0
 public function process()
 {
     // Now Playing defaults.
     $np = array('on_air' => array('text' => 'Stream Offline', 'thumbnail' => \DF\Url::content('images/video_thumbnail.png')), 'meta' => array('status' => 'offline', 'listeners' => 0));
     if (!$this->stream->is_active) {
         return $np;
     }
     // Merge station-specific info into defaults.
     $this->_process($np);
     // Update status code for offline stations, clean up song info for online ones.
     if ($np['on_air']['text'] == 'Stream Offline') {
         $np['meta']['status'] = 'offline';
     }
     return $np;
 }
Example #9
0
 public function preDispatch()
 {
     parent::preDispatch();
     // Disable session creation.
     \DF\Session::disable();
     // Disable rendering.
     $this->doNotRender();
     // Allow AJAX retrieval.
     $this->response->setHeader('Access-Control-Allow-Origin', '*');
     // Fix the base URL prefixed with '//'.
     \DF\Url::forceSchemePrefix(true);
     $this->_time_start = microtime(true);
     // Set all API calls to be public cache-controlled by default.
     $this->setCachePrivacy('public');
     $this->setCacheLifetime(30);
 }
Example #10
0
 /**
  * Generate random image from a folder.
  *
  * @param $static_dir
  * @return string
  */
 public static function randomImage($static_dir)
 {
     $img = null;
     $folder = DF_INCLUDE_STATIC . DIRECTORY_SEPARATOR . $static_dir;
     $extList = array('gif' => 'image/gif', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'png' => 'image/png');
     $handle = opendir($folder);
     while ($file = readdir($handle)) {
         $file_info = pathinfo($file);
         $file_ext = strtolower($file_info['extension']);
         if (isset($extList[$file_ext])) {
             $fileList[] = $file;
         }
     }
     closedir($handle);
     if (count($fileList) > 0) {
         $imageNumber = time() % count($fileList);
         $img = $fileList[$imageNumber];
     }
     return \DF\Url::content($static_dir . '/' . $img);
 }
Example #11
0
 public static function conventionUrls()
 {
     $urls = array();
     $short_names = Convention::getShortNameLookup();
     foreach ($short_names as $short_name => $record) {
         $urls[$short_name] = \DF\Url::route(array('module' => 'default', 'controller' => 'convention', 'action' => 'archive', 'id' => $record['id']));
     }
     return $urls;
 }
Example #12
0
 public static function run($force_run = false)
 {
     $di = \Phalcon\Di::getDefault();
     $em = $di->get('em');
     $config = $di->get('config');
     // Set up Google Client.
     $gclient_api_key = $config->apis->google_apis_key;
     $gclient_app_name = $config->application->name;
     if (empty($gclient_api_key)) {
         return null;
     }
     $gclient = new \Google_Client();
     $gclient->setApplicationName($gclient_app_name);
     $gclient->setDeveloperKey($gclient_api_key);
     $gcal = new \Google_Service_Calendar($gclient);
     // Prevent running repeatedly in too short of a time (avoid API limits).
     $last_run = Settings::getSetting('schedule_manager_last_run', 0);
     if ($last_run > time() - 60 && !$force_run) {
         return null;
     }
     $schedule_items = array();
     $schedule_records = array();
     $stations = $em->createQuery('SELECT s FROM Entity\\Station s WHERE (s.gcal_url IS NOT NULL AND s.gcal_url != \'\') AND s.is_active = 1')->getArrayResult();
     $active_stations = Utilities::ipull($stations, 'id');
     // Clear all invalid station records.
     $em->createQuery('DELETE FROM Entity\\Schedule s WHERE (s.station_id IS NOT NULL) AND (s.station_id NOT IN (:station_ids))')->setParameter('station_ids', $active_stations)->execute();
     foreach ($stations as $station) {
         if ($station['gcal_url']) {
             $schedule_items[] = array('name' => $station['name'], 'url' => $station['gcal_url'], 'type' => 'station', 'station_id' => $station['id'], 'image_url' => \DF\Url::content($station['image_url']));
         }
     }
     Debug::startTimer('Get Calendar Records');
     // Time boundaries for calendar entries.
     $threshold_start = date(\DateTime::RFC3339, strtotime('-1 week'));
     $threshold_end = date(\DateTime::RFC3339, strtotime('+1 year'));
     foreach ($schedule_items as $item) {
         // Get the "calendar_id" from the URL provided by the user.
         $orig_url_parts = parse_url($item['url']);
         $url_path_parts = explode('/', $orig_url_parts['path']);
         $calendar_id = urldecode($url_path_parts[3]);
         if (empty($calendar_id)) {
             continue;
         }
         // Call the external Google Calendar client.
         try {
             $all_events = $gcal->events->listEvents($calendar_id, array('timeMin' => $threshold_start, 'timeMax' => $threshold_end, 'singleEvents' => 'true', 'orderBy' => 'startTime', 'maxResults' => '300'));
         } catch (\Exception $e) {
             continue;
         }
         // Process each individual event.
         foreach ($all_events as $event_orig) {
             $title = $event_orig->summary;
             $body = $event_orig->description;
             $location = $event_orig->location;
             $web_url = $event_orig->htmlLink;
             $banner_url = null;
             $is_all_day = false;
             $start_time_obj = $event_orig->start;
             if ($start_time_obj->date) {
                 $is_all_day = true;
                 $start_time = strtotime($start_time_obj->date . ' 00:00:00');
             } else {
                 $start_time = strtotime($start_time_obj->dateTime);
             }
             $end_time_obj = $event_orig->end;
             if ($end_time_obj->date) {
                 $is_all_day = true;
                 $end_time = strtotime($end_time_obj->date . ' 00:00:00');
             } elseif ($end_time_obj) {
                 $end_time = strtotime($end_time_obj->dateTime);
             } else {
                 $end_time = $start_time;
             }
             // Detect URLs for link.
             if ($body && !$web_url) {
                 preg_match('@((https?://)?([-\\w]+\\.[-\\w\\.]+)+\\w(:\\d+)?(/([-\\w/_\\.]*(\\?\\S+)?)?)*)@', $body, $urls);
                 if (count($urls) > 0) {
                     $web_url = $urls[0];
                 }
             }
             // Detect URLs for photo.
             if ($location) {
                 preg_match('@((https?://)?([-\\w]+\\.[-\\w\\.]+)+\\w(:\\d+)?(/([-\\w/_\\.]*(\\?\\S+)?)?)*)@', $location, $urls);
                 if (count($urls) > 0) {
                     $banner_url = $urls[0];
                 }
             }
             $guid = md5(implode('|', array($event_orig->id, $start_time, $end_time, $title, $location)));
             $schedule_record = array('guid' => $guid, 'type' => $item['type'], 'start_time' => $start_time, 'end_time' => $end_time, 'is_all_day' => $is_all_day, 'title' => $title, 'location' => $location, 'body' => \DF\Utilities::truncateText(strip_tags($body), 300), 'banner_url' => $banner_url, 'web_url' => $web_url);
             \PVL\Debug::print_r($schedule_record);
             $schedule_records[$item['station_id']][$guid] = $schedule_record;
         }
     }
     Debug::endTimer('Get Calendar Records');
     if (count($schedule_records) == 0) {
         Debug::log('Error: No calendar records loaded');
         return;
     }
     // Add/Remove all differential records.
     Debug::startTimer('Sync DB Records');
     foreach ($schedule_records as $station_id => $station_records) {
         $station = Station::find($station_id);
         if ($station_id == 0) {
             $existing_guids_raw = $em->createQuery('SELECT s.guid FROM Entity\\Schedule s WHERE s.station_id IS NULL')->getArrayResult();
         } else {
             $existing_guids_raw = $em->createQuery('SELECT s.guid FROM Entity\\Schedule s WHERE s.station_id = :sid')->setParameter('sid', $station_id)->getArrayResult();
         }
         $existing_guids = array();
         foreach ($existing_guids_raw as $i) {
             $existing_guids[] = $i['guid'];
         }
         $new_guids = array_keys($station_records);
         $guids_to_delete = array_diff($existing_guids, $new_guids);
         if ($guids_to_delete) {
             $em->createQuery('DELETE FROM Entity\\Schedule s WHERE s.guid IN (:guids)')->setParameter('guids', $guids_to_delete)->execute();
         }
         $guids_to_add = array_diff($new_guids, $existing_guids);
         if ($guids_to_add) {
             foreach ($guids_to_add as $guid) {
                 $schedule_record = $station_records[$guid];
                 $record = new Schedule();
                 $record->station = $station;
                 $record->fromArray($schedule_record);
                 $em->persist($record);
             }
         }
         $em->flush();
         $em->clear();
     }
     Debug::endTimer('Sync DB Records');
     Settings::setSetting('schedule_manager_last_run', time());
 }
Example #13
0
 public function route($params)
 {
     return \DF\Url::route($params, $this->di);
 }
Example #14
0
 /**
  * Render the entire form (or a specified field name).
  *
  * @param null $name The portion of the form to render (leave null for the entire form).
  * @return string The rendered form.
  */
 public function render($name = null)
 {
     if ($name !== null) {
         return $this->_renderField($name, array());
     }
     $form_defaults = array('method' => 'POST', 'action' => \DF\Url::current(), 'class' => 'form-stacked df-form');
     $form_options = (array) $this->options;
     unset($form_options['elements'], $form_options['groups']);
     $form_options = array_merge($form_defaults, $form_options);
     $form_tag = '<form';
     foreach ((array) $form_options as $option_key => $option_value) {
         $form_tag .= ' ' . $option_key . '="' . $option_value . '"';
     }
     $form_tag .= '>';
     $return = '';
     $return .= $form_tag;
     if ($this->options['groups']) {
         foreach ($this->options['groups'] as $group_id => $group_info) {
             if (!empty($group_info['legend'])) {
                 $return .= '<fieldset id="' . $group_id . '">';
                 $return .= '<legend>' . $group_info['legend'] . '</legend>';
                 if ($group_info['description']) {
                     $return .= '<p>' . $group_info['description'] . '</p>';
                 }
             }
             foreach ($group_info['elements'] as $element_key => $element_info) {
                 $return .= $this->_renderField($element_key, $element_info);
             }
             if (!empty($group_info['legend'])) {
                 $return .= '</fieldset>';
             }
         }
     }
     if (!empty($this->options['elements'])) {
         foreach ($this->options['elements'] as $element_key => $element_info) {
             $return .= $this->_renderField($element_key, $element_info);
         }
     }
     $return .= '</form>';
     return $return;
 }
Example #15
0
 protected function _getHybridConfig()
 {
     // Force "scheme" injection for base URLs.
     $ha_config = $this->config->apis->hybrid_auth->toArray();
     $ha_config['base_url'] = \DF\Url::addSchemePrefix(\DF\Url::routeFromHere(array('action' => 'hybrid')));
     return $ha_config;
 }
Example #16
0
<?php

/**
 * Login Form
 */
return array('method' => 'post', 'elements' => array('username' => array('text', array('label' => 'E-mail Address', 'class' => 'half-width', 'spellcheck' => 'false', 'required' => true)), 'password' => array('password', array('label' => 'Password', 'description' => '<a href="' . \DF\Url::route(array('module' => 'default', 'controller' => 'account', 'action' => 'forgot')) . '">Forgot your password?</a>', 'class' => 'half-width', 'required' => true)), 'submit' => array('submit', array('type' => 'submit', 'label' => 'Log in', 'helper' => 'formButton', 'class' => 'ui-button'))));
Example #17
0
 public static function getEpisodeRotatorUrl($episode, $podcast = NULL, $source = NULL)
 {
     if ($episode instanceof self) {
         if ($podcast === null) {
             $podcast = $episode->podcast;
         }
         if ($source === null) {
             $source = $episode->source;
         }
     }
     if ($episode['banner_url'] && !$podcast['is_adult'] && !$podcast['always_use_banner_url']) {
         $image_path_base = 'podcast_episodes/' . $episode['guid'] . '.jpg';
         $image_path = AmazonS3::path($image_path_base);
         // Crop remote banner URL if the local version doesn't already exist.
         if (file_exists($image_path)) {
             return AmazonS3::url($image_path_base);
         } else {
             $temp_path_ext = \DF\File::getFileExtension($episode['banner_url']);
             $temp_path = DF_INCLUDE_TEMP . DIRECTORY_SEPARATOR . '/podcast_episodes/podcast_episode_' . $episode['id'] . '_temp.' . $temp_path_ext;
             @mkdir(dirname($temp_path));
             @copy($episode['banner_url'], $temp_path);
             if (file_exists($temp_path)) {
                 try {
                     Image::resizeImage($temp_path, $temp_path, 600, 300, TRUE);
                     AmazonS3::upload($temp_path, $image_path_base);
                     return AmazonS3::url($image_path_base);
                 } catch (\Exception $e) {
                 }
             }
         }
     }
     if ($podcast !== null && !empty($podcast['banner_url'])) {
         // Reference the podcast's existing banner URL.
         return AmazonS3::url($podcast['banner_url']);
     }
     if ($source !== null) {
         return Url::content('images/podcast_' . $source['type'] . '_banner.png');
     }
     return Url::content('images/podcast_default.png');
 }
Example #18
0
<?php

/**
 * Configuration for PVL Third-Party APIs.
 */
return array('pvl_api_key' => '', 'pvlnode_local_url' => 'http://localhost:4001/data', 'pvlnode_remote_url' => 'http://localhost:8080/', 'pvlnode_remote_path' => '/live', 'amazon_aws' => array('access_key_id' => '', 'secret_access_key' => '', 's3_bucket' => 'uploads.ponyvillelive.com'), 'smtp' => array('server' => 'smtp.mandrillapp.com', 'port' => '587', 'auth' => 'login', 'username' => '', 'password' => ''), 'cloudflare' => array('domain' => 'ponyvillelive.com', 'email' => '', 'api_key' => ''), 'google_apis_key' => '', 'twitter' => array('consumer_key' => '', 'consumer_secret' => '', 'user_token' => '', 'user_secret' => '', 'curl_ssl_verifyhost' => 0, 'curl_ssl_verifypeer' => false), 'tumblr' => array("key" => '', "secret" => ''), 'notifico_push_url' => '', 'hybrid_auth' => array('base_url' => \DF\Url::baseUrl(), 'debug_mode' => false, 'debug_file' => '', 'providers' => array("OpenID" => array("enabled" => true), "Google" => array("enabled" => true, "keys" => array("id" => "", "secret" => "")), "Facebook" => array("enabled" => true, "keys" => array("id" => "", "secret" => ""), "scope" => "email, user_about_me"), "Twitter" => array("enabled" => true, "keys" => array("key" => "", "secret" => "")), "Tumblr" => array("enabled" => true, "keys" => array("key" => "", "secret" => "")), "Poniverse" => array("enabled" => true, "keys" => array("id" => '', "secret" => '')))), 'centovacast' => array('host' => '198.27.112.218', 'db_user' => 'centova', 'db_pass' => '', 'db_name' => 'centova', 'timezone' => 'US/Eastern'), 'recaptcha' => array('public_key' => '', 'private_key' => ''));
Example #19
0
<?php

return array('method' => 'post', 'enctype' => 'multipart/form-data', 'groups' => array('intro' => array('legend' => 'About Artist Profiles', 'elements' => array('intro_text' => array('markup', array('markup' => '
                    <p>Thank you for submitting your Artist profile to the Ponyville Live system! Here at PVL, our growing network of radio stations, video streams and podcasts are built upon the brilliant work created by the Brony community at large, and our Artist Center is one small way that we can work directly with the artists creating this amazing content.</p>

                    <p>Artist profiles are Ponyville Live\'s way of putting you in charge of how your creative output is presented on our network, and giving you tools to work more closely with us. The Artist profile is especially useful if you are a musician or vocalist. By creating an artist profile, musicians can not only see how all of their music is performing across the network (including which songs are liked the most, played the most, etc), but you can also submit new music directly to all Ponyville Live stations from one single system.</p>

                    <p>Just so you know, we also list every artist who submits a profile on our system in our public Artists Directory, so that we can bring more exposure to your work, and direct people to your social media pages where your art originates. All of the contact information in the "Social Netowrking Links" section below is completely optional, but we encourage you to supply any items that are relevant to the work you create.</p>

                    <h3>Artist Verification</h3>
                    <p>We want to make sure that the person submitting your profile is actually you! For this reason, we require any artist profiles submitted through our system to be verified by our staff.</p>
                    <p>There are several ways to verify your profile after submitting it:</p>
                    <ul>
                        <li>Send a tweet to <a href="http://twitter.com/ponyvillelive" target="_blank">@PonyvilleLive</a> from your Twitter account,</li>
                        <li>Send an e-mail to <a href="mailto:pr@ponyvillelive.com" target="_blank">our PR team</a> with your contact information, or</li>
                        <li>Contact a member of our team on Skype or elsewhere. You can find all of our essential contact information from our <a href="' . \DF\Url::route(array('module' => 'frontend', 'controller' => 'index', 'action' => 'contact')) . '" target="_blank">Contact Us page</a>.</li>
                    </ul>
                    <p>Once your profile has been approved, you will be able to access the Artist Center by logging in to the Ponyville Live! homepage.</p>
                ')))), 'profile' => array('legend' => 'Basic Details', 'description' => 'This basic profile information will be shown to the public in our Artists Directory.', 'elements' => array('name' => array('text', array('label' => 'Your Name', 'class' => 'half-width', 'required' => true)), 'description' => array('textarea', array('label' => 'Describe Yourself', 'description' => 'Tell us about what you do in the pony community, what projects you\'ve worked with, or how you want to contribute in the future.', 'class' => 'full-width half-height')), 'types' => array('multiCheckbox', array('label' => 'Type(s) of Art Created', 'multiOptions' => \Entity\ArtistType::fetchSelect(), 'required' => true)), 'web_url' => array('text', array('label' => 'Personal Web Site Address', 'class' => 'half-width', 'filters' => array('WebAddress'))), 'image_url' => array('file', array('label' => 'Avatar', 'description' => 'This is the small image that appears on your profile. Images should be under 150x150px in size. Larger images will automatically be scaled.')))), 'social' => array('legend' => 'Social Networking Links', 'description' => '
                Adding links to these services allows us to automatically update our users about your new releases and other social activity.<br>
                All fields are optional. Most of the time, your web address for these services will match the format shown in the field.
            ', 'elements' => array('twitter_url' => array('text', array('label' => 'Twitter Address', 'class' => 'half-width', 'filters' => array('WebAddress'), 'placeholder' => 'http://www.twitter.com/YourUsername')), 'tumblr_url' => array('text', array('label' => 'Tumblr Address', 'class' => 'half-width', 'filters' => array('WebAddress'), 'placeholder' => 'http://YourUsername.tumblr.com')), 'facebook_url' => array('text', array('label' => 'Facebook Address', 'class' => 'half-width', 'filters' => array('WebAddress'), 'placeholder' => 'http://www.facebook.com/YourUserName')), 'youtube_url' => array('text', array('label' => 'YouTube Address', 'class' => 'half-width', 'filters' => array('WebAddress'), 'placeholder' => 'http://www.youtube.com/YourUsername')), 'soundcloud_url' => array('text', array('label' => 'SoundCloud Address', 'class' => 'half-width', 'filters' => array('WebAddress'), 'placeholder' => 'http://www.soundcloud.com/YourUsername')), 'deviantart_url' => array('text', array('label' => 'DeviantArt Address', 'class' => 'half-width', 'filters' => array('WebAddress'), 'placeholder' => 'http://YourUsername.deviantart.com')), 'rss_url' => array('text', array('label' => 'RSS Feed Address', 'description' => '<a href="http://www.whatisrss.com/" target="_blank">What is RSS?</a>', 'class' => 'half-width', 'filters' => array('WebAddress'))))), 'sharing' => array('legend' => 'Sharing Settings', 'description' => 'Your Sharing Settings put you in control of how your content is shared across the Ponyville Live! network of stations.', 'elements' => array('about_sharing' => array('markup', array('label' => 'About Sharing Permissions', 'markup' => '
                        <p>The "Permission to Broadcast Content" setting below is your way of instructing the team at all Ponyville Live stations on how to broadcast or present the content you produce.</p>

                        <p>There are several important things to know about this setting:</p>

                        <dl>
                            <dt>This is not a formal or legally binding agreement.</dt>
                            <dd>We aren\'t lawyers, so we\'ll keep it simple: we make every effort to respect your preferences as an artist, but we aren\'t perfect. Much like many Brony community projects, this is a fun non-commercial hobby for us, and we don\'t want to bog it down with complex legalese. Consider this page an indication of preferences and not a legally binding document.</dd>

                            <dt>Stations operate independently from the Ponyville Live network.</dt>
Example #20
0
 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;
 }
Example #21
0
 public static function handle(\Exception $e, \Phalcon\DiInterface $di)
 {
     if ($e instanceof \DF\Exception\NotLoggedIn) {
         // Redirect to login page for not-logged-in users.
         \DF\Flash::addMessage('You must be logged in to access this page!');
         // Set referrer for login redirection.
         $session = \DF\Session::get('referrer_login');
         $session->url = \DF\Url::current($di);
         // Redirect to login page.
         $login_url = $di->get('url')->get('account/login');
         $response = $di->get('response');
         $response->redirect($login_url, 302);
         $response->send();
         return;
     } elseif ($e instanceof \DF\Exception\PermissionDenied) {
         // Bounce back to homepage for permission-denied users.
         \DF\Flash::addMessage('You do not have permission to access this portion of the site.', \DF\Flash::ERROR);
         $home_url = $di->get('url')->get('');
         $response = $di->get('response');
         $response->redirect($home_url, 302);
         $response->send();
         return;
     } elseif ($e instanceof \Phalcon\Mvc\Dispatcher\Exception) {
         // Handle 404 page not found exception
         if ($di->has('view')) {
             $view = $di->get('view');
             $view->disable();
         }
         $view = \DF\Phalcon\View::getView(array());
         $result = $view->getRender('error', 'pagenotfound');
         $response = $di->get('response');
         $response->setStatusCode(404, "Not Found");
         $response->setContent($result);
         $response->send();
         return;
     } elseif ($e instanceof \DF\Exception\Bootstrap) {
         // Bootstrapping error; cannot render template for error display.
         if (DF_APPLICATION_ENV != 'production') {
             self::renderPretty($e, $di);
             return;
         } else {
             $response = $di->get('response');
             $response->setStatusCode(500, "Internal Server Error");
             $exception_msg = "<b>Application core exception: </b>\n<blockquote>" . $e->getMessage() . "</blockquote>" . "\n" . "on line <b>" . $e->getLine() . "</b> of <i>" . $e->getFile() . "</i>";
             $response->setContent($exception_msg);
             $response->send();
             return;
         }
     } else {
         if ($di->has('view')) {
             $view = $di->get('view');
             $view->disable();
         }
         $show_debug = false;
         if ($di->has('acl')) {
             $acl = $di->get('acl');
             if ($acl->isAllowed('administer all')) {
                 $show_debug = true;
             }
         }
         if (DF_APPLICATION_ENV != 'production') {
             $show_debug = true;
         }
         if ($show_debug) {
             self::renderPretty($e, $di);
             return;
         } else {
             $view = \DF\Phalcon\View::getView(array());
             $view->setVar('exception', $e);
             $result = $view->getRender('error', 'general');
             $response = $di->get('response');
             $response->setStatusCode(500, "Internal Server Error");
             $response->setContent($result);
             $response->send();
             return;
         }
     }
 }
Example #22
0
 protected function redirectToReferrer($default = false)
 {
     if (!$default) {
         $default = Url::baseUrl();
     }
     return $this->redirect(Url::referrer($default));
 }