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


PHP Util::shorten_text方法代码示例

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


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

示例1: getLastPosts

/**
 * Get the latest posts of a forum.
 *
 * @param mixed[] $latestPostOptions
 * @return array
 */
function getLastPosts($latestPostOptions)
{
    global $scripturl, $modSettings;
    $db = database();
    // Find all the posts. Newer ones will have higher IDs. (assuming the last 20 * number are accessable...)
    // @todo SLOW This query is now slow, NEEDS to be fixed.  Maybe break into two?
    $request = $db->query('substring', '
		SELECT
			m.poster_time, m.subject, m.id_topic, m.id_member, m.id_msg,
			IFNULL(mem.real_name, m.poster_name) AS poster_name, t.id_board, b.name AS board_name,
			SUBSTRING(m.body, 1, 385) AS body, m.smileys_enabled
		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 = t.id_board)
			LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
		WHERE m.id_msg >= {int:likely_max_msg}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? '
			AND b.id_board != {int:recycle_board}' : '') . '
			AND {query_wanna_see_board}' . ($modSettings['postmod_active'] ? '
			AND t.approved = {int:is_approved}
			AND m.approved = {int:is_approved}' : '') . '
		ORDER BY m.id_msg DESC
		LIMIT ' . $latestPostOptions['number_posts'], array('likely_max_msg' => max(0, $modSettings['maxMsgID'] - 50 * $latestPostOptions['number_posts']), 'recycle_board' => $modSettings['recycle_board'], 'is_approved' => 1));
    $posts = array();
    while ($row = $db->fetch_assoc($request)) {
        // Censor the subject and post for the preview ;).
        censorText($row['subject']);
        censorText($row['body']);
        $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br />' => '&#10;')));
        $row['body'] = Util::shorten_text($row['body'], !empty($modSettings['lastpost_preview_characters']) ? $modSettings['lastpost_preview_characters'] : 128, true);
        // Build the array.
        $posts[] = array('board' => array('id' => $row['id_board'], 'name' => $row['board_name'], 'href' => $scripturl . '?board=' . $row['id_board'] . '.0', 'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['board_name'] . '</a>'), 'topic' => $row['id_topic'], 'poster' => array('id' => $row['id_member'], 'name' => $row['poster_name'], 'href' => empty($row['id_member']) ? '' : $scripturl . '?action=profile;u=' . $row['id_member'], 'link' => empty($row['id_member']) ? $row['poster_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['poster_name'] . '</a>'), 'subject' => $row['subject'], 'short_subject' => Util::shorten_text($row['subject'], $modSettings['subject_length']), 'preview' => $row['body'], 'time' => standardTime($row['poster_time']), 'html_time' => htmlTime($row['poster_time']), 'timestamp' => forum_time(true, $row['poster_time']), 'raw_timestamp' => $row['poster_time'], 'href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . ';topicseen#msg' . $row['id_msg'], 'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . ';topicseen#msg' . $row['id_msg'] . '" rel="nofollow">' . $row['subject'] . '</a>');
    }
    $db->free_result($request);
    return $posts;
}
开发者ID:KeiroD,项目名称:Elkarte,代码行数:41,代码来源:Recent.subs.php

示例2: template_messages_informations_above

/**
 * Topic informations, descriptions, etc.
 */
function template_messages_informations_above()
{
    global $context, $settings, $txt, $scripturl, $modSettings;
    // Show the topic information - icon, subject, etc.
    echo '
		<div id="forumposts" class="forumposts">
			<h2 class="category_header">
				<img src="', $settings['images_url'], '/topic/', $context['class'], '.png" alt="" />
				', $txt['topic'], ': ', $context['subject'], '&nbsp;<span class="views_text">(', $context['num_views_text'], ')</span>
				<span class="nextlinks">', !empty($context['links']['go_prev']) ? '<a href="' . $context['links']['go_prev'] . '">' . $txt['previous_next_back'] . '</a>' : '', !empty($context['links']['go_next']) ? ' - <a href="' . $context['links']['go_next'] . '">' . $txt['previous_next_forward'] . '</a>' : '', !empty($context['links']['derived_from']) ? ' - <a href="' . $context['links']['derived_from'] . '">' . sprintf($txt['topic_derived_from'], '<em>' . Util::shorten_text($context['topic_derived_from']['subject'], $modSettings['subject_length'])) . '</em></a>' : '', '</span>
			</h2>';
    if (!empty($settings['display_who_viewing']) || !empty($context['topic_redirected_from'])) {
        echo '
			<div class="generalinfo">';
        if (!empty($settings['display_who_viewing'])) {
            echo '
				<span id="whoisviewing">';
            // Show just numbers...?
            if ($settings['display_who_viewing'] == 1) {
                echo count($context['view_members']), ' ', count($context['view_members']) === 1 ? $txt['who_member'] : $txt['members'];
            } else {
                echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . (empty($context['view_num_hidden']) || $context['can_moderate_forum'] ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')');
            }
            // Now show how many guests are here too.
            echo $txt['who_and'], $context['view_num_guests'], ' ', $context['view_num_guests'] == 1 ? $txt['guest'] : $txt['guests'], $txt['who_viewing_topic'], '
				</span>';
        }
        // Is this topic a redirect?
        if (!empty($context['topic_redirected_from'])) {
            echo '
				<span id="redirectfrom">
					' . sprintf($txt['no_redir'], '<a href="' . $context['topic_redirected_from']['redir_href'] . '">' . $context['topic_redirected_from']['subject'] . '</a>'), '
				</span>';
        }
        echo '
			</div>';
    }
    echo '
			<form action="', $scripturl, '?action=quickmod2;topic=', $context['current_topic'], '.', $context['start'], '" method="post" accept-charset="UTF-8" name="quickModForm" id="quickModForm" style="margin: 0;" onsubmit="return oQuickModify.bInEditMode ? oQuickModify.modifySave(\'' . $context['session_id'] . '\', \'' . $context['session_var'] . '\') : false">';
}
开发者ID:KeiroD,项目名称:Elkarte,代码行数:43,代码来源:Display.template.php

示例3: lastPost

/**
 * Get the latest post made on the system
 *
 * - respects approved, recycled, and board permissions
 *
 * @package Posts
 * @return array
 */
function lastPost()
{
    global $scripturl, $modSettings;
    $db = database();
    // Find it by the board - better to order by board than sort the entire messages table.
    $request = $db->query('substring', '
		SELECT ml.poster_time, ml.subject, ml.id_topic, ml.poster_name, SUBSTRING(ml.body, 1, 385) AS body,
			ml.smileys_enabled
		FROM {db_prefix}boards AS b
			INNER JOIN {db_prefix}messages AS ml ON (ml.id_msg = b.id_last_msg)
		WHERE {query_wanna_see_board}' . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? '
			AND b.id_board != {int:recycle_board}' : '') . '
			AND ml.approved = {int:is_approved}
		ORDER BY b.id_msg_updated DESC
		LIMIT 1', array('recycle_board' => $modSettings['recycle_board'], 'is_approved' => 1));
    if ($db->num_rows($request) == 0) {
        return array();
    }
    $row = $db->fetch_assoc($request);
    $db->free_result($request);
    // Censor the subject and post...
    censorText($row['subject']);
    censorText($row['body']);
    $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled']), array('<br />' => '&#10;')));
    $row['body'] = Util::shorten_text($row['body'], !empty($modSettings['lastpost_preview_characters']) ? $modSettings['lastpost_preview_characters'] : 128, true);
    // Send the data.
    return array('topic' => $row['id_topic'], 'subject' => $row['subject'], 'short_subject' => Util::shorten_text($row['subject'], $modSettings['subject_length']), 'preview' => $row['body'], 'time' => standardTime($row['poster_time']), 'html_time' => htmlTime($row['poster_time']), 'timestamp' => forum_time(true, $row['poster_time']), 'href' => $scripturl . '?topic=' . $row['id_topic'] . '.new;topicseen#new', 'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.new;topicseen#new">' . $row['subject'] . '</a>');
}
开发者ID:KeiroD,项目名称:Elkarte,代码行数:36,代码来源:Post.subs.php

示例4: ssi_recentTopics

/**
 * Recent topic list:
 *  [board] Subject by Poster Date
 *
 * @param int $num_recent
 * @param int[]|null $exclude_boards
 * @param bool|null $include_boards
 * @param string $output_method = 'echo'
 */
function ssi_recentTopics($num_recent = 8, $exclude_boards = null, $include_boards = null, $output_method = 'echo')
{
    global $settings, $scripturl, $txt, $user_info, $modSettings;
    $db = database();
    if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0) {
        $exclude_boards = array($modSettings['recycle_board']);
    } else {
        $exclude_boards = empty($exclude_boards) ? array() : (is_array($exclude_boards) ? $exclude_boards : array($exclude_boards));
    }
    // Only some boards?.
    if (is_array($include_boards) || (int) $include_boards === $include_boards) {
        $include_boards = is_array($include_boards) ? $include_boards : array($include_boards);
    } elseif ($include_boards != null) {
        $output_method = $include_boards;
        $include_boards = array();
    }
    require_once SUBSDIR . '/MessageIndex.subs.php';
    $icon_sources = MessageTopicIcons();
    // Find all the posts in distinct topics. Newer ones will have higher IDs.
    $request = $db->query('', '
		SELECT
			t.id_topic, b.id_board, b.name AS board_name
		FROM {db_prefix}topics AS t
			INNER JOIN {db_prefix}messages AS ml ON (ml.id_msg = t.id_last_msg)
			LEFT JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
		WHERE t.id_last_msg >= {int:min_message_id}' . (empty($exclude_boards) ? '' : '
			AND b.id_board NOT IN ({array_int:exclude_boards})') . '' . (empty($include_boards) ? '' : '
			AND b.id_board IN ({array_int:include_boards})') . '
			AND {query_wanna_see_board}' . ($modSettings['postmod_active'] ? '
			AND t.approved = {int:is_approved}
			AND ml.approved = {int:is_approved}' : '') . '
		ORDER BY t.id_last_msg DESC
		LIMIT ' . $num_recent, array('include_boards' => empty($include_boards) ? '' : $include_boards, 'exclude_boards' => empty($exclude_boards) ? '' : $exclude_boards, 'min_message_id' => $modSettings['maxMsgID'] - 35 * min($num_recent, 5), 'is_approved' => 1));
    $topics = array();
    while ($row = $db->fetch_assoc($request)) {
        $topics[$row['id_topic']] = $row;
    }
    $db->free_result($request);
    // Did we find anything? If not, bail.
    if (empty($topics)) {
        return array();
    }
    // Find all the posts in distinct topics. Newer ones will have higher IDs.
    $request = $db->query('substring', '
		SELECT
			mf.poster_time, mf.subject, ml.id_topic, mf.id_member, ml.id_msg, t.num_replies, t.num_views, mg.online_color,
			IFNULL(mem.real_name, mf.poster_name) AS poster_name, ' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
			IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= ml.id_msg_modified AS is_read,
			IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . ', SUBSTRING(mf.body, 1, 384) AS body, mf.smileys_enabled, mf.icon
		FROM {db_prefix}topics AS t
			INNER JOIN {db_prefix}messages AS ml ON (ml.id_msg = t.id_last_msg)
			INNER JOIN {db_prefix}messages AS mf ON (mf.id_msg = t.id_last_msg)
			LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = mf.id_member)' . (!$user_info['is_guest'] ? '
			LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = t.id_topic AND lt.id_member = {int:current_member})
			LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = t.id_board AND lmr.id_member = {int:current_member})' : '') . '
			LEFT JOIN {db_prefix}membergroups AS mg ON (mg.id_group = mem.id_group)
		WHERE t.id_topic IN ({array_int:topic_list})', array('current_member' => $user_info['id'], 'topic_list' => array_keys($topics)));
    $posts = array();
    while ($row = $db->fetch_assoc($request)) {
        $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), array('<br />' => '&#10;')));
        if (Util::strlen($row['body']) > 128) {
            $row['body'] = Util::substr($row['body'], 0, 128) . '...';
        }
        // Censor the subject.
        censorText($row['subject']);
        censorText($row['body']);
        if (!empty($modSettings['messageIconChecks_enable']) && !isset($icon_sources[$row['icon']])) {
            $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url';
        }
        // Build the array.
        $posts[] = array('board' => array('id' => $topics[$row['id_topic']]['id_board'], 'name' => $topics[$row['id_topic']]['board_name'], 'href' => $scripturl . '?board=' . $topics[$row['id_topic']]['id_board'] . '.0', 'link' => '<a href="' . $scripturl . '?board=' . $topics[$row['id_topic']]['id_board'] . '.0">' . $topics[$row['id_topic']]['board_name'] . '</a>'), 'topic' => $row['id_topic'], 'poster' => array('id' => $row['id_member'], 'name' => $row['poster_name'], 'href' => empty($row['id_member']) ? '' : $scripturl . '?action=profile;u=' . $row['id_member'], 'link' => empty($row['id_member']) ? $row['poster_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['poster_name'] . '</a>'), 'subject' => $row['subject'], 'replies' => $row['num_replies'], 'views' => $row['num_views'], 'short_subject' => Util::shorten_text($row['subject'], 25), 'preview' => $row['body'], 'time' => standardTime($row['poster_time']), 'html_time' => htmlTime($row['poster_time']), 'timestamp' => forum_time(true, $row['poster_time']), 'href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . ';topicseen#new', 'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#new" rel="nofollow">' . $row['subject'] . '</a>', 'new' => !empty($row['is_read']), 'is_new' => empty($row['is_read']), 'new_from' => $row['new_from'], 'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.png" style="vertical-align: middle;" alt="' . $row['icon'] . '" />');
    }
    $db->free_result($request);
    // Just return it.
    if ($output_method != 'echo' || empty($posts)) {
        return $posts;
    }
    echo '
		<table class="ssi_table">';
    foreach ($posts as $post) {
        echo '
			<tr>
				<td class="righttext top">
					[', $post['board']['link'], ']
				</td>
				<td class="top">
					<a href="', $post['href'], '">', $post['subject'], '</a>
					', $txt['by'], ' ', $post['poster']['link'], '
					', !$post['is_new'] ? '' : '<a href="' . $scripturl . '?topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new" rel="nofollow"><span class="new_posts">' . $txt['new'] . '</span></a>', '
				</td>
				<td class="righttext">
//.........这里部分代码省略.........
开发者ID:scripple,项目名称:Elkarte,代码行数:101,代码来源:SSI.php

示例5: action_search_internal

 /**
  * A complicated but relatively quick internal search.
  */
 public function action_search_internal()
 {
     global $context, $txt, $helptxt, $scripturl;
     // Try to get some more memory.
     setMemoryLimit('128M');
     // Load a lot of language files.
     $language_files = array('Help', 'ManageMail', 'ManageSettings', 'ManageCalendar', 'ManageBoards', 'ManagePaid', 'ManagePermissions', 'Search', 'Login', 'ManageSmileys', 'Maillist');
     // All the files we need to include.
     $include_files = array('AddonSettings.controller', 'AdminLog.controller', 'CoreFeatures.controller', 'ManageAttachments.controller', 'ManageAvatars.controller', 'ManageBBC.controller', 'ManageBoards.controller', 'ManageCalendar.controller', 'ManageDrafts.controller', 'ManageFeatures.controller', 'ManageLanguages.controller', 'ManageMail.controller', 'ManageNews.controller', 'ManagePaid.controller', 'ManagePermissions.controller', 'ManagePosts.controller', 'ManageRegistration.controller', 'ManageSearch.controller', 'ManageSearchEngines.controller', 'ManageSecurity.controller', 'ManageServer.controller', 'ManageSmileys.controller', 'ManageTopics.controller', 'ManageMaillist.controller', 'ManageMembergroups.controller');
     // This is a special array of functions that contain setting data
     // - we query all these to simply pull all setting bits!
     $settings_search = array(array('settings_search', 'area=logs;sa=pruning', 'AdminLog_Controller'), array('config_vars', 'area=corefeatures', 'CoreFeatures_Controller'), array('basicSettings_search', 'area=featuresettings;sa=basic', 'ManageFeatures_Controller'), array('layoutSettings_search', 'area=featuresettings;sa=layout', 'ManageFeatures_Controller'), array('karmaSettings_search', 'area=featuresettings;sa=karma', 'ManageFeatures_Controller'), array('likesSettings_search', 'area=featuresettings;sa=likes', 'ManageFeatures_Controller'), array('mentionSettings_search', 'area=featuresettings;sa=mention', 'ManageFeatures_Controller'), array('signatureSettings_search', 'area=featuresettings;sa=sig', 'ManageFeatures_Controller'), array('settings_search', 'area=addonsettings;sa=general', 'AddonSettings_Controller'), array('settings_search', 'area=manageattachments;sa=attachments', 'ManageAttachments_Controller'), array('settings_search', 'area=manageattachments;sa=avatars', 'ManageAvatars_Controller'), array('settings_search', 'area=postsettings;sa=bbc', 'ManageBBC_Controller'), array('settings_search', 'area=manageboards;sa=settings', 'ManageBoards_Controller'), array('settings_search', 'area=managecalendar;sa=settings', 'ManageCalendar_Controller'), array('settings_search', 'area=managedrafts', 'ManageDrafts_Controller'), array('settings_search', 'area=languages;sa=settings', 'ManageLanguages_Controller'), array('settings_search', 'area=mailqueue;sa=settings', 'ManageMail_Controller'), array('settings_search', 'area=maillist;sa=emailsettings', 'ManageMaillist_Controller'), array('settings_search', 'area=membergroups;sa=settings', 'ManageMembergroups_Controller'), array('settings_search', 'area=news;sa=settings', 'ManageNews_Controller'), array('settings_search', 'area=paidsubscribe;sa=settings', 'ManagePaid_Controller'), array('settings_search', 'area=permissions;sa=settings', 'ManagePermissions_Controller'), array('settings_search', 'area=postsettings;sa=posts', 'ManagePosts_Controller'), array('settings_search', 'area=regcenter;sa=settings', 'ManageRegistration_Controller'), array('settings_search', 'area=managesearch;sa=settings', 'ManageSearch_Controller'), array('settings_search', 'area=sengines;sa=settings', 'ManageSearchEngines_Controller'), array('securitySettings_search', 'area=securitysettings;sa=general', 'ManageSecurity_Controller'), array('spamSettings_search', 'area=securitysettings;sa=spam', 'ManageSecurity_Controller'), array('moderationSettings_search', 'area=securitysettings;sa=moderation', 'ManageSecurity_Controller'), array('bbSettings_search', 'area=securitysettings;sa=badbehavior', 'ManageSecurity_Controller'), array('generalSettings_search', 'area=serversettings;sa=general', 'ManageServer_Controller'), array('databaseSettings_search', 'area=serversettings;sa=database', 'ManageServer_Controller'), array('cookieSettings_search', 'area=serversettings;sa=cookie', 'ManageServer_Controller'), array('cacheSettings_search', 'area=serversettings;sa=cache', 'ManageServer_Controller'), array('balancingSettings_search', 'area=serversettings;sa=loads', 'ManageServer_Controller'), array('settings_search', 'area=smileys;sa=settings', 'ManageSmileys_Controller'), array('settings_search', 'area=postsettings;sa=topics', 'ManageTopics_Controller'));
     call_integration_hook('integrate_admin_search', array(&$language_files, &$include_files, &$settings_search));
     loadLanguage(implode('+', $language_files));
     foreach ($include_files as $file) {
         require_once ADMINDIR . '/' . $file . '.php';
     }
     /* This is the huge array that defines everything ... it's items are formatted as follows:
     			0 = Language index (Can be array of indexes) to search through for this setting.
     			1 = URL for this indexes page.
     			2 = Help index for help associated with this item (If different from 0)
     		*/
     $search_data = array('sections' => array(), 'settings' => array(array('COPPA', 'area=regcenter;sa=settings'), array('CAPTCHA', 'area=securitysettings;sa=spam')));
     // Go through the admin menu structure trying to find suitably named areas!
     foreach ($context[$context['admin_menu_name']]['sections'] as $section) {
         foreach ($section['areas'] as $menu_key => $menu_item) {
             $search_data['sections'][] = array($menu_item['label'], 'area=' . $menu_key);
             if (!empty($menu_item['subsections'])) {
                 foreach ($menu_item['subsections'] as $key => $sublabel) {
                     if (isset($sublabel['label'])) {
                         $search_data['sections'][] = array($sublabel['label'], 'area=' . $menu_key . ';sa=' . $key);
                     }
                 }
             }
         }
     }
     foreach ($settings_search as $setting_area) {
         // Get a list of their variables.
         if (isset($setting_area[2])) {
             // an OOP controller: get the settings from the settings method.
             $controller = new $setting_area[2]();
             $config_vars = $controller->{$setting_area[0]}();
         } else {
             // a good ole' procedural controller: get the settings from the function.
             $config_vars = $setting_area[0](true);
         }
         foreach ($config_vars as $var) {
             if (!empty($var[1]) && !in_array($var[0], array('permissions', 'switch', 'warning'))) {
                 $search_data['settings'][] = array($var[isset($var[2]) && in_array($var[2], array('file', 'db')) ? 0 : 1], $setting_area[1]);
             }
         }
     }
     $context['page_title'] = $txt['admin_search_results'];
     $context['search_results'] = array();
     // Go through all the search data trying to find this text!
     $search_term = strtolower(un_htmlspecialchars($context['search_term']));
     foreach ($search_data as $section => $data) {
         foreach ($data as $item) {
             $found = false;
             if (!is_array($item[0])) {
                 $item[0] = array($item[0]);
             }
             foreach ($item[0] as $term) {
                 if (stripos($term, $search_term) !== false || isset($txt[$term]) && stripos($txt[$term], $search_term) !== false || isset($txt['setting_' . $term]) && stripos($txt['setting_' . $term], $search_term) !== false) {
                     $found = $term;
                     break;
                 }
             }
             if ($found) {
                 // Format the name - and remove any descriptions the entry may have.
                 $name = isset($txt[$found]) ? $txt[$found] : (isset($txt['setting_' . $found]) ? $txt['setting_' . $found] : $found);
                 $name = preg_replace('~<(?:div|span)\\sclass="smalltext">.+?</(?:div|span)>~', '', $name);
                 if (!empty($name)) {
                     $context['search_results'][] = array('url' => (substr($item[1], 0, 4) == 'area' ? $scripturl . '?action=admin;' . $item[1] : $item[1]) . ';' . $context['session_var'] . '=' . $context['session_id'] . (substr($item[1], 0, 4) == 'area' && $section == 'settings' ? '#' . $item[0][0] : ''), 'name' => $name, 'type' => $section, 'help' => Util::shorten_text(isset($item[2]) ? strip_tags($helptxt[$item[2]]) : (isset($helptxt[$found]) ? strip_tags($helptxt[$found]) : ''), 255));
                 }
             }
         }
     }
 }
开发者ID:scripple,项目名称:Elkarte,代码行数:82,代码来源:Admin.controller.php

示例6: getBoards


//.........这里部分代码省略.........
                }
                // Avoid showing category unread link where it only has redirection boards.
                $this->_categories[$row_board['id_cat']]['show_unread'] = !empty($this->_categories[$row_board['id_cat']]['show_unread']) ? 1 : !$row_board['is_redirect'];
                // Collapsed category - don't do any of this.
                if ($this->_categories[$row_board['id_cat']]['is_collapsed']) {
                    continue;
                }
                // Let's save some typing.  Climbing the array might be slower, anyhow.
                $this->_current_boards =& $this->_categories[$row_board['id_cat']]['boards'];
            }
            // This is a parent board.
            if ($row_board['id_parent'] == $this->_options['parent_id']) {
                // Is this a new board, or just another moderator?
                if (!isset($this->_current_boards[$row_board['id_board']])) {
                    $this->_current_boards[$row_board['id_board']] = array('new' => empty($row_board['is_read']), 'id' => $row_board['id_board'], 'name' => $row_board['board_name'], 'description' => $row_board['description'], 'moderators' => array(), 'link_moderators' => array(), 'children' => array(), 'link_children' => array(), 'children_new' => false, 'topics' => $row_board['num_topics'], 'posts' => $row_board['num_posts'], 'is_redirect' => $row_board['is_redirect'], 'unapproved_topics' => $row_board['unapproved_topics'], 'unapproved_posts' => $row_board['unapproved_posts'] - $row_board['unapproved_topics'], 'can_approve_posts' => $this->_user['mod_cache_ap'] == array(0) || in_array($row_board['id_board'], $this->_user['mod_cache_ap']), 'href' => $this->_scripturl . '?board=' . $row_board['id_board'] . '.0', 'link' => '<a href="' . $this->_scripturl . '?board=' . $row_board['id_board'] . '.0">' . $row_board['board_name'] . '</a>');
                }
                $this->_boards[$row_board['id_board']] = $this->_options['include_categories'] ? $row_board['id_cat'] : 0;
            } elseif (isset($this->_current_boards[$row_board['id_parent']]['children']) && !isset($this->_current_boards[$row_board['id_parent']]['children'][$row_board['id_board']])) {
                // A valid child!
                $isChild = true;
                $this->_current_boards[$row_board['id_parent']]['children'][$row_board['id_board']] = array('id' => $row_board['id_board'], 'name' => $row_board['board_name'], 'description' => $row_board['description'], 'new' => empty($row_board['is_read']) && $row_board['poster_name'] != '', 'topics' => $row_board['num_topics'], 'posts' => $row_board['num_posts'], 'is_redirect' => $row_board['is_redirect'], 'unapproved_topics' => $row_board['unapproved_topics'], 'unapproved_posts' => $row_board['unapproved_posts'] - $row_board['unapproved_topics'], 'can_approve_posts' => $this->_user['mod_cache_ap'] == array(0) || in_array($row_board['id_board'], $this->_user['mod_cache_ap']), 'href' => $this->_scripturl . '?board=' . $row_board['id_board'] . '.0', 'link' => '<a href="' . $this->_scripturl . '?board=' . $row_board['id_board'] . '.0">' . $row_board['board_name'] . '</a>');
                // Counting sub-board posts is... slow :/.
                if (!empty($this->_options['countChildPosts']) && !$row_board['is_redirect']) {
                    $this->_current_boards[$row_board['id_parent']]['posts'] += $row_board['num_posts'];
                    $this->_current_boards[$row_board['id_parent']]['topics'] += $row_board['num_topics'];
                }
                // Does this board contain new boards?
                $this->_current_boards[$row_board['id_parent']]['children_new'] |= empty($row_board['is_read']);
                // This is easier to use in many cases for the theme....
                $this->_current_boards[$row_board['id_parent']]['link_children'][] =& $this->_current_boards[$row_board['id_parent']]['children'][$row_board['id_board']]['link'];
            } elseif (!empty($this->_options['countChildPosts'])) {
                // @todo why this is not initialized outside the loop?
                if (!isset($parent_map)) {
                    $parent_map = array();
                }
                if (!isset($parent_map[$row_board['id_parent']])) {
                    foreach ($this->_current_boards as $id => $board) {
                        if (!isset($board['children'][$row_board['id_parent']])) {
                            continue;
                        }
                        $parent_map[$row_board['id_parent']] = array(&$this->_current_boards[$id], &$this->_current_boards[$id]['children'][$row_board['id_parent']]);
                        $parent_map[$row_board['id_board']] = array(&$this->_current_boards[$id], &$this->_current_boards[$id]['children'][$row_board['id_parent']]);
                        break;
                    }
                }
                if (isset($parent_map[$row_board['id_parent']]) && !$row_board['is_redirect']) {
                    $parent_map[$row_board['id_parent']][0]['posts'] += $row_board['num_posts'];
                    $parent_map[$row_board['id_parent']][0]['topics'] += $row_board['num_topics'];
                    $parent_map[$row_board['id_parent']][1]['posts'] += $row_board['num_posts'];
                    $parent_map[$row_board['id_parent']][1]['topics'] += $row_board['num_topics'];
                    continue;
                }
                continue;
            } else {
                continue;
            }
            // Prepare the subject, and make sure it's not too long.
            censorText($row_board['subject']);
            $row_board['short_subject'] = Util::shorten_text($row_board['subject'], $this->_subject_length);
            $this_last_post = array('id' => $row_board['id_msg'], 'time' => $row_board['poster_time'] > 0 ? standardTime($row_board['poster_time']) : $txt['not_applicable'], 'html_time' => $row_board['poster_time'] > 0 ? htmlTime($row_board['poster_time']) : $txt['not_applicable'], 'timestamp' => forum_time(true, $row_board['poster_time']), 'subject' => $row_board['short_subject'], 'member' => array('id' => $row_board['id_member'], 'username' => $row_board['poster_name'] != '' ? $row_board['poster_name'] : $txt['not_applicable'], 'name' => $row_board['real_name'], 'href' => $row_board['poster_name'] != '' && !empty($row_board['id_member']) ? $this->_scripturl . '?action=profile;u=' . $row_board['id_member'] : '', 'link' => $row_board['poster_name'] != '' ? !empty($row_board['id_member']) ? '<a href="' . $this->_scripturl . '?action=profile;u=' . $row_board['id_member'] . '">' . $row_board['real_name'] . '</a>' : $row_board['real_name'] : $txt['not_applicable']), 'start' => 'msg' . $row_board['new_from'], 'topic' => $row_board['id_topic']);
            if ($this->_options['avatars_on_indexes']) {
                $this_last_post['member']['avatar'] = determineAvatar($row_board);
            }
            // Provide the href and link.
            if ($row_board['subject'] != '') {
                $this_last_post['href'] = $this->_scripturl . '?topic=' . $row_board['id_topic'] . '.msg' . ($this->_user['is_guest'] ? $row_board['id_msg'] : $row_board['new_from']) . (empty($row_board['is_read']) ? ';boardseen' : '') . '#new';
                $this_last_post['link'] = '<a href="' . $this_last_post['href'] . '" title="' . $row_board['subject'] . '">' . $row_board['short_subject'] . '</a>';
                /* The board's and children's 'last_post's have:
                			time, timestamp (a number that represents the time.), id (of the post), topic (topic id.),
                			link, href, subject, start (where they should go for the first unread post.),
                			and member. (which has id, name, link, href, username in it.) */
                $this_last_post['last_post_message'] = sprintf($txt['last_post_message'], $this_last_post['member']['link'], $this_last_post['link'], $this_last_post['html_time']);
            } else {
                $this_last_post['href'] = '';
                $this_last_post['link'] = $txt['not_applicable'];
                $this_last_post['last_post_message'] = '';
            }
            // Set the last post in the parent board.
            if ($row_board['id_parent'] == $this->_options['parent_id'] || $isChild && !empty($row_board['poster_time']) && $this->_current_boards[$row_board['id_parent']]['last_post']['timestamp'] < forum_time(true, $row_board['poster_time'])) {
                $this->_current_boards[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'] = $this_last_post;
            }
            // Just in the child...?
            if ($isChild) {
                $this->_current_boards[$row_board['id_parent']]['children'][$row_board['id_board']]['last_post'] = $this_last_post;
                // If there are no posts in this board, it really can't be new...
                $this->_current_boards[$row_board['id_parent']]['children'][$row_board['id_board']]['new'] &= $row_board['poster_name'] != '';
            } elseif ($row_board['poster_name'] == '') {
                $this->_current_boards[$row_board['id_board']]['new'] = false;
            }
            // Determine a global most recent topic.
            if ($this->_options['set_latest_post'] && !empty($row_board['poster_time']) && $row_board['poster_time'] > $this->_latest_post['timestamp'] && !$ignoreThisBoard) {
                $this->_latest_post =& $this->_current_boards[$isChild ? $row_board['id_parent'] : $row_board['id_board']]['last_post'];
            }
        }
        $this->_db->free_result($result_boards);
        if ($this->_options['get_moderators'] && !empty($this->_boards)) {
            $this->_getBoardModerators();
        }
        return $this->_options['include_categories'] ? $this->_categories : $this->_current_boards;
    }
