Пример #1
0
function pretty_boards_test()
{
    global $scripturl, $txt;
    // Get the 3 top boards
    $boards = ssi_topBoards(3, 'array');
    $return = array();
    foreach ($boards as $board) {
        $return[] = $board['link'];
    }
    return $return;
}
Пример #2
0
function TPortal_ssi()
{
    global $context;
    echo '
	<div style="padding: 5px;" class="smalltext">';
    if ($context['TPortal']['ssifunction'] == 'topboards') {
        ssi_topBoards();
    } elseif ($context['TPortal']['ssifunction'] == 'topposters') {
        ssi_topPoster(5);
    } elseif ($context['TPortal']['ssifunction'] == 'topreplies') {
        ssi_topTopicsReplies();
    } elseif ($context['TPortal']['ssifunction'] == 'topviews') {
        ssi_topTopicsViews();
    } elseif ($context['TPortal']['ssifunction'] == 'calendar') {
        ssi_todaysCalendar();
    }
    echo '
    </div>';
}
function sp_topBoards($parameters, $id, $return_parameters = false)
{
    global $context, $settings, $smcFunc, $txt, $scripturl, $user_info, $user_info, $modSettings, $boards;
    $block_parameters = array('limit' => 'int');
    if ($return_parameters) {
        return $block_parameters;
    }
    $limit = !empty($parameters['limit']) ? $parameters['limit'] : 5;
    $boards = ssi_topBoards($limit, 'array');
    if (empty($boards)) {
        echo '
								', $txt['error_sp_no_boards_found'];
        return;
    } else {
        $boards[count($boards) - 1]['is_last'] = true;
    }
    echo '
								<ul class="sp_list">';
    foreach ($boards as $board) {
        echo '
									<li class="sp_list_top">', sp_embed_image('board'), ' ', $board['link'], '</li>
									<li class="sp_list_indent', empty($board['is_last']) ? ' sp_list_bottom' : '', ' smalltext">', $txt['topics'], ': ', comma_format($board['num_topics']), ' | ', $txt['posts'], ': ', comma_format($board['num_posts']), '</li>';
    }
    echo '
								</ul>';
}
ssi_recentPoll();
flush();
?>
</div>
			</div>

<!-- TOP ITEMS -->
			<div class="ssi_preview" id="ssi_topBoards">
				<h2>Top Boards Function</h2>
				<p>Shows top boards by the number of posts.</p>

				<h3>Code</h3>
				<div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code">&lt;?php ssi_topBoards(); ?&gt;</code>
				<h3>Result</h3>
				<div class="ssi_result"><?php 
ssi_topBoards();
flush();
?>
</div>
			</div>

			<div class="ssi_preview" id="ssi_topTopicsViews">
				<h2>Top Topics</h2>
				<p>Shows top topics by the number of replies or views.</p>

				<h3>Code (show by number of views)</h3>
				<div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code">&lt;?php ssi_topTopicsViews(); ?&gt;</code>
				<h3>Result</h3>
				<div class="ssi_result"><?php 
ssi_topTopicsViews();
flush();
/**
 * Top Boards Block, shows top boards by number of posts
 *
 * @param mixed[] $parameters
 *		'limit' => number of boards 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_topBoards($parameters, $id, $return_parameters = false)
{
    global $txt, $user_info, $user_info, $boards;
    $block_parameters = array('limit' => 'int');
    if ($return_parameters) {
        return $block_parameters;
    }
    // Use ssi to get the top boards
    $limit = !empty($parameters['limit']) ? $parameters['limit'] : 5;
    $boards = ssi_topBoards($limit, 'array');
    if (empty($boards)) {
        echo '
								', $txt['error_sp_no_boards_found'];
        return;
    } else {
        end($boards);
        $boards[key($boards)]['is_last'] = true;
    }
    echo '
								<ul class="sp_list">';
    foreach ($boards as $board) {
        echo '
									<li ', sp_embed_class('board', '', 'sp_list_top'), '>', $board['link'], '
									</li>
									<li class="sp_list_indent', empty($board['is_last']) ? ' sp_list_bottom' : '', ' smalltext">', empty($board['num_topics']) && !empty($board['num_posts']) ? $txt['redirects'] : $txt['topics'] . ': ' . $board['num_topics'] . ' | ' . $txt['posts'], ': ', $board['num_posts'], '
									</li>';
    }
    echo '
								</ul>';
}
 /**
  * Short description
  *
  * Long description
  *
  * @param
  * @return
  */
 protected function show_topBoards()
 {
     try {
         $this->loadSSI();
     } catch (Exception $e) {
         throw new \Exception($e->getMessage());
     }
     if ('echo' == $this->output_method) {
         ob_start();
         ssi_topBoards($this->num_top, $this->output_method);
         $this->data = ob_get_contents();
         ob_end_clean();
     } else {
         $this->data = ssi_topBoards($this->num_top, $this->output_method);
     }
 }