Ver Fonte

! Make the top 'login or register' login button be a nice overlay for the login.

Signed-off-by: Peter Spicer <[email protected]>
Peter Spicer há 10 anos atrás
pai
commit
76923ffffb

+ 0 - 3
Sources/Load.php

@@ -1685,9 +1685,6 @@ function loadTheme($id_theme = 0, $initialize = true)
 	if (isset($modSettings['load_average']))
 		$context['load_average'] = $modSettings['load_average'];
 
-	// Set some permission related settings.
-	$context['show_login_bar'] = !empty($user_info['is_guest']) && !empty($modSettings['enableVBStyleLogin']);
-
 	// Detect the browser. This is separated out because it's also used in attachment downloads
 	detectBrowser();
 

+ 6 - 0
Sources/LogInOut.php

@@ -43,6 +43,12 @@ function Login()
 		loadLanguage('Login');
 		loadTemplate('Login');
 		$context['sub_template'] = 'login';
+
+		if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest')
+		{
+			$context['from_ajax'] = true;
+			$context['template_layers'] = array();
+		}
 	}
 
 	// Get the template ready.... not really much else to do.

+ 0 - 1
Sources/ManageSettings.php

@@ -238,7 +238,6 @@ function ModifyLayoutSettings($return_config = false)
 			// Stuff that just is everywhere - today, search, online, etc.
 			array('select', 'todayMod', array($txt['today_disabled'], $txt['today_only'], $txt['yesterday_today'])),
 			array('check', 'onlineEnable'),
-			array('check', 'enableVBStyleLogin'),
 		'',
 			// This is like debugging sorta.
 			array('check', 'timeLoadPageEnable'),

+ 1 - 4
Sources/Subs.php

@@ -2841,7 +2841,7 @@ function setupThemeContext($forceload = false)
 	$context['in_maintenance'] = !empty($maintenance);
 	$context['current_time'] = timeformat(time(), false);
 	$context['current_action'] = isset($_GET['action']) ? $smcFunc['htmlspecialchars']($_GET['action']) : '';
-	$context['show_quick_login'] = !empty($modSettings['enableVBStyleLogin']) && $user_info['is_guest'];
+	$context['show_quick_login'] = false;
 
 	// Get some news...
 	$context['news_lines'] = array_filter(explode("\n", str_replace("\r", '', trim(addslashes($modSettings['news'])))));
@@ -2913,9 +2913,6 @@ function setupThemeContext($forceload = false)
 	// Setup the main menu items.
 	setupMenuContext();
 
-	if (empty($settings['theme_version']))
-		$context['show_vBlogin'] = $context['show_quick_login'];
-
 	// This is here because old index templates might still use it.
 	$context['show_news'] = !empty($settings['enable_news']);
 

+ 44 - 37
Themes/default/Login.template.php

@@ -18,69 +18,76 @@ function template_login()
 	echo '
 		<script src="', $settings['default_theme_url'], '/scripts/sha1.js"></script>
 
-		<form action="', $scripturl, '?action=login2" name="frmLogin" id="frmLogin" method="post" accept-charset="', $context['character_set'], '" ', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' . $context['session_id'] . '\', \'' . (!empty($context['login_token']) ? $context['login_token'] : '') . '\');"' : '', '>
 		<div class="tborder login">
 			<div class="cat_bar">
 				<h3 class="catbg">
 					<img src="', $settings['images_url'], '/icons/login_hd.png" alt="" class="icon"> ', $txt['login'], '
 				</h3>
 			</div>
-			<div class="roundframe">';
+			<div class="roundframe">
+				<form class="login" action="', $scripturl, '?action=login2" name="frmLogin" id="frmLogin" method="post" accept-charset="', $context['character_set'], '" ', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' . $context['session_id'] . '\', \'' . (!empty($context['login_token']) ? $context['login_token'] : '') . '\');"' : '', '>';
 
 	// Did they make a mistake last time?
 	if (!empty($context['login_errors']))
 		echo '
-			<p class="errorbox">', implode('<br>', $context['login_errors']), '</p><br>';
+					<p class="errorbox">', implode('<br>', $context['login_errors']), '</p><br>';
 
 	// Or perhaps there's some special description for this time?
 	if (isset($context['description']))
 		echo '
