1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 
<?php
/**
 * Simple Machines Forum (SMF)
 *
 * @package SMF
 * @author Simple Machines http://www.simplemachines.org
 * @copyright 2019 Simple Machines and individual contributors
 * @license http://www.simplemachines.org/about/smf/license.php BSD
 *
 * @version 2.1 RC1
 */

/**
 * Template for showing recent posts
 */
function template_recent()
{
    global $context, $txt, $scripturl;

    echo '
    <div id="recent" class="main_section">
        <div class="cat_bar">
            <h3 class="catbg">
                <span class="xx"></span>', $txt['recent_posts'], '
            </h3>
        </div>
        <div class="pagesection">', $context['page_index'], '</div>';

    if (empty($context['posts']))
        echo '
        <div class="windowbg">', $txt['no_messages'], '</div>';

    foreach ($context['posts'] as $post)
    {
        echo '
        <div class="', $post['css_class'], '">
            <div class="counter">', $post['counter'], '</div>
            <div class="topic_details">
                <h5>', $post['board']['link'], ' / ', $post['link'], '</h5>
                <span class="smalltext">', $txt['last_poster'], ' <strong>', $post['poster']['link'], ' </strong> - ', $post['time'], '</span>
            </div>
            <div class="list_posts">', $post['message'], '</div>';

        if ($post['can_reply'] || $post['can_quote'] || $post['can_delete'])
            echo '
            <ul class="quickbuttons">';

        // If they *can* reply?
        if ($post['can_reply'])
            echo '
                <li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], '"><span class="main_icons reply_button"></span>', $txt['reply'], '</a></li>';

        // If they *can* quote?
        if ($post['can_quote'])
            echo '
                <li><a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], ';quote=', $post['id'], '"><span class="main_icons quote"></span>', $txt['quote_action'], '</a></li>';

        // How about... even... remove it entirely?!
        if ($post['can_delete'])
            echo '
                <li><a href="', $scripturl, '?action=deletemsg;msg=', $post['id'], ';topic=', $post['topic'], ';recent;', $context['session_var'], '=', $context['session_id'], '" data-confirm="', $txt['remove_message'], '" class="you_sure"><span class="main_icons remove_button"></span>', $txt['remove'], '</a></li>';

        if ($post['can_reply'] || $post['can_quote'] || $post['can_delete'])
            echo '
            </ul>';

        echo '
        </div><!-- $post[css_class] -->';
    }

    echo '
        <div class="pagesection">', $context['page_index'], '</div>
    </div><!-- #recent -->';
}

/**
 * Template for showing unread posts
 */
