Term pages, taxonomy widget supports files #4346

Settings up os_taxonomy to show entities instead of just nodes was no problem.  Nor was using field_data_og_vocabulary isntead of taxonomy_index.

The difficulty came in the sort queries.  It was sorting by node.sticky and node.created, neither of which exist in file_managed.  I had to do a leftJoin on file_managed and node.  Later we add an expression that does a sql IF() to choose node.created or file_managed.timestamp depending on ogv's entity_type.  That result is called entity_date and we sort by that.

But entity_date isn't indexed so it'll be slow.  We shouldn't run it for all those taxonomies that can't have files.

I added a function that looks at the bundles we're using and figures out the entities that are active.  If only one is active it sorts by the appropriate creation date column.  If both are active, then do the collation.

But some taxonomy widgets never specify bundles.  If they don't specify bundles, we can't know which entities are active.

For this case I checked the bundles associated with the vocab we're looking at.  Vocabs already in the system will have only nodes as their bundles.  So until someone goes in and makes a vocab of files and bundles, they'll get the speedy version they're used to.
Merge branch 'SCHOLAR-3.x' of github.com:openscholar/openscholar into SCHOLAR-3.x