-				<p class="description">', $context['description'], '</p>';
+					<p class="description">', $context['description'], '</p>';
 
 	// Now just get the basic information - username, password, etc.
 	echo '
-				<dl>
-					<dt>', $txt['username'], ':</dt>
-					<dd><input type="text" name="user" size="20" value="', $context['default_username'], '" class="input_text"></dd>
-					<dt>', $txt['password'], ':</dt>
-					<dd><input type="password" name="passwrd" value="', $context['default_password'], '" size="20" class="input_password"></dd>
-				</dl>';
+					<dl>
+						<dt>', $txt['username'], ':</dt>
+						<dd><input type="text" id="', !empty($context['from_ajax']) ? 'ajax_' : '', 'loginuser" name="user" size="20" value="', $context['default_username'], '" class="input_text"></dd>
+						<dt>', $txt['password'], ':</dt>
+						<dd><input type="password" id="', !empty($context['from_ajax']) ? 'ajax_' : '', 'loginpass" name="passwrd" value="', $context['default_password'], '" size="20" class="input_password"></dd>
+					</dl>';
 
 	if (!empty($modSettings['enableOpenID']))
-		echo '<p><strong>&mdash;', $txt['or'], '&mdash;</strong></p>
-				<dl>
-					<dt>', $txt['openid'], ':</dt>
-					<dd><input type="text" name="openid_identifier" class="input_text openid_login" size="17">&nbsp;<a href="', $scripturl, '?action=helpadmin;help=register_openid" onclick="return reqOverlayDiv(this.href);" class="help"><img src="', $settings['images_url'], '/helptopics.png" alt="', $txt['help'], '" class="centericon"></a></dd>
-				</dl>
-				<hr>';
+		echo '
+					<p><strong>&mdash;', $txt['or'], '&mdash;</strong></p>
+					<dl>
+						<dt>', $txt['openid'], ':</dt>
+						<dd><input type="text" name="openid_identifier" class="input_text openid_login" size="17">&nbsp;<a href="', $scripturl, '?action=helpadmin;help=register_openid" onclick="return reqOverlayDiv(this.href);" class="help"><img src="', $settings['images_url'], '/helptopics.png" alt="', $txt['help'], '" class="centericon"></a></dd>
+					</dl>
+					<hr>';
 
 	echo '
-				<dl>
-					<dt>', $txt['mins_logged_in'], ':</dt>
-					<dd><input type="number" name="cookielength" size="4" maxlength="4" value="', $modSettings['cookieTime'], '"', $context['never_expire'] ? ' disabled' : '', ' class="input_text"></dd>
-					<dt>', $txt['always_logged_in'], ':</dt>
-					<dd><input type="checkbox" name="cookieneverexp"', $context['never_expire'] ? ' checked' : '', ' class="input_check" onclick="this.form.cookielength.disabled = this.checked;"></dd>';
+					<dl>
+						<dt>', $txt['mins_logged_in'], ':</dt>
+						<dd><input type="number" name="cookielength" size="4" maxlength="4" value="', $modSettings['cookieTime'], '"', $context['never_expire'] ? ' disabled' : '', ' class="input_text"></dd>
+						<dt>', $txt['always_logged_in'], ':</dt>
+						<dd><input type="checkbox" name="cookieneverexp"', $context['never_expire'] ? ' checked' : '', ' class="input_check" onclick="this.form.cookielength.disabled = this.checked;"></dd>';
 	// If they have deleted their account, give them a chance to change their mind.
 	if (isset($context['login_show_undelete']))
 		echo '
-					<dt class="alert">', $txt['undelete_account'], ':</dt>
-					<dd><input type="checkbox" name="undelete" class="input_check"></dd>';
+						<dt class="alert">', $txt['undelete_account'], ':</dt>
+						<dd><input type="checkbox" name="undelete" class="input_check"></dd>';
 	echo '
-				</dl>
-				<p><input type="submit" value="', $txt['login'], '" class="button_submit"></p>
-				<p class="smalltext"><a href="', $scripturl, '?action=reminder">', $txt['forgot_your_password'], '</a></p>
-				<input type="hidden" name="hash_passwrd" value="">
-				<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
-				<input type="hidden" name="', $context['login_token_var'], '" value="', $context['login_token'], '">
-			</div>
-		</div>
-		</form>';
-
-	// Focus on the correct input - username or password.
+					</dl>
+					<p><input type="submit" value="', $txt['login'], '" class="button_submit"></p>
+					<p class="smalltext"><a href="', $scripturl, '?action=reminder">', $txt['forgot_your_password'], '</a></p>
+					<input type="hidden" name="hash_passwrd" value="">
+					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
+					<input type="hidden" name="', $context['login_token_var'], '" value="', $context['login_token'], '">
+					<script>
+						setTimeout(function() {
+							document.getElementById("', !empty($context['from_ajax']) ? 'ajax_' : '', isset($context['default_username']) && $context['default_username'] != '' ? 'loginpass' : 'loginuser', '").focus();
+						}, 150);
+					</script>
+				</form>';
+
+	// It is a long story as to why we have this when we're clearly not going to use it.
+	if (!empty($context['from_ajax']))
+		echo '
+					<br>
+					<a href="javascript:self.close();"></a>';
 	echo '
-		<script><!-- // --><![CDATA[
-			document.forms.frmLogin.', isset($context['default_username']) && $context['default_username'] != '' ? 'passwrd' : 'user', '.focus();
-		// ]]></script>';
+			</div>
+		</div>';
 }
 
 // Tell a guest to get lost or login!

+ 3 - 0
Themes/default/css/index.css

@@ -2851,6 +2851,9 @@ fieldset.merge_options {
 	width: 540px;
 	margin: 0 auto;
 }
