? LICENSE.txt ? pre-update.sql ? schedule/_station_schedule.install ? schedule/images/Thumbs.db Index: playlist/station_playlist.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/station/playlist/station_playlist.install,v retrieving revision 1.4.2.1 diff -u -p -u -p -r1.4.2.1 station_playlist.install --- playlist/station_playlist.install 28 Apr 2007 20:57:01 -0000 1.4.2.1 +++ playlist/station_playlist.install 19 Dec 2007 17:10:34 -0000 @@ -25,6 +25,7 @@ function station_playlist_install() { `title` varchar(255) NOT NULL default '', `label` varchar(255) NOT NULL default '', `link` varchar(255) NOT NULL default '', + `composer` LONGTEXT default '', KEY `station_playlist_artist` (`artist`), KEY `station_playlist_nid_weight` (`nid`,`weight`), KEY `station_playlist_title` (`title`), Index: playlist/station_playlist.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/station/playlist/station_playlist.module,v retrieving revision 1.9.2.4 diff -u -p -u -p -r1.9.2.4 station_playlist.module --- playlist/station_playlist.module 19 Oct 2007 15:56:01 -0000 1.9.2.4 +++ playlist/station_playlist.module 19 Dec 2007 17:06:17 -0000 @@ -1,6 +1,9 @@ MENU_LOCAL_TASK ); + $items[] = array( + 'path' => 'station/playlists/popular', + 'title' => t('Popular'), + 'callback' => 'station_search_page', + 'access' => user_access('access content'), + ); + + $items[] = array( + 'path' => 'artist', + 'title' => t('Popular Artist'), + 'callback' => 'station_search_page_artist', + 'access' => user_access('access content'), + 'type' => MENU_CALLBACK, + ); + + $items[] = array( + 'path' => 'album', + 'title' => t('Popular Album'), + 'callback' => 'station_search_page_album', + 'access' => user_access('access content'), + 'type' => MENU_CALLBACK, + ); + + $items[] = array( + 'path' => 'composer', + 'title' => t('Popular Composer'), + 'callback' => 'station_search_page_composer', + 'access' => user_access('access content'), + 'type' => MENU_CALLBACK, + ); + + $items[] = array( + 'path' => 'station/playlist/js_search', + 'callback' => 'station_playlist_search_js', + 'access' => user_access('access content'), + 'type' => MENU_CALLBACK, + ); + + /* $items[] = array( + 'path' => 'station/playlists/popular', + 'title' => t("best composer"), + 'callback' => 'station_playlist_popular_composer', + 'access' => user_access('access content'), + ); + $items[] = array( + 'path' => 'station/playlists/popular_', + 'title' => t("What's hot"), + 'callback' => 'station_playlist_popular', + 'access' => user_access('access content'), + ); + */ + $items[] = array( 'path' => 'station/autocomplete/playlist', 'title' => t('Playlist Autocomplete'), 'callback' => 'station_playlist_autocomplete', @@ -85,6 +140,38 @@ function station_playlist_admin_settings '#default_value' => variable_get('station_playlist_program_dateformat', 'F j, Y'), '#description' => t("The playlist's date is also displayed on the the program node. This setting lets you control how it is formatted."), ); + $times = array( + 4 * STATION_PLAYLIST_WEEK, + 3 * STATION_PLAYLIST_WEEK, + 2 * STATION_PLAYLIST_WEEK, + 1 * STATION_PLAYLIST_WEEK, + 6 * STATION_PLAYLIST_DAY, + 5 * STATION_PLAYLIST_DAY, + 4 * STATION_PLAYLIST_DAY, + 3 * STATION_PLAYLIST_DAY, + 2 * STATION_PLAYLIST_DAY, + 1 * STATION_PLAYLIST_DAY, + ); + $age_options = drupal_map_assoc($times, 'format_interval'); + $form['popular'] = array( + '#type' => 'fieldset', + '#title' => t('Popular list'), + '#tree' => FALSE, + ); + $form['popular']['station_playlist_popular_range'] = array( + '#type' => 'select', + '#title' => t('Show since'), + '#default_value' => variable_get('station_playlist_popular_range', 1 * STATION_PLAYLIST_WEEK), + '#options' => $age_options, + '#description' => t("Show the most played albums for this length of time from."), + ); + $form['popular']['station_playlist_popular_range2'] = array( + '#type' => 'select', + '#title' => t('Show upto'), + '#default_value' => variable_get('station_playlist_popular_range2', 1 * STATION_PLAYLIST_DAY), + '#options' => $age_options, + '#description' => t("Show the most played albums for this length of time upto should be less then from."), + ); $form['module_cvs_id'] = array( '#type' => 'item', '#value' => '
'. STATION_PLAYLIST_CVS_ID .'', @@ -253,6 +340,11 @@ function station_playlist_form(&$node) { '#default_value' => $track['label'], '#autocomplete_path' => 'station/autocomplete/playlist/label', ); + $form['tracks'][$weight]['composer'] = array( + '#type' => 'textfield', '#size' => 30, '#maxlength' => 255, + '#default_value' => $track['composer'], + '#autocomplete_path' => 'station/autocomplete/playlist/composer', + ); $form['tracks'][$weight]['link'] = array( '#type' => 'textfield', '#size' => 30, '#maxlength' => 255, '#default_value' => $track['link'], @@ -279,6 +371,10 @@ function station_playlist_form(&$node) { '#size' => 30, '#maxlength' => 255, '#autocomplete_path' => 'station/autocomplete/playlist/label', ); + $form['tracks'][$weight]['composer'] = array('#type'=>'textfield', + '#size' => 30, '#maxlength' => 500, + '#autocomplete_path' => 'station/autocomplete/playlist/composer', + ); $form['tracks'][$weight]['link'] = array('#type'=>'textfield', '#size' => 30, '#maxlength' => 255, ); @@ -292,7 +388,7 @@ function station_playlist_form(&$node) { } function theme_station_playlist_track_form($form) { - $header = array(t('Artist'), t('Title'), t('Album'), t('Label'), t('Link'), t('Weight')); + $header = array(t('Artist'), t('Title'), t('Album'), t('Label'),t('Composer'), t('Link'), t('Weight')); $rows = array(); foreach (element_children($form) as $key) { @@ -301,6 +397,7 @@ function theme_station_playlist_track_fo $row[] = drupal_render($form[$key]['title']); $row[] = drupal_render($form[$key]['album']); $row[] = drupal_render($form[$key]['label']); + $row[] = drupal_render($form[$key]['composer']); $row[] = drupal_render($form[$key]['link']); $row[] = drupal_render($form[$key]['weight']); $rows[] = $row; @@ -367,9 +464,11 @@ function station_playlist_load($node) { 'year' => date('Y', $extras->timestamp) ); + //$extra->composer = + // tracks $extras->tracks = array(); - $result = db_query('SELECT weight, album, artist, title, label, link FROM {station_playlist_track} WHERE nid = %d ORDER BY weight', $node->nid); + $result = db_query('SELECT weight, album, artist, title, label,composer, link FROM {station_playlist_track} WHERE nid = %d ORDER BY weight', $node->nid); while ($track = db_fetch_array($result)) { $extras->tracks[] = $track; } @@ -384,8 +483,8 @@ function station_playlist_insert($node) db_query("INSERT INTO {station_playlist} (nid, program_nid, timestamp) VALUES (%d, %d, %d)", $node->nid, $node->program_nid, $node->timestamp); foreach ($node->tracks as $track) { if ($track['artist'] || $track['title']) { - db_query("INSERT INTO {station_playlist_track} (nid, weight, artist, album, title, label, link) VALUES (%d, %d, '%s', '%s', '%s', '%s', '%s')", - $node->nid, trim($track['weight']), trim($track['artist']), trim($track['album']), trim($track['title']), trim($track['label']), trim($track['link'])); + db_query("INSERT INTO {station_playlist_track} (nid, weight, artist, album, title, label,composer, link) VALUES (%d, %d, '%s', '%s', '%s', '%s','%s', '%s')", + $node->nid, trim($track['weight']), trim($track['artist']), trim($track['album']), trim($track['title']), trim($track['label']),trim($track['composer']), trim($track['link'])); } } } @@ -407,8 +506,8 @@ function station_playlist_update($node) db_query('DELETE FROM {station_playlist_track} WHERE nid = %d', $node->nid); foreach ($node->tracks as $track) { if ($track['artist'] || $track['title']) { - db_query("INSERT INTO {station_playlist_track} (nid, weight, artist, album, title, label, link) VALUES (%d, %d, '%s', '%s', '%s', '%s', '%s')", - $node->nid, trim($track['weight']), trim($track['artist']), trim($track['album']), trim($track['title']), trim($track['label']), trim($track['link'])); + db_query("INSERT INTO {station_playlist_track} (nid, weight, artist, album, title, label, link ,composer) VALUES (%d, %d, '%s', '%s', '%s', '%s', '%s', '%s')", + $node->nid, trim($track['weight']), trim($track['artist']), trim($track['album']), trim($track['title']), trim($track['label']), trim($track['link']),trim($track['composer'])); } } } @@ -437,6 +536,7 @@ function station_playlist_view(&$node, $ foreach ((array) $node->tracks as $track) { $hasAlbum |= (bool) ($track['album']); $hasLabel |= (bool) ($track['label']); + $hasComposer |= (bool) ($track['composer']); $hasLink |= (bool) ($track['link']); } $header = array(t('Artist'), t('Title')); @@ -446,6 +546,9 @@ function station_playlist_view(&$node, $ if ($hasLabel) { $header[] = t('Label'); } + if ($hasComposer) { + $header[] = t('Composer'); + } if ($hasLink) { $header[] = t('Link'); } @@ -462,6 +565,9 @@ function station_playlist_view(&$node, $ if ($hasLabel) { $row[] = check_plain($track['label']); } + if ($hasComposer) { + $row[] = check_plain($track['composer']); + } if ($hasLink) { if ($track['link']) { // Use the host name as a link text @@ -549,3 +655,268 @@ function station_playlist_autocomplete($ print drupal_to_js($matches); exit(); } + +/** + * Display a page of most popular albums. + */ +function station_playlist_popular() { + $since = time() - variable_get('station_playlist_popular_range', 1 * STATION_PLAYLIST_WEEK); + $upto = time() - variable_get('station_playlist_popular_range2', 1 * STATION_PLAYLIST_DAY); + if($since>$upto){ + $upto = time(); + variable_set('station_playlist_popular_range2', 1 * STATION_PLAYLIST_DAY); + } + $sql = 'SELECT spt.artist, spt.album, COUNT(*) AS play_count FROM {node} n INNER JOIN {station_playlist} sp ON n.nid = sp.nid INNER JOIN {station_playlist_track} spt ON sp.nid = spt.nid WHERE sp.timestamp >= %d GROUP BY spt.album HAVING COUNT(*) >= 1 ORDER BY play_count DESC'; + //$result = db_queryd($sql, array($since)); + $result = db_query_range($sql, array($since), 0, 30); + $rows = array(); + while ($item = db_fetch_array($result)) { + $rows[] = $item; + } + $header = array(t('Artist'), t('Album'), t('Play count')); + return theme('table', $header, $rows); +} + +function station_playlist_popular_composer() { + $since = time() - variable_get('station_playlist_popular_range', 1 * STATION_PLAYLIST_WEEK); + $upto = time() - variable_get('station_playlist_popular_range2', 1 * STATION_PLAYLIST_DAY); + if($since>$upto){ + $upto = time(); + variable_set('station_playlist_popular_range2', 1 * STATION_PLAYLIST_DAY); + } + $sql = 'SELECT spt.composer, COUNT(*) AS play_count FROM {node} n INNER JOIN {station_playlist} sp ON n.nid = sp.nid INNER JOIN {station_playlist_track} spt ON sp.nid = spt.nid WHERE sp.timestamp >= %d AND sp.timestamp <= %d GROUP BY spt.composer HAVING COUNT(*) >= 1 ORDER BY play_count DESC'; + //$result = db_queryd($sql, array($since,$upto)); + $result = db_query_range($sql, array($since,$upto),0,30); + $rows = array(); + while ($item = db_fetch_array($result)) { + $rows[] = $item; + } + $header = array(t('Composer'), t('Play count')); + return theme('table', $header, $rows); +} + + + +function station_search_page($field = '', $value1 ='', $value2 ='') { + drupal_add_js(drupal_get_path('module', 'station_catalog') .'/station_catalog.js' , 'module', 'header', FALSE, TRUE); + + $output .= '