From b2a103a05a1425e66e2c0a9948adeb20d8835e4b Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 10 Dec 2006 00:05:48 +0000 Subject: [PATCH] r1341: The basic workings of column ordering appear to now work --- includes/class_sort.php | 95 ++++++++++++++++++++++++++++++++++ includes/functions.php | 1 + includes/permissions.php | 2 +- index.php | 4 +- templates/trackerhome.tpl | 8 +-- templates/trackerhome_bits.tpl | 22 +------- 6 files changed, 102 insertions(+), 30 deletions(-) diff --git a/includes/class_sort.php b/includes/class_sort.php index 2bfc5b8..aa9fbe9 100644 --- a/includes/class_sort.php +++ b/includes/class_sort.php @@ -60,6 +60,12 @@ class ListSorter */ var $direction = ''; + /** + * Column array for table heads + * @var array + */ + var $columns; + // ################################################################### /** * Constructor: set the page name @@ -316,6 +322,95 @@ class ListSorter { return $this->direction; } + + // ################################################################### + /** + * Returns the HTML code for bug listing table column headers + * + * @param bool Include the sort links/image? + * @param string Additional GET params to pass to fetch_sort_link() + * + * @return string HTML code + */ + function constructColumnHeaders($sortable, $params = null) + { + $this->_processColumns(); + + $output = ''; + foreach ($this->columns AS $columns) + { + $build = array(); + foreach ($columns AS $column) + { + $build[] = ($sortable ? '' . $this->registry->columnNames["$column"] . '' : $this->registry->columnNames["$column"]); + } + $image = ($this->sortkey == $column ? $this->fetch_sort_image() : ''); + $name = implode(' / ', $build); + eval('$output .= "' . $this->registry->template->fetch('list_head') . '";'); + } + + return $output; + } + + // ################################################################### + /** + * Returns the HTML code for a row of data for the bug listing + * + * @param array Bug data array + * @param string Additional link params + * + * @return string Row HTML + */ + function constructRow($bug, $params = null) + { + $this->_processColumns(); + + foreach ($this->columns AS $columns) + { + if (sizeof($columns) > 1) + { + $build = array(); + foreach ($columns AS $column) + { + $build[] = '
' . $bug["$column"] . '
'; + } + $data = "\n\t\t" . implode("\n\t\t", $build) . "\n\t"; + } + else + { + $data = $bug["$columns[0]"]; + } + $fields .= "\n\t$data"; + } + + eval('$output = "' . $this->registry->template->fetch('trackerhome_bits') . '";'); + return $output; + } + + // ################################################################### + /** + * Sets up $this->columns so that the data can be processed more + * easily + */ + function _processColumns() + { + if (is_array($this->columns)) + { + return; + } + + $array = (($this->registry->userinfo['userid'] AND is_array($this->registry->userinfo['columnoptions'])) ? $this->registry->userinfo['columnoptions'] : $this->registry->options['columnoptions']); + + foreach ($array AS $column => $position) + { + if ($position > 0) + { + $this->columns["$position"][] = $column; + } + } + + ksort($this->columns); + } } /*=====================================================================*\ diff --git a/includes/functions.php b/includes/functions.php index d83ab7d..982dbfa 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -635,6 +635,7 @@ function ProcessBugDataForDisplay($bug, $color = '') $bug['bgcolor'] = ($bugsys->userinfo['showcolors'] ? $bugsys->datastore['status']["$bug[status]"]['color'] : $color); $bug['product'] = $bugsys->datastore['product']["$bug[product]"]['title']; $bug['version'] = $bugsys->datastore['version']["$bug[version]"]['version']; + $bug['component'] = $bugsys->datastore['product']["$bug[component]"]['title']; $bug['status'] = $bugsys->datastore['status']["$bug[status]"]['status']; $bug['resolution'] = $bugsys->datastore['resolution']["$bug[resolution]"]['resolution']; $bug['priority'] = $bugsys->datastore['priority']["$bug[priority]"]['priority']; diff --git a/includes/permissions.php b/includes/permissions.php index fbd9353..a768804 100644 --- a/includes/permissions.php +++ b/includes/permissions.php @@ -87,7 +87,7 @@ $bugsys->columns = array( ); $bugsys->columnNames = array( - 'bugid' => _('Bug ID'), + 'bugid' => _('ID'), 'summary' => _('Summary'), 'userid' => _('Reporter'), 'product' => _('Product'), diff --git a/index.php b/index.php index 654b05c..d81bb3f 100644 --- a/index.php +++ b/index.php @@ -60,11 +60,13 @@ while ($bug = $db->fetch_array($bugs_fetch)) { $funct->exec_swap_bg($stylevar['alt_color'], ''); ProcessBugDataForDisplay(&$bug, $funct->bgcolour); - eval('$bugs .= "' . $template->fetch('trackerhome_bits') . '";'); + $bugs .= $sort->constructRow($bug); } $db->free_result($bugs_fetch); +$columnHeads = $sort->constructColumnHeaders(true); + $order = $sort->fetch_display_array('p=' . $pagination->page . '&pp=' . $pagination->perpage); $show['pagenav'] = ($pagination->getPageCount() > 1); $pagenav = $pagination->constructPageNav($sort->fetch_sort_link($sort->sortkey)); diff --git a/templates/trackerhome.tpl b/templates/trackerhome.tpl index 1d956b2..17acf11 100644 --- a/templates/trackerhome.tpl +++ b/templates/trackerhome.tpl @@ -11,13 +11,7 @@ $header - - - - - - - + $columnHeads $bugs
{@"ID"} {$order['id']['image']}{@"Summary"} {$order['summary']['image']}/ {@"Reporter"} {$order['reporter']['image']}{@"Product/Version"} {$order['product']['image']}{@"Status"} {$order['status']['image']}/ {@"Resolution"} {$order['resolution']['image']}{@"Priority"} {$order['priority']['image']}/ {@"Severity"} {$order['severity']['image']}{@"Last Post"} {$order['lastpost']['image']}
diff --git a/templates/trackerhome_bits.tpl b/templates/trackerhome_bits.tpl index 58de037..e0317c8 100644 --- a/templates/trackerhome_bits.tpl +++ b/templates/trackerhome_bits.tpl @@ -1,26 +1,6 @@ style="background-color: $bug[bgcolor]; font-style: italic"> - $bug[bugid] - -
$bug[summary]
-
$bug[username]
- - -
$bug[product]
-
$bug[version]
- - -
$bug[status]
-
$bug[resolution]
- - -
$bug[priority]
-
$bug[severity]
- - -
$bug[lastposttime]
-
{@"by"} $bug[lastpost]
- +$fields -- 2.43.5