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


PHP htmlTime函数代码示例

本文整理汇总了PHP中htmlTime函数的典型用法代码示例。如果您正苦于以下问题:PHP htmlTime函数的具体用法?PHP htmlTime怎么用?PHP htmlTime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: action_sportal_index

 /**
  * Loads article previews for display with the portal index template
  */
 public function action_sportal_index()
 {
     global $context, $modSettings;
     // Showing articles on the index page?
     if (!empty($modSettings['sp_articles_index'])) {
         require_once SUBSDIR . '/PortalArticle.subs.php';
         $context['sub_template'] = 'portal_index';
         // Set up the pages
         $total_articles = sportal_get_articles_count();
         $total = min($total_articles, !empty($modSettings['sp_articles_index_total']) ? $modSettings['sp_articles_index_total'] : 20);
         $per_page = min($total, !empty($modSettings['sp_articles_index_per_page']) ? $modSettings['sp_articles_index_per_page'] : 5);
         $start = !empty($_REQUEST['articles']) ? (int) $_REQUEST['articles'] : 0;
         if ($total > $per_page) {
             $context['article_page_index'] = constructPageIndex($context['portal_url'] . '?articles=%1$d', $start, $total, $per_page, true);
         }
         // If we have some articles
         require_once SUBSDIR . '/PortalArticle.subs.php';
         $context['articles'] = sportal_get_articles(0, true, true, 'spa.id_article DESC', 0, $per_page, $start);
         foreach ($context['articles'] as $article) {
             if (empty($modSettings['sp_articles_length']) && ($cutoff = Util::strpos($article['body'], '[cutoff]')) !== false) {
                 $article['body'] = Util::substr($article['body'], 0, $cutoff);
                 if ($article['type'] === 'bbc') {
                     require_once SUBSDIR . '/Post.subs.php';
                     preparsecode($article['body']);
                 }
             }
             $context['articles'][$article['id']]['preview'] = sportal_parse_content($article['body'], $article['type'], 'return');
             $context['articles'][$article['id']]['date'] = htmlTime($article['date']);
             // Just want a shorter look on the index page
             if (!empty($modSettings['sp_articles_length'])) {
                 $context['articles'][$article['id']]['preview'] = Util::shorten_html($context['articles'][$article['id']]['preview'], $modSettings['sp_articles_length']);
             }
         }
     }
 }
开发者ID:emanuele45,项目名称:SimplePortal_ElkArte,代码行数:38,代码来源:PortalMain.controller.php

示例2: getErrorLogData

/**
 * Gets data from the error log
 *
 * @param int $start
 * @param string $sort_direction
 * @param mixed[]|null $filter
 */
function getErrorLogData($start, $sort_direction = 'DESC', $filter = null)
{
    global $modSettings, $scripturl, $txt;
    $db = database();
    // Find and sort out the errors.
    $request = $db->query('', '
		SELECT id_error, id_member, ip, url, log_time, message, session, error_type, file, line
		FROM {db_prefix}log_errors' . (isset($filter) ? '
		WHERE ' . $filter['variable'] . ' LIKE {string:filter}' : '') . '
		ORDER BY id_error ' . ($sort_direction == 'down' ? 'DESC' : '') . '
		LIMIT ' . $start . ', ' . $modSettings['defaultMaxMessages'], array('filter' => isset($filter) ? $filter['value']['sql'] : ''));
    $log = array();
    for ($i = 0; $row = $db->fetch_assoc($request); $i++) {
        $search_message = preg_replace('~<span class="remove">(.+?)</span>~', '%', $db->escape_wildcard_string($row['message']));
        if ($search_message == $filter['value']['sql']) {
            $search_message = $db->escape_wildcard_string($row['message']);
        }
        $show_message = strtr(strtr(preg_replace('~&lt;span class=&quot;remove&quot;&gt;(.+?)&lt;/span&gt;~', '$1', $row['message']), array("\r" => '', '<br />' => "\n", '<' => '&lt;', '>' => '&gt;', '"' => '&quot;')), array("\n" => '<br />'));
        $log['errors'][$row['id_error']] = array('alternate' => $i % 2 == 0, 'member' => array('id' => $row['id_member'], 'ip' => $row['ip'], 'session' => $row['session']), 'time' => standardTime($row['log_time']), 'html_time' => htmlTime($row['log_time']), 'timestamp' => forum_time(true, $row['log_time']), 'url' => array('html' => htmlspecialchars((substr($row['url'], 0, 1) == '?' ? $scripturl : '') . $row['url'], ENT_COMPAT, 'UTF-8'), 'href' => base64_encode($db->escape_wildcard_string($row['url']))), 'message' => array('html' => $show_message, 'href' => base64_encode($search_message)), 'id' => $row['id_error'], 'error_type' => array('type' => $row['error_type'], 'name' => isset($txt['errortype_' . $row['error_type']]) ? $txt['errortype_' . $row['error_type']] : $row['error_type']), 'file' => array());
        if (!empty($row['file']) && !empty($row['line'])) {
            // Eval'd files rarely point to the right location and cause havoc for linking, so don't link them.
            $linkfile = strpos($row['file'], 'eval') === false || strpos($row['file'], '?') === false;
            // De Morgan's Law.  Want this true unless both are present.
            $log['errors'][$row['id_error']]['file'] = array('file' => $row['file'], 'line' => $row['line'], 'href' => $scripturl . '?action=admin;area=logs;sa=errorlog;activity=file;file=' . base64_encode($row['file']) . ';line=' . $row['line'], 'link' => $linkfile ? '<a href="' . $scripturl . '?action=admin;area=logs;sa=errorlog;activity=file;file=' . base64_encode($row['file']) . ';line=' . $row['line'] . '" onclick="return reqWin(this.href, 600, 480, false);">' . $row['file'] . '</a>' : $row['file'], 'search' => base64_encode($row['file']));
        }
        // Make a list of members to load later.
        $log['members'][$row['id_member']] = $row['id_member'];
    }
    $db->free_result($request);
    return $log;
}
开发者ID:KeiroD,项目名称:Elkarte,代码行数:38,代码来源:Error.subs.php

示例3: action_sportal_category

 /**
  * View a specific category, showing all articles it contains
  */
 public function action_sportal_category()
 {
     global $context, $scripturl, $modSettings;
     // Basic article support
     require_once SUBSDIR . '/PortalArticle.subs.php';
     $category_id = !empty($_REQUEST['category']) ? $_REQUEST['category'] : 0;
     if (is_int($category_id)) {
         $category_id = (int) $category_id;
     } else {
         $category_id = Util::htmlspecialchars($category_id, ENT_QUOTES);
     }
     $context['category'] = sportal_get_categories($category_id, true, true);
     if (empty($context['category']['id'])) {
         fatal_lang_error('error_sp_category_not_found', false);
     }
     // Set up the pages
     $total_articles = sportal_get_articles_in_cat_count($context['category']['id']);
     $per_page = min($total_articles, !empty($modSettings['sp_articles_per_page']) ? $modSettings['sp_articles_per_page'] : 10);
     $start = !empty($_REQUEST['start']) ? (int) $_REQUEST['start'] : 0;
     if ($total_articles > $per_page) {
         $context['page_index'] = constructPageIndex($context['category']['href'] . ';start=%1$d', $start, $total_articles, $per_page, true);
     }
     // Load the articles in this category
     $context['articles'] = sportal_get_articles(0, true, true, 'spa.id_article DESC', $context['category']['id'], $per_page, $start);
     foreach ($context['articles'] as $article) {
         // Cut me mick
         if (($cutoff = Util::strpos($article['body'], '[cutoff]')) !== false) {
             $article['body'] = Util::substr($article['body'], 0, $cutoff);
             if ($article['type'] === 'bbc') {
                 require_once SUBSDIR . '/Post.subs.php';
                 preparsecode($article['body']);
             }
         }
         $context['articles'][$article['id']]['preview'] = sportal_parse_content($article['body'], $article['type'], 'return');
         $context['articles'][$article['id']]['date'] = htmlTime($article['date']);
     }
     $context['linktree'][] = array('url' => $scripturl . '?category=' . $context['category']['category_id'], 'name' => $context['category']['name']);
     $context['page_title'] = $context['category']['name'];
     $context['sub_template'] = 'view_category';
 }
开发者ID:emanuele45,项目名称:SimplePortal_ElkArte,代码行数:43,代码来源:PortalCategories.controller.php

示例4: action_who

 /**
  * Who's online, and what are they doing?
  * This function prepares the who's online data for the Who template.
  * It requires the who_view permission.
  * It is enabled with the who_enabled setting.
  * It is accessed via ?action=who.
  *
  * @uses Who template, main sub-template
  * @uses Who language file.
  */
 public function action_who()
 {
     global $context, $scripturl, $txt, $modSettings, $memberContext;
     // Permissions, permissions, permissions.
     isAllowedTo('who_view');
     // You can't do anything if this is off.
     if (empty($modSettings['who_enabled'])) {
         fatal_lang_error('who_off', false);
     }
     // Load the 'Who' template.
     loadTemplate('Who');
     loadLanguage('Who');
     // Sort out... the column sorting.
     $sort_methods = array('user' => 'mem.real_name', 'time' => 'lo.log_time');
     $show_methods = array('members' => '(lo.id_member != 0)', 'guests' => '(lo.id_member = 0)', 'all' => '1=1');
     // Store the sort methods and the show types for use in the template.
     $context['sort_methods'] = array('user' => $txt['who_user'], 'time' => $txt['who_time']);
     $context['show_methods'] = array('all' => $txt['who_show_all'], 'members' => $txt['who_show_members_only'], 'guests' => $txt['who_show_guests_only']);
     // Can they see spiders too?
     if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] == 2 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) {
         $show_methods['spiders'] = '(lo.id_member = 0 AND lo.id_spider > 0)';
         $show_methods['guests'] = '(lo.id_member = 0 AND lo.id_spider = 0)';
         $context['show_methods']['spiders'] = $txt['who_show_spiders_only'];
     } elseif (empty($modSettings['show_spider_online']) && isset($_SESSION['who_online_filter']) && $_SESSION['who_online_filter'] == 'spiders') {
         unset($_SESSION['who_online_filter']);
     }
     // Does the user prefer a different sort direction?
     if (isset($_REQUEST['sort']) && isset($sort_methods[$_REQUEST['sort']])) {
         $context['sort_by'] = $_SESSION['who_online_sort_by'] = $_REQUEST['sort'];
         $sort_method = $sort_methods[$_REQUEST['sort']];
     } elseif (isset($_SESSION['who_online_sort_by'])) {
         $context['sort_by'] = $_SESSION['who_online_sort_by'];
         $sort_method = $sort_methods[$_SESSION['who_online_sort_by']];
     } else {
         $context['sort_by'] = $_SESSION['who_online_sort_by'] = 'time';
         $sort_method = 'lo.log_time';
     }
     $context['sort_direction'] = isset($_REQUEST['asc']) || isset($_REQUEST['sort_dir']) && $_REQUEST['sort_dir'] == 'asc' ? 'up' : 'down';
     $conditions = array();
     if (!allowedTo('moderate_forum')) {
         $conditions[] = '(IFNULL(mem.show_online, 1) = 1)';
     }
     // Fallback to top filter?
     if (isset($_REQUEST['submit_top']) && isset($_REQUEST['show_top'])) {
         $_REQUEST['show'] = $_REQUEST['show_top'];
     }
     // Does the user wish to apply a filter?
     if (isset($_REQUEST['show']) && isset($show_methods[$_REQUEST['show']])) {
         $context['show_by'] = $_SESSION['who_online_filter'] = $_REQUEST['show'];
         $conditions[] = $show_methods[$_REQUEST['show']];
     } elseif (isset($_SESSION['who_online_filter'])) {
         $context['show_by'] = $_SESSION['who_online_filter'];
         $conditions[] = $show_methods[$_SESSION['who_online_filter']];
     } else {
         $context['show_by'] = $_SESSION['who_online_filter'] = 'all';
     }
     require_once SUBSDIR . '/Members.subs.php';
     $totalMembers = countMembersOnline($conditions);
     // Prepare some page index variables.
     $context['page_index'] = constructPageIndex($scripturl . '?action=who;sort=' . $context['sort_by'] . ($context['sort_direction'] == 'up' ? ';asc' : '') . ';show=' . $context['show_by'], $_REQUEST['start'], $totalMembers, $modSettings['defaultMaxMembers']);
     $context['start'] = $_REQUEST['start'];
     $context['sub_template'] = 'whos_online';
     Template_Layers::getInstance()->add('whos_selection');
     // Look for people online, provided they don't mind if you see they are.
     $members = onlineMembers($conditions, $sort_method, $context['sort_direction'], $context['start']);
     $context['members'] = array();
     $member_ids = array();
     $url_data = array();
     foreach ($members as $row) {
         $actions = @unserialize($row['url']);
         if ($actions === false) {
             continue;
         }
         // Send the information to the template.
         $context['members'][$row['session']] = array('id' => $row['id_member'], 'ip' => allowedTo('moderate_forum') ? $row['ip'] : '', 'time' => standardTime($row['log_time'], true), 'html_time' => htmlTime($row['log_time']), 'timestamp' => forum_time(true, $row['log_time']), 'query' => $actions, 'is_hidden' => $row['show_online'] == 0, 'id_spider' => $row['id_spider'], 'color' => empty($row['online_color']) ? '' : $row['online_color']);
         $url_data[$row['session']] = array($row['url'], $row['id_member']);
         $member_ids[] = $row['id_member'];
     }
     // Load the user data for these members.
     loadMemberData($member_ids);
     // Load up the guest user.
     $memberContext[0] = array('id' => 0, 'name' => $txt['guest_title'], 'group' => $txt['guest_title'], 'href' => '', 'link' => $txt['guest_title'], 'email' => $txt['guest_title'], 'is_guest' => true);
     // Are we showing spiders?
     $spiderContext = array();
     if (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] == 2 || allowedTo('admin_forum')) && !empty($modSettings['spider_name_cache'])) {
         foreach (unserialize($modSettings['spider_name_cache']) as $id => $name) {
             $spiderContext[$id] = array('id' => 0, 'name' => $name, 'group' => $txt['spiders'], 'href' => '', 'link' => $name, 'email' => $name, 'is_guest' => true);
         }
     }
     require_once SUBSDIR . '/Who.subs.php';
