| 1 |
<?php |
<?php |
| 2 |
// $Id: taxonomy_theme_taxonomy.inc,v 1.3 2006/10/10 20:48:34 profix898 Exp $ |
// $Id: taxonomy_theme_taxonomy.inc,v 1.4 2006/10/18 10:01:56 profix898 Exp $ |
| 3 |
|
|
| 4 |
define('TAXOTHEME_SKIP', 0); |
define('TAXOTHEME_SKIP', 0); |
| 5 |
define('TAXOTHEME_TERM', 1); |
define('TAXOTHEME_TERM', 1); |
| 45 |
*/ |
*/ |
| 46 |
function _taxonomy_theme_select_term(&$theme_method, &$custom_theme, $default_theme, $uri) { |
function _taxonomy_theme_select_term(&$theme_method, &$custom_theme, $default_theme, $uri) { |
| 47 |
$selector_vid = variable_get('taxonomy_theme_selector', ''); |
$selector_vid = variable_get('taxonomy_theme_selector', ''); |
| 48 |
if ((arg(0) == 'node') && is_numeric(arg(1))) { |
if ((arg(0) == 'node') && is_numeric($nid = arg(1))) { |
|
$nid = arg(1); |
|
| 49 |
$terms = taxonomy_node_get_terms_by_vocabulary($nid, $selector_vid); |
$terms = taxonomy_node_get_terms_by_vocabulary($nid, $selector_vid); |
| 50 |
if ($terms) { |
if ($terms) { |
| 51 |
$term = current($terms); |
$term = current($terms); |
| 56 |
$custom_theme = variable_get('taxonomy_theme_forum|'.$term->tid, $default_theme); |
$custom_theme = variable_get('taxonomy_theme_forum|'.$term->tid, $default_theme); |
| 57 |
} |
} |
| 58 |
} |
} |
| 59 |
else if ((arg(0) == 'taxonomy_menu') && is_numeric(arg(1)) && arg(2)) { |
else if ((arg(0) == 'taxonomy_menu') && is_numeric($vid = arg(1)) && arg(2)) { |
|
$vid = arg(1); |
|
| 60 |
$tid = basename($uri); |
$tid = basename($uri); |
| 61 |
if ($theme_forums && ($vid == $forum_vid)) { |
if ($theme_forums && ($vid == $forum_vid)) { |
| 62 |
$custom_theme = variable_get('taxonomy_theme_forum|'.$tid, $default_theme); |
$custom_theme = variable_get('taxonomy_theme_forum|'.$tid, $default_theme); |
| 66 |
} |
} |
| 67 |
} |
} |
| 68 |
else if ((arg(0) == 'taxonomy') && (arg(1) == 'term')) { |
else if ((arg(0) == 'taxonomy') && (arg(1) == 'term')) { |
| 69 |
if (is_numeric(arg(2))) { |
if (is_numeric($tid = arg(2))) { |
|
$tid = arg(2); |
|
| 70 |
$tobj = taxonomy_get_term($tid); |
$tobj = taxonomy_get_term($tid); |
| 71 |
if ($tobj->vid == $selector_vid) { |
if ($tobj->vid == $selector_vid) { |
| 72 |
$custom_theme = variable_get('taxonomy_theme_term|'.$tid, $default_theme); |
$custom_theme = variable_get('taxonomy_theme_term|'.$tid, $default_theme); |
| 76 |
} |
} |
| 77 |
} |
} |
| 78 |
} |
} |
| 79 |
else if ((arg(0) == 'forum') && is_numeric(arg(1)) && $theme_forums) { |
else if ((arg(0) == 'forum') && is_numeric($tid = arg(1)) && $theme_forums) { |
|
$tid = arg(1); |
|
| 80 |
$custom_theme = variable_get('taxonomy_theme_forum|'.$tid, $default_theme); |
$custom_theme = variable_get('taxonomy_theme_forum|'.$tid, $default_theme); |
| 81 |
} |
} |
| 82 |
} |
} |
| 86 |
* (vocabulary-based theme selection) |
* (vocabulary-based theme selection) |
| 87 |
*/ |
*/ |
| 88 |
function _taxonomy_theme_select_vocabulary(&$theme_method, &$custom_theme, $default_theme, $uri) { |
function _taxonomy_theme_select_vocabulary(&$theme_method, &$custom_theme, $default_theme, $uri) { |
| 89 |
if ((arg(0) == 'node') && is_numeric(arg(1))) { |
if (((arg(0) == 'node') && is_numeric($nid = arg(1))) || ((arg(0) == 'comment') && (arg(1) == 'reply') && ($nid = arg(2)))) { |
|
$nid = arg(1); |
|
| 90 |
$terms = taxonomy_node_get_terms($nid); |
$terms = taxonomy_node_get_terms($nid); |
| 91 |
$term = current($terms); |
$term = current($terms); |
| 92 |
$vid = $term->vid; |
$vid = $term->vid; |
| 96 |
$custom_theme = variable_get('taxonomy_theme_forum|'.$term->tid, $default_theme); |
$custom_theme = variable_get('taxonomy_theme_forum|'.$term->tid, $default_theme); |
| 97 |
} |
} |
| 98 |
} |
} |
| 99 |
else if ((arg(0) == 'taxonomy_menu') && is_numeric(arg(1))) { |
else if ((arg(0) == 'taxonomy_menu') && is_numeric($vid = arg(1))) { |
|
$vid = arg(1); |
|
| 100 |
if ($theme_forums && ($vid == $forum_vid) && arg(2)) { |
if ($theme_forums && ($vid == $forum_vid) && arg(2)) { |
| 101 |
$tid = basename($uri); |
$tid = basename($uri); |
| 102 |
$custom_theme = variable_get('taxonomy_theme_forum|'.$tid, $default_theme); |
$custom_theme = variable_get('taxonomy_theme_forum|'.$tid, $default_theme); |
| 106 |
} |
} |
| 107 |
} |
} |
| 108 |
else if ((arg(0) == 'taxonomy')) { |
else if ((arg(0) == 'taxonomy')) { |
| 109 |
if (is_numeric(arg(2))) { |
if (is_numeric($tid = arg(2))) { |
|
$tid = arg(2); |
|
| 110 |
$tobj = taxonomy_get_term($tid); |
$tobj = taxonomy_get_term($tid); |
| 111 |
$vid = $tobj->vid; |
$vid = $tobj->vid; |
| 112 |
if ($theme_forums && ($vid == $forum_vid)) { |
if ($theme_forums && ($vid == $forum_vid)) { |
| 117 |
} |
} |
| 118 |
} |
} |
| 119 |
} |
} |
| 120 |
else if ((arg(0) == 'forum') && is_numeric(arg(1)) && $theme_forums) { |
else if ((arg(0) == 'forum') && is_numeric($tid = arg(1)) && $theme_forums) { |
|
$tid = arg(1); |
|
| 121 |
$custom_theme = variable_get('taxonomy_theme_forum|'.$tid, $default_theme); |
$custom_theme = variable_get('taxonomy_theme_forum|'.$tid, $default_theme); |
| 122 |
} |
} |
| 123 |
} |
} |
| 127 |
* (all-taxonomy theme selection = term-based + vocab-based) |
* (all-taxonomy theme selection = term-based + vocab-based) |
| 128 |
*/ |
*/ |
| 129 |
function _taxonomy_theme_select_alltaxonomy(&$theme_method, &$custom_theme, $default_theme, $uri) { |
function _taxonomy_theme_select_alltaxonomy(&$theme_method, &$custom_theme, $default_theme, $uri) { |
| 130 |
if ((arg(0) == 'node') && is_numeric(arg(1))) { |
if (((arg(0) == 'node') && is_numeric($nid = arg(1))) || ((arg(0) == 'comment') && (arg(1) == 'reply') && ($nid = arg(2)))) { |
|
$nid = arg(1); |
|
| 131 |
$terms = taxonomy_node_get_terms($nid); |
$terms = taxonomy_node_get_terms($nid); |
| 132 |
$term = current($terms); |
$term = current($terms); |
| 133 |
$vid = $term->vid; |
$vid = $term->vid; |
| 137 |
$custom_theme = variable_get('taxonomy_theme_forum|'.$term->tid, $default_theme); |
$custom_theme = variable_get('taxonomy_theme_forum|'.$term->tid, $default_theme); |
| 138 |
} |
} |
| 139 |
} |
} |
| 140 |
else if ((arg(0) == 'taxonomy_menu') && is_numeric(arg(1)) && arg(2)) { |
else if ((arg(0) == 'taxonomy_menu') && is_numeric($vid = arg(1)) && arg(2)) { |
|
$vid = arg(1); |
|
| 141 |
$tid = basename($uri); |
$tid = basename($uri); |
| 142 |
if ($theme_forums && ($vid == $forum_vid)) { |
if ($theme_forums && ($vid == $forum_vid)) { |
| 143 |
$custom_theme = variable_get('taxonomy_theme_forum|'.$tid, $default_theme); |
$custom_theme = variable_get('taxonomy_theme_forum|'.$tid, $default_theme); |
| 147 |
} |
} |
| 148 |
} |
} |
| 149 |
else if ((arg(0) == 'taxonomy')) { |
else if ((arg(0) == 'taxonomy')) { |
| 150 |
if (is_numeric(arg(2))) { |
if (is_numeric($tid = arg(2))) { |
|
$tid = arg(2); |
|
| 151 |
$tobj = taxonomy_get_term($tid); |
$tobj = taxonomy_get_term($tid); |
| 152 |
$custom_theme = variable_get('taxonomy_theme_all|'.$tid, $default_theme); |
$custom_theme = variable_get('taxonomy_theme_all|'.$tid, $default_theme); |
| 153 |
if ($tobj->vid == $forum_vid) { |
if ($tobj->vid == $forum_vid) { |
| 155 |
} |
} |
| 156 |
} |
} |
| 157 |
} |
} |
| 158 |
else if ((arg(0) == 'forum') && is_numeric(arg(1)) && $theme_forums) { |
else if ((arg(0) == 'forum') && is_numeric($tid = arg(1)) && $theme_forums) { |
|
$tid = arg(1); |
|
| 159 |
$custom_theme = variable_get('taxonomy_theme_forum|'.$tid, $default_theme); |
$custom_theme = variable_get('taxonomy_theme_forum|'.$tid, $default_theme); |
| 160 |
} |
} |
| 161 |
} |
} |
| 165 |
* (nodetype-based theme selection) |
* (nodetype-based theme selection) |
| 166 |
*/ |
*/ |
| 167 |
function _taxonomy_theme_select_nodetype(&$theme_method, &$custom_theme, $default_theme, $uri) { |
function _taxonomy_theme_select_nodetype(&$theme_method, &$custom_theme, $default_theme, $uri) { |
| 168 |
if ((arg(0) == 'node') && is_numeric(arg(1))) { |
if (((arg(0) == 'node') && is_numeric($nid = arg(1))) || ((arg(0) == 'comment') && (arg(1) == 'reply') && ($nid = arg(2)))) { |
|
$nid = arg(1); |
|
| 169 |
$nodetype = db_fetch_object(db_query('SELECT type FROM {node} WHERE nid = %d', $nid)); |
$nodetype = db_fetch_object(db_query('SELECT type FROM {node} WHERE nid = %d', $nid)); |
| 170 |
if ($nodetype->type) { |
if ($nodetype->type) { |
| 171 |
$custom_theme = variable_get('taxonomy_theme_nodetype|'.$nodetype->type, $default_theme); |
$custom_theme = variable_get('taxonomy_theme_nodetype|'.$nodetype->type, $default_theme); |
| 175 |
} |
} |
| 176 |
} |
} |
| 177 |
} |
} |
| 178 |
else if ((arg(0) == 'forum') && is_numeric(arg(1)) && $theme_forums) { |
else if ((arg(0) == 'forum') && is_numeric($tid = arg(1)) && $theme_forums) { |
|
$tid = arg(1); |
|
| 179 |
$custom_theme = variable_get('taxonomy_theme_forum|'.$tid, $default_theme); |
$custom_theme = variable_get('taxonomy_theme_forum|'.$tid, $default_theme); |
| 180 |
} |
} |
| 181 |
} |
} |