[add] azerty layout

This commit is contained in:
Knah 2016-03-24 15:47:07 +01:00
parent 9c3d5be2a2
commit c59702b5c5
4 changed files with 14 additions and 9 deletions

View File

@ -28,31 +28,31 @@ if (!RequestUtils::isPost()) {
$primary = RequestUtils::parsePrimaryColor(); $primary = RequestUtils::parsePrimaryColor();
$secondary = RequestUtils::parseSecondaryColor(); $secondary = RequestUtils::parseSecondaryColor();
$spaceBarSize = RequestUtils::parseSpacebarSize(); $spaceBarSize = RequestUtils::parseSpacebarSize();
// Setup configuration // Setup configuration
$cfg = new Configuration($seed, $pattern, $keyboardLayout, $spaceBarSize, $text, $primary, $secondary); $cfg = new Configuration($seed, $pattern, $keyboardLayout, $spaceBarSize, $text, $primary, $secondary);
$creator = new CardCreator($cfg); $creator = new CardCreator($cfg);
// Load SVG templates // Load SVG templates
$front_template = $creator->getSvgTemplate('simple_back'); $front_template = $creator->getSvgTemplate('simple_back');
$back_template = $creator->getSvgTemplate('simple_front'); $back_template = $creator->getSvgTemplate('simple_front');
// Render SVG into tempfiles // Render SVG into tempfiles
$front = $creator->renderIntoTempfile($front_template); $front = $creator->renderIntoTempfile($front_template);
$back = $creator->renderIntoTempfile($back_template); $back = $creator->renderIntoTempfile($back_template);
// Render the PDF // Render the PDF
$doc = PDFRenderer::render($front, $back); $doc = PDFRenderer::render($front, $back);
// Prepare response PDF file header // Prepare response PDF file header
RequestUtils::preparePdfHeader(strlen($doc)); RequestUtils::preparePdfHeader(strlen($doc));
// Ignore user abort to cleanup afterwards // Ignore user abort to cleanup afterwards
ignore_user_abort(true); ignore_user_abort(true);
// Strem the PDF // Strem the PDF
echo $doc; echo $doc;
// Cleanup temporary SVG images // Cleanup temporary SVG images
unlink($back); unlink($back);
unlink($front); unlink($front);

View File

@ -49,6 +49,7 @@
<div class="row" style="margin-top: 30px;"> <div class="row" style="margin-top: 30px;">
<p>What's your Keyboard layout?</p> <p>What's your Keyboard layout?</p>
<select type="text" name="keyboardlayout"> <select type="text" name="keyboardlayout">
<option value="azerty">AZERTY</option>
<option value="qwerty">QWERTY</option> <option value="qwerty">QWERTY</option>
<option value="qwertz">QWERTZ</option> <option value="qwertz">QWERTZ</option>
</select> </select>

View File

@ -80,6 +80,10 @@ class Configuration
*/ */
public static function evalKeys($keys) public static function evalKeys($keys)
{ {
// Return azerty
if (strtolower($keys) === 'azerty') {
return 'AZERTYUIOPQSDFGHJKLMWXCVBN';
}
// Return qwertz // Return qwertz
if (strtolower($keys) === 'qwertz') { if (strtolower($keys) === 'qwertz') {
return 'QWERTZUIOPASDFGHJKLYXCVBNM'; return 'QWERTZUIOPASDFGHJKLYXCVBNM';

View File

@ -105,7 +105,7 @@ class RequestUtils
{ {
if ( if (
isset($_POST['keyboardlayout']) && isset($_POST['keyboardlayout']) &&
preg_match("/qwerty|qwertz/", $_POST['keyboardlayout']) preg_match("/azerty|qwerty|qwertz/", $_POST['keyboardlayout'])
) { ) {
return strtolower($_POST['keyboardlayout']); return strtolower($_POST['keyboardlayout']);
} }