Closed (fixed)
Project:
Creative Commons
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
29 Dec 2009 at 02:58 UTC
Updated:
21 Jan 2010 at 06:50 UTC
Jump to comment: Most recent file
Comments
Comment #1
darrick commentedComment #2
balleyne commentedThanks! Applied the patch, just committed.
Comment #3
darrick commentedCool. Thanks. I did just notice today a slight error in the patch. At the last minute I changed the class name creativecommons_views_handler_filter_license to creativecommons_views_handler_filter_license_uri to make the naming all nice and proper. However, I didn't test it. This new attached patch fixes the error.
Comment #4
balleyne commentedAh, thanks.
On further review though, I'm wondering if you know how we could filter by license type rather than license uri. The current filter doesn't work across jurisdictions or license versions. I'm not very familiar with the Views API, which is why I hadn't added this filter before (thanks for your help!), but I'm not sure how to go about making the change.
The problem: I can filter by BY-SA 3.0 Unported, which adds this to the query: (creativecommons_node.license_uri in ('http://creativecommons.org/licenses/by-sa/3.0/')) -- but that won't match against my content that's licensed BY-SA 2.5 Canada, or when 3.5/4.0 comes out, it will only match one particular version of the license. (I have made another adjustment to your code so that it loads the default jurisdiction for the filter value options properly.)
There are a couple functions in the module which might be useful...
* creativecommons_get_license_type_from_uri($uri)
* creativecommons_generic_license_name($full_name)
Those functions can easily be used to make the value options generic license types rather than specific license names and URIs. It's easy enough to change the value options, but I don't know how to change the way that the filter determines matches... I think it needs to do something like in line 1943 of the main module file, that is, the resulting SQL should be something along the lines of "WHERE license_uri LIKE 'http://creativecommons.org/%/%s/%" with the license type as %s.
Do you know how to do this? I imagine it could be done by either customizing the license_uri filter in some way to make a more sophisticated match, or by creating a license type field and performing a filter on that? I'd be happy to do the work, just not quite sure how to do it... any ideas?
For now, I've applied your fix and my jurisdiction change. A filter on license URIs is still a nice step in the right direction.
Comment #5
darrick commentedOkay. Try this out.
Comment #6
balleyne commentedWow, thanks. Applied the patch, with a couple minor modifications -- that's exactly what I was trying to do! Much appreciated.