Formatting

This commit is contained in:
Miles Lott 2001-05-06 16:15:43 +00:00
parent e7f38fb001
commit 38882f39ae

View File

@ -12,15 +12,15 @@
/* $Id$ */ /* $Id$ */
$phpgw_info["flags"] = array( $phpgw_info['flags'] = array(
"noheader" => True, 'noheader' => True,
"nonavbar" => True, 'nonavbar' => True,
"currentapp" => "addressbook", 'currentapp' => 'addressbook',
"enable_contacts_class" => True, 'enable_contacts_class' => True,
"enable_nextmatchs_class" => True 'enable_nextmatchs_class' => True
); );
include("../header.inc.php"); include('../header.inc.php');
$this = CreateObject("phpgwapi.contacts"); $this = CreateObject("phpgwapi.contacts");
@ -35,66 +35,75 @@
$phpgw->common->phpgw_exit(); $phpgw->common->phpgw_exit();
} }
if (!$ab_id) { if (!$ab_id)
Header("Location: " . $phpgw->link("/addressbook/index.php")); {
} elseif (!$submit && $ab_id) { Header("Location: " . $phpgw->link('/addressbook/index.php'));
}
elseif (!$submit && $ab_id)
{
$phpgw->common->phpgw_header(); $phpgw->common->phpgw_header();
echo parse_navbar(); echo parse_navbar();
} }
$t = new Template($phpgw->common->get_tpl_dir("addressbook")); $t = new Template($phpgw->common->get_tpl_dir('addressbook'));
$t->set_file(array( $t->set_file(array(
"view" => "view.tpl", 'view' => 'view.tpl',
"view_header" => "view_header.tpl", 'view_header' => 'view_header.tpl',
"view_row" => "view_row.tpl", 'view_row' => 'view_row.tpl',
"view_footer" => "view_footer.tpl" 'view_footer' => 'view_footer.tpl'
)); ));
$customfields = array(); $customfields = array();
while (list($col,$descr) = @each($phpgw_info["user"]["preferences"]["addressbook"])) { while (list($col,$descr) = @each($phpgw_info['user']['preferences']['addressbook']))
if ( substr($col,0,6) == 'extra_' ) { {
if ( substr($col,0,6) == 'extra_' )
{
$field = ereg_replace('extra_','',$col); $field = ereg_replace('extra_','',$col);
$field = ereg_replace(' ','_',$field); $field = ereg_replace(' ','_',$field);
$customfields[$field] = ucfirst($field); $customfields[$field] = ucfirst($field);
} }
} }
while ($column = each($this->stock_contact_fields)) { while ($column = each($this->stock_contact_fields))
if (isset($phpgw_info["user"]["preferences"]["addressbook"][$column[0]]) && {
$phpgw_info["user"]["preferences"]["addressbook"][$column[0]]) { if (isset($phpgw_info['user']['preferences']['addressbook'][$column[0]]) &&
$phpgw_info['user']['preferences']['addressbook'][$column[0]])
{
$columns_to_display[$column[0]] = True; $columns_to_display[$column[0]] = True;
$colname[$column[0]] = $column[0]; $colname[$column[0]] = $column[0];
} }
} }
// No prefs? // No prefs?
if (!$columns_to_display ) { if (!$columns_to_display )
{
$columns_to_display = array( $columns_to_display = array(
"n_given" => "n_given", 'n_given' => 'n_given',
"n_family" => "n_family", 'n_family' => 'n_family',
"org_name" => "org_name", 'org_name' => 'org_name',
"tel_work" => "tel_work", 'tel_work' => 'tel_work',
"tel_home" => "tel_home", 'tel_home' => 'tel_home',
"email" => "email", 'email' => 'email',
"email_home" => "email_home" 'email_home' => 'email_home'
); );
while ($column = each($columns_to_display)) { while ($column = each($columns_to_display))
{
$colname[$column[0]] = $column[1]; $colname[$column[0]] = $column[1];
} }
$noprefs= " - " . lang("Please set your preferences for this app"); $noprefs = " - " . lang('Please set your preferences for this app');
} }
// merge in extra fields // merge in extra fields
$extrafields = array( $extrafields = array(
"ophone" => "ophone", 'ophone' => 'ophone',
"address2" => "address2", 'address2' => 'address2',
"address3" => "address3" 'address3' => 'address3'
); );
$qfields = $this->stock_contact_fields + $extrafields + $customfields; $qfields = $this->stock_contact_fields + $extrafields + $customfields;
$fields = addressbook_read_entry($ab_id,$qfields); $fields = addressbook_read_entry($ab_id,$qfields);
$record_owner = $fields[0]["owner"]; $record_owner = $fields[0]['owner'];
if ($fields[0]["access"] == 'private') if ($fields[0]["access"] == 'private')
{ {
@ -108,7 +117,8 @@
$t->set_var('lang_viewpref',lang("Address book - view") . $noprefs); $t->set_var('lang_viewpref',lang("Address book - view") . $noprefs);
@reset($qfields); @reset($qfields);
while (list($column,$null) = @each($qfields)) { // each entry column while (list($column,$null) = @each($qfields)) // each entry column
{
if(display_name($colname[$column])) if(display_name($colname[$column]))
{ {
$t->set_var('display_col',display_name($colname[$column])); $t->set_var('display_col',display_name($colname[$column]));
@ -127,7 +137,7 @@
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color); $tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
$t->set_var('th_bg',$tr_color); $t->set_var('th_bg',$tr_color);
$coldata = $fields[0][$column]; $coldata = $fields[0][$column];
// Some fields require special formatting. // Some fields require special formatting.
if ( ($column == "note" || $column == "label" || $column == "pubkey") && $coldata ) if ( ($column == "note" || $column == "label" || $column == "pubkey") && $coldata )
{ {
$datarray = explode ("\n",$coldata); $datarray = explode ("\n",$coldata);
@ -182,28 +192,28 @@
{ {
$t->set_var('ref_data',$ref . $data); $t->set_var('ref_data',$ref . $data);
} }
$t->parse("cols","view_row",True); $t->parse('cols','view_row',True);
} }
} }
$cat = CreateObject('phpgwapi.categories'); $cat = CreateObject('phpgwapi.categories');
$catinfo = $cat->return_single($fields[0]['cat_id']); $catinfo = $cat->return_single($fields[0]['cat_id']);
$catname = $catinfo[0]["name"]; $catname = $catinfo[0]['name'];
if ($fields[0]['cat_id']) { $cat_id = $fields[0]['cat_id']; } if ($fields[0]['cat_id']) { $cat_id = $fields[0]['cat_id']; }
$cat->app_name = "phpgw"; $cat->app_name = 'phpgw';
$catinfo = $cat->return_single($fields[0]['cat_id']); $catinfo = $cat->return_single($fields[0]['cat_id']);
$catname .= $catinfo[0]["name"]; $catname .= $catinfo[0]['name'];
if ($fields[0]['cat_id']) { $cat_id = $fields[0]['cat_id']; } if ($fields[0]['cat_id']) { $cat_id = $fields[0]['cat_id']; }
if (!$catname) { $catname = lang('none'); } if (!$catname) { $catname = lang('none'); }
// These are in the footer // These are in the footer
$t->set_var('lang_owner',lang("Record owner")); $t->set_var('lang_owner',lang('Record owner'));
$t->set_var('owner',$phpgw->common->grab_owner_name($record_owner)); $t->set_var('owner',$phpgw->common->grab_owner_name($record_owner));
$t->set_var('lang_access',lang("Record access")); $t->set_var('lang_access',lang("Record access"));
$t->set_var('access',$access_check); $t->set_var('access',$access_check);
$t->set_var('lang_category',lang("Category")); $t->set_var('lang_category',lang('Category'));
$t->set_var('catname',$catname); $t->set_var('catname',$catname);
$sfields = rawurlencode(serialize($fields[0])); $sfields = rawurlencode(serialize($fields[0]));
@ -225,7 +235,7 @@
$t->set_var('edit_button','<input type="submit" name="edit" value="' . lang('Edit') . '">'); $t->set_var('edit_button','<input type="submit" name="edit" value="' . lang('Edit') . '">');
} }
$copylink = '<form method="POST" action="' . $phpgw->link("/addressbook/add.php").'">'; $copylink = '<form method="POST" action="' . $phpgw->link("/addressbook/add.php").'">';
if ($fields[0]['n_family'] && $fields[0]['n_given']) if ($fields[0]['n_family'] && $fields[0]['n_given'])
{ {
$vcardlink = '<form method="POST" action="' . $phpgw->link("/addressbook/vcardout.php").'">'; $vcardlink = '<form method="POST" action="' . $phpgw->link("/addressbook/vcardout.php").'">';
@ -237,39 +247,39 @@
if ($referer) if ($referer)
{ {
$referer = ereg_replace('/phpgroupware','',$referer); $referer = ereg_replace('/phpgroupware','',$referer);
$donelink = '<form method="POST" action="' $donelink = '<form method="POST" action="'
. $phpgw->link($referer, . $phpgw->link($referer,
"cd=16&order=$order&sort=$sort&filter=$filter&start=$start&query=$query").'">'; "cd=16&order=$order&sort=$sort&filter=$filter&start=$start&query=$query").'">';
} }
else else
{ {
$donelink = '<form method="POST" action="' $donelink = '<form method="POST" action="'
. $phpgw->link("/addressbook/index.php", . $phpgw->link("/addressbook/index.php",
"cd=16&order=$order&sort=$sort&filter=$filter&start=$start&query=$query").'">'; "cd=16&order=$order&sort=$sort&filter=$filter&start=$start&query=$query").'">';
} }
$t->set_var("access_link",$access_link); $t->set_var('access_link',$access_link);
$t->set_var("ab_id",$ab_id); $t->set_var('ab_id',$ab_id);
$t->set_var("sort",$sort); $t->set_var('sort',$sort);
$t->set_var("order",$order); $t->set_var('order',$order);
$t->set_var("filter",$filter); $t->set_var('filter',$filter);
$t->set_var("start",$start); $t->set_var('start',$start);
$t->set_var("cat_id",$cat_id); $t->set_var('cat_id',$cat_id);
$t->parse("header","view_header"); $t->parse('header','view_header');
$t->parse("footer","view_footer"); $t->parse('footer','view_footer');
$t->set_var("lang_ok",lang("ok")); $t->set_var('lang_ok',lang('ok'));
$t->set_var("lang_done",lang("done")); $t->set_var('lang_done',lang('done'));
$t->set_var("lang_copy",lang("copy")); $t->set_var('lang_copy',lang('copy'));
$t->set_var("copy_fields",$sfields); $t->set_var('copy_fields',$sfields);
$t->set_var("lang_submit",lang("submit")); $t->set_var('lang_submit',lang('submit'));
$t->set_var("lang_vcard",lang("vcard")); $t->set_var('lang_vcard',lang('vcard'));
$t->set_var("done_link",$donelink); $t->set_var('done_link',$donelink);
$t->set_var("copy_link",$copylink); $t->set_var('copy_link',$copylink);
$t->set_var("vcard_link",$vcardlink); $t->set_var('vcard_link',$vcardlink);
$t->pfp("out","view"); $t->pfp('out','view');
$phpgw->common->phpgw_footer(); $phpgw->common->phpgw_footer();
?> ?>