function _glossary_get_terms in Glossary 5
Same name and namespace in other branches
- 5.2 glossary.module \_glossary_get_terms()
- 6 glossary.module \_glossary_get_terms()
- 7 glossary.module \_glossary_get_terms()
1 call to _glossary_get_terms()
File
- ./
glossary.module, line 730
Code
function _glossary_get_terms($format) {
static $terms = false;
$show_all = variable_get('glossary_allow_no_description', false);
if ($terms === false) {
$terms = $synonyms = array();
$vids = variable_get("glossary_vids_{$format}", 0);
foreach ($vids as $vid) {
// $vocab = taxonomy_get_vocabulary($vid);
$synonyms = _glossary_get_synonyms($vid);
// Get all glossary terms and attach synonyms.
// Omit terms without a description. those are usually container terms.
$result = db_query("SELECT t.name, t.description, t.tid, COUNT(tn.nid) as nodes FROM {term_data} t LEFT JOIN {term_node} tn USING(tid) WHERE t.vid=%d GROUP BY t.tid, t.name, t.description ORDER BY LENGTH(t.name) DESC", $vid);
while ($term = db_fetch_object($result)) {
if ($term->nodes) {
// If there were any nodes attached, we need to see if they were unpublished.
$unpubs = db_result(db_query("SELECT COUNT(n.nid) FROM {term_node} t JOIN {node} n USING (nid) WHERE t.tid=%d AND n.status=0", $term->tid));
$term->nodes -= $unpubs;
}
if ($term->description || $show_all) {
$term->synonyms = $synonyms[$term->tid];
$term->synonyms[] = $term->name;
$term->vid = $vid;
$terms[] = $term;
}
}
}
}
return $terms;
}