PDA

View Full Version : Need help with horizontal login box


Usurper
07-25-2006, 08:43 PM
I'm working on editing the MI-Login Panel to make an unobtrusive horizontal login panel for my site. I'm most of the way done, with one exception. Before getting into that, here's how I've hacked things into their current shape:

This is using a test skin that I'm building from scratch based on my current Powder-based skin, only without a hojillion unnecessary nested tables. Yay me. If you are not logged in, you will see this:
[attachmentid=453]


If you choose to register, you're taken to the forum's registration page (been a while since I tested SD without a forum, so no clue what happens if you have no forum). If you click Log In, however, some javascript show/hide code replaces the first div with another, instantly displaying this:
[attachmentid=454]


After you log in, you get this. Naturally, avatars cannot be displayed in this mod. :)
[attachmentid=455]


The problem I have right now is the error system. If you enter a wrong username or password, you get something like this:
[attachmentid=456]

I don't want it growing an extra row. I figured that this would be easy to fix; just find the html for it and put it in a left-floating div or somesuch. Alas, there IS no html for it. Viewing the source shows that not only is it called from outside the file, it also uses FONT tags to format the text. The horror!

I'm not sure where to look for the $value of $loginerrors or whatever I should be looking for. I don't know if it's a global variable (well, I guess it is, but didn't see it in Spib's guide), or if they get the info out of the forum based on its login system, or where. I'd like to run a diff check on loginpanel.php so that I can share this if anyone wants it, but I'm also trying to avoid modifying a ton of files if possible (I already require a small bit of javascript in skin headers; I suppose I'll have to somehow have a noscript alternative).

Any specific help on the loginerrors thing would be appreciated, and any suggestions are welcome as well.

crashnet47
07-25-2006, 09:13 PM
This is interesting. I'm very anxious to know how you changed the plugin and eliminated the "plugin in a box" design SD uses for plugins. Please be sure to post a how to if you don't want to release your plugin.

abcohen
07-25-2006, 09:18 PM
in loginpanel.php**if(count($loginerrors))
******{
********foreach($loginerrors as $key => $value)
********{
**********echo $value . '<br />';
********}
******}

if you take off that
you should find that it moves things to the right with the errors... or change the echo to make it like an alert window or a floating div or something else.

Robert_J_Ellis
07-25-2006, 09:40 PM
Hmm, nice work you've done. A horixzontal login box is quite stylish :).

Usurper
07-25-2006, 09:53 PM
Thanks for the suggestions. As of now, I replaced "echo $value . '
';" with "echo 'Wrong Input - ';" and added a line before the check to echo the start of the div containing the welcome message (probably makes no sense to anyone reading this, but basically everything's on one line again).

[attachmentid=457]

It isn't very specific about which input is wrong, but it doesn't use font tags in an xhtml page anymore.

abcohen
07-25-2006, 10:00 PM
well if you take off the
and replace it with a '-' then it should echo out the error of the login (I'll have to hunt around a bit more for the error and font tags)

ok thats what I thought... the Font tags are added from the Languages panel from Subdreamer.

so the Languages font tags messes up the XHTML validation huh... note to self... :)

From globalfunctions.php line 288ish :)

// ############################### GET LANGUAGE ################################

function GetLanguage($pluginid)
{
**global $DB;

**$getlanguage = $DB->query("SELECT * FROM " . TABLE_PREFIX . "phrases WHERE pluginid = '$pluginid'");

**while($languagearray = $DB->fetch_array($getlanguage))
**{
****// start building the font tags
****$fontstart = '<font style="';
****$fontend** = '</font>';

****if($languagearray['font'])
******$fontstart .= 'font-family: ' . $languagearray['font']**. '; ';

****if($languagearray['size'])
******$fontstart .= 'font-size: '** . $languagearray['size']**. 'px; ';

****if($languagearray['color'])
******$fontstart .= 'color: '****** . $languagearray['color'] . '; ';

****if($languagearray['bold'])
******$fontstart .= 'font-weight: bold; ';

****if($languagearray['italic'])
******$fontstart .= 'font-style: italic; ';

****if($languagearray['underline'])
******$fontstart .= 'text-decoration: underline; ';

****// close the first font tag
****$fontstart .= '">';

****// don't add a style if there isn't any
****// this is to prevent conflict with existing css
****if($fontstart == '<font style="">')
****{
******$fontstart = '';
******$fontend** = '';
****}

****if($languagearray['customphrase'])
******$language[$languagearray['varname']] = $fontstart . $languagearray['customphrase']**. $fontend;
****else
******$language[$languagearray['varname']] = $fontstart . $languagearray['defaultphrase'] . $fontend;
**}

**return $language;
}



