Added type attribute to adjustment reasons and fixed some bugs in manual EOB posting
[openemr.git] / controllers / C_Document.class.php
blobceac67df24c9f5089309d4b3ac2effd6d99a1281
1 <?php
2 // This program is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU General Public License
4 // as published by the Free Software Foundation; either version 2
5 // of the License, or (at your option) any later version.
7 require_once(dirname(__FILE__) . "/../library/classes/Controller.class.php");
8 require_once(dirname(__FILE__) . "/../library/classes/Document.class.php");
9 require_once(dirname(__FILE__) . "/../library/classes/CategoryTree.class.php");
10 require_once(dirname(__FILE__) . "/../library/classes/TreeMenu.php");
11 require_once(dirname(__FILE__) . "/../library/classes/Note.class.php");
13 class C_Document extends Controller {
15 var $template_mod;
16 var $documents;
17 var $document_categories;
18 var $tree;
19 var $_config;
20 var $file_path;
23 function C_Document($template_mod = "general") {
24 parent::Controller();
25 $this->documents = array();
26 $this->template_mod = $template_mod;
27 $this->assign("FORM_ACTION", $GLOBALS['webroot']."/controller.php?" . $_SERVER['QUERY_STRING']);
28 $this->assign("CURRENT_ACTION", $GLOBALS['webroot']."/controller.php?" . "document&");
30 //get global config options for this namespace
31 $this->_config = $GLOBALS['oer_config']['documents'];
33 $this->file_path = $this->_config['repository'] . preg_replace("/[^A-Za-z0-9]/","_",$_GET['patient_id']) . "/";
35 $this->_args = array("patient_id" => $_GET['patient_id']);
37 $this->assign("STYLE", $GLOBALS['style']);
38 $t = new CategoryTree(1);
39 //print_r($t->tree);
40 $this->tree = $t;
43 function upload_action($patient_id,$category_id) {
44 $category_name = $this->tree->get_node_name($category_id);
45 $this->assign("category_id", $category_id);
46 $this->assign("category_name", $category_name);
47 $this->assign("patient_id", $patient_id);
48 $activity = $this->fetch($GLOBALS['template_dir'] . "documents/" . $this->template_mod . "_upload.html");
49 $this->assign("activity", $activity);
50 return $this->list_action($patient_id);
53 function upload_action_process() {
55 if ($_POST['process'] != "true")
56 return;
58 if (is_numeric($_POST['category_id'])) {
59 $category_id = $_POST['category_id'];
61 if (is_numeric($_POST['patient_id'])) {
62 $patient_id = $_POST['patient_id'];
65 foreach ($_FILES as $file) {
66 $fname = $file['name'];
67 $err = "";
68 if ($file['error'] > 0 || empty($file['name']) || $file['size'] == 0) {
69 $fname = $file['name'];
70 if (empty($fname)) {
71 $fname = htmlentities("<empty>");
73 $error = "Error number: " . $file['error'] . " occured while uploading file named: " . $fname . "\n";
74 if ($file['size'] == 0) {
75 $error .= "The system does not permit uploading files of with size 0.\n";
79 else {
81 if (!file_exists($this->file_path)) {
82 if (!mkdir($this->file_path,0700)) {
83 $error .= "The system was unable to create the directory for this upload, '" . $this->file_path . "'.\n";
87 $fname = preg_replace("/[^a-zA-Z0-9_.]/","_",$fname);
88 if (file_exists($this->file_path.$file['name'])) {
89 $error .= xl('File with same name already exists at location:','','',' ') . $this->file_path . "\n";
90 $fname = basename($this->_rename_file($this->file_path.$file['name']));
91 $file['name'] = $fname;
92 $error .= xl('Current file name was changed to','','',' ') . $fname ."\n";
94 if (move_uploaded_file($file['tmp_name'],$this->file_path.$file['name'])) {
95 $this->assign("upload_success", "true");
96 $d = new Document();
97 $d->url = "file://" .$this->file_path.$file['name'];
98 $d->mimetype = $file['type'];
99 $d->size = $file['size'];
100 $d->type = $d->type_array['file_url'];
101 $d->set_foreign_id($patient_id);
102 $d->persist();
103 $d->populate();
104 $this->assign("file",$d);
106 if (is_numeric($d->get_id()) && is_numeric($category_id)) {
107 $sql = "REPLACE INTO categories_to_documents set category_id = '" . $category_id . "', document_id = '" . $d->get_id() . "'";
108 $d->_db->Execute($sql);
111 else {
112 $error .= "The file could not be succesfully stored, this error is usually related to permissions problems on the storage system.\n";
116 $this->assign("error", nl2br($error));
117 //$this->_state = false;
118 $_POST['process'] = "";
119 //return $this->fetch($GLOBALS['template_dir'] . "documents/" . $this->template_mod . "_upload.html");
122 function note_action_process($patient_id) {
124 if ($_POST['process'] != "true")
125 return;
127 $n = new Note();
128 parent::populate_object($n);
129 $n->persist();
131 $this->_state = false;
132 $_POST['process'] = "";
133 return $this->view_action($patient_id,$n->get_foreign_id());
136 function default_action() {
137 return $this->list_action();
140 function view_action($patient_id="",$doc_id) {
141 // Added by Rod to support document delete:
142 global $gacl_object, $phpgacl_location;
143 global $ISSUE_TYPES;
145 require_once(dirname(__FILE__) . "/../library/acl.inc");
146 require_once(dirname(__FILE__) . "/../library/lists.inc");
148 $d = new Document($doc_id);
149 $n = new Note();
151 $notes = $n->notes_factory($doc_id);
153 $this->assign("file", $d);
154 $this->assign("web_path", $this->_link("retrieve") . "document_id=" . $d->get_id() . "&");
155 $this->assign("NOTE_ACTION",$this->_link("note"));
156 $this->assign("MOVE_ACTION",$this->_link("move") . "document_id=" . $d->get_id() . "&process=true");
158 // Added by Rod to support document delete:
159 $delete_string = '';
160 if (acl_check('admin', 'super')) {
161 $delete_string = "<a href='' class='css_button' onclick='return deleteme(" . $d->get_id() .
162 ")'><span><font color='red'>" . xl('Delete') . "</font></span></a>";
164 $this->assign("delete_string", $delete_string);
165 $this->assign("REFRESH_ACTION",$this->_link("list"));
167 // Added by Rod to support document date update:
168 $this->assign("DOCDATE", $d->get_docdate());
169 $this->assign("UPDATE_ACTION",$this->_link("update") .
170 "document_id=" . $d->get_id() . "&process=true");
172 // Added by Rod to support document issue update:
173 $issues_options = "<option value='0'>-- " . xl('Select Issue') . " --</option>";
174 $ires = sqlStatement("SELECT id, type, title, begdate FROM lists WHERE " .
175 "pid = $patient_id " . // AND enddate IS NULL " .
176 "ORDER BY type, begdate");
177 while ($irow = sqlFetchArray($ires)) {
178 $desc = $irow['type'];
179 if ($ISSUE_TYPES[$desc]) $desc = $ISSUE_TYPES[$desc][2];
180 $desc .= ": " . $irow['begdate'] . " " . htmlspecialchars(substr($irow['title'], 0, 40));
181 $sel = ($irow['id'] == $d->get_list_id()) ? ' selected' : '';
182 $issues_options .= "<option value='" . $irow['id'] . "'$sel>$desc</option>";
184 $this->assign("ISSUES_LIST", $issues_options);
186 $this->assign("notes",$notes);
188 $this->_last_node = null;
190 $menu = new HTML_TreeMenu();
192 //pass an empty array because we don't want the documents for each category showing up in this list box
193 $rnode = $this->_array_recurse($this->tree->tree,array());
194 $menu->addItem($rnode);
195 $treeMenu_listbox = &new HTML_TreeMenu_Listbox($menu, array("promoText" => xl('Move Document to Category:')));
197 $this->assign("tree_html_listbox",$treeMenu_listbox->toHTML());
199 $activity = $this->fetch($GLOBALS['template_dir'] . "documents/" . $this->template_mod . "_view.html");
200 $this->assign("activity", $activity);
202 return $this->list_action($patient_id);
205 function retrieve_action($patient_id="",$document_id,$as_file=true,$original_file=true) {
207 //controller function ruins booleans, so need to manually re-convert to booleans
208 if ($as_file == "true") {
209 $as_file=true;
211 else if ($as_file == "false") {
212 $as_file=false;
214 if ($original_file == "true") {
215 $original_file=true;
217 else if ($original_file == "false") {
218 $original_file=false;
221 $d = new Document($document_id);
222 $url = $d->get_url();
224 //strip url of protocol handler
225 $url = preg_replace("|^(.*)://|","",$url);
227 //change full path to current webroot. this is for documents that may have
228 //been moved from a different filesystem and the full path in the database
229 //is not current. this is also for documents that may of been moved to
230 //different patients
231 // NOTE that $from_filename and basename($url) are the same thing
232 $from_all = explode("/",$url);
233 $from_filename = array_pop($from_all);
234 $from_patientid = array_pop($from_all);
235 $temp_url = $GLOBALS['OE_SITE_DIR'] . '/documents/' . $from_patientid . '/' . $from_filename;
236 if (file_exists($temp_url)) {
237 $url = $temp_url;
239 if (!file_exists($url)) {
240 echo xl('The requested document is not present at the expected location on the filesystem or there are not sufficient permissions to access it.','','',' ') . $url;
242 else {
243 if ($original_file) {
244 //normal case when serving the file referenced in database
245 header("Pragma: public");
246 header("Expires: 0");
247 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
248 header("Content-Disposition: " . ($as_file ? "attachment" : "inline") . "; filename=\"" . basename($d->get_url()) . "\"");
249 header("Content-Type: " . $d->get_mimetype());
250 header("Content-Length: " . $d->get_size());
251 $f = fopen($url,"r");
252 fpassthru($f);
253 exit;
255 else {
256 //special case when retrieving a document that has been converted to a jpg and not directly referenced in database
257 $convertedFile = substr(basename($url), 0, strrpos(basename($url), '.')) . '_converted.jpg';
258 $url = $GLOBALS['OE_SITE_DIR'] . '/documents/' . $from_patientid . '/' . $convertedFile;
259 header("Pragma: public");
260 header("Expires: 0");
261 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
262 header("Content-Disposition: " . ($as_file ? "attachment" : "inline") . "; filename=\"" . basename($url) . "\"");
263 header("Content-Type: image/jpeg");
264 header("Content-Length: " . filesize($url));
265 $f = fopen($url,"r");
266 fpassthru($f);
267 exit;
272 function queue_action($patient_id="") {
273 $messages = $this->_tpl_vars['messages'];
274 $queue_files = array();
276 //see if the repository exists and it is a directory else error
277 if (file_exists($this->_config['repository']) && is_dir($this->_config['repository'])) {
278 $dir = opendir($this->_config['repository']);
279 //read each entry in the directory
280 while (($file = readdir($dir)) !== false) {
281 //concat the filename and path
282 $file = $this->_config['repository'] .$file;
283 $file_info = array();
284 //if the filename is a file get its info and put into a tmp array
285 if (is_file($file) && strpos(basename($file),".") !== 0) {
286 $file_info['filename'] = basename($file);
287 $file_info['mtime'] = date("m/d/Y H:i:s",filemtime($file));
288 $d = Document::document_factory_url("file://" . $file);
289 preg_match("/^([0-9]+)_/",basename($file),$patient_match);
290 $file_info['patient_id'] = $patient_match[1];
291 $file_info['document_id'] = $d->get_id();
292 $file_info['web_path'] = $this->_link("retrieve",true) . "document_id=" . $d->get_id() . "&";
294 //merge the tmp array into the larger array
295 $queue_files[] = $file_info;
298 closedir($dir);
300 else {
301 $messages .= "The repository directory does not exist, it is not a directory or there are not sufficient permissions to access it. '" . $this->config['repository'] . "'\n";
305 $this->assign("queue_files",$queue_files);
306 $this->_last_node = null;
308 $menu = new HTML_TreeMenu();
310 //pass an empty array because we don't want the documents for each category showing up in this list box
311 $rnode = $this->_array_recurse($this->tree->tree,array());
312 $menu->addItem($rnode);
313 $treeMenu_listbox = &new HTML_TreeMenu_Listbox($menu, array());
315 $this->assign("tree_html_listbox",$treeMenu_listbox->toHTML());
317 $this->assign("messages",nl2br($messages));
318 return $this->fetch($GLOBALS['template_dir'] . "documents/" . $this->template_mod . "_queue.html");
321 function queue_action_process() {
322 if ($_POST['process'] != "true")
323 return;
325 $messages = $this->_tpl_vars['messages'];
327 //build a category tree so we can have a list of category ids that are valid
328 $ct = new CategoryTree(1);
329 $categories = $ct->_id_name;
331 //see if there were and posted files and assign them
332 $files = null;
333 is_array($_POST['files']) ? $files = $_POST['files']: $files = array();
335 //loop through posted files
336 foreach($files as $doc_id=> $file) {
337 //only operate on files checked as active
338 if (!$file['active']) continue;
340 //run basic validation checks
341 if (!is_numeric($file['patient_id']) || !is_numeric($file['category_id']) || !is_numeric($doc_id)) {
342 $messages .= "Error processing file '" . $file['name'] ."' the patient id must be a number and the category must exist.\n";
343 continue;
346 //validate that the pod exists
347 $d = new Document($doc_id);
348 $sql = "SELECT pid from patient_data where pubpid = '" . $file['patient_id'] . "'";
349 $result = $d->_db->Execute($sql);
351 if (!$result || $result->EOF) {
352 //patient id does not exist
353 $messages .= "Error processing file '" . $file['name'] ." the specified patient id '" . $file['patient_id'] . "' could not be found.\n";
354 continue;
357 //validate that the category id exists
358 if (!isset($categories[$file['category_id']])) {
359 $messages .= "Error processing file '" . $file['name'] . " the specified category with id '" . $file['category_id'] . "' could not be found.\n";
360 continue;
363 //now do the work of moving the file
364 $new_path = $this->_config['repository'] . $file['patient_id'] ."/";
366 //see if the patient dir exists in the repository and create if not
367 if (!file_exists($new_path)) {
368 if (!mkdir($new_path,0700)) {
369 $messages .= "The system was unable to create the directory for this upload, '" . $this->file_path . "'.\n";
370 continue;
374 //fname is the name of the file after it is moved
375 $fname = $file['name'];
377 //see if patient autonumbering is used in this filename, if so strip out the autonumber part
378 preg_match("/^([0-9]+)_/",basename($fname),$patient_match);
379 if ($patient_match[1] == $file['patient_id']) {
380 $fname = preg_replace("/^([0-9]+)_/","",$fname);
383 //filenames should not have funny chars
384 $fname = preg_replace("/[^a-zA-Z0-9_.]/","_",$fname);
386 //see if there is an existing file with the same name and rename as necessary
387 if (file_exists($new_path.$file['name'])) {
388 $messages .= "File with same name already exists at location: " . $new_path . "\n";
389 $fname = basename($this->_rename_file($new_path.$file['name']));
390 $messages .= "Current file name was changed to " . $fname ."\n";
393 //now move the file
394 if (rename($this->_config['repository'].$file['name'],$new_path.$fname)) {
395 $messages .= "File " . $fname . " moved to patient id '" . $file['patient_id'] ."' and category '" . $categories[$file['category_id']]['name'] . "' successfully.\n";
396 $d->url = "file://" .$new_path.$fname;
397 $d->set_foreign_id($file['patient_id']);
398 $d->set_mimetype($mimetype);
399 $d->persist();
400 $d->populate();
402 if (is_numeric($d->get_id()) && is_numeric($file['category_id'])) {
403 $sql = "REPLACE INTO categories_to_documents set category_id = '" . $file['category_id'] . "', document_id = '" . $d->get_id() . "'";
404 $d->_db->Execute($sql);
407 else {
408 $error .= "The file could not be succesfully stored, this error is usually related to permissions problems on the storage system.\n";
411 $this->assign("messages",$messages);
412 $_POST['process'] = "";
415 function move_action_process($patient_id="",$document_id) {
416 if ($_POST['process'] != "true")
417 return;
419 $new_category_id = $_POST['new_category_id'];
420 $new_patient_id = $_POST['new_patient_id'];
422 //move to new category
423 if (is_numeric($new_category_id) && is_numeric($document_id)) {
424 $sql = "UPDATE categories_to_documents set category_id = '" . $new_category_id . "' where document_id = '" . $document_id ."'";
425 $messages .= xl('Document moved to new category','','',' \'') . $this->tree->_id_name[$new_category_id]['name'] . xl('successfully.','','\' ') . "\n";
426 //echo $sql;
427 $this->tree->_db->Execute($sql);
430 //move to new patient
431 if (is_numeric($new_patient_id) && is_numeric($document_id)) {
432 $d = new Document($document_id);
433 // $sql = "SELECT pid from patient_data where pubpid = '" . $new_patient_id . "'";
434 $sql = "SELECT pid from patient_data where pid = '" . $new_patient_id . "'";
435 $result = $d->_db->Execute($sql);
437 if (!$result || $result->EOF) {
438 //patient id does not exist
439 $messages .= xl('Document could not be moved to patient id','','',' \'') . $new_patient_id . xl('because that id does not exist.','','\' ') . "\n";
441 else {
442 //set the new patient
443 $d->set_foreign_id($new_patient_id);
444 $d->persist();
445 $this->_state = false;
446 $messages .= xl('Document moved to patient id','','',' \'') . $new_patient_id . xl('successfully.','','\' ') . "\n";
447 $this->assign("messages",$messages);
448 return $this->list_action($patient_id);
451 //in this case return the document to the queue instead of moving it
452 elseif (strtolower($new_patient_id) == "q" && is_numeric($document_id)) {
453 $d = new Document($document_id);
454 $new_path = $this->_config['repository'];
455 $fname = $d->get_url_file();
457 //see if there is an existing file with the same name and rename as necessary
458 if (file_exists($new_path.$d->get_url_file())) {
459 $messages .= "File with same name already exists in the queue.\n";
460 $fname = basename($this->_rename_file($new_path.$d->get_url_file()));
461 $messages .= "Current file name was changed to " . $fname ."\n";
464 //now move the file
465 if (rename($d->get_url_filepath(),$new_path.$fname)) {
466 $d->url = "file://" .$new_path.$fname;
467 $d->set_foreign_id("");
468 $d->persist();
469 $d->persist();
470 $d->populate();
472 $sql = "DELETE FROM categories_to_documents where document_id =" . $d->_db->qstr($document_id);
473 $d->_db->Execute($sql);
474 $messages .= "Document returned to queue successfully.\n";
477 else {
478 $messages .= "The file could not be succesfully stored, this error is usually related to permissions problems on the storage system.\n";
481 $this->_state = false;
482 $this->assign("messages",$messages);
483 return $this->list_action($patient_id);
486 $this->_state = false;
487 $this->assign("messages",$messages);
488 return $this->view_action($patient_id,$document_id);
491 // Added by Rod for metadata update.
493 function update_action_process($patient_id="", $document_id) {
494 if ($_POST['process'] != "true") {
495 die("process is '" . $_POST['process'] . "', expected 'true'");
496 return;
499 $docdate = $_POST['docdate'];
500 $issue_id = $_POST['issue_id'];
502 if (is_numeric($document_id)) {
503 if (preg_match('/^\d\d\d\d-\d+-\d+$/', $docdate)) {
504 $docdate = "'$docdate'";
505 } else {
506 $docdate = "NULL";
508 if (!is_numeric($issue_id)) {
509 $issue_id = 0;
511 $sql = "UPDATE documents SET docdate = $docdate, " .
512 "list_id = '$issue_id' " .
513 "WHERE id = '$document_id'";
514 $this->tree->_db->Execute($sql);
515 $messages .= xl('Document date and issue updated successfully') . "\n";
518 $this->_state = false;
519 $this->assign("messages", $messages);
520 return $this->view_action($patient_id, $document_id);
523 function list_action($patient_id = "") {
524 $this->_last_node = null;
525 $categories_list = $this->tree->_get_categories_array($patient_id);
526 //print_r($categories_list);
528 $menu = new HTML_TreeMenu();
529 $rnode = $this->_array_recurse($this->tree->tree,$categories_list);
530 $menu->addItem($rnode);
531 $treeMenu = &new HTML_TreeMenu_DHTML($menu, array('images' => 'images', 'defaultClass' => 'treeMenuDefault'));
532 $treeMenu_listbox = &new HTML_TreeMenu_Listbox($menu, array('linkTarget' => '_self'));
534 $this->assign("tree_html",$treeMenu->toHTML());
536 return $this->fetch($GLOBALS['template_dir'] . "documents/" . $this->template_mod . "_list.html");
540 * This is a recursive function to rename a file to something that doesn't already exist.
541 * Modified in version 3.2.0 to place a counter within the filename (previously was placed at end)
542 * to ensure documents opened correctly by external browser viewers. If the counter is at the
543 * end of the file, then will use it (to continue to work with older files), however all new
544 * counters will be placed within filenames.
546 function _rename_file($fname) {
547 $file = basename($fname);
548 $fparts = split("\.",$fname);
549 $path = dirname($fname);
550 if (count($fparts) > 1) {
551 if (is_numeric($fparts[count($fparts) -2]) && (count($fparts) > 2)) {
552 //increment the counter in filename
553 $fparts[count($fparts) -2] = $fparts[count($fparts) -2] + 1;
554 $fname = join(".",$fparts);
556 elseif (is_numeric($fparts[count($fparts) -1]) && $fparts[count($fparts) -1] < 1000) {
557 //increment counter at end of filename (so compatible with previous openemr version files
558 $fparts[count($fparts) -1] = $fparts[count($fparts) -1] + 1;
559 $fname = join(".",$fparts);
561 elseif (is_numeric($fparts[count($fparts) -1])) {
562 //leave date at end and place counter in filename
563 array_splice($fparts, -1, 0, "1");
564 $fname = join(".",$fparts);
566 else {
567 //add the counter to filename
568 array_splice($fparts, -1, 0, "1");
569 $fname = join(".",$fparts);
572 else { // (count($fparts) == 1)
573 //place counter at end of filename
574 array_push($fparts,"1");
575 $fname = join(".",$fparts);
578 if (file_exists($fname)) {
579 return $this->_rename_file($fname);
581 else {
582 return($fname);
586 function &_array_recurse($array,$categories = array()) {
587 if (!is_array($array)) {
588 $array = array();
590 $node = &$this->_last_node;
591 $current_node = &$node;
592 $expandedIcon = 'folder-expanded.gif';
593 foreach($array as $id => $ar) {
594 $icon = 'folder.gif';
595 if (is_array($ar) || !empty($id)) {
596 if ($node == null) {
597 //echo "r:" . $this->tree->get_node_name($id) . "<br>";
598 $rnode = new HTML_TreeNode(array("id" => $id, 'text' => $this->tree->get_node_name($id), 'link' => $this->_link("upload") . "parent_id=" . $id . "&", 'icon' => $icon, 'expandedIcon' => $expandedIcon, 'expanded' => false));
599 $this->_last_node = &$rnode;
600 $node = &$rnode;
601 $current_node =&$rnode;
603 else {
604 //echo "p:" . $this->tree->get_node_name($id) . "<br>";
605 $this->_last_node = &$node->addItem(new HTML_TreeNode(array("id" => $id, 'text' => $this->tree->get_node_name($id), 'link' => $this->_link("upload") . "parent_id=" . $id . "&", 'icon' => $icon, 'expandedIcon' => $expandedIcon)));
606 $current_node =&$this->_last_node;
609 $this->_array_recurse($ar,$categories);
611 else {
612 if ($id === 0 && !empty($ar)) {
613 $info = $this->tree->get_node_info($id);
614 //echo "b:" . $this->tree->get_node_name($id) . "<br>";
615 $current_node = &$node->addItem(new HTML_TreeNode(array("id" => $id, 'text' => $info['value'], 'link' => $this->_link("upload") . "parent_id=" . $id . "&", 'icon' => $icon, 'expandedIcon' => $expandedIcon)));
617 else {
618 //there is a third case that is implicit here when title === 0 and $ar is empty, in that case we do not want to do anything
619 //this conditional tree could be more efficient but working with recursive trees makes my head hurt, TODO
620 if ($id !== 0 && is_object($node)) {
621 //echo "n:" . $this->tree->get_node_name($id) . "<br>";
622 $current_node = &$node->addItem(new HTML_TreeNode(array("id" => $id, 'text' => $this->tree->get_node_name($id), 'link' => $this->_link("upload") . "parent_id=" . $id . "&", 'icon' => $icon, 'expandedIcon' => $expandedIcon)));
628 // If there are documents in this document category, then add their
629 // attributes to the current node.
630 $icon = "file3.png";
631 if (is_array($categories[$id])) {
632 foreach ($categories[$id] as $doc) {
633 $current_node->addItem(new HTML_TreeNode(array(
634 'text' => $doc['docdate'] . ' ' . basename($doc['url']),
635 'link' => $this->_link("view") . "doc_id=" . $doc['document_id'] . "&",
636 'icon' => $icon,
637 'expandedIcon' => $expandedIcon
638 )));
643 return $node;
647 //place to hold optional code
648 //$first_node = array_keys($t->tree);
649 //$first_node = $first_node[0];
650 //$node1 = new HTML_TreeNode(array('text' => $t->get_node_name($first_node), 'link' => "test.php", 'icon' => $icon, 'expandedIcon' => $expandedIcon, 'expanded' => true), array('onclick' => "alert('foo'); return false", 'onexpand' => "alert('Expanded')"));
652 //$this->_last_node = &$node1;