aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio <silvio@socioambiental.org>2013-11-19 15:53:48 -0200
committerSilvio <silvio@socioambiental.org>2013-11-19 15:53:48 -0200
commit7f98f5dca52386fec9c129071bb46591acb46da1 (patch)
tree02b1a635f626267144c425972bb98bdfa2b0b2b2
parent85a52429aebe041a135e4cad9bc02a4b80c0a1b1 (diff)
downloadjquery_drawer-7f98f5dca52386fec9c129071bb46591acb46da1.tar.gz
jquery_drawer-7f98f5dca52386fec9c129071bb46591acb46da1.tar.bz2
Split themeable output from logic
-rw-r--r--jquery_drawer.module66
1 files changed, 35 insertions, 31 deletions
diff --git a/jquery_drawer.module b/jquery_drawer.module
index a54679d..7283fcd 100644
--- a/jquery_drawer.module
+++ b/jquery_drawer.module
@@ -144,26 +144,9 @@ function theme_jquery_drawer($menu) {
}
/**
- * Menu callback.
- *
- * @todo Split themeable output from logic.
+ * Render all nodes whose terms are children of $tid.
*/
-function jquery_drawer_page($tid = NULL) {
- $output = '';
- $nodes = taxonomy_select_nodes(array($tid));
- $base = variable_get('jquery_drawer_link', 'node');
- $output .= '<ul id="drw_item" class="hidden">';
-
- // First render all nodes whose parent is $term
- while ($node = db_fetch_object($nodes)) {
- path_nodeapi($node,'load','');
- $link['title'] = $node->title;
- $link['href'] = ($node->path?$node->path:"$base/". $node->nid);
- //$output .= print_r($node,1);
- $output .= theme('jquery_drawer_link', $link);
- }
-
- // Check for child terms
+function jquery_drawer_get_children($tid = NULL) {
$vid = variable_get('jquery_drawer', '1');
$terms = taxonomy_node_tree_taxonomy_get_tree($vid, $tid);
@@ -181,20 +164,41 @@ function jquery_drawer_page($tid = NULL) {
{term_node} ON term_node.nid = n.nid WHERE term_node.tid IN (%s)
AND n.status = "1" ORDER BY term_node.weight_in_tid ASC';
- $query2 = db_rewrite_sql($query);
- $nodes = db_query(db_rewrite_sql($query), implode(',', $filter));
- $tree = taxonomy_node_tree_build($nodes, $terms);
-
- // Format output
- if (is_array($tree) && !empty($tree)) {
- foreach ($tree as $term) {
- $output .= taxonomy_node_tree_list($term, 'jquery_drawer', 'hidden', $base);
- }
- }
- else {
- $output .= t('No content exists for this topic yet.');
+ //$query = db_rewrite_sql($query);
+ $nodes = db_query(db_rewrite_sql($query), implode(',', $filter));
+ $tree = taxonomy_node_tree_build($nodes, $terms);
+
+ return $tree;
+ }
+}
+
+/**
+ * Menu callback.
+ */
+function jquery_drawer_page($tid = NULL) {
+ $output = '';
+ $nodes = taxonomy_select_nodes(array($tid));
+ $base = variable_get('jquery_drawer_link', 'node');
+ $tree = jquery_drawer_get_children($tid);
+ $output .= '<ul id="drw_item" class="hidden">';
+
+ // First render all nodes whose parent is $term
+ while ($node = db_fetch_object($nodes)) {
+ path_nodeapi($node,'load','');
+ $link['title'] = $node->title;
+ $link['href'] = ($node->path?$node->path:"$base/". $node->nid);
+ $output .= theme('jquery_drawer_link', $link);
+ }
+
+ // Add other nodes
+ if (is_array($tree) && !empty($tree)) {
+ foreach ($tree as $term) {
+ $output .= taxonomy_node_tree_list($term, 'jquery_drawer', 'hidden', $base);
}
}
+ else {
+ $output .= t('No content exists for this topic yet.');
+ }
$output .= '</ul></li>';