forum.coppermine-gallery.net

Support => cpg1.4.x Support => Older/other versions => cpg1.4 cpmFetch by vuud => Topic started by: Texas Kelly on February 02, 2008, 08:30:33 pm

Title: Display Thumbnails by Filename
Post by: Texas Kelly on February 02, 2008, 08:30:33 pm
Background: I'm the technical administrator for a Survivor fansite. We're in the business of spoiler analysis from vidcaps of episodes, previews, and the like. I set up a Coppermine gallery to facilitate the uploading and organization of our vidcaps. With a lot of work and elbow-grease, I've also managed to use cpmFetch to allow our users to post thumbnails from Coppermine in posts on our vBulletin forums, using a BBCode. (Not ready to go public with that one yet, because I'm still testing/refining it, but it works wonderfully.)

Problem: When my users post vidcaps, there's a specific order to them (based on the order they appear in the source material that they come from). Neither of the methods of pulling thumbnails in cpmFetch (random, last uploaded) is all that conducive to getting the thumbnails to display in the order we'd like them to. I'm telling my users to upload in reverse order with a cockamamie methodology, and I want to make it easier for them.

Is there a way in the current version of cpmFetch to get the thumbnails to display in an order based on filename? (For example, if the pictures in an album were named Cap001, Cap004, Cap003, Cap007, Cap002, etc.; cpmFetch would display the thumbnails in order: Cap001, Cap002, Cap003, Cap004, etc.) If there isn't a way, currently, how difficult would it be to add a function like cpm_viewMediaFromByFilename()?

I've scoured the documentation and searched these forums fruitlessly. Please help!

Using: I'm using the current stable version of cpmFetch (2.0.0) and version 1.4.15 of Coppermine. (I'm using GD for thumbnails, so no need to upgrade to 1.4.16.)
Title: Re: Display Thumbnails by Filename
Post by: Nibbler on February 02, 2008, 10:26:59 pm
Should be easy enough. Take this one as an example:

Code: [Select]
function cpm_viewTopRatedMediaFrom ($source, $rows, $columns, $options="") {
$this->loadOptions($options);

$resultset = $this->getTopRatedMediaFrom ($source, $rows * $columns);
$this->addDescriptionsToResultSet($resultset);

$retval = "";
switch ($this->returntype) {
case ('resultset'):
$retval = $resultset;
break;
case ('html'):
$retval = $this->createTable($resultset,$rows,$columns);
break;
case ('print'):
default:
print $this->createTable($resultset,$rows,$columns);
}

$this->clearOptions();
return ($retval);

}

copy it, rename the copy, then do likewise for the function it calls

Code: [Select]
function getTopRatedMediaFrom ($source, $count = 1) {
$resultset = array();
if (is_numeric($count)) {

$sourceSql = $this->makeSourceSql($source);

if ($sourceSql != "") $sourceSql = " AND " . $sourceSql;

$sqlcode = "SELECT {$this->sqlPostSelect} " . $this->sqlSelect . " FROM "
. $this->sqlTableSelect
. " WHERE 1 "
. $this->sqlUserDataLink
. $this->filetypefilter ." AND p.approved='YES' "
. $sourceSql . " {$this->privacyfilter} "
. " ORDER BY p.pic_rating DESC LIMIT 0,$count";

$resultset = $this->dbExecuteSql($sqlcode);
$this->addPathInfo($resultset);
}
elseif ($this->cfg['cfDebugMode'] == 'true'){
debugPrint("Non numeric count submitted");
}

return ($resultset);
}

Change the 'order by' to be by filename ascending instead of rating descending.

I don't have cpmfetch installed so I can't give you copy/paste code.
Title: Re: Display Thumbnails by Filename
Post by: Texas Kelly on February 02, 2008, 11:07:55 pm
That's what I tried before I posted, and it didn't work... but when I tried it again with the code snippets you provided, it worked fine! Puzzling... ???

Anyways, thanks for your help! :)
Title: Re: Display Thumbnails by Filename
Post by: Texas Kelly on February 02, 2008, 11:11:46 pm
Here's the snippets of code I used if anyone else wants to do this:

Paste this into cpmfetch.php after function cpm_viewRandomMediaFrom
Code: [Select]
function cpm_viewMediaFromByFilename ($source, $rows, $columns, $options="") {
$this->loadOptions($options);

$resultset = $this->getMediaFromByFilename ($source, $rows * $columns);
$this->addDescriptionsToResultSet($resultset);

$retval = "";
switch ($this->returntype) {
case ('resultset'):
$retval = $resultset;
break;
case ('html'):
$retval = $this->createTable($resultset,$rows,$columns);
break;
case ('print'):
default:
print $this->createTable($resultset,$rows,$columns);
}

$this->clearOptions();
return ($retval);

}

Paste this into cpmfetch_dao.php after function getMediaAddedSince
Code: [Select]
function getMediaFromByFilename ($source, $count = 1) {
$resultset = array();
if (is_numeric($count)) {

$sourceSql = $this->makeSourceSql($source);

if ($sourceSql != "") $sourceSql = " AND " . $sourceSql;

$sqlcode = "SELECT {$this->sqlPostSelect} " . $this->sqlSelect . " FROM "
. $this->sqlTableSelect
. " WHERE 1 "
. $this->sqlUserDataLink
. $this->filetypefilter ." AND p.approved='YES' "
. $sourceSql . " {$this->privacyfilter} "
. " ORDER BY p.filename ASC LIMIT 0,$count";

$resultset = $this->dbExecuteSql($sqlcode);
$this->addPathInfo($resultset);
}
elseif ($this->cfg['cfDebugMode'] == 'true'){
debugPrint("Non numeric count submitted");
}

return ($resultset);
}
Title: Re: Display Thumbnails by Filename
Post by: Nibbler on February 02, 2008, 11:20:56 pm
Great. Thanks for posting your final code.