function template_unread()
{
    global $context, $settings, $txt, $scripturl, $modSettings;

    echo '
    <div id="recent" class="main_content">';

    if ($context['showCheckboxes'])
        echo '
        <form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="quickModForm" id="quickModForm">
            <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
            <input type="hidden" name="qaction" value="markread">
            <input type="hidden" name="redirect_url" value="action=unread', (!empty($context['showing_all_topics']) ? ';all' : ''), $context['querystring_board_limits'], '">';

    if (!empty($context['topics']))
    {
        echo '
            <div class="pagesection">
                ', $context['menu_separator'], '
                <div class="pagelinks floatleft">
                    <a href="#bot" class="button">', $txt['go_down'], '</a>
                    ', $context['page_index'], '
                </div>
                ', !empty($context['recent_buttons']) ? template_button_strip($context['recent_buttons'], 'right') : '', '
            </div>';

        echo '
            <div id="unread">
                <div id="topic_header" class="title_bar">
                    <div class="board_icon"></div>
                    <div class="info">
                        <a href="', $scripturl, '?action=unread', $context['showing_all_topics'] ? ';all' : '', $context['querystring_board_limits'], ';sort=subject', $context['sort_by'] == 'subject' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt['subject'], $context['sort_by'] == 'subject' ? ' <span class="main_icons sort_' . $context['sort_direction'] . '"></span>' : '', '</a>
                    </div>
                    <div class="board_stats centertext">
                        <a href="', $scripturl, '?action=unread', $context['showing_all_topics'] ? ';all' : '', $context['querystring_board_limits'], ';sort=replies', $context['sort_by'] == 'replies' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt['replies'], $context['sort_by'] == 'replies' ? ' <span class="main_icons sort_' . $context['sort_direction'] . '"></span>' : '', '</a>
                    </div>
                    <div class="lastpost">
                        <a href="', $scripturl, '?action=unread', $context['showing_all_topics'] ? ';all' : '', $context['querystring_board_limits'], ';sort=last_post', $context['sort_by'] == 'last_post' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt['last_post'], $context['sort_by'] == 'last_post' ? ' <span class="main_icons sort_' . $context['sort_direction'] . '"></span>' : '', '</a>
                    </div>';

        // Show a "select all" box for quick moderation?
        if ($context['showCheckboxes'])
            echo '
                    <div class="moderation">
                        <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');">
                    </div>';

        echo '
                </div><!-- #topic_header -->
                <div id="topic_container">';

        foreach ($context['topics'] as $topic)
        {
            echo '
                    <div class="', $topic['css_class'], '">
                        <div class="board_icon">
                            <img src="', $topic['first_post']['icon_url'], '" alt="">
                            ', $topic['is_posted_in'] ? '<img class="posted" src="' . $settings['images_url'] . '/icons/profile_sm.png" alt="">' : '', '
                        </div>
                        <div class="info">';

            // Now we handle the icons
            echo '
                            <div class="icons floatright">';

            if ($topic['is_locked'])
                echo '
                                <span class="main_icons lock"></span>';

            if ($topic['is_sticky'])
                echo '
                                <span class="main_icons sticky"></span>';

            if ($topic['is_poll'])
                echo '
                                <span class="main_icons poll"></span>';

            echo '
                            </div>';

            echo '
                            <div class="recent_title">
                                <a href="', $topic['new_href'], '" id="newicon', $topic['first_post']['id'], '" class="new_posts">' . $txt['new'] . '</a>
                                ', $topic['is_sticky'] ? '<strong>' : '', '<span class="preview" title="', $topic[(empty($modSettings['message_index_preview_first']) ? 'last_post' : 'first_post')]['preview'], '"><span id="msg_' . $topic['first_post']['id'] . '">', $topic['first_post']['link'], '</span></span>', $topic['is_sticky'] ? '</strong>' : '', '
                            </div>
                            <p class="floatleft">
                                ', $topic['first_post']['started_by'], '
                            </p>
                            ', !empty($topic['pages']) ? '<span id="pages' . $topic['first_post']['id'] . '" class="topic_pages">' . $topic['pages'] . '</span>' : '', '
                        </div><!-- .info -->
                        <div class="board_stats centertext">
                            <p>
                                ', $topic['replies'], ' ', $txt['replies'], '
                                <br>
                                ', $topic['views'], ' ', $txt['views'], '
                            </p>
                        </div>
                        <div class="lastpost">
                            ', sprintf($txt['last_post_topic'], '<a href="' . $topic['last_post']['href'] . '">' . $topic['last_post']['time'] . '</a>', $topic['last_post']['member']['link']), '
                        </div>';

            if ($context['showCheckboxes'])
                echo '
                        <div class="moderation">
                            <input type="checkbox" name="topics[]" value="', $topic['id'], '">
                        </div>';

            echo '
                    </div><!-- $topic[css_class] -->';
        }

        if (empty($context['topics']))
            echo '
                    <div style="display: none;"></div>';

        echo '
                </div><!-- #topic_container -->
            </div><!-- #unread -->';

        echo '
            <div class="pagesection">
                ', !empty($context['recent_buttons']) ? template_button_strip($context['recent_buttons'], 'right') : '', '
                ', $context['menu_separator'], '
                <div class="pagelinks">
                    <a href="#recent" class="button">', $txt['go_up'], '</a>
                    ', $context['page_index'], '
                </div>
            </div>';
    }
    else
        echo '
            <div class="cat_bar">
                <h3 class="catbg centertext">
                    ', $context['showing_all_topics'] ? $txt['topic_alert_none'] : $txt['unread_topics_visit_none'], '
                </h3>
            </div>';

    if ($context['showCheckboxes'])
        echo '
        </form>';

    echo '
    </div><!-- #recent -->';

    if (empty($context['no_topic_listing']))
        template_topic_legend();
}

/**
 * Template for showing unread replies (eg new replies to topics you've posted in)
 */
