cvs: bugtracker /htdocs/index index.php /includes functions.php template.php /template/generic/bug index.php
| From: | Barry Carlyon | Date: | Fri, 01 Aug 2008 14:31:41 +0000 |
| Subject: | cvs: bugtracker /htdocs/index index.php /includes functions.php template.php /template/generic/bug index.php | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-2275@lists.php.net to get a copy of this message | ||
bcarlyon Fri Aug 1 14:31:41 2008 UTC
Modified files:
/bugtracker/htdocs/index index.php
/bugtracker/includes functions.php template.php
/bugtracker/template/generic/bug index.php
Log:
Committing the loop part of the tempate engine
http://cvs.php.net/viewvc.cgi/bugtracker/htdocs/index/index.php?r1=1.14&r2=1.15&diff_format=u Index: bugtracker/htdocs/index/index.php diff -u bugtracker/htdocs/index/index.php:1.14 bugtracker/htdocs/index/index.php:1.15 --- bugtracker/htdocs/index/index.php:1.14 Fri Aug 1 10:51:11 2008 +++ bugtracker/htdocs/index/index.php Fri Aug 1 14:31:41 2008 @@ -14,7 +14,9 @@ include($_SERVER['DOCUMENT_ROOT'] . '/config.php'); include($_SERVER['DOCUMENT_ROOT'] . '../includes/functions.php'); -$errorhandler = set_error_handler("theerrorhandler",E_ALL&~E_NOTICE); +//$errorhandler = set_error_handler("theerrorhandler",E_ALL&~E_NOTICE); +error_reporting(E_ALL); +$old_error_handler = set_error_handler("theerrorhandler",E_ALL); //database time $db = new db(); http://cvs.php.net/viewvc.cgi/bugtracker/includes/functions.php?r1=1.16&r2=1.17&diff_format=u Index: bugtracker/includes/functions.php diff -u bugtracker/includes/functions.php:1.16 bugtracker/includes/functions.php:1.17 --- bugtracker/includes/functions.php:1.16 Fri Aug 1 10:51:11 2008 +++ bugtracker/includes/functions.php Fri Aug 1 14:31:41 2008 @@ -169,6 +169,7 @@ function theerrorhandler($errno, $errstr, $errfile, $errline) { +trace('ERROR -> in backtrace now'); global $backtrace; $fail = ''; switch ($errno) { @@ -192,7 +193,6 @@ $backtrace .= '<strong>' . $fail . '</strong>'; errorarray(debug_backtrace()); - $backtrace = '<div id="error" style="font-size: 8px;">' . $backtrace . '</div>'; $first_flag = FALSE; http://cvs.php.net/viewvc.cgi/bugtracker/includes/template.php?r1=1.1&r2=1.2&diff_format=u Index: bugtracker/includes/template.php diff -u bugtracker/includes/template.php:1.1 bugtracker/includes/template.php:1.2 --- bugtracker/includes/template.php:1.1 Fri Aug 1 10:51:11 2008 +++ bugtracker/includes/template.php Fri Aug 1 14:31:41 2008 @@ -1,6 +1,6 @@ <?php -//this is the template engine version 2 +//this is the template engine version 3 /* @@ -100,6 +100,8 @@ $this->swap('alternative_css', $this->alternative_css ); global $backtrace; + if ($backtrace) + $backtrace = '<div id="error" style="font-size: 8px;">' . $backtrace . '</div>'; $this->swap('backtrace', $backtrace ); $this->swap('login', $this->login ); @@ -140,18 +142,51 @@ return; } - function swap($target, $victim) { - $this->html = str_replace('{' . strtoupper($target) . '}', $victim, $this->html); - return; + function swap($target, $victim, $source = '') { + global $cache; + $return = TRUE; + if (empty($source)) + { + $source = $this->html; + $return = FALSE; + } + $cache_check = str_replace('DSP_','',$target); + if (isset($cache->$cache_check)) + { + trace('found ' . $cache_check); + $victim = $cache->obtain($cache_check, $victim); + } + + //put the victim on the target + $source = str_replace('{' . strtoupper($target) . '}', $victim, $source); + if ($return) + return $source; + else + { + $this->html = $source; + return; + } } - function loop($loop_data, $loop_html) { + function loop($loop_data, $loop_html = '') { + if (empty($loop_html)) + $loop_html = $this->loop_html; $this->loop_html = $loop_html; + + $html = ''; foreach ($loop_data as $ref => $data) { - $this->html .= $this->loop_html; - swap($ref, $data); + $html .= $this->loop_html; + if (is_array($data)) + { + foreach ($data as $nref => $ndata) { + $html = $this->swap('DSP_' . $nref, $ndata, $html); + } + } else { + $html = $this->swap('DSP_' . $ref, $data, $html); + } } - return; + + return $html; } function sanitize($in) @@ -221,6 +256,7 @@ return; } function load_template() { + global $db; if ($this->template_type == 'php') { include($this->template_file); } http://cvs.php.net/viewvc.cgi/bugtracker/template/generic/bug/index.php?r1=1.16&r2=1.17&diff_format=u Index: bugtracker/template/generic/bug/index.php diff -u bugtracker/template/generic/bug/index.php:1.16 bugtracker/template/generic/bug/index.php:1.17 --- bugtracker/template/generic/bug/index.php:1.16 Fri Aug 1 10:51:11 2008 +++ bugtracker/template/generic/bug/index.php Fri Aug 1 14:31:41 2008 @@ -1,185 +1,9 @@ <?php +$content = ''; $bug_id = $_REQUEST['bug_id']; $bug_id = str_replace('/','',$bug_id); -if (substr($bug_id,0,8) == 'download') -{ - //code download! - $bug_id = str_replace('download/', '', $bug_id); - $bug_id = str_replace('download', '', $bug_id); - $query = 'SELECT * FROM bug_comment WHERE bug_id = ' . "'{$bug_id}' AND comment_type= " . REPRODUCE; - $db->get_data($query); - if ($db->total_rows) - { - //lets shunt out a text file - header("Cache-Control: no-cache, must-revalidate"); - header("Content-Type: text/plain"); - header('Content-Disposition: attachment; filename="bug_reproduce_code_bugid_' . $bug_id . '.txt"'); - $file = $db->fetch_row(); - echo $file['comment']; - exit; - } - else - { - $content .= '<h2>Bug Error</h2>'; - $template_data['system_error'] = 'Invalid Bug Id or no Reproduce Code to download'; - } -} - -if (is_numeric($bug_id)) -{ - $query = "SELECT *,UNIX_TIMESTAMP(reported_on),UNIX_TIMESTAMP(assigned_on),UNIX_TIMESTAMP(updated) FROM bug WHERE bug_id = '{$bug_id}'"; - $db->get_data($query); - $row = $db->fetch_row(); - - if (!$db->total_rows) - { - $content .= '<h2>Bug Error</h2>'; - $template_data['system_error'] = 'The ID you supplied is invalid, the bug does not exist.<br /><a href="/bug/" title="Bug Listings">Back to the Bug Listings</a>'; - } - else - { - $bug->bug_id = $bug_id; - $bug_row = $row; - - //get comments - $query = "SELECT * FROM bug_comment WHERE bug_id = '{$bug_id}' AND ( comment_type = " . DESCRIPTION . ' OR comment_type = ' . REPRODUCE . ' OR comment_type = ' . EXPECTED . ' OR comment_type = ' . ACTUAL . ')'; - $db->get_data($query); - $comments = array(); - while ($entry = $db->fetch_row()) - { - $comments[$comment_type[$entry['comment_type']]] = $entry['comment']; - } - $bug_row = array_merge($bug_row, $comments); - - $row['password'] = ''; - - $template_data['page_title'] .= ' - #' . $bug->bug_id . ' ' . $bug_row['summary']; - -//shunt to dispplay -$display_data['bug_id'] = $bug_row['bug_id']; -$display_data['summary'] = $bug_row['summary']; -$display_data['status'] = $bug_row['status']; - -$display_data['reported_by'] = $bug_row['reported_by']; -// this is to get switched to a profile pref -// 'd/m/Y H:i O' -$display_data['time']['reported_on'] = $bug_row['UNIX_TIMESTAMP(reported_on)']; -$display_data['time']['updated'] = $bug_row['UNIX_TIMESTAMP(updated)']; - -$display_data['dsp_description'] = $bug_row['description']; - - $content .= '<h2>Bug Display</h2>'; -//ie fix???? - $content .= ' - -<style> -td { -border: 1px solid black; -} -</style> - -<table id="bug"> -<tr> <td style="width: 100px;"> </td> <td style="width: 80px;"> </td> <td style="width: 180px;"> </td> <td style="width: 150px;"> </td></tr> -<tr> <td>Bug: #{DSP_BUG_ID}</td> <td colspan="2" style="width: 220px;">{DSP_SUMMARY}</td> <td>Reported By:<br /><strong>{DSP_REPORTED_BY}</strong></td> </tr> -<tr> <td><h4>{DSP_STATUS}</h4></td> <td>Opened:</td> <td colspan="2">{DSP_REPORTED_ON}</td> </tr> -'; - if ($bug_row['UNIX_TIMESTAMP(updated)'] != $bug_row['UNIX_TIMESTAMP(reported_on)']) - { - $content .= '<tr> <td></td> <td>Last Updated:</td> <td colspan="2">{DSP_UPDATED}</td> </tr>'; - } - if ($bug_row['assigned_to']) - { - $content .= '<tr> <td></td> <td>Assigned To:</td> <td colspan="2"><strong>' . $row['assigned_to'] . '</strong></td> </tr> -<tr> <td></td> <td>Assigned On:</td> <td colspan="2">' . date('d/m/Y H:i O',$bug_row['UNIX_TIMESTAMP(assigned_on)']) . '</td> </tr>'; - } - $content .= ' -<tr> <td></td> <td colspan="2" style="text-align: right;">Version:</td> <td>' . $php_version[$row['php_version']] .'</td> </tr> -<tr> <td></td> <td colspan="2" style="text-align: right;">Type:</td> <td>' . $bug_type[$row['bug_type']] . '</td> </tr> -<tr> <td></td> <td colspan="2" style="text-align: right;">OS:</td> <td>' . $os_version[$row['os_version']] . '</td> </tr> -<tr> <td></td> <td colspan="3" id="description">{dsp_description}</td> </tr> -'; - - //extra basic comments - if (isset($bug_row['reproduce'])) - { - $jsscripts[] = '/elements/js/lineno.js'; - $content .= ' -<tr> <td></td> <td colspan="3" style="display: none;" id="reproduce_link"><br /><a href="javascript:handleClick(\'reproduce_code\');handleClick(\'reproduce_link\');">Show Reproduce Code and Results</a><br /> </td> </tr> -<tr> <td></td> <td colspan="3" id="reproduce_code"> - <br /><h5>Reproduce Code</h5> - <a href="javascript:handleClick(\'reproduce_code\');handleClick(\'reproduce_link\');" class="lineno">Hide Code and Results</a> - <a href="javascript:selectText(\'reproduce\');" title="Select Code" class="textselect">Select Code</a> - <a href="/bug/download/' . $bug_row['bug_id'] . '/" title="Download Code" class="textselect">Download</a> - <br /><br /> - <textarea id="reproduce" rows="7" cols="55">' . htmlentities($bug_row['reproduce']) . '</textarea> - <hr /> - <br /> - <h5>Expected Result</h5> - <textarea id="expected" rows="7" cols="55">' . $bug_row['expected'] . '</textarea> - <br /> - <a href="javascript:createTextAreaWithLines(\'expected\');handleClick(\'expected_add\');" id="expected_add" class="lineno">Add Line Numbers</a> - <hr /> - <h5>Actaul Result</h5> - <textarea id="actual" rows="7" cols="55">' . $bug_row['actual'] . '</textarea> - <br /><a href="javascript:createTextAreaWithLines(\'actual\');handleClick(\'actual_add\');" id="actual_add" class="lineno">Add Line Numbers</a> -</td></tr> -'; - } - - //here be the comment controller - $comment->spawn_form(); - - $content .= ' -<tr> <td> </td> <td colspan="3"> </td> </tr> -'; - $content .= '</table><br /><hr /><hr />'; - - if (isset($bug_row['reproduce'])) - { - $content .= ' -<script type="text/javascript"> - createTextAreaWithLines(\'reproduce\'); -</script>'; -/* - document.getElementById(\'reproduce_code\').style.display = \'none\'; - document.getElementById(\'reproduce_link\').style.display = \'block\'; -</script> -'; -*/ - } - - $content .= 'tempory hack'; - $content .= '<table>'; - foreach ($row as $col => $data) - { - if (is_numeric($col)) - { - } - else if (isset($$col)) - { - if (is_array($$col)) - { - //shunt into box - $temp = $$col; - $content .= '<tr><td>' . $col . '</td><td>' . $temp[$data] . ' - ' . $data . '</td></tr>'; - } - } - else - { - $content .= '<tr><td>' . $col . '</td><td>' . $data . '</td></tr>'; - } - } - $content .= '</table>'; - } -} -else if ($bug_id) -{ - $content = ' No search controller atm '; -} -else -{ //some statage $query = 'SELECT * FROM bug WHERE status = \'0\''; $db->get_data($query); @@ -193,30 +17,33 @@ $db->get_data($query); - $content .= '<h2>Bug Summary</h2>'; + $this->page_title = 'Bug Index'; + $this->content_title = 'Bug Summary'; $content .= 'There are Currenty ' . $db->total_rows . ' bugs in the system, of which ' . $pending . ' are pending review, the average review time is {AVERAGE_REVIEW}, the average close time is {AVERAGE_CLOSE}'; if ($db->total_rows) { $content .= '<table>'; $content .= '<tr><th>Bug Id</th><th>Summary</th><th>Reported By</th><th>Status</th></tr>'; + + $loop_html = '<tr><td style="text-align: center;"><a href="{DSP_BUG_ID}" title="View Bug">#{DSP_BUG_ID}</a></td><td>{DSP_SUMMARY}</td>'; + $loop_html .= '<td>{DSP_REPORTED_BY}</td><td>{DSP_STATUS}</td>'; + $loop_html .= '<td>{DSP_TIME}</d><td><a href="{DSP_BUG_ID}" title="View Bug">View Bug #{DSP_BUG_ID}</a></td></tr>'; + + $loop_data = array(); while ($row = $db->fetch_row()) { - $content .= '<tr>'; - $content .= '<td style="text-align: center;"><a href="{DSP_BUG_ID}" title="View Bug">#{DSP_BUG_ID}</a></td><td>{DSP_SUMMARY}</td>'; - $content .= '<td>{DSP_SUMMARY}</td>'; - $content .= '<td>{DSP_STATUS}</td>'; - if ($row['status']) - { - $content .= '<td>{DSP_UPDATED}</td>'; - } - else - { - $content .= '<td>{DSP_REPORTED_ON}</td>'; - } - $content .= '<td><a href="{DSP_BUG_ID}" title="View Bug">View Bug</a></td>'; - $content .= '</tr>'; + $this_loop = array(); + $this_loop['bug_id'] = $row['bug_id']; + $this_loop['summary'] = $row['summary']; + $this_loop['reported_by'] = $row['reported_by']; + $this_loop['status'] = $row['status']; + $this_loop['time'] = ($row['status']) ? $row['updated'] : $row['reported_on']; + + $loop_data[] = $this_loop; } + trace('go for loop'); + $content .= $this->loop($loop_data, $loop_html); $content .= '</table>'; } else @@ -224,5 +51,7 @@ $content .= '<h2>No Bugs</h2>'; $template_data['system_error'] = 'There does not appear to be any bugs, perhaps one needs to be <a href="/report/" title="Report a bug">reported</a>.'; } -} + +//we are inside the template engine!!! +$this->prehtml = $content;
http://cvs.php.net/viewvc.cgi/bugtracker/htdocs/index/index.php?r1=1.14&r2=1.15&diff_format=u Index: bugtracker/htdocs/index/index.php diff -u bugtracker/htdocs/index/index.php:1.14 bugtracker/htdocs/index/index.php:1.15 --- bugtracker/htdocs/index/index.php:1.14 Fri Aug 1 10:51:11 2008 +++ bugtracker/htdocs/index/index.php Fri Aug 1 14:31:41 2008 @@ -14,7 +14,9 @@ include($_SERVER['DOCUMENT_ROOT'] . '/config.php'); include($_SERVER['DOCUMENT_ROOT'] . '../includes/functions.php'); -$errorhandler = set_error_handler("theerrorhandler",E_ALL&~E_NOTICE); +//$errorhandler = set_error_handler("theerrorhandler",E_ALL&~E_NOTICE); +error_reporting(E_ALL); +$old_error_handler = set_error_handler("theerrorhandler",E_ALL); //database time $db = new db(); http://cvs.php.net/viewvc.cgi/bugtracker/includes/functions.php?r1=1.16&r2=1.17&diff_format=u Index: bugtracker/includes/functions.php diff -u bugtracker/includes/functions.php:1.16 bugtracker/includes/functions.php:1.17 --- bugtracker/includes/functions.php:1.16 Fri Aug 1 10:51:11 2008 +++ bugtracker/includes/functions.php Fri Aug 1 14:31:41 2008 @@ -169,6 +169,7 @@ function theerrorhandler($errno, $errstr, $errfile, $errline) { +trace('ERROR -> in backtrace now'); global $backtrace; $fail = ''; switch ($errno) { @@ -192,7 +193,6 @@ $backtrace .= '<strong>' . $fail . '</strong>'; errorarray(debug_backtrace()); - $backtrace = '<div id="error" style="font-size: 8px;">' . $backtrace . '</div>'; $first_flag = FALSE; http://cvs.php.net/viewvc.cgi/bugtracker/includes/template.php?r1=1.1&r2=1.2&diff_format=u Index: bugtracker/includes/template.php diff -u bugtracker/includes/template.php:1.1 bugtracker/includes/template.php:1.2 --- bugtracker/includes/template.php:1.1 Fri Aug 1 10:51:11 2008 +++ bugtracker/includes/template.php Fri Aug 1 14:31:41 2008 @@ -1,6 +1,6 @@ <?php -//this is the template engine version 2 +//this is the template engine version 3 /* @@ -100,6 +100,8 @@ $this->swap('alternative_css', $this->alternative_css ); global $backtrace; + if ($backtrace) + $backtrace = '<div id="error" style="font-size: 8px;">' . $backtrace . '</div>'; $this->swap('backtrace', $backtrace ); $this->swap('login', $this->login ); @@ -140,18 +142,51 @@ return; } - function swap($target, $victim) { - $this->html = str_replace('{' . strtoupper($target) . '}', $victim, $this->html); - return; + function swap($target, $victim, $source = '') { + global $cache; + $return = TRUE; + if (empty($source)) + { + $source = $this->html; + $return = FALSE; + } + $cache_check = str_replace('DSP_','',$target); + if (isset($cache->$cache_check)) + { + trace('found ' . $cache_check); + $victim = $cache->obtain($cache_check, $victim); + } + + //put the victim on the target + $source = str_replace('{' . strtoupper($target) . '}', $victim, $source); + if ($return) + return $source; + else + { + $this->html = $source; + return; + } } - function loop($loop_data, $loop_html) { + function loop($loop_data, $loop_html = '') { + if (empty($loop_html)) + $loop_html = $this->loop_html; $this->loop_html = $loop_html; + + $html = ''; foreach ($loop_data as $ref => $data) { - $this->html .= $this->loop_html; - swap($ref, $data); + $html .= $this->loop_html; + if (is_array($data)) + { + foreach ($data as $nref => $ndata) { + $html = $this->swap('DSP_' . $nref, $ndata, $html); + } + } else { + $html = $this->swap('DSP_' . $ref, $data, $html); + } } - return; + + return $html; } function sanitize($in) @@ -221,6 +256,7 @@ return; } function load_template() { + global $db; if ($this->template_type == 'php') { include($this->template_file); } http://cvs.php.net/viewvc.cgi/bugtracker/template/generic/bug/index.php?r1=1.16&r2=1.17&diff_format=u Index: bugtracker/template/generic/bug/index.php diff -u bugtracker/template/generic/bug/index.php:1.16 bugtracker/template/generic/bug/index.php:1.17 --- bugtracker/template/generic/bug/index.php:1.16 Fri Aug 1 10:51:11 2008 +++ bugtracker/template/generic/bug/index.php Fri Aug 1 14:31:41 2008 @@ -1,185 +1,9 @@ <?php +$content = ''; $bug_id = $_REQUEST['bug_id']; $bug_id = str_replace('/','',$bug_id); -if (substr($bug_id,0,8) == 'download') -{ - //code download! - $bug_id = str_replace('download/', '', $bug_id); - $bug_id = str_replace('download', '', $bug_id); - $query = 'SELECT * FROM bug_comment WHERE bug_id = ' . "'{$bug_id}' AND comment_type= " . REPRODUCE; - $db->get_data($query); - if ($db->total_rows) - { - //lets shunt out a text file - header("Cache-Control: no-cache, must-revalidate"); - header("Content-Type: text/plain"); - header('Content-Disposition: attachment; filename="bug_reproduce_code_bugid_' . $bug_id . '.txt"'); - $file = $db->fetch_row(); - echo $file['comment']; - exit; - } - else - { - $content .= '<h2>Bug Error</h2>'; - $template_data['system_error'] = 'Invalid Bug Id or no Reproduce Code to download'; - } -} - -if (is_numeric($bug_id)) -{ - $query = "SELECT *,UNIX_TIMESTAMP(reported_on),UNIX_TIMESTAMP(assigned_on),UNIX_TIMESTAMP(updated) FROM bug WHERE bug_id = '{$bug_id}'"; - $db->get_data($query); - $row = $db->fetch_row(); - - if (!$db->total_rows) - { - $content .= '<h2>Bug Error</h2>'; - $template_data['system_error'] = 'The ID you supplied is invalid, the bug does not exist.<br /><a href="/bug/" title="Bug Listings">Back to the Bug Listings</a>'; - } - else - { - $bug->bug_id = $bug_id; - $bug_row = $row; - - //get comments - $query = "SELECT * FROM bug_comment WHERE bug_id = '{$bug_id}' AND ( comment_type = " . DESCRIPTION . ' OR comment_type = ' . REPRODUCE . ' OR comment_type = ' . EXPECTED . ' OR comment_type = ' . ACTUAL . ')'; - $db->get_data($query); - $comments = array(); - while ($entry = $db->fetch_row()) - { - $comments[$comment_type[$entry['comment_type']]] = $entry['comment']; - } - $bug_row = array_merge($bug_row, $comments); - - $row['password'] = ''; - - $template_data['page_title'] .= ' - #' . $bug->bug_id . ' ' . $bug_row['summary']; - -//shunt to dispplay -$display_data['bug_id'] = $bug_row['bug_id']; -$display_data['summary'] = $bug_row['summary']; -$display_data['status'] = $bug_row['status']; - -$display_data['reported_by'] = $bug_row['reported_by']; -// this is to get switched to a profile pref -// 'd/m/Y H:i O' -$display_data['time']['reported_on'] = $bug_row['UNIX_TIMESTAMP(reported_on)']; -$display_data['time']['updated'] = $bug_row['UNIX_TIMESTAMP(updated)']; - -$display_data['dsp_description'] = $bug_row['description']; - - $content .= '<h2>Bug Display</h2>'; -//ie fix???? - $content .= ' - -<style> -td { -border: 1px solid black; -} -</style> - -<table id="bug"> -<tr> <td style="width: 100px;"> </td> <td style="width: 80px;"> </td> <td style="width: 180px;"> </td> <td style="width: 150px;"> </td></tr> -<tr> <td>Bug: #{DSP_BUG_ID}</td> <td colspan="2" style="width: 220px;">{DSP_SUMMARY}</td> <td>Reported By:<br /><strong>{DSP_REPORTED_BY}</strong></td> </tr> -<tr> <td><h4>{DSP_STATUS}</h4></td> <td>Opened:</td> <td colspan="2">{DSP_REPORTED_ON}</td> </tr> -'; - if ($bug_row['UNIX_TIMESTAMP(updated)'] != $bug_row['UNIX_TIMESTAMP(reported_on)']) - { - $content .= '<tr> <td></td> <td>Last Updated:</td> <td colspan="2">{DSP_UPDATED}</td> </tr>'; - } - if ($bug_row['assigned_to']) - { - $content .= '<tr> <td></td> <td>Assigned To:</td> <td colspan="2"><strong>' . $row['assigned_to'] . '</strong></td> </tr> -<tr> <td></td> <td>Assigned On:</td> <td colspan="2">' . date('d/m/Y H:i O',$bug_row['UNIX_TIMESTAMP(assigned_on)']) . '</td> </tr>'; - } - $content .= ' -<tr> <td></td> <td colspan="2" style="text-align: right;">Version:</td> <td>' . $php_version[$row['php_version']] .'</td> </tr> -<tr> <td></td> <td colspan="2" style="text-align: right;">Type:</td> <td>' . $bug_type[$row['bug_type']] . '</td> </tr> -<tr> <td></td> <td colspan="2" style="text-align: right;">OS:</td> <td>' . $os_version[$row['os_version']] . '</td> </tr> -<tr> <td></td> <td colspan="3" id="description">{dsp_description}</td> </tr> -'; - - //extra basic comments - if (isset($bug_row['reproduce'])) - { - $jsscripts[] = '/elements/js/lineno.js'; - $content .= ' -<tr> <td></td> <td colspan="3" style="display: none;" id="reproduce_link"><br /><a href="javascript:handleClick(\'reproduce_code\');handleClick(\'reproduce_link\');">Show Reproduce Code and Results</a><br /> </td> </tr> -<tr> <td></td> <td colspan="3" id="reproduce_code"> - <br /><h5>Reproduce Code</h5> - <a href="javascript:handleClick(\'reproduce_code\');handleClick(\'reproduce_link\');" class="lineno">Hide Code and Results</a> - <a href="javascript:selectText(\'reproduce\');" title="Select Code" class="textselect">Select Code</a> - <a href="/bug/download/' . $bug_row['bug_id'] . '/" title="Download Code" class="textselect">Download</a> - <br /><br /> - <textarea id="reproduce" rows="7" cols="55">' . htmlentities($bug_row['reproduce']) . '</textarea> - <hr /> - <br /> - <h5>Expected Result</h5> - <textarea id="expected" rows="7" cols="55">' . $bug_row['expected'] . '</textarea> - <br /> - <a href="javascript:createTextAreaWithLines(\'expected\');handleClick(\'expected_add\');" id="expected_add" class="lineno">Add Line Numbers</a> - <hr /> - <h5>Actaul Result</h5> - <textarea id="actual" rows="7" cols="55">' . $bug_row['actual'] . '</textarea> - <br /><a href="javascript:createTextAreaWithLines(\'actual\');handleClick(\'actual_add\');" id="actual_add" class="lineno">Add Line Numbers</a> -</td></tr> -'; - } - - //here be the comment controller - $comment->spawn_form(); - - $content .= ' -<tr> <td> </td> <td colspan="3"> </td> </tr> -'; - $content .= '</table><br /><hr /><hr />'; - - if (isset($bug_row['reproduce'])) - { - $content .= ' -<script type="text/javascript"> - createTextAreaWithLines(\'reproduce\'); -</script>'; -/* - document.getElementById(\'reproduce_code\').style.display = \'none\'; - document.getElementById(\'reproduce_link\').style.display = \'block\'; -</script> -'; -*/ - } - - $content .= 'tempory hack'; - $content .= '<table>'; - foreach ($row as $col => $data) - { - if (is_numeric($col)) - { - } - else if (isset($$col)) - { - if (is_array($$col)) - { - //shunt into box - $temp = $$col; - $content .= '<tr><td>' . $col . '</td><td>' . $temp[$data] . ' - ' . $data . '</td></tr>'; - } - } - else - { - $content .= '<tr><td>' . $col . '</td><td>' . $data . '</td></tr>'; - } - } - $content .= '</table>'; - } -} -else if ($bug_id) -{ - $content = ' No search controller atm '; -} -else -{ //some statage $query = 'SELECT * FROM bug WHERE status = \'0\''; $db->get_data($query); @@ -193,30 +17,33 @@ $db->get_data($query); - $content .= '<h2>Bug Summary</h2>'; + $this->page_title = 'Bug Index'; + $this->content_title = 'Bug Summary'; $content .= 'There are Currenty ' . $db->total_rows . ' bugs in the system, of which ' . $pending . ' are pending review, the average review time is {AVERAGE_REVIEW}, the average close time is {AVERAGE_CLOSE}'; if ($db->total_rows) { $content .= '<table>'; $content .= '<tr><th>Bug Id</th><th>Summary</th><th>Reported By</th><th>Status</th></tr>'; + + $loop_html = '<tr><td style="text-align: center;"><a href="{DSP_BUG_ID}" title="View Bug">#{DSP_BUG_ID}</a></td><td>{DSP_SUMMARY}</td>'; + $loop_html .= '<td>{DSP_REPORTED_BY}</td><td>{DSP_STATUS}</td>'; + $loop_html .= '<td>{DSP_TIME}</d><td><a href="{DSP_BUG_ID}" title="View Bug">View Bug #{DSP_BUG_ID}</a></td></tr>'; + + $loop_data = array(); while ($row = $db->fetch_row()) { - $content .= '<tr>'; - $content .= '<td style="text-align: center;"><a href="{DSP_BUG_ID}" title="View Bug">#{DSP_BUG_ID}</a></td><td>{DSP_SUMMARY}</td>'; - $content .= '<td>{DSP_SUMMARY}</td>'; - $content .= '<td>{DSP_STATUS}</td>'; - if ($row['status']) - { - $content .= '<td>{DSP_UPDATED}</td>'; - } - else - { - $content .= '<td>{DSP_REPORTED_ON}</td>'; - } - $content .= '<td><a href="{DSP_BUG_ID}" title="View Bug">View Bug</a></td>'; - $content .= '</tr>'; + $this_loop = array(); + $this_loop['bug_id'] = $row['bug_id']; + $this_loop['summary'] = $row['summary']; + $this_loop['reported_by'] = $row['reported_by']; + $this_loop['status'] = $row['status']; + $this_loop['time'] = ($row['status']) ? $row['updated'] : $row['reported_on']; + + $loop_data[] = $this_loop; } + trace('go for loop'); + $content .= $this->loop($loop_data, $loop_html); $content .= '</table>'; } else @@ -224,5 +51,7 @@ $content .= '<h2>No Bugs</h2>'; $template_data['system_error'] = 'There does not appear to be any bugs, perhaps one needs to be <a href="/report/" title="Report a bug">reported</a>.'; } -} + +//we are inside the template engine!!! +$this->prehtml = $content;