Welcome, Guest. Please login or register.
December 14, 2018, 08:55:35 pm

ballp.it is the community forum for The F Plus.

You're only seeing part of the forum conversation. To see more, register for an account. This will give you read-only access to nearly all the forums.

Topic: [REQUEST] Fix this stupid PHP.  (Read 3796 times)

Lemon

  • (I have no sex virus)
  • Administrator
  • Miss Priss, I'd like to piss on your coat.
  • 3,229
  • 375
[REQUEST] Fix this stupid PHP.
« on: July 06, 2015, 10:24:09 am »
Hi! I am not good at PHP.

So, when you're looking at the thread view of ballp.it (like this page), the HTML rendered, in order, for the Subject/Started By cell is...

  • a useless div
  • a useless span
  • a link to the actual thread
  • a link to the new posts in that thread (if there are any)
  • Thread creator
  • Thread pagination

So, in HTML terms, what I get is...
Code: (HTML) [Select]
<td class="subject windowbg2">
<div>
<span id="msg_50194"><a href="http://ballp.it/index.php?topic=1703.0">First times watching classic movies</a></span>
<a href="http://ballp.it/index.php?topic=1703.msg50303#new" class="jump-to-new subject-level" id="newicon50194">
<svg viewBox="0 0 32 32"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#PostNewOnes"></use></svg>
</a>
<p>Started by <a href="http://ballp.it/index.php?action=profile;u=19" title="View the profile of jack chick">jack chick</a>
<small id="pages50194"> <a class="navPages" href="http://ballp.it/index.php?topic=1703.0">1</a> <a class="navPages" href="http://ballp.it/index.php?topic=1703.15">2</a>  </small>
</p>
</div>
</td>

While this isn't the worst thing in the world, it really isn't the best. Most  importantly, I really want that "jump to new" link to come first, so I can float it appropriately. Perfect world, the markup looks like this...
Code: (HTML) [Select]
<td class="subject-and-creator">
<div class="title">
<a href="http://ballp.it/index.php?topic=1703.msg50303#new" class="jump-to-new subject-level" id="newicon50194">
<svg viewBox="0 0 32 32"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#PostNewOnes"></use></svg>
</a>
<a class="thread-title" href="http://ballp.it/index.php?topic=1703.0">First times watching classic movies</a>
</div>
<div class="creator-and-pagination">
<span class="creator">
Started by <a href="http://ballp.it/index.php?action=profile;u=19" title="View the profile of jack chick">jack chick</a>
</span>
<span class="pagination">
<a class="navPages" href="http://ballp.it/index.php?topic=1703.0">1</a> <a class="navPages" href="http://ballp.it/index.php?topic=1703.15">2</a> 
</span>
</div>
</td>

With a lot of these ballpit changes, these changes are pretty easy. However, in this particular case, the code is a fucking mess...
Code: (PHP) [Select]
<td class="subject ', $alternate_class, '">
<div ', (!empty($topic['quick_mod']['modify']) ? 'id="topic_' . $topic['first_post']['id'] . '" onmouseout="mouse_on_div = 0;" onmouseover="mouse_on_div = 1;" ondblclick="modify_topic(\'' . $topic['id'] . '\', \'' . $topic['first_post']['id'] . '\');"' : ''), '>
', $topic['is_sticky'] ? '<strong>' : '', '<span id="msg_' . $topic['first_post']['id'] . '">', $topic['first_post']['link'], (!$context['can_approve_posts'] && !$topic['approved'] ? '&nbsp;<em>(' . $txt['awaiting_approval'] . ')</em>' : ''), '</span>', $topic['is_sticky'] ? '</strong>' : '';

// Is this topic new? (assuming they are logged in!)
if ($topic['new'] && $context['user']['is_logged'])
echo '
<a href="', $topic['new_href'], '" class="jump-to-new subject-level" id="newicon' . $topic['first_post']['id'] . '">
                                     <svg viewBox="0 0 32 32" ><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#PostNewOnes"></use></svg>
                                   </a>';
echo '
<p>', $txt['started_by'], ' ', $topic['first_post']['member']['link'], '
<small id="pages' . $topic['first_post']['id'] . '">', $topic['pages'], '</small>
</p>
</div>
</td>

If somebody has the chops and wants to simplify that crap, I'd appreciate it. If you're interested, I have all of this up in a GitHub repo, the file in question here is Themes/Giggle/MessageIndex.template.php

Otherwise, no big deal, but I'll probably never address that float issue.

Lemon

  • (I have no sex virus)
  • Administrator
  • Miss Priss, I'd like to piss on your coat.
  • 3,229
  • 375
[REQUEST] Fix this stupid PHP.
« Reply #1 on: December 02, 2015, 12:30:34 pm »
Just turned this into a GitHub issue.

duz

  • Paid
  • 367
  • 14
[REQUEST] Fix this stupid PHP.
« Reply #2 on: June 02, 2016, 11:18:03 pm »
What messy code. So basically this?

Code: (PHP) [Select]
echo "<td class='subject {$alternate_class}'>
    <div class='title' ", (!empty($topic["quick_mod"]["modify"])
        ? "id='topic_" . $topic["first_post"]["id"] . "' onmouseout='mouse_on_div = 0;' onmouseover='mouse_on_div = 1;' ondblclick='modify_topic(\"" . $topic["id"] . "\", \"" . $topic["first_post"]["id"] . "\");'"
        : ""),
    ">";

// Is this topic new? (assuming they are logged in!)
if ($topic["new"] && $context["user"]["is_logged"]) {
    echo "
        <a href='{$topic["new_href"]}' class='jump-to-new subject-level' id='newicon{$topic["first_post"]["id"]}'>
            <svg viewBox='0 0 32 32' ><use xmlns:xlink='http://www.w3.org/1999/xlink' xlink:href='#PostNewOnes'></use></svg>
        </a>";
}

