| 1 |
<?php |
<?php |
| 2 |
// $Id: taxonomy_dss.module,v 1.26 2008/01/09 18:25:08 moonray Exp $ |
// $Id: taxonomy_dss.module,v 1.26.2.1 2008/01/16 21:34:49 moonray Exp $ |
| 3 |
|
|
| 4 |
/* Required patch to core (can we find a module specific workaround?): |
/* Required patch to core (can we find a module specific workaround?): |
| 5 |
|
|
| 55 |
*/ |
*/ |
| 56 |
|
|
| 57 |
/** |
/** |
| 58 |
|
* Implementation of hook_node_info(). |
| 59 |
|
*/ |
| 60 |
|
function taxonomy_dss_node_info() { |
| 61 |
|
return array( |
| 62 |
|
'termset' => array( |
| 63 |
|
'name' => t('Termset'), |
| 64 |
|
'module' => 'taxonomy_dss', |
| 65 |
|
'description' => t('Special pages for taxonomy terms. Used by Taxonomy DSS module.'), |
| 66 |
|
'has_title' => FALSE, |
| 67 |
|
'locked' => TRUE, |
| 68 |
|
) |
| 69 |
|
); |
| 70 |
|
} |
| 71 |
|
|
| 72 |
|
/** |
| 73 |
|
* Implementation of hook_perm(). |
| 74 |
|
*/ |
| 75 |
|
function taxonomy_dss_perm() { |
| 76 |
|
return array('create termset', 'edit termset'); |
| 77 |
|
} |
| 78 |
|
|
| 79 |
|
/** |
| 80 |
|
* Implementation of hook_access(). |
| 81 |
|
*/ |
| 82 |
|
function taxonomy_dss_access($op, $node) { |
| 83 |
|
if ($op == 'create') { |
| 84 |
|
return user_access('create termset'); |
| 85 |
|
} |
| 86 |
|
|
| 87 |
|
if ($op == 'update' || $op == 'delete') { |
| 88 |
|
return user_access('edit termset'); |
| 89 |
|
} |
| 90 |
|
} |
| 91 |
|
|
| 92 |
|
/** |
| 93 |
* Implementation of hook_menu(). |
* Implementation of hook_menu(). |
| 94 |
*/ |
*/ |
| 95 |
function taxonomy_dss_menu($may_cache) { |
function taxonomy_dss_menu($may_cache) { |
| 96 |
|
global $user; |
| 97 |
$items = array(); |
$items = array(); |
| 98 |
|
|
| 99 |
if (!$may_cache) { |
if ($may_cache) { |
| 100 |
|
$items[] = array( |
| 101 |
|
'path' => 'node/add/termset', |
| 102 |
|
'title' => t('Termset'), |
| 103 |
|
'access' => user_access('create termset'), |
| 104 |
|
); |
| 105 |
|
} |
| 106 |
|
else { |
| 107 |
$items[] = array( |
$items[] = array( |
| 108 |
'path' => 'admin/content/taxonomy/settings', |
'path' => 'admin/content/taxonomy/settings', |
| 109 |
'title' => t('Settings'), |
'title' => t('Settings'), |
| 135 |
'type' => MENU_DEFAULT_LOCAL_TASK, |
'type' => MENU_DEFAULT_LOCAL_TASK, |
| 136 |
'weight' => -10, |
'weight' => -10, |
| 137 |
); |
); |
| 138 |
if ($node) { |
if (!$node) { |
|
$items[] = array( |
|
|
'path' => 'taxonomy/term/'. arg(2) .'/outline', |
|
|
'title' => t('Outline'), |
|
|
'callback' => 'drupal_get_form', |
|
|
'callback arguments' => array('book_outline', $node->nid), |
|
|
'access' => user_access('outline posts in books'), |
|
|
'type' => MENU_LOCAL_TASK, |
|
|
'weight' => 2 |
|
|
); |
|
|
$items[] = array( |
|
|
'path' => 'taxonomy/term/'. arg(2) .'/edit', |
|
|
'title' => t('Edit'), |
|
|
'callback' => 'taxonomy_dss_page_edit', |
|
|
'callback arguments' => array(arg(2), $node), |
|
|
'access' => node_access('update', $node), |
|
|
'weight' => 1, |
|
|
'type' => MENU_LOCAL_TASK, |
|
|
); |
|
| 139 |
$items[] = array( |
$items[] = array( |
| 140 |
'path' => 'taxonomy/term/'. arg(2) .'/add', |
'path' => 'taxonomy/term/'. arg(2) .'/add', |
| 141 |
'title' => t('Edit'), |
'title' => t('Edit'), |
| 142 |
'callback' => 'taxonomy_dss_not_available', |
'callback' => 'drupal_goto', |
| 143 |
'access' => node_access('update', $node), |
'callback arguments' => array('node/add/termset', 'tids='. arg(2)), |
| 144 |
'weight' => 1, |
'access' => node_access('create', 'termset'), |
|
'type' => MENU_CALLBACK, |
|
|
); |
|
|
$items[] = array( |
|
|
'path' => 'taxonomy/term/'. arg(2) .'/delete', |
|
|
'title' => t('Delete'), |
|
|
'callback' => 'drupal_get_form', |
|
|
'callback arguments' => array('node_delete_confirm', $node), |
|
|
'access' => node_access('delete', $node), |
|
|
'weight' => 1, |
|
|
'type' => MENU_CALLBACK, |
|
|
); |
|
|
} |
|
|
else { |
|
|
$items[] = array( |
|
|
'path' => 'taxonomy/term/'. arg(2) .'/add', |
|
|
'title' => t('Edit'), |
|
|
'callback' => 'taxonomy_dss_page_add', |
|
|
'callback arguments' => array(arg(2)), |
|
|
'access' => node_access('create', 'term'), |
|
| 145 |
'weight' => 1, |
'weight' => 1, |
| 146 |
'type' => MENU_LOCAL_TASK, |
'type' => MENU_LOCAL_TASK, |
| 147 |
); |
); |
|
$items[] = array( |
|
|
'path' => 'taxonomy/term/'. arg(2) .'/edit', |
|
|
'title' => t('Edit'), |
|
|
'callback' => 'taxonomy_dss_not_available', |
|
|
'access' => node_access('create', 'term'), |
|
|
'weight' => 1, |
|
|
'type' => MENU_CALLBACK, |
|
|
); |
|
| 148 |
} |
} |
| 149 |
} |
} |
| 150 |
} |
} |
| 207 |
} |
} |
| 208 |
|
|
| 209 |
/** |
/** |
| 210 |
* Menu callback; presents the editing form associated with this set of terms, |
* Implementation of hook_validate(). |
|
* or redirects to delete confirmation. |
|
| 211 |
*/ |
*/ |
| 212 |
function taxonomy_dss_page_edit($tid, $node) { |
function taxonomy_dss_validate(&$node) { |
| 213 |
if ($_POST['op'] == t('Delete')) { |
if (empty($node->termset['tids'])) { |
| 214 |
// Note: we redirect from taxonomy/term/tid/edit to taxonomy/term/tid/delete to make the tabs disappear. |
form_set_error('tids', t('This termset needs to be associated with a set of taxonomy terms.')); |
| 215 |
if ($_REQUEST['destination']) { |
} |
| 216 |
$destination = drupal_get_destination(); |
} |
| 217 |
unset($_REQUEST['destination']); |
|
| 218 |
|
/** |
| 219 |
|
* Implementation of hook_submit(). |
| 220 |
|
*/ |
| 221 |
|
function taxonomy_dss_submit(&$node) { |
| 222 |
|
global $locale; |
| 223 |
|
|
| 224 |
|
// Make sure termset is an object |
| 225 |
|
if (!is_object($node->termset)) { |
| 226 |
|
$node->termset = (object) $node->termset; |
| 227 |
|
} |
| 228 |
|
|
| 229 |
|
// Set proper path alias |
| 230 |
|
if (module_exists('i18n')) { |
| 231 |
|
if ($node->language == i18n_default_language()) { |
| 232 |
|
$node->path = 'taxonomy/term/'. $node->termset->tids; |
| 233 |
|
} |
| 234 |
|
else { |
| 235 |
|
$node->path = $node->language .'/taxonomy/term/'. $node->termset->tids; |
| 236 |
} |
} |
| 237 |
drupal_goto('taxonomy/term/'. $tid .'/delete', $destination); |
} |
| 238 |
|
else { |
| 239 |
|
$node->path = 'taxonomy/term/'. $node->termset->tids; |
| 240 |
} |
} |
| 241 |
|
|
| 242 |
$terms = taxonomy_dss_terms_parse_string($tid); |
// Add a title |
| 243 |
|
if (module_exists('i18ntaxonomy') && !empty($node->language)) { |
| 244 |
|
$lang = $locale; |
| 245 |
|
$locale = $node->language; |
| 246 |
|
taxonomy_dss_terms_parse_string(NULL, NULL, TRUE); |
| 247 |
|
$node->title = taxonomy_dss_get_title($node->termset->tids); |
| 248 |
|
$locale = $lang; |
| 249 |
|
} |
| 250 |
|
else { |
| 251 |
|
$node->title = taxonomy_dss_get_title($node->termset->tids); |
| 252 |
|
} |
| 253 |
|
|
| 254 |
|
// Allow other modules to alter the data |
| 255 |
|
taxonomy_dss_invoke($node, 'submit'); |
| 256 |
|
$node->termset->serialized_data = serialize($node->termset->serial_data); |
| 257 |
|
} |
| 258 |
|
|
| 259 |
|
/** |
| 260 |
|
* Implementation of hook_insert(). |
| 261 |
|
*/ |
| 262 |
|
function taxonomy_dss_insert(&$node) { |
| 263 |
|
// Insert termset into database |
| 264 |
|
db_query("INSERT INTO {taxonomy_dss_term} (tids, nid, vid, hidden, toc_hidden, toc_depth, toc_nodecount, lst_hidden, lst_teasers_hidden, serialized_data) VALUES ('%s', %d, %d, %d, %d, %d, %d, %d, %d, '%s')", $node->termset->tids, $node->nid, $node->vid, $node->termset->hidden, $node->termset->toc_hidden, $node->termset->toc_depth, $node->termset->toc_nodecount, $node->termset->lst_hidden, $node->termset->lst_teasers_hidden, $node->termset->serialized_data); |
| 265 |
|
|
| 266 |
|
// Allow other modules to alter the data |
| 267 |
|
taxonomy_dss_invoke($node, 'insert'); |
| 268 |
|
} |
| 269 |
|
|
| 270 |
|
/** |
| 271 |
|
* Implementation of hook_update(). |
| 272 |
|
*/ |
| 273 |
|
function taxonomy_dss_update(&$node) { |
| 274 |
|
if ($node->revision) { |
| 275 |
|
taxonomy_dss_insert($node); |
| 276 |
|
} |
| 277 |
|
else { |
| 278 |
|
// Update termset in database |
| 279 |
|
// We're not allowed to change tids!!! |
| 280 |
|
db_query("UPDATE {taxonomy_dss_term} SET hidden = %d, toc_hidden = %d, toc_depth = %d, toc_nodecount = %d, lst_hidden = %d, lst_teasers_hidden = %d, serialized_data = '%s' WHERE vid = %s", $node->termset->hidden, $node->termset->toc_hidden, $node->termset->toc_depth, $node->termset->toc_nodecount, $node->termset->lst_hidden, $node->termset->lst_teasers_hidden, $node->termset->serialized_data, $node->vid); |
| 281 |
|
|
| 282 |
|
// Allow other modules to alter the data |
| 283 |
|
taxonomy_dss_invoke($node, 'update'); |
| 284 |
|
} |
| 285 |
|
} |
| 286 |
|
|
| 287 |
|
/** |
| 288 |
|
* Implementation of hook_delete(). |
| 289 |
|
*/ |
| 290 |
|
function taxonomy_dss_delete(&$node) { |
| 291 |
|
db_query("DELETE FROM {taxonomy_dss_term} WHERE nid = %d", $node->nid); |
| 292 |
|
|
| 293 |
|
// Allow other modules to alter the data |
| 294 |
|
taxonomy_dss_invoke($node, 'delete'); |
| 295 |
|
} |
| 296 |
|
|
| 297 |
|
/** |
| 298 |
|
* Implementation of hook_load(). |
| 299 |
|
*/ |
| 300 |
|
function taxonomy_dss_load(&$node) { |
| 301 |
|
$node->termset = db_fetch_object(db_query("SELECT tids, hidden, toc_hidden, toc_depth, toc_nodecount, lst_hidden, lst_teasers_hidden, serialized_data FROM {taxonomy_dss_term} WHERE vid = %d", $node->vid)); |
| 302 |
|
$node->termset->serial_data = unserialize($node->termset->serialized_data); |
| 303 |
|
|
| 304 |
|
// Allow other modules to alter the data |
| 305 |
|
taxonomy_dss_invoke($node, 'load'); |
| 306 |
|
} |
| 307 |
|
|
| 308 |
|
/** |
| 309 |
|
* Implementation of hook_form(). |
| 310 |
|
*/ |
| 311 |
|
function taxonomy_dss_form(&$node) { |
| 312 |
|
$type = node_get_types('type', $node); |
| 313 |
|
$form = array(); |
| 314 |
|
|
| 315 |
|
if (!isset($node->nid) && !isset($node->termset->tids)) { |
| 316 |
|
// We're creating a new node |
| 317 |
|
// Check for tids supplied through query string |
| 318 |
|
if ($_GET['tids']) { |
| 319 |
|
$tids = $_GET['tids']; |
| 320 |
|
} |
| 321 |
|
else { |
| 322 |
|
// ERROR!!! |
| 323 |
|
$tids = ''; |
| 324 |
|
form_set_error('tids', t('This termset needs to be associated with a set of taxonomy terms.')); |
| 325 |
|
} |
| 326 |
|
} |
| 327 |
|
else { |
| 328 |
|
$tids = $node->termset->tids; |
| 329 |
|
} |
| 330 |
|
|
| 331 |
|
if (!isset($node->nid) && !empty($tids)) { |
| 332 |
|
$termset = taxonomy_dss_load_termset($tids); |
| 333 |
|
|
| 334 |
|
// Make sure this tids exists |
| 335 |
|
if ($tids != $termset->tids) { |
| 336 |
|
$tids = ''; |
| 337 |
|
form_set_error('tids', t('This termset needs to be associated with a set of taxonomy terms.')); |
| 338 |
|
} |
| 339 |
|
|
| 340 |
|
// Set the title |
| 341 |
|
if (module_exists('i18ntaxonomy') && !empty($node->language)) { |
| 342 |
|
global $locale; |
| 343 |
|
|
| 344 |
|
$lang = $locale; |
| 345 |
|
$locale = $node->language; |
| 346 |
|
taxonomy_dss_terms_parse_string(NULL, NULL, TRUE); |
| 347 |
|
drupal_set_title(taxonomy_dss_get_title($tids)); |
| 348 |
|
$locale = $lang; |
| 349 |
|
} |
| 350 |
|
else { |
| 351 |
|
drupal_set_title(taxonomy_dss_get_title($tids)); |
| 352 |
|
} |
| 353 |
|
} |
| 354 |
|
|
| 355 |
|
// Need to generate tids when creating a new node!!! |
| 356 |
|
$form[] = array( |
| 357 |
|
'#value' => 'Termset for <em>taxonomy/term/'. ($tids ? check_plain($tids) : '?') .'</em>', |
| 358 |
|
'#weight' => -10, |
| 359 |
|
); |
| 360 |
|
|
| 361 |
|
// Required to make this form unique to this set of terms. If omitted, |
| 362 |
|
// drupal's form handler often thinks it's a duplicate submit for a |
| 363 |
|
// previous 'add node' request. |
| 364 |
|
$form['termset']['tids'] = array( |
| 365 |
|
'#type' => 'hidden', |
| 366 |
|
'#value' => $tids, |
| 367 |
|
'#tree' => TRUE, |
| 368 |
|
'#parents' => array('termset', 'tids'), |
| 369 |
|
); |
| 370 |
|
|
| 371 |
|
$form['termset']['toc_options'] = array( |
| 372 |
|
'#type' => 'fieldset', |
| 373 |
|
'#title' => t('Outline options'), |
| 374 |
|
'#collapsible' => TRUE, |
| 375 |
|
'#collapsed' => FALSE, |
| 376 |
|
'#weight' => -2, |
| 377 |
|
); |
| 378 |
|
$form['termset']['toc_options']['hidden'] = array( |
| 379 |
|
'#type' => 'checkbox', |
| 380 |
|
'#title' => t('Hide term'), |
| 381 |
|
'#default_value' => $node->termset->hidden, |
| 382 |
|
'#description' => t('Don\'t display this item in the table of contents.'), |
| 383 |
|
'#tree' => TRUE, |
| 384 |
|
'#parents' => array('termset', 'hidden'), |
| 385 |
|
); |
| 386 |
|
$form['termset']['toc_options']['toc_hidden'] = array( |
| 387 |
|
'#type' => 'checkbox', |
| 388 |
|
'#title' => t('Hide outline'), |
| 389 |
|
'#default_value' => $node->termset->toc_hidden, |
| 390 |
|
'#description' => t('Hide the table of contents for this set of terms.'), |
| 391 |
|
'#tree' => TRUE, |
| 392 |
|
'#parents' => array('termset', 'toc_hidden'), |
| 393 |
|
); |
| 394 |
|
$form['termset']['toc_options']['toc_depth'] = array( |
| 395 |
|
'#type' => 'select', |
| 396 |
|
'#title' => t('Depth of outline'), |
| 397 |
|
'#default_value' => $node->termset->toc_depth, |
| 398 |
|
'#options' => array(0 => 0, 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10), |
| 399 |
|
'#description' => t('Depth of the table of contents for this set of terms. Set this to 0 to reflect an infinite depth.'), |
| 400 |
|
'#tree' => TRUE, |
| 401 |
|
'#parents' => array('termset', 'toc_depth'), |
| 402 |
|
); |
| 403 |
|
$form['termset']['toc_options']['toc_nodecount'] = array( |
| 404 |
|
'#type' => 'checkbox', |
| 405 |
|
'#title' => t('Show assigned node count in outline'), |
| 406 |
|
'#default_value' => $node->termset->toc_nodecount, |
| 407 |
|
'#description' => t('Toggles display of the number of assigned nodes available for each item listed in the table of contents.'), |
| 408 |
|
'#tree' => TRUE, |
| 409 |
|
'#parents' => array('termset', 'toc_nodecount'), |
| 410 |
|
); |
| 411 |
|
|
| 412 |
// Set page title |
$form['termset']['node_options'] = array( |
| 413 |
$title = check_plain(end($terms['names'])); |
'#type' => 'fieldset', |
| 414 |
drupal_set_title($title); |
'#title' => t('Node listing options'), |
| 415 |
|
'#collapsible' => TRUE, |
| 416 |
|
'#collapsed' => FALSE, |
| 417 |
|
'#weight' => -1, |
| 418 |
|
); |
| 419 |
|
$form['termset']['node_options']['lst_hidden'] = array( |
| 420 |
|
'#type' => 'checkbox', |
| 421 |
|
'#title' => t('Hide node listing'), |
| 422 |
|
'#default_value' => $node->termset->lst_hidden, |
| 423 |
|
'#description' => t('Hide the listed nodes in this set of terms.'), |
| 424 |
|
'#tree' => TRUE, |
| 425 |
|
'#parents' => array('termset', 'lst_hidden'), |
| 426 |
|
); |
| 427 |
|
$form['termset']['node_options']['lst_teasers_hidden'] = array( |
| 428 |
|
'#type' => 'checkbox', |
| 429 |
|
'#title' => t('Hide teasers'), |
| 430 |
|
'#default_value' => $node->termset->lst_teasers_hidden, |
| 431 |
|
'#description' => t('Hide the teaser texts for the listed nodes in this set of terms.'), |
| 432 |
|
'#tree' => TRUE, |
| 433 |
|
'#parents' => array('termset', 'lst_teasers_hidden'), |
| 434 |
|
); |
| 435 |
|
|
| 436 |
// Set breadcrumb |
$form['body_filter']['body'] = array( |
| 437 |
$breadcrumb = taxonomy_dss_generate_breadcrumb($terms['tids'], $terms['names']); |
'#type' => 'textarea', |
| 438 |
taxonomy_dss_set_breadcrumb($breadcrumb); |
'#title' => check_plain($type->body_label), |
| 439 |
|
'#default_value' => $node->body, |
| 440 |
|
'#rows' => 20, |
| 441 |
|
'#required' => ($type->min_word_count > 0) |
| 442 |
|
); |
| 443 |
|
$form['body_filter']['format'] = filter_form($node->format); |
| 444 |
|
|
| 445 |
// Render editing form |
return $form; |
|
return drupal_get_form($node->type .'_node_form', $node); |
|
| 446 |
} |
} |
| 447 |
|
|
| 448 |
/** |
/** |
| 449 |
* Menu callback; presents the add node form and associated a node with this |
* Implementation of hook_view(). |
|
* set of terms. |
|
| 450 |
*/ |
*/ |
| 451 |
function taxonomy_dss_page_add($tid) { |
function taxonomy_dss_view(&$node, $teaser, $page) { |
| 452 |
$type = 'term'; |
$node = node_prepare($node, $teaser); |
| 453 |
|
|
| 454 |
$terms = taxonomy_dss_terms_parse_string($tid); |
if ($page) { |
| 455 |
|
// Need to see about passing depth as an arg() |
| 456 |
|
$depth = 0; |
| 457 |
|
|
| 458 |
// Set page title |
$terms = taxonomy_dss_terms_parse_string($node->termset->tids); |
| 459 |
$title = check_plain(end($terms['names'])); |
$title = check_plain(end($terms['names'])); |
| 460 |
drupal_set_title($title); |
|
| 461 |
|
$node->content['body'] = array( |
| 462 |
|
'#value' => theme('taxonomy_dss_body', $node), |
| 463 |
|
'#weight' => 0, |
| 464 |
|
); |
| 465 |
|
$node->content = array_merge($node->content, taxonomy_dss_build_content($node->termset, $depth)); |
| 466 |
|
|
| 467 |
// Set breadcrumb |
// Fix the title |
| 468 |
$breadcrumb = taxonomy_dss_generate_breadcrumb($terms['tids'], $terms['names']); |
drupal_set_title($title); |
|
taxonomy_dss_set_breadcrumb($breadcrumb); |
|
| 469 |
|
|
| 470 |
// Initialize settings: |
// Build breadcrumb in order of tids |
| 471 |
$node = array('uid' => $GLOBALS['user']->uid, 'name' => $GLOBALS['user']->name, 'type' => $type); |
$breadcrumb = taxonomy_dss_generate_breadcrumb($terms['tids'], $terms['names']); |
| 472 |
|
menu_set_location($breadcrumb); |
| 473 |
|
taxonomy_dss_set_breadcrumb($breadcrumb); |
| 474 |
|
|
| 475 |
|
// Add RSS feed icon |
| 476 |
|
if (drupal_is_front_page()) { |
| 477 |
|
$feed_url = url('rss.xml', NULL, NULL, TRUE); |
| 478 |
|
drupal_add_feed($feed_url, variable_get('site_name', 'Drupal') .' '. t('RSS')); |
| 479 |
|
} |
| 480 |
|
else { |
| 481 |
|
drupal_add_feed(url('taxonomy/term/'. $node->termset->tids .'/'. $depth .'/feed'), 'RSS - '. $title); |
| 482 |
|
} |
| 483 |
|
|
| 484 |
return drupal_get_form($type .'_node_form', $node); |
// Add custom CSS |
| 485 |
|
drupal_add_css(drupal_get_path('module', 'taxonomy_dss') .'/taxonomy_dss.css'); |
| 486 |
|
} |
| 487 |
|
return $node; |
| 488 |
} |
} |
| 489 |
|
|
| 490 |
/** |
/** |
| 555 |
*/ |
*/ |
| 556 |
function taxonomy_dss_form_alter($form_id, &$form) { |
function taxonomy_dss_form_alter($form_id, &$form) { |
| 557 |
switch ($form_id) { |
switch ($form_id) { |
| 558 |
|
case 'termset_node_form': |
| 559 |
|
$path = $form['#node']->path; |
| 560 |
|
$form['path'] = array( |
| 561 |
|
); |
| 562 |
|
$form['path']['path'] = array( |
| 563 |
|
'#type' => 'value', |
| 564 |
|
'#value' => $path, |
| 565 |
|
); |
| 566 |
|
if ($path) { |
| 567 |
|
$form['path']['pid'] = array( |
| 568 |
|
'#type' => 'value', |
| 569 |
|
'#value' => db_result(db_query("SELECT pid FROM {url_alias} WHERE dst = '%s'", $path)) |
| 570 |
|
); |
| 571 |
|
} |
| 572 |
|
break; |
| 573 |
|
|
| 574 |
case 'taxonomy_form_vocabulary': |
case 'taxonomy_form_vocabulary': |
| 575 |
$form['taxonomy_dss_hidden'] = array( |
$form['taxonomy_dss_hidden'] = array( |
| 576 |
'#type' => 'checkboxes', |
'#type' => 'checkboxes', |
| 582 |
); |
); |
| 583 |
break; |
break; |
| 584 |
|
|
|
case 'term_node_form': |
|
|
if (arg(0) == 'node' && arg(1) == 'add') { |
|
|
$form = array(); |
|
|
$form[] = array( |
|
|
'#value' => t('Term pages can only be created from a taxonomy term page.'), |
|
|
); |
|
|
} |
|
|
elseif (arg(0) == 'taxonomy' && arg(1) == 'term' && (arg(3) == 'add' || arg(3) == 'edit')) { |
|
|
// Add options for display of outline tree |
|
|
|
|
|
$termset = taxonomy_dss_load(arg(2)); |
|
|
|
|
|
$form['toc_options'] = array( |
|
|
'#type' => 'fieldset', |
|
|
'#title' => t('Outline options'), |
|
|
'#collapsible' => TRUE, |
|
|
'#collapsed' => FALSE, |
|
|
'#weight' => -2, |
|
|
); |
|
|
$form['toc_options']['hidden'] = array( |
|
|
'#type' => 'checkbox', |
|
|
'#title' => t('Hide term'), |
|
|
'#default_value' => isset($node->hidden) ? $node->hidden : $termset->hidden, |
|
|
'#description' => t('Don\'t display this item in the table of contents.'), |
|
|
); |
|
|
$form['toc_options']['toc_hidden'] = array( |
|
|
'#type' => 'checkbox', |
|
|
'#title' => t('Hide outline'), |
|
|
'#default_value' => isset($node->toc_hidden) ? $node->toc_hidden : $termset->toc_hidden, |
|
|
'#description' => t('Hide the table of contents for this set of terms.'), |
|
|
); |
|
|
$form['toc_options']['toc_depth'] = array( |
|
|
'#type' => 'select', |
|
|
'#title' => t('Depth of outline'), |
|
|
'#default_value' => isset($node->toc_depth) ? $node->toc_depth : $termset->toc_depth, |
|
|
'#options' => array(0 => 0, 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10), |
|
|
'#description' => t('Depth of the table of contents for this set of terms. Set this to 0 to reflect an infinite depth.'), |
|
|
); |
|
|
$form['toc_options']['toc_nodecount'] = array( |
|
|
'#type' => 'checkbox', |
|
|
'#title' => t('Show assigned node count in outline'), |
|
|
'#default_value' => isset($node->toc_nodecount) ? $node->toc_nodecount : $termset->toc_nodecount, |
|
|
'#description' => t('Toggles display of the number of assigned nodes available for each item listed in the table of contents.'), |
|
|
); |
|
|
|
|
|
$form['node_options'] = array( |
|
|
'#type' => 'fieldset', |
|
|
'#title' => t('Node listing options'), |
|
|
'#collapsible' => TRUE, |
|
|
'#collapsed' => FALSE, |
|
|
'#weight' => -1, |
|
|
); |
|
|
$form['node_options']['lst_hidden'] = array( |
|
|
'#type' => 'checkbox', |
|
|
'#title' => t('Hide node listing'), |
|
|
'#default_value' => isset($node->lst_hidden) ? $node->lst_hidden : $termset->lst_hidden, |
|
|
'#description' => t('Hide the listed nodes in this set of terms.'), |
|
|
); |
|
|
$form['node_options']['lst_teasers_hidden'] = array( |
|
|
'#type' => 'checkbox', |
|
|
'#title' => t('Hide teasers'), |
|
|
'#default_value' => isset($node->lst_teasers_hidden) ? $node->lst_teasers_hidden : $termset->lst_teasers_hidden, |
|
|
'#description' => t('Hide the teaser texts for the listed nodes in this set of terms.'), |
|
|
); |
|
|
|
|
|
// Required to make this form unique to this set of terms. If omitted, |
|
|
// drupal's form handler often thinks it's a duplicate submit for a |
|
|
// previous 'add node' request. |
|
|
$form['term_tid'] = array( |
|
|
'#type' => 'hidden', |
|
|
'#value' => arg(2), |
|
|
); |
|
|
} |
|
|
else { |
|
|
print "EDIT THIS PAGE!<br />\nAdd a taxonomy select dropdown menu.<br />\nOr, we can somehow disable access to this particular page from this particular spot?"; |
|
|
} |
|
|
break; |
|
|
|
|
| 585 |
case 'node_admin_nodes': |
case 'node_admin_nodes': |
| 586 |
// Override edit destination for 'term' nodes on 'Content management' page |
// Override edit destination for 'termset' nodes on 'Content management' page |
| 587 |
if (is_array($form['name'])) { |
if (is_array($form['name'])) { |
| 588 |
$keys = array_keys($form['name']); |
$keys = array_keys($form['name']); |
| 589 |
foreach ($keys as $key) { |
foreach ($keys as $key) { |
| 590 |
if ($form['name'][$key]['#value'] == 'Term') { |
if ($form['name'][$key]['#value'] == 'Termset') { |
| 591 |
$form['operations'][$key]['#value'] = l(t('edit'), 'taxonomy/term/'. taxonomy_dss_get_tids($key) .'/edit', array(), drupal_get_destination()); |
$form['operations'][$key]['#value'] = l(t('edit'), 'taxonomy/term/'. taxonomy_dss_get_tids($key) .'/edit', array(), drupal_get_destination()); |
| 592 |
} |
} |
| 593 |
} |
} |
| 616 |
elseif ($type == 'term') { |
elseif ($type == 'term') { |
| 617 |
switch ($op) { |
switch ($op) { |
| 618 |
case 'delete': |
case 'delete': |
| 619 |
db_query("DELETE FROM {taxonomy_dss_term} WHERE tid = '%s'", $object['tid']); |
db_query("DELETE FROM {taxonomy_dss_term} WHERE tids = '%s'", $object['tid']); |
| 620 |
// Actually, we need to delete every single page that this term appears in... ouch! |
// Actually, we need to delete every single page that this term appears in... ouch! |
| 621 |
break; |
break; |
| 622 |
} |
} |
| 631 |
$delimiter = ($clean_url == FALSE || strstr('?', $node->breadcrumb[$i]['path']) ? '&' : '?'); |
$delimiter = ($clean_url == FALSE || strstr('?', $node->breadcrumb[$i]['path']) ? '&' : '?'); |
| 632 |
|
|
| 633 |
switch ($op) { |
switch ($op) { |
| 634 |
case 'insert': |
case 'delete revision': |
| 635 |
if (arg(0) == 'taxonomy' && arg(1) == 'term' && arg(3) == 'add') { |
db_query('DELETE FROM {taxonomy_dss_term} WHERE vid = %d', $node->vid); |
|
// arg(2) needs to be cleaned, or we might have a security hole! |
|
|
|
|
|
// Allow other modules to alter the data |
|
|
$termset = taxonomy_dss_node_to_termset(arg(2), $node); |
|
|
taxonomy_dss_invoke($termset, 'submit', $node); |
|
|
$termset->serialized_data = serialize($termset->serial_data); |
|
|
|
|
|
// Insert termset into database |
|
|
db_query("INSERT INTO {taxonomy_dss_term} (tid, nid, hidden, toc_hidden, toc_depth, toc_nodecount, lst_hidden, lst_teasers_hidden, serialized_data) VALUES ('%s', %d, %d, %d, %d, %d, %d, %d, '%s')", $termset->tids, $termset->nid, $termset->hidden, $termset->toc_hidden, $termset->toc_depth, $termset->toc_nodecount, $termset->lst_hidden, $termset->lst_teasers_hidden, $termset->serialized_data); |
|
|
|
|
|
// Allow other modules to alter the data |
|
|
taxonomy_dss_invoke($termset, 'insert', $node); |
|
|
} |
|
|
break; |
|
|
|
|
|
case 'update': |
|
|
if (arg(0) == 'taxonomy' && arg(1) == 'term' && arg(3) == 'edit') { |
|
|
|
|
|
// Allow other modules to alter the data |
|
|
$termset = taxonomy_dss_node_to_termset(arg(2), $node); |
|
|
taxonomy_dss_invoke($termset, 'submit', $node); |
|
|
$termset->serialized_data = serialize($termset->serial_data); |
|
|
|
|
|
// Update termset in database |
|
|
db_query("UPDATE {taxonomy_dss_term} SET hidden = %d, toc_hidden = %d, toc_depth = %d, toc_nodecount = %d, lst_hidden = %d, lst_teasers_hidden = %d, serialized_data = '%s' WHERE tid = '%s'", $termset->hidden, $termset->toc_hidden, $termset->toc_depth, $termset->toc_nodecount, $termset->lst_hidden, $termset->lst_teasers_hidden, $termset->serialized_data, $termset->tids); |
|
|
|
|
|
// Allow other modules to alter the data |
|
|
taxonomy_dss_invoke($termset, 'update', $node); |
|
|
} |
|
|
break; |
|
|
|
|
|
case 'delete': |
|
|
db_query("DELETE FROM {taxonomy_dss_term} WHERE nid = %d", $node->nid); |
|
| 636 |
|
|
| 637 |
// Allow other modules to alter the data |
// Allow other modules to alter the data |
| 638 |
taxonomy_dss_invoke($termset, 'delete'); |
taxonomy_dss_invoke($node, 'delete revision'); |
|
break; |
|
|
|
|
|
case 'submit': |
|
|
// If it's a term node, add a title |
|
|
if (isset($node->nid)) { |
|
|
// Updating existing node |
|
|
if ($node->type == 'term' && $tids = taxonomy_dss_get_tids($node->nid)) { |
|
|
$node->title = taxonomy_dss_get_title($tids); |
|
|
} |
|
|
} |
|
|
elseif (arg(0) == 'taxonomy' && arg(1) == 'term' && arg(3) == 'add') { |
|
|
// Creating new node |
|
|
$node->title = taxonomy_dss_get_title(arg(2)); |
|
|
} |
|
|
|
|
| 639 |
break; |
break; |
| 640 |
|
|
| 641 |
case 'view': |
case 'view': |
| 642 |
if ($page) { |
if ($page) { |
| 643 |
// Page view |
// Page view |
| 644 |
|
|
|
// If this node is associated with a taxonomy term, jump! |
|
|
if (arg(0) != 'taxonomy' && arg(1) != 'term' && $tid = taxonomy_dss_get_tids($node->nid)) { |
|
|
drupal_goto('taxonomy/term/'.$tid); |
|
|
} |
|
|
|
|
| 645 |
// Fix book module links |
// Fix book module links |
| 646 |
$taxonomy = $_GET['taxonomy'] ? 'taxonomy='.$_GET['taxonomy'] : ''; |
$taxonomy = $_GET['taxonomy'] ? 'taxonomy='.$_GET['taxonomy'] : ''; |
| 647 |
if (module_exists('book') && isset($node->content['book_navigation']) && $taxonomy) { |
if (module_exists('book') && isset($node->content['book_navigation']) && $taxonomy) { |
| 710 |
return $vocabularies[$vid]; |
return $vocabularies[$vid]; |
| 711 |
} |
} |
| 712 |
|
|
| 713 |
function taxonomy_dss_not_available() { |
function taxonomy_dss_load_termset($tids) { |
| 714 |
return t('n/a'); |
if (is_array($tids)) { |
| 715 |
|
$tids = implode(',', $tids); |
| 716 |
|
} |
| 717 |
|
|
| 718 |
|
// Do some cleanup |
| 719 |
|
$terms = taxonomy_dss_terms_parse_string($tids); |
| 720 |
|
return _taxonomy_dss_load_termset(implode(',', $terms['tids'])); |
| 721 |
} |
} |
| 722 |
|
|
| 723 |
function taxonomy_dss_get_termset_data($tids) { |
function _taxonomy_dss_load_termset($tids) { |
| 724 |
static $data = array(); |
static $data = array(); |
| 725 |
|
|
| 726 |
if (!isset($data[$tids])) { |
if (!isset($data[$tids])) { |
| 727 |
$result = db_query("SELECT nid, hidden, toc_hidden, toc_depth, toc_nodecount, lst_hidden, lst_teasers_hidden, serialized_data FROM {taxonomy_dss_term} WHERE tid = '%s'", $tids); |
$result = db_query("SELECT tids, nid, hidden, toc_hidden, toc_depth, toc_nodecount, lst_hidden, lst_teasers_hidden, serialized_data FROM {taxonomy_dss_term} WHERE tids = '%s'", $tids); |
| 728 |
if ($row = db_fetch_object($result)) { |
if ($row = db_fetch_object($result)) { |
| 729 |
$row->serial_data = unserialize($row->serialized_data); |
$row->serial_data = unserialize($row->serialized_data); |
| 730 |
$data[$tids] = $row; |
$data[$tids] = $row; |
| 741 |
$data[$tids]->lst_teasers_hidden = variable_get('taxonomy_dss_lst_teasers_hidden', 0); |
$data[$tids]->lst_teasers_hidden = variable_get('taxonomy_dss_lst_teasers_hidden', 0); |
| 742 |
$data[$tids]->serial_data = unserialize(''); |
$data[$tids]->serial_data = unserialize(''); |
| 743 |
} |
} |
| 744 |
|
|
| 745 |
|
// Allow other modules to alter the data |
| 746 |
|
taxonomy_dss_invoke($data[$tids], 'load'); |
| 747 |
} |
} |
| 748 |
|
|
| 749 |
return drupal_clone($data[$tids]); |
return drupal_clone($data[$tids]); |
| 750 |
} |
} |
| 751 |
|
|
| 752 |
function taxonomy_dss_term_is_hidden($tids) { |
function taxonomy_dss_term_is_hidden($tids) { |
| 753 |
$termset = taxonomy_dss_load($tids); |
$termset = taxonomy_dss_load_termset($tids); |
| 754 |
return $termset->hidden; |
return $termset->hidden; |
| 755 |
} |
} |
| 756 |
|
|
| 757 |
function taxonomy_dss_get_nid($tids) { |
function taxonomy_dss_get_nid($tids) { |
| 758 |
$termset = taxonomy_dss_load($tids); |
$termset = taxonomy_dss_load_termset($tids); |
| 759 |
return $termset->nid; |
return $termset->nid; |
| 760 |
} |
} |
| 761 |
|
|
| 762 |
function taxonomy_dss_get_tids($nid) { |
function taxonomy_dss_get_tids($nid) { |
| 763 |
$tids = 0; |
$tids = 0; |
| 764 |
|
|
| 765 |
$result = db_query("SELECT tid FROM {taxonomy_dss_term} WHERE nid = %d", $nid); |
$result = db_query("SELECT tids FROM {taxonomy_dss_term} WHERE nid = %d", $nid); |
| 766 |
if ($row = db_fetch_array($result)) { |
if ($row = db_fetch_array($result)) { |
| 767 |
$tids = $row['tid']; |
$tids = $row['tid']; |
| 768 |
} |
} |
| 770 |
} |
} |
| 771 |
|
|
| 772 |
function taxonomy_dss_get_current_tids() { |
function taxonomy_dss_get_current_tids() { |
| 773 |
|
static $tids; |
| 774 |
|
|
| 775 |
|
// Return cached version |
| 776 |
|
if (is_array($tids)) { |
| 777 |
|
return $tids; |
| 778 |
|
} |
| 779 |
|
|
| 780 |
$tids = array(); |
$tids = array(); |
| 781 |
switch (arg(0)) { |
switch (arg(0)) { |
| 782 |
case 'node': |
case 'node': |
| 785 |
if (!$node) { |
if (!$node) { |
| 786 |
break; |
break; |
| 787 |
} |
} |
| 788 |
$tids = taxonomy_dss_filter_tids($node->taxonomy, isset($_GET['taxonomy']) ? $_GET['taxonomy'] : ''); |
if ($node->type == 'termset') { |
| 789 |
|
$tids = explode(',', $node->termset->tids); |
| 790 |
|
} |
| 791 |
|
else { |
| 792 |
|
$tids = taxonomy_dss_filter_tids($node->taxonomy, isset($_GET['taxonomy']) ? $_GET['taxonomy'] : ''); |
| 793 |
|
} |
| 794 |
} |
} |
| 795 |
break; |
break; |
| 796 |
case 'taxonomy': |
case 'taxonomy': |
| 829 |
* a tids key containing an array of the term ids, and a names key |
* a tids key containing an array of the term ids, and a names key |
| 830 |
* containing the term names/titles. |
* containing the term names/titles. |
| 831 |
*/ |
*/ |
| 832 |
function taxonomy_dss_terms_parse_string($str_tids, $expand_parents = FALSE) { |
function taxonomy_dss_terms_parse_string($str_tids, $expand_parents = FALSE, $clear_cache = FALSE) { |
| 833 |
static $termsets = array( |
static $termsets = array( |
| 834 |
'default' => array(), |
'default' => array(), |
| 835 |
'expanded' => array(), |
'expanded' => array(), |
| 836 |
); |
); |
| 837 |
|
|
| 838 |
|
if ($clear_cache == TRUE) { |
| 839 |
|
$termsets['default'] = array(); |
| 840 |
|
$termsets['expanded'] = array(); |
| 841 |
|
return; |
| 842 |
|
} |
| 843 |
|
|
| 844 |
if ($expand_parents === FALSE) { |
if ($expand_parents === FALSE) { |
| 845 |
if (isset($termsets['default'][$str_tids])) { |
if (isset($termsets['default'][$str_tids])) { |
| 846 |
return $termsets['default'][$str_tids]; |
return $termsets['default'][$str_tids]; |
| 880 |
$tids = array(); |
$tids = array(); |
| 881 |
$names = array(); |
$names = array(); |
| 882 |
|
|
| 883 |
$result = db_query(db_rewrite_sql('SELECT t.tid, t.name, (%s) AS weight FROM {term_data} t WHERE t.tid IN (%s) ORDER BY weight', 't', 'tid'), _taxonomy_dss_sql_order_tids($terms['tids']), implode(',', $terms['tids'])); |
$result = db_query(db_rewrite_sql('SELECT t.tid, t.vid, t.name, (%s) AS weight FROM {term_data} t WHERE t.tid IN (%s) ORDER BY weight', 't', 'tid'), _taxonomy_dss_sql_order_tids($terms['tids']), implode(',', $terms['tids'])); |
| 884 |
while ($term = db_fetch_object($result)) { |
while ($term = db_fetch_object($result)) { |
| 885 |
|
if (module_exists('i18ntaxonomy')) { |
| 886 |
|
$ary = array($term); |
| 887 |
|
_i18ntaxonomy_translate_terms($ary); |
| 888 |
|
} |
| 889 |
|
|
| 890 |
$tids[] = $term->tid; |
$tids[] = $term->tid; |
| 891 |
$names[] = $term->name; |
$names[] = $term->name; |
| 892 |
} |
} |
| 1064 |
|
|
| 1065 |
// db_rewrite_sql() bugs out on a complex SELECT within a SELECT, so need to work around it |
// db_rewrite_sql() bugs out on a complex SELECT within a SELECT, so need to work around it |
| 1066 |
$sql_a = db_rewrite_sql("SELECT COUNT(DISTINCT(td0.vid)) FROM {term_node} t LEFT JOIN {term_data} td0 ON t.tid = td0.tid WHERE t.nid = n.nid", 'tn', 'tid'); |
$sql_a = db_rewrite_sql("SELECT COUNT(DISTINCT(td0.vid)) FROM {term_node} t LEFT JOIN {term_data} td0 ON t.tid = td0.tid WHERE t.nid = n.nid", 'tn', 'tid'); |
| 1067 |
|
|
| 1068 |
$sql_b = db_rewrite_sql("SELECT DISTINCT(n.nid) FROM {node} n {$joins} WHERE n.status = 1 {$wheres} AND (___PLACEHOLDER1___) > ". count($tids)); |
$sql_b = db_rewrite_sql("SELECT DISTINCT(n.nid) FROM {node} n {$joins} WHERE n.status = 1 {$wheres} AND (___PLACEHOLDER1___) > ". count($tids)); |
| 1069 |
$sql_b = str_replace('___PLACEHOLDER1___', $sql_a, $sql_b); |
$sql_b = str_replace('___PLACEHOLDER1___', $sql_a, $sql_b); |
| 1070 |
|
|
| 1228 |
if ($operator == 'or') { |
if ($operator == 'or') { |
| 1229 |
$str_tids = implode(',', call_user_func_array('array_merge', $descendant_tids)); |
$str_tids = implode(',', call_user_func_array('array_merge', $descendant_tids)); |
| 1230 |
$sql = 'SELECT DISTINCT(n.nid), n.sticky, n.title, n.created FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid IN ('. $str_tids .') '. $promote_sql .'AND n.status = 1 ORDER BY '. $order; |
$sql = 'SELECT DISTINCT(n.nid), n.sticky, n.title, n.created FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid IN ('. $str_tids .') '. $promote_sql .'AND n.status = 1 ORDER BY '. $order; |
| 1231 |
|
|
| 1232 |
$sql_count = 'SELECT COUNT(DISTINCT(n.nid)) FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid IN ('. $str_tids .') '. $promote_sql .'AND n.status = 1'; |
$sql_count = 'SELECT COUNT(DISTINCT(n.nid)) FROM {node} n INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid IN ('. $str_tids .') '. $promote_sql .'AND n.status = 1'; |
| 1233 |
|
|
| 1234 |
$sql = db_rewrite_sql($sql); |
$sql = db_rewrite_sql($sql); |
| 1235 |
$sql_count = db_rewrite_sql($sql_count); |
$sql_count = db_rewrite_sql($sql_count); |
| 1236 |
} |
} |
| 1243 |
} |
} |
| 1244 |
if ($exclusive) { |
if ($exclusive) { |
| 1245 |
$sql = db_rewrite_sql('SELECT DISTINCT(n.nid), n.sticky, n.title, n.created FROM {node} n '. $joins .' WHERE n.status = 1 '. $promote_sql . $wheres .' AND (___PLACEHOLDER___) = '. count($descendant_tids) .' ORDER BY '. $order); |
$sql = db_rewrite_sql('SELECT DISTINCT(n.nid), n.sticky, n.title, n.created FROM {node} n '. $joins .' WHERE n.status = 1 '. $promote_sql . $wheres .' AND (___PLACEHOLDER___) = '. count($descendant_tids) .' ORDER BY '. $order); |
| 1246 |
|
|
| 1247 |
// db_rewrite_sql() bugs out on a complex SELECT within a SELECT, so need to work around it |
// db_rewrite_sql() bugs out on a complex SELECT within a SELECT, so need to work around it |
| 1248 |
$sql_sub = db_rewrite_sql('SELECT COUNT(DISTINCT(td0.vid)) FROM {term_node} tn LEFT JOIN {term_data} td0 ON tn.tid = td0.tid WHERE tn.nid = n.nid', 'tn', 'tid'); |
$sql_sub = db_rewrite_sql('SELECT COUNT(DISTINCT(td0.vid)) FROM {term_node} tn LEFT JOIN {term_data} td0 ON tn.tid = td0.tid WHERE tn.nid = n.nid', 'tn', 'tid'); |
| 1249 |
$sql = str_replace('___PLACEHOLDER___', $sql_sub, $sql); |
$sql = str_replace('___PLACEHOLDER___', $sql_sub, $sql); |
| 1250 |
|
|
| 1251 |
// db_rewrite_sql() bugs out on a complex SELECT within a SELECT, so need to work around it |
// db_rewrite_sql() bugs out on a complex SELECT within a SELECT, so need to work around it |
| 1252 |
$sql_count = db_rewrite_sql('SELECT COUNT(DISTINCT(n.nid)) FROM {node} n '. $joins .' AND (___PLACEHOLDER___) = '. count($descendant_tids) .' WHERE n.status = 1 '. $promote_sql . $wheres); |
$sql_count = db_rewrite_sql('SELECT COUNT(DISTINCT(n.nid)) FROM {node} n '. $joins .' AND (___PLACEHOLDER___) = '. count($descendant_tids) .' WHERE n.status = 1 '. $promote_sql . $wheres); |
| 1253 |
$sql_count_sub = db_rewrite_sql('SELECT COUNT(*) FROM {term_node} t WHERE t.nid = n.nid', 'tn', 'tid'); |
$sql_count_sub = db_rewrite_sql('SELECT COUNT(*) FROM {term_node} t WHERE t.nid = n.nid', 'tn', 'tid'); |
| 1255 |
} |
} |
| 1256 |
else { |
else { |
| 1257 |
$sql = 'SELECT DISTINCT(n.nid), n.sticky, n.title, n.created FROM {node} n '. $joins .' WHERE n.status = 1 '. $promote_sql . $wheres .' ORDER BY '. $order; |
$sql = 'SELECT DISTINCT(n.nid), n.sticky, n.title, n.created FROM {node} n '. $joins .' WHERE n.status = 1 '. $promote_sql . $wheres .' ORDER BY '. $order; |
| 1258 |
|
|
| 1259 |
$sql_count = 'SELECT COUNT(DISTINCT(n.nid)) FROM {node} n '. $joins .' WHERE n.status = 1 '. $promote_sql . $wheres; |
$sql_count = 'SELECT COUNT(DISTINCT(n.nid)) FROM {node} n '. $joins .' WHERE n.status = 1 '. $promote_sql . $wheres; |
| 1260 |
|
|
| 1261 |
$sql = db_rewrite_sql($sql); |
$sql = db_rewrite_sql($sql); |
| 1262 |
$sql_count = db_rewrite_sql($sql_count); |
$sql_count = db_rewrite_sql($sql_count); |
| 1263 |
} |
} |
| 1334 |
return $location; |
return $location; |
| 1335 |
} |
} |
| 1336 |
|
|
|
/** |
|
|
* Theme for displaying terms on the taxonomy pages. |
|
|
* |
|
|
* @ingroup themeable |
|
|
*/ |
|
|
function theme_taxonomy_dss_term_link($term, $show_count = FALSE, $current = FALSE) { |
|
|
if ($current) { |
|
|
$attributes = array('class' => 'active-trail'); |
|
|
} |
|
|
else { |
|
|
$attributes = array(); |
|
|
} |
|
|
|
|
|
return l($term->name, $term->link, $attributes) .($show_count ? ' <span class="taxonomy-dss-term-count">('. $term->count .')</span>' : ''); |
|
|
} |
|
|
|
|
|
/** |
|
|
* Theme for displaying terms on the taxonomy pages. |
|
|
* |
|
|
* @ingroup themeable |
|
|
*/ |
|
|
function theme_taxonomy_dss_term_toc($tree, $depth = 0, $show_count = FALSE) { |
|
|
$ouput = ''; |
|
|
|
|
|
// Render tree of child terms |
|
|
if (count($tree->children)) { |
|
|
if ($depth == 0) { |
|
|
$output .= '<div class="taxonomy-dss-terms">'."\n"; |
|
|
} |
|
|
|
|
|
$output .= '<ul class="menu">'."\n"; |
|
|
foreach ($tree->children as $term) { |
|
|
if ($term->hidden) { |
|
|
// skip it |
|
|
} |
|
|
elseif (!isset($term->children)) { |
|
|
$output .= '<li class="leaf">'. theme('taxonomy_dss_term_link', $term, $show_count) .'</li>'."\n"; |
|
|
} |
|
|
elseif (count($term->children)) { |
|
|
$output .= '<li class="expanded">'. theme('taxonomy_dss_term_link', $term, $show_count) ."\n"; |
|
|
$output .= theme('taxonomy_dss_term_toc', $term, $depth + 1, $show_count); |
|
|
$output .= '</li>'."\n"; |
|
|
} |
|
|
else { |
|
|
$output .= '<li class="collapsed">'. theme('taxonomy_dss_term_link', $term, $show_count) .'</li>'."\n"; |
|
|
} |
|
|
} |
|
|
$output .= '</ul>'."\n"; |
|
|
|
|
|
if ($depth == 0) { |
|
|
$output .= '</div>'."\n"; |
|
|
} |
|
|
} |
|
|
|
|
|
return $output; |
|
|
} |
|
|
|
|
|
function theme_taxonomy_dss_term_nodes($tree, $depth = 0, $hide_teasers = FALSE) { |
|
|
$ouput = ''; |
|
|
|
|
|
// Render associated nodes |
|
|
if ($depth == 0 && count($tree->nodes)) { |
|
|
$output .= '<div class="taxonomy-dss-nodes">'."\n"; |
|
|
if ($hide_teasers) { |
|
|
$output .= '<ul>'; |
|
|
foreach ($tree->nodes as $node) { |
|
|
// Allow modules to modify the fully-built node. |
|
|
node_invoke_nodeapi($node, 'alter', TRUE, FALSE); |
|
|
|
|
|
// Hack to get proper links. Really needs to be a core editable link, through hook_link_alter(). |
|
|
$tids = taxonomy_dss_filter_tids($node->taxonomy, arg(2), TRUE); |
|
|
$query = (count($tids) ? 'taxonomy='. implode(',', $tids) : ''); |
|
|
|
|
|
$output .= '<li>'. l($node->title, 'node/'.$node->nid, array(), $query ? $query : NULL) .'</li>'; |
|
|
} |
|
|
$output .= '</ul>'; |
|
|
} |
|
|
else { |
|
|
foreach ($tree->nodes as $node) { |
|
|
$output .= node_view($node, TRUE); |
|
|
} |
|
|
} |
|
|
$output .= '</div>'."\n"; |
|
|
|
|
|
$output .= theme('pager', NULL, variable_get('default_nodes_main', 10), 0); |
|
|
} |
|
|
|
|
|
return $output; |
|
|
} |
|
|
|
|
| 1337 |
function _taxonomy_dss_sql_order_tids($tids) { |
function _taxonomy_dss_sql_order_tids($tids) { |
| 1338 |
$order = 'CASE t.tid '; |
$order = 'CASE t.tid '; |
| 1339 |
foreach ($tids as $key => $value) { |
foreach ($tids as $key => $value) { |
| 1380 |
if(isset($tree[$tid]->children)) { |
if(isset($tree[$tid]->children)) { |
| 1381 |
_taxonomy_dss_translate_tree($tree[$tid]->children); |
_taxonomy_dss_translate_tree($tree[$tid]->children); |
| 1382 |
} |
} |
| 1383 |
} |
} |
| 1384 |
_i18ntaxonomy_translate_terms(&$tree); |
_i18ntaxonomy_translate_terms(&$tree); |
| 1385 |
} |
} |
| 1386 |
} |
} |
| 1517 |
} |
} |
| 1518 |
} |
} |
| 1519 |
|
|
|
|
|
|
/*****************************************************************************/ |
|
|
|
|
| 1520 |
/** |
/** |
| 1521 |
* Invoke a hook_taxonomy_dss() operation in all modules. |
* Invoke a hook_taxonomy_dss() operation in all modules. |
| 1522 |
* |
* |
| 1527 |
* @return |
* @return |
| 1528 |
* The returned value of the invoked hooks. |
* The returned value of the invoked hooks. |
| 1529 |
*/ |
*/ |
| 1530 |
function taxonomy_dss_invoke(&$termset, $op, $arg1 = NULL) { |
function taxonomy_dss_invoke(&$termset, $op, &$arg1 = NULL) { |
| 1531 |
$return = array(); |
$return = array(); |
| 1532 |
foreach (module_implements('taxonomy_dss') as $name) { |
foreach (module_implements('taxonomy_dss') as $name) { |
| 1533 |
$function = $name .'_taxonomy_dss'; |
$function = $name .'_taxonomy_dss'; |
| 1556 |
* A structured array containing the individual elements |
* A structured array containing the individual elements |
| 1557 |
* of the termset's body. |
* of the termset's body. |
| 1558 |
*/ |
*/ |
| 1559 |
function taxonomy_dss_build_content(&$termset, $op, $depth) { |
function taxonomy_dss_build_content($termset, $depth) { |
| 1560 |
$termset = taxonomy_dss_prepare($termset); |
$content = array(); |
| 1561 |
|
|
| 1562 |
// Add associated node's body to the page. |
$terms = taxonomy_dss_terms_parse_string($termset->tids); |
|
$node = node_load($termset->nid); |
|
|
if ($node && $node->body) { |
|
|
$termset->content['body'] = array( |
|
|
'#value' => '<div class="taxonomy-dss-node">'. node_view($node, FALSE, TRUE, TRUE) .'</div>', |
|
|
'#weight' => 0, |
|
|
); |
|
|
} |
|
| 1563 |
|
|
| 1564 |
// Add taxonomy tree |
// Add taxonomy tree |
| 1565 |
if (!$termset->toc_hidden || !$termset->lst_hidden) { |
if (!$termset->toc_hidden || !$termset->lst_hidden) { |
| 1566 |
if (!$termset->toc_hidden) { |
if (!$termset->toc_hidden) { |
| 1567 |
$children = taxonomy_dss_select_children($termset->terms['tids']); |
$children = taxonomy_dss_select_children($terms['tids']); |
| 1568 |
} |
} |
| 1569 |
else { |
else { |
| 1570 |
$children = FALSE; |
$children = FALSE; |
| 1571 |
} |
} |
| 1572 |
if (!$termset->lst_hidden) { |
if (!$termset->lst_hidden) { |
| 1573 |
$nodes = taxonomy_dss_select_nodes($termset->terms['tids'], $termset->terms['operator'], $depth, TRUE); |
$nodes = taxonomy_dss_select_nodes($terms['tids'], $terms['operator'], $depth, TRUE); |
| 1574 |
} |
} |
| 1575 |
else { |
else { |
| 1576 |
$nodes = FALSE; |
$nodes = FALSE; |
| 1579 |
// Build the tree |
// Build the tree |
| 1580 |
$tree = new StdClass; |
$tree = new StdClass; |
| 1581 |
if (!$termset->toc_hidden) { |
if (!$termset->toc_hidden) { |
| 1582 |
$tree->children = taxonomy_dss_get_tree_children($termset->terms['tids'], $children, $termset->toc_depth); |
$tree->children = taxonomy_dss_get_tree_children($terms['tids'], $children, $termset->toc_depth); |
| 1583 |
$tree->count = count($tree->children); |
$tree->count = count($tree->children); |
| 1584 |
} |
} |
| 1585 |
else { |
else { |
| 1587 |
$tree->count = 0; |
$tree->count = 0; |
| 1588 |
} |
} |
| 1589 |
if (!$termset->lst_hidden) { |
if (!$termset->lst_hidden) { |
| 1590 |
$tree->nodes = _taxonomy_dss_get_tree_nodes($tids, $nodes); |
$tree->nodes = _taxonomy_dss_get_tree_nodes($termset->tids, $nodes); |
| 1591 |
} |
} |
| 1592 |
else { |
else { |
| 1593 |
$tree->nodes = array(); |
$tree->nodes = array(); |
| 1594 |
} |
} |
| 1595 |
|
|
| 1596 |
// Output the toc |
// Output the toc |
| 1597 |
$termset->content['tree'] = array( |
$content['tree'] = array( |
| 1598 |
'#value' => theme('taxonomy_dss_term_toc', $tree, 0, $termset->toc_nodecount), |
'#value' => theme('taxonomy_dss_term_toc', $tree, 0, $termset->toc_nodecount), |
| 1599 |
'#weight' => 5, |
'#weight' => 5, |
| 1600 |
); |
); |
| 1602 |
// Output the nodes |
// Output the nodes |
| 1603 |
if (!$termset->lst_hidden) { |
if (!$termset->lst_hidden) { |
| 1604 |
if (count($tree->nodes)) { |
if (count($tree->nodes)) { |
| 1605 |
$termset->content['nodes'] = array( |
$content['nodes'] = array( |
| 1606 |
'#value' => theme('taxonomy_dss_term_nodes', $tree, 0, $termset->lst_teasers_hidden), |
'#value' => theme('taxonomy_dss_term_nodes', $tree, 0, $termset->lst_teasers_hidden), |
| 1607 |
'#weight' => 6, |
'#weight' => 6, |
| 1608 |
); |
); |
| 1609 |
} |
} |
| 1610 |
if (!count($tree->nodes) || !$termset->content['nodes']['#value']) { |
if (count($tree->nodes) == 0 || empty($content['nodes']['#value'])) { |
| 1611 |
$termset->content['nodes'] = array( |
$content['nodes'] = array( |
| 1612 |
'#value' => '<div class="taxonomy-dss-nodes">'."\n".'<p class="taxonomy-dss-nodes-none">'. t('There are currently no posts in this category.') .'</p>'."\n".'</div>'."\n", |
'#value' => '<div class="taxonomy-dss-nodes">'."\n".'<p class="taxonomy-dss-nodes-none">'. t('There are currently no posts in this category.') .'</p>'."\n".'</div>'."\n", |
| 1613 |
'#weight' => 6, |
'#weight' => 6, |
| 1614 |
); |
); |
| 1616 |
} |
} |
| 1617 |
} |
} |
| 1618 |
|
|
| 1619 |
// Allow modules to make their own additions to the node. |
// Allow modules to modify the fully-built termset. |
| 1620 |
taxonomy_dss_invoke($termset, $op); |
taxonomy_dss_invoke($termset, 'build content', $content); |
|
} |
|
|
|
|
|
/** |
|
|
* Build the termset's standard elements. |
|
|
*/ |
|
|
function taxonomy_dss_prepare($termset) { |
|
|
$termset->content = array(); |
|
| 1621 |
|
|
| 1622 |
$termset->content['body'] = array( |
return $content; |
|
'#value' => $termset->body, |
|
|
'#weight' => 0, |
|
|
); |
|
|
|
|
|
return $termset; |
|
|
} |
|
|
|
|
|
function taxonomy_dss_load($tids) { |
|
|
if (is_array($tids)) { |
|
|
$tids = implode(',', $tids); |
|
|
} |
|
|
|
|
|
// Do some cleanup |
|
|
$terms = taxonomy_dss_terms_parse_string($tids); |
|
|
|
|
|
$termset = taxonomy_dss_get_termset_data(implode(',', $terms['tids'])); |
|
|
$termset->terms = $terms; |
|
|
$termset->title = check_plain(end($termset->terms['names'])); |
|
|
|
|
|
// Allow other modules to alter the data |
|
|
taxonomy_dss_invoke($termset, 'load'); |
|
|
|
|
|
return $termset; |
|
|
} |
|
|
|
|
|
function taxonomy_dss_node_to_termset($tids, $node) { |
|
|
$terms = taxonomy_dss_terms_parse_string($tids); |
|
|
|
|
|
$termset = new StdClass; |
|
|
$termset->tids = implode(',', $terms['tids']); |
|
|
$termset->nid = $node->nid; |
|
|
$termset->hidden = $node->hidden; |
|
|
$termset->toc_hidden = $node->toc_hidden; |
|
|
$termset->toc_depth = $node->toc_depth; |
|
|
$termset->toc_nodecount = $node->toc_nodecount; |
|
|
$termset->lst_hidden = $node->lst_hidden; |
|
|
$termset->lst_teasers_hidden = $node->lst_teasers_hidden; |
|
|
$termset->serial_data = array(); |
|
|
|
|
|
$termset->terms = $terms; |
|
|
$termset->title = check_plain(end($termset->terms['names'])); |
|
|
|
|
|
return $termset; |
|
| 1623 |
} |
} |
| 1624 |
|
|
| 1625 |
/** |
/** |
| 1635 |
|
|
| 1636 |
if (count($terms['tids']) && count($terms['names'])) { |
if (count($terms['tids']) && count($terms['names'])) { |
| 1637 |
// Initialize termset object. |
// Initialize termset object. |
| 1638 |
$termset = taxonomy_dss_load($terms['tids']); |
$termset = taxonomy_dss_load_termset($terms['tids']); |
| 1639 |
|
|
| 1640 |
switch ($op) { |
switch ($op) { |
| 1641 |
case 'page': |
case 'page': |
| 1642 |
// Build the different parts of the termset |
// If a node exists for this termset, forward to it |
| 1643 |
taxonomy_dss_build_content($termset, $op, $depth); |
if (!empty($termset->nid)) { |
| 1644 |
|
drupal_goto('node/'. $termset->nid); |
| 1645 |
// Render the body. |
} |
| 1646 |
$termset->body = drupal_render($termset->content); |
else { |
| 1647 |
|
// Need to see about passing depth as an arg() |
| 1648 |
|
$depth = 0; |
| 1649 |
|
|
| 1650 |
// Allow modules to modify the fully-built termset. |
$title = check_plain(end($terms['names'])); |
|
taxonomy_dss_invoke($termset, 'alter'); |
|
| 1651 |
|
|
| 1652 |
|
$content = taxonomy_dss_build_content($termset, $depth); |
| 1653 |
|
|
| 1654 |
// Fix the title |
// Fix the title |
| 1655 |
drupal_set_title($termset->title); |
drupal_set_title($title); |
| 1656 |
|
|
| 1657 |
// Build breadcrumb in order of tids |
// Build breadcrumb in order of tids |
| 1658 |
$breadcrumb = taxonomy_dss_generate_breadcrumb($termset->terms['tids'], $termset->terms['names']); |
$breadcrumb = taxonomy_dss_generate_breadcrumb($terms['tids'], $terms['names']); |
| 1659 |
menu_set_location($breadcrumb); |
menu_set_location($breadcrumb); |
| 1660 |
taxonomy_dss_set_breadcrumb($breadcrumb); |
taxonomy_dss_set_breadcrumb($breadcrumb); |
| 1661 |
|
|
| 1662 |
// Add RSS feed icon |
// Add RSS feed icon |
| 1663 |
if (drupal_is_front_page()) { |
if (drupal_is_front_page()) { |
| 1664 |
$feed_url = url('rss.xml', NULL, NULL, TRUE); |
$feed_url = url('rss.xml', NULL, NULL, TRUE); |
| 1665 |
drupal_add_feed($feed_url, variable_get('site_name', 'Drupal') .' '. t('RSS')); |
drupal_add_feed($feed_url, variable_get('site_name', 'Drupal') .' '. t('RSS')); |
| 1666 |
} |
} |
| 1667 |
else { |
else { |
| 1668 |
drupal_add_feed(url('taxonomy/term/'. $str_tids .'/'. $depth .'/feed'), 'RSS - '. $termset->title); |
drupal_add_feed(url('taxonomy/term/'. $termset->tids .'/'. $depth .'/feed'), t('RSS') .' - '. $title); |
| 1669 |
} |
} |
| 1670 |
|
|
| 1671 |
// Add custom CSS |
// Add custom CSS |
| 1672 |
drupal_add_css(drupal_get_path('module', 'taxonomy_dss') .'/taxonomy_dss.css'); |
drupal_add_css(drupal_get_path('module', 'taxonomy_dss') .'/taxonomy_dss.css'); |
| 1673 |
|
|
| 1674 |
// Make the output themeable. |
// Render the body. |
| 1675 |
return theme('taxonomy_dss_term_page', $termset); |
return drupal_render($content); |
| 1676 |
|
} |
| 1677 |
|
|
| 1678 |
case 'feed': |
case 'feed': |
| 1679 |
$term = taxonomy_get_term($termset->terms['tids'][0]); |
$term = taxonomy_get_term($terms['tids'][0]); |
| 1680 |
|
|
| 1681 |
$channel['link'] = url('taxonomy/term/'. $str_tids .'/'. $depth, NULL, NULL, TRUE); |
$channel['link'] = url('taxonomy/term/'. $str_tids .'/'. $depth, NULL, NULL, TRUE); |
| 1682 |
$channel['title'] = variable_get('site_name', 'Drupal') .' - '. $title; |
$channel['title'] = variable_get('site_name', 'Drupal') .' - '. $title; |
| 1683 |
$channel['description'] = $term->description; |
$channel['description'] = $term->description; |
| 1684 |
|
|
| 1685 |
$result = taxonomy_select_nodes($termset->terms['tids'], $termset->terms['operator'], $depth, FALSE); |
$result = taxonomy_select_nodes($terms['tids'], $terms['operator'], $depth, FALSE); |
| 1686 |
|
|
| 1687 |
node_feed($result, $channel); |
node_feed($result, $channel); |
| 1688 |
break; |
break; |
| 1689 |
|
|
| 1696 |
} |
} |
| 1697 |
} |
} |
| 1698 |
|
|
| 1699 |
|
|
| 1700 |
|
/** |
| 1701 |
|
* Theme for displaying the taxonomy term page's body. |
| 1702 |
|
* |
| 1703 |
|
* @ingroup themeable |
| 1704 |
|
*/ |
| 1705 |
|
function theme_taxonomy_dss_body($node) { |
| 1706 |
|
return '<div class="taxonomy-dss-node">'. $node->body .'</div>'; |
| 1707 |
|
} |
| 1708 |
|
|
| 1709 |
|
/** |
| 1710 |
|
* Theme for displaying links in the taxonomy page's table of contents. |
| 1711 |
|
* |
| 1712 |
|
* @ingroup themeable |
| 1713 |
|
*/ |
| 1714 |
|
function theme_taxonomy_dss_term_link($term, $show_count = FALSE, $current = FALSE) { |
| 1715 |
|
if ($current) { |
| 1716 |
|
$attributes = array('class' => 'active-trail'); |
| 1717 |
|
} |
| 1718 |
|
else { |
| 1719 |
|
$attributes = array(); |
| 1720 |
|
} |
| 1721 |
|
|
| 1722 |
|
return l($term->name, $term->link, $attributes) .($show_count ? ' <span class="taxonomy-dss-term-count">('. $term->count .')</span>' : ''); |
| 1723 |
|
} |
| 1724 |
|
|
| 1725 |
|
/** |
| 1726 |
|
* Theme for displaying the taxonomy page's table of contents. |
| 1727 |
|
* |
| 1728 |
|
* @ingroup themeable |
| 1729 |
|
*/ |
| 1730 |
|
function theme_taxonomy_dss_term_toc($tree, $depth = 0, $show_count = FALSE) { |
| 1731 |
|
$ouput = ''; |
| 1732 |
|
|
| 1733 |
|
// Render tree of child terms |
| 1734 |
|
if (count($tree->children)) { |
| 1735 |
|
if ($depth == 0) { |
| 1736 |
|
$output .= '<div class="taxonomy-dss-terms">'."\n"; |
| 1737 |
|
} |
| 1738 |
|
|
| 1739 |
|
$output .= '<ul class="menu">'."\n"; |
| 1740 |
|
foreach ($tree->children as $term) { |
| 1741 |
|
if ($term->hidden) { |
| 1742 |
|
// skip it |
| 1743 |
|
} |
| 1744 |
|
elseif (!isset($term->children)) { |
| 1745 |
|
$output .= '<li class="leaf">'. theme('taxonomy_dss_term_link', $term, $show_count) .'</li>'."\n"; |
| 1746 |
|
} |
| 1747 |
|
elseif (count($term->children)) { |
| 1748 |
|
$output .= '<li class="expanded">'. theme('taxonomy_dss_term_link', $term, $show_count) ."\n"; |
| 1749 |
|
$output .= theme('taxonomy_dss_term_toc', $term, $depth + 1, $show_count); |
| 1750 |
|
$output .= '</li>'."\n"; |
| 1751 |
|
} |
| 1752 |
|
else { |
| 1753 |
|
$output .= '<li class="collapsed">'. theme('taxonomy_dss_term_link', $term, $show_count) .'</li>'."\n"; |
| 1754 |
|
} |
| 1755 |
|
} |
| 1756 |
|
$output .= '</ul>'."\n"; |
| 1757 |
|
|
| 1758 |
|
if ($depth == 0) { |
| 1759 |
|
$output .= '</div>'."\n"; |
| 1760 |
|
} |
| 1761 |
|
} |
| 1762 |
|
|
| 1763 |
|
return $output; |
| 1764 |
|
} |
| 1765 |
|
|
| 1766 |
/** |
/** |
| 1767 |
* Theme for displaying the taxonomy term page. |
* Theme for displaying the taxonomy term page's node listing. |
| 1768 |
* |
* |
| 1769 |
* @ingroup themeable |
* @ingroup themeable |
| 1770 |
*/ |
*/ |
| 1771 |
function theme_taxonomy_dss_term_page($termset) { |
function theme_taxonomy_dss_term_nodes($tree, $depth = 0, $hide_teasers = FALSE) { |
| 1772 |
return $termset->body; |
$ouput = ''; |
| 1773 |
|
|
| 1774 |
|
// Render associated nodes |
| 1775 |
|
if ($depth == 0 && count($tree->nodes)) { |
| 1776 |
|
$output .= '<div class="taxonomy-dss-nodes">'."\n"; |
| 1777 |
|
if ($hide_teasers) { |
| 1778 |
|
$output .= '<ul>'; |
| 1779 |
|
foreach ($tree->nodes as $node) { |
| 1780 |
|
// Allow modules to modify the fully-built node. |
| 1781 |
|
node_invoke_nodeapi($node, 'alter', TRUE, FALSE); |
| 1782 |
|
|
| 1783 |
|
// Hack to get proper links. Really needs to be a core editable link, through hook_link_alter(). |
| 1784 |
|
$tids = taxonomy_dss_filter_tids($node->taxonomy, arg(2), TRUE); |
| 1785 |
|
$query = (count($tids) ? 'taxonomy='. implode(',', $tids) : ''); |
| 1786 |
|
|
| 1787 |
|
$output .= '<li>'. l($node->title, 'node/'.$node->nid, array(), $query ? $query : NULL) .'</li>'; |
| 1788 |
|
} |
| 1789 |
|
$output .= '</ul>'; |
| 1790 |
|
} |
| 1791 |
|
else { |
| 1792 |
|
foreach ($tree->nodes as $node) { |
| 1793 |
|
$output .= node_view($node, TRUE); |
| 1794 |
|
} |
| 1795 |
|
} |
| 1796 |
|
$output .= '</div>'."\n"; |
| 1797 |
|
|
| 1798 |
|
$output .= theme('pager', NULL, variable_get('default_nodes_main', 10), 0); |
| 1799 |
|
} |
| 1800 |
|
|
| 1801 |
|
return $output; |
| 1802 |
} |
} |