News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Admin Dropdown

Started by Matthew K., January 03, 2010, 10:40:03 AM

Previous topic - Next topic

Matthew K.

It's value is 2, which is crosshair

Arantor

// A bug in some versions of IIS under CGI (older ones) makes cookie setting not work with Location: headers.
$context['server']['needs_login_fix'] = $context['server']['is_cgi'] && $context['server']['is_iis'];

// Detect the browser. This is separated out because it's also used in attachment downloads
detectBrowser();

global $txt;
$cursortext = array(0 => 'auto', 1 => $txt['cursor_default'], 2 => $txt['cursor_crosshair'], 3 => $txt['cursor_hand'], 4 => $txt['cursor_pointer'], 5 => $txt['cursor_move'], 6 => $txt['cursor_text'], 7 => $txt['cursor_wait']);
$ident = !empty($modSettings['forum_cursor']) ? (int) $modSettings['forum_cursor'] : 0;
if (empty($cursortext[$ident]))
$ident = 0;

$context['html_headers'] .= '<style type="text/css">
body
{
cursor: ' . $cursortext[$ident] . ') . ';
}
</style>';

Matthew K.

Could you explain what the part you added does, so I can understand it?

Thanks,
Labradoodle-360

Arantor

   global $txt;
-> ensures things are in scope

   $cursortext = array(0 => 'auto', 1 => $txt['cursor_default'], 2 => $txt['cursor_crosshair'], 3 => $txt['cursor_hand'], 4 => $txt['cursor_pointer'], 5 => $txt['cursor_move'], 6 => $txt['cursor_text'], 7 => $txt['cursor_wait']);
-> puts all the strings - including auto into the array

   $ident = !empty($modSettings['forum_cursor']) ? (int) $modSettings['forum_cursor'] : 0;
-> checks if modSettings['forum_cursor'] exists. If not, use 0 (which is auto), if it does, force it to be a number (since it won't be otherwise, which will cause the lookup to $cursortext to fail since that relies on numbered keys.

   if (empty($cursortext[$ident]))
      $ident = 0;
-> if there isn't an entry in $cursortext that matches, revert it to 0, i.e. auto

   $context['html_headers'] .= '<style type="text/css">
   body
   {
      cursor: ' . $cursortext[$ident] . ') . ';
   }
   </style>';
-> should be fairly obvious.

Matthew K.

Your code generates an error from
Code (This line) Select
      cursor: ' . $cursortext[$ident] . ') . ';

Error: unexpected T_CONSTANT_ENCAPSED_STRING, expecting T_STRING
I tried escaping [$ident] .') to no avail.

Arantor

// A bug in some versions of IIS under CGI (older ones) makes cookie setting not work with Location: headers.
$context['server']['needs_login_fix'] = $context['server']['is_cgi'] && $context['server']['is_iis'];

// Detect the browser. This is separated out because it's also used in attachment downloads
detectBrowser();

global $txt;
$cursortext = array(0 => 'auto', 1 => $txt['cursor_default'], 2 => $txt['cursor_crosshair'], 3 => $txt['cursor_hand'], 4 => $txt['cursor_pointer'], 5 => $txt['cursor_move'], 6 => $txt['cursor_text'], 7 => $txt['cursor_wait']);
$ident = !empty($modSettings['forum_cursor']) ? (int) $modSettings['forum_cursor'] : 0;
if (empty($cursortext[$ident]))
$ident = 0;

$context['html_headers'] .= '<style type="text/css">
body
{
cursor: ' . $cursortext[$ident] . ';
}
</style>';


That's what I get for trying to clean up.

Matthew K.

Cursor stays default, after changing the admin input.

The page source shows:<style type="text/css">
   body
   {
      cursor: auto;
   }
   </style>

Matthew K.

Would it be smarter just to put the text directly in load for the $cursortext? That does work.

Arantor

I don't get why it does though.

It's on the fence though; strictly all language strings should be $txt strings because they're translatable that way however these aren't exactly just language strings...

Hmmm, not sure what our view as a team on this is; I'm personally inclined to allow it though.

Matthew K.

Yep, definitely. I understand that.

But I've already put a lot more time into just this section than really it's worth.
I could see if it was a fairly easy fix, but I've spent a long time on it, and you've also spent a while on it.

I'll submit it using plain text rather than strings and if the SMF Customization Team wants to correct me, I'll let them show me how and I'll gladly change it.

Arantor

Well, since I'm probably going to be the one who reviews it...

Matthew K.

haha true.

Should the code be left as:

   global $txt;
   $cursortext = array(0 => 'auto', 1 => 'default', 2 => 'crosshair', 3 => 'hand', 4 => 'pointer;cursor;hand', 5 => 'move', 6 => 'text', 7 => 'wait');
   $ident = !empty($modSettings['forum_cursor']) ? (int) $modSettings['forum_cursor'] : 0;
   if (empty($cursortext[$ident]))
      $ident = 0;

   $context['html_headers'] .= '<style type="text/css">
   body
   {
      cursor: ' . $cursortext[$ident] . ';
   }
   </style>';


Or should things be removed? (Obviously global $txt; correct?)

Anything else?

Advertisement: