123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294 |
- <?php
- /**
- * Simple Machines Forum (SMF)
- *
- * @package SMF
- * @author Simple Machines
- * @copyright 2014 Simple Machines and individual contributors
- * @license http://www.simplemachines.org/about/smf/license.php BSD
- *
- * @version 2.1 Alpha 1
- */
- function template_show_list($list_id = null)
- {
- global $context, $scripturl, $txt, $modSettings;
- // Get a shortcut to the current list.
- $list_id = $list_id === null ? (!empty($context['default_list']) ? $context['default_list'] : '') : $list_id;
- if (empty($list_id) || empty($context[$list_id]))
- return;
- $cur_list = &$context[$list_id];
- // These are the main tabs that is used all around the template.
- if (isset($cur_list['list_menu'], $cur_list['list_menu']['show_on']) && ($cur_list['list_menu']['show_on'] == 'both' || $cur_list['list_menu']['show_on'] == 'top'))
- template_create_list_menu($cur_list['list_menu'], 'top');
- if (isset($cur_list['form']))
- echo '
- <form class="generic_list_wrapper" action="', $cur_list['form']['href'], '" method="post"', empty($cur_list['form']['name']) ? '' : ' name="' . $cur_list['form']['name'] . '" id="' . $cur_list['form']['name'] . '"', ' accept-charset="', $context['character_set'], '">
- <div class="generic_list">';
- else
- echo '
- <div class="generic_list_wrapper">';
- // Show the title of the table (if any).
- if (!empty($cur_list['title']))
- echo '
- <div class="cat_bar clear_right">
- <h3 class="catbg">
- ', $cur_list['title'], '
- </h3>
- </div>';
- if (isset($cur_list['additional_rows']['after_title']))
- {
- echo '
- <div class="information flow_hidden">';
- template_additional_rows('after_title', $cur_list);
- echo '
- </div>';
- }
- if (isset($cur_list['additional_rows']['top_of_list']))
- template_additional_rows('top_of_list', $cur_list);
- if ((!empty($cur_list['items_per_page']) && !empty($cur_list['page_index'])) || isset($cur_list['additional_rows']['above_column_headers']))
- {
- echo '
- <div class="flow_auto">';
- // Show the page index (if this list doesn't intend to show all items).
- if (!empty($cur_list['items_per_page']) && !empty($cur_list['page_index']))
- echo '
- <div class="floatleft">
- <div class="pagesection">', $cur_list['page_index'], '</div>
- </div>';
- if (isset($cur_list['additional_rows']['above_column_headers']))
- template_additional_rows('above_column_headers', $cur_list);
- echo '
- </div>';
- }
- echo '
- <table class="table_grid" cellspacing="0"', !empty($cur_list['width']) ? ' style="width:' . $cur_list['width'] . '"' : '', '>';
- // Show the column headers.
- $header_count = count($cur_list['headers']);
- if (!($header_count < 2 && empty($cur_list['headers'][0]['label'])))
- {
- echo '
- <thead>
- <tr class="catbg">';
- // Loop through each column and add a table header.
- $i = 0;
- foreach ($cur_list['headers'] as $col_header)
- {
- $i ++;
- if ($i === 1)
- $col_header['class'] = empty($col_header['class']) ? 'first_th' : 'first_th ' . $col_header['class'];
- elseif ($i === $header_count)
- $col_header['class'] = empty($col_header['class']) ? 'last_th' : 'last_th ' . $col_header['class'];
- echo '
- <th scope="col" id="header_', $list_id, '_', $col_header['id'], '"', empty($col_header['class']) ? '' : ' class="' . $col_header['class'] . '"', empty($col_header['style']) ? '' : ' style="' . $col_header['style'] . '"', empty($col_header['colspan']) ? '' : ' colspan="' . $col_header['colspan'] . '"', '>', empty($col_header['href']) ? '' : '<a href="' . $col_header['href'] . '" rel="nofollow">', empty($col_header['label']) ? ' ' : $col_header['label'], empty($col_header['href']) ? '' : (empty($col_header['sort_image']) ? '</a>' : ' <span class="sort sort_' . $col_header['sort_image'] . '"></span></a>'), '</th>';
- }
- echo '
- </tr>
- </thead>';
- }
- echo '
- <tbody>';
- // Show a nice message informing there are no items in this list.
- if (empty($cur_list['rows']) && !empty($cur_list['no_items_label']))
- echo '
- <tr>
- <td class="windowbg" colspan="', $cur_list['num_columns'], '" align="', !empty($cur_list['no_items_align']) ? $cur_list['no_items_align'] : 'center', '"><div class="padding">', $cur_list['no_items_label'], '</div></td>
- </tr>';
- // Show the list rows.
- elseif (!empty($cur_list['rows']))
- {
- $alternate = false;
- foreach ($cur_list['rows'] as $id => $row)
- {
- echo '
- <tr class="windowbg', $alternate ? '2' : '', $row['class'], '"', $row['style'], ' id="list_', $list_id, '_', $id, '">';
- foreach ($row['data'] as $row_data)
- echo '
- <td', empty($row_data['class']) ? '' : ' class="' . $row_data['class'] . '"', empty($row_data['style']) ? '' : ' style="' . $row_data['style'] . '"', '>', $row_data['value'], '</td>';
- echo '
- </tr>';
- $alternate = !$alternate;
- }
- }
- echo '
- </tbody>
- </table>';
- if ((!empty($cur_list['items_per_page']) && !empty($cur_list['page_index'])) || isset($cur_list['additional_rows']['below_table_data']))
- {
- echo '
- <div class="flow_auto">';
- // Show the page index (if this list doesn't intend to show all items).
- if (!empty($cur_list['items_per_page']) && !empty($cur_list['page_index']))
- echo '
- <div class="floatleft">
- <div class="pagesection">', $cur_list['page_index'], '</div>
- </div>';
- if (isset($cur_list['additional_rows']['below_table_data']))
- template_additional_rows('below_table_data', $cur_list);
- echo '
- </div>';
- }
- if (isset($cur_list['additional_rows']['bottom_of_list']))
- template_additional_rows('bottom_of_list', $cur_list);
- if (isset($cur_list['form']))
- {
- foreach ($cur_list['form']['hidden_fields'] as $name => $value)
- echo '
- <input type="hidden" name="', $name, '" value="', $value, '">';
- echo '
- </div>
- </form>';
- }
- else
- echo '
- </div>';
- // Tabs at the bottom. Usually bottom alligned.
- if (isset($cur_list['list_menu'], $cur_list['list_menu']['show_on']) && ($cur_list['list_menu']['show_on'] == 'both' || $cur_list['list_menu']['show_on'] == 'bottom'))
- template_create_list_menu($cur_list['list_menu'], 'bottom');
- if (isset($cur_list['javascript']))
- echo '
- <script><!-- // --><![CDATA[
- ', $cur_list['javascript'], '
- // ]]></script>';
- }
- function template_additional_rows($row_position, $cur_list)
- {
- foreach ($cur_list['additional_rows'][$row_position] as $row)
- echo '
- <div class="additional_row', empty($row['class']) ? '' : ' ' . $row['class'], '"', empty($row['style']) ? '' : ' style="' . $row['style'] . '"', '>', $row['value'], '</div>';
- }
- function template_create_list_menu($list_menu, $direction = 'top')
- {
- global $context;
- /**
- // This is use if you want your generic lists to have tabs.
- $cur_list['list_menu'] = array(
- // This is the style to use. Tabs or Buttons (Text 1 | Text 2).
- // By default tabs are selected if not set.
- // The main difference between tabs and buttons is that tabs get highlighted if selected.
- // If style is set to buttons and use tabs is diabled then we change the style to old styled tabs.
- 'style' => 'tabs',
- // The posisiton of the tabs/buttons. Left or Right. By default is set to left.
- 'position' => 'left',
- // This is used by the old styled menu. We *need* to know the total number of columns to span.
- 'columns' => 0,
- // This gives you the option to show tabs only at the top, bottom or both.
- // By default they are just shown at the top.
- 'show_on' => 'top',
- // Links. This is the core of the array. It has all the info that we need.
- 'links' => array(
- 'name' => array(
- // This will tell use were to go when they click it.
- 'href' => $scripturl . '?action=theaction',
- // The name that you want to appear for the link.
- 'label' => $txt['name'],
- // If we use tabs instead of buttons we highlight the current tab.
- // Must use conditions to determine if its selected or not.
- 'is_selected' => isset($_REQUEST['name']),
- ),
- ),
- );
- */
- // Are we using right-to-left orientation?
- $first = $context['right_to_left'] ? 'last' : 'first';
- $last = $context['right_to_left'] ? 'first' : 'last';
- if (!isset($list_menu['style']) || isset($list_menu['style']) && $list_menu['style'] == 'tabs')
- {
- echo '
- <table cellpadding="0" cellspacing="0" style="margin-', $list_menu['position'], ': 10px; width: 100%;">
- <tr>', $list_menu['position'] == 'right' ? '
- <td> </td>' : '', '
- <td align="', $list_menu['position'], '">
- <table cellspacing="0" cellpadding="0">
- <tr>
- <td class="', $direction == 'top' ? 'mirror' : 'main', 'tab_', $first, '"> </td>';
- foreach ($list_menu['links'] as $link)
- {
- if ($link['is_selected'])
- echo '
- <td class="', $direction == 'top' ? 'mirror' : 'main', 'tab_active_', $first, '"> </td>
- <td valign="top" class="', $direction == 'top' ? 'mirrortab' : 'maintab', '_active_back">
- <a href="', $link['href'], '">', $link['label'], '</a>
- </td>
- <td class="', $direction == 'top' ? 'mirror' : 'main', 'tab_active_', $last, '"> </td>';
- else
- echo '
- <td valign="top" class="', $direction == 'top' ? 'mirror' : 'main', 'tab_back">
- <a href="', $link['href'], '">', $link['label'], '</a>
- </td>';
- }
- echo '
- <td class="', $direction == 'top' ? 'mirror' : 'main', 'tab_', $last, '"> </td>
- </tr>
- </table>
- </td>', $list_menu['position'] == 'left' ? '
- <td> </td>' : '', '
- </tr>
- </table>';
- }
- elseif (isset($list_menu['style']) && $list_menu['style'] == 'buttons')
- {
- $links = array();
- foreach ($list_menu['links'] as $link)
- $links[] = '<a href="' . $link['href'] . '">' . $link['label'] . '</a>';
- echo '
- <table cellpadding="0" cellspacing="0" style="margin-', $list_menu['position'], ': 10px; width: 100%;">
- <tr>', $list_menu['position'] == 'right' ? '
- <td> </td>' : '', '
- <td align="', $list_menu['position'], '">
- <table cellspacing="0" cellpadding="0">
- <tr>
- <td class="', $direction == 'top' ? 'mirror' : 'main', 'tab_', $first, '"> </td>
- <td class="', $direction == 'top' ? 'mirror' : 'main', 'tab_back">', implode(' | ', $links), '</td>
- <td class="', $direction == 'top' ? 'mirror' : 'main', 'tab_', $last, '"> </td>
- </tr>
- </table>
- </td>', $list_menu['position'] == 'left' ? '
- <td> </td>' : '', '
- </tr>
- </table>';
- }
- }
- ?>
|