[enh] Initialize a form

This commit is contained in:
kload
2014-11-08 15:46:56 +01:00
parent 0cc34124bd
commit 6c30102326
7 changed files with 60 additions and 13 deletions

BIN
sources/.controller.php.swp Normal file

Binary file not shown.

View File

@@ -1,15 +1,21 @@
<?php <?php
dispatch('/', 'hello_world'); dispatch('/', function() {
function hello_world() { set('title', T_('Configure your VPN client'));
flash('success', T_('This is a notification')); return render('settings.html.php');
set('title', T_('Hello World !')); });
return render('homepage.html.php');
}
dispatch('/lang/:locale', 'changeLocale'); dispatch_put('/settings', function() {
function changeLocale ($locale = 'en') { $success_message = "";
foreach ($_POST as $key => $value) {
$success_message = $success_message.T_("Parameter ").$key.": ".$value."<br>";
}
flash('success', $success_message);
redirect_to('/');
});
dispatch('/lang/:locale', function($locale = 'en') {
switch ($locale) { switch ($locale) {
case 'fr': case 'fr':
$_SESSION['locale'] = 'fr'; $_SESSION['locale'] = 'fr';
@@ -22,5 +28,5 @@ function changeLocale ($locale = 'en') {
redirect_to($_GET['redirect_to']); redirect_to($_GET['redirect_to']);
else else
redirect_to('/'); redirect_to('/');
} });

Binary file not shown.

Binary file not shown.

View File

@@ -1,3 +0,0 @@
<div class="hero">
<h1>Hello world !</h1>
</div>

View File

@@ -6,7 +6,7 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>YunoHost <? echo (isset($title)) ? "| ".$title : "" ?></title> <title>VPN Client <? echo (isset($title)) ? "| ".$title : "" ?></title>
<meta name="viewport" content="width=device-width"> <meta name="viewport" content="width=device-width">
<link media="all" type="text/css" href="<?= PUBLIC_DIR ?>/bootstrap/css/bootstrap.min.css" rel="stylesheet"> <link media="all" type="text/css" href="<?= PUBLIC_DIR ?>/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link media="all" type="text/css" href="<?= PUBLIC_DIR ?>/bootstrap/css/bootstrap-theme.min.css" rel="stylesheet"> <link media="all" type="text/css" href="<?= PUBLIC_DIR ?>/bootstrap/css/bootstrap-theme.min.css" rel="stylesheet">

View File

@@ -0,0 +1,44 @@
<h2><?= T_("Configure your VPN client") ?></h2>
<hr>
<div class="row">
<div class="col-sm-offset-2 col-sm-8">
<form method="post" action="settings" class="form-horizontal" role="form">
<input type="hidden" name="_method" value="put" />
<div class="form-group">
<label for="host" class="col-sm-3 control-label"><?= T_('Host') ?></label>
<div class="col-sm-9">
<input type="text" class="form-control" name="host" id="host" placeholder="vpn.neutrinet.be">
</div>
</div>
<div class="form-group">
<label for="password" class="col-sm-3 control-label"><?= T_('Password') ?></label>
<div class="col-sm-9">
<input type="password" class="form-control" name="password" id="password" placeholder="Password">
</div>
</div>
<div class="form-group">
<label for="privatekey" class="col-sm-3 control-label"><?= T_('Private key') ?></label>
<div class="col-sm-9">
<textarea rows="7" class="form-control" name="privatekey" id="privatekey">
-----BEGIN PRIVATE KEY-----
-----END PRIVATE KEY-----
</textarea>
</div>
</div>
<div class="form-group">
<div class="col-xs-offset-3 col-sm-10">
<div class="checkbox">
<label>
<input type="checkbox" name="usetcp" value="yes"> <?= T_('Use TCP') ?>
</label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-xs-offset-3 col-sm-9">
<button type="submit" class="btn btn-default"><?= T_('Save settings') ?></button>
</div>
</div>
</form>
</div>
</div>