coppermine-gallery.com/forum

Support => cpg1.4.x Support => Older/other versions => cpg1.4 cpmFetch by vuud => Topic started by: radmofo on April 18, 2008, 05:38:21 AM

Title: Searching Filenames
Post by: radmofo on April 18, 2008, 05:38:21 AM
Ok, so I know we can do things like this 


$searchword = "whatever";

$objCpm->cpm_viewRandomMediaFrom("cat=:album=:text=$searchword", 1, 4, $options);


to get image results using keywords, title etc which is cool. But it doesn't work with Filenames, I've dug into a few files but don't see anything jumping out at me saying "change me" can I get a nudge in the proper direction?

I know you can direct link to search results like this  thumbnails.php?album=search&search=findthisword

I've messed with this line from search.inc.php a tad thinking maybe it prioritized in order...it don't.

$USER['search']['params']['title'] = $USER['search']['params']['caption'] = $USER['search']['params']['keywords'] = $USER['search']['params']['filename'] = 1;

Someone please point in the proper direction.
Title: Re: Searching Filenames
Post by: vuud on April 18, 2008, 06:01:29 AM

You would need to mess with the cpmfetch_dao's makeSourceSql code to include a new flag to generate the SQL code to check filesnames.

Hope that helps
Title: Re: Searching Filenames
Post by: radmofo on April 18, 2008, 03:38:24 PM
That was to easy.

Here's what I did

In cpmfetch_dao.php find:
if (sizeof($textlist)) {
foreach ($textlist as $keyword) {
$sourceSql .= " p.keywords LIKE '%" . mysql_escape_string($keyword) . "%' OR ";
$sourceSql .= " p.title LIKE '%" . mysql_escape_string($keyword) . "%' OR ";
$sourceSql .= " p.caption LIKE '%" . mysql_escape_string($keyword) . "%' OR ";


Add after:
$sourceSql .= " p.filename Like '%" . mysql_escape_string($keyword) . "%' OR ";