? 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 16:55:30 -0000 @@ -25,18 +25,22 @@ 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`), KEY `station_playlist_album` (`album`), KEY `station_playlist_label` (`label`) - ) /*!40100 DEFAULT CHARACTER SET utf8 */; + ) ; "); break; } } -/** +/**CREATE TABLE `a` ( +`id` TINYINT( 5 ) NOT NULL , +`name` TEXT NOT NULL LONGTEXT +) TYPE = MYISAM ; * Implementation of hook_uninstall(). */ function station_playlist_uninstall() { 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 .= ''; + return $output; +} + +function station_playlist_search_form($field = '', $value1 ='', $value2 ='') { + $aaa=date("j, n, Y"); + $form['field'] = array( + '#type' => 'select', + '#title' => 'Search by', + '#options' => array( + '-' => t('Select one...'), + 'artist' => t('Artist'), + 'album' => t('Album'), + 'composer' => t('Composer') + ), + '#default_value' => $field, + '#required' => TRUE, + ); + $form['startvalue'] = array( + '#type' => 'date', + '#title' => 'Search from', + '#default_value' => array('month' => '1' ,'day' => '1' ,'year' => '2008',), + '#required' => TRUE, + ); + + $form['endvalue'] = array( + '#type' => 'date', + '#title' => 'Search upto', + '#default_value' => array('month' => '12' ,'day' => '1' ,'year' => '2008',), + '#required' => TRUE, + ); + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Search') + ); + $form['#action'] = url("station/playlists/popular"); + return $form; +} + +function station_playlist_search_form_validate($form_id, $form_values){ + if($form_values['field']=='-'){ + form_set_error('',"Please select a field Search by: Drop Down list"); + } +} + +function station_playlist_search_form_submit($form_id, $form_values) { + // make sure it's an allowed search field + $a = $form_values['startvalue']; + $b = $form_values['endvalue']; + //echo $a[month].$a[day].$a[year]; + $from = mktime(0, 0, 0, $a[month], $a[day], $a[year]); + $upto = mktime(0, 0, 0, $b[month], $b[day], $b[year]); + if (in_array($form_values['field'], array('artist', 'album', 'composer'))) { + return 'station/playlists/popular/' . $form_values['field'] .'/'. $from.'/'. $upto; + //print 'station/playlists/popular/' . $form_values['field'] .'/'. $form_values['startvalue'].'/'. $form_values['endvalue']; + //print_r($form_values['startvalue']); + } + return 'station/playlists/popular'; +} + +function station_playlist_search_js($field = '', $value ='') { + $matches = array(); + if ($value && in_array($field, array('artist', 'album', 'composer'))) { + + //$result = db_query_range('SELECT * FROM {station_catalog} WHERE LOWER(%s) LIKE LOWER("%s%%") ORDER BY number', $field, $value, 0, 30); + while ($item = db_fetch_object($result)) { + $matches[] = $item; + } + } + print drupal_to_js($matches); + exit(); +} + +function theme_station_playlist_search_form($form) { + $rows = array( + drupal_render($form['field']), + drupal_render($form['startvalue']), + drupal_render($form['endvalue']), + drupal_render($form['submit']), + ); + return theme('table', $rows, array()) . drupal_render($form); +} + +function station_search_page_artist(){ + $heading = array( t('Program title'),t('Title'),t('Label'),t('Date'),t('Composer'),t('Album'),t('Artist')); + $value1 = arg(1); + $value2 = arg(2); + $name = arg(3); + $result = db_query_range('SELECT n.title as programe,spt.nid as track_playlist_nid, spt.title,spt.label,sp.timestamp,spt.composer,spt.album,spt.artist 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 AND spt.artist = "%s" ',$value1,$value2,$name,0,30); + + while($item = db_fetch_object($result)) { + $time = date("d-M-Y",$item->timestamp); + $pro = $item->programe; + $a = strpos($pro,"playlist for"); + if($a>0){ + $protitle = substr($item->programe,0,$a); + } + else{ + $protitle = $pro; + } + $rows[]= array($protitle,$item->title,$item->label,l($time,'node/'.$item->track_playlist_nid),$item->composer,$item->album,$item->artist); + } + if ($rows) { + $matches = theme('table',$heading , $rows); + } + else { + $matches = t("No matches were found."); + } + + $output .= '
' .$matches; + $output .= 'go back
'; + return $output; +} + +function station_search_page_album(){ + $heading = array( t('Program title'),t('Title'),t('Label'),t('Date'),t('Composer'),t('Album'),t('Artist')); + $value1 = arg(1); + $value2 = arg(2); + //print date("d-M-Y"); + $name = arg(3); + $result = db_query_range('SELECT n.nid,n.title as programe,spt.nid as track_playlist_nid, spt.title, spt.label, sp.timestamp, spt.composer, spt.album, spt.artist 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 AND spt.album = "%s" ',$value1,$value2,$name,0,30); + + while($item = db_fetch_object($result)) { + $time = date("d-M-Y",$item->timestamp); + $pro = $item->programe; + $a = strpos($pro,"playlist for"); + if($a>0){ + $protitle = substr($item->programe,0,$a); + } + else{ + $protitle = $pro; + } + $rows[]= array($protitle,$item->title,$item->label,l($time,'node/'.$item->track_playlist_nid),$item->composer,$item->album,$item->artist); + } + + if ($rows) { + $matches = theme('table',$heading , $rows); + } + else { + $matches = t("No matches were found."); + } + + $output .= '
' .$matches; + $output .= 'go back
'; + return $output; +} + +function station_search_page_composer(){ + $heading = array( t('Program title'),t('Title'),t('Label'),t('Date'),t('Composer'),t('Album'),t('Artist')); + $value1 = arg(1); + $value2 = arg(2); + $name = arg(3); + $result = db_query_range('SELECT n.title as programe,spt.nid as track_playlist_nid,spt.title,spt.label,sp.timestamp,spt.composer,spt.album,spt.artist 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 AND spt.composer = "%s" ',$value1,$value2,$name,0,30); + + while($item = db_fetch_object($result)) { + $time = date("d-M-Y",$item->timestamp); + $pro = $item->programe; + $a = strpos($pro,"playlist for"); + if($a>0){ + $protitle = substr($item->programe,0,$a); + } + else{ + $protitle = $pro; + } + $rows[]= array($protitle,$item->title,$item->label,l($time,'node/'.$item->track_playlist_nid),$item->composer,$item->album,$item->artist); + + } + if ($rows) { + $matches = theme('table',$heading , $rows); + } + else { + $matches = t("No matches were found."); + } + + $output .= '
' .$matches; + $output .= 'go back
'; + return $output; +} + Index: playlist/views.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/station/playlist/views.inc,v retrieving revision 1.1.2.1 diff -u -p -u -p -r1.1.2.1 views.inc --- playlist/views.inc 1 Oct 2007 16:22:36 -0000 1.1.2.1 +++ playlist/views.inc 19 Nov 2007 22:32:46 -0000 @@ -93,6 +93,7 @@ function station_playlist_arg_program_ni $query->ensure_table('station_playlist', true); $query->ensure_table('station_playlist_program_node', true); $query->add_field('program_nid', 'station_playlist'); + $query->add_field('program_composer', 'station_playlist'); $query->add_field('title', 'station_playlist_program_node'); $fieldinfo['field'] = "station_playlist_program_node.title"; return $fieldinfo;