当前位置: 首页>>代码示例>>PHP>>正文


PHP template::display方法代码示例

本文整理汇总了PHP中phpbb\template\template::display方法的典型用法代码示例。如果您正苦于以下问题:PHP template::display方法的具体用法?PHP template::display怎么用?PHP template::display使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在phpbb\template\template的用法示例。


在下文中一共展示了template::display方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: recent

    public function recent()
    {
        $http_ajax = $this->request->server('HTTP_X_REQUESTED_WITH') == "XMLHttpRequest" ? true : false;
        $crawl = $this->request->variable('mode', '');
        $this->template->assign_vars(array('L_RECENT_TITLE' => $this->config['recent_title'], 'L_RECENT_POSTS_NAME' => $this->config['recent_posts_name'], 'S_RECENT_MARQUE' => $this->config['recent_show_marque'] && $crawl ? true : false));
        $http_headers = array('Content-type' => 'text/html; charset=UTF-8', 'Cache-Control' => 'private, no-cache="set-cookie", pre-check=0, post-check=0, max-age=0', 'Expires' => gmdate('D, d M Y H:i:s', time()) . ' GMT', 'Pragma' => 'no-cache');
        foreach ($http_headers as $hname => $hval) {
            header((string) $hname . ': ' . (string) $hval);
        }
        //
        // Building URL
        //
        $board_path = generate_board_url();
        $viewtopic_url = $board_path . '/viewtopic.' . $this->php_ext;
        $forum = $this->request->variable('forum', 0);
        if ($forum || !$this->config['recent_ignore_forums'] && $this->config['recent_only_forums']) {
            if ($forum) {
                $sql_forums = ' AND t.forum_id = "' . $this->db->sql_escape($forum) . '" ';
            } else {
                $sql_forums = ' AND t.forum_id IN(' . $this->config['recent_only_forums'] . ') ';
            }
        } else {
            // Fetching forums that should not be displayed
            $forums = implode(',', array_keys($this->auth->acl_getf('!f_read', true)));
            if ($this->config['recent_only_forums'] && !empty($forums)) {
                $cfg_ignore_forums = $this->config['recent_only_forums'] . ',' . $forums;
            } else {
                if (!empty($forums)) {
                    $cfg_ignore_forums = $forums;
                } else {
                    $cfg_ignore_forums = $this->config['recent_only_forums'] ? $this->config['recent_only_forums'] : '';
                }
            }
            // Building sql for forums that should not be displayed
            $sql_forums = $cfg_ignore_forums ? ' AND t.forum_id NOT IN(' . $cfg_ignore_forums . ') ' : '';
        }
        // Fetching topics of public forums
        $sql = 'SELECT t.*, p.post_id, p.post_text, p.bbcode_uid, p.bbcode_bitfield, p.post_attachment
			FROM ' . TOPICS_TABLE . ' AS t, ' . POSTS_TABLE . ' AS p, ' . FORUMS_TABLE . " AS f\n\t\t\tWHERE t.forum_id = f.forum_id\n\t\t\t\t{$sql_forums}\n\t\t\t\tAND p.post_id = t.topic_first_post_id\n\t\t\t\tAND t.topic_moved_id = 0\n\t\t\tORDER BY t.topic_last_post_id DESC";
        $result = $this->db->sql_query_limit($sql, $this->config['recent_nm_topics']);
        if (!($recent_topics = $this->db->sql_fetchrowset($result))) {
            trigger_error('NO_FORUM');
        }
        //
        // BEGIN ATTACHMENT DATA
        //
        if ($this->config['recent_show_first_post'] && $this->config['recent_show_attachments'] && !$crawl) {
            $attach_list = $update_count = array();
            foreach ($recent_topics as $post_attachment) {
                if ($post_attachment['post_attachment'] && $this->config['allow_attachments']) {
                    $attach_list[] = $post_attachment['post_id'];
                    if ($post_attachment['topic_posts_approved']) {
                        $has_attachments = true;
                    }
                }
            }
            // Pull attachment data
            if (sizeof($attach_list)) {
                if ($this->auth->acl_get('u_download')) {
                    $sql_attach = 'SELECT *
						FROM ' . ATTACHMENTS_TABLE . '
						WHERE ' . $this->db->sql_in_set('post_msg_id', $attach_list) . '
							AND in_message = 0
						ORDER BY filetime DESC, post_msg_id ASC';
                    $result_attach = $this->db->sql_query($sql_attach);
                    while ($row_attach = $this->db->sql_fetchrow($result_attach)) {
                        $attachments[$row_attach['post_msg_id']][] = $row_attach;
                    }
                    $this->db->sql_freeresult($result_attach);
                } else {
                    $display_notice = true;
                }
            }
        }
        //
        // END ATTACHMENT DATA
        //
        foreach ($recent_topics as $row) {
            $topic_title = censor_text($row['topic_title']);
            if (!$this->config['recent_show_first_post'] && utf8_strlen($topic_title) > $this->config['recent_max_topic_length']) {
                $topic_title = utf8_substr($topic_title, 0, $this->config['recent_max_topic_length']) . '…';
            }
            // Replies
            if ($this->config['recent_show_replies']) {
                global $phpbb_container;
                $phpbb_content_visibility = $phpbb_container->get('content.visibility');
                $replies = $phpbb_content_visibility->get_count('topic_posts', $row, $row['forum_id']) - 1;
            }
            $this->template->assign_block_vars('topicrow', array('U_TOPIC' => $viewtopic_url . '?t=' . $row['topic_id'], 'U_LAST_POST' => $viewtopic_url . '?p=' . $row['topic_last_post_id'] . '#' . $row['topic_last_post_id'], 'TOPIC_TITLE' => $topic_title, 'TOPIC_REPLIES' => isset($replies) ? $replies : '', 'TOPIC_AUTHOR' => get_username_string('username', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 'FIRST_POST_TIME' => $this->user->format_date($row['topic_time']), 'LAST_POST_TIME' => $this->user->format_date($row['topic_last_post_time']), 'LAST_POST_AUTHOR' => get_username_string('username', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 'POST_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour'])));
            if ($this->config['recent_show_first_post'] && !$crawl) {
                $message = $row['post_text'];
                if (utf8_strlen($message) > $this->config['recent_max_topic_length']) {
                    //strip_bbcode($message);
                    //$message = utf8_substr($message, 0, $this->config['recent_max_topic_length']) . '…';
                    $message = $this->text_substr($message, $this->config['recent_max_topic_length']) . '…';
                }
                // Parse the message and subject
                $parse_flags = ($row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES;
                $message = generate_text_for_display($message, $row['bbcode_uid'], $row['bbcode_bitfield'], $parse_flags, true);
                if (!$http_ajax) {
//.........这里部分代码省略.........
开发者ID:Galixte,项目名称:recent_topics,代码行数:101,代码来源:recent.php


注:本文中的phpbb\template\template::display方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。