コード例 #1
0
    if (array_key_exists('folder', $_GET)) {
        if (array_key_exists('parent', $_GET)) {
            if ($_GET['parent'] === 'default') {
                $parent = $GLOBALS['cfg_remote_path'];
            } else {
                $parent = $_GET['parent'];
            }
        } else {
            $parent = false;
        }
        if ($_GET['folder'] === 'default') {
            $path = $GLOBALS['cfg_remote_path'];
        } else {
            $path = $_GET['folder'];
        }
        $res = get_folder_contents(htmlspecialchars_decode($path), $parent);
    }
    if (array_key_exists('readxml', $_GET)) {
        $ddexml = new Ddexml($_GET['xml']);
        $res = $ddexml->xmlToJSON();
    }
    if (isset($res)) {
        $output['responseText'] = $res;
        $output['errors'] = $log->getErrors();
        sendResponse($output);
        die;
    }
}
if (isset($argv)) {
    //IF script is run from command line, call the command line job.
    $cmdmode = true;
コード例 #2
0
/**
 * Builds an array with the whole structure of the workspace suitable for jsTree
 * Called by an AJAX function, that returns the array as a alternative JSON file for jstree
 *
 * @param $sort_type the way the workspace is to be sorte
 */
function get_users_projects($sort_type)
{
    global $xerte_toolkits_site;
    $root_folder = get_user_root_folder();
    $workspace = new stdClass();
    $workspace->user = $_SESSION['toolkits_logon_id'];
    $workspace->items = array();
    /**
     * We've two toplevel icons
     * - Workspace
     * - Recyclebin
     */
    $workspace->workspace_id = "ID_" . $_SESSION['toolkits_logon_id'] . "_F" . get_user_root_folder();
    $item = new stdClass();
    $item->id = $workspace->workspace_id;
    $item->xot_id = get_user_root_folder();
    $item->parent = "#";
    $item->text = DISPLAY_WORKSPACE;
    $item->type = "workspace";
    $item->xot_type = "workspace";
    $state = new stdClass();
    $state->opened = true;
    $state->disabled = false;
    $state->selected = true;
    $item->state = $state;
    $workspace->items[] = $item;
    $workspace->nodes[$item->id] = $item;
    $items = get_folder_contents($item->xot_id, $item->id, $sort_type);
    if ($items) {
        $workspace->items = array_merge($workspace->items, $items);
        foreach ($items as $item) {
            $workspace->nodes[$item->id] = $item;
        }
    }
    $prefix = $xerte_toolkits_site->database_table_prefix;
    $query = "select folder_id from {$prefix}folderdetails where folder_name=? AND login_id = ?";
    $params = array("recyclebin", $_SESSION['toolkits_logon_id']);
    $row = db_query_one($query, $params);
    $workspace->recyclebin_id = "ID_" . $_SESSION['toolkits_logon_id'] . "_F" . $row['folder_id'];
    $item = new stdClass();
    $item->id = $workspace->recyclebin_id;
    $item->xot_id = $row['folder_id'];
    $item->parent = "#";
    $item->text = DISPLAY_RECYCLE;
    $item->type = "recyclebin";
    $item->xot_type = "recyclebin";
    $workspace->items[] = $item;
    $workspace->nodes[$item->id] = $item;
    $items = get_folder_contents($item->xot_id, $item->id, $sort_type);
    if ($items) {
        $workspace->items = array_merge($workspace->items, $items);
        foreach ($items as $item) {
            $workspace->nodes[$item->id] = $item;
        }
    }
    // setup the templates available in the installation , to determine the node types
    $query_for_blank_templates = "select * from {$prefix}originaltemplatesdetails order by date_uploaded DESC";
    $templates = array();
    $rows = db_query($query_for_blank_templates, array());
    foreach ($rows as $row) {
        $templates[] = strtolower($row['template_name']);
    }
    $workspace->templates = $templates;
    return json_encode($workspace);
}