//.........这里部分代码省略.........
开发者ID:KeiroD,项目名称:Elkarte,代码行数:101,代码来源:Who.controller.php

示例5: getUnapprovedPosts

/**
 * Make sure the "current user" (uses $user_info) cannot go outside of the limit for the day.
 *
 * @param string $approve_query additional condition for the query
 * @param string $current_view defined whether return the topics (first
 *                messages) or the messages. If set to 'topics' it returns
 *                the topics, otherwise the messages
 * @param mixed[] $boards_allowed array of arrays, it must contain three
 *                 indexes:
 *                  - delete_own_boards
 *                  - delete_any_boards
 *                  - delete_own_replies
 *                 each of which must be an array of boards the user is allowed
 *                 to perform a certain action (return of boardsAllowedTo)
 * @param int $start start of the query LIMIT
 * @param int $limit number of elements to return (default 10)
 */
function getUnapprovedPosts($approve_query, $current_view, $boards_allowed, $start, $limit = 10)
{
    global $context, $scripturl, $user_info;
    $db = database();
    $request = $db->query('', '
		SELECT m.id_msg, m.id_topic, m.id_board, m.subject, m.body, m.id_member,
			IFNULL(mem.real_name, m.poster_name) AS poster_name, m.poster_time, m.smileys_enabled,
			t.id_member_started, t.id_first_msg, b.name AS board_name, c.id_cat, c.name AS cat_name
		FROM {db_prefix}messages AS m
			INNER JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic)
			INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board)
			LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
			LEFT JOIN {db_prefix}categories AS c ON (c.id_cat = b.id_cat)
		WHERE m.approved = {int:not_approved}
			AND t.id_first_msg ' . ($current_view == 'topics' ? '=' : '!=') . ' m.id_msg
			AND {query_see_board}
			' . $approve_query . '
		LIMIT {int:start}, {int:limit}', array('start' => $start, 'limit' => $limit, 'not_approved' => 0));
    $unapproved_items = array();
    for ($i = 1; $row = $db->fetch_assoc($request); $i++) {
        // Can delete is complicated, let's solve it first... is it their own post?
        if ($row['id_member'] == $user_info['id'] && ($boards_allowed['delete_own_boards'] == array(0) || in_array($row['id_board'], $boards_allowed['delete_own_boards']))) {
            $can_delete = true;
        } elseif ($row['id_member'] == $row['id_member_started'] && $row['id_msg'] != $row['id_first_msg'] && ($boards_allowed['delete_own_replies'] == array(0) || in_array($row['id_board'], $boards_allowed['delete_own_replies']))) {
            $can_delete = true;
        } elseif ($row['id_member'] != $user_info['id'] && ($boards_allowed['delete_any_boards'] == array(0) || in_array($row['id_board'], $boards_allowed['delete_any_boards']))) {
            $can_delete = true;
        } else {
            $can_delete = false;
        }
        $unapproved_items[] = array('id' => $row['id_msg'], 'alternate' => $i % 2, 'counter' => $context['start'] + $i, 'href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'], 'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>', 'subject' => $row['subject'], 'body' => parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), 'time' => standardTime($row['poster_time']), 'html_time' => htmlTime($row['poster_time']), 'timestamp' => forum_time(true, $row['poster_time']), 'poster' => array('id' => $row['id_member'], 'name' => $row['poster_name'], 'link' => $row['id_member'] ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['poster_name'] . '</a>' : $row['poster_name'], 'href' => $scripturl . '?action=profile;u=' . $row['id_member']), 'topic' => array('id' => $row['id_topic']), 'board' => array('id' => $row['id_board'], 'name' => $row['board_name'], 'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['board_name'] . '</a>'), 'category' => array('id' => $row['id_cat'], 'name' => $row['cat_name'], 'link' => '<a href="' . $scripturl . '#c' . $row['id_cat'] . '">' . $row['cat_name'] . '</a>'), 'can_delete' => $can_delete);
    }
    $db->free_result($request);
    return $unapproved_items;
}
开发者ID:KeiroD,项目名称:Elkarte,代码行数:52,代码来源:Moderation.subs.php

示例6: prepareSearchContext_callback


//.........这里部分代码省略.........
         $charLimit = 50;
         $message['body'] = strtr($message['body'], array("\n" => ' ', '<br />' => "\n"));
         $message['body'] = parse_bbc($message['body'], $message['smileys_enabled'], $message['id_msg']);
         $message['body'] = strip_tags(strtr($message['body'], array('</div>' => '<br />', '</li>' => '<br />')), '<br>');
         if (Util::strlen($message['body']) > $charLimit) {
             if (empty($context['key_words'])) {
                 $message['body'] = Util::substr($message['body'], 0, $charLimit) . '<strong>...</strong>';
             } else {
                 $matchString = '';
                 $force_partial_word = false;
                 foreach ($context['key_words'] as $keyword) {
                     $keyword = un_htmlspecialchars($keyword);
                     $keyword = preg_replace_callback('~(&amp;#(\\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'entity_fix__callback', strtr($keyword, array('\\\'' => '\'', '&' => '&amp;')));
                     if (preg_match('~[\'\\.,/@%&;:(){}\\[\\]_\\-+\\\\]$~', $keyword) != 0 || preg_match('~^[\'\\.,/@%&;:(){}\\[\\]_\\-+\\\\]~', $keyword) != 0) {
                         $force_partial_word = true;
                     }
                     $matchString .= strtr(preg_quote($keyword, '/'), array('\\*' => '.+?')) . '|';
                 }
                 $matchString = un_htmlspecialchars(substr($matchString, 0, -1));
                 $message['body'] = un_htmlspecialchars(strtr($message['body'], array('&nbsp;' => ' ', '<br />' => "\n", '&#91;' => '[', '&#93;' => ']', '&#58;' => ':', '&#64;' => '@')));
                 if (empty($modSettings['search_method']) || $force_partial_word) {
                     preg_match_all('/([^\\s\\W]{' . $charLimit . '}[\\s\\W]|[\\s\\W].{0,' . $charLimit . '}?|^)(' . $matchString . ')(.{0,' . $charLimit . '}[\\s\\W]|[^\\s\\W]{0,' . $charLimit . '})/isu', $message['body'], $matches);
                 } else {
                     preg_match_all('/([^\\s\\W]{' . $charLimit . '}[\\s\\W]|[\\s\\W].{0,' . $charLimit . '}?[\\s\\W]|^)(' . $matchString . ')([\\s\\W].{0,' . $charLimit . '}[\\s\\W]|[\\s\\W][^\\s\\W]{0,' . $charLimit . '})/isu', $message['body'], $matches);
                 }
                 $message['body'] = '';
                 foreach ($matches[0] as $index => $match) {
                     $match = strtr(htmlspecialchars($match, ENT_QUOTES, 'UTF-8'), array("\n" => '&nbsp;'));
                     $message['body'] .= '<strong>......</strong>&nbsp;' . $match . '&nbsp;<strong>......</strong>';
                 }
             }
             // Re-fix the international characters.
             $message['body'] = preg_replace_callback('~(&amp;#(\\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'entity_fix__callback', $message['body']);
         }
     } else {
         // Run BBC interpreter on the message.
         $message['body'] = parse_bbc($message['body'], $message['smileys_enabled'], $message['id_msg']);
     }
     // Make sure we don't end up with a practically empty message body.
     $message['body'] = preg_replace('~^(?:&nbsp;)+$~', '', $message['body']);
     // Sadly, we need to check that the icon is not broken.
     if (!empty($modSettings['messageIconChecks_enable'])) {
         if (!isset($context['icon_sources'][$message['first_icon']])) {
             $context['icon_sources'][$message['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['first_icon'] . '.png') ? 'images_url' : 'default_images_url';
         }
         if (!isset($context['icon_sources'][$message['last_icon']])) {
             $context['icon_sources'][$message['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['last_icon'] . '.png') ? 'images_url' : 'default_images_url';
         }
         if (!isset($context['icon_sources'][$message['icon']])) {
             $context['icon_sources'][$message['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $message['icon'] . '.png') ? 'images_url' : 'default_images_url';
         }
     } else {
         if (!isset($context['icon_sources'][$message['first_icon']])) {
             $context['icon_sources'][$message['first_icon']] = 'images_url';
         }
         if (!isset($context['icon_sources'][$message['last_icon']])) {
             $context['icon_sources'][$message['last_icon']] = 'images_url';
         }
         if (!isset($context['icon_sources'][$message['icon']])) {
             $context['icon_sources'][$message['icon']] = 'images_url';
         }
     }
     // Do we have quote tag enabled?
     $quote_enabled = empty($modSettings['disabledBBC']) || !in_array('quote', explode(',', $modSettings['disabledBBC']));
     $output = array_merge($context['topics'][$message['id_msg']], array('id' => $message['id_topic'], 'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($message['is_sticky']), 'is_locked' => !empty($message['locked']), 'is_poll' => !empty($modSettings['pollMode']) && $message['id_poll'] > 0, 'is_hot' => !empty($modSettings['useLikesNotViews']) ? $message['num_likes'] >= $modSettings['hotTopicPosts'] : $message['num_replies'] >= $modSettings['hotTopicPosts'], 'is_very_hot' => !empty($modSettings['useLikesNotViews']) ? $message['num_likes'] >= $modSettings['hotTopicVeryPosts'] : $message['num_replies'] >= $modSettings['hotTopicVeryPosts'], 'posted_in' => !empty($participants[$message['id_topic']]), 'views' => $message['num_views'], 'replies' => $message['num_replies'], 'tests' => array('can_reply' => in_array($message['id_board'], $boards_can['post_reply_any']) || in_array(0, $boards_can['post_reply_any']), 'can_quote' => (in_array($message['id_board'], $boards_can['post_reply_any']) || in_array(0, $boards_can['post_reply_any'])) && $quote_enabled, 'can_mark_notify' => in_array($message['id_board'], $boards_can['mark_any_notify']) || in_array(0, $boards_can['mark_any_notify']) && !$context['user']['is_guest']), 'first_post' => array('id' => $message['first_msg'], 'time' => standardTime($message['first_poster_time']), 'html_time' => htmlTime($message['first_poster_time']), 'timestamp' => forum_time(true, $message['first_poster_time']), 'subject' => $message['first_subject'], 'href' => $scripturl . '?topic=' . $message['id_topic'] . '.0', 'link' => '<a href="' . $scripturl . '?topic=' . $message['id_topic'] . '.0">' . $message['first_subject'] . '</a>', 'icon' => $message['first_icon'], 'icon_url' => $settings[$context['icon_sources'][$message['first_icon']]] . '/post/' . $message['first_icon'] . '.png', 'member' => array('id' => $message['first_member_id'], 'name' => $message['first_member_name'], 'href' => !empty($message['first_member_id']) ? $scripturl . '?action=profile;u=' . $message['first_member_id'] : '', 'link' => !empty($message['first_member_id']) ? '<a href="' . $scripturl . '?action=profile;u=' . $message['first_member_id'] . '" title="' . $txt['profile_of'] . ' ' . $message['first_member_name'] . '">' . $message['first_member_name'] . '</a>' : $message['first_member_name'])), 'last_post' => array('id' => $message['last_msg'], 'time' => standardTime($message['last_poster_time']), 'html_time' => htmlTime($message['last_poster_time']), 'timestamp' => forum_time(true, $message['last_poster_time']), 'subject' => $message['last_subject'], 'href' => $scripturl . '?topic=' . $message['id_topic'] . ($message['num_replies'] == 0 ? '.0' : '.msg' . $message['last_msg']) . '#msg' . $message['last_msg'], 'link' => '<a href="' . $scripturl . '?topic=' . $message['id_topic'] . ($message['num_replies'] == 0 ? '.0' : '.msg' . $message['last_msg']) . '#msg' . $message['last_msg'] . '">' . $message['last_subject'] . '</a>', 'icon' => $message['last_icon'], 'icon_url' => $settings[$context['icon_sources'][$message['last_icon']]] . '/post/' . $message['last_icon'] . '.png', 'member' => array('id' => $message['last_member_id'], 'name' => $message['last_member_name'], 'href' => !empty($message['last_member_id']) ? $scripturl . '?action=profile;u=' . $message['last_member_id'] : '', 'link' => !empty($message['last_member_id']) ? '<a href="' . $scripturl . '?action=profile;u=' . $message['last_member_id'] . '" title="' . $txt['profile_of'] . ' ' . $message['last_member_name'] . '">' . $message['last_member_name'] . '</a>' : $message['last_member_name'])), 'board' => array('id' => $message['id_board'], 'name' => $message['board_name'], 'href' => $scripturl . '?board=' . $message['id_board'] . '.0', 'link' => '<a href="' . $scripturl . '?board=' . $message['id_board'] . '.0">' . $message['board_name'] . '</a>'), 'category' => array('id' => $message['id_cat'], 'name' => $message['cat_name'], 'href' => $scripturl . '#c' . $message['id_cat'], 'link' => '<a href="' . $scripturl . '#c' . $message['id_cat'] . '">' . $message['cat_name'] . '</a>')));
     determineTopicClass($output);
     if ($output['posted_in']) {
         $output['class'] = 'my_' . $output['class'];
     }
     $body_highlighted = $message['body'];
     $subject_highlighted = $message['subject'];
     if (!empty($options['display_quick_mod'])) {
         $started = $output['first_post']['member']['id'] == $user_info['id'];
         $output['quick_mod'] = array('lock' => in_array(0, $boards_can['lock_any']) || in_array($output['board']['id'], $boards_can['lock_any']) || $started && (in_array(0, $boards_can['lock_own']) || in_array($output['board']['id'], $boards_can['lock_own'])), 'sticky' => (in_array(0, $boards_can['make_sticky']) || in_array($output['board']['id'], $boards_can['make_sticky'])) && !empty($modSettings['enableStickyTopics']), 'move' => in_array(0, $boards_can['move_any']) || in_array($output['board']['id'], $boards_can['move_any']) || $started && (in_array(0, $boards_can['move_own']) || in_array($output['board']['id'], $boards_can['move_own'])), 'remove' => in_array(0, $boards_can['remove_any']) || in_array($output['board']['id'], $boards_can['remove_any']) || $started && (in_array(0, $boards_can['remove_own']) || in_array($output['board']['id'], $boards_can['remove_own'])));
         $context['can_lock'] |= $output['quick_mod']['lock'];
         $context['can_sticky'] |= $output['quick_mod']['sticky'];
         $context['can_move'] |= $output['quick_mod']['move'];
         $context['can_remove'] |= $output['quick_mod']['remove'];
         $context['can_merge'] |= in_array($output['board']['id'], $boards_can['merge_any']);
         $context['can_markread'] = $context['user']['is_logged'];
         $context['qmod_actions'] = array('remove', 'lock', 'sticky', 'move', 'markread');
         call_integration_hook('integrate_quick_mod_actions_search');
     }
     foreach ($context['key_words'] as $query) {
         // Fix the international characters in the keyword too.
         $query = un_htmlspecialchars($query);
         $query = trim($query, '\\*+');
         $query = strtr(Util::htmlspecialchars($query), array('\\\'' => '\''));
         $body_highlighted = preg_replace_callback('/((<[^>]*)|' . preg_quote(strtr($query, array('\'' => '&#039;')), '/') . ')/iu', array($this, '_highlighted_callback'), $body_highlighted);
         $subject_highlighted = preg_replace('/(' . preg_quote($query, '/') . ')/iu', '<strong class="highlight">$1</strong>', $subject_highlighted);
     }
     require_once SUBSDIR . '/Attachments.subs.php';
     $output['matches'][] = array('id' => $message['id_msg'], 'attachment' => loadAttachmentContext($message['id_msg']), 'alternate' => $counter % 2, 'member' => &$memberContext[$message['id_member']], 'icon' => $message['icon'], 'icon_url' => $settings[$context['icon_sources'][$message['icon']]] . '/post/' . $message['icon'] . '.png', 'subject' => $message['subject'], 'subject_highlighted' => $subject_highlighted, 'time' => standardTime($message['poster_time']), 'html_time' => htmlTime($message['poster_time']), 'timestamp' => forum_time(true, $message['poster_time']), 'counter' => $counter, 'modified' => array('time' => standardTime($message['modified_time']), 'html_time' => htmlTime($message['modified_time']), 'timestamp' => forum_time(true, $message['modified_time']), 'name' => $message['modified_name']), 'body' => $message['body'], 'body_highlighted' => $body_highlighted, 'start' => 'msg' . $message['id_msg']);
     $counter++;
     if (!$context['compact']) {
         $output['buttons'] = array('notify' => array('href' => $scripturl . '?action=notify;topic=' . $output['id'] . '.msg' . $message['id_msg'], 'text' => $txt['notify'], 'test' => 'can_mark_notify'), 'reply' => array('href' => $scripturl . '?action=post;topic=' . $output['id'] . '.msg' . $message['id_msg'], 'text' => $txt['reply'], 'test' => 'can_reply'), 'quote' => array('href' => $scripturl . '?action=post;topic=' . $output['id'] . '.msg' . $message['id_msg'] . ';quote=' . $message['id_msg'], 'text' => $txt['quote'], 'test' => 'can_quote'));
     }
     call_integration_hook('integrate_search_message_context', array($counter, &$output));
     return $output;
 }
开发者ID:scripple,项目名称:Elkarte,代码行数:101,代码来源:Search.controller.php

示例7: list_getModLogEntries


//.........这里部分代码省略.........
        }
        // A message?
        if (isset($row['extra']['message'])) {
            $messages[(int) $row['extra']['message']][] = $row['id_action'];
        }
        // IP Info?
        if (isset($row['extra']['ip_range'])) {
            if ($seeIP) {
                $row['extra']['ip_range'] = '<a href="' . $scripturl . '?action=trackip;searchip=' . $row['extra']['ip_range'] . '">' . $row['extra']['ip_range'] . '</a>';
            } else {
                $row['extra']['ip_range'] = $txt['logged'];
            }
        }
        // Email?
        if (isset($row['extra']['email'])) {
            $row['extra']['email'] = '<a href="mailto:' . $row['extra']['email'] . '">' . $row['extra']['email'] . '</a>';
        }
        // Bans are complex.
        if ($row['action'] == 'ban') {
            if (!isset($row['extra']['new']) || $row['extra']['new'] == 1) {
                $row['action_text'] = $txt['modlog_ac_ban'];
            } elseif ($row['extra']['new'] == 0) {
                $row['action_text'] = $txt['modlog_ac_ban_update'];
            } else {
                $row['action_text'] = $txt['modlog_ac_ban_remove'];
            }
            foreach (array('member', 'email', 'ip_range', 'hostname') as $type) {
                if (isset($row['extra'][$type])) {
                    $row['action_text'] .= $txt['modlog_ac_ban_trigger_' . $type];
                }
            }
        }
        // The array to go to the template. Note here that action is set to a "default" value of the action doesn't match anything in the descriptions. Allows easy adding of logging events with basic details.
        $entries[$row['id_action']] = array('id' => $row['id_action'], 'ip' => $seeIP ? $row['ip'] : $txt['logged'], 'position' => empty($row['real_name']) && empty($row['group_name']) ? $txt['guest'] : $row['group_name'], 'moderator_link' => $row['id_member'] ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>' : (empty($row['real_name']) ? $txt['guest'] . (!empty($row['extra']['member_acted']) ? ' (' . $row['extra']['member_acted'] . ')' : '') : $row['real_name']), 'time' => standardTime($row['log_time']), 'html_time' => htmlTime($row['log_time']), 'timestamp' => forum_time(true, $row['log_time']), 'editable' => time() > $row['log_time'] + $context['hoursdisable'] * 3600, 'extra' => $row['extra'], 'action' => $row['action'], 'action_text' => isset($row['action_text']) ? $row['action_text'] : '');
    }
    $db->free_result($result);
    if (!empty($boards)) {
        require_once SUBSDIR . '/Boards.subs.php';
        $boards_info = fetchBoardsInfo(array('boards' => array_keys($boards)));
        foreach ($boards_info as $row) {
            foreach ($boards[$row['id_board']] as $action) {
                // Make the board number into a link - dealing with moving too.
                if (isset($entries[$action]['extra']['board_to']) && $entries[$action]['extra']['board_to'] == $row['id_board']) {
                    $entries[$action]['extra']['board_to'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
                } elseif (isset($entries[$action]['extra']['board_from']) && $entries[$action]['extra']['board_from'] == $row['id_board']) {
                    $entries[$action]['extra']['board_from'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
                } elseif (isset($entries[$action]['extra']['board']) && $entries[$action]['extra']['board'] == $row['id_board']) {
                    $entries[$action]['extra']['board'] = '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['name'] . '</a>';
                }
            }
        }
    }
    if (!empty($topics)) {
        $request = $db->query('', '
			SELECT ms.subject, t.id_topic
			FROM {db_prefix}topics AS t
				INNER JOIN {db_prefix}messages AS ms ON (ms.id_msg = t.id_first_msg)
			WHERE t.id_topic IN ({array_int:topic_list})
			LIMIT ' . count(array_keys($topics)), array('topic_list' => array_keys($topics)));
        while ($row = $db->fetch_assoc($request)) {
            foreach ($topics[$row['id_topic']] as $action) {
                $this_action =& $entries[$action];
                // This isn't used in the current theme.
                $this_action['topic'] = array('id' => $row['id_topic'], 'subject' => $row['subject'], 'href' => $scripturl . '?topic=' . $row['id_topic'] . '.0', 'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>');
                // Make the topic number into a link - dealing with splitting too.
                if (isset($this_action['extra']['topic']) && $this_action['extra']['topic'] == $row['id_topic']) {
开发者ID:KeiroD,项目名称:Elkarte,代码行数:67,代码来源:Modlog.subs.php

示例8: action_unread


//.........这里部分代码省略.........
				WHERE t.id_topic IN ({array_int:topic_list})
				ORDER BY ' . $_REQUEST['sort'] . ($ascending ? '' : ' DESC') . '
				LIMIT ' . count($topics), array('current_member' => $user_info['id'], 'topic_list' => $topics));
        }
        $context['topics'] = array();
        $topic_ids = array();
        while ($row = $db->fetch_assoc($request)) {
            $topic_ids[] = $row['id_topic'];
            if (!empty($modSettings['message_index_preview'])) {
                // Limit them to 128 characters - do this FIRST because it's a lot of wasted censoring otherwise.
                $row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], false, $row['id_first_msg']), array('<br />' => "\n", '&nbsp;' => ' ')));
                $row['first_body'] = Util::shorten_text($row['first_body'], !empty($modSettings['preview_characters']) ? $modSettings['preview_characters'] : 128, true);
                // No reply then they are the same, no need to process it again
                if ($row['num_replies'] == 0) {
                    $row['last_body'] == $row['first_body'];
                } else {
                    $row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], false, $row['id_last_msg']), array('<br />' => "\n", '&nbsp;' => ' ')));
                    $row['last_body'] = Util::shorten_text($row['last_body'], !empty($modSettings['preview_characters']) ? $modSettings['preview_characters'] : 128, true);
                }
                // Censor the subject and message preview.
                censorText($row['first_subject']);
                censorText($row['first_body']);
                // Don't censor them twice!
                if ($row['id_first_msg'] == $row['id_last_msg']) {
                    $row['last_subject'] = $row['first_subject'];
                    $row['last_body'] = $row['first_body'];
                } else {
                    censorText($row['last_subject']);
                    censorText($row['last_body']);
                }
            } else {
                $row['first_body'] = '';
                $row['last_body'] = '';
                censorText($row['first_subject']);
                if ($row['id_first_msg'] == $row['id_last_msg']) {
                    $row['last_subject'] = $row['first_subject'];
                } else {
                    censorText($row['last_subject']);
                }
            }
            // Decide how many pages the topic should have.
            $topic_length = $row['num_replies'] + 1;
            $messages_per_page = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages'];
            if ($topic_length > $messages_per_page) {
                $start = -1;
                $pages = constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d;topicseen', $start, $topic_length, $messages_per_page, true, array('prev_next' => false, 'all' => !empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages']));
            } else {
                $pages = '';
            }
            // We need to check the topic icons exist... you can never be too sure!
            if (!empty($modSettings['messageIconChecks_enable'])) {
                // First icon first... as you'd expect.
                if (!isset($context['icon_sources'][$row['first_icon']])) {
                    $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url';
                }
                // Last icon... last... duh.
                if (!isset($context['icon_sources'][$row['last_icon']])) {
                    $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url';
                }
            }
            // And build the array.
            $context['topics'][$row['id_topic']] = array('id' => $row['id_topic'], 'first_post' => array('id' => $row['id_first_msg'], 'member' => array('name' => $row['first_poster_name'], 'id' => $row['id_first_member'], 'href' => $scripturl . '?action=profile;u=' . $row['id_first_member'], 'link' => !empty($row['id_first_member']) ? '<a class="preview" href="' . $scripturl . '?action=profile;u=' . $row['id_first_member'] . '" title="' . $txt['profile_of'] . ' ' . $row['first_poster_name'] . '">' . $row['first_poster_name'] . '</a>' : $row['first_poster_name']), 'time' => standardTime($row['first_poster_time']), 'html_time' => htmlTime($row['first_poster_time']), 'timestamp' => forum_time(true, $row['first_poster_time']), 'subject' => $row['first_subject'], 'preview' => $row['first_body'], 'icon' => $row['first_icon'], 'icon_url' => $settings[$context['icon_sources'][$row['first_icon']]] . '/post/' . $row['first_icon'] . '.png', 'href' => $scripturl . '?topic=' . $row['id_topic'] . '.0;topicseen', 'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0;topicseen">' . $row['first_subject'] . '</a>'), 'last_post' => array('id' => $row['id_last_msg'], 'member' => array('name' => $row['last_poster_name'], 'id' => $row['id_last_member'], 'href' => $scripturl . '?action=profile;u=' . $row['id_last_member'], 'link' => !empty($row['id_last_member']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_last_member'] . '">' . $row['last_poster_name'] . '</a>' : $row['last_poster_name']), 'time' => standardTime($row['last_poster_time']), 'html_time' => htmlTime($row['last_poster_time']), 'timestamp' => forum_time(true, $row['last_poster_time']), 'subject' => $row['last_subject'], 'preview' => $row['last_body'], 'icon' => $row['last_icon'], 'icon_url' => $settings[$context['icon_sources'][$row['last_icon']]] . '/post/' . $row['last_icon'] . '.png', 'href' => $scripturl . '?topic=' . $row['id_topic'] . ($row['num_replies'] == 0 ? '.0' : '.msg' . $row['id_last_msg']) . ';topicseen#msg' . $row['id_last_msg'], 'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . ($row['num_replies'] == 0 ? '.0' : '.msg' . $row['id_last_msg']) . ';topicseen#msg' . $row['id_last_msg'] . '" rel="nofollow">' . $row['last_subject'] . '</a>'), 'default_preview' => trim($row[!empty($modSettings['message_index_preview']) && $modSettings['message_index_preview'] == 2 ? 'last_body' : 'first_body']), 'new_from' => $row['new_from'], 'new_href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['new_from'] . ';topicseen#new', 'href' => $scripturl . '?topic=' . $row['id_topic'] . ($row['num_replies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen' . ($row['num_replies'] == 0 ? '' : 'new'), 'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . ($row['num_replies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen#msg' . $row['new_from'] . '" rel="nofollow">' . $row['first_subject'] . '</a>', 'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($row['is_sticky']), 'is_locked' => !empty($row['locked']), 'is_poll' => !empty($modSettings['pollMode']) && $row['id_poll'] > 0, 'is_hot' => !empty($modSettings['useLikesNotViews']) ? $row['num_likes'] >= $modSettings['hotTopicPosts'] : $row['num_replies'] >= $modSettings['hotTopicPosts'], 'is_very_hot' => !empty($modSettings['useLikesNotViews']) ? $row['num_likes'] >= $modSettings['hotTopicVeryPosts'] : $row['num_replies'] >= $modSettings['hotTopicVeryPosts'], 'is_posted_in' => false, 'icon' => $row['first_icon'], 'icon_url' => $settings[$context['icon_sources'][$row['first_icon']]] . '/post/' . $row['first_icon'] . '.png', 'subject' => $row['first_subject'], 'pages' => $pages, 'replies' => comma_format($row['num_replies']), 'views' => comma_format($row['num_views']), 'likes' => comma_format($row['num_likes']), 'board' => array('id' => $row['id_board'], 'name' => $row['bname'], 'href' => $scripturl . '?board=' . $row['id_board'] . '.0', 'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['bname'] . '</a>'));
            $context['topics'][$row['id_topic']]['first_post']['started_by'] = sprintf($txt['topic_started_by_in'], '<strong>' . $context['topics'][$row['id_topic']]['first_post']['member']['link'] . '</strong>', '<em>' . $context['topics'][$row['id_topic']]['board']['link'] . '</em>');
            determineTopicClass($context['topics'][$row['id_topic']]);
        }
        $db->free_result($request);
        if ($is_topics && !empty($modSettings['enableParticipation']) && !empty($topic_ids)) {
            require_once SUBSDIR . '/MessageIndex.subs.php';
            $topics_participated_in = topicsParticipation($user_info['id'], $topic_ids);
            foreach ($topics_participated_in as $topic) {
                if (empty($context['topics'][$topic['id_topic']]['is_posted_in'])) {
                    $context['topics'][$topic['id_topic']]['is_posted_in'] = true;
                    $context['topics'][$topic['id_topic']]['class'] = 'my_' . $context['topics'][$topic['id_topic']]['class'];
                }
            }
        }
        $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']);
        $context['topics_to_mark'] = implode('-', $topic_ids);
        if ($settings['show_mark_read']) {
            // Build the recent button array.
            if ($is_topics) {
                $context['recent_buttons'] = array('markread' => array('text' => !empty($context['no_board_limits']) ? 'mark_as_read' : 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'custom' => 'onclick="return markunreadButton(this);"', 'url' => $scripturl . '?action=markasread;sa=' . (!empty($context['no_board_limits']) ? 'all' : 'board' . $context['querystring_board_limits']) . ';' . $context['session_var'] . '=' . $context['session_id']));
                if ($context['showCheckboxes']) {
                    $context['recent_buttons']['markselectread'] = array('text' => 'quick_mod_markread', 'image' => 'markselectedread.png', 'lang' => true, 'url' => 'javascript:document.quickModForm.submit();');
                }
                if (!empty($context['topics']) && !$context['showing_all_topics']) {
                    $context['recent_buttons']['readall'] = array('text' => 'unread_topics_all', 'image' => 'markreadall.png', 'lang' => true, 'url' => $scripturl . '?action=unread;all' . $context['querystring_board_limits'], 'active' => true);
                }
            } elseif (!$is_topics && isset($context['topics_to_mark'])) {
                $context['recent_buttons'] = array('markread' => array('text' => 'mark_as_read', 'image' => 'markread.png', 'lang' => true, 'url' => $scripturl . '?action=markasread;sa=unreadreplies;topics=' . $context['topics_to_mark'] . ';' . $context['session_var'] . '=' . $context['session_id']));
                if ($context['showCheckboxes']) {
                    $context['recent_buttons']['markselectread'] = array('text' => 'quick_mod_markread', 'image' => 'markselectedread.png', 'lang' => true, 'url' => 'javascript:document.quickModForm.submit();');
                }
            }
            // Allow mods to add additional buttons here
            call_integration_hook('integrate_recent_buttons');
        }
        // Allow helpdesks and bug trackers and what not to add their own unread data (just add a template_layer to show custom stuff in the template!)
        call_integration_hook('integrate_unread_list');
    }
开发者ID:scripple,项目名称:Elkarte,代码行数:101,代码来源:Recent.controller.php

示例9: ssi_recentAttachments

/**
 * We want to show the recent attachments outside of the forum.
 *
 * @param int $num_attachments = 10
 * @param string[] $attachment_ext = array()
 * @param string $output_method = 'echo'
 */
function ssi_recentAttachments($num_attachments = 10, $attachment_ext = array(), $output_method = 'echo')
{
    global $modSettings, $scripturl, $txt, $settings;
    // We want to make sure that we only get attachments for boards that we can see *if* any.
    $attachments_boards = boardsAllowedTo('view_attachments');
    // No boards?  Adios amigo.
    if (empty($attachments_boards)) {
        return array();
    }
    $db = database();
    // Is it an array?
    if (!is_array($attachment_ext)) {
        $attachment_ext = array($attachment_ext);
    }
    // Lets build the query.
    $request = $db->query('', '
		SELECT
			att.id_attach, att.id_msg, att.filename, IFNULL(att.size, 0) AS filesize, att.downloads, mem.id_member,
			IFNULL(mem.real_name, m.poster_name) AS poster_name, m.id_topic, m.subject, t.id_board, m.poster_time,
			att.width, att.height' . (empty($modSettings['attachmentShowImages']) || empty($modSettings['attachmentThumbnails']) ? '' : ', IFNULL(thumb.id_attach, 0) AS id_thumb, thumb.width AS thumb_width, thumb.height AS thumb_height') . '
		FROM {db_prefix}attachments AS att
			INNER JOIN {db_prefix}messages AS m ON (m.id_msg = att.id_msg)
			INNER JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic)
			LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)' . (empty($modSettings['attachmentShowImages']) || empty($modSettings['attachmentThumbnails']) ? '' : '
			LEFT JOIN {db_prefix}attachments AS thumb ON (thumb.id_attach = att.id_thumb)') . '
		WHERE att.attachment_type = 0' . ($attachments_boards === array(0) ? '' : '
			AND m.id_board IN ({array_int:boards_can_see})') . (!empty($attachment_ext) ? '
			AND att.fileext IN ({array_string:attachment_ext})' : '') . (!$modSettings['postmod_active'] || allowedTo('approve_posts') ? '' : '
			AND t.approved = {int:is_approved}
			AND m.approved = {int:is_approved}
			AND att.approved = {int:is_approved}') . '
		ORDER BY att.id_attach DESC
		LIMIT {int:num_attachments}', array('boards_can_see' => $attachments_boards, 'attachment_ext' => $attachment_ext, 'num_attachments' => $num_attachments, 'is_approved' => 1));
    // We have something.
    $attachments = array();
    while ($row = $db->fetch_assoc($request)) {
        $filename = preg_replace('~&amp;#(\\d{1,7}|x[0-9a-fA-F]{1,6});~', '&#\\1;', htmlspecialchars($row['filename'], ENT_COMPAT, 'UTF-8'));
        // Is it an image?
        $attachments[$row['id_attach']] = array('member' => array('id' => $row['id_member'], 'name' => $row['poster_name'], 'link' => empty($row['id_member']) ? $row['poster_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['poster_name'] . '</a>'), 'file' => array('filename' => $filename, 'filesize' => round($row['filesize'] / 1024, 2) . $txt['kilobyte'], 'downloads' => $row['downloads'], 'href' => $scripturl . '?action=dlattach;topic=' . $row['id_topic'] . '.0;attach=' . $row['id_attach'], 'link' => '<img src="' . $settings['images_url'] . '/icons/clip.png" alt="" /> <a href="' . $scripturl . '?action=dlattach;topic=' . $row['id_topic'] . '.0;attach=' . $row['id_attach'] . '">' . $filename . '</a>', 'is_image' => !empty($row['width']) && !empty($row['height']) && !empty($modSettings['attachmentShowImages'])), 'topic' => array('id' => $row['id_topic'], 'subject' => $row['subject'], 'href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'], 'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '">' . $row['subject'] . '</a>', 'time' => standardTime($row['poster_time']), 'html_time' => htmlTime($row['poster_time']), 'timestamp' => forum_time(true, $row['poster_time'])));
        // Images.
        if ($attachments[$row['id_attach']]['file']['is_image']) {
            $id_thumb = empty($row['id_thumb']) ? $row['id_attach'] : $row['id_thumb'];
            $attachments[$row['id_attach']]['file']['image'] = array('id' => $id_thumb, 'width' => $row['width'], 'height' => $row['height'], 'img' => '<img src="' . $scripturl . '?action=dlattach;topic=' . $row['id_topic'] . '.0;attach=' . $row['id_attach'] . ';image" alt="' . $filename . '" />', 'thumb' => '<img src="' . $scripturl . '?action=dlattach;topic=' . $row['id_topic'] . '.0;attach=' . $id_thumb . ';image" alt="' . $filename . '" />', 'href' => $scripturl . '?action=dlattach;topic=' . $row['id_topic'] . '.0;attach=' . $id_thumb . ';image', 'link' => '<a href="' . $scripturl . '?action=dlattach;topic=' . $row['id_topic'] . '.0;attach=' . $row['id_attach'] . ';image"><img src="' . $scripturl . '?action=dlattach;topic=' . $row['id_topic'] . '.0;attach=' . $id_thumb . ';image" alt="' . $filename . '" /></a>');
        }
    }
    $db->free_result($request);
    // So you just want an array?  Here you can have it.
    if ($output_method == 'array' || empty($attachments)) {
        return $attachments;
    }
    // Give them the default.
    echo '
		<table class="ssi_downloads" cellpadding="2">
			<tr>
				<th align="left">', $txt['file'], '</th>
				<th align="left">', $txt['posted_by'], '</th>
				<th align="left">', $txt['downloads'], '</th>
				<th align="left">', $txt['filesize'], '</th>
			</tr>';
    foreach ($attachments as $attach) {
        echo '
			<tr>
				<td>', $attach['file']['link'], '</td>
				<td>', $attach['member']['link'], '</td>
				<td align="center">', $attach['file']['downloads'], '</td>
				<td>', $attach['file']['filesize'], '</td>
			</tr>';
    }
    echo '
		</table>';
}
开发者ID:scripple,项目名称:Elkarte,代码行数:78,代码来源:SSI.php

示例10: action_showPMDrafts

 /**
  * Show all PM drafts of the current user
  * Uses the showpmdraft template
  * Allows for the deleting and loading/editing of PM drafts
  */
 public function action_showPMDrafts()
 {
     global $txt, $user_info, $scripturl, $modSettings, $context;
     require_once SUBSDIR . '/Profile.subs.php';
     require_once SUBSDIR . '/Drafts.subs.php';
     $memID = currentMemberID();
     // Quick check how we got here.
     if ($memID != $user_info['id']) {
         // empty($modSettings['drafts_enabled']) || empty($modSettings['drafts_pm_enabled']))
         fatal_lang_error('no_access', false);
     }
     // Set up what we will need
     $context['start'] = isset($_REQUEST['start']) ? (int) $_REQUEST['start'] : 0;
     // If just deleting a draft, do it and then redirect back.
     if (!empty($_REQUEST['delete'])) {
         checkSession('get');
         $id_delete = (int) $_REQUEST['delete'];
         deleteDrafts($id_delete, $memID);
         redirectexit('action=pm;sa=showpmdrafts;start=' . $context['start']);
     }
     // Perhaps a draft was selected for editing? if so pass this off
     if (!empty($_REQUEST['id_draft']) && !empty($context['drafts_pm_save'])) {
         checkSession('get');
         $id_draft = (int) $_REQUEST['id_draft'];
         redirectexit('action=pm;sa=send;id_draft=' . $id_draft);
     }
     // Init
     $maxIndex = (int) $modSettings['defaultMaxMessages'];
     // Default to 10.
     if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount'])) {
         $_REQUEST['viewscount'] = 10;
     }
     // Get the count of applicable drafts
     $msgCount = draftsCount($memID, 1);
     // Make sure the starting place makes sense and construct our friend the page index.
     $context['page_index'] = constructPageIndex($scripturl . '?action=pm;sa=showpmdrafts', $context['start'], $msgCount, $maxIndex);
     $context['current_page'] = $context['start'] / $maxIndex;
     // Reverse the query if we're past 50% of the total for better performance.
     $start = $context['start'];
     $reverse = $start > $msgCount / 2;
     if ($reverse) {
         $maxIndex = $msgCount < $context['start'] + $modSettings['defaultMaxMessages'] + 1 && $msgCount > $context['start'] ? $msgCount - $context['start'] : (int) $modSettings['defaultMaxMessages'];
         $start = $msgCount < $context['start'] + $modSettings['defaultMaxMessages'] + 1 || $msgCount < $context['start'] + $modSettings['defaultMaxMessages'] ? 0 : $msgCount - $context['start'] - $modSettings['defaultMaxMessages'];
     }
     // Go get em'
     $order = 'ud.poster_time ' . ($reverse ? 'ASC' : 'DESC');
     $limit = $start . ', ' . $maxIndex;
     $user_drafts = load_user_drafts($memID, 1, false, $order, $limit);
     // Start counting at the number of the first message displayed.
     $counter = $reverse ? $context['start'] + $maxIndex + 1 : $context['start'];
     $context['posts'] = array();
     foreach ($user_drafts as $row) {
         // Censor....
         if (empty($row['body'])) {
             $row['body'] = '';
         }
         $row['subject'] = Util::htmltrim($row['subject']);
         if (empty($row['subject'])) {
             $row['subject'] = $txt['no_subject'];
         }
         censorText($row['body']);
         censorText($row['subject']);
         // BBC-ilize the message.
         $row['body'] = parse_bbc($row['body'], true, 'draft' . $row['id_draft']);
         // Have they provided who this will go to?
         $recipients = array('to' => array(), 'bcc' => array());
         $recipient_ids = !empty($row['to_list']) ? unserialize($row['to_list']) : array();
         // Get nice names to show the user, the id's are not that great to see!
         if (!empty($recipient_ids['to']) || !empty($recipient_ids['bcc'])) {
             $recipient_ids['to'] = array_map('intval', $recipient_ids['to']);
             $recipient_ids['bcc'] = array_map('intval', $recipient_ids['bcc']);
             $allRecipients = array_merge($recipient_ids['to'], $recipient_ids['bcc']);
             $recipients = draftsRecipients($allRecipients, $recipient_ids);
         }
         // Add the items to the array for template use
         $context['drafts'][$counter += $reverse ? -1 : 1] = array('body' => $row['body'], 'counter' => $counter, 'alternate' => $counter % 2, 'subject' => $row['subject'], 'time' => standardTime($row['poster_time']), 'html_time' => htmlTime($row['poster_time']), 'timestamp' => forum_time(true, $row['poster_time']), 'id_draft' => $row['id_draft'], 'recipients' => $recipients, 'age' => floor((time() - $row['poster_time']) / 86400), 'remaining' => !empty($modSettings['drafts_keep_days']) ? floor($modSettings['drafts_keep_days'] - (time() - $row['poster_time']) / 86400) : 0);
     }
     // If the drafts were retrieved in reverse order, then put them in the right order again.
     if ($reverse) {
         $context['drafts'] = array_reverse($context['drafts'], true);
     }
     // Off to the template we go
     $context['page_title'] = $txt['drafts'];
     $context['sub_template'] = 'showPMDrafts';
     $context['linktree'][] = array('url' => $scripturl . '?action=pm;sa=showpmdrafts', 'name' => $txt['drafts']);
 }
开发者ID:KeiroD,项目名称:Elkarte,代码行数:91,代码来源:Draft.controller.php

示例11: block_notes

 /**
  * Show an area for the moderator to type into.
  */
 public function block_notes()
 {
     global $context, $scripturl, $txt, $user_info;
     // Are we saving a note?
     if (isset($_POST['makenote']) && isset($_POST['new_note'])) {
         checkSession();
         $new_note = Util::htmlspecialchars(trim($_POST['new_note']));
         // Make sure they actually entered something.
         if (!empty($new_note) && $new_note !== $txt['mc_click_add_note']) {
             // Insert it into the database then!
             addModeratorNote($user_info['id'], $user_info['name'], $new_note);
             // Clear the cache.
             cache_put_data('moderator_notes', null, 240);
             cache_put_data('moderator_notes_total', null, 240);
         }
         // Redirect otherwise people can resubmit.
         redirectexit('action=moderate');
     }
     // Bye... bye...
     if (isset($_GET['notes']) && isset($_GET['delete']) && is_numeric($_GET['delete'])) {
         checkSession('get');
         // Just checkin'!
         $id_delete = (int) $_GET['delete'];
         // Lets delete it.
         removeModeratorNote($id_delete);
         // Clear the cache.
         cache_put_data('moderator_notes', null, 240);
         cache_put_data('moderator_notes_total', null, 240);
         redirectexit('action=moderate');
     }
     // How many notes in total?
     $moderator_notes_total = countModeratorNotes();
     // Grab the current notes. We can only use the cache for the first page of notes.
     $offset = isset($_GET['notes']) && isset($_GET['start']) ? $_GET['start'] : 0;
     $moderator_notes = moderatorNotes($offset);
     // Lets construct a page index.
     $context['page_index'] = constructPageIndex($scripturl . '?action=moderate;area=index;notes', $_GET['start'], $moderator_notes_total, 10);
     $context['start'] = $_GET['start'];
     $context['notes'] = array();
     foreach ($moderator_notes as $note) {
         $context['notes'][] = array('author' => array('id' => $note['id_member'], 'link' => $note['id_member'] ? '<a href="' . $scripturl . '?action=profile;u=' . $note['id_member'] . '" title="' . $txt['on'] . ' ' . strip_tags(standardTime($note['log_time'])) . '">' . $note['member_name'] . '</a>' : $note['member_name']), 'time' => standardTime($note['log_time']), 'html_time' => htmlTime($note['log_time']), 'timestamp' => forum_time(true, $note['log_time']), 'text' => parse_bbc($note['body']), 'delete_href' => $scripturl . '?action=moderate;area=index;notes;delete=' . $note['id_note'] . ';' . $context['session_var'] . '=' . $context['session_id']);
     }
     return 'notes';
 }
开发者ID:KeiroD,项目名称:Elkarte,代码行数:47,代码来源:ModerationCenter.controller.php

示例12: action_jsmodify


//.........这里部分代码省略.........
            $moderationAction = $row['id_member'] != $user_info['id'];
        }
        $post_errors = Error_Context::context('post', 1);
        if (isset($_POST['subject']) && Util::htmltrim(Util::htmlspecialchars($_POST['subject'])) !== '') {
            $_POST['subject'] = strtr(Util::htmlspecialchars($_POST['subject']), array("\r" => '', "\n" => '', "\t" => ''));
            // Maximum number of characters.
            if (Util::strlen($_POST['subject']) > 100) {
                $_POST['subject'] = Util::substr($_POST['subject'], 0, 100);
            }
        } elseif (isset($_POST['subject'])) {
            $post_errors->addError('no_subject');
            unset($_POST['subject']);
        }
        if (isset($_POST['message'])) {
            if (Util::htmltrim(Util::htmlspecialchars($_POST['message'])) === '') {
                $post_errors->addError('no_message');
                unset($_POST['message']);
            } elseif (!empty($modSettings['max_messageLength']) && Util::strlen($_POST['message']) > $modSettings['max_messageLength']) {
                $post_errors->addError(array('long_message', array($modSettings['max_messageLength'])));
                unset($_POST['message']);
            } else {
                $_POST['message'] = Util::htmlspecialchars($_POST['message'], ENT_QUOTES);
                preparsecode($_POST['message']);
                if (Util::htmltrim(strip_tags(parse_bbc($_POST['message'], false), '<img>')) === '') {
                    $post_errors->addError('no_message');
                    unset($_POST['message']);
                }
            }
        }
        if (isset($_POST['lock'])) {
            if (!allowedTo(array('lock_any', 'lock_own')) || !allowedTo('lock_any') && $user_info['id'] != $row['id_member']) {
                unset($_POST['lock']);
            } elseif (!allowedTo('lock_any')) {
                if ($row['locked'] == 1) {
                    unset($_POST['lock']);
                } else {
                    $_POST['lock'] = empty($_POST['lock']) ? 0 : 2;
                }
            } elseif (!empty($row['locked']) && !empty($_POST['lock']) || $_POST['lock'] == $row['locked']) {
                unset($_POST['lock']);
            } else {
                $_POST['lock'] = empty($_POST['lock']) ? 0 : 1;
            }
        }
        if (isset($_POST['sticky']) && !allowedTo('make_sticky')) {
            unset($_POST['sticky']);
        }
        if (!$post_errors->hasErrors()) {
            $msgOptions = array('id' => $row['id_msg'], 'subject' => isset($_POST['subject']) ? $_POST['subject'] : null, 'body' => isset($_POST['message']) ? $_POST['message'] : null, 'icon' => isset($_REQUEST['icon']) ? preg_replace('~[\\./\\\\*\':"<>]~', '', $_REQUEST['icon']) : null);
            $topicOptions = array('id' => $topic, 'board' => $board, 'lock_mode' => isset($_POST['lock']) ? (int) $_POST['lock'] : null, 'sticky_mode' => isset($_POST['sticky']) && !empty($modSettings['enableStickyTopics']) ? (int) $_POST['sticky'] : null, 'mark_as_read' => false);
            $posterOptions = array();
            // Only consider marking as editing if they have edited the subject, message or icon.
            if (isset($_POST['subject']) && $_POST['subject'] != $row['subject'] || isset($_POST['message']) && $_POST['message'] != $row['body'] || isset($_REQUEST['icon']) && $_REQUEST['icon'] != $row['icon']) {
                // And even then only if the time has passed...
                if (time() - $row['poster_time'] > $modSettings['edit_wait_time'] || $user_info['id'] != $row['id_member']) {
                    $msgOptions['modify_time'] = time();
                    $msgOptions['modify_name'] = $user_info['name'];
                }
            } else {
                $moderationAction = false;
            }
            modifyPost($msgOptions, $topicOptions, $posterOptions);
            // If we didn't change anything this time but had before put back the old info.
            if (!isset($msgOptions['modify_time']) && !empty($row['modified_time'])) {
                $msgOptions['modify_time'] = $row['modified_time'];
                $msgOptions['modify_name'] = $row['modified_name'];
            }
            // Changing the first subject updates other subjects to 'Re: new_subject'.
            if (isset($_POST['subject']) && isset($_REQUEST['change_all_subjects']) && $row['id_first_msg'] == $row['id_msg'] && !empty($row['num_replies']) && (allowedTo('modify_any') || $row['id_member_started'] == $user_info['id'] && allowedTo('modify_replies'))) {
                // Get the proper (default language) response prefix first.
                $context['response_prefix'] = response_prefix();
                $db->query('', '
					UPDATE {db_prefix}messages
					SET subject = {string:subject}
					WHERE id_topic = {int:current_topic}
						AND id_msg != {int:id_first_msg}', array('current_topic' => $topic, 'id_first_msg' => $row['id_first_msg'], 'subject' => $context['response_prefix'] . $_POST['subject']));
            }
            if (!empty($moderationAction)) {
                logAction('modify', array('topic' => $topic, 'message' => $row['id_msg'], 'member' => $row['id_member'], 'board' => $board));
            }
        }
        if (isset($_REQUEST['xml'])) {
            $context['sub_template'] = 'modifydone';
            if (!$post_errors->hasErrors() && isset($msgOptions['subject']) && isset($msgOptions['body'])) {
                $context['message'] = array('id' => $row['id_msg'], 'modified' => array('time' => isset($msgOptions['modify_time']) ? standardTime($msgOptions['modify_time']) : '', 'html_time' => isset($msgOptions['modify_time']) ? htmlTime($msgOptions['modify_time']) : '', 'timestamp' => isset($msgOptions['modify_time']) ? forum_time(true, $msgOptions['modify_time']) : 0, 'name' => isset($msgOptions['modify_time']) ? $msgOptions['modify_name'] : ''), 'subject' => $msgOptions['subject'], 'first_in_topic' => $row['id_msg'] == $row['id_first_msg'], 'body' => strtr($msgOptions['body'], array(']]>' => ']]]]><![CDATA[>')));
                censorText($context['message']['subject']);
                censorText($context['message']['body']);
                $context['message']['body'] = parse_bbc($context['message']['body'], $row['smileys_enabled'], $row['id_msg']);
            } elseif (!$post_errors->hasErrors()) {
                $context['sub_template'] = 'modifytopicdone';
                $context['message'] = array('id' => $row['id_msg'], 'modified' => array('time' => isset($msgOptions['modify_time']) ? standardTime($msgOptions['modify_time']) : '', 'html_time' => isset($msgOptions['modify_time']) ? htmlTime($msgOptions['modify_time']) : '', 'timestamp' => isset($msgOptions['modify_time']) ? forum_time(true, $msgOptions['modify_time']) : 0, 'name' => isset($msgOptions['modify_time']) ? $msgOptions['modify_name'] : ''), 'subject' => isset($msgOptions['subject']) ? $msgOptions['subject'] : '');
                censorText($context['message']['subject']);
            } else {
                $context['message'] = array('id' => $row['id_msg'], 'errors' => array(), 'error_in_subject' => $post_errors->hasError('no_subject'), 'error_in_body' => $post_errors->hasError('no_message') || $post_errors->hasError('long_message'));
                $context['message']['errors'] = $post_errors->prepareErrors();
            }
        } else {
            obExit(false);
        }
    }
开发者ID:Ralkage,项目名称:Elkarte,代码行数:101,代码来源:Post.controller.php

示例13: sportal_get_comments

/**
 * Loads all the comments that an article has generated
 *
 * @param int|null $article_id
 * @param int|null $limit limit the number of results
 * @param int|null $start start number for pages
 */
function sportal_get_comments($article_id = null, $limit = null, $start = null)
{
    global $scripturl, $user_info, $color_profile;
    $db = database();
    $request = $db->query('', '
		SELECT
			spc.id_comment, IFNULL(spc.id_member, 0) AS id_author,
			IFNULL(m.real_name, spc.member_name) AS author_name,
			spc.body, spc.log_time,
			m.avatar, m.email_address,
			a.id_attach, a.attachment_type, a.filename
		FROM {db_prefix}sp_comments AS spc
			LEFT JOIN {db_prefix}members AS m ON (m.id_member = spc.id_member)
			LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = m.id_member)
		WHERE spc.id_article = {int:article_id}
		ORDER BY spc.id_comment' . (!empty($limit) ? '
		LIMIT {int:start}, {int:limit}' : ''), array('article_id' => (int) $article_id, 'limit' => (int) $limit, 'start' => (int) $start));
    $return = array();
    $member_ids = array();
    while ($row = $db->fetch_assoc($request)) {
        if (!empty($row['id_author'])) {
            $member_ids[$row['id_author']] = $row['id_author'];
        }
        $return[$row['id_comment']] = array('id' => $row['id_comment'], 'body' => parse_bbc($row['body']), 'time' => htmlTime($row['log_time']), 'author' => array('id' => $row['id_author'], 'name' => $row['author_name'], 'href' => $scripturl . '?action=profile;u=' . $row['id_author'], 'link' => $row['id_author'] ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_author'] . '">' . $row['author_name'] . '</a>' : $row['author_name'], 'avatar' => determineAvatar(array('avatar' => $row['avatar'], 'filename' => $row['filename'], 'id_attach' => $row['id_attach'], 'email_address' => $row['email_address'], 'attachment_type' => $row['attachment_type']))), 'can_moderate' => allowedTo('sp_admin') || allowedTo('sp_manage_articles') || !$user_info['is_guest'] && $user_info['id'] == $row['id_author']);
    }
    $db->free_result($request);
    // Colorization
    if (!empty($member_ids) && sp_loadColors($member_ids) !== false) {
        foreach ($return as $key => $value) {
            if (!empty($color_profile[$value['author']['id']]['link'])) {
                $return[$key]['author']['link'] = $color_profile[$value['author']['id']]['link'];
            }
        }
    }
    return $return;
}
开发者ID:emanuele45,项目名称:SimplePortal_ElkArte,代码行数:43,代码来源:PortalArticle.subs.php

示例14: action_messageindex


//.........这里部分代码省略.........
             $row['last_body'] = '';
             censorText($row['first_subject']);
             if ($row['id_first_msg'] == $row['id_last_msg']) {
                 $row['last_subject'] = $row['first_subject'];
             } else {
                 censorText($row['last_subject']);
             }
         }
         // Decide how many pages the topic should have.
         if ($row['num_replies'] + 1 > $context['messages_per_page']) {
             // We can't pass start by reference.
             $start = -1;
             $pages = constructPageIndex($scripturl . '?topic=' . $row['id_topic'] . '.%1$d', $start, $row['num_replies'] + 1, $context['messages_per_page'], true, array('prev_next' => false, 'all' => !empty($modSettings['enableAllMessages']) && $row['num_replies'] + 1 < $modSettings['enableAllMessages']));
         } else {
             $pages = '';
         }
         // We need to check the topic icons exist...
         if (!empty($modSettings['messageIconChecks_enable'])) {
             if (!isset($context['icon_sources'][$row['first_icon']])) {
                 $context['icon_sources'][$row['first_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['first_icon'] . '.png') ? 'images_url' : 'default_images_url';
             }
             if (!isset($context['icon_sources'][$row['last_icon']])) {
                 $context['icon_sources'][$row['last_icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['last_icon'] . '.png') ? 'images_url' : 'default_images_url';
             }
         } else {
             if (!isset($context['icon_sources'][$row['first_icon']])) {
                 $context['icon_sources'][$row['first_icon']] = 'images_url';
             }
             if (!isset($context['icon_sources'][$row['last_icon']])) {
                 $context['icon_sources'][$row['last_icon']] = 'images_url';
             }
         }
         // 'Print' the topic info.
         $context['topics'][$row['id_topic']] = array('id' => $row['id_topic'], 'first_post' => array('id' => $row['id_first_msg'], 'member' => array('username' => $row['first_member_name'], 'name' => $row['first_display_name'], 'id' => $row['first_id_member'], 'href' => !empty($row['first_id_member']) ? $scripturl . '?action=profile;u=' . $row['first_id_member'] : '', 'link' => !empty($row['first_id_member']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['first_id_member'] . '" title="' . $txt['profile_of'] . ' ' . $row['first_display_name'] . '" class="preview">' . $row['first_display_name'] . '</a>' : $row['first_display_name']), 'time' => standardTime($row['first_poster_time']), 'html_time' => htmlTime($row['first_poster_time']), 'timestamp' => forum_time(true, $row['first_poster_time']), 'subject' => $row['first_subject'], 'preview' => trim($row['first_body']), 'icon' => $row['first_icon'], 'icon_url' => $settings[$context['icon_sources'][$row['first_icon']]] . '/post/' . $row['first_icon'] . '.png', 'href' => $scripturl . '?topic=' . $row['id_topic'] . '.0', 'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['first_subject'] . '</a>'), 'last_post' => array('id' => $row['id_last_msg'], 'member' => array('username' => $row['last_member_name'], 'name' => $row['last_display_name'], 'id' => $row['last_id_member'], 'href' => !empty($row['last_id_member']) ? $scripturl . '?action=profile;u=' . $row['last_id_member'] : '', 'link' => !empty($row['last_id_member']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['last_id_member'] . '">' . $row['last_display_name'] . '</a>' : $row['last_display_name']), 'time' => standardTime($row['last_poster_time']), 'html_time' => htmlTime($row['last_poster_time']), 'timestamp' => forum_time(true, $row['last_poster_time']), 'subject' => $row['last_subject'], 'preview' => trim($row['last_body']), 'icon' => $row['last_icon'], 'icon_url' => $settings[$context['icon_sources'][$row['last_icon']]] . '/post/' . $row['last_icon'] . '.png', 'href' => $scripturl . '?topic=' . $row['id_topic'] . ($user_info['is_guest'] ? '.' . (int) ($row['num_replies'] / $context['pageindex_multiplier']) * $context['pageindex_multiplier'] . '#msg' . $row['id_last_msg'] : ($row['num_replies'] == 0 ? '.0' : '.msg' . $row['id_last_msg']) . '#new'), 'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . ($user_info['is_guest'] ? '.' . (int) ($row['num_replies'] / $context['pageindex_multiplier']) * $context['pageindex_multiplier'] . '#msg' . $row['id_last_msg'] : ($row['num_replies'] == 0 ? '.0' : '.msg' . $row['id_last_msg']) . '#new') . '" ' . ($row['num_replies'] == 0 ? '' : 'rel="nofollow"') . '>' . $row['last_subject'] . '</a>'), 'default_preview' => trim($row[!empty($modSettings['message_index_preview']) && $modSettings['message_index_preview'] == 2 ? 'last_body' : 'first_body']), 'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($row['is_sticky']), 'is_locked' => !empty($row['locked']), 'is_poll' => !empty($modSettings['pollMode']) && $row['id_poll'] > 0, 'is_hot' => !empty($modSettings['useLikesNotViews']) ? $row['num_likes'] >= $modSettings['hotTopicPosts'] : $row['num_replies'] >= $modSettings['hotTopicPosts'], 'is_very_hot' => !empty($modSettings['useLikesNotViews']) ? $row['num_likes'] >= $modSettings['hotTopicVeryPosts'] : $row['num_replies'] >= $modSettings['hotTopicVeryPosts'], 'is_posted_in' => false, 'icon' => $row['first_icon'], 'icon_url' => $settings[$context['icon_sources'][$row['first_icon']]] . '/post/' . $row['first_icon'] . '.png', 'subject' => $row['first_subject'], 'new' => $row['new_from'] <= $row['id_msg_modified'], 'new_from' => $row['new_from'], 'newtime' => $row['new_from'], 'new_href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['new_from'] . '#new', 'redir_href' => !empty($row['id_redirect_topic']) ? $scripturl . '?topic=' . $row['id_topic'] . '.0;noredir' : '', 'pages' => $pages, 'replies' => comma_format($row['num_replies']), 'views' => comma_format($row['num_views']), 'likes' => comma_format($row['num_likes']), 'approved' => $row['approved'], 'unapproved_posts' => $row['unapproved_posts']);
         if (!empty($settings['avatars_on_indexes'])) {
             $context['topics'][$row['id_topic']]['last_post']['member']['avatar'] = determineAvatar($row);
         }
         determineTopicClass($context['topics'][$row['id_topic']]);
     }
     // Allow addons to add to the $context['topics']
     call_integration_hook('integrate_messageindex_listing', array($topics_info));
     // Fix the sequence of topics if they were retrieved in the wrong order. (for speed reasons...)
     if ($fake_ascending) {
         $context['topics'] = array_reverse($context['topics'], true);
     }
     if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest'] && !empty($topic_ids)) {
         $topics_participated_in = topicsParticipation($user_info['id'], $topic_ids);
         foreach ($topics_participated_in as $participated) {
             $context['topics'][$participated['id_topic']]['is_posted_in'] = true;
             $context['topics'][$participated['id_topic']]['class'] = 'my_' . $context['topics'][$participated['id_topic']]['class'];
         }
     }
     $context['jump_to'] = array('label' => addslashes(un_htmlspecialchars($txt['jump_to'])), 'board_name' => htmlspecialchars(strtr(strip_tags($board_info['name']), array('&amp;' => '&')), ENT_COMPAT, 'UTF-8'), 'child_level' => $board_info['child_level']);
     // Is Quick Moderation active/needed?
     if (!empty($options['display_quick_mod']) && !empty($context['topics'])) {
         $context['can_markread'] = $context['user']['is_logged'];
         $context['can_lock'] = allowedTo('lock_any');
         $context['can_sticky'] = allowedTo('make_sticky') && !empty($modSettings['enableStickyTopics']);
         $context['can_move'] = allowedTo('move_any');
         $context['can_remove'] = allowedTo('remove_any');
         $context['can_merge'] = allowedTo('merge_any');
         // Ignore approving own topics as it's unlikely to come up...
         $context['can_approve'] = $modSettings['postmod_active'] && allowedTo('approve_posts') && !empty($board_info['unapproved_topics']);
         // Can we restore topics?
         $context['can_restore'] = allowedTo('move_any') && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] == $board;
         // Set permissions for all the topics.
开发者ID:KeiroD,项目名称:Elkarte,代码行数:67,代码来源:MessageIndex.controller.php

示例15: action_search2


//.........这里部分代码省略.........
        foreach ($search_params as $k => $v) {
            $context['params'][] = $k . '|\'|' . $v;
        }
        $context['params'] = base64_encode(implode('|"|', $context['params']));
        // Compile the subject query part.
        $andQueryParts = array();
        foreach ($searchWords as $index => $word) {
            if ($word == '') {
                continue;
            }
            if ($search_params['subject_only']) {
                $andQueryParts[] = 'pm.subject' . (in_array($word, $excludedWords) ? ' NOT' : '') . ' LIKE {string:search_' . $index . '}';
            } else {
                $andQueryParts[] = '(pm.subject' . (in_array($word, $excludedWords) ? ' NOT' : '') . ' LIKE {string:search_' . $index . '} ' . (in_array($word, $excludedWords) ? 'AND pm.body NOT' : 'OR pm.body') . ' LIKE {string:search_' . $index . '})';
            }
            $searchq_parameters['search_' . $index] = '%' . strtr($word, array('_' => '\\_', '%' => '\\%')) . '%';
        }
        $searchQuery = ' 1=1';
        if (!empty($andQueryParts)) {
            $searchQuery = implode(!empty($search_params['searchtype']) && $search_params['searchtype'] == 2 ? ' OR ' : ' AND ', $andQueryParts);
        }
        // Age limits?
        $timeQuery = '';
        if (!empty($search_params['minage'])) {
            $timeQuery .= ' AND pm.msgtime < ' . (time() - $search_params['minage'] * 86400);
        }
        if (!empty($search_params['maxage'])) {
            $timeQuery .= ' AND pm.msgtime > ' . (time() - $search_params['maxage'] * 86400);
        }
        // If we have errors - return back to the first screen...
        if (!empty($context['search_errors'])) {
            $_REQUEST['params'] = $context['params'];
            return $this->action_search();
        }
        // Get the number of results.
        $numResults = numPMSeachResults($userQuery, $labelQuery, $timeQuery, $searchQuery, $searchq_parameters);
        // Get all the matching message ids, senders and head pm nodes
        list($foundMessages, $posters, $head_pms) = loadPMSearchMessages($userQuery, $labelQuery, $timeQuery, $searchQuery, $searchq_parameters, $search_params);
        // Find the real head pm when in converstaion view
        if ($context['display_mode'] == 2 && !empty($head_pms)) {
            $real_pm_ids = loadPMSearchHeads($head_pms);
        }
        // Load the found user data
        $posters = array_unique($posters);
        if (!empty($posters)) {
            loadMemberData($posters);
        }
        // Sort out the page index.
        $context['page_index'] = constructPageIndex($scripturl . '?action=pm;sa=search2;params=' . $context['params'], $_GET['start'], $numResults, $modSettings['search_results_per_page'], false);
        $context['message_labels'] = array();
        $context['message_replied'] = array();
        $context['personal_messages'] = array();
        $context['first_label'] = array();
        // If we have results, we have work to do!
        if (!empty($foundMessages)) {
            $recipients = array();
            list($context['message_labels'], $context['message_replied'], $context['message_unread'], $context['first_label']) = loadPMRecipientInfo($foundMessages, $recipients, $context['folder'], true);
            // Prepare for the callback!
            $search_results = loadPMSearchResults($foundMessages, $search_params);
            $counter = 0;
            foreach ($search_results as $row) {
                // If there's no subject, use the default.
                $row['subject'] = $row['subject'] == '' ? $txt['no_subject'] : $row['subject'];
                // Load this posters context info, if its not there then fill in the essentials...
                if (!loadMemberContext($row['id_member_from'], true)) {
                    $memberContext[$row['id_member_from']]['name'] = $row['from_name'];
                    $memberContext[$row['id_member_from']]['id'] = 0;
                    $memberContext[$row['id_member_from']]['group'] = $txt['guest_title'];
                    $memberContext[$row['id_member_from']]['link'] = $row['from_name'];
                    $memberContext[$row['id_member_from']]['email'] = '';
                    $memberContext[$row['id_member_from']]['show_email'] = showEmailAddress(true, 0);
                    $memberContext[$row['id_member_from']]['is_guest'] = true;
                }
                // Censor anything we don't want to see...
                censorText($row['body']);
                censorText($row['subject']);
                // Parse out any BBC...
                $row['body'] = parse_bbc($row['body'], true, 'pm' . $row['id_pm']);
                // Highlight the hits
                $body_highlighted = '';
                $subject_highlighted = '';
                foreach ($searchArray as $query) {
                    // Fix the international characters in the keyword too.
                    $query = un_htmlspecialchars($query);
                    $query = trim($query, '\\*+');
                    $query = strtr(Util::htmlspecialchars($query), array('\\\'' => '\''));
                    $body_highlighted = preg_replace_callback('/((<[^>]*)|' . preg_quote(strtr($query, array('\'' => '&#039;')), '/') . ')/iu', array($this, '_highlighted_callback'), $row['body']);
                    $subject_highlighted = preg_replace('/(' . preg_quote($query, '/') . ')/iu', '<strong class="highlight">$1</strong>', $row['subject']);
                }
                // Set a link using the first label information
                $href = $scripturl . '?action=pm;f=' . $context['folder'] . (isset($context['first_label'][$row['id_pm']]) ? ';l=' . $context['first_label'][$row['id_pm']] : '') . ';pmid=' . ($context['display_mode'] == 2 && isset($real_pm_ids[$head_pms[$row['id_pm']]]) && $context['folder'] == 'inbox' ? $real_pm_ids[$head_pms[$row['id_pm']]] : $row['id_pm']) . '#msg_' . $row['id_pm'];
                $context['personal_messages'][] = array('id' => $row['id_pm'], 'member' => &$memberContext[$row['id_member_from']], 'subject' => $subject_highlighted, 'body' => $body_highlighted, 'time' => standardTime($row['msgtime']), 'html_time' => htmlTime($row['msgtime']), 'timestamp' => forum_time(true, $row['msgtime']), 'recipients' => &$recipients[$row['id_pm']], 'labels' => &$context['message_labels'][$row['id_pm']], 'fully_labeled' => count($context['message_labels'][$row['id_pm']]) == count($context['labels']), 'is_replied_to' => &$context['message_replied'][$row['id_pm']], 'href' => $href, 'link' => '<a href="' . $href . '">' . $subject_highlighted . '</a>', 'counter' => ++$counter);
            }
        }
        // Finish off the context.
        $context['page_title'] = $txt['pm_search_title'];
        $context['sub_template'] = 'search_results';
        $context['menu_data_' . $context['pm_menu_id']]['current_area'] = 'search';
        $context['linktree'][] = array('url' => $scripturl . '?action=pm;sa=search', 'name' => $txt['pm_search_bar_title']);
    }
开发者ID:KeiroD,项目名称:Elkarte,代码行数:101,代码来源:PersonalMessage.controller.php


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