You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
182 lines
6.0 KiB
PHTML
182 lines
6.0 KiB
PHTML
17 years ago
|
<?php
|
||
17 years ago
|
|
||
17 years ago
|
$headers=array();
|
||
17 years ago
|
foreach(array_keys($fm_struct) as $row){
|
||
|
list($editible,$view,$type)=$fm_struct[$row];
|
||
|
$title = $PALANG['pFetchmail_field_' . $row];
|
||
|
$comment = $PALANG['pFetchmail_desc_' . $row];
|
||
17 years ago
|
if ($view){
|
||
17 years ago
|
$headers[]=array($editible, $view, $type, $title, $comment);
|
||
17 years ago
|
}
|
||
|
}
|
||
17 years ago
|
|
||
17 years ago
|
if ($edit || $new) { # edit mode
|
||
17 years ago
|
echo '<div id="edit_form">';
|
||
|
echo '<form name="fetchmail" method="post">';
|
||
17 years ago
|
print fetchmail_edit_row($formvars);
|
||
17 years ago
|
|
||
17 years ago
|
} else { # display mode
|
||
17 years ago
|
print '<div id="overview">';
|
||
|
print '<form name="overview" method="post">';
|
||
|
print "<table id=\"log_table\" border=0>\n";
|
||
17 years ago
|
print " <tr>\n";
|
||
|
print " <td colspan=\"".(sizeof($headers)+2)."\"><h3>".$PALANG['pFetchmail_welcome'].$user_domains."</h3></td>\n";
|
||
|
print " </tr>\n";
|
||
|
print " <tr class=\"header\">\n";
|
||
|
foreach($headers as $row){
|
||
|
list($editible,$view,$type,$title,$comment)=$row;
|
||
|
print " <td>" . $title . "</td>\n";
|
||
|
}
|
||
17 years ago
|
print "<td> </td>";
|
||
17 years ago
|
print "<td> </td>";
|
||
17 years ago
|
print " </tr>\n";
|
||
|
|
||
17 years ago
|
if (sizeof ($tFmail) > 0){
|
||
|
foreach($tFmail as $row){
|
||
17 years ago
|
print " <tr class=\"hilightoff\" onMouseOver=\"className='hilighton';\" onMouseOut=\"className='hilightoff';\">\n";
|
||
|
foreach($row as $key=>$val){
|
||
17 years ago
|
|
||
17 years ago
|
if (!isset($fm_struct[$key])) continue; # TODO: not really nice, but avoids undefined index warnings ;-)
|
||
17 years ago
|
list($editible,$view,$type)=$fm_struct[$key];
|
||
17 years ago
|
if ($view){
|
||
|
$func="_listview_".$type;
|
||
|
print " <td nowrap>" . (function_exists($func)?$func($val):$val) . "</td>\n";
|
||
|
}
|
||
17 years ago
|
|
||
17 years ago
|
}
|
||
17 years ago
|
print "<td><a href=\"fetchmail.php?edit=" . $row['id'] . "\">" . $PALANG['edit'] . "</a></td>";
|
||
17 years ago
|
print " <td><a href=\"fetchmail.php?delete=" . $row['id'] . "\"onclick=\"return confirm ('"
|
||
|
. $PALANG['confirm'] . $PALANG['pMenu_fetchmail'] . ": ". htmlentities($row['src_user']) . " @ "
|
||
|
. htmlentities($row['src_server']) . "')\">" . $PALANG['del'] . "</a></td>\n";
|
||
17 years ago
|
print " </tr>\n";
|
||
17 years ago
|
}
|
||
|
}
|
||
17 years ago
|
print "</table>";
|
||
|
print "<p />\n";
|
||
|
print "</form>\n";
|
||
|
print "</div>\n";
|
||
|
|
||
17 years ago
|
print "<p><a href='?new=1'>".$PALANG['pFetchmail_new_entry']."</a></p>\n";
|
||
17 years ago
|
|
||
17 years ago
|
} # end display mode
|
||
17 years ago
|
|
||
|
function fetchmail_edit_row($data=array()){
|
||
17 years ago
|
global $fm_struct,$fm_defaults,$PALANG;
|
||
|
$id=$data["id"];
|
||
|
$_id=$data["id"]*100+1;
|
||
|
$ret="<table>";
|
||
17 years ago
|
$ret .= '<tr><td colspan="3"><h3>' . $PALANG['pMenu_fetchmail'] . '</h3></td></tr>';
|
||
17 years ago
|
# TODO: $formvars possibly contains db-specific boolean values
|
||
|
# TODO: no problems with MySQL, to be tested with PgSQL
|
||
|
# TODO: undefined values may also occour
|
||
17 years ago
|
foreach($fm_struct as $key=>$struct){
|
||
17 years ago
|
list($editible,$view,$type)=$struct;
|
||
|
$title = $PALANG['pFetchmail_field_' . $key];
|
||
|
$comment = $PALANG['pFetchmail_desc_' . $key];
|
||
17 years ago
|
if ($editible){
|
||
|
$ret.="<tr><td align=left valign=top><label for=${_id} style='width:20em;'>${title}: </label></td>";
|
||
|
$ret.="<td align=left style='padding-left:.25em;padding-right:.25em;background-color:white;'>";
|
||
|
$func="_edit_".$type;
|
||
|
if (! function_exists($func))
|
||
|
$func="_edit_text";
|
||
|
$val=isset($data[$key])
|
||
|
?$data[$key]
|
||
|
:(! is_array($fm_defaults[$key])
|
||
|
?$fm_defaults[$key]
|
||
|
:''
|
||
|
);
|
||
|
$fm_defaults_key = ""; if (isset($fm_defaults[$key])) $fm_defaults_key = $fm_defaults[$key];
|
||
|
$ret.=$func($_id++,$key,$fm_defaults_key,$val);
|
||
|
$ret.="</td><td align=left valign=top><i> ${comment}</i></td></tr>\n";
|
||
|
}
|
||
|
elseif($view){
|
||
|
$func="_view_".$type;
|
||
|
$val=isset($data[$key])
|
||
|
?(function_exists($func)
|
||
|
?$func($data[$key])
|
||
|
:nl2br($data[$key])
|
||
|
)
|
||
|
:"--x--";
|
||
|
$ret.="<tr><td align=left valign=top>${title}: </label></td>";
|
||
|
$ret.="<td align=left valign=top style='padding-left:.25em;padding-right:.25em;background-color:white;'>".$val;
|
||
|
$ret.="</td><td align=left valign=top><i> ${comment}</i></td></tr>\n";
|
||
|
}
|
||
|
}
|
||
17 years ago
|
$ret.="<tr><td align=center colspan=3>
|
||
|
<input type=submit name=save value='" . $PALANG['save'] . "'>
|
||
|
<input type=submit name=cancel value='" . $PALANG['cancel'] . "'>
|
||
|
";
|
||
17 years ago
|
if ($id){
|
||
|
$ret.="<input type=hidden name=edit value='${id}'>";
|
||
|
}
|
||
|
$ret.="</td></tr>\n";
|
||
|
$ret.="</table>\n";
|
||
17 years ago
|
$ret.="<p />\n";
|
||
|
$ret.="</form>\n";
|
||
|
$ret.="</div>\n";
|
||
17 years ago
|
return $ret;
|
||
17 years ago
|
}
|
||
|
|
||
|
function _edit_text($id,$key,$def_vals,$val=""){
|
||
17 years ago
|
$val=htmlspecialchars($val);
|
||
|
return "<input type=text name=${key} id=${id} value='${val}'>";
|
||
17 years ago
|
}
|
||
|
|
||
|
function _edit_password($id,$key,$def_vals,$val=""){
|
||
17 years ago
|
$val=preg_replace("{.}","*",$val);
|
||
|
return "<input type=password name=${key} id=${id} value='${val}'>";
|
||
17 years ago
|
}
|
||
|
|
||
|
function _edit_num($id,$key,$def_vals,$val=""){
|
||
17 years ago
|
$val=(int)($val);
|
||
|
return "<input type=text name=${key} id=${id} value='${val}'>";
|
||
17 years ago
|
}
|
||
|
|
||
|
function _edit_bool($id,$key,$def_vals,$val=""){
|
||
17 years ago
|
$ret="<input type=checkbox name=${key} id=${id}";
|
||
|
if ($val)
|
||
|
$ret.=" checked";
|
||
|
$ret.=">";
|
||
|
return $ret;
|
||
17 years ago
|
}
|
||
|
|
||
|
function _edit_longtext($id,$key,$def_vals,$val=""){
|
||
17 years ago
|
$val=htmlspecialchars($val);
|
||
|
return "<textarea name=${key} id=${id} rows=2 style='width:20em;'>${val}</textarea>";
|
||
17 years ago
|
}
|
||
|
|
||
|
function _edit_enum($id,$key,$def_vals,$val=""){
|
||
17 years ago
|
$ret="<select name=${key} id=${id}>";
|
||
|
foreach($def_vals as $opt_val){
|
||
|
$ret.="<option";
|
||
|
if ($opt_val==$val)
|
||
|
$ret.=" selected";
|
||
|
$ret.=">${opt_val}</option>\n";
|
||
|
}
|
||
|
$ret.="</select>\n";
|
||
|
return $ret;
|
||
17 years ago
|
}
|
||
|
|
||
|
function _listview_id($val){
|
||
17 years ago
|
return "<a href='?edit=${val}'> ${val} </a>";
|
||
17 years ago
|
}
|
||
|
|
||
|
function _listview_bool($val){
|
||
17 years ago
|
return $val?"+":"";
|
||
17 years ago
|
}
|
||
|
|
||
|
function _listview_longtext($val){
|
||
17 years ago
|
return strlen($val)?"Text - ".strlen($val)." chars":"--x--";
|
||
17 years ago
|
}
|
||
|
|
||
|
function _listview_text($val){
|
||
17 years ago
|
return sizeof($val)?$val:"--x--";
|
||
17 years ago
|
}
|
||
|
|
||
|
function _listview_password($val){
|
||
17 years ago
|
return preg_replace("{.}","*",$val);
|
||
17 years ago
|
}
|
||
|
|
||
17 years ago
|
/* vim: set ft=php expandtab softtabstop=3 tabstop=3 shiftwidth=3: */
|
||
17 years ago
|
?>
|