you'd have to edit this to get teh xhtml validation working.

Usurper
07-25-2006, 10:30 PM
Thanks much for the find! I'll be editing my globalfunctions.php shortly. :)

Here's a (horrible) little guide to putting this together. Everyone's skins and setups are going to be different, so I hope this is useful to some of you. In loginpanel.php:

Find:******echo '<table border="0" cellspacing="0" cellpadding="0">
************<tr>
**************<td>' . $language['welcome_back'] . ' ' . $userinfo['username'] . '</td>
************</tr>';

Replace with:******echo 'Logged in as <a title="My Control Panel" class="smallcaps" href="' . $forumpath . 'index.php?act=UserCP&CODE=00' . '">' . $userinfo['username'] . '</a> ';
******echo ' <small>(<a href="' . RewriteLink('index.php?categoryid=' . $categoryid . '&logout=1') . '">Log Out</a>) </small> ';

- - - - - - - - - -

Find:******if(isset($avatar))
******{
********echo '<tr>
****************<td><br />' . $avatar . '</td>
**************</tr>';
******}

******echo '<tr>
**************<td><br />'.iif(strlen($cppath) > 0, $myaccount, '').'</td>
************</tr>';

******if($settings['Display Admin Link'] && ($userinfo['adminaccess'] OR count($userinfo['pluginadminids']) > 0))
******{
**************echo '<tr>
**************<td><a href="' . RewriteLink('admin/index.php') . '">' . $language['admin_panel'] . '</a></td>
************</tr>';
******}

******echo '<tr>
**************<td><a href="' . RewriteLink('index.php?categoryid=' . $categoryid . '&logout=1') . '">' . $language['logout'] . '</a></td>
************</tr>';

******if($settings['Show PMs'] == 1)
******{
********echo '<tr>
****************<td><br/>';

********require('./plugins/p10_mi_loginpanel/pminfo.php');

********echo '****</td>
************</tr>';
******}

******echo '</table>';

Replace with:******if($settings['Show PMs'] == 1)
******{
********require('./plugins/p10_mi_loginpanel/pminfo.php');
******}

- - - - - - - - - -

Find:******if(count($loginerrors))
******{
********foreach($loginerrors as $key => $value)
********{
**********echo $value . '<br />';

********}
******}

******echo '<form action="' . RewriteLink('index.php?categoryid=' . $categoryid) . '" method="post">
************<input type="hidden" name="login" value="login" />
************<table border="0" cellspacing="0" cellpadding="0">
************<tr><td style="padding-bottom: 4px;">' . $language['username'] . '</td></tr>
************<tr><td style="padding-bottom: 4px;"><input name="loginusername" type="text" size="'.$inputsize.'" /></td></tr>
************<tr><td style="padding-bottom: 4px;">' . $language['password'] . '</td></tr>
************<tr><td style="padding-bottom: 4px;"><input name="loginpassword" type="password" size="'.$inputsize.'" /></td></tr>
************<tr><td style="padding-bottom: 4px;"><input class="checkbox" type="checkbox" name="rememberme" checked="checked" /> ' . $language['remember_me'] . '</td></tr>
************<tr><td><input type="submit" name="Submit now" value="' . strip_tags($language['login']) . '" /></td></tr>';



Replace with:******echo '<div id="loginload" style="display:block">';
******if(count($loginerrors))
******{
********foreach($loginerrors as $key => $value)
********{
****// change globalfunctions.php to rid thyself of font tags on the following value
**********echo $value . ' - ';
********}
******}
******echo 'Welcome, Guest. Please <a href="java script:show(\'loginpop\');hide(\'loginload\')">log in</a> or';


- - - - - - - - - -

Find:********echo '<tr>
****************<td><br />' . $language['not_registered'] . '<br /><a href="' . $regpath . '">' . $language['register_now'] . '</a></td>
**************</tr>';
******}


******// $pwdpath has already gone through rewritelink (or $sdurl added) in the integration files
******if(isset($pwdpath))
******{
********echo '<tr>
****************<td><br /><a href="' . $pwdpath . '">' . $language['forgot_password'] . '</a></td>
**************</tr>';
******}

******echo '</table>
************</form>';

