From fb55bed3c804a134f8cbdb77607979e384584bb3 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sat, 10 Mar 2012 19:36:40 -0300 Subject: Initial commit --- icecast_page.module | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 icecast_page.module (limited to 'icecast_page.module') diff --git a/icecast_page.module b/icecast_page.module new file mode 100644 index 0000000..f4cbf62 --- /dev/null +++ b/icecast_page.module @@ -0,0 +1,75 @@ + 'blogs', + * 'page callback' => 'blog_page', + * 'access arguments' => array('access content'), + * 'type' => MENU_SUGGESTED_ITEM, + *); + */ + $items['stream'] = array( + 'title' => 'Icecast Stream', + 'page callback' => 'icecast_page', + 'access arguments' => array('access content'), + 'type' => MENU_CALLBACK, + ); + + return $items; +} + +/** + * Implements hook_theme() + */ +function icecast_page_theme() { + return array( + 'icecast_page' => array( + 'arguments' => array('listen_url' => NULL), + 'template' => 'icecast_page', ), + 'qwebirc' => array( + 'arguments' => array('mount' => NULL), + 'template' => 'qwebirc', ), + 'icecast_page_footer' => array( + 'arguments' => array('listen_url' => NULL), + 'template' => 'icecast_page_footer', ), + ); +} + +/** + * Page callback. + * + * @param $sid + * Stream Id. + */ +function icecast_page($sid = NULL) { + $sid = (int) $sid; + $query = 'SELECT server_name, description, listen_url FROM {yp_stream} WHERE sid = %d'; + $result = db_fetch_array(db_query(db_rewrite_sql($query), $sid)); + + if ($sid == NULL || empty($result['listen_url'])) { + drupal_not_found(); + return; + } + + drupal_set_title(t('Live: @server_name', array('@server_name' => check_plain($result['server_name'])))); + + $mount = basename($result['listen_url'], '.ogg'); + $mount = basename($mount, '.ogv'); + $mount = basename($mount, '.mp3'); + + $output = theme('icecast_page', $result['listen_url']); + $output .= theme('qwebirc', $mount); + $output .= theme('icecast_page_footer', $result['listen_url']); + + return $output; +} -- cgit v1.2.3