echo ($topic["is_sticky"]
    ? "<strong>"
        : ""),
    "{$topic["first_post"]["link"]}",
    (!$context["can_approve_posts"]
        && !$topic["approved"]
    ? "&nbsp;<em>({$txt["awaiting_approval"]})</em>"
        : ""),
    "",
    ($topic["is_sticky"]
    ? "</strong>"
        : "");

echo "</div><div class='creator-and-pagination'>";
echo "  <span class='creator'>
            {$txt["started_by"]} {$topic["first_post"]["member"]["link"]}
        </span>
        <span class='pagination'>
            {$topic["pages"]}
        </span>
    </div>
</td>";

Lemon

  • (I have no sex virus)
  • Administrator
  • Miss Priss, I'd like to piss on your coat.
  • 3,229
  • 375
[REQUEST] Fix this stupid PHP.
« Reply #3 on: June 05, 2016, 12:20:44 pm »
Hmmmm, unfortunately no I'm not having luck with that. I'm editing this template, placing your bit at the parts between 268 - 283, and then providing a couple of extra apostrophes and echo commands to compensate, but when I upload the results, pages like this are completely blank.

duz

  • Paid
  • 367
  • 14
[REQUEST] Fix this stupid PHP.
« Reply #4 on: June 07, 2016, 07:40:23 pm »
Oh, woops, here's a pastebin of the full thing merged now that I'm sober and can do a proper diff.  If it's still not working I'll get git installed and tweak some more.
Lemon Ambious

Lemon

  • (I have no sex virus)
  • Administrator
  • Miss Priss, I'd like to piss on your coat.
  • 3,229
  • 375
[REQUEST] Fix this stupid PHP.
« Reply #5 on: June 08, 2016, 02:57:35 pm »
Yaaaaaay! Thanks, duz. That worked.

Bodark

  • Joan Ocean's #1 Fansquatch
  • Paid
  • I'm real and I tried to suck your dick.
  • 808
  • 54
[REQUEST] Fix this stupid PHP.
« Reply #6 on: June 08, 2016, 06:38:44 pm »
I really hate to burst your bubble, but it made things very messy on mobile.

Running Chrome on Android, fwiw.
Vinny Possum

Frank West

  • Have you ever astraled and kicked it with satan
  • Ridiculist
  • The size of an AHM (Average Human Mother)
    • 1,075
    • 95
[REQUEST] Fix this stupid PHP.
« Reply #7 on: June 08, 2016, 06:46:35 pm »
What Bodark said but if I said it instead.

Nifty Nif

  • Big Dumb Slimy Monster
  • Paid
  • powerful and can be dangreous
  • 814
  • 51
[REQUEST] Fix this stupid PHP.
« Reply #8 on: June 08, 2016, 06:52:03 pm »
Confirmed on Chrome, iOS 9. :(

Lemon

  • (I have no sex virus)
  • Administrator
  • Miss Priss, I'd like to piss on your coat.
  • 3,229
  • 375
[REQUEST] Fix this stupid PHP.
« Reply #9 on: June 08, 2016, 08:40:26 pm »
Confirmed on Chrome, iOS 9. :(

Shiiit.

Okay, on it.
Vinny Possum

Vinny Possum

  • Garfield's cosmic love katana.
  • Paid
  • 950
  • 50
[REQUEST] Fix this stupid PHP.
« Reply #10 on: June 08, 2016, 08:42:46 pm »
I really hate to burst your bubble, but it made things very messy on mobile.

Running Chrome on Android, fwiw.
I'm having the same problem, so it isn't an isolated thing.

Lemon

  • (I have no sex virus)
  • Administrator
  • Miss Priss, I'd like to piss on your coat.
  • 3,229
  • 375
[REQUEST] Fix this stupid PHP.
« Reply #11 on: June 08, 2016, 08:47:33 pm »
Yeah, I can duplicate it.

Though at the moment, I don't understand why this is happening, but I'll figure it out.

Nifty Nif

  • Big Dumb Slimy Monster
  • Paid
  • powerful and can be dangreous
  • 814
  • 51
[REQUEST] Fix this stupid PHP.
« Reply #12 on: June 08, 2016, 09:03:02 pm »
Yeah, I can duplicate it.

Though at the moment, I don't understand why this is happening, but I'll figure it out.

Did it happen in the 3.5 hours between your deploy and Bodark's post?  Not to be that guy, I know you know how to do your job, but it could be a sneaky browser update or some bullshit.  It probably wasn't.  :(  Just ruling things out, picking the low-hanging fruit.  I'll get my nose out of here.

Edit: it actually looks fine on mobile Safari, might be a Chrome thing.  And while I was trying to cross-check it on Firefox, I decided to double-check Chrome...and I think you either rolled it back or fixed it.  You're fast!  Nice job!
« Last Edit: June 08, 2016, 09:14:30 pm by Nifty Nif »

Vinny Possum

  • Garfield's cosmic love katana.
  • Paid
  • 950
  • 50
[REQUEST] Fix this stupid PHP.
« Reply #13 on: June 08, 2016, 09:14:01 pm »
Seems to be fixed. Thanks Lemon!
Bodark

Nifty Nif

  • Big Dumb Slimy Monster
  • Paid
  • powerful and can be dangreous
  • 814
  • 51
[REQUEST] Fix this stupid PHP.
« Reply #14 on: June 08, 2016, 09:16:32 pm »
I saw the tiniest blip while I was bulbing something, and that was probably when you fixed it.  Hot damn!  Shows what I know.  Thank you Lemon!!!  [yay][lemon]
Lemon Bodark