Replace with:********echo ' <a href="' . $regpath . '">register</a>.';
******}****
******echo ' - Forgot Password</div><div id="loginpop" style="display:none"><form action="' . RewriteLink('index.php?categoryid=' . $categoryid) . '" method="post">
************<input type="hidden" name="login" value="login" />' . $language['username'] . '<input name="loginusername" class="upass" type="text" size="'.$inputsize.'" /> ' . $language['password'] . '<input name="loginpassword" class="upass" type="password" size="'.$inputsize.'" />
************<input class="checkbox" type="checkbox" name="rememberme" style="height:10px; width:10px; background:#c0c0c0" checked="checked" />Save <input class="upass2" type="submit" name="Submit now" value="' . strip_tags($language['login']) . '" /> Forget Password?</div>';

******// $pwdpath has already gone through rewritelink (or $sdurl added) in the integration files
******echo '</form>';

- - - - - - - - - -

Hopefully I haven't violated any rules in reproducing such large chunks of the plugin. Anyway, there are obviously some CSS classes and IDs to be added. I THINK these are all of the relevant ones:

.login
{
****background:#800;
****color:#fff;
****font:10px/14px verdana, sans-serif;
****padding:0 10px;
}

#loginload
{
****display: block; height:20px;
****font:10px/20px verdana, sans-serif;
}

form { margin:0; padding:0 }

#loginpop
{
****display: none;
}

.login a:link, .login a:visited
{
****color:#fff;
****font-weight:bold;
****text-decoration:none;
}

.login a:hover, .login a:active
{
****color:#eee;
****font-weight:bold;
****text-decoration:underline;
}

.login td
{
****vertical-align:middle;
}

.upass, .upass2
{
****font:10px/12px arial, sans-serif;
****background:#c0c0c0;
****margin:0;
****padding:2px;
****border:1px solid #000;
}

.upass2
{
****padding:0;
****border:1px outset #c0c0c0;
}
****
.smallcaps
{
****font-variant:small-caps;
****font:12px/14px verdana, sans-serif;
}

- - - - - - - - - -

Finally, this code has to go in the head tag of each skin. If anyone knows a way to do the javascript trick without skin edits, I'm all ears.

<!--show/hide login panel-->
<script type="text/javascript">
<!--
function show(Menu)
{
****document.getElementById(Menu).style.display = 'block';
}

function hide(Menu)
{
****document.getElementById(Menu).style.display = 'none';
}
// -->
</script>

I hope nothing got chopped off or omitted.

Usurper
07-25-2006, 10:41 PM
Methinks the font tag fixing is as easy as this:

in globalfunctions.php

find:****// start building the font tags
****$fontstart = '<font style="';
****$fontend** = '</font>';

replace with:****// start building the font tags
**** $fontstart = '<span style="';
**** $fontend** = '</span>';


THEN

find:****if($fontstart == '<font style="">')

replace with:****if($fontstart == '<span style="">')

Thanks again.

critical
11-09-2006, 07:43 AM
hi Thanks for the hack but I couldnt make it i am getting this

Parse error: syntax error, unexpected '*' in /home/uozturk/public_html/plugins/p10_mi_loginpanel/loginpanel.php on line 40

robert_p_skold
11-09-2006, 08:52 AM
Theres no reason for the*'s in there. Remove them all and try again.

critical
11-09-2006, 11:15 AM
Theres no reason for the*'s in there. Remove them all and try again.

I did 3 times :mad:

anybody has that oginpanel.php file i can download? thanks

CJG
11-11-2006, 10:37 PM
Hey,
I was hoping there was someone out there with a little bit of spare time on their hands that could mod the code for me as Im a complete noob but I would love to have a horizontal Log In Box. Im using the Colours Skin. I would be very greatful if some one could mod it and email it to me?
I know it's asking alot but I'm not confident enough to go in and mess about with the code in the .php files.

Email : CJG@clublandedinburgh.com

Thanks Folks!

Usurper
11-13-2006, 05:27 AM
The conversion to VBulletin really borked those original posts.

I can't promise anything, but if I get the mod cleaned up and operating as a separate plugin instead of a mod, I'll try submitting it. I wouldn't expect it anytime soon, though, as I've got a lot of other non-SD projects going on.

My own site still has a bug with the "forgot password" function that I haven't been buggered to fix all this time.

CJG
11-19-2006, 03:39 PM
Any news on this coming out as a plugin instead of a mod ? That would be Great!


CJ