<package name="dbedit" surlstyle="get">
<domain lang="en">

<import src="macro/util"/>
<import src="macro/editform"/>
<import src="macro/tinychat"/>
<import src="macro/admin"/>

<import pm="PApp::UserObs">access_p authen_p</import>

<package name="db" src="widget/dbedit"/>

<!--<perl>$stylesheet = $ppkg->load_stylesheet("style/identity")</perl><style apply="output" expr="$stylesheet">-->

<module name="">
<state keys="dsn user" preferences="yes"/>
<phtml><![CDATA[
<html>
<head>
<title>__"MySQL Database Editor"</title>
</head>
<body text="black" link="#1010C0" vlink="#101080" alink="red" bgcolor="white">
<table width="100%"><tr><td><h1>__"MySQL Database Editor"</h1></td><td align="right">
<:language_selector $papp_translator:>
</td></tr></table>
<:tinychat_top:>

#if !authen_p
__"You need to authentificate yourself first"<p />
<:loginbox:>
#else

<:tinychat_top:>

<:$S{dsn} ||= "DBI:mysql:":>

<?ef_begin change_db => 1:>
<table>
<tr><th align='left'>__"DSN"</th><th align='left'>__"User"</th><th align='left'>__"Password"</th></tr>
<tr>
   <td><?ef_string \$S{dsn}, 40:></td>
   <td><?ef_string \$S{user}, 10:></td>
   <td><?ef_password \$S{pass}, 10:></td>
   <td><?ef_submit __"Set":></td>
</tr>
</table>
<?ef_end:>

<:
   if (delete $S{change_db}) {
      save_prefs;
   }

   eval {
      $PApp::SQL::Database = new PApp::SQL::Database (__FILE__, $S{dsn}, $S{user}, $S{pass});
      $PApp::SQL::DBH = $PApp::SQL::Database->dbh;
   };

   my $err = $@;
   if ($err) {
      :><h2>__"Unable to connect"</h2><?$err:><:
   } else {
      $ppkg->{pkg}{db}->embed;
   }
:>
#endif

<:tinychat_bot:>
</body>
</html>
]]></phtml></module>

</domain>
</package>

