function media_gallery_select_galleries in Media Gallery 7.2
Same name and namespace in other branches
- 7 media_gallery.module \media_gallery_select_galleries()
Media gallery equivalent to taxonomy_select_nodes().
1 call to media_gallery_select_galleries()
- media_gallery_list_galleries in ./
media_gallery.pages.inc - Page callback to list all galleries.
File
- ./
media_gallery.module, line 1325
Code
function media_gallery_select_galleries($tid, $pager = TRUE, $limit = FALSE) {
if (!variable_get('taxonomy_maintain_index_table', TRUE)) {
return array();
}
$query = db_select('taxonomy_index', 't');
$query
->leftJoin('media_gallery_weight', 'mgw', 'mgw.nid = t.nid AND mgw.tid = :tid', array(
':tid' => $tid,
));
$query
->addTag('node_access');
$query
->condition('t.tid', $tid);
if ($pager) {
$count_query = clone $query;
$count_query
->addExpression('COUNT(t.nid)');
$query = $query
->extend('PagerDefault');
if ($limit !== FALSE) {
$query = $query
->limit($limit);
}
$query
->setCountQuery($count_query);
}
else {
if ($limit !== FALSE) {
$query
->range(0, $limit);
}
}
$query
->addField('t', 'nid');
$query
->addField('t', 'tid');
$query
->addField('mgw', 'weight');
$query
->orderBy('mgw.weight', 'ASC');
$query
->orderBy('t.nid', 'ASC');
$result = $query
->execute();
return $result
->fetchCol();
}