ballp.it

Snakes In The Ball Pit => Announcements => Topic started by: Lemon on July 06, 2015, 10:24:09 am

Title: [REQUEST] Fix this stupid PHP.
Post by: Lemon 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 (http://ballp.it/index.php?board=12.0)), the HTML rendered, in order, for the Subject/Started By cell is...


So, in HTML terms, what I get is...
HTML
<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...
HTML
<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...
PHP
<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 (https://github.com/AhoyLemon/ballpit), the file in question here is Themes/Giggle/MessageIndex.template.php

Otherwise, no big deal, but I'll probably never address that float issue.
Title: [REQUEST] Fix this stupid PHP.
Post by: Lemon on December 02, 2015, 12:30:34 pm
Just turned this into a GitHub issue (https://github.com/AhoyLemon/ballpit/issues/4).
Title: [REQUEST] Fix this stupid PHP.
Post by: duz on June 02, 2016, 11:18:03 pm
What messy code. So basically this?

PHP
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>";
Title: [REQUEST] Fix this stupid PHP.
Post by: Lemon on June 05, 2016, 12:20:44 pm
Hmmmm, unfortunately no I'm not having luck with that. I'm editing this template (https://github.com/AhoyLemon/ballpit/blob/master/Themes/Giggle/MessageIndex.template.php), 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 (http://ballp.it/index.php?board=12.0) are completely blank.
Title: [REQUEST] Fix this stupid PHP.
Post by: duz on June 07, 2016, 07:40:23 pm
Oh, woops, here's a pastebin (http://pastebin.com/aJ8JKLy3) 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.
Title: [REQUEST] Fix this stupid PHP.
Post by: Lemon on June 08, 2016, 02:57:35 pm
Yaaaaaay! Thanks, duz. That worked.
Title: [REQUEST] Fix this stupid PHP.
Post by: Bodark 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.
Title: [REQUEST] Fix this stupid PHP.
Post by: Frank West on June 08, 2016, 06:46:35 pm
What Bodark said but if I said it instead.
Title: [REQUEST] Fix this stupid PHP.
Post by: Nifty Nif on June 08, 2016, 06:52:03 pm
Confirmed on Chrome, iOS 9. :(
Title: [REQUEST] Fix this stupid PHP.
Post by: Lemon on June 08, 2016, 08:40:26 pm
Confirmed on Chrome, iOS 9. :(
Nifty Nif, June 08, 2016, 06:52:03 pm

Shiiit.

Okay, on it.
Title: [REQUEST] Fix this stupid PHP.
Post by: Vinny Possum 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.
Bodark, June 08, 2016, 06:38:44 pm
I'm having the same problem, so it isn't an isolated thing.
Title: [REQUEST] Fix this stupid PHP.
Post by: Lemon 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.
Title: [REQUEST] Fix this stupid PHP.
Post by: Nifty Nif 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.
Lemon, June 08, 2016, 08:47:33 pm

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!
Title: [REQUEST] Fix this stupid PHP.
Post by: Vinny Possum on June 08, 2016, 09:14:01 pm
Seems to be fixed. Thanks Lemon!
Title: [REQUEST] Fix this stupid PHP.
Post by: Nifty Nif 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]
Title: [REQUEST] Fix this stupid PHP.
Post by: duz on June 18, 2016, 11:39:29 pm
I noticed the same thing randomly until I refreshed.

There is one css class that was in the original that you didn't ask for in the new format so I didn't include it.  If that is an issue, it's NBD to include.