now using PHPGW_APP_TPL, and index.php is using new single template file

This commit is contained in:
Miles Lott 2001-05-10 12:21:16 +00:00
parent 20c373ce1b
commit a17f9909b9
13 changed files with 120 additions and 66 deletions

View File

@ -23,7 +23,7 @@
$phpgw_info["flags"]["enable_contacts_class"] = True; $phpgw_info["flags"]["enable_contacts_class"] = True;
include("../header.inc.php"); 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")); $t->set_file(array("add" => "add.tpl"));
$this = CreateObject("phpgwapi.contacts"); $this = CreateObject("phpgwapi.contacts");

View File

@ -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_file(array('form' => 'field_form.tpl'));
$t->set_block('form','add','addhandle'); $t->set_block('form','add','addhandle');
$t->set_block('form','edit','edithandle'); $t->set_block('form','edit','edithandle');

View File

@ -36,7 +36,7 @@
$phpgw->common->phpgw_exit(); $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")); $t->set_file(array("delete" => "delete.tpl"));
if ($confirm != "true") { if ($confirm != "true") {

View File

@ -37,7 +37,7 @@
. "<input type=\"hidden\" name=\"start\" value=\"$start\">\n" . "<input type=\"hidden\" name=\"start\" value=\"$start\">\n"
. "<input type=\"hidden\" name=\"field\" value=\"$field\">\n"; . "<input type=\"hidden\" name=\"field\" value=\"$field\">\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_file(array('field_delete' => 'delete_common.tpl'));
$t->set_var('messages',lang('Are you sure you want to delete this field?')); $t->set_var('messages',lang('Are you sure you want to delete this field?'));

View File

@ -34,8 +34,8 @@
$phpgw->common->phpgw_exit(); $phpgw->common->phpgw_exit();
} }
$t = new Template($phpgw->common->get_tpl_dir('addressbook')); $t = new Template(PHPGW_APP_TPL);
$t->set_file(array('edit' => 'edit.tpl')); $t->set_file(array('edit' => 'edit.tpl'));
if (!$ab_id) if (!$ab_id)
{ {

View File

@ -26,7 +26,7 @@
Header('Location: ' . $phpgw->link('/addressbook/fields.php',"sort=$sort&query=$query&start=$start")); 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_file(array('form' => 'field_form.tpl'));
$t->set_block('form','add','addhandle'); $t->set_block('form','add','addhandle');
$t->set_block('form','edit','edithandle'); $t->set_block('form','edit','edithandle');

View File

@ -31,22 +31,26 @@
$sep = SEP; $sep = SEP;
if (!$convert) { if (!$convert)
$t = new Template($phpgw_info["server"]["app_tpl"]); {
$t = new Template(PHPGW_APP_TPL);
$t->set_file(array("export" => "export.tpl")); $t->set_file(array("export" => "export.tpl"));
$dir_handle=opendir($phpgw_info["server"]["app_root"].$sep."export"); $dir_handle=opendir($phpgw_info["server"]["app_root"].$sep."export");
$i=0; $myfilearray=""; $i=0; $myfilearray="";
while ($file = readdir($dir_handle)) { while ($file = readdir($dir_handle))
{
#echo "<!-- ".is_file($phpgw_info["server"]["app_root"].$sep."conv".$sep.$file)." -->"; #echo "<!-- ".is_file($phpgw_info["server"]["app_root"].$sep."conv".$sep.$file)." -->";
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; $myfilearray[$i] = $file;
$i++; $i++;
} }
} }
closedir($dir_handle); closedir($dir_handle);
sort($myfilearray); sort($myfilearray);
for ($i=0;$i<count($myfilearray);$i++) { for ($i=0;$i<count($myfilearray);$i++)
{
$fname = ereg_replace('_',' ',$myfilearray[$i]); $fname = ereg_replace('_',' ',$myfilearray[$i]);
$conv .= ' <OPTION VALUE="'.$myfilearray[$i].'">'.$fname.'</OPTION>'."\n"; $conv .= ' <OPTION VALUE="'.$myfilearray[$i].'">'.$fname.'</OPTION>'."\n";
} }
@ -72,15 +76,19 @@
$t->pparse("out","export"); $t->pparse("out","export");
$phpgw->common->phpgw_footer(); $phpgw->common->phpgw_footer();
} else { }
else
{
include ($phpgw_info["server"]["app_root"].$sep."export".$sep.$conv_type); include ($phpgw_info["server"]["app_root"].$sep."export".$sep.$conv_type);
$buffer=array(); $buffer=array();
$this = new export_conv; $this = new export_conv;
// Read in user custom fields, if any // Read in user custom fields, if any
$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);
@ -91,7 +99,8 @@
"address2" => "address2", "address2" => "address2",
"address3" => "address3" "address3" => "address3"
); );
if ($this->type != 'vcard') { if ($this->type != 'vcard')
{
$this->qfields = $this->stock_contact_fields;# + $extrafields;# + $customfields; $this->qfields = $this->stock_contact_fields;# + $extrafields;# + $customfields;
} }
@ -104,9 +113,11 @@
$buffer = $this->export_start_file($buffer); $buffer = $this->export_start_file($buffer);
} }
for ($i=0;$i<count($this->ids);$i++) { for ($i=0;$i<count($this->ids);$i++)
{
$buffer = $this->export_start_record($buffer); $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_new_attrib($buffer,$name,$value);
} }
$buffer = $this->export_end_record($buffer); $buffer = $this->export_end_record($buffer);
@ -117,11 +128,14 @@
$tsvfilename = $phpgw_info['server']['temp_dir'].$sep.$tsvfilename; $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 // filename, default application/octet-stream, length of file, default nocache True
$phpgw->browser->content_header($tsvfilename,'',strlen($buffer)); $phpgw->browser->content_header($tsvfilename,'',strlen($buffer));
echo $buffer; echo $buffer;
} else { }
else
{
echo "<pre>\n"; echo "<pre>\n";
echo $buffer; echo $buffer;
echo "\n</pre>\n"; echo "\n</pre>\n";

View File

@ -17,8 +17,7 @@
include('../header.inc.php'); include('../header.inc.php');
$t = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('addressbook')); $t = new Template(PHPGW_APP_TPL);
$t->set_file(array( $t->set_file(array(
'field_list_t' => 'listfields.tpl', 'field_list_t' => 'listfields.tpl',
'field_list' => 'listfields.tpl')); 'field_list' => 'listfields.tpl'));

