} $graph_2 = bar_graph($array_2, 300, $cfg['xml_lang']); // SQL : user agent //-------------------------------------------------------------------------------- $res_3 = mysql_query($sql_3) or die("Boo. " . mysql_error()); $array_3 = array(); while ($row = mysql_fetch_row($res_3)) { $count = $row[0]; $name = $row[1]; $array_3[$name] = $count; } $sum = array_sum($array_3); if ($hitrow > $sum) { $array_3['...Others (less than ' . $cfg['referer_limit_num'] . ' hits)'] = $hitrow - $sum; } $graph_3 = bar_graph($array_3, 300, $cfg['xml_lang']); // SQL : referer //-------------------------------------------------------------------------------- $res_4 = mysql_query($sql_4) or die("Boo. " . mysql_error()); $array_4 = array(); while ($row = mysql_fetch_row($res_4)) { $count = $row[0]; $name = $row[1]; $array_4[$name] = $count; } $sum = array_sum($array_4); if ($hitrow > $sum) { $array_4['...Others (less than ' . $cfg['referer_limit_num'] . ' hits)'] = $hitrow - $sum; } $graph_4 = bar_graph_with_link($array_4, 300, $cfg['xml_lang']); // SQL : Last 7 daily hits
function draw_table(&$data_array, $title, $filter, $project_table = '') { # data_array is potentially huge. Pass by reference explicitly global $debug_g, $current_session_g; $bug_statuses = explode(",", CT_BUG_STATUSES); $bug_severities = explode(",", CT_BUG_SEVERITIES); foreach ($bug_statuses as $status) { $status_counts[$status] = 0; } # ex. $status_counts["Closed"] foreach ($bug_severities as $severity) { $severity_counts[$severity] = 0; } # ex. $severity_counts["Fatal"] if ($debug_g) { print "<pre>"; var_dump($data_array); var_dump($filter); print "</pre>"; } if (!$data_array or !$title) { die("Fatal: Draw table passed no data array or title!"); } print '<script type="text/javascript" src="javascript/table_sort.js"> </script>'; print "\n\n<div id='pageTitle'>{$title}</div><br />\n"; $row_cnt = sizeof($data_array); # This is correct; We need original size. # Project Hot List Drop Down if ($project_table) { draw_project_hotlist_widget($project_table, $current_session_g["project"], "home"); } # Sort by $data_array by Project, Severity (desc), ID (bug lists only) $in = 'return strcasecmp($a["Project"].$b["Severity"].$a["ID"],'; $out = '$b["Project"].$a["Severity"].$b["ID"]);'; $f = $in . $out; usort($data_array, create_function('$a,$b', $f)); # EXTRACT COLUMN HEADINGS if ($title == 'Active Projects' or $title == 'Address Book') { $element_entry = array_keys($data_array[0]); } else { $element_entry = explode(",", CT_HOME_PAGE_DATA_COLUMNS); } # zztop -- got it, sweep all code to send project table on draw_table call # } # else # $element_entry = array_keys( $data_array[0] ); #zztop ? # $element_entry = explode(",", CT_HOME_PAGE_DATA_COLUMNS ); zztop Source of duplicate URL if (!$element_entry) { return; } # Build Generic Summary Table print "<div class='dataBlock'>\n"; print "<table id='results' cellspacing='1' border='0' width='100%' summary='Data Table'>\n"; print "<thead>\n\t<tr title='Click on column name to sort'>\n"; $hdr_cnt = 0; foreach ($element_entry as $column_name) { if ($column_name == 'Project' and !stristr($title, "All Projects")) { # zztop this is a kludge continue; } if ($column_name == 'Password') { continue; } if ($column_name == 'Assign_To') { $column_name = 'Assigned_To'; } if ($column_name == 'Developer_Response') { # zztop customization has it's costs... if (sizeof($project_table)) { foreach ($project_table as $tmp_proj) { if ($tmp_proj["Title"] == $current_session_g["project"]) { if (isset($tmp_proj["Preferred_Title"])) { $column_name = $tmp_proj["Preferred_Title"] . "_Response"; } break; } } } } print "\t\t<th onclick='SortTable(" . $hdr_cnt++ . ");'> " . strtr($column_name, "_", " ") . " </th>\n"; } print "\t</tr>\n</thead>\n<tbody>"; # WALK EACH NODE (BUG, USER, WHATEVER) THROUGH EACH OF ITS ELEMENTS $row_cnt = sizeof($data_array); $shown_row_cnt = 0; $delcnt = 0; for ($row = 0; $row < $row_cnt; $row++) { if (!$data_array[$row]["ID"]) { continue; } for ($j = 0; $j < $delcnt; $j++) { if ($data_array[$row]["ID"] == $already_shown[$delcnt]) { break; } else { $already_shown[$delcnt++] = $data_array[$row]["ID"]; } } if (isset($data_array["{$row}"]["Delete_Bug"])) { continue; } $display = TRUE; if ($filter) { foreach ($filter as $filter_column => $filter_value) { if ($filter_column == 'Project' and $filter_value == 'All') { continue; } # Don't fail looking for a project "all" if ($data_array[$row][$filter_column] != $filter_value) { $display = FALSE; break; } } } if ($display) { # Got one -- let's show it $highlight_class = ""; print "\t<tr" . ($shown_row_cnt % 2 ? " class='rowOdd'" : " class='rowEven'") . ">\n"; if (stristr($title, "issue")) { foreach ($bug_statuses as $status) { if ($data_array[$row]["Status"] == $status) { $status_counts[$status]++; } # ex. $status_counts["Closed"] } foreach ($bug_severities as $severity) { if ($data_array[$row]["Severity"] == $severity) { $severity_counts[$severity]++; } # ex. $severity_counts["Fatal"] } } foreach ($element_entry as $column) { if ($column == 'Project' and !stristr($title, "All Projects") or $column == 'Password') { # zztop kludge continue; } $data_array[$row][$column] = trim($data_array[$row][$column]); if ($project_table) { # Limit column size for bug-related tables (not user/proj) if (strlen($data_array[$row][$column]) > 40) { $data_array[$row][$column] = substr($data_array[$row][$column], 0, 40) . "..."; } } # If this is a designated (and populated) link entry, make it a link if ($title != "Address Book") { /* if ( ($column == "Attachment") and ($data_array[$row][$column]) ) { $data_array[$row][$column] = "<a href='attachments/" . $data_array[$row][$column] . "' target=_blank >{$data_array[$row][$column]}</a>" ; } */ if ($column == "ID" and $data_array[$row][$column]) { $accession = (int) $data_array[$row][$column]; if ($title == "Active Projects") { $data_array[$row][$column] = "<a href='codetrack.php" . "?page=changeproject&redir=home&project=" . urlencode($data_array[$row]["Title"]) . "'>{$data_array[$row][$column]}</a>"; } else { $data_array[$row][$column] = "<a href='codetrack.php" . "?page=viewissue&id=" . $data_array[$row][$column] . "'>{$data_array[$row][$column]}</a>"; } # Embed a numeric, sortable numeric-only comment so the column sort works # in human-order (lastNode value in table_sort.js) $data_array[$row][$column] .= '<!-- ' . $accession . ' -->'; } } # If developer has posted a response, highlight the status column if ($column == 'Status' and (!isset($data_array[$row]["Developer_Comment"]) and !isset($data_array[$row]["Developer_Response"]))) { $highlight_class = " class='devResponse'"; } # Embed a numeric, sortable Unix-style timestamp as an HTML comment, so the column sort js will use if ($column == 'Last_Updated' or $column == "Submit_Time") { $human_date = parse_human_date($data_array[$row][$column]); $unix_timestamp = strtotime($data_array[$row][$column]); $data_array[$row][$column] = $human_date . '<!-- ' . $unix_timestamp . ' -->'; } print "\t\t<td{$highlight_class}>"; print $data_array[$row][$column] ? $data_array[$row][$column] : ' '; print "</td>\n"; $highlight_class = ""; } print "\t</tr>\n"; $shown_row_cnt++; } } print "</tbody></table>\n</div>\n"; if (stristr($title, "issue")) { #zztop ? print "<span id='resultsTotal'>Total issues: {$shown_row_cnt} </span>"; if ($shown_row_cnt > 0) { print "\n<span id='resultsFooter'> (Oldest to newest, by severity. " . "Red status indicates response or comment needed.)</span><br /><br /><br /> \n"; print "<div class='graphTitle'> Count by Severity </div>\n"; bar_graph($severity_counts); print "<div class='graphTitle'> Count by Status </div>\n"; bar_graph($status_counts); } } }