Fixed bug where clicking on a column name in the search results gave you no results from that point forward. Now if you click on a column name it will sort by the column. Fixed #2173 - This was done by removing the sorting by track number. However, and upgrade script has been added to clean track numbers (convert from things like "20/1" to "1"), and this same function is used when importing from the command line and the web (however, not from the studio). More fixes for #2107 - changed the way the Web BROWSE columns work so that they matched how the studio works (i.e. each column is dependent on the previous column).

This commit is contained in:
paul 2007-02-09 15:38:57 +00:00
parent 01b4a6d993
commit be56bbd453
6 changed files with 129 additions and 58 deletions

View file

@ -3,6 +3,37 @@ require_once("MetaData.php");
require_once("Playlist.php");
require_once(dirname(__FILE__)."/../../getid3/var/getid3.php");
/**
* Track numbers in metadata tags can come in many formats:
* "1 of 20", "1/20", "20/1". This function parses the track
* number and gets the real number so that we can sort by it
* in the database.
*
* @param string $p_trackNumber
* @return int
*/
function camp_parse_track_number($p_trackNumber)
{
$num = trim($p_trackNumber);
if (!is_numeric($num)) {
$matches = preg_match("/\s*([0-9]+)([^0-9]*)([0-9]*)\s*/", $num, $results);
$trackNum = 0;
foreach ($results as $result) {
if (is_numeric($result)) {
if ($trackNum == 0) {
$trackNum = $result;
} elseif ($result < $trackNum) {
$trackNum = $result;
}
}
}
} else {
$trackNum = $num;
}
return $trackNum;
}
/**
* Add data to the global array $mdata, also sets global variables
* $titleHaveSet and $titleKey.
@ -199,6 +230,11 @@ function camp_get_audio_metadata($p_filename, $p_testonly = false)
eval("\$enc = $encodedElement;");
}
}
// Special case handling for track number
if ($key == "ls:track_num") {
$data = camp_parse_track_number($data);
}
camp_add_metadata($mdata, $key, $data, $enc);
if ($key == $titleKey) {
$titleHaveSet = TRUE;