cvs: bugtracker /includes comment.php functions.php template.php user.php /includes/cache comment_type.php users.php /template/generic header.html
/template/generic/bug comment.php /template/generic/report index.php

From: Date: Thu, 07 Aug 2008 13:31:55 +0000
Subject: cvs: bugtracker /includes comment.php functions.php template.php user.php /includes/cache comment_type.php users.php /template/generic header.html
/template/generic/bug comment.php /template/generic/report index.php
Groups: php.webmaster 
Request: Send a blank email to php-webmaster+get-2335@lists.php.net to get a copy of this message
bcarlyon Thu Aug 7 13:31:55 2008 UTC Modified files: /bugtracker/includes comment.php functions.php template.php user.php /bugtracker/includes/cache comment_type.php users.php /bugtracker/template/generic header.html /bugtracker/template/generic/bug comment.php /bugtracker/template/generic/report index.php Log: Template engine error handler and update the main error handler

http://cvs.php.net/viewvc.cgi/bugtracker/includes/comment.php?r1=1.9&r2=1.10&diff_format=u Index: bugtracker/includes/comment.php diff -u bugtracker/includes/comment.php:1.9 bugtracker/includes/comment.php:1.10 --- bugtracker/includes/comment.php:1.9 Thu Aug 7 09:59:42 2008 +++ bugtracker/includes/comment.php Thu Aug 7 13:31:55 2008 @@ -16,8 +16,12 @@ $this->add_comment(ACTUAL,$this->bug_id,$comments['actual'],$comments['handle']); } } - function add_comment($type,$bug_id,$text,$handle) { + function add_comment($type,$bug_id,$text,$handle= '') { global $db; + + if (!$handle) + $handle = $user->handle; + $text = $db->protect_data($text); $query = 'INSERT INTO bug_comment(bug_id,comment_type,comment,handle,added) VALUES ' . "('{$bug_id}', '{$type}', '{$text}', '{$handle}', NOW())"; $db->get_data($query); @@ -30,16 +34,19 @@ } function delete_comment() { } - function spawn_form() { - global $user,$content,$bug; + function spawn_form($form_data = array(), $error_data = array()) { + global $user,$content,$bug,$template; //generate a comment form - //this generates a basic form without all the refill feilds + + if (!isset($bug->bug_id) && $form_data['bug_id']) + $bug->bug_id = $form_data['bug_id']; $form_content = ' <tr> <td style="text-align: center; border-top: 1px solid #000;">&nbsp;Add Comment</td> <td colspan="3" style="border-top: 1px solid #000;"></td> </tr> <tr> <td></td> <td colspan="3"> <form action="/bug/comment/" method="post" name="commentform" id="commentform" > <input type="hidden" name="bug_id" value="' . $bug->bug_id . ' " /> +{FORM_FORM_ERROR} '; if (!$user->logged_in) @@ -49,7 +56,7 @@ $form_content .= ' <p>If you hold a temporary account the password is that of the last bug you posted</p><br /> <div class="slim"> - <label for="handle">Handle/Email:</label> <input type="text" name="handle" id="handle" value="" /><br /><br /> + <label for="handle">Handle/Email:</label> <input type="text" name="handle" id="handle" value="{FORM_HANDLE}" /><br /><br /> <label for="password">Password:</label> <input type="password" name="password" id="password" /><br /><br /> </div> '; @@ -57,7 +64,7 @@ $form_content .= ' <label for="comment_text">Comment</label> - <textarea name="comment_text" id="comment_text" rows="7" cols="55" ></textarea> + <textarea name="comment_text" id="comment_text" rows="7" cols="55" >{FORM_COMMENT_TEXT}</textarea> <div class="blocker" ></div> <input type="button" value="Submit Comment" onclick="document.getElementById(\'commentform\').submit()" /> </form> @@ -74,6 +81,8 @@ $content .= $form_content; } + $content = $template->dontloop(array('form' => $form_data, 'error' => $error_data), $content); + return; } } http://cvs.php.net/viewvc.cgi/bugtracker/includes/functions.php?r1=1.20&r2=1.21&diff_format=u Index: bugtracker/includes/functions.php diff -u bugtracker/includes/functions.php:1.20 bugtracker/includes/functions.php:1.21 --- bugtracker/includes/functions.php:1.20 Thu Aug 7 09:59:42 2008 +++ bugtracker/includes/functions.php Thu Aug 7 13:31:55 2008 @@ -174,18 +174,21 @@ trace('ERROR -> in backtrace now'); global $backtrace; $fail = ''; + $exit = FALSE; switch ($errno) { case E_USER_ERROR: + $exit = TRUE; + case E_USER_NOTICE: $fail = $errstr; - $backtrace = '<strong>' . $fail . '</strong>'; + $backtrace .= '<strong>' . $fail . '</strong>'; break; case E_NOTICE: $fail = "<b>Notice:</b> $errstr in $errfile on line $errline<br />\n"; - $backtrace = '<strong>' . $fail . '</strong>'; + $backtrace .= '<strong>' . $fail . '</strong>'; break; case E_WARNING: $fail = "<b>Warning:</b> $errstr - $errfile, $errline<br />\n"; - $backtrace = '<strong>' . $fail . '</strong>'; + $backtrace .= '<strong>' . $fail . '</strong>'; $backtrace .= 'Ref:<br /><table>'; foreach ($context as $ref => $data) { @@ -215,12 +218,21 @@ break; default: $fail = "Unknown error type: [$errno] $errstr<br />\n"; - $backtrace = '<strong>' . $fail . '</strong>'; + $backtrace .= '<strong>' . $fail . '</strong>'; errorarray(debug_backtrace()); break; } $first_flag = FALSE; + if ($exit) + { + global $template; + $template->prehtml = '<a href="javascript:history.go(-1);" title="Back" style="display: block; text-align: center;">Back</a><br />'; + $template->content_title = ' '; + $template->compile_and_echo(); + exit; + } + return; } http://cvs.php.net/viewvc.cgi/bugtracker/includes/template.php?r1=1.9&r2=1.10&diff_format=u Index: bugtracker/includes/template.php diff -u bugtracker/includes/template.php:1.9 bugtracker/includes/template.php:1.10 --- bugtracker/includes/template.php:1.9 Thu Aug 7 09:25:44 2008 +++ bugtracker/includes/template.php Thu Aug 7 13:31:55 2008 @@ -101,7 +101,7 @@ global $backtrace; if ($backtrace) - $backtrace = '<div id="error" style="font-size: 8px;">' . $backtrace . '</div>'; + $backtrace = '<div id="error">' . $backtrace . '</div>'; $this->swap('backtrace', $backtrace ); $this->swap('login', $this->login ); @@ -214,6 +214,7 @@ return $html; } + // sort of only used for form processing function dontloop($loop_data, $html) { foreach ($loop_data as $ref => $data) { $mod = ''; @@ -230,6 +231,8 @@ { $ndata = $ndata ? '<div class="error">' . $ndata . '</div>' : ''; } + if ($nref == 'form_error') + $ndata = $ndata ? '<div id="error">' . $ndata . '</div>' : ''; $ndata = $this->sanitize($ndata); $ndata = $this->time_check($nref, $ndata, $data); @@ -240,6 +243,8 @@ { $data = $data ? '<div class="error">' . $data . '</div>' : ''; } + if ($ref == 'form_error') + $data = $data ? '<div id="error">' . $data . '</div>' : ''; $data = $this->sanitize($data); $data = $this->time_check($ref, $data, $loop_data); http://cvs.php.net/viewvc.cgi/bugtracker/includes/user.php?r1=1.6&r2=1.7&diff_format=u Index: bugtracker/includes/user.php diff -u bugtracker/includes/user.php:1.6 bugtracker/includes/user.php:1.7 --- bugtracker/includes/user.php:1.6 Wed Jul 16 12:13:36 2008 +++ bugtracker/includes/user.php Thu Aug 7 13:31:55 2008 @@ -19,12 +19,6 @@ $this->handle = $data[1]; //no further auth required } -/* -$template_data['login'] = ' -<li><a href="/profile/">' . $this->handle . '</a></li> -<li><a href="/logout/">Logout</a></li> -'; -*/ } return; http://cvs.php.net/viewvc.cgi/bugtracker/includes/cache/comment_type.php?r1=1.5&r2=1.6&diff_format=u Index: bugtracker/includes/cache/comment_type.php diff -u bugtracker/includes/cache/comment_type.php:1.5 bugtracker/includes/cache/comment_type.php:1.6 --- bugtracker/includes/cache/comment_type.php:1.5 Thu Jul 31 12:34:21 2008 +++ bugtracker/includes/cache/comment_type.php Thu Aug 7 13:31:55 2008 @@ -8,6 +8,8 @@ $cacher['comment_type'][3] = "expected"; $comment_type[4] = "actual"; $cacher['comment_type'][4] = "actual"; + $comment_type[5] = "bug_comment"; + $cacher['comment_type'][5] = "bug_comment"; foreach($comment_type as $ref => $data) { http://cvs.php.net/viewvc.cgi/bugtracker/includes/cache/users.php?r1=1.1&r2=1.2&diff_format=u Index: bugtracker/includes/cache/users.php diff -u bugtracker/includes/cache/users.php:1.1 bugtracker/includes/cache/users.php:1.2 --- bugtracker/includes/cache/users.php:1.1 Thu Jul 31 12:34:21 2008 +++ bugtracker/includes/cache/users.php Thu Aug 7 13:31:55 2008 @@ -6,3 +6,6 @@ $users["Tlars_strojny"]["handle"] = "Tlars_strojny"; $users["Tlars_strojny"]["email"] = "lars@strojny.net"; + $users["T_"]["handle"] = "T_"; + $users["T_"]["email"] = ""; + http://cvs.php.net/viewvc.cgi/bugtracker/template/generic/header.html?r1=1.7&r2=1.8&diff_format=u Index: bugtracker/template/generic/header.html diff -u bugtracker/template/generic/header.html:1.7 bugtracker/template/generic/header.html:1.8 --- bugtracker/template/generic/header.html:1.7 Tue Aug 5 15:05:59 2008 +++ bugtracker/template/generic/header.html Thu Aug 7 13:31:55 2008 @@ -57,6 +57,8 @@ <input type="image" src="/gifs/small_submit_white.gif" onclick="window.location = '/bug/' + document.getElementById('searchfor').value;"/> </div> +<div id="error">This is NOT <a href="http://bugs.php.net/">bugs.php.net</a></div> + {BACKTRACE} <a name="content"></a><h2>{CONTENT_TITLE}</h2> http://cvs.php.net/viewvc.cgi/bugtracker/template/generic/bug/comment.php?r1=1.2&r2=1.3&diff_format=u Index: bugtracker/template/generic/bug/comment.php diff -u bugtracker/template/generic/bug/comment.php:1.2 bugtracker/template/generic/bug/comment.php:1.3 --- bugtracker/template/generic/bug/comment.php:1.2 Sat Jul 26 02:33:43 2008 +++ bugtracker/template/generic/bug/comment.php Thu Aug 7 13:31:55 2008 @@ -3,41 +3,69 @@ //woo is comment time //most of this involves taking to the comment class -$template_data['page_title'] .= ' - Comment'; -$content .= '<h2>Comment</h2>'; +$content = ''; +$template->page_title .= 'Comment'; +$template->content_title = 'Comment'; + +$password = loadvar('password',''); + +$form_data['bug_id'] = loadvar('bug_id',''); +$form_data['handle'] = loadvar('handle',$user->handle); +$form_data['comment_type'] = $form_data['bug_id'] ? BUG_COMMENT : ''; +$form_data['comment_text'] = loadvar('comment',''); +$form_data['form_error'] = 'Please Correct the Errors Shown'; -$bug_id = loadvar('bug_id',''); -$comment_type = ''; -$comment_text = loadvar('comment',''); +foreach ($form_data as $ref => $data) +{ + if (!$data) + { + $error_data[$ref] = TRUE; + } +} -if ($user->logged_in) { +if (!$form_data['comment_type']) { + trigger_error('Unable to determine what kinda comment you are making', E_USER_ERROR); +} +else if ($user->logged_in) { //user logged in - $handle = $user->handle; + $form_data['handle'] = $user->handle; } else { - $content .= '<p>Not Logged In</p>'; trace('not logged in'); - $handle = loadvar('handle',''); - $password = loadvar('password',''); - - if (!$handle || !$password) + if (!$form_data['handle'] || !$password) { - $form_data['bug_id'] = $bug_id; - $form_data['handle'] = $handle; - $form_data['comment_type'] = $comment_type; - $form_data['comment_text'] = $comment_text; - $form_data['form_error'] = 'Invalid Handle and/or password'; - trace('no handle or password'); trace('calling teh bug display?? not'); $content .= '<table id="bug">'; - $comment->spawn_form(); + $comment->spawn_form($form_data, $error_data); $content .= '</table>'; } + else + { + //authenticate the user + } } if (!$form_data['form_error']) - $comment->add_comment(); +{ + $comment->add_comment($comment_type, $bug_id, $comment_text, $handle); + if ($db->insert_id) { + $content .= '<div id="success">Your comment has been added successfully</div>'; + } else { + $form_data['form_error'] = '<div id="error">Your comment failed to be added</div>'; + trace('failed comment add'); + $content .= '<table id="bug">'; + $comment->spawn_form($form_data, $error_data); + $content .= '</table>'; + } +} +elseif (!$content) +{ + trigger_error('<br />Fatal Drop through the comment engine', E_USER_ERROR); +} +trace($form_data['form_error']); + +$template->prehtml = $content; http://cvs.php.net/viewvc.cgi/bugtracker/template/generic/report/index.php?r1=1.13&r2=1.14&diff_format=u Index: bugtracker/template/generic/report/index.php diff -u bugtracker/template/generic/report/index.php:1.13 bugtracker/template/generic/report/index.php:1.14 --- bugtracker/template/generic/report/index.php:1.13 Thu Aug 7 09:33:04 2008 +++ bugtracker/template/generic/report/index.php Thu Aug 7 13:31:55 2008 @@ -5,7 +5,7 @@ $template->page_title .= 'Reporting a bug'; $template->content_title = 'Reporting a bug'; -$form_data['form_error'] = isset($form_data['form_error']) ? '<div id="error">' . $form_data['form_error'] . '</div>' : ''; +$form_data['form_error'] = isset($form_data['form_error']) ? $form_data['form_error'] : ''; //form_data recovers form_data //this is pushed to dsp_data for template process $form_data['php_version'] = isset($form_data['php_version']) ? $form_data['php_version'] : ''; @@ -41,8 +41,7 @@ '; //time to process -$content = '{DSP_FORM_ERROR}'; -$content = $template->swap('dsp_form_error', $form_data['form_error'], $content); +$content = '{FORM_FORM_ERROR}'; $content .= ' <form action="/report/report/" method="post" class="form">
« previous php.webmaster (#2335) next »