You are here

function tft_ajax_get_folder in Taxonomy File Tree 7.2

Same name and namespace in other branches
  1. 7 tft.ajax.inc \tft_ajax_get_folder()

Page callback: get folder content via AJAX.

Returns a JSON object with a 'data' key for the HTML table and a 'parent' key for the parent taxonomy term tid. A 'ops_links' key stores the folder menu.

1 string reference to 'tft_ajax_get_folder'
tft_menu in ./tft.module
Implementation of hook_menu().

File

includes/tft.ajax.inc, line 9

Code

function tft_ajax_get_folder() {
  $tid = isset($_GET['tid']) ? (int) $_GET['tid'] : NULL;
  watchdog('tid before', '<pre>' . print_r($tid, TRUE) . '</pre>');
  if (!isset($tid)) {
    return drupal_json_output(array(
      'error' => 1,
      'data' => t("No valid identifier received"),
    ));
  }
  elseif (!tft_term_access($tid)) {
    return drupal_json_output(array(
      'error' => 1,
      'data' => t("You do not have access to this folder."),
    ));
  }
  watchdog('tid after', '<pre>' . print_r($tid, TRUE) . '</pre>');
  $content = tft_content_table($tid);
  $parent = tft_get_parent_tid($tid);
  $add_content_links = tft_theme_add_content_links(tft_get_add_content_links($tid));
  $ops_links = tft_theme_folder_menu_links(tft_get_folder_menu_links($tid));
  drupal_json_output(array(
    'data' => $content,
    'add_content_links' => $add_content_links,
    'parent' => $parent,
    'ops_links' => $ops_links,
  ));
}