View File

@ -32,22 +32,26 @@
} }
$context = $phpgw_info["server"]["ldap_contact_context"]; $context = $phpgw_info["server"]["ldap_contact_context"];
if (!$convert) { if (!$convert)
$t = new Template($phpgw_info["server"]["app_tpl"]); {
$t = new Template(PHPGW_APP_TPL);
$t->set_file(array("import" => "import.tpl")); $t->set_file(array("import" => "import.tpl"));
$dir_handle=opendir($phpgw_info["server"]["app_root"].$sep."import"); $dir_handle=opendir($phpgw_info["server"]["app_root"].$sep."import");
$i=0; $myfilearray=""; $i=0; $myfilearray="";
while ($file = readdir($dir_handle)) { while ($file = readdir($dir_handle))
{
//echo "<!-- ".is_file($phpgw_info["server"]["app_root"].$sep."import".$sep.$file)." -->"; //echo "<!-- ".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) ) { if ((substr($file, 0, 1) != ".") && is_file($phpgw_info["server"]["app_root"].$sep."import".$sep.$file) )
{
$myfilearray[$i] = $file; $myfilearray[$i] = $file;
$i++; $i++;
} }
} }
closedir($dir_handle); closedir($dir_handle);
sort($myfilearray); sort($myfilearray);
for ($i=0;$i<count($myfilearray);$i++) { for ($i=0;$i<count($myfilearray);$i++)
{
$fname = ereg_replace('_',' ',$myfilearray[$i]); $fname = ereg_replace('_',' ',$myfilearray[$i]);
$conv .= '<OPTION VALUE="'.$myfilearray[$i].'">'.$fname.'</OPTION>'; $conv .= '<OPTION VALUE="'.$myfilearray[$i].'">'.$fname.'</OPTION>';
} }
@ -75,7 +79,9 @@
$t->set_var("cat_id",$cat_id); $t->set_var("cat_id",$cat_id);
$t->pparse("out","import"); $t->pparse("out","import");
$phpgw->common->phpgw_footer(); $phpgw->common->phpgw_footer();
} else { }
else
{
include ($phpgw_info["server"]["app_root"].$sep."import".$sep.$conv_type); include ($phpgw_info["server"]["app_root"].$sep."import".$sep.$conv_type);
if ($private=="") { $private="public"; } if ($private=="") { $private="public"; }
@ -84,78 +90,108 @@
$this = new import_conv; $this = new import_conv;
$buffer = $this->import_start_file($buffer,$basedn,$context); $buffer = $this->import_start_file($buffer,$basedn,$context);
$fp=fopen($tsvfile,"r"); $fp=fopen($tsvfile,"r");
if ($this->type == 'csv') { if ($this->type == 'csv')
while ($data = fgetcsv($fp,8000,",")) { {
while ($data = fgetcsv($fp,8000,","))
{
$num = count($data); $num = count($data);
$row++; $row++;
if ($row == 1) { if ($row == 1)
{
$header = $data; $header = $data;
} else { }
else
{
$buffer = $this->import_start_record($buffer); $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 //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_new_attrib($buffer, $this->import[$header[$c]],$data[$c]);
} }
} }
$buffer = $this->import_end_record($buffer,$private); $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 = ""; $url = "";
list($name,$value,$extra) = split(':', $data); list($name,$value,$extra) = split(':', $data);
if (substr($name,0,2) == 'dn') { if (substr($name,0,2) == 'dn')
{
$buffer = $this->import_start_record($buffer); $buffer = $this->import_start_record($buffer);
} }
$test = trim($value); $test = trim($value);
if ($name && !empty($test) && $extra) { if ($name && !empty($test) && $extra)
{
// Probable url string // Probable url string
$url = $test; $url = $test;
$value = $extra; $value = $extra;
} elseif ($name && empty($test) && $extra) { }
elseif ($name && empty($test) && $extra)
{
// Probable multiline encoding // Probable multiline encoding
$newval = base64_decode(trim($extra)); $newval = base64_decode(trim($extra));
$value = $newval; $value = $newval;
//echo $name.':'.$value; //echo $name.':'.$value;
} }
if ($name && $value) { if ($name && $value)
{
$test = split(',mail=',$value); $test = split(',mail=',$value);
if ($test[1]) { if ($test[1])
{
$name = "mail"; $name = "mail";
$value = $test[1]; $value = $test[1];
} }
if ($url) { if ($url)
{
$name = "homeurl"; $name = "homeurl";
$value = $url. ':' . $value; $value = $url. ':' . $value;
} }
//echo '<br>'.$j.': '.$name.' => '.$value; //echo '<br>'.$j.': '.$name.' => '.$value;
if ($this->import[$name] != "" && $value != "") { if ($this->import[$name] != "" && $value != "")
{
$buffer = $this->import_new_attrib($buffer, $this->import[$name],$value); $buffer = $this->import_new_attrib($buffer, $this->import[$name],$value);
} }
} else { }
else
{
$buffer = $this->import_end_record($buffer,$private); $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); 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); $buffer = $this->import_start_record($buffer);
} }
if (substr($value,0,5) == "http") { if (substr($value,0,5) == "http")
{
$value = $value . ":".$extra; $value = $value . ":".$extra;
} }
if ($name && $value) { if ($name && $value)
{
reset($this->import); reset($this->import);
while ( list($fname,$fvalue) = each($this->import) ) { while ( list($fname,$fvalue) = each($this->import) )
if ( strstr(strtolower($name), $this->import[$fname]) ) { {
if ( strstr(strtolower($name), $this->import[$fname]) )
{
$buffer = $this->import_new_attrib($buffer,$name,$value); $buffer = $this->import_new_attrib($buffer,$name,$value);
} }
} }
} else { }
else
{
$buffer = $this->import_end_record($buffer); $buffer = $this->import_end_record($buffer);
} }
} }
@ -164,19 +200,25 @@
fclose($fp); fclose($fp);
$buffer = $this->import_end_file($buffer,$private,$cat_id); $buffer = $this->import_end_file($buffer,$private,$cat_id);
if ($download == "") { if ($download == "")
if($conv_type=="Debug LDAP" || $conv_type=="Debug SQL" ) { {
if($conv_type=="Debug LDAP" || $conv_type=="Debug SQL" )
{
// filename, default application/octet-stream, length of file, default nocache True // filename, default application/octet-stream, length of file, default nocache True
$phpgw->browser->content_header($tsvfilename,'',strlen($buffer)); $phpgw->browser->content_header($tsvfilename,'',strlen($buffer));
echo $buffer; echo $buffer;
} else { }
else
{
echo "<pre>$buffer</pre>"; echo "<pre>$buffer</pre>";
echo '<a href="'.$phpgw->link("/addressbook/index.php", echo '<a href="'.$phpgw->link("/addressbook/index.php",
"sort=$sort&order=$order&filter=$filter&start=$start&query=$query&cat_id=$cat_id") "sort=$sort&order=$order&filter=$filter&start=$start&query=$query&cat_id=$cat_id")
. '">'.lang("OK").'</a>'; . '">'.lang("OK").'</a>';
$phpgw->common->phpgw_footer(); $phpgw->common->phpgw_footer();
} }
} else { }
else
{
echo "<pre>$buffer</pre>"; echo "<pre>$buffer</pre>";
echo '<a href="'.$phpgw->link("/addressbook/index.php", echo '<a href="'.$phpgw->link("/addressbook/index.php",
"sort=$sort&order=$order&filter=$filter&start=$start&query=$query&cat_id=$cat_id") "sort=$sort&order=$order&filter=$filter&start=$start&query=$query&cat_id=$cat_id")

View File

@ -20,13 +20,12 @@
include('../header.inc.php'); include('../header.inc.php');
$t = new Template($phpgw->common->get_tpl_dir('addressbook')); $t = new Template(PHPGW_APP_TPL);
$t->set_file(array( $t->set_file(array('addressbook_list_t' => 'index.tpl'));
'addressbook_header' => 'header.tpl', $t->set_block('addressbook_list_t','addressbook_header','addressbook_header');
'column' => 'column.tpl', $t->set_block('addressbook_list_t','column','column');
'row' => 'row.tpl', $t->set_block('addressbook_list_t','row','row');
'addressbook_footer' => 'footer.tpl' $t->set_block('addressbook_list_t','addressbook_footer','addressbook_footer');
));
$this = CreateObject('phpgwapi.contacts'); $this = CreateObject('phpgwapi.contacts');
//$this->delete_all($phpgw_info['user']['account_id']); //$this->delete_all($phpgw_info['user']['account_id']);

View File

@ -92,7 +92,7 @@
echo "<p><center>" . $phpgw->common->error_list($errors) . "</center>"; echo "<p><center>" . $phpgw->common->error_list($errors) . "</center>";
} }
$t = new Template($phpgw->common->get_tpl_dir("addressbook")); $t = new Template(PHPGW_APP_TPL);
$t->set_file(array( $t->set_file(array(
"preferences" => "preferences.tpl", "preferences" => "preferences.tpl",
)); ));

View File

@ -89,7 +89,7 @@
echo "<B><CENTER>You must select a vcard. (*.vcf)</B></CENTER><BR><BR>"; echo "<B><CENTER>You must select a vcard. (*.vcf)</B></CENTER><BR><BR>";
} }
$t = new Template($phpgw->common->get_tpl_dir("addressbook")); $t = new Template(PHPGW_APP_TPL);
$t->set_file(array("vcardin" => "vcardin.tpl")); $t->set_file(array("vcardin" => "vcardin.tpl"));
$vcard_header = "<p>&nbsp;<b>" . lang("Address book - VCard in") . "</b><hr><p>"; $vcard_header = "<p>&nbsp;<b>" . lang("Address book - VCard in") . "</b><hr><p>";

View File

@ -45,7 +45,7 @@
echo parse_navbar(); echo parse_navbar();
} }
$t = new Template($phpgw->common->get_tpl_dir('addressbook')); $t = new Template(PHPGW_APP_TPL);
$t->set_file(array( $t->set_file(array(
'view' => 'view.tpl', 'view' => 'view.tpl',
'view_header' => 'view_header.tpl', 'view_header' => 'view_header.tpl',