Ticket #3267: mythweb-music-add-genre.patch

File mythweb-music-add-genre.patch, 5.0 KB (added by otto at kolsi dot fi, 14 years ago)
  • modules/music/mp3act_functions.php

     
    382382        <ul class="music">';
    383383
    384384      $query = 'SELECT ms.song_id, ms.track, ms.name, ms.length, ms.numplays, '.
    385                'SEC_TO_TIME(ms.length/1000) AS length, artist_name '.
     385               'SEC_TO_TIME(ms.length/1000) AS length, artist_name, genre '.
    386386               'FROM music_songs AS ms '.
    387387               'LEFT JOIN music_artists ON ms.artist_id=music_artists.artist_id '.
     388               'LEFT JOIN music_genres ON ms.genre_id=music_genres.genre_id '.
    388389               'WHERE ms.album_id='.$sql_itemid.' '.
    389390               'ORDER BY ms.track';
    390391      $result = mysql_query($query);
     
    395396      {
    396397        $output .= getHtmlSong($row['song_id'], $row['artist_name'],
    397398          '', $row['track'], $row['name'],
    398           $row['length'], $row['numplays']);
     399          $row['length'], $row['numplays'], $row['genre']);
    399400      }
    400401      mysql_free_result($result);
    401402      $output .= '</ul>';
     
    424425      {
    425426        $output .= getHtmlSong($row['song_id'], $row['artist_name'],
    426427          '', '', $row['name'],
    427           $row['length'], $row['numplays']);
     428          $row['length'], $row['numplays'], '');
    428429      }
    429430      mysql_free_result($result);
    430431      $output .= '</ul>';
     
    478479        <ul class="music">';
    479480
    480481      $query = 'SELECT ms.song_id, ms.track, ms.name, ms.length, ms.numplays, '.
    481         'SEC_TO_TIME(ms.length/1000) AS length, music_artists.artist_name, track, music_albums.album_name '.
     482        'SEC_TO_TIME(ms.length/1000) AS length, music_artists.artist_name, track, '.
     483        'music_albums.album_name, genre '.
    482484        'FROM music_songs AS ms '.
    483485        'LEFT JOIN music_artists ON ms.artist_id=music_artists.artist_id '.
    484486        'LEFT JOIN music_albums ON ms.album_id=music_albums.album_id '.
     487        'LEFT JOIN music_genres ON ms.genre_id=music_genres.genre_id '.
    485488        'WHERE ms.artist_id='.$sql_itemid.';';
    486489      $result = mysql_query($query);
    487490      if (!$result)
     
    491494      {
    492495        $output .= getHtmlSong($row['song_id'], '',
    493496          $row['album_name'], $row['track'], $row['name'],
    494           $row['length'], $row['numplays']);
     497          $row['length'], $row['numplays'], $row['genre']);
    495498      }
    496499      mysql_free_result($result);
    497500      $output .= '</ul>';
     
    653656            $row = $song_info[$song_id];
    654657            $output .= getHtmlSong($row['song_id'], $row['artist_name'],
    655658              '', '', $row['name'],
    656               $row['length'], $row['numplays']);
     659              $row['length'], $row['numplays'], '');
    657660          }
    658661          else if ($song_id < 0)
    659662          {
     
    760763      while ($row = mysql_fetch_array($result))
    761764      {
    762765        $output .= getHtmlSong($row['song_id'], $row['artist_name'],
    763           '', '', $row['name'],
    764           '', '');
     766          '', '', $row['name'], '', '', '');
    765767      }
    766768      mysql_free_result($result);
    767769      $output .= '</ul>';
     
    787789      while ($row = mysql_fetch_array($result))
    788790      {
    789791        $output .= getHtmlSong($row['song_id'], $row['artist_name'],
    790           '', '', $row['name'],
    791           '', '');
     792          '', '', $row['name'], '', '', '');
    792793      }
    793794      $output .= '</ul>';
    794795      break;
     
    835836function searchMusic($terms, $option)
    836837{
    837838  $sql_terms = "'%".mysql_real_escape_string($terms)."%'";
    838   $query = 'SELECT ms.song_id, ma.album_name, ms.track, mt.artist_name, ms.name, SEC_TO_TIME(ms.length/1000) AS length '.
     839  $query = 'SELECT ms.song_id, ma.album_name, ms.track, mt.artist_name, ms.name, SEC_TO_TIME(ms.length/1000) AS length, genre '.
    839840    'FROM music_songs AS ms '.
    840841    'LEFT JOIN music_artists AS mt ON ms.artist_id=mt.artist_id '.
    841842    'LEFT JOIN music_albums AS ma ON ms.album_id=ma.album_id '.
     843    'LEFT JOIN music_genres AS mg ON ms.genre_id=mg.genre_id '.
    842844    'WHERE 1 AND ';
    843845
    844846  if ($option == 'all')
     
    881883    {
    882884      $output .= getHtmlSong($row['song_id'], $row['artist_name'],
    883885        $row['album_name'], $row['track'], $row['name'],
    884         $row['length'], '');
     886        $row['length'], '', $row['genre']);
    885887    }
    886888    $output .= '</ul>';
    887889  }
  • modules/music/mp3act_html_functions.php

     
    11<?php
    22
    3 function getHtmlSong($id, $artistName, $albumName, $trackNum, $trackName, $trackLength, $numPlays)
     3function getHtmlSong($id, $artistName, $albumName, $trackNum, $trackName, $trackLength, $numPlays, $genre)
    44{
    55  static $alt = true;
    66  $alt = !$alt;
     
    3636  if (!empty($trackLength))
    3737    '<em>'.$trackLength.'</em>';
    3838
     39  if(!empty($genre))
     40    $sub_output .= t('Genre').': '.$genre.'<br />';
     41
    3942  if (!empty($sub_output))
    4043  {
    4144    $output .= '<p>'.$sub_output.'</p>';