Changeset 91
- Timestamp:
- Apr 9, 2006 3:39:08 AM (18 years ago)
- Location:
- branches/1.1dev/lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.1dev/lib/Hierarchy.inc.php
r90 r91 354 354 $child_id =& $this->child_id; 355 355 } else { 356 logMsg(_("getParents failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);356 logMsg(_("getParents failed. Arguments not specified properly."), resource_tbl, __FILE__, __LINE__); 357 357 return false; 358 358 } … … 402 402 $child_id =& $this->child_id; 403 403 } else { 404 logMsg(_("getNode failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);404 logMsg(_("getNode failed. Arguments not specified properly."), resource_tbl, __FILE__, __LINE__); 405 405 return false; 406 406 } … … 408 408 409 409 $qid = dbQuery(" 410 SELECT child_type, child_id, title, subnode_quantity410 SELECT * 411 411 FROM node_tbl 412 412 WHERE child_type = '" . mysql_real_escape_string($child_type) . "' … … 443 443 $child_id =& $this->child_id; 444 444 } else { 445 logMsg(_("getChildren failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);445 logMsg(_("getChildren failed. Arguments not specified properly."), resource_tbl, __FILE__, __LINE__); 446 446 return false; 447 447 } … … 492 492 $child_id =& $this->child_id; 493 493 } else { 494 logMsg(_("getNumberChildren failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);494 logMsg(_("getNumberChildren failed. Arguments not specified properly."), resource_tbl, __FILE__, __LINE__); 495 495 return false; 496 496 } … … 530 530 $child_id =& $this->child_id; 531 531 } else { 532 logMsg(_("isLeaf failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);532 logMsg(_("isLeaf failed. Arguments not specified properly."), resource_tbl, __FILE__, __LINE__); 533 533 return false; 534 534 } … … 641 641 $child_id =& $this->child_id; 642 642 } else { 643 logMsg(_("nodeExists failed. Arguments not specified properly."), LOG_ERR, __FILE__, __LINE__);643 logMsg(_("nodeExists failed. Arguments not specified properly."), resource_tbl, __FILE__, __LINE__); 644 644 return false; 645 645 } … … 748 748 } 749 749 750 function convertListToTree($curr, $child_type=null, $child_id=null, $_ return_flag=true)750 function convertListToTree($curr, $child_type=null, $child_id=null, $_indent=0) 751 751 { 752 752 if (!is_array($curr) || empty($curr)) { … … 757 757 static $children_map; 758 758 static $node_map; 759 759 760 760 // The original $curr contains the full list. Save a copy of this. 761 761 if (!isset($orig)) { … … 765 765 $children_map = array(); 766 766 foreach ($orig as $i => $n) { 767 $n_parent = $this->toStringID($n['parent_type'], $n['parent_id']);767 $n_parent = ('' != $n['parent_type'] && '' != $n['parent_id']) ? $this->toStringID($n['parent_type'], $n['parent_id']) : 'null__00'; 768 768 $n_child = $this->toStringID($n['child_type'], $n['child_id']); 769 769 $children_map[$n_parent][] = $n_child; … … 786 786 } 787 787 } 788 788 789 if (!isset($curr['indent'])) { 790 $curr['indent'] = $_indent; 791 } 792 789 793 // Get children of current node. 790 794 $curr_str_id = $this->toStringID($curr['child_type'], $curr['child_id']); … … 794 798 if (!empty($curr_children)) { 795 799 foreach ($curr_children as $child) { 796 $curr['children'][] = $this->convertListToTree($orig[$node_map[$child]], null, null, false);797 } 798 } 799 800 if ($_ return_flag) {800 $curr['children'][] = $this->convertListToTree($orig[$node_map[$child]], null, null, $_indent + 1); 801 } 802 } 803 804 if ($_indent === 0) { 801 805 // We must reset the static variables so that they do 802 806 // not fill up during subsequent function calls. -
branches/1.1dev/lib/ScriptTimer.inc.php
r90 r91 7 7 class ScriptTimer { 8 8 9 var $time_format = '%.10f'; 10 var $_timing_start_times; 11 var $_timing_stop_times; 9 var $time_format = '%.10s'; 10 var $_timing_start_times = array(); 11 var $_timing_stop_times = array(); 12 var $_timing_cumulative_times = array(); 12 13 13 function start ($name ='default') {14 function start($name='default') { 14 15 $this->_timing_start_times[$name] = explode(' ', microtime()); 15 16 } 16 17 17 function stop($name ='default') {18 $this->_timing_ stop_times[$name] = explode(' ', microtime());18 function stop($name='default') { 19 $this->_timing_cumulative_times[$name] += $this->getTime($name); 19 20 } 20 21 21 function getTime($name ='default') {22 function getTime($name='default') { 22 23 if (!isset($this->_timing_start_times[$name])) { 23 24 return 0; … … 31 32 $current = $stop_time[1] - $this->_timing_start_times[$name][1]; 32 33 $current += $stop_time[0] - $this->_timing_start_times[$name][0]; 33 return sprintf($this->time_format, $current); 34 return $current; 35 } 36 37 function printAll($sort_by_time=false) 38 { 39 $names = array_map('strlen', array_keys($this->_timing_start_times)); 40 sort($names); 41 $name_len = end($names); 42 43 if ($sort_by_time) { 44 arsort($this->_timing_cumulative_times, SORT_NUMERIC); 45 } 46 47 $this->_timing_cumulative_times["TOTAL"] = array_sum($this->_timing_cumulative_times); 48 49 echo '<pre>'; 50 foreach ($this->_timing_cumulative_times as $name => $time) { 51 printf("\n%-{$name_len}s $this->time_format", $name, $time); 52 } 53 echo '</pre>'; 34 54 } 35 55 }
Note: See TracChangeset
for help on using the changeset viewer.