+.popup_content .login {
+	width: 100%;
+}
 .login dl {
 	overflow: auto;
 	clear: right;

+ 3 - 38
Themes/default/index.template.php

@@ -195,7 +195,7 @@ function template_body_above()
 	else
 		echo '
 			<ul class="floatleft welcome">
-				<li>', sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $scripturl . '?action=login'), '</li>
+				<li>', sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $context['forum_name'], $scripturl . '?action=login', 'return reqOverlayDiv(this.href, ' . JavaScriptEscape($txt['login']) . ');', $scripturl . '?action=register'), '</li>
 			</ul>';
 
 	if ($context['allow_search'])
@@ -263,43 +263,8 @@ function template_body_above()
 		<div id="upper_section">
 			<div id="inner_section">
 				<div id="inner_wrap">
-					<div class="user">';
-
-	// Otherwise they're a guest - this time ask them to either register or login - lazy bums...
-	if (!empty($context['show_login_bar']))
-	{
-		echo '
-						<script src="', $settings['default_theme_url'], '/scripts/sha1.js"></script>
-						<form id="guest_form" action="', $scripturl, '?action=login2;quicklogin" method="post" accept-charset="', $context['character_set'], '" ', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' . $context['session_id'] . '\', \'' . (!empty($context['login_token']) ? $context['login_token'] : '') . '\');"' : '', '>
-							<input type="text" name="user" size="10" class="input_text">
-							<input type="password" name="passwrd" size="10" class="input_password">
-							<select name="cookielength">
-								<option value="60">', $txt['one_hour'], '</option>
-								<option value="1440">', $txt['one_day'], '</option>
-								<option value="10080">', $txt['one_week'], '</option>
-								<option value="43200">', $txt['one_month'], '</option>
-								<option value="-1" selected>', $txt['forever'], '</option>
-							</select>
-							<input type="submit" value="', $txt['login'], '" class="button_submit">
-							<div>', $txt['quick_login_dec'], '</div>';
-
-		if (!empty($modSettings['enableOpenID']))
-			echo '
-							<br><input type="text" name="openid_identifier" size="25" class="input_text openid_login">';
-
-		echo '
-							<input type="hidden" name="hash_passwrd" value="">
-							<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
-							<input type="hidden" name="', $context['login_token_var'], '" value="', $context['login_token'], '">
-						</form>';
-	}
-	else
-	{
-		echo '
-						', $context['current_time'];
-	}
-
-	echo'
+					<div class="user">
+						', $context['current_time'], '
 					</div>';
 	// Show a random news item? (or you could pick one from news_lines...)
 	if (!empty($settings['enable_news']) && !empty($context['random_news_line']))

+ 0 - 1
Themes/default/languages/Help.english.php

@@ -256,7 +256,6 @@ $helptxt['pollMode'] = 'This selects whether polls are enabled or not. If polls
 		from the topic listing. You can choose to continue to show the regular topic without their polls by selecting
 		&quot;Show Existing Polls as Topics&quot;.<br><br>To choose who can post polls, view polls, and similar, you
 		can allow and disallow those permissions. Remember this if polls are not working.';
-$helptxt['enableVBStyleLogin'] = 'This will show a more compact login on every page of the forum for guests.';
 $helptxt['enableCompressedOutput'] = 'This option will compress output to lower bandwidth consumption, but it requires
 		zlib to be installed.';
 $helptxt['disableTemplateEval'] = 'By default, templates are evaluated instead of just included. This helps with showing more useful debug information in case a template contains an error.<br><br>

+ 0 - 1
Themes/default/languages/ManageSettings.english.php

@@ -82,7 +82,6 @@ $txt['today_disabled'] = 'Disabled';
 $txt['today_only'] = 'Only Today';
 $txt['yesterday_today'] = 'Today &amp; Yesterday';
 $txt['onlineEnable'] = 'Show online/offline in posts and PMs';
-$txt['enableVBStyleLogin'] = 'Show a quick login on every page';
 $txt['defaultMaxMembers'] = 'Members per page in member list';
 $txt['timeLoadPageEnable'] = 'Display time taken to create every page';
 $txt['disableHostnameLookup'] = 'Disable hostname lookups';

+ 2 - 2
Themes/default/languages/index.english.php

@@ -209,10 +209,10 @@ $txt['female'] = 'Female';
 
 $txt['error_invalid_characters_username'] = 'Invalid character used in Username.';
 
-$txt['welcome_guest'] = 'Welcome, <strong>%1$s</strong>. Please <a href="%2$s">login</a>.';
+$txt['welcome_guest'] = 'Welcome, <strong>%1$s</strong>. Please <a href="%3$s">login</a>.';
 
 //$txt['welcome_guest_register'] = 'Welcome, <strong>%1$s</strong>. Please <a href="' . $scripturl . '?action=login">login</a> or <a href="' . $scripturl . '?action=register">register</a>.';
-$txt['welcome_guest_register'] = 'Welcome to <strong>' . $context['forum_name'] . '</strong>. Please <a href="' . $scripturl . '?action=login">login</a> or <a href="' . $scripturl . '?action=register">register</a>.';
+$txt['welcome_guest_register'] = 'Welcome to <strong>%2$s</strong>. Please <a href="%3$s" onclick="%4$s">login</a> or <a href="%5$s">register</a>.';
 
 $txt['please_login'] = 'Please <a href="' . $scripturl . '?action=login">login</a>.';
 $txt['login_or_register'] = 'Please <a href="' . $scripturl . '?action=login">login</a> or <a href="' . $scripturl . '?action=register">register</a>.';

+ 0 - 1
other/install_2-1_mysql.sql

@@ -1706,7 +1706,6 @@ VALUES ('smfVersion', '{$smf_version}'),
 	('karmaTimeRestrictAdmins', '1'),
 	('enablePreviousNext', '1'),
 	('pollMode', '1'),
-	('enableVBStyleLogin', '1'),
 	('enableCompressedOutput', '{$enableCompressedOutput}'),
 	('karmaWaitTime', '1'),
 	('karmaMinPosts', '0'),

+ 0 - 1
other/install_2-1_postgresql.sql

@@ -2217,7 +2217,6 @@ INSERT INTO {$db_prefix}settings (variable, value) VALUES ('karmaMode', '0');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('karmaTimeRestrictAdmins', '1');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('enablePreviousNext', '1');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('pollMode', '1');
-INSERT INTO {$db_prefix}settings (variable, value) VALUES ('enableVBStyleLogin', '1');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('enableCompressedOutput', '{$enableCompressedOutput}');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('karmaWaitTime', '1');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('karmaMinPosts', '0');

+ 0 - 1
other/install_2-1_sqlite.sql

@@ -1849,7 +1849,6 @@ INSERT INTO {$db_prefix}settings (variable, value) VALUES ('karmaMode', '0');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('karmaTimeRestrictAdmins', '1');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('enablePreviousNext', '1');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('pollMode', '1');
-INSERT INTO {$db_prefix}settings (variable, value) VALUES ('enableVBStyleLogin', '1');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('enableCompressedOutput', '{$enableCompressedOutput}');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('karmaWaitTime', '1');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('karmaMinPosts', '0');

+ 0 - 1
other/install_2-1_sqlite3.sql

@@ -1849,7 +1849,6 @@ INSERT INTO {$db_prefix}settings (variable, value) VALUES ('karmaMode', '0');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('karmaTimeRestrictAdmins', '1');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('enablePreviousNext', '1');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('pollMode', '1');
-INSERT INTO {$db_prefix}settings (variable, value) VALUES ('enableVBStyleLogin', '1');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('enableCompressedOutput', '{$enableCompressedOutput}');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('karmaWaitTime', '1');
 INSERT INTO {$db_prefix}settings (variable, value) VALUES ('karmaMinPosts', '0');

+ 1 - 1
other/upgrade_2-1_mysql.sql

@@ -777,7 +777,7 @@ WHERE variable = 'avatar_action_too_large'
 
 ---# Cleaning up old settings.
 DELETE FROM {$db_prefix}settings
-WHERE variable IN ('enableStickyTopics', 'guest_hideContacts', 'notify_new_registration', 'attachmentEncryptFilenames', 'hotTopicPosts', 'hotTopicVeryPosts', 'fixLongWords', 'admin_features', 'topbottomEnable', 'simpleSearch');
+WHERE variable IN ('enableStickyTopics', 'guest_hideContacts', 'notify_new_registration', 'attachmentEncryptFilenames', 'hotTopicPosts', 'hotTopicVeryPosts', 'fixLongWords', 'admin_features', 'topbottomEnable', 'simpleSearch', 'enableVBStyleLogin');
 ---#
 
 ---# Cleaning up old theme settings.

+ 1 - 1
other/upgrade_2-1_postgresql.sql

@@ -856,7 +856,7 @@ WHERE variable = 'avatar_action_too_large'
 
 ---# Cleaning up old settings.
 DELETE FROM {$db_prefix}settings
-WHERE variable IN ('enableStickyTopics', 'guest_hideContacts', 'notify_new_registration', 'attachmentEncryptFilenames', 'hotTopicPosts', 'hotTopicVeryPosts', 'fixLongWords', 'admin_features', 'topbottomEnable', 'simpleSearch');
+WHERE variable IN ('enableStickyTopics', 'guest_hideContacts', 'notify_new_registration', 'attachmentEncryptFilenames', 'hotTopicPosts', 'hotTopicVeryPosts', 'fixLongWords', 'admin_features', 'topbottomEnable', 'simpleSearch', 'enableVBStyleLogin');
 ---#
 
 ---# Cleaning up old theme settings.

+ 1 - 1
other/upgrade_2-1_sqlite.sql

@@ -847,7 +847,7 @@ WHERE variable = 'avatar_action_too_large'
 
 ---# Cleaning up old settings.
 DELETE FROM {$db_prefix}settings
-WHERE variable IN ('enableStickyTopics', 'guest_hideContacts', 'notify_new_registration', 'attachmentEncryptFilenames', 'hotTopicPosts', 'hotTopicVeryPosts', 'fixLongWords', 'admin_features', 'topbottomEnable', 'simpleSearch');
+WHERE variable IN ('enableStickyTopics', 'guest_hideContacts', 'notify_new_registration', 'attachmentEncryptFilenames', 'hotTopicPosts', 'hotTopicVeryPosts', 'fixLongWords', 'admin_features', 'topbottomEnable', 'simpleSearch', 'enableVBStyleLogin');
 ---#
 
 ---# Cleaning up old theme settings.