This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once 'FormControl.php'; | |
require_once dirname(__FILE__) . '/../functions.php'; | |
class Checkbox extends FormControl | |
{ | |
public function __construct($name, $errors) | |
{ | |
parent::__construct($name, $errors, 'checkbox'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="field"> | |
<label class="label" for="email">Email</label> | |
<div class="control"> | |
<input | |
id="email" | |
name="email" | |
type="email" | |
value="adam@gmail." | |
class="input is-danger" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once 'FormControl.php'; | |
require_once dirname(__FILE__) . '/../functions.php'; | |
class Input extends FormControl | |
{ | |
public function __construct($name, $errors, $type = 'text') | |
{ | |
parent::__construct($name, $errors, $type); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once dirname(__FILE__) . '/../functions.php'; | |
abstract class FormControl | |
{ | |
public static function make($name, $errors = null, $type = null) | |
{ | |
return new static($name, $errors, $type); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once dirname(__FILE__) . '/i18n/I18n.php'; | |
function __($key, $replacements = []) | |
{ | |
return I18n::__($key, $replacements); | |
} | |
function lang() | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$messages = [ | |
'en' => [ | |
'title' => 'Sign Up', | |
'subtitle' => 'Join our awesome community 😀', | |
'hello_user' => 'Hello {user}', | |
// ... | |
], | |
'ar' => [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$languages = [ | |
'en' => 'English', | |
'ar' => 'Arabic (العربية)', | |
]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class I18n | |
{ | |
public const DEFAULT_LANG = 'en'; | |
private static $allMessages; | |
private static $supportedLangs; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require './HttpAcceptLanguageHeaderLocaleDetector.php'; | |
require './IpAddressLocaleDetector.php'; | |
function detect_user_locales() | |
{ | |
$locales = HttpAcceptLanguageHeaderLocaleDetector::detect(); | |
if (count($locales) == 0) { | |
$locales = IPAddressLocaleDetector::detect(); |