/** * Construct an array of folders that can be translated to * a JSON object * * @param array $folder_obj container for folders * @param string $folder_name display name for the folder object * * @return array * * @author Ken Auberry <*****@*****.**> */ function format_folder_object_json($folder_obj, $folder_name) { $output = array(); if (array_key_exists('folders', $folder_obj)) { foreach ($folder_obj['folders'] as $folder_entry => $folder_tree) { $folder_output = array('title' => $folder_entry, 'folder' => TRUE); $children = format_folder_object_json($folder_tree, $folder_entry); if (!empty($children)) { foreach ($children as $child) { $folder_output['children'][] = $child; } } $output[] = $folder_output; } } if (array_key_exists('files', $folder_obj)) { foreach ($folder_obj['files'] as $item_id => $file_entry) { $output[] = array('title' => $file_entry, 'key' => "ft_item_{$item_id}"); } } return $output; }
/** * Get Lazy Load Folder * * @return void */ public function get_lazy_load_folder() { if (!$this->input->post('parent')) { echo ''; return; } $node = intval(str_replace('treeData_', '', $this->input->post('parent'))); $treelist = $this->status->get_files_for_transaction($node); $output_array = format_folder_object_json($treelist['treelist'], 'test'); transmit_array_with_json_header($output_array); }