function template_replies()
{
    global $context, $settings, $txt, $scripturl, $modSettings;

    echo '
    <div id="recent">';

    if ($context['showCheckboxes'])
        echo '
        <form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="quickModForm" id="quickModForm">
            <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
            <input type="hidden" name="qaction" value="markread">
            <input type="hidden" name="redirect_url" value="action=unreadreplies', (!empty($context['showing_all_topics']) ? ';all' : ''), $context['querystring_board_limits'], '">';

    if (!empty($context['topics']))
    {
        echo '
            <div class="pagesection">
                ', $context['menu_separator'], '
                <div class="pagelinks floatleft">
                    <a href="#bot" class="button">', $txt['go_down'], '</a>
                    ', $context['page_index'], '
                </div>
                ', !empty($context['recent_buttons']) ? template_button_strip($context['recent_buttons'], 'right') : '', '
            </div>';

        echo '
            <div id="unreadreplies">
                <div id="topic_header" class="title_bar">
                    <div class="board_icon"></div>
                    <div class="info">
                        <a href="', $scripturl, '?action=unreadreplies', $context['querystring_board_limits'], ';sort=subject', $context['sort_by'] === 'subject' && $context['sort_direction'] === 'up' ? ';desc' : '', '">', $txt['subject'], $context['sort_by'] === 'subject' ? ' <span class="main_icons sort_' . $context['sort_direction'] . '"></span>' : '', '</a>
                    </div>
                    <div class="board_stats centertext">
                        <a href="', $scripturl, '?action=unreadreplies', $context['querystring_board_limits'], ';sort=replies', $context['sort_by'] === 'replies' && $context['sort_direction'] === 'up' ? ';desc' : '', '">', $txt['replies'], $context['sort_by'] === 'replies' ? ' <span class="main_icons sort_' . $context['sort_direction'] . '"></span>' : '', '</a>
                    </div>
                    <div class="lastpost">
                        <a href="', $scripturl, '?action=unreadreplies', $context['querystring_board_limits'], ';sort=last_post', $context['sort_by'] === 'last_post' && $context['sort_direction'] === 'up' ? ';desc' : '', '">', $txt['last_post'], $context['sort_by'] === 'last_post' ? ' <span class="main_icons sort_' . $context['sort_direction'] . '"></span>' : '', '</a>
                    </div>';

        // Show a "select all" box for quick moderation?
        if ($context['showCheckboxes'])
            echo '
                    <div class="moderation">
                        <input type="checkbox" onclick="invertAll(this, this.form, \'topics[]\');">
                    </div>';

        echo '
                </div><!-- #topic_header -->
                <div id="topic_container">';

        foreach ($context['topics'] as $topic)
        {
            echo '
                    <div class="', $topic['css_class'], '">
                        <div class="board_icon">
                            <img src="', $topic['first_post']['icon_url'], '" alt="">
                            ', $topic['is_posted_in'] ? '<img class="posted" src="' . $settings['images_url'] . '/icons/profile_sm.png" alt="">' : '', '
                        </div>
                        <div class="info">';

            // Now we handle the icons
            echo '
                            <div class="icons floatright">';

            if ($topic['is_locked'])
                echo '
                                <span class="main_icons lock"></span>';

            if ($topic['is_sticky'])
                echo '
                                <span class="main_icons sticky"></span>';

            if ($topic['is_poll'])
                echo '
                                <span class="main_icons poll"></span>';

            echo '
                            </div>';

            echo '
                            <div class="recent_title">
                                <a href="', $topic['new_href'], '" id="newicon', $topic['first_post']['id'], '" class="new_posts">' . $txt['new'] . '</a>
                                ', $topic['is_sticky'] ? '<strong>' : '', '<span title="', $topic[(empty($modSettings['message_index_preview_first']) ? 'last_post' : 'first_post')]['preview'], '"><span id="msg_' . $topic['first_post']['id'] . '">', $topic['first_post']['link'], '</span>', $topic['is_sticky'] ? '</strong>' : '', '
                            </div>
                            <p class="floatleft">
                                ', $topic['first_post']['started_by'], '
                            </p>
                            ', !empty($topic['pages']) ? '<span id="pages' . $topic['first_post']['id'] . '" class="topic_pages">' . $topic['pages'] . '</span>' : '', '
                        </div><!-- .info -->
                        <div class="board_stats centertext">
                            <p>
                                ', $topic['replies'], ' ', $txt['replies'], '
                                <br>
                                ', $topic['views'], ' ', $txt['views'], '
                            </p>
                        </div>
                        <div class="lastpost">
                            ', sprintf($txt['last_post_topic'], '<a href="' . $topic['last_post']['href'] . '">' . $topic['last_post']['time'] . '</a>', $topic['last_post']['member']['link']), '
                        </div>';

            if ($context['showCheckboxes'])
                echo '
                        <div class="moderation">
                            <input type="checkbox" name="topics[]" value="', $topic['id'], '">
                        </div>';

            echo '
                    </div><!-- $topic[css_class] -->';
        }

        echo '
                </div><!-- #topic_container -->
            </div><!-- #unreadreplies -->
            <div class="pagesection">
                ', !empty($context['recent_buttons']) ? template_button_strip($context['recent_buttons'], 'right') : '', '
                ', $context['menu_separator'], '
                <div class="pagelinks">
                    <a href="#recent" class="button">', $txt['go_up'], '</a>
                    ', $context['page_index'], '
                </div>
            </div>';
    }
    else
        echo '
            <div class="cat_bar">
                <h3 class="catbg centertext">
                    ', $context['showing_all_topics'] ? $txt['topic_alert_none'] : $txt['updated_topics_visit_none'], '
                </h3>
            </div>';

    if ($context['showCheckboxes'])
        echo '
        </form>';

    echo '
    </div><!-- #recent -->';

    if (empty($context['no_topic_listing']))
        template_topic_legend();
}

?>