You are here

tft.ajax.inc in Taxonomy File Tree 7.2

File

includes/tft.ajax.inc
View source
<?php

/**
 * 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.
 */
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,
  ));
}

Functions

Namesort descending Description
tft_ajax_get_folder Page callback: get folder content via AJAX.