Update of /cvsroot/phpbt/phpbt
In directory sc8-pr-cvs1:/tmp/cvs-serv22383
Modified Files:
Tag: htmltemplates
attachment.php bug.php include.php index.php install.php
query.php report.php user.php
Log Message:
Switching to html templates and gettext
Index: attachment.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/attachment.php,v
retrieving revision 1.21
retrieving revision 1.21.4.1
diff -u -r1.21 -r1.21.4.1
--- attachment.php 20 May 2003 03:08:01 -0000 1.21
+++ attachment.php 30 Aug 2003 22:07:11 -0000 1.21.4.1
@@ -153,7 +153,7 @@
? number_format(ini_get('upload_max_filesize'))
: number_format(ATTACHMENT_MAX_SIZE)
));
- $t->wrap('bugattachmentform.html', 'addattachment');
+ $t->render('bugattachmentform.html', translate('Add Attachment'), 'wrap-popup.html');
}
if (isset($_gv['del'])) {
Index: bug.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/bug.php,v
retrieving revision 1.134
retrieving revision 1.134.2.1
diff -u -r1.134 -r1.134.2.1
--- bug.php 24 Jul 2003 04:47:13 -0000 1.134
+++ bug.php 30 Aug 2003 22:07:12 -0000 1.134.2.1
@@ -33,7 +33,7 @@
'from '.TBL_AUTH_USER.' u, '.TBL_BUG_VOTE." v ".
"where u.user_id = v.user_id and bug_id = $bug_id ".
'order by v.created_date'));
- $t->wrap('bugvotes.html', 'bugvotes');
+ $t->render('bugvotes.html', translate('Bug Votes'));
}
///
@@ -113,7 +113,7 @@
}
$t->assign('history', $db->getAll(sprintf($QUERY['bug-history'], $bugid)));
- $t->wrap('bughistory.html', 'bughistory');
+ $t->render('bughistory.html', translate('Bug History'));
}
///
@@ -632,20 +632,20 @@
}
function show_form($bugid = 0, $error = '') {
- global $db, $me, $t, $_gv, $_pv, $TITLE;
+ global $db, $t;
- $projectname = $db->getOne("select project_name from ".TBL_PROJECT." where project_id = {$_gv['project']}");
+ $projectname = $db->getOne("select project_name from ".TBL_PROJECT." where project_id = {$_GET['project']}");
if ($bugid && !$error) {
$t->assign($db->getRow("select * from ".TBL_BUG." where bug_id = '$bugid'"));
} else {
$t->assign($_pv);
$t->assign(array(
'error' => $error,
- 'project' => $_gv['project'],
+ 'project' => $_GET['project'],
'projectname' => $projectname
));
}
- $t->wrap('bugform.html', 'enterbug');
+ $t->render('bugform.html', translate('Create Bug'));
}
function show_bug_printable($bugid) {
@@ -675,7 +675,7 @@
' from '.TBL_COMMENT.' c, '.TBL_AUTH_USER.
" where bug_id = $bugid and c.created_by = user_id order by c.created_date"
));
- $t->wrap('bugdisplay-printable.html', 'viewbug');
+ $t->render('bugdisplay-printable.html', translate('View Bug'));
}
///
@@ -800,7 +800,7 @@
" where bug_id = $bugid and c.created_by = user_id order by c.created_date")
));
- $t->wrap('bugdisplay.html', 'viewbug');
+ $t->render('bugdisplay.html', translate('View Bug'));
}
function show_projects() {
@@ -824,12 +824,12 @@
show_text($STRING['noprojects'], true);
return;
case 1 :
- $_gv['project'] = $projects[0]['project_id'];
+ $_GET['project'] = $projects[0]['project_id'];
show_form();
break;
default :
$t->assign('projects', $projects);
- $t->wrap('projectlist.html', 'enterbug');
+ $t->render('projectlist.html', translate('Select Project'));
}
}
Index: include.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/include.php,v
retrieving revision 1.126
retrieving revision 1.126.4.1
diff -u -r1.126 -r1.126.4.1
--- include.php 5 Jul 2003 22:57:33 -0000 1.126
+++ include.php 30 Aug 2003 22:07:12 -0000 1.126.4.1
@@ -106,49 +106,33 @@
// Template class
-if (!@include(SMARTY_PATH . 'Smarty.class.php')) {
- include('templates/default/base/smartymissing.html');
- exit;
-}
-
-class extSmarty extends Smarty {
+class template {
+ var $vars;
- function fetch($_smarty_tpl_file, $_smarty_cache_id = null, $_smarty_compile_id = null, $_smarty_display = false) {
- error_reporting(E_ALL ^ E_NOTICE); // Clobber Smarty warnings
- return Smarty::fetch($_smarty_tpl_file, $_smarty_cache_id, $_smarty_compile_id, $_smarty_display);
+ function template() {
+ $this->vars = array();
}
- function wrap($template, $title = '') {
- global $TITLE, $_gv, $_pv;
+ function render($content_template, $page_title, $wrap_file = '') {
+ extract($this->vars);
+ $path = defined('TEMPLATE_PATH')
+ ? './templates/'.THEME.'/'.TEMPLATE_PATH.'/'
+ : './templates/'.THEME.'/';
+ include($wrap_file ? $path.$wrap_file : $path.'wrap.html');
+ }
- $this->assign(array(
- 'content_template' => $template,
- 'page_title' => isset($TITLE[$title]) ? $TITLE[$title] : $title
- ));
-
- // Use a popup wrap?
- if ((isset($_gv['use_js']) and $_gv['use_js']) or
- (isset($_pv['use_js']) and $_pv['use_js'])) {
- $wrap = 'wrap-popup.html';
- } else {
- $wrap = 'wrap.html';
- }
- if (($dir = dirname($template)) != '.') {
- $this->display("$dir/$wrap");
+ function assign($var, $value = '') {
+ if (is_array($var)) {
+ foreach ($var as $k => $v) {
+ $this->vars[$k] = $v;
+ }
} else {
- $this->display($wrap);
+ $this->vars[$var] = $value;
}
}
}
-$t = new extSmarty;
-$t->template_dir = 'templates/'.THEME.'/';
-$t->compile_dir = 'c_templates';
-$t->config_dir = '.';
-$t->use_sub_dirs = false;
-$t->register_function('build_select', 'build_select');
-$t->register_function('project_js', 'build_project_js');
-$t->register_modifier('date', 'bt_date');
+$t = new template();
$t->assign(array(
'STRING' => $STRING,
'TITLE' => $TITLE,
@@ -162,6 +146,16 @@
}
// End classes -- Begin page
+
+// Set the domain if gettext is available
+if (function_exists('gettext')) {
+ define('USE_GETTEXT', true);
+ setlocale(LC_ALL, LOCALE);
+ bindtextdomain('phpbt', './locale');
+ textdomain('phpbt');
+} else {
+ define('USE_GETTEXT', false);
+}
if (!defined('NO_AUTH')) {
session_start();
Index: index.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/index.php,v
retrieving revision 1.39
retrieving revision 1.39.2.1
diff -u -r1.39 -r1.39.2.1
--- index.php 24 Jul 2003 04:47:13 -0000 1.39
+++ index.php 30 Aug 2003 22:07:12 -0000 1.39.2.1
@@ -90,16 +90,6 @@
"<img align=\"right\" src=\"jpgimages/".GenImgName()."\" ISMAP USEMAP=\"#myimagemap\" border=0>";
}
-// Show the overall bug stats
-if (USE_JPGRAPH) {
- if (!is_writeable('jpgimages')) {
- $t->assign('summary_image', $STRING['image_path_not_writeable']);
- } else {
- $t->assign('summary_image', build_image($restricted_projects));
- }
-} else {
- $t->assign('stats', grab_data($restricted_projects));
-}
if (SHOW_PROJECT_SUMMARIES) {
$querystring = $QUERY['index-projsummary-1'];
@@ -157,7 +147,7 @@
// End Create links for the project resolutions
$t->assign($aProjects);
-
+ $t->assign('resfields', $resfields);
$db->setOption('optimize', 'portability');
}
@@ -183,6 +173,7 @@
}
}
-$t->wrap('index.html', 'home');
+$t->assign('restricted_projects', $restricted_projects);
+$t->render('index.html', translate('Home'));
?>
Index: install.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/install.php,v
retrieving revision 1.39
retrieving revision 1.39.2.1
diff -u -r1.39 -r1.39.2.1
--- install.php 24 Jul 2003 04:47:13 -0000 1.39
+++ install.php 30 Aug 2003 22:07:12 -0000 1.39.2.1
@@ -111,15 +111,14 @@
header("Location: index.php");
}
-function build_select($params) {
+function build_select($selected = 0) {
global $db_types;
- extract($params);
$text = '';
foreach ($db_types as $val => $item) {
if ($selected == $val and $selected != '') $sel = ' selected';
- else $sel = '';
- $text .= "<option value=\"$val\"$sel>$item</option>";
+ else $sel = '';
+ $text .= "<option value=\"$val\"$sel>$item</option>";
}
echo $text;
}
Index: query.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/query.php,v
retrieving revision 1.98
retrieving revision 1.98.2.1
diff -u -r1.98 -r1.98.2.1
--- query.php 23 Jul 2003 01:22:12 -0000 1.98
+++ query.php 30 Aug 2003 22:07:12 -0000 1.98.2.1
@@ -25,11 +25,11 @@
include 'include.php';
function delete_saved_query($queryid) {
- global $db, $u, $me, $_gv;
+ global $db, $u, $me;
$db->query("delete from ".TBL_SAVED_QUERY." where user_id = $u
and saved_query_id = $queryid");
- if (!empty($_gv['form']) and $_gv['form'] == 'advanced') {
+ if (!empty($_GET['form']) and $_GET['form'] == 'advanced') {
header("Location: $me?op=query&form=advanced");
} else {
header("Location: $me?op=query");
@@ -37,7 +37,7 @@
}
function show_query() {
- global $db, $t, $TITLE, $u, $_gv;
+ global $db, $t, $TITLE, $u;
if ($u != 'nobody') {
// Grab the saved queries if there are any
@@ -46,19 +46,19 @@
}
// Show the advanced query form
- if (!empty($_gv['form']) and $_gv['form'] == 'advanced') {
- $t->wrap('queryform.html', 'bugquery');
+ if (!empty($_GET['form']) and $_GET['form'] == 'advanced') {
+ $t->render('queryform.html', translate('Query Bugs'));
} else { // or show the simple one
- $t->wrap('queryform-simple.html', 'bugquery');
+ $t->render('queryform-simple.html', translate('Query Bugs'));
}
}
function build_query($assignedto, $reportedby, $open) {
- global $db, $_sv, $_gv, $perm, $restricted_projects;
+ global $db, $perm, $restricted_projects;
$paramstr = '';
- foreach ($_gv as $k => $v) {
+ foreach ($_GET as $k => $v) {
$$k = $v;
if ($k == 'order' or $k == 'sort') continue;
if (is_array($v)) {
@@ -75,9 +75,9 @@
$query[] = 'b.status_id '.($open ? '' : 'not ').
'in ('.OPEN_BUG_STATUSES.')';
if ($assignedto) {
- $query[] = "assigned_to = {$_sv['uid']}";
+ $query[] = "assigned_to = {$_SESSION['uid']}";
} else {
- $query[] = "b.created_by = {$_sv['uid']}";
+ $query[] = "b.created_by = {$_SESSION['uid']}";
}
} else {
// Select boxes
@@ -124,30 +124,28 @@
}
// Search for additional comments with 'description'
- $bugs_with_comment = array();
- foreach ($db->getAll('SELECT bug_id FROM '.TBL_COMMENT.' WHERE comment_text LIKE \'%'.$description.'%\'') as $row) {
- $bugs_with_comment[] = $row['bug_id'];
+ // TODO: Change this to match the condition selected (see below for rlike, not rlike, etc.)
+ if (!empty($description)) {
+ $bugs_with_comment = array(0);
+ foreach ($db->getAll('SELECT bug_id FROM '.TBL_COMMENT.' WHERE comment_text LIKE \'%'.$description.'%\'') as $row) {
+ $bugs_with_comment[] = $row['bug_id'];
+ }
}
// Text search field(s)
- foreach(array('title','url') as $searchfield) {
+ foreach(array('title','url', 'description') as $searchfield) {
if (!empty($$searchfield)) {
switch (${$searchfield."_type"}) {
case 'like' : $cond = "like '%".$$searchfield."%'"; break;
case 'rlike' : $cond = "rlike '".$$searchfield."'"; break;
case 'not rlike' :$cond = "not rlike '".$$searchfield."'"; break;
}
- $fields[] = "$searchfield $cond";
+ $fields[] = "$searchfield $cond".
+ ($searchfield == 'description'
+ ? ' or bug_id in ('.@join(', ', $bugs_with_comment).')'
+ : '');
}
}
- if (!empty($description)) {
- switch($description_type) {
- case 'like' : $cond = 'like \'%'.$description.'%\''; break;
- case 'rlike' : $cond = 'rlike \''.$description.'\''; break;
- case 'not rlike' : $cond = 'not rlike \''.$description.'\'';
- }
- $fields[] = '(description '.$cond.(count($bugs_with_comment) ? ' OR bug_id = '.join(' OR bug_id = ', $bugs_with_comment):'').')';
- }
if (!empty($fields)) $query[] = '('.@join(' and ',$fields).')';
// Project/Version/Component
@@ -180,45 +178,40 @@
function format_bug_col($colvalue, $coltype, $bugid, $pos) {
global $select;
- $pos--;
-
switch ($coltype) {
case 'url' :
- echo "<a href=\"$colvalue\" target=\"_new\">$colvalue</a>";
+ return "<a href=\"$colvalue\" target=\"_new\">$colvalue</a>";
break;
case 'created_date' :
case 'last_modified_date' :
case 'close_date' :
- echo '<div align="center">'.
+ return '<div align="center">'.
($colvalue ? date(DATE_FORMAT, $colvalue) : ' ').
'</div>';
break;
case 'bug_id' :
case 'title' :
- echo "<a href=\"bug.php?op=show&bugid=$bugid&pos=$pos\">$colvalue</a>";
+ return "<a href=\"bug.php?op=show&bugid=$bugid&pos=$pos\">$colvalue</a>";
break;
case 'reporter' :
case 'owner' :
case 'lastmodifier' :
- echo '<div align="center">'.
+ return '<div align="center">'.
(!empty($colvalue) ? maskemail($colvalue) : '').'</div>';
break;
case 'priority' :
- echo '<div align="center">'.$select['priority'][$colvalue].'</div>';
+ return '<div align="center">'.$select['priority'][$colvalue].'</div>';
break;
default :
- echo '<div align="center">'.
+ return '<div align="center">'.
(!empty($colvalue) ? $colvalue : '').'</div>';
break;
}
}
-$t->register_modifier('modify_bug_col', 'format_bug_col');
-
function list_items($assignedto = 0, $reportedby = 0, $open = 0) {
- global $me, $db, $t, $select, $TITLE, $STRING, $_gv, $u,
- $default_db_fields, $all_db_fields, $HTTP_SESSION_VARS, $HTTP_SERVER_VARS,
- $QUERY;
+ global $me, $db, $t, $select, $TITLE, $STRING, $u,
+ $default_db_fields, $all_db_fields, $QUERY;
$query_db_fields = array(
'bug_id' => 'bug_id',
@@ -272,13 +265,13 @@
'close_date' => 'close_date'
);
- extract($_gv);
+ extract($_GET);
if (!isset($page)) {
$page = 1;
}
// Save the query if requested
if (!empty($savedqueryname)) {
- $savedquerystring = ereg_replace('&savedqueryname=.*(&?)', '\1', $HTTP_SERVER_VARS['QUERY_STRING']);
+ $savedquerystring = ereg_replace('&savedqueryname=.*(&?)', '\1', $_SERVER['QUERY_STRING']);
$savedquerystring .= '&op=doquery';
if ($savedqueryoverride) { // Updating an existing query
$db->query("update ".TBL_SAVED_QUERY." set saved_query_string = ".
@@ -296,9 +289,9 @@
}
}
if (!isset($order)) {
- if (isset($HTTP_SESSION_VARS['queryinfo']['order'])) {
- $order = $HTTP_SESSION_VARS['queryinfo']['order'];
- $sort = $HTTP_SESSION_VARS['queryinfo']['sort'];
+ if (isset($_SESSION['queryinfo']['order'])) {
+ $order = $_SESSION['queryinfo']['order'];
+ $sort = $_SESSION['queryinfo']['sort'];
} else {
$order = 'bug_id';
$sort = 'asc';
@@ -306,27 +299,27 @@
}
if (!session_is_registered('queryinfo')) {
session_register('queryinfo');
- $HTTP_SESSION_VARS['queryinfo'] = array();
+ $_SESSION['queryinfo'] = array();
}
- $HTTP_SESSION_VARS['queryinfo']['order'] = $order;
- $HTTP_SESSION_VARS['queryinfo']['sort'] = $sort;
+ $_SESSION['queryinfo']['order'] = $order;
+ $_SESSION['queryinfo']['sort'] = $sort;
- if (empty($HTTP_SESSION_VARS['queryinfo']['query']) or isset($op)) {
- list($HTTP_SESSION_VARS['queryinfo']['query'], $paramstr) =
+ if (empty($_SESSION['queryinfo']['query']) or isset($op)) {
+ list($_SESSION['queryinfo']['query'], $paramstr) =
build_query($assignedto, $reportedby, $open);
}
$nr = $db->getOne($QUERY['query-list-bugs-count'].
- (!empty($HTTP_SESSION_VARS['queryinfo']['query'])
+ (!empty($_SESSION['queryinfo']['query'])
? $QUERY['query-list-bugs-count-join'].
- $HTTP_SESSION_VARS['queryinfo']['query']
+ $_SESSION['queryinfo']['query']
: ''));
- $HTTP_SESSION_VARS['queryinfo']['numrows'] = $nr;
+ $_SESSION['queryinfo']['numrows'] = $nr;
list($selrange, $llimit) = multipages($nr, $page, "order=$order&sort=$sort");
- $desired_fields = !empty($HTTP_SESSION_VARS['db_fields']) ?
- $HTTP_SESSION_VARS['db_fields'] : $default_db_fields;
+ $desired_fields = !empty($_SESSION['db_fields']) ?
+ $_SESSION['db_fields'] : $default_db_fields;
$query_fields = array('bug_id as bug_link_id', 'severity.severity_color');
foreach ($desired_fields as $field) {
@@ -342,23 +335,23 @@
$t->assign('bugs', $db->getAll($db->modifyLimitQuery(
sprintf($QUERY['query-list-bugs'], join(', ', $query_fields),
- (!empty($HTTP_SESSION_VARS['queryinfo']['query'])
- ? "and {$HTTP_SESSION_VARS['queryinfo']['query']} " : ''),
+ (!empty($_SESSION['queryinfo']['query'])
+ ? "and {$_SESSION['queryinfo']['query']} " : ''),
$order, $sort), $llimit, $selrange)));
sorting_headers($me, $headers, $order, $sort, "page=$page".
(!empty($paramstr) ? $paramstr : ''));
- $t->wrap('buglist.html', 'buglist');
+ $t->render('buglist.html', translate('Bug List'));
}
-$reportedby = !empty($_gv['reportedby']) ? $_gv['reportedby'] : 0;
-$assignedto = !empty($_gv['assignedto']) ? $_gv['assignedto'] : 0;
-$open = !empty($_gv['open']) ? $_gv['open'] : 0;
+$reportedby = !empty($_GET['reportedby']) ? $_GET['reportedby'] : 0;
+$assignedto = !empty($_GET['assignedto']) ? $_GET['assignedto'] : 0;
+$open = !empty($_GET['open']) ? $_GET['open'] : 0;
-if (isset($_gv['op'])) switch($_gv['op']) {
+if (isset($_GET['op'])) switch($_GET['op']) {
case 'query' : show_query(); break;
- case 'doquery' : $_sv['queryinfo'] = array(); list_items(); break;
- case 'delquery' : delete_saved_query($_gv['queryid']); break;
+ case 'doquery' : $_SESSION['queryinfo'] = array(); list_items(); break;
+ case 'delquery' : delete_saved_query($_GET['queryid']); break;
case 'mybugs' : list_items($assignedto, $reportedby, $open); break;
default : show_query(); break;
}
Index: report.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/report.php,v
retrieving revision 1.26
retrieving revision 1.26.6.1
diff -u -r1.26 -r1.26.6.1
--- report.php 18 May 2002 02:59:32 -0000 1.26
+++ report.php 30 Aug 2003 22:07:12 -0000 1.26.6.1
@@ -59,7 +59,7 @@
));
$db->setOption('optimize', 'portability');
- $t->wrap('report.html', 'reporting');
+ $t->render('report.html', translate("Reporting"));
}
function new_bugs_by_date($date_range) {
Index: user.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/user.php,v
retrieving revision 1.28
retrieving revision 1.28.4.1
diff -u -r1.28 -r1.28.4.1
--- user.php 4 Jun 2003 18:47:19 -0000 1.28
+++ user.php 30 Aug 2003 22:07:12 -0000 1.28.4.1
@@ -63,8 +63,8 @@
}
$db->query("update ".TBL_AUTH_USER." set password = '$mpassword' where user_id = $u");
- $t->assign('changetext', $STRING['password_changed']);
- $t->wrap('changessaved.html', 'changessaved');
+ $t->assign('changetext', translate('Password changed'));
+ $t->render('changessaved.html', translate('Changes Saved'));
}
// Save changes to a user's preferences
@@ -92,8 +92,8 @@
" where user_id = $u");
}
- $t->assign('changetext', $STRING['prefs_changed']);
- $t->wrap('changessaved.html', 'changessaved');
+ $t->assign('changetext', translate('Preferences changed'));
+ $t->render('changessaved.html', translate('Changes Saved'));
}
@@ -129,7 +129,7 @@
'def_results' => $def_results
));
- $t->wrap('user.html', 'preferences');
+ $t->render('user.html', translate('User preferences'));
}
$perm->check_group('User');
|