From a17f9909b9de931497933723bdc9cba213dc01f7 Mon Sep 17 00:00:00 2001 From: Miles Lott Date: Thu, 10 May 2001 12:21:16 +0000 Subject: [PATCH] now using PHPGW_APP_TPL, and index.php is using new single template file --- addressbook/add.php | 2 +- addressbook/addfield.php | 2 +- addressbook/delete.php | 2 +- addressbook/deletefield.php | 2 +- addressbook/edit.php | 4 +- addressbook/editfield.php | 2 +- addressbook/export.php | 40 ++++++++----- addressbook/fields.php | 3 +- addressbook/import.php | 110 +++++++++++++++++++++++++----------- addressbook/index.php | 13 ++--- addressbook/preferences.php | 2 +- addressbook/vcardin.php | 2 +- addressbook/view.php | 2 +- 13 files changed, 120 insertions(+), 66 deletions(-) diff --git a/addressbook/add.php b/addressbook/add.php index 8d3fc17c93..77086bb666 100755 --- a/addressbook/add.php +++ b/addressbook/add.php @@ -23,7 +23,7 @@ $phpgw_info["flags"]["enable_contacts_class"] = True; include("../header.inc.php"); - $t = new Template($phpgw->common->get_tpl_dir("addressbook")); + $t = new Template(PHPGW_APP_TPL); $t->set_file(array("add" => "add.tpl")); $this = CreateObject("phpgwapi.contacts"); diff --git a/addressbook/addfield.php b/addressbook/addfield.php index 6777c32ebe..2c3716ae33 100644 --- a/addressbook/addfield.php +++ b/addressbook/addfield.php @@ -22,7 +22,7 @@ } - $t = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('addressbook')); + $t = new Template(PHPGW_APP_TPL); $t->set_file(array('form' => 'field_form.tpl')); $t->set_block('form','add','addhandle'); $t->set_block('form','edit','edithandle'); diff --git a/addressbook/delete.php b/addressbook/delete.php index b9738ba2ff..7884b93b0d 100755 --- a/addressbook/delete.php +++ b/addressbook/delete.php @@ -36,7 +36,7 @@ $phpgw->common->phpgw_exit(); } - $t = new Template($phpgw->common->get_tpl_dir("addressbook")); + $t = new Template(PHPGW_APP_TPL); $t->set_file(array("delete" => "delete.tpl")); if ($confirm != "true") { diff --git a/addressbook/deletefield.php b/addressbook/deletefield.php index 39e0acbd7d..bc4d4928d2 100644 --- a/addressbook/deletefield.php +++ b/addressbook/deletefield.php @@ -37,7 +37,7 @@ . "\n" . "\n"; - $t = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('addressbook')); + $t = new Template(PHPGW_APP_TPL); $t->set_file(array('field_delete' => 'delete_common.tpl')); $t->set_var('messages',lang('Are you sure you want to delete this field?')); diff --git a/addressbook/edit.php b/addressbook/edit.php index af30ed03b0..2801037c03 100755 --- a/addressbook/edit.php +++ b/addressbook/edit.php @@ -34,8 +34,8 @@ $phpgw->common->phpgw_exit(); } - $t = new Template($phpgw->common->get_tpl_dir('addressbook')); - $t->set_file(array('edit' => 'edit.tpl')); + $t = new Template(PHPGW_APP_TPL); + $t->set_file(array('edit' => 'edit.tpl')); if (!$ab_id) { diff --git a/addressbook/editfield.php b/addressbook/editfield.php index 7b392b57d0..e28ca134b3 100644 --- a/addressbook/editfield.php +++ b/addressbook/editfield.php @@ -26,7 +26,7 @@ Header('Location: ' . $phpgw->link('/addressbook/fields.php',"sort=$sort&query=$query&start=$start")); } - $t = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('addressbook')); + $t = new Template(PHPGW_APP_TPL); $t->set_file(array('form' => 'field_form.tpl')); $t->set_block('form','add','addhandle'); $t->set_block('form','edit','edithandle'); diff --git a/addressbook/export.php b/addressbook/export.php index 7e3dff8d06..68a4fdb859 100644 --- a/addressbook/export.php +++ b/addressbook/export.php @@ -31,22 +31,26 @@ $sep = SEP; - if (!$convert) { - $t = new Template($phpgw_info["server"]["app_tpl"]); + if (!$convert) + { + $t = new Template(PHPGW_APP_TPL); $t->set_file(array("export" => "export.tpl")); $dir_handle=opendir($phpgw_info["server"]["app_root"].$sep."export"); $i=0; $myfilearray=""; - while ($file = readdir($dir_handle)) { + while ($file = readdir($dir_handle)) + { #echo ""; - if ((substr($file, 0, 1) != ".") && is_file($phpgw_info["server"]["app_root"].$sep."export".$sep.$file) ) { + if ((substr($file, 0, 1) != ".") && is_file($phpgw_info["server"]["app_root"].$sep."export".$sep.$file) ) + { $myfilearray[$i] = $file; $i++; } } closedir($dir_handle); sort($myfilearray); - for ($i=0;$i'.$fname.''."\n"; } @@ -72,15 +76,19 @@ $t->pparse("out","export"); $phpgw->common->phpgw_footer(); - } else { + } + else + { include ($phpgw_info["server"]["app_root"].$sep."export".$sep.$conv_type); $buffer=array(); $this = new export_conv; // Read in user custom fields, if any $customfields = array(); - while (list($col,$descr) = @each($phpgw_info["user"]["preferences"]["addressbook"])) { - if ( substr($col,0,6) == 'extra_' ) { + while (list($col,$descr) = @each($phpgw_info["user"]["preferences"]["addressbook"])) + { + if ( substr($col,0,6) == 'extra_' ) + { $field = ereg_replace('extra_','',$col); $field = ereg_replace(' ','_',$field); $customfields[$field] = ucfirst($field); @@ -91,7 +99,8 @@ "address2" => "address2", "address3" => "address3" ); - if ($this->type != 'vcard') { + if ($this->type != 'vcard') + { $this->qfields = $this->stock_contact_fields;# + $extrafields;# + $customfields; } @@ -104,9 +113,11 @@ $buffer = $this->export_start_file($buffer); } - for ($i=0;$iids);$i++) { + for ($i=0;$iids);$i++) + { $buffer = $this->export_start_record($buffer); - while( list($name,$value) = each($this->currentrecord) ) { + while( list($name,$value) = each($this->currentrecord) ) + { $buffer = $this->export_new_attrib($buffer,$name,$value); } $buffer = $this->export_end_record($buffer); @@ -117,11 +128,14 @@ $tsvfilename = $phpgw_info['server']['temp_dir'].$sep.$tsvfilename; - if ( ($download == "on") || ($o->type == 'pdb') ) { + if ( ($download == "on") || ($o->type == 'pdb') ) + { // filename, default application/octet-stream, length of file, default nocache True $phpgw->browser->content_header($tsvfilename,'',strlen($buffer)); echo $buffer; - } else { + } + else + { echo "
\n";
 			echo $buffer;
 			echo "\n
\n"; diff --git a/addressbook/fields.php b/addressbook/fields.php index 79cca0ee18..8baf3bad6f 100644 --- a/addressbook/fields.php +++ b/addressbook/fields.php @@ -17,8 +17,7 @@ include('../header.inc.php'); - $t = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('addressbook')); - + $t = new Template(PHPGW_APP_TPL); $t->set_file(array( 'field_list_t' => 'listfields.tpl', 'field_list' => 'listfields.tpl')); diff --git a/addressbook/import.php b/addressbook/import.php index 55ef94fe63..49fd071d93 100644 --- a/addressbook/import.php +++ b/addressbook/import.php @@ -32,22 +32,26 @@ } $context = $phpgw_info["server"]["ldap_contact_context"]; - if (!$convert) { - $t = new Template($phpgw_info["server"]["app_tpl"]); + if (!$convert) + { + $t = new Template(PHPGW_APP_TPL); $t->set_file(array("import" => "import.tpl")); $dir_handle=opendir($phpgw_info["server"]["app_root"].$sep."import"); $i=0; $myfilearray=""; - while ($file = readdir($dir_handle)) { + while ($file = readdir($dir_handle)) + { //echo ""; - if ((substr($file, 0, 1) != ".") && is_file($phpgw_info["server"]["app_root"].$sep."import".$sep.$file) ) { + if ((substr($file, 0, 1) != ".") && is_file($phpgw_info["server"]["app_root"].$sep."import".$sep.$file) ) + { $myfilearray[$i] = $file; $i++; } } closedir($dir_handle); sort($myfilearray); - for ($i=0;$i'.$fname.''; } @@ -75,7 +79,9 @@ $t->set_var("cat_id",$cat_id); $t->pparse("out","import"); $phpgw->common->phpgw_footer(); - } else { + } + else + { include ($phpgw_info["server"]["app_root"].$sep."import".$sep.$conv_type); if ($private=="") { $private="public"; } @@ -84,78 +90,108 @@ $this = new import_conv; $buffer = $this->import_start_file($buffer,$basedn,$context); $fp=fopen($tsvfile,"r"); - if ($this->type == 'csv') { - while ($data = fgetcsv($fp,8000,",")) { + if ($this->type == 'csv') + { + while ($data = fgetcsv($fp,8000,",")) + { $num = count($data); $row++; - if ($row == 1) { + if ($row == 1) + { $header = $data; - } else { + } + else + { $buffer = $this->import_start_record($buffer); - for ($c=0; $c<$num; $c++ ) { + for ($c=0; $c<$num; $c++ ) + { //Send name/value pairs along with the buffer - if ($this->import[$header[$c]]!="" && $data[$c]!="") { + if ($this->import[$header[$c]]!="" && $data[$c]!="") + { $buffer = $this->import_new_attrib($buffer, $this->import[$header[$c]],$data[$c]); } } $buffer = $this->import_end_record($buffer,$private); } } - } elseif ($this->type == 'ldif') { - while ($data = fgets($fp,8000)) { + } + elseif ($this->type == 'ldif') + { + while ($data = fgets($fp,8000)) + { $url = ""; list($name,$value,$extra) = split(':', $data); - if (substr($name,0,2) == 'dn') { + if (substr($name,0,2) == 'dn') + { $buffer = $this->import_start_record($buffer); } $test = trim($value); - if ($name && !empty($test) && $extra) { + if ($name && !empty($test) && $extra) + { // Probable url string $url = $test; $value = $extra; - } elseif ($name && empty($test) && $extra) { + } + elseif ($name && empty($test) && $extra) + { // Probable multiline encoding $newval = base64_decode(trim($extra)); $value = $newval; //echo $name.':'.$value; } - if ($name && $value) { + if ($name && $value) + { $test = split(',mail=',$value); - if ($test[1]) { + if ($test[1]) + { $name = "mail"; $value = $test[1]; } - if ($url) { + if ($url) + { $name = "homeurl"; $value = $url. ':' . $value; } //echo '
'.$j.': '.$name.' => '.$value; - if ($this->import[$name] != "" && $value != "") { + if ($this->import[$name] != "" && $value != "") + { $buffer = $this->import_new_attrib($buffer, $this->import[$name],$value); } - } else { + } + else + { $buffer = $this->import_end_record($buffer,$private); } } - } else { - while ($data = fgets($fp,8000)) { + } + else + { + while ($data = fgets($fp,8000)) + { list($name,$value,$extra) = split(':', $data); - if (strtolower(substr($name,0,5)) == 'begin') { + if (strtolower(substr($name,0,5)) == 'begin') + { $buffer = $this->import_start_record($buffer); } - if (substr($value,0,5) == "http") { + if (substr($value,0,5) == "http") + { $value = $value . ":".$extra; } - if ($name && $value) { + if ($name && $value) + { reset($this->import); - while ( list($fname,$fvalue) = each($this->import) ) { - if ( strstr(strtolower($name), $this->import[$fname]) ) { + while ( list($fname,$fvalue) = each($this->import) ) + { + if ( strstr(strtolower($name), $this->import[$fname]) ) + { $buffer = $this->import_new_attrib($buffer,$name,$value); } } - } else { + } + else + { $buffer = $this->import_end_record($buffer); } } @@ -164,19 +200,25 @@ fclose($fp); $buffer = $this->import_end_file($buffer,$private,$cat_id); - if ($download == "") { - if($conv_type=="Debug LDAP" || $conv_type=="Debug SQL" ) { + if ($download == "") + { + if($conv_type=="Debug LDAP" || $conv_type=="Debug SQL" ) + { // filename, default application/octet-stream, length of file, default nocache True $phpgw->browser->content_header($tsvfilename,'',strlen($buffer)); echo $buffer; - } else { + } + else + { echo "
$buffer
"; echo ''.lang("OK").''; $phpgw->common->phpgw_footer(); } - } else { + } + else + { echo "
$buffer
"; echo 'common->get_tpl_dir('addressbook')); - $t->set_file(array( - 'addressbook_header' => 'header.tpl', - 'column' => 'column.tpl', - 'row' => 'row.tpl', - 'addressbook_footer' => 'footer.tpl' - )); + $t = new Template(PHPGW_APP_TPL); + $t->set_file(array('addressbook_list_t' => 'index.tpl')); + $t->set_block('addressbook_list_t','addressbook_header','addressbook_header'); + $t->set_block('addressbook_list_t','column','column'); + $t->set_block('addressbook_list_t','row','row'); + $t->set_block('addressbook_list_t','addressbook_footer','addressbook_footer'); $this = CreateObject('phpgwapi.contacts'); //$this->delete_all($phpgw_info['user']['account_id']); diff --git a/addressbook/preferences.php b/addressbook/preferences.php index ea489384ec..305cc3c894 100644 --- a/addressbook/preferences.php +++ b/addressbook/preferences.php @@ -92,7 +92,7 @@ echo "

" . $phpgw->common->error_list($errors) . "
"; } - $t = new Template($phpgw->common->get_tpl_dir("addressbook")); + $t = new Template(PHPGW_APP_TPL); $t->set_file(array( "preferences" => "preferences.tpl", )); diff --git a/addressbook/vcardin.php b/addressbook/vcardin.php index 5d724ba83c..4b49e65f73 100644 --- a/addressbook/vcardin.php +++ b/addressbook/vcardin.php @@ -89,7 +89,7 @@ echo "
You must select a vcard. (*.vcf)


"; } - $t = new Template($phpgw->common->get_tpl_dir("addressbook")); + $t = new Template(PHPGW_APP_TPL); $t->set_file(array("vcardin" => "vcardin.tpl")); $vcard_header = "

 " . lang("Address book - VCard in") . "


"; diff --git a/addressbook/view.php b/addressbook/view.php index f30e1cdd4e..35da0554e6 100755 --- a/addressbook/view.php +++ b/addressbook/view.php @@ -45,7 +45,7 @@ echo parse_navbar(); } - $t = new Template($phpgw->common->get_tpl_dir('addressbook')); + $t = new Template(PHPGW_APP_TPL); $t->set_file(array( 'view' => 'view.tpl', 'view_header' => 'view_header.tpl',