开发者ID:scripple,项目名称:Elkarte,代码行数:101,代码来源:BoardsList.class.php

示例7: action_summary


//.........这里部分代码省略.........
                        if (!empty($modSettings['attachmentThumbWidth']) && !empty($modSettings['attachmentThumbHeight'])) {
                            if ($attachments[$i]['width'] > $modSettings['attachmentThumbWidth'] || $attachments[$i]['height'] > $modSettings['attachmentThumbHeight']) {
                                $context['thumbs'][$i]['img'] = '<img id="thumb_' . $attachments[$i]['id'] . '" src="' . $scripturl . '?action=dlattach;topic=' . $attachments[$i]['topic'] . '.0;attach=' . $attachments[$i]['id'] . '" title="" alt="" width="' . $modSettings['attachmentThumbWidth'] . '" height="' . $modSettings['attachmentThumbHeight'] . '" />';
                            } else {
                                $context['thumbs'][$i]['img'] = '<img id="thumb_' . $attachments[$i]['id'] . '" src="' . $scripturl . '?action=dlattach;topic=' . $attachments[$i]['topic'] . '.0;attach=' . $attachments[$i]['id'] . '" title="" alt="" width="' . $attachments[$i]['width'] . '" height="' . $attachments[$i]['height'] . '" />';
                            }
                        }
                    }
                } else {
                    if (!empty($modSettings['attachmentThumbWidth']) && !empty($modSettings['attachmentThumbHeight']) && (128 > $modSettings['attachmentThumbWidth'] || 128 > $modSettings['attachmentThumbHeight'])) {
                        $context['thumbs'][$i]['img'] = '<img src="' . $mime_images_url . (!file_exists($mime_path . $attachments[$i]['fileext'] . '.png') ? 'default' : $attachments[$i]['fileext']) . '.png" title="" alt="" width="' . $modSettings['attachmentThumbWidth'] . '" height="' . $modSettings['attachmentThumbHeight'] . '" />';
                    } else {
                        $context['thumbs'][$i]['img'] = '<img src="' . $mime_images_url . (!file_exists($mime_path . $attachments[$i]['fileext'] . '.png') ? 'default' : $attachments[$i]['fileext']) . '.png" title="" alt="" />';
                    }
                }
            }
        }
        // Would you be mine? Could you be mine? Be my buddy :D
        if (!empty($modSettings['enable_buddylist']) && $context['user']['is_owner'] && !empty($user_info['buddies']) && in_array('buddies', $summary_areas)) {
            $context['buddies'] = array();
            loadMemberData($user_info['buddies'], false, 'profile');
            // Get the info for this buddy
            foreach ($user_info['buddies'] as $buddy) {
                loadMemberContext($buddy, true);
                $context['buddies'][$buddy] = $memberContext[$buddy];
            }
        }
        // How about thier most recent posts?
        if (in_array('posts', $summary_areas)) {
            // Is the load average too high just now, then let them know
            if (!empty($modSettings['loadavg_show_posts']) && $modSettings['current_load'] >= $modSettings['loadavg_show_posts']) {
                $context['loadaverage'] = true;
            } else {
                // Set up to get the last 10 psots of this member
                $msgCount = count_user_posts($memID);
                $range_limit = '';
                $maxIndex = 10;
                $start = (int) $_REQUEST['start'];
                // If they are a frequent poster, we guess the range to help minimize what the query work
                if ($msgCount > 1000) {
                    list($min_msg_member, $max_msg_member) = findMinMaxUserMessage($memID);
                    $margin = floor(($max_msg_member - $min_msg_member) * (($start + $modSettings['defaultMaxMessages']) / $msgCount) + 0.1 * ($max_msg_member - $min_msg_member));
                    $range_limit = 'm.id_msg > ' . ($max_msg_member - $margin);
                }
                // Find this user's most recent posts
                $rows = load_user_posts($memID, 0, $maxIndex, $range_limit);
                $context['posts'] = array();
                foreach ($rows as $row) {
                    // Censor....
                    censorText($row['body']);
                    censorText($row['subject']);
                    // Do the code.
                    $row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']);
                    $preview = strip_tags(strtr($row['body'], array('<br />' => '&#10;')));
                    $preview = Util::shorten_text($preview, !empty($modSettings['ssi_preview_length']) ? $modSettings['ssi_preview_length'] : 128);
                    $short_subject = Util::shorten_text($row['subject'], !empty($modSettings['ssi_subject_length']) ? $modSettings['ssi_subject_length'] : 24);
                    // And the array...
                    $context['posts'][] = array('body' => $preview, 'board' => array('name' => $row['bname'], 'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['bname'] . '</a>'), 'subject' => $row['subject'], 'short_subject' => $short_subject, 'time' => standardTime($row['poster_time']), 'html_time' => htmlTime($row['poster_time']), 'timestamp' => forum_time(true, $row['poster_time']), 'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '" rel="nofollow">' . $short_subject . '</a>');
                }
            }
        }
        // How about the most recent topics that they started?
        if (in_array('topics', $summary_areas)) {
            // Is the load average still too high?
            if (!empty($modSettings['loadavg_show_posts']) && $modSettings['current_load'] >= $modSettings['loadavg_show_posts']) {
                $context['loadaverage'] = true;
            } else {
                // Set up to get the last 10 topics of this member
                $topicCount = count_user_topics($memID);
                $range_limit = '';
                $maxIndex = 10;
                // If they are a frequent topic starter we guess the range to help the query
                if ($topicCount > 1000) {
                    list($min_topic_member, $max_topic_member) = findMinMaxUserTopic($memID);
                    $margin = floor(($max_topic_member - $min_topic_member) * (($start + $modSettings['defaultMaxMessages']) / $topicCount) + 0.1 * ($max_topic_member - $min_topic_member));
                    $margin *= 5;
                    $range_limit = 't.id_first_msg > ' . ($max_topic_member - $margin);
                }
                // Find this user's most recent topics
                $rows = load_user_topics($memID, 0, $maxIndex, $range_limit);
                $context['topics'] = array();
                foreach ($rows as $row) {
                    // Censor....
                    censorText($row['body']);
                    censorText($row['subject']);
                    // Do the code.
                    $short_subject = Util::shorten_text($row['subject'], !empty($modSettings['ssi_subject_length']) ? $modSettings['ssi_subject_length'] : 24);
                    // And the array...
                    $context['topics'][] = array('board' => array('name' => $row['bname'], 'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['bname'] . '</a>'), 'subject' => $row['subject'], 'short_subject' => $short_subject, 'time' => standardTime($row['poster_time']), 'html_time' => htmlTime($row['poster_time']), 'timestamp' => forum_time(true, $row['poster_time']), 'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'] . '" rel="nofollow">' . $short_subject . '</a>');
                }
            }
        }
        // To finish this off, custom profile fields.
        require_once SUBSDIR . '/Profile.subs.php';
        loadCustomFields($memID);
        // To make tabs work, we need jQueryUI
        $modSettings['jquery_include_ui'] = true;
        addInlineJavascript('
		$(function() {$( "#tabs" ).tabs();});', true);
    }
开发者ID:scripple,项目名称:Elkarte,代码行数:101,代码来源:ProfileInfo.controller.php

示例8: sp_rssFeed

/**
 * RSS Block, Displays rss feed in a block.
 *
 * @param mixed[] $parameters
 *		'url' => url of the feed
 *		'show_title' => Show the feed title
 *		'show_content' => Show the content of the feed
 *		'show_date' => Show the date of the feed item
 *		'strip_preserve' => preserve tags
 * 		'count' => number of items to show
 * 		'limit' => number of characters of content to show
 * @param int $id - not used in this block
 * @param boolean $return_parameters if true returns the configuration options for the block
 */
function sp_rssFeed($parameters, $id, $return_parameters = false)
{
    global $txt;
    $block_parameters = array('url' => 'text', 'show_title' => 'check', 'show_content' => 'check', 'show_date' => 'check', 'strip_preserve' => 'text', 'count' => 'int', 'limit' => 'int');
    if ($return_parameters) {
        return $block_parameters;
    }
    $feed = !empty($parameters['url']) ? un_htmlspecialchars($parameters['url']) : '';
    $show_title = !empty($parameters['show_title']);
    $show_content = !empty($parameters['show_content']);
    $show_date = !empty($parameters['show_date']);
    $strip_preserve = !empty($parameters['strip_preserve']) ? $parameters['strip_preserve'] : 'br';
    $strip_preserve = preg_match_all('~[A-Za-z0-9]+~', $strip_preserve, $match) ? $match[0] : array();
    $count = !empty($parameters['count']) ? (int) $parameters['count'] : 5;
    $limit = !empty($parameters['limit']) ? (int) $parameters['limit'] : 0;
    // Need a feed name to load it
    if (empty($feed)) {
        echo '
								', $txt['error_sp_invalid_feed'];
        return;
    }
    $rss = array();
    require_once SUBSDIR . '/Package.subs.php';
    $data = fetch_web_data($feed);
    $data_save = $data;
    // Convert it to UTF8 if we can and its not already
    preg_match('~encoding="([^"]*)"~', $data, $charset);
    if (!empty($charset[1]) && $charset != 'UTF-8') {
        // Use iconv if its available
        if (function_exists('iconv')) {
            $data = @iconv($charset[1], 'UTF-8' . '//TRANSLIT//IGNORE', $data);
        }
        // No iconv or a false response from it
        if (!function_exists('iconv') || $data == false) {
            // PHP (some 5.4 versions) mishandles //TRANSLIT//IGNORE and returns false: see https://bugs.php.net/bug.php?id=61484
            if ($data == false) {
                $data = $data_save;
            }
            if (function_exists('mb_convert_encoding')) {
                // Replace unknown characters with a space
                @ini_set('mbstring.substitute_character', '32');
                $data = @mb_convert_encoding($data, 'UTF-8', $charset[1]);
            } elseif (function_exists('recode_string')) {
                $data = @recode_string($charset[1] . '..' . 'UTF-8', $data);
            }
        }
    }
    $data = str_replace(array("\n", "\r", "\t"), '', $data);
    $data = preg_replace('~<\\!\\[CDATA\\[(.+?)\\]\\]>~eu', '\'#cdata_escape_encode#\' . Util::htmlspecialchars(\'$1\')', $data);
    // Find all the feed items
    preg_match_all('~<item>(.+?)</item>~', $data, $items);
    foreach ($items[1] as $item_id => $item) {
        if ($item_id === $count) {
            break;
        }
        preg_match_all('~<([A-Za-z]+)>(.+?)</\\1>~', $item, $match);
        foreach ($match[0] as $tag_id => $dummy) {
            if (Util::strpos($match[2][$tag_id], '#cdata_escape_encode#') === 0) {
                $match[2][$tag_id] = stripslashes(un_htmlspecialchars(Util::substr($match[2][$tag_id], 21)));
            }
            $rss[$item_id][strtolower($match[1][$tag_id])] = un_htmlspecialchars($match[2][$tag_id]);
        }
    }
    // Nothing, say its invalid
    if (empty($rss)) {
        echo '
								', $txt['error_sp_invalid_feed'];
        return;
    }
    // Add all the items to an array
    $items = array();
    foreach ($rss as $item) {
        $item['title'] = isset($item['title']) ? strip_tags($item['title']) : '';
        $item['description'] = isset($item['description']) ? strip_tags($item['description'], empty($strip_preserve) ? '' : '<' . implode('><', $strip_preserve) . '>') : '';
        $items[] = array('title' => $item['title'], 'href' => $item['link'], 'link' => $item['title'] == '' ? '' : ($item['link'] == '' ? $item['title'] : '<a href="' . $item['link'] . '" target="_blank" class="new_win">' . $item['title'] . '</a>'), 'content' => $limit > 0 ? Util::shorten_text($item['description'], $limit, true) : $item['description'], 'date' => !empty($item['pubdate']) ? standardTime(strtotime($item['pubdate']), '%d %B') : '');
    }
    // No items in the feed
    if (empty($items)) {
        echo '
								', $txt['error_sp_invalid_feed'];
        return;
    } else {
        $items[count($items) - 1]['is_last'] = true;
    }
    if ($show_content) {
        echo '
//.........这里部分代码省略.........
开发者ID:emanuele45,项目名称:SimplePortal_ElkArte,代码行数:101,代码来源:PortalBlocks.subs.php

示例9: daily_digest

    /**
     * Send out a daily email of all subscribed topics, to members.
     *
     * - It sends notifications about replies or new topics,
     * and moderation actions.
     */
    public function daily_digest()
    {
        global $is_weekly, $txt, $mbname, $scripturl, $modSettings, $boardurl;
        $db = database();
        // We'll want this...
        require_once SUBSDIR . '/Mail.subs.php';
        loadEssentialThemeData();
        // If the maillist function is on then so is the enhanced digest
        $maillist = !empty($modSettings['maillist_enabled']) && !empty($modSettings['maillist_digest_enabled']);
        if ($maillist) {
            require_once SUBSDIR . '/Emailpost.subs.php';
        }
        $is_weekly = !empty($is_weekly) ? 1 : 0;
        // Right - get all the notification data FIRST.
        $request = $db->query('', '
			SELECT ln.id_topic, COALESCE(t.id_board, ln.id_board) AS id_board, mem.email_address, mem.member_name, mem.real_name, mem.notify_types,
				mem.lngfile, mem.id_member
			FROM {db_prefix}log_notify AS ln
				INNER JOIN {db_prefix}members AS mem ON (mem.id_member = ln.id_member)
				LEFT JOIN {db_prefix}topics AS t ON (ln.id_topic != {int:empty_topic} AND t.id_topic = ln.id_topic)
			WHERE mem.notify_regularity = {int:notify_regularity}
				AND mem.is_activated = {int:is_activated}', array('empty_topic' => 0, 'notify_regularity' => $is_weekly ? '3' : '2', 'is_activated' => 1));
        $members = array();
        $langs = array();
        $notify = array();
        $boards = array();
        while ($row = $db->fetch_assoc($request)) {
            if (!isset($members[$row['id_member']])) {
                $members[$row['id_member']] = array('email' => $row['email_address'], 'name' => $row['real_name'] == '' ? $row['member_name'] : un_htmlspecialchars($row['real_name']), 'id' => $row['id_member'], 'notifyMod' => $row['notify_types'] < 3 ? true : false, 'lang' => $row['lngfile']);
                $langs[$row['lngfile']] = $row['lngfile'];
            }
            // Store this useful data!
            $boards[$row['id_board']] = $row['id_board'];
            if ($row['id_topic']) {
                $notify['topics'][$row['id_topic']][] = $row['id_member'];
            } else {
                $notify['boards'][$row['id_board']][] = $row['id_member'];
            }
        }
        $db->free_result($request);
        if (empty($boards)) {
            return true;
        }
        // Just get the board names.
        require_once SUBSDIR . '/Boards.subs.php';
        $boards = fetchBoardsInfo(array('boards' => $boards), array('override_permissions' => true));
        if (empty($boards)) {
            return true;
        }
        // Get the actual topics...
        $request = $db->query('', '
			SELECT ld.note_type, t.id_topic, t.id_board, t.id_member_started, m.id_msg, m.subject, m.body, ld.id_msg AS last_reply,
				b.name AS board_name, ml.body as last_body
			FROM {db_prefix}log_digest AS ld
				INNER JOIN {db_prefix}topics AS t ON (t.id_topic = ld.id_topic
					AND t.id_board IN ({array_int:board_list}))
				INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
				INNER JOIN {db_prefix}messages AS ml ON (ml.id_msg = ld.id_msg)
				INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
			WHERE ' . ($is_weekly ? 'ld.daily != {int:daily_value}' : 'ld.daily IN (0, 2)'), array('board_list' => array_keys($boards), 'daily_value' => 2));
        $types = array();
        while ($row = $db->fetch_assoc($request)) {
            if (!isset($types[$row['note_type']][$row['id_board']])) {
                $types[$row['note_type']][$row['id_board']] = array('lines' => array(), 'name' => un_htmlspecialchars($row['board_name']), 'id' => $row['id_board']);
            }
            // A reply has been made
            if ($row['note_type'] === 'reply') {
                // More than one reply to this topic?
                if (isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) {
                    $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['count']++;
                    // keep track of the highest numbered reply and body text for this topic ...
                    if ($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['body_id'] < $row['last_reply']) {
                        $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['body_id'] = $row['last_reply'];
                        $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']]['body_text'] = $row['last_body'];
                    }
                } else {
                    // First time we have seen a reply to this topic, so load our array
                    $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array('id' => $row['id_topic'], 'subject' => un_htmlspecialchars($row['subject']), 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.new;topicseen#new', 'count' => 1, 'body_id' => $row['last_reply'], 'body_text' => $row['last_body']);
                }
            } elseif ($row['note_type'] === 'topic') {
                if ($maillist) {
                    // Convert to markdown markup e.g. text ;)
                    pbe_prepare_text($row['body']);
                    $row['body'] = Util::shorten_text($row['body'], !empty($modSettings['digest_preview_length']) ? $modSettings['digest_preview_length'] : 375, true);
                    $row['body'] = preg_replace("~\n~s", "\n  ", $row['body']);
                }
                // Topics are simple since we are only concerned with the first post
                if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) {
                    $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array('id' => $row['id_topic'], 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.new;topicseen#new', 'subject' => un_htmlspecialchars($row['subject']), 'body' => $row['body']);
                }
            } elseif ($maillist && empty($modSettings['pbe_no_mod_notices'])) {
                if (!isset($types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']])) {
                    $types[$row['note_type']][$row['id_board']]['lines'][$row['id_topic']] = array('id' => $row['id_topic'], 'subject' => un_htmlspecialchars($row['subject']), 'starter' => $row['id_member_started']);
                }
//.........这里部分代码省略.........
开发者ID:Ralkage,项目名称:Elkarte,代码行数:101,代码来源:ScheduledTask.class.php

示例10: action_xmlrecent

 /**
  * Get the recent topics to display.
  * The returned array will be generated to match the xml_format.
  *
  * @param string $xml_format one of rss, rss2, rdf, atom
  * @return mixed[] of recent posts
  */
 public function action_xmlrecent($xml_format)
 {
     global $scripturl, $modSettings, $board;
     // Get the latest news
     require_once SUBSDIR . '/News.subs.php';
     $results = getXMLRecent($this->_query_this_board, $board, $this->_limit);
     // Loop on the results and prepare them in the format requested
     $data = array();
     foreach ($results as $row) {
         // Limit the length of the message, if the option is set.
         if (!empty($modSettings['xmlnews_maxlen']) && Util::strlen(str_replace('<br />', "\n", $row['body'])) > $modSettings['xmlnews_maxlen']) {
             $row['body'] = strtr(Util::shorten_text(str_replace('<br />', "\n", $row['body']), $modSettings['xmlnews_maxlen'], true), array("\n" => '<br />'));
         }
         $row['body'] = parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']);
         // You can't say that
         censorText($row['body']);
         censorText($row['subject']);
         // Doesn't work as well as news, but it kinda does..
         if ($xml_format == 'rss' || $xml_format == 'rss2') {
             $data[] = array('title' => $row['subject'], 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'], 'description' => cdata_parse(strtr(un_htmlspecialchars($row['body']), '&', '&#x26;')), 'author' => in_array(showEmailAddress(!empty($row['hide_email']), $row['id_member']), array('yes', 'yes_permission_override')) ? $row['poster_email'] . ' (' . un_htmlspecialchars($row['poster_name']) . ')' : '<![CDATA[none@noreply.net (' . un_htmlspecialchars($row['poster_name']) . ')]]>', 'category' => cdata_parse($row['bname']), 'comments' => $scripturl . '?action=post;topic=' . $row['id_topic'] . '.0', 'pubDate' => gmdate('D, d M Y H:i:s \\G\\M\\T', $row['poster_time']), 'guid' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg']);
             // Add the poster name on if we are rss2
             if ($xml_format == 'rss2') {
                 $data[count($data) - 1]['dc:creator'] = $row['poster_name'];
                 unset($data[count($data) - 1]['author']);
             }
         } elseif ($xml_format == 'rdf') {
             $data[] = array('title' => $row['subject'], 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'], 'description' => cdata_parse($row['body']));
         } elseif ($xml_format == 'atom') {
             $data[] = array('title' => $row['subject'], 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg'], 'summary' => cdata_parse($row['body']), 'category' => $row['bname'], 'author' => array('name' => $row['poster_name'], 'email' => in_array(showEmailAddress(!empty($row['hide_email']), $row['id_member']), array('yes', 'yes_permission_override')) ? $row['poster_email'] : null, 'uri' => !empty($row['id_member']) ? $scripturl . '?action=profile;u=' . $row['id_member'] : ''), 'published' => gmstrftime('%Y-%m-%dT%H:%M:%SZ', $row['poster_time']), 'updated' => gmstrftime('%Y-%m-%dT%H:%M:%SZ', empty($row['modified_time']) ? $row['poster_time'] : $row['modified_time']), 'id' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg']);
         } else {
             $data[] = array('time' => htmlspecialchars(strip_tags(standardTime($row['poster_time'])), ENT_COMPAT, 'UTF-8'), 'id' => $row['id_msg'], 'subject' => cdata_parse($row['subject']), 'body' => cdata_parse($row['body']), 'starter' => array('name' => cdata_parse($row['first_poster_name']), 'id' => $row['id_first_member'], 'link' => !empty($row['id_first_member']) ? $scripturl . '?action=profile;u=' . $row['id_first_member'] : ''), 'poster' => array('name' => cdata_parse($row['poster_name']), 'id' => $row['id_member'], 'link' => !empty($row['id_member']) ? $scripturl . '?action=profile;u=' . $row['id_member'] : ''), 'topic' => array('subject' => cdata_parse($row['first_subject']), 'id' => $row['id_topic'], 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.new#new'), 'board' => array('name' => cdata_parse($row['bname']), 'id' => $row['id_board'], 'link' => $scripturl . '?board=' . $row['id_board'] . '.0'), 'link' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#msg' . $row['id_msg']);
         }
     }
     return $data;
 }
开发者ID:KeiroD,项目名称:Elkarte,代码行数:42,代码来源:News.controller.php

示例11: _prepareDraftsContext

 /**
  * Loads in a group of post drafts for the user.
  * Loads a specific draft for current use in the postbox if selected.
  * Used in the posting screens to allow draft selection
  * Will load a draft if selected is supplied via post
  *
  * @param int $member_id
  * @param int|false $id_topic if set, load drafts for the specified topic
  * @return false|null
  */
 private function _prepareDraftsContext($member_id, $id_topic = false)
 {
     global $scripturl, $context, $txt, $modSettings;
     $context['drafts'] = array();
     // Need a member
     if (empty($member_id)) {
         return false;
     }
     // We haz drafts
     loadLanguage('Drafts');
     require_once SUBSDIR . '/Drafts.subs.php';
     // has a specific draft has been selected?  Load it up if there is not already a message already in the editor
     if (isset($_REQUEST['id_draft']) && empty($_POST['subject']) && empty($_POST['message'])) {
         loadDraft((int) $_REQUEST['id_draft'], 0, true, true);
     }
     // load all the drafts for this user that meet the criteria
     $order = 'poster_time DESC';
     $user_drafts = load_user_drafts($member_id, 0, $id_topic, $order);
     // Add them to the context draft array for template display
     foreach ($user_drafts as $draft) {
         $short_subject = empty($draft['subject']) ? $txt['drafts_none'] : Util::shorten_text(stripslashes($draft['subject']), !empty($modSettings['draft_subject_length']) ? $modSettings['draft_subject_length'] : 24);
         $context['drafts'][] = array('subject' => censorText($short_subject), 'poster_time' => standardTime($draft['poster_time']), 'link' => '<a href="' . $scripturl . '?action=post;board=' . $draft['id_board'] . ';' . (!empty($draft['id_topic']) ? 'topic=' . $draft['id_topic'] . '.0;' : '') . 'id_draft=' . $draft['id_draft'] . '">' . (!empty($draft['subject']) ? $draft['subject'] : $txt['drafts_none']) . '</a>');
     }
 }
开发者ID:Ralkage,项目名称:Elkarte,代码行数:34,代码来源:Post.controller.php

示例12: action_messageindex


//.........这里部分代码省略.........
     // Trick
     $txt['starter'] = $txt['started_by'];
     foreach ($sort_methods as $key => $val) {
         $context['topics_headers'][$key] = array('url' => $scripturl . '?board=' . $context['current_board'] . '.' . $context['start'] . ';sort=' . $key . ($context['sort_by'] == $key && $context['sort_direction'] == 'up' ? ';desc' : ''), 'sort_dir_img' => $context['sort_by'] == $key ? '<img class="sort" src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.png" alt="" title="' . $context['sort_title'] . '" />' : '');
     }
     // Calculate the fastest way to get the topics.
     $start = (int) $_REQUEST['start'];
     if ($start > ($board_info['total_topics'] - 1) / 2) {
         $ascending = !$ascending;
         $fake_ascending = true;
         $maxindex = $board_info['total_topics'] < $start + $maxindex + 1 ? $board_info['total_topics'] - $start : $maxindex;
         $start = $board_info['total_topics'] < $start + $maxindex + 1 ? 0 : $board_info['total_topics'] - $start - $maxindex;
     } else {
         $fake_ascending = false;
     }
     // Setup the default topic icons...
     $context['icon_sources'] = MessageTopicIcons();
     $topic_ids = array();
     $context['topics'] = array();
     // Set up the query options
     $indexOptions = array('include_sticky' => !empty($modSettings['enableStickyTopics']), 'only_approved' => $modSettings['postmod_active'] && !allowedTo('approve_posts'), 'previews' => !empty($modSettings['message_index_preview']) ? empty($modSettings['preview_characters']) ? -1 : $modSettings['preview_characters'] : 0, 'include_avatars' => !empty($settings['avatars_on_indexes']), 'ascending' => $ascending, 'fake_ascending' => $fake_ascending);
     // Allow integration to modify / add to the $indexOptions
     call_integration_hook('integrate_messageindex_topics', array(&$sort_column, &$indexOptions));
     $topics_info = messageIndexTopics($board, $user_info['id'], $start, $maxindex, $context['sort_by'], $sort_column, $indexOptions);
     // Prepare for links to guests (for search engines)
     $context['pageindex_multiplier'] = empty($modSettings['disableCustomPerPage']) && !empty($options['messages_per_page']) ? $options['messages_per_page'] : $modSettings['defaultMaxMessages'];
     // Begin 'printing' the message index for current board.
     foreach ($topics_info as $row) {
         $topic_ids[] = $row['id_topic'];
         // Do they want message previews?
         if (!empty($modSettings['message_index_preview'])) {
             // Limit them to $modSettings['preview_characters'] characters
             $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.
         if ($row['num_replies'] + 1 > $context['messages_per_page']) {
             // We can't pass start by reference.
             $start = -1;
开发者ID:KeiroD,项目名称:Elkarte,代码行数:67,代码来源:MessageIndex.controller.php

示例13: action_unread


//.........这里部分代码省略.........
            }
            $db->free_result($request);
            // Sanity... where have you gone?
            if (empty($topics)) {
                $context['topics'] = array();
                if ($context['querystring_board_limits'] == ';start=%d') {
                    $context['querystring_board_limits'] = '';
                } else {
                    $context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']);
                }
                return;
            }
            $request = $db->query('substring', '
				SELECT ' . $select_clause . '
				FROM {db_prefix}topics AS t
					INNER JOIN {db_prefix}messages AS ms ON (ms.id_topic = t.id_topic AND ms.id_msg = t.id_first_msg)
					INNER JOIN {db_prefix}messages AS ml ON (ml.id_msg = t.id_last_msg)
					INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
					LEFT JOIN {db_prefix}members AS mems ON (mems.id_member = ms.id_member)
					LEFT JOIN {db_prefix}members AS meml ON (meml.id_member = ml.id_member)
					LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = t.id_topic AND lt.id_member = {int:current_member})
					LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = t.id_board AND lmr.id_member = {int:current_member})
				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) {
开发者ID:scripple,项目名称:Elkarte,代码行数:67,代码来源:Recent.controller.php


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