. */ namespace Fisharebest\Webtrees\Module; use Fisharebest\Webtrees\Auth; use Fisharebest\Webtrees\I18N; use Fisharebest\Webtrees\Site; use Fisharebest\Webtrees\Theme; use Fisharebest\Webtrees\View; /** * Class LoginBlockModule */ class LoginBlockModule extends AbstractModule implements ModuleBlockInterface { /** {@inheritdoc} */ public function getTitle() { return /* I18N: Name of a module */ I18N::translate('Sign in'); } /** {@inheritdoc} */ public function getDescription() { return /* I18N: Description of the “Sign in” module */ I18N::translate('An alternative way to sign in and sign out.'); } /** * Generate the HTML content of this block. * * @param int $block_id * @param bool $template * @param string[] $cfg * * @return string */ public function getBlock($block_id, $template = true, $cfg = []) { global $controller; $id = $this->getName() . $block_id; $class = $this->getName() . '_block'; $controller->addInlineJavascript(' $("#new_passwd").hide(); $("#passwd_click").click(function() { $("#new_passwd").slideToggle(200); $("#register-link").slideToggle(200); $("#new_passwd_username").focus(); return false; }); '); if (Auth::check()) { $title = I18N::translate('Sign out'); $content = '
'; $content .= '
' . I18N::translate('You are signed in as %s.', '' . Auth::user()->getRealNameHtml() . '') . '

'; $content .= ''; $content .= '

'; } else { $title = I18N::translate('Sign in'); $content = '
'; $content .= '
' . I18N::translate('Forgot password?') . '
'; if (Site::getPreference('USE_REGISTRATION_MODULE') === '1') { $content .= ''; } $content .= '
'; // close "login-form" // hidden New Password block $content .= '

' . I18N::translate('Request a new password') . '

'; //"new_passwd" $content .= '
'; //"login-box" } if ($template) { return View::make('blocks/template', [ 'block' => str_replace('_', '-', $this->getName()), 'id' => $block_id, 'config_url' => '', 'title' => $this->getTitle(), 'content' => $content, ]); } else { return $content; } } /** {@inheritdoc} */ public function loadAjax() { return false; } /** {@inheritdoc} */ public function isUserBlock() { return true; } /** {@inheritdoc} */ public function isGedcomBlock() { return true; } /** * An HTML form to edit block settings * * @param int $block_id */ public function configureBlock($block_id) { } }