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:
parent
01b4a6d993
commit
be56bbd453
|
@ -13,12 +13,12 @@
|
|||
<table style="width: 600px;">
|
||||
<tr class="blue_head">
|
||||
<td style="width: 20px"><input type="checkbox" name="all" onClick="collector_switchAll('SEARCHRESULTS')"></td>
|
||||
<td style="width: 200px;"><a href="#" onClick="hpopup('{$UI_HANDLER}?act={$_act_prefix}.reorder&by=title', 'order');" id="blue_head">##Title##</a></td>
|
||||
<td style="width: 195px"><a href="#" onClick="hpopup('{$UI_HANDLER}?act={$_act_prefix}.reorder&by=creator', 'order');" id="blue_head">##Creator##</a></td>
|
||||
<td style="width: 195px">##Album##</td>
|
||||
<td style="width: 25px">##Track##</td>
|
||||
<td><a href="#" onClick="hpopup('{$UI_HANDLER}?act={$_act_prefix}.reorder&by=extent', 'order');" id="blue_head">##Duration##</a></td>
|
||||
<td style="width: 41px; border: 0; text-align: center"><a href="#" onClick="hpopup('{$UI_HANDLER}?act={$_act_prefix}.reorder&by=type', 'order');" id="blue_head">##Type##</a></td>
|
||||
<td style="width: 200px;"><a href="#" onClick="hpopup('{$UI_HANDLER}?act={$_act_prefix}.reorder&by=dc:title', 'order');" id="blue_head">##Title##</a></td>
|
||||
<td style="width: 195px"><a href="#" onClick="hpopup('{$UI_HANDLER}?act={$_act_prefix}.reorder&by=dc:creator', 'order');" id="blue_head">##Creator##</a></td>
|
||||
<td style="width: 195px"><a href="#" onClick="hpopup('{$UI_HANDLER}?act={$_act_prefix}.reorder&by=dc:source', 'order');" id="blue_head">##Album##</a></td>
|
||||
<td style="width: 25px"><a href="#" onClick="hpopup('{$UI_HANDLER}?act={$_act_prefix}.reorder&by=ls:track_num', 'order');" id="blue_head">##Track##</a></td>
|
||||
<td><a href="#" onClick="hpopup('{$UI_HANDLER}?act={$_act_prefix}.reorder&by=dcterms:extent', 'order');" id="blue_head">##Duration##</a></td>
|
||||
<td style="width: 41px; border: 0; text-align: center">{*<a href="#" onClick="hpopup('{$UI_HANDLER}?act={$_act_prefix}.reorder&by=type', 'order');" id="blue_head">*}##Type##{*</a>*}</td>
|
||||
</tr>
|
||||
{foreach from=$_results.items item=i}
|
||||
<!-- start item -->
|
||||
|
|
|
@ -6,7 +6,10 @@
|
|||
*/
|
||||
class uiBrowse
|
||||
{
|
||||
public $Base; // uiBase object
|
||||
/**
|
||||
* @var uiBase
|
||||
*/
|
||||
public $Base;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
|
@ -188,23 +191,33 @@ class uiBrowse
|
|||
$columnNumber = $p_param['col'];
|
||||
$category = uiBase::formElementDecode($p_param['category']);
|
||||
|
||||
// Set the new values for this column.
|
||||
// Set the new category for this column.
|
||||
$this->col[$columnNumber]['category'] = $category;
|
||||
$this->col[$columnNumber]['criteria'] = NULL;
|
||||
$this->col[$columnNumber]['form_value'] = '%%all%%';
|
||||
$previousValue = $this->col[$columnNumber]['form_value'];
|
||||
|
||||
// Get the values of this category based on the criteria in the
|
||||
// other columns.
|
||||
// For this column and all columns above this one, reset the values
|
||||
for ($i = $columnNumber; $i <= 3; $i++) {
|
||||
$this->col[$i]['criteria'] = NULL;
|
||||
$this->col[$i]['form_value'] = '%%all%%';
|
||||
}
|
||||
|
||||
// Reload the criteria
|
||||
$this->setCriteria();
|
||||
$tmpCriteria = $this->criteria;
|
||||
// We put a limit here to because some categories will select
|
||||
// way too many values.
|
||||
$tmpCriteria["limit"] = 1000;
|
||||
$tmpCriteria["offset"] = 0;
|
||||
$browseValues = $this->Base->gb->browseCategory(
|
||||
$category, $tmpCriteria, $this->Base->sessid);
|
||||
if (!PEAR::isError($browseValues)) {
|
||||
$this->col[$columnNumber]['values'] = $browseValues;
|
||||
|
||||
// For this column and all columns above this one,
|
||||
// reload the values.
|
||||
for ($i = $columnNumber; $i <= 3; $i++) {
|
||||
$browseValues = $this->Base->gb->browseCategory(
|
||||
$this->col[$i]["category"], $tmpCriteria, $this->Base->sessid);
|
||||
if (!PEAR::isError($browseValues)) {
|
||||
$this->col[$i]['values'] = $browseValues;
|
||||
}
|
||||
$browseValues = null;
|
||||
}
|
||||
|
||||
$this->Base->redirUrl = UI_BROWSER.'?act='.$this->prefix;
|
||||
|
@ -242,6 +255,12 @@ class uiBrowse
|
|||
$this->col[$columnNumber]['criteria']['conditions'] = $conditions;
|
||||
}
|
||||
|
||||
// Clear all columns above this one of selected values.
|
||||
for ($tmpColNum = $columnNumber + 1; $tmpColNum <= 3; $tmpColNum++) {
|
||||
$this->col[$tmpColNum]['criteria'] = NULL;
|
||||
$this->col[$tmpColNum]['form_value'] = '%%all%%';
|
||||
}
|
||||
|
||||
// Update the criteria
|
||||
$this->setCriteria();
|
||||
$tmpCriteria = $this->criteria;
|
||||
|
@ -250,22 +269,13 @@ class uiBrowse
|
|||
$tmpCriteria["limit"] = 1000;
|
||||
$tmpCriteria["offset"] = 0;
|
||||
|
||||
// We need to update all other column values for any column
|
||||
// that does not have a selected value.
|
||||
for ($tmpColNum = 1; $tmpColNum <= 3; $tmpColNum++) {
|
||||
// Make sure not to update current column
|
||||
if ($tmpColNum != $columnNumber) {
|
||||
// if the column does not have a selected value
|
||||
if ($this->col[$tmpColNum]['criteria'] == NULL) {
|
||||
$tmpCategory = $this->col[$tmpColNum]['category'];
|
||||
$browseValues = $this->Base->gb->browseCategory(
|
||||
$tmpCategory, $tmpCriteria, $this->Base->sessid);
|
||||
if (!PEAR::isError($browseValues)) {
|
||||
$this->col[$tmpColNum]['values'] = $browseValues;
|
||||
$this->col[$tmpColNum]['criteria'] = NULL;
|
||||
$this->col[$tmpColNum]['form_value'] = '%%all%%';
|
||||
}
|
||||
}
|
||||
// For all columns greater than this one, reload the values.
|
||||
for ($tmpColNum = $columnNumber + 1; $tmpColNum <= 3; $tmpColNum++) {
|
||||
$tmpCategory = $this->col[$tmpColNum]['category'];
|
||||
$browseValues = $this->Base->gb->browseCategory(
|
||||
$tmpCategory, $tmpCriteria, $this->Base->sessid);
|
||||
if (!PEAR::isError($browseValues)) {
|
||||
$this->col[$tmpColNum]['values'] = $browseValues;
|
||||
}
|
||||
}
|
||||
$this->Base->redirUrl = UI_BROWSER.'?act='.$this->prefix;
|
||||
|
@ -364,17 +374,17 @@ class uiBrowse
|
|||
} // fn pagination
|
||||
|
||||
|
||||
public function reorder($by)
|
||||
public function reorder($p_orderBy)
|
||||
{
|
||||
$this->criteria['offset'] = NULL;
|
||||
|
||||
if ( ($this->criteria['orderby'] == $by) && !$this->criteria['desc']) {
|
||||
if ( ($this->criteria['orderby'] == $p_orderBy) && !$this->criteria['desc']) {
|
||||
$this->criteria['desc'] = TRUE;
|
||||
} else {
|
||||
$this->criteria['desc'] = FALSE;
|
||||
}
|
||||
|
||||
$this->criteria['orderby'] = $by;
|
||||
$this->criteria['orderby'] = $p_orderBy;
|
||||
$this->setReload();
|
||||
} // fn reorder
|
||||
|
||||
|
|
|
@ -66,20 +66,10 @@ class BasicStor {
|
|||
/**
|
||||
* Store new file in the storage
|
||||
*
|
||||
* @param int $parid
|
||||
* @param int $p_parentId
|
||||
* Parent id
|
||||
* @param string $fileName
|
||||
* Name for new file
|
||||
* @param string $localFilePath
|
||||
* Local path of media file
|
||||
* @param string $metadataFilePath
|
||||
* Local path of metadata file
|
||||
* @param string $gunid
|
||||
* global unique id
|
||||
* @param string $ftype
|
||||
* Internal file type
|
||||
* @param string $mdataLoc
|
||||
* 'file'|'string'
|
||||
* @param array $p_values
|
||||
* See StoredFile::Insert() for details.
|
||||
* @param boolean $copyMedia
|
||||
* copy the media file if true, make symlink if false
|
||||
* @return int|PEAR_Error
|
||||
|
|
|
@ -367,15 +367,33 @@ class DataEngine {
|
|||
|
||||
// Order by clause
|
||||
$orderby = TRUE;
|
||||
$orderByAllowedValues = array('dc:creator', 'dc:source', 'dc:title', 'dcterms:extent', "ls:track_num");
|
||||
$orderByDefaults = array('dc:creator', 'dc:source', 'dc:title');
|
||||
if ((!isset($criteria['orderby']))
|
||||
|| (is_array($criteria['orderby']) && (count($criteria['orderby'])==0))) {
|
||||
// default ORDER BY
|
||||
$orderbyQns = array('dc:creator', 'dc:source', 'ls:track_num', 'dc:title');
|
||||
// PaulB: track number removed because it doesnt work yet because
|
||||
// if track_num is not an integer (e.g. bad metadata like "1/20",
|
||||
// or if the field is blank) the SQL statement gives an error.
|
||||
//$orderbyQns = array('dc:creator', 'dc:source', 'ls:track_num', 'dc:title');
|
||||
$orderbyQns = $orderByDefaults;
|
||||
} else {
|
||||
$orderbyQns = $criteria['orderby'];
|
||||
}
|
||||
if (!is_array($orderbyQns)) {
|
||||
$orderbyQns = array($orderbyQns);
|
||||
// ORDER BY clause is given in the parameters.
|
||||
|
||||
// Convert the parameter to an array if it isnt already.
|
||||
$orderbyQns = $criteria['orderby'];
|
||||
if (!is_array($orderbyQns)) {
|
||||
$orderbyQns = array($orderbyQns);
|
||||
}
|
||||
|
||||
// Check that it has valid ORDER BY values, if not, revert
|
||||
// to the default ORDER BY values.
|
||||
foreach ($orderbyQns as $metadataTag) {
|
||||
if (!in_array($metadataTag, $orderByAllowedValues)) {
|
||||
$orderbyQns = $orderByDefaults;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$descA = (isset($criteria['desc']) ? $criteria['desc'] : NULL);
|
||||
|
@ -437,11 +455,13 @@ class DataEngine {
|
|||
// Special case for track number because if we use text
|
||||
// sorting of this value, then 10 comes right after 1.
|
||||
// So we convert track number to an integer for ordering.
|
||||
if ($qname == "ls:track_num") {
|
||||
$tmpSql .= ", CAST(m$i.object as integer) as ls_track_num";
|
||||
} else {
|
||||
$tmpSql .= ", m$i.object as ".$dataName[$qname];
|
||||
}
|
||||
|
||||
// PaulB: see my note above about why this is commented out.
|
||||
//if ($qname == "ls:track_num") {
|
||||
// $tmpSql .= ", CAST(m$i.object as integer) as ls_track_num";
|
||||
//} else {
|
||||
$tmpSql .= ", m$i.object as ".$dataName[$qname];
|
||||
//}
|
||||
$i++;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -54,6 +54,21 @@ echo " * Adding 'jobpid' to ".$CC_CONFIG['transTable']."...";
|
|||
$sql = "ALTER TABLE ".$CC_CONFIG['transTable']." ADD COLUMN jobpid int";
|
||||
camp_install_query($sql);
|
||||
|
||||
echo " * Fixing track numbers...\n";
|
||||
$sql = "SELECT id, object as track_num FROM ".$CC_CONFIG['mdataTable']
|
||||
." WHERE predns='ls' AND predicate='track_num'";
|
||||
$rows = $CC_DBC->GetAll($sql);
|
||||
foreach ($rows as $row) {
|
||||
$newTrackNum = camp_parse_track_number($row["track_num"]);
|
||||
if ($row["track_num"] != $newTrackNum) {
|
||||
echo " * Converting '".$row["track_num"]."' --> '$newTrackNum'\n";
|
||||
$sql = "UPDATE ".$CC_CONFIG["mdataTable"]
|
||||
." SET object='$newTrackNum'"
|
||||
." WHERE id=".$row["id"];
|
||||
$CC_DBC->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
// Get MD5 values for all files
|
||||
echo " * Computing MD5 sums for all files (this may take a while)...\n";
|
||||
$sql = "SELECT to_hex(gunid) as gunid, name FROM ".$CC_CONFIG['filesTable'] ." WHERE ftype='audioclip'";
|
||||
|
|
Loading…
Reference in New Issue