/**
  * Show the Block List.
  */
 public function action_sportal_admin_block_list()
 {
     global $txt, $context, $scripturl;
     // We have 6 sides...like a cube!
     $context['sides'] = array('header' => array('id' => '5', 'name' => 'adminHeader', 'label' => $txt['sp-positionHeader'], 'help' => 'sp-blocksHeaderList'), 'left' => array('id' => '1', 'name' => 'adminLeft', 'label' => $txt['sp-positionLeft'], 'help' => 'sp-blocksLeftList'), 'top' => array('id' => '2', 'name' => 'adminTop', 'label' => $txt['sp-positionTop'], 'help' => 'sp-blocksTopList'), 'bottom' => array('id' => '3', 'name' => 'adminBottom', 'label' => $txt['sp-positionBottom'], 'help' => 'sp-blocksBottomList'), 'right' => array('id' => '4', 'name' => 'adminRight', 'label' => $txt['sp-positionRight'], 'help' => 'sp-blocksRightList'), 'footer' => array('id' => '6', 'name' => 'adminFooter', 'label' => $txt['sp-positionFooter'], 'help' => 'sp-blocksFooterList'));
     $sides = array('header', 'left', 'top', 'bottom', 'right', 'footer');
     // Are we viewing any of the sub lists for an individual side?
     if (in_array($context['sub_action'], $sides)) {
         // Remove any sides that we don't need to show. ;)
         foreach ($sides as $side) {
             if ($context['sub_action'] != $side) {
                 unset($context['sides'][$side]);
             }
         }
         $context['sp_blocks_single_side_list'] = true;
     }
     // Columns to show.
     $context['columns'] = array('label' => array('width' => '40%', 'label' => $txt['sp-adminColumnName'], 'class' => 'first_th'), 'type' => array('width' => '40%', 'label' => $txt['sp-adminColumnType']), 'action' => array('width' => '20%', 'label' => $txt['sp-adminColumnAction'], 'class' => 'centertext last_th'));
     // Get the block info for each side.
     foreach ($context['sides'] as $side_id => $side) {
         $context['blocks'][$side['name']] = getBlockInfo($side['id']);
         foreach ($context['blocks'][$side['name']] as $block_id => $block) {
             $context['sides'][$side_id]['last'] = $block_id;
             $context['blocks'][$side['name']][$block_id]['actions'] = array('state_icon' => empty($block['state']) ? '<a href="' . $scripturl . '?action=admin;area=portalblocks;sa=statechange;' . (empty($context['sp_blocks_single_side_list']) ? '' : 'redirect=' . $block['column'] . ';') . 'block_id=' . $block['id'] . ';type=block;' . $context['session_var'] . '=' . $context['session_id'] . '">' . sp_embed_image('deactive', $txt['sp-blocksActivate']) . '</a>' : '<a href="' . $scripturl . '?action=admin;area=portalblocks;sa=statechange;' . (empty($context['sp_blocks_single_side_list']) ? '' : 'redirect=' . $block['column'] . ';') . 'block_id=' . $block['id'] . ';type=block;' . $context['session_var'] . '=' . $context['session_id'] . '">' . sp_embed_image('active', $txt['sp-blocksDeactivate']) . '</a>', 'edit' => '&nbsp;<a href="' . $scripturl . '?action=admin;area=portalblocks;sa=edit;block_id=' . $block['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '">' . sp_embed_image('modify') . '</a>', 'delete' => '&nbsp;<a href="' . $scripturl . '?action=admin;area=portalblocks;sa=delete;block_id=' . $block['id'] . ';col=' . $block['column'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" onclick="return confirm(\'' . $txt['sp-deleteblock'] . '\');">' . sp_embed_image('delete') . '</a>');
         }
     }
     // Call the sub template.
     createToken('admin-sort', 'post');
     $context['sub_template'] = 'block_list';
     $context['page_title'] = $txt['sp-adminBlockListName'];
 }
    /**
     * Show page listing of all permission groups in the system
     */
    public function action_sportal_admin_permission_profiles_list()
    {
        global $context, $scripturl, $txt, $modSettings;
        // Removing some permission profiles?
        if (!empty($_POST['remove_profiles']) && !empty($_POST['remove']) && is_array($_POST['remove'])) {
            checkSession();
            $remove = array();
            foreach ($_POST['remove'] as $index => $profile_id) {
                $remove[(int) $index] = (int) $profile_id;
            }
            sp_delete_profiles($remove);
        }
        // Build the listoption array to display the permission profiles
        $listOptions = array('id' => 'portal_permisssions', 'title' => $txt['sp_admin_permission_profiles_list'], 'items_per_page' => $modSettings['defaultMaxMessages'], 'no_items_label' => $txt['error_sp_no_articles'], 'base_href' => $scripturl . '?action=admin;area=portalprofiles;sa=listpermission;', 'default_sort_col' => 'name', 'get_items' => array('function' => array($this, 'list_spLoadProfiles')), 'get_count' => array('function' => array($this, 'list_spCountProfiles')), 'columns' => array('name' => array('header' => array('value' => $txt['sp_admin_profiles_col_name']), 'data' => array('db' => 'label'), 'sort' => array('default' => 'name', 'reverse' => 'name DESC')), 'articles' => array('header' => array('value' => $txt['sp_admin_profiles_col_articles'], 'class' => 'centertext'), 'data' => array('function' => create_function('$row', '
							return empty($row[\'articles\']) ? \'0\' : $row[\'articles\'];
						'), 'class' => 'centertext')), 'blocks' => array('header' => array('value' => $txt['sp_admin_profiles_col_blocks'], 'class' => 'centertext'), 'data' => array('function' => create_function('$row', '
							return empty($row[\'blocks\']) ? \'0\' : $row[\'blocks\'];
						'), 'class' => 'centertext')), 'categories' => array('header' => array('value' => $txt['sp_admin_profiles_col_categories'], 'class' => 'centertext'), 'data' => array('function' => create_function('$row', '
							return empty($row[\'categories\']) ? \'0\' : $row[\'categories\'];
						'), 'class' => 'centertext')), 'pages' => array('header' => array('value' => $txt['sp_admin_profiles_col_pages'], 'class' => 'centertext'), 'data' => array('function' => create_function('$row', '
							return empty($row[\'pages\']) ? \'0\' : $row[\'pages\'];
						'), 'class' => 'centertext')), 'shoutboxes' => array('header' => array('value' => $txt['sp_admin_profiles_col_shoutboxes'], 'class' => 'centertext'), 'data' => array('function' => create_function('$row', '
							return empty($row[\'shoutboxes\']) ? \'0\' : $row[\'shoutboxes\'];
						'), 'class' => 'centertext')), 'action' => array('header' => array('value' => $txt['sp_admin_articles_col_actions'], 'class' => 'centertext'), 'data' => array('sprintf' => array('format' => '<a href="?action=admin;area=portalprofiles;sa=editpermission;profile_id=%1$s;' . $context['session_var'] . '=' . $context['session_id'] . '" accesskey="e">' . sp_embed_image('modify') . '</a>&nbsp;
								<a href="?action=admin;area=portalprofiles;sa=deletepermission;profile_id=%1$s;' . $context['session_var'] . '=' . $context['session_id'] . '" onclick="return confirm(' . JavaScriptEscape($txt['sp_admin_articles_delete_confirm']) . ') && submitThisOnce(this);" accesskey="d">' . sp_embed_image('delete') . '</a>', 'params' => array('id' => true)), 'class' => 'centertext', 'style' => "width: 40px")), 'check' => array('header' => array('value' => '<input type="checkbox" onclick="invertAll(this, this.form);" class="input_check" />', 'class' => 'centertext'), 'data' => array('function' => create_function('$row', '
							return \'<input type="checkbox" name="remove[]" value="\' . $row[\'id\'] . \'" class="input_check" />\';
						'), 'class' => 'centertext'))), 'form' => array('href' => $scripturl . '?action=admin;area=portalprofiles;sa=listpermission', 'include_sort' => true, 'include_start' => true, 'hidden_fields' => array($context['session_var'] => $context['session_id'])));
        // Set the context values
        $context['page_title'] = $txt['sp_admin_permission_profiles_list'];
        $context['sub_template'] = 'show_list';
        $context['default_list'] = 'portal_permisssions';
        // Create the list.
        require_once SUBSDIR . '/GenericList.class.php';
        createList($listOptions);
    }
예제 #3
0
/**
 * @package SimplePortal
 *
 * @author SimplePortal Team
 * @copyright 2014 SimplePortal Team
 * @license BSD 3-clause
 *
 * @version 2.3.6
 */
function template_portal_above()
{
    global $context, $modSettings, $settings;
    if (empty($modSettings['sp_disable_side_collapse']) && ($context['SPortal']['sides'][1]['active'] || $context['SPortal']['sides'][4]['active'])) {
        echo '
	<div class="sp_right sp_fullwidth', !empty($settings['sphidepanels']) ? ' whide' : '', '">';
        if ($context['SPortal']['sides'][1]['active']) {
            echo '
		<a href="#side" onclick="return sp_collapseSide(1)">', sp_embed_image($context['SPortal']['sides'][1]['collapsed'] ? 'expand' : 'collapse', '', null, null, true, 'sp_collapse_side1'), '</a>';
        }
        if ($context['SPortal']['sides'][4]['active']) {
            echo '
		<a href="#side" onclick="return sp_collapseSide(4)">', sp_embed_image($context['SPortal']['sides'][4]['collapsed'] ? 'expand' : 'collapse', '', null, null, true, 'sp_collapse_side4'), '</a>';
        }
        echo '
	</div>';
    }
    if (!empty($context['SPortal']['blocks'][5])) {
        echo '
	<div id="sp_header" class="', !empty($settings['sphidepanels']) ? ' whide' : '', '">';
        foreach ($context['SPortal']['blocks'][5] as $block) {
            template_block($block);
        }
        echo '
	</div>';
    }
    echo '
	<div id="sp_main" class="bwtable" >
		<div class="bwrow">';
    if (!empty($modSettings['showleft']) && !empty($context['SPortal']['blocks'][1])) {
        echo '
			<div id="sp_left" class="bwcol w', !empty($settings['spleftwidth']) ? $settings['spleftwidth'] : '4', ' ', !empty($settings['sphidepanels']) ? ' whide' : '', '" ', $context['SPortal']['sides'][1]['collapsed'] && empty($modSettings['sp_disable_side_collapse']) ? 'style="display: none;"' : '', '>
				<div class="gutter_left', !empty($settings['spgutter']) ? $settings['spgutter'] : 0, '">';
        foreach ($context['SPortal']['blocks'][1] as $block) {
            template_block($block);
        }
        echo '
				</div>
			</div>';
    }
    echo '
			<div id="sp_center" class="bwcol">';
    if (!empty($context['SPortal']['blocks'][2])) {
        echo '
				<div class="', !empty($settings['sphidepanels']) ? ' whide' : '', '">';
        foreach ($context['SPortal']['blocks'][2] as $block) {
            template_block($block);
        }
        if (empty($context['SPortal']['on_portal'])) {
            echo '
				<br class="sp_side_clear" />';
        }
        echo '</div>';
    }
}
function template_portal_above()
{
    global $context, $modSettings;
    if (empty($modSettings['sp_disable_side_collapse']) && ($context['SPortal']['sides'][1]['active'] || $context['SPortal']['sides'][4]['active'])) {
        echo '
	<div class="sp_right sp_fullwidth">';
        if ($context['SPortal']['sides'][1]['active']) {
            echo '
		<a href="#side" onclick="return sp_collapseSide(1)">', sp_embed_image($context['SPortal']['sides'][1]['collapsed'] ? 'expand' : 'collapse', '', null, null, true, 'sp_collapse_side1'), '</a>';
        }
        if ($context['SPortal']['sides'][4]['active']) {
            echo '
		<a href="#side" onclick="return sp_collapseSide(4)">', sp_embed_image($context['SPortal']['sides'][4]['collapsed'] ? 'expand' : 'collapse', '', null, null, true, 'sp_collapse_side4'), '</a>';
        }
        echo '
	</div>';
    }
    if (!empty($context['SPortal']['blocks'][5])) {
        echo '
	<div id="sp_header">';
        foreach ($context['SPortal']['blocks'][5] as $block) {
            template_block($block);
        }
        echo '
	</div>';
    }
    echo '
	<table id="sp_main">
		<tr>';
    if (!empty($modSettings['showleft']) && !empty($context['SPortal']['blocks'][1])) {
        echo '
			<td id="sp_left"', !empty($modSettings['leftwidth']) ? ' width="' . $modSettings['leftwidth'] . '"' : '', $context['SPortal']['sides'][1]['collapsed'] && empty($modSettings['sp_disable_side_collapse']) ? ' style="display: none;"' : '', '>';
        foreach ($context['SPortal']['blocks'][1] as $block) {
            template_block($block);
        }
        echo '
			</td>';
    }
    echo '
			<td id="sp_center">';
    if (!empty($context['SPortal']['blocks'][2])) {
        foreach ($context['SPortal']['blocks'][2] as $block) {
            template_block($block);
        }
        if (empty($context['SPortal']['on_portal'])) {
            echo '
				<br class="sp_side_clear" />';
        }
    }
}
    /**
     * Show a listing of articles in the system
     */
    public function action_sportal_admin_article_list()
    {
        global $context, $scripturl, $txt, $modSettings;
        // Build the listoption array to display the categories
        $listOptions = array('id' => 'portal_articles', 'title' => $txt['sp_admin_articles_list'], 'items_per_page' => $modSettings['defaultMaxMessages'], 'no_items_label' => $txt['error_sp_no_articles'], 'base_href' => $scripturl . '?action=admin;area=portalarticles;sa=list;', 'default_sort_col' => 'title', 'get_items' => array('function' => array($this, 'list_spLoadArticles')), 'get_count' => array('function' => array($this, 'list_spCountArticles')), 'columns' => array('title' => array('header' => array('value' => $txt['sp_admin_articles_col_title']), 'data' => array('db' => 'title'), 'sort' => array('default' => 'title', 'reverse' => 'title DESC')), 'namespace' => array('header' => array('value' => $txt['sp_admin_articles_col_namespace']), 'data' => array('db' => 'article_id'), 'sort' => array('default' => 'article_namespace', 'reverse' => 'article_namespace DESC')), 'category' => array('header' => array('value' => $txt['sp_admin_articles_col_category']), 'data' => array('db' => 'category_name'), 'sort' => array('default' => 'name', 'reverse' => 'name DESC')), 'author' => array('header' => array('value' => $txt['sp_admin_articles_col_author']), 'data' => array('db' => 'author_name'), 'sort' => array('default' => 'author_name', 'reverse' => 'author_name DESC')), 'type' => array('header' => array('value' => $txt['sp_admin_articles_col_type']), 'data' => array('db' => 'type'), 'sort' => array('default' => 'type', 'reverse' => 'type DESC')), 'date' => array('header' => array('value' => $txt['sp_admin_articles_col_date']), 'data' => array('db' => 'date'), 'sort' => array('default' => 'date', 'reverse' => 'date DESC')), 'status' => array('header' => array('value' => $txt['sp_admin_articles_col_status'], 'class' => 'centertext'), 'data' => array('db' => 'status_image', 'class' => 'centertext'), 'sort' => array('default' => 'status', 'reverse' => 'status DESC')), 'action' => array('header' => array('value' => $txt['sp_admin_articles_col_actions'], 'class' => 'centertext'), 'data' => array('sprintf' => array('format' => '<a href="?action=admin;area=portalarticles;sa=edit;article_id=%1$s;' . $context['session_var'] . '=' . $context['session_id'] . '" accesskey="e">' . sp_embed_image('modify') . '</a>&nbsp;
								<a href="?action=admin;area=portalarticles;sa=delete;article_id=%1$s;' . $context['session_var'] . '=' . $context['session_id'] . '" onclick="return confirm(' . JavaScriptEscape($txt['sp_admin_articles_delete_confirm']) . ') && submitThisOnce(this);" accesskey="d">' . sp_embed_image('delete') . '</a>', 'params' => array('id' => true)), 'class' => 'centertext nowrap')), 'check' => array('header' => array('value' => '<input type="checkbox" onclick="invertAll(this, this.form);" class="input_check" />', 'class' => 'centertext'), 'data' => array('function' => create_function('$row', '
							return \'<input type="checkbox" name="remove[]" value="\' . $row[\'id\'] . \'" class="input_check" />\';
						'), 'class' => 'centertext'))), 'form' => array('href' => $scripturl . '?action=admin;area=portalarticles;sa=remove', 'include_sort' => true, 'include_start' => true, 'hidden_fields' => array($context['session_var'] => $context['session_id'])), 'additional_rows' => array(array('position' => 'below_table_data', 'value' => '<input type="submit" name="remove_articles" value="' . $txt['sp_admin_articles_remove'] . '" class="right_submit" />')));
        // Set the context values
        $context['page_title'] = $txt['sp_admin_articles_title'];
        $context['sub_template'] = 'show_list';
        $context['default_list'] = 'portal_articles';
        // Create the list.
        require_once SUBSDIR . '/GenericList.class.php';
        createList($listOptions);
    }
function sportal_admin_page_list()
{
    global $txt, $smcFunc, $context, $scripturl;
    if (!empty($_POST['remove_pages']) && !empty($_POST['remove']) && is_array($_POST['remove'])) {
        checkSession();
        foreach ($_POST['remove'] as $index => $page_id) {
            $_POST['remove'][(int) $index] = (int) $page_id;
        }
        $smcFunc['db_query']('', '
			DELETE FROM {db_prefix}sp_pages
			WHERE id_page IN ({array_int:pages})', array('pages' => $_POST['remove']));
    }
    $sort_methods = array('title' => array('down' => 'title ASC', 'up' => 'title DESC'), 'namespace' => array('down' => 'namespace ASC', 'up' => 'namespace DESC'), 'type' => array('down' => 'type ASC', 'up' => 'type DESC'), 'views' => array('down' => 'views ASC', 'up' => 'views DESC'), 'status' => array('down' => 'status ASC', 'up' => 'status DESC'));
    $context['columns'] = array('title' => array('width' => '45%', 'label' => $txt['sp_admin_pages_col_title'], 'class' => 'first_th', 'sortable' => true), 'namespace' => array('width' => '25%', 'label' => $txt['sp_admin_pages_col_namespace'], 'sortable' => true), 'type' => array('width' => '8%', 'label' => $txt['sp_admin_pages_col_type'], 'sortable' => true), 'views' => array('width' => '6%', 'label' => $txt['sp_admin_pages_col_views'], 'sortable' => true), 'status' => array('width' => '6%', 'label' => $txt['sp_admin_pages_col_status'], 'sortable' => true), 'actions' => array('width' => '10%', 'label' => $txt['sp_admin_pages_col_actions'], 'sortable' => false));
    if (!isset($_REQUEST['sort']) || !isset($sort_methods[$_REQUEST['sort']])) {
        $_REQUEST['sort'] = 'title';
    }
    foreach ($context['columns'] as $col => $dummy) {
        $context['columns'][$col]['selected'] = $col == $_REQUEST['sort'];
        $context['columns'][$col]['href'] = $scripturl . '?action=admin;area=portalpages;sa=list;sort=' . $col;
        if (!isset($_REQUEST['desc']) && $col == $_REQUEST['sort']) {
            $context['columns'][$col]['href'] .= ';desc';
        }
        $context['columns'][$col]['link'] = '<a href="' . $context['columns'][$col]['href'] . '">' . $context['columns'][$col]['label'] . '</a>';
    }
    $context['sort_by'] = $_REQUEST['sort'];
    $context['sort_direction'] = !isset($_REQUEST['desc']) ? 'down' : 'up';
    $request = $smcFunc['db_query']('', '
		SELECT COUNT(*)
		FROM {db_prefix}sp_pages');
    list($total_pages) = $smcFunc['db_fetch_row']($request);
    $smcFunc['db_free_result']($request);
    $context['page_index'] = constructPageIndex($scripturl . '?action=admin;area=portalpages;sa=list;sort=' . $_REQUEST['sort'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $total_pages, 20);
    $context['start'] = $_REQUEST['start'];
    $request = $smcFunc['db_query']('', '
		SELECT id_page, namespace, title, type, views, status
		FROM {db_prefix}sp_pages
		ORDER BY {raw:sort}
		LIMIT {int:start}, {int:limit}', array('sort' => $sort_methods[$_REQUEST['sort']][$context['sort_direction']], 'start' => $context['start'], 'limit' => 20));
    $context['pages'] = array();
    while ($row = $smcFunc['db_fetch_assoc']($request)) {
        $context['pages'][$row['id_page']] = array('id' => $row['id_page'], 'page_id' => $row['namespace'], 'title' => $row['title'], 'href' => $scripturl . '?page=' . $row['namespace'], 'link' => '<a href="' . $scripturl . '?page=' . $row['namespace'] . '">' . $row['title'] . '</a>', 'type' => $row['type'], 'type_text' => $txt['sp_pages_type_' . $row['type']], 'views' => $row['views'], 'status' => $row['status'], 'status_image' => '<a href="' . $scripturl . '?action=admin;area=portalpages;sa=status;page_id=' . $row['id_page'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '">' . sp_embed_image(empty($row['status']) ? 'deactive' : 'active', $txt['sp_admin_pages_' . (!empty($row['status']) ? 'de' : '') . 'activate']) . '</a>', 'actions' => array('edit' => '<a href="' . $scripturl . '?action=admin;area=portalpages;sa=edit;page_id=' . $row['id_page'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '">' . sp_embed_image('modify') . '</a>', 'delete' => '<a href="' . $scripturl . '?action=admin;area=portalpages;sa=delete;page_id=' . $row['id_page'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" onclick="return confirm(\'', $txt['sp_admin_pages_delete_confirm'], '\');">' . sp_embed_image('delete') . '</a>'));
    }
    $smcFunc['db_free_result']($request);
    $context['sub_template'] = 'pages_list';
    $context['page_title'] = $txt['sp_admin_pages_list'];
}
/**
 * Loads all of the permission profiles in the system
 * Returns an indexed array of them
 *
 * @param int $start
 * @param int $items_per_page
 * @param string $sort
 */
function sp_load_profiles($start, $items_per_page, $sort)
{
    global $scripturl, $txt, $context;
    $db = database();
    // First load up all of the permission profiles names in the system
    $request = $db->query('', '
		SELECT id_profile, name
		FROM {db_prefix}sp_profiles
		ORDER BY {raw:sort}
		LIMIT {int:start}, {int:limit}', array('sort' => $sort, 'start' => $start, 'limit' => $items_per_page));
    $profiles = array();
    while ($row = $db->fetch_assoc($request)) {
        $profiles[$row['id_profile']] = array('id' => $row['id_profile'], 'name' => $row['name'], 'label' => isset($txt['sp_admin_profiles' . substr($row['name'], 1)]) ? $txt['sp_admin_profiles' . substr($row['name'], 1)] : $row['name'], 'actions' => array('edit' => '<a href="' . $scripturl . '?action=admin;area=portalprofiles;sa=editpermission;profile_id=' . $row['id_profile'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '">' . sp_embed_image('modify') . '</a>', 'delete' => '<a href="' . $scripturl . '?action=admin;area=portalprofiles;sa=deletepermission;profile_id=' . $row['id_profile'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" onclick="return confirm(\'', $txt['sp_admin_profiles_delete_confirm'], '\');">' . sp_embed_image('delete') . '</a>'));
    }
    $db->free_result($request);
    // Now for each profile, load up the specific permissions for each area of the portal
    foreach (array('articles', 'blocks', 'categories', 'pages', 'shoutboxes') as $module) {
        $request = $db->query('', '
			SELECT permissions, COUNT(*) AS used
			FROM {db_prefix}sp_{raw:module}
			GROUP BY permissions', array('module' => $module));
        while ($row = $db->fetch_assoc($request)) {
            if (isset($profiles[$row['permissions']])) {
                $profiles[$row['permissions']][$module] = $row['used'];
            }
        }
        $db->free_result($request);
    }
    return $profiles;
}
/**
 * Show the list of availalbe blocks in the system
 * If no specific area is provided will show all areas with available blocks in each
 * otherwise will just show the chosen area
 */
function template_block_list()
{
    global $context, $scripturl, $txt;
    echo '
	<div id="sp_manage_blocks">';
    // Show each portal area with the blocks in each one
    foreach ($context['sides'] as $id => $side) {
        $sortables[] = '#side_' . $side['id'];
        echo '
		<h3 class="category_header">
			<a class="floatright" href="', $scripturl, '?action=admin;area=portalblocks;sa=add;col=', $side['id'], '">', sp_embed_image('add', sprintf($txt['sp-blocksCreate'], $side['label'])), '</a>
			<a class="hdicon cat_img_helptopics help" href="', $scripturl, '?action=quickhelp;help=', $side['help'], '" onclick="return reqOverlayDiv(this.href);" title="', $txt['help'], '"></a>
			<a href="', $scripturl, '?action=admin;area=portalblocks;sa=', $id, '">', $side['label'], ' ', $txt['sp-blocksBlocks'], '</a>
		</h3>
		<table class="table_grid">
			<thead>
				<tr class="table_head">';
        foreach ($context['columns'] as $column) {
            echo '
					<th scope="col"', isset($column['class']) ? ' class="' . $column['class'] . '"' : '', isset($column['width']) ? ' width="' . $column['width'] . '"' : '', '>', $column['label'], '</th>';
        }
        echo '
				</tr>
			</thead>
			<tbody id="side_', $side['id'], '" class="sortme">';
        if (empty($context['blocks'][$side['name']])) {
            echo '
				<tr class="windowbg">
					<td class="centertext noticebox" colspan="4"></td>
				</tr>';
        }
        foreach ($context['blocks'][$side['name']] as $block) {
            echo '
				<tr id="block_', $block['id'], '" class="windowbg">
					<td>', $block['label'], '</td>
					<td>', $block['type_text'], '</td>
					<td class="centertext">', implode(' ', $block['actions']), '</td>
				</tr>';
        }
        echo '
			</tbody>
		</table>';
    }
    // Engage sortable to allow drag/drop arrangement of the blocks
    echo '
	</div>
	<script>
		// Set up our sortable call
		$().elkSortable({
			sa: "blockorder",
			error: "' . $txt['admin_order_error'] . '",
			title: "' . $txt['admin_order_title'] . '",
			token: {token_var: "' . $context['admin-sort_token_var'] . '", token_id: "' . $context['admin-sort_token'] . '"},
			tag: "' . implode(',', $sortables) . '",
			connect: ".sortme",
			containment: "#sp_manage_blocks",
			href: "?action=admin;area=portalblocks",
			placeholder: "ui-state-highlight",
			axis: "y",
		});
	</script>';
}
function template_shoutbox_embed($shoutbox)
{
    global $context, $scripturl, $settings, $txt;
    echo '
	<form action="" method="post">
		<div class="shoutbox_container">
			<div class="shoutbox_info">
				<div id="shoutbox_load_', $shoutbox['id'], '" style="float: right; display: none;"><img src="', $settings['sp_images_url'], '/loading.gif" alt="" /></div>
				<a href="', $scripturl, '?action=portal;sa=shoutbox;shoutbox_id=', $shoutbox['id'], '" onclick="sp_refresh_shout(', $shoutbox['id'], ', last_refresh_', $shoutbox['id'], '); return false;">', sp_embed_image('refresh'), '</a> <a href="', $scripturl, '?action=portal;sa=shoutbox;shoutbox_id=', $shoutbox['id'], '">', sp_embed_image('history'), '</a>';
    if ($context['can_shout']) {
        echo ' <a href="#smiley" onclick="sp_collapse_object(\'sb_smiley_', $shoutbox['id'], '\', false); return false;">', sp_embed_image('smiley'), '</a> <a href="#style" onclick="sp_collapse_object(\'sb_style_', $shoutbox['id'], '\', false); return false;">', sp_embed_image('style'), '</a>';
    }
    echo '
			</div>';
    if ($context['can_shout']) {
        echo '
			<div id="sp_object_sb_smiley_', $shoutbox['id'], '" style="display: none;">';
        foreach ($shoutbox['smileys']['normal'] as $smiley) {
            echo '
				<a href="javascript:void(0);" onclick="replaceText(\' ', $smiley['code'], '\', document.getElementById(\'new_shout_', $shoutbox['id'], '\')); return false;"><img src="', $settings['smileys_url'], '/', $smiley['filename'], '" alt="', $smiley['description'], '" title="', $smiley['description'], '" /></a>';
        }
        if (!empty($shoutbox['smileys']['popup'])) {
            echo '
					<a onclick="sp_showMoreSmileys(\'', $shoutbox['id'], '\', \'', $txt['more_smileys_title'], '\', \'', $txt['more_smileys_pick'], '\', \'', $txt['more_smileys_close_window'], '\', \'', $settings['theme_url'], '\', \'', $settings['smileys_url'], '\'); return false;" href="javascript:void(0);">[', $txt['more_smileys'], ']</a>';
        }
        echo '
			</div>
			<div id="sp_object_sb_style_', $shoutbox['id'], '" style="display: none;">';
        foreach ($shoutbox['bbc'] as $image => $tag) {
            if (!in_array($tag['code'], $shoutbox['allowed_bbc'])) {
                continue;
            }
            if (!isset($tag['after'])) {
                echo '<a href="javascript:void(0);" onclick="replaceText(\'', $tag['before'], '\', document.getElementById(\'new_shout_', $shoutbox['id'], '\')); return false;">';
            } else {
                echo '<a href="javascript:void(0);" onclick="surroundText(\'', $tag['before'], '\', \'', $tag['after'], '\', document.getElementById(\'new_shout_', $shoutbox['id'], '\')); return false;">';
            }
            echo '<img onmouseover="style_highlight(this, true);" onmouseout="if (window.style_highlight) style_highlight(this, false);" src="', $settings['images_url'], '/bbc/', $image, '.gif" align="bottom" width="23" height="22" alt="', $tag['description'], '" title="', $tag['description'], '" style="background-image: url(', $settings['images_url'], '/bbc/bbc_bg.gif); margin: 1px 2px 1px 1px;" /></a>';
        }
        echo '
			</div>';
    }
    echo '
			<div class="shoutbox_body">
				<ul class="shoutbox_list_compact" id="shouts_', $shoutbox['id'], '"', !empty($shoutbox['height']) ? ' style="height: ' . $shoutbox['height'] . 'px;"' : '', '>';
    if (!empty($shoutbox['warning'])) {
        echo '
					<li class="shoutbox_warning smalltext">', $shoutbox['warning'], '</li>';
    }
    if (!empty($shoutbox['shouts'])) {
        foreach ($shoutbox['shouts'] as $shout) {
            echo '
					<li class="smalltext">', !$shout['is_me'] ? '<strong>' . $shout['author']['link'] . ':</strong> ' : '', $shout['text'], '<br />', !empty($shout['delete_link_js']) ? '<span class="shoutbox_delete">' . $shout['delete_link_js'] . '</span>' : '', '<span class="smalltext shoutbox_time">', $shout['time'], '</span></li>';
        }
    } else {
        echo '
					<li class="smalltext">', $txt['sp_shoutbox_no_shout'], '</li>';
    }
    echo '
				</ul>
			</div>';
    if ($context['can_shout']) {
        echo '
			<div class="shoutbox_input smalltext">
				<input type="text" name="new_shout" id="new_shout_', $shoutbox['id'], '" class="shoutbox_input sp_float_left input_text"', $context['browser']['is_ie'] ? ' onkeypress="if (sp_catch_enter(event)) { sp_submit_shout(' . $shoutbox['id'] . ', \'' . $context['session_var'] . '\', \'' . $context['session_id'] . '\'); return false; }"' : '', ' />
				<input type="submit" name="submit_shout" value="', $txt['sp_shoutbox_button'], '" class="sp_float_right button_submit" onclick="sp_submit_shout(', $shoutbox['id'], ', \'', $context['session_var'], '\', \'', $context['session_id'], '\'); return false;" />
			</div>';
    }
    echo '
		</div>
		<input type="hidden" name="shoutbox_id" value="', $shoutbox['id'], '" />
		<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
	</form>
	<script language="Javascript" type="text/javascript"><!-- // --><![CDATA[
		var last_refresh_', $shoutbox['id'], ' = ', time(), ';';
    if ($shoutbox['reverse']) {
        echo '
		var objDiv = document.getElementById("shouts_', $shoutbox['id'], '");
		objDiv.scrollTop = objDiv.scrollHeight;';
    }
    if (!empty($shoutbox['refresh'])) {
        echo '
		var interval_id_', $shoutbox['id'], ' = setInterval( "sp_auto_refresh_', $shoutbox['id'], '()", ', $shoutbox['refresh'], ' * 1000);
		function sp_auto_refresh_', $shoutbox['id'], '()
		{
			if (window.XMLHttpRequest)
			{
				sp_refresh_shout(', $shoutbox['id'], ', last_refresh_', $shoutbox['id'], ');
			}
			else
				clearInterval(interval_id_', $shoutbox['id'], ');
		}';
    }
    // Setup the data for the popup smileys.
    if (!empty($shoutbox['smileys']['popup'])) {
        echo '
		if (sp_smileys == undefined)
			var sp_smileys = [';
        foreach ($shoutbox['smileys']['popup'] as $smiley) {
            echo '
					["', $smiley['code'], '","', $smiley['filename'], '","', $smiley['js_description'], '"]';
            if (empty($smiley['last'])) {
                echo ',';
            }
        }
        echo ']';
        echo '
		if (sp_moreSmileysTemplate == undefined)
		{
			var sp_moreSmileysTemplate =  ', JavaScriptEscape('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
					<html>
						<head>
							<title>' . $txt['more_smileys_title'] . '</title>
							<link rel="stylesheet" type="text/css" href="' . $settings['theme_url'] . '/css/index' . $context['theme_variant'] . '.css?rc2" />
						</head>
						<body id="help_popup">
							<div class="padding windowbg">
								<div class="cat_bar">
									<h3 class="catbg">
										' . $txt['more_smileys_pick'] . '
									</h3>
								</div>
								<div class="padding">
									%smileyRows%
								</div>
								<div class="smalltext centertext">
									<a href="javascript:window.close();">' . $txt['more_smileys_close_window'] . '</a>
								</div>
							</div>
						</body>
					</html>'), '
		}';
    }
    echo '
	// ]]></script>';
}
예제 #10
0
function sportal_get_shouts($shoutbox, $parameters)
{
    global $smcFunc, $scripturl, $context, $user_info, $modSettings, $options, $txt;
    $shoutbox = !empty($shoutbox) ? (int) $shoutbox : 0;
    $start = !empty($parameters['start']) ? (int) $parameters['start'] : 0;
    $limit = !empty($parameters['limit']) ? (int) $parameters['limit'] : 20;
    $bbc = !empty($parameters['bbc']) ? $parameters['bbc'] : array();
    $reverse = !empty($parameters['reverse']);
    $cache = !empty($parameters['cache']);
    $can_delete = !empty($parameters['can_moderate']);
    if (!empty($start) || !$cache || ($shouts = cache_get_data('shoutbox_shouts-' . $shoutbox, 240)) === null) {
        $request = $smcFunc['db_query']('', '
			SELECT
				sh.id_shout, sh.body, IFNULL(mem.id_member, 0) AS id_member,
				IFNULL(mem.real_name, sh.member_name) AS member_name, sh.log_time,
				mg.online_color AS member_group_color, pg.online_color AS post_group_color
			FROM {db_prefix}sp_shouts AS sh
				LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = sh.id_member)
				LEFT JOIN {db_prefix}membergroups AS pg ON (pg.id_group = mem.id_post_group)
				LEFT JOIN {db_prefix}membergroups AS mg ON (mg.id_group = mem.id_group)
			WHERE sh.id_shoutbox = {int:id_shoutbox}
			ORDER BY sh.id_shout DESC
			LIMIT {int:start}, {int:limit}', array('id_shoutbox' => $shoutbox, 'start' => $start, 'limit' => $limit));
        $shouts = array();
        while ($row = $smcFunc['db_fetch_assoc']($request)) {
            // Disable the aeva mod for the shoutbox.
            $context['aeva_disable'] = true;
            $online_color = !empty($row['member_group_color']) ? $row['member_group_color'] : $row['post_group_color'];
            $shouts[$row['id_shout']] = array('id' => $row['id_shout'], 'author' => array('id' => $row['id_member'], 'name' => $row['member_name'], 'link' => $row['id_member'] ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" title="' . $txt['on'] . ' ' . strip_tags(timeformat($row['log_time'])) . '"' . (!empty($online_color) ? ' style="color: ' . $online_color . ';"' : '') . '>' . $row['member_name'] . '</a>' : $row['member_name'], 'color' => $online_color), 'time' => $row['log_time'], 'text' => parse_bbc($row['body'], true, '', $bbc));
        }
        $smcFunc['db_free_result']($request);
        if (empty($start) && $cache) {
            cache_put_data('shoutbox_shouts-' . $shoutbox, $shouts, 240);
        }
    }
    foreach ($shouts as $shout) {
        if (preg_match('~^@(.+?): ~' . ($context['utf8'] ? 'u' : ''), $shout['text'], $target) && $smcFunc['strtolower']($target[1]) !== $smcFunc['strtolower']($user_info['name']) && $shout['author']['id'] != $user_info['id'] && !$user_info['is_admin']) {
            unset($shouts[$shout['id']]);
            continue;
        }
        $shouts[$shout['id']] += array('is_me' => preg_match('~^<div\\sclass="meaction">\\* ' . preg_quote($shout['author']['name'], '~') . '.+</div>$~', $shout['text']) != 0, 'delete_link' => $can_delete ? '<a href="' . $scripturl . '?action=portal;sa=shoutbox;shoutbox_id=' . $shoutbox . ';delete=' . $shout['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '">' . sp_embed_image('delete_small') . '</a> ' : '', 'delete_link_js' => $can_delete ? '<a href="' . $scripturl . '?action=portal;sa=shoutbox;shoutbox_id=' . $shoutbox . ';delete=' . $shout['id'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" onclick="sp_delete_shout(' . $shoutbox . ', ' . $shout['id'] . ', \'' . $context['session_var'] . '\', \'' . $context['session_id'] . '\'); return false;">' . sp_embed_image('delete_small') . '</a> ' : '');
        $shouts[$shout['id']]['text'] = str_replace(':jade:', '<img src="http://www.simpleportal.net/sp/cheerleader.gif" alt="Jade!" />', $shouts[$shout['id']]['text']);
        $shouts[$shout['id']]['time'] = timeformat($shouts[$shout['id']]['time']);
        $shouts[$shout['id']]['text'] = preg_replace('~(</?)div([^<]*>)~', '$1span$2', $shouts[$shout['id']]['text']);
        $shouts[$shout['id']]['text'] = preg_replace('~<a([^>]+>)([^<]+)</a>~', '<a$1' . $txt['sp_link'] . '</a>', $shouts[$shout['id']]['text']);
        $shouts[$shout['id']]['text'] = censorText($shouts[$shout['id']]['text']);
        if (!empty($modSettings['enable_buddylist']) && !empty($options['posts_apply_ignore_list']) && in_array($shout['author']['id'], $context['user']['ignoreusers'])) {
            $shouts[$shout['id']]['text'] = '<a href="#toggle" id="ignored_shout_link_' . $shout['id'] . '" onclick="sp_show_ignored_shout(' . $shout['id'] . '); return false;">[' . $txt['sp_shoutbox_show_ignored'] . ']</a><span id="ignored_shout_' . $shout['id'] . '" style="display: none;">' . $shouts[$shout['id']]['text'] . '</span>';
        }
    }
    if ($reverse) {
        $shouts = array_reverse($shouts);
    }
    return $shouts;
}
function sp_menu($parameters, $id, $return_parameters = false)
{
    global $context;
    $block_parameters = array();
    if ($return_parameters) {
        return $block_parameters;
    }
    if (empty($context['menu_buttons'])) {
        setupMenuContext();
    }
    echo '
								<ul class="sp_list" id="sp_menu">';
    foreach ($context['menu_buttons'] as $act => $button) {
        echo '
									<li>', sp_embed_image('dot'), ' <a title="', $button['title'], '" href="', $button['href'], '">', $button['active_button'] ? '<strong>' : '', $button['title'], $button['active_button'] ? '</strong>' : '', '</a>';
        if (!empty($button['sub_buttons'])) {
            echo '
										<ul class="sp_list">';
            foreach ($button['sub_buttons'] as $sub_button) {
                echo '
											<li class="sp_list_indent">', sp_embed_image('dot'), ' <a title="', $sub_button['title'], '" href="', $sub_button['href'], '">', $sub_button['title'], '</a></li>';
            }
            echo '
										</ul>';
        }
        echo '</li>';
    }
    echo '
								</ul>';
}
/**
 * Article Block, show the list of articles in the system
 *
 * @param mixed[] $parameters
 *		'category' => list of categories to choose article from
 *		'limit' => number of articles to show
 *		'type' => 0 latest 1 random
 *		'length' => length for the body text preview
 *		'avatar' => whether to show the author avatar or not
 *
 * @param int $id - not used in this block
 * @param boolean $return_parameters if true returns the configuration options for the block
 */
function sp_articles($parameters, $id, $return_parameters = false)
{
    global $scripturl, $txt, $color_profile;
    $block_parameters = array('category' => array(0 => $txt['sp_all']), 'limit' => 'int', 'type' => 'select', 'length' => 'int', 'avatar' => 'check');
    if ($return_parameters) {
        require_once SUBSDIR . '/PortalAdmin.subs.php';
        $categories = sp_load_categories();
        foreach ($categories as $category) {
            $block_parameters['category'][$category['id']] = $category['name'];
        }
        return $block_parameters;
    }
    // Needed utilities
    require_once SUBSDIR . '/Post.subs.php';
    require_once SUBSDIR . '/PortalArticle.subs.php';
    // Set up for the query
    $category = empty($parameters['category']) ? 0 : (int) $parameters['category'];
    $limit = empty($parameters['limit']) ? 5 : (int) $parameters['limit'];
    $type = empty($parameters['type']) ? 0 : 1;
    $length = isset($parameters['length']) ? (int) $parameters['length'] : 250;
    $avatar = empty($parameters['avatar']) ? 0 : (int) $parameters['avatar'];
    $articles = sportal_get_articles(null, true, true, $type ? 'RAND()' : 'spa.date DESC', $category, $limit);
    $colorids = array();
    foreach ($articles as $article) {
        if (!empty($article['author']['id'])) {
            $colorids[$article['author']['id']] = $article['author']['id'];
        }
    }
    // No articles in the system or none they can see
    if (empty($articles)) {
        echo '
								', $txt['error_sp_no_articles_found'];
        return;
    }
    // Doing the color thing
    if (!empty($colorids) && sp_loadColors($colorids) !== false) {
        foreach ($articles as $k => $p) {
            if (!empty($color_profile[$p['author']['id']]['link'])) {
                $articles[$k]['author']['link'] = $color_profile[$p['author']['id']]['link'];
            }
        }
    }
    // Not showing avatars, just use a compact link view
    if (empty($avatar)) {
        echo '
			<ul class="sp_list">';
        foreach ($articles as $article) {
            echo '
				<li>', sp_embed_image('topic'), ' ', $article['link'], '</li>';
        }
        echo '
			</ul>';
    } else {
        echo '
							<table class="sp_fullwidth">';
        foreach ($articles as $article) {
            // Using the cutoff tag?
            $limited = false;
            if (($cutoff = Util::strpos($article['body'], '[cutoff]')) !== false) {
                $article['body'] = Util::substr($article['body'], 0, $cutoff);
                preparsecode($article['body']);
                $limited = true;
            }
            // Good time to do this is ... now
            censorText($article['subject']);
            censorText($article['body']);
            $article['body'] = sportal_parse_content($article['body'], $article['type'], 'return');
            // Shorten the text, link the ellipsis, etc as needed
            if ($limited || !empty($length)) {
                $ellip = '<a href="' . $scripturl . '?article=' . $article['article_id'] . '">&hellip;</a>';
                $article['body'] = $limited ? $article['body'] . $ellip : Util::shorten_html($article['body'], $length, $ellip, false);
            }
            echo '
								<tr class="sp_articles_row">
									<td class="sp_articles centertext">';
            // If we have an avatar to show, show it
            if ($avatar && !empty($article['author']['avatar']['href'])) {
                echo '
										<a href="', $scripturl, '?action=profile;u=', $article['author']['id'], '">
											<img src="', $article['author']['avatar']['href'], '" alt="', $article['author']['name'], '" style="max-width:40px" />
										</a>';
            }
            echo '
									</td>
									<td>
										<span class="sp_articles_title">', $article['author']['link'], '</span><br />
										', $article['link'], '
									</td>
									<td>', $article['body'], '</td>
								</tr>
								<tr>
									<td colspan="3" class="sp_articles_row"></td>
								</tr>';
        }
        echo '
							</table>';
    }
}
function template_block_list()
{
    global $context, $settings, $options, $scripturl, $txt;
    echo '
	<div id="sp_manage_blocks">';
    if ($context['block_move']) {
        echo '
		<div class="information">
			<p>', $context['move_title'], ' [<a href="', $scripturl, '?action=admin;area=portalblocks">', $txt['sp-blocks_cancel_moving'], '</a>]', '</p>
		</div>';
    }
    foreach ($context['sides'] as $id => $side) {
        echo '
		<div class="cat_bar">
			<h3 class="catbg">
				<a class="sp_float_right" href="', $scripturl, '?action=admin;area=portalblocks;sa=add;col=', $side['id'], '">', sp_embed_image('add', sprintf($txt['sp-blocksCreate'], $side['label'])), '</a>
				<a href="', $scripturl, '?action=helpadmin;help=', $side['help'], '" onclick="return reqWin(this.href);" class="help"><img src="', $settings['images_url'], '/helptopics.gif" alt="', $txt['help'], '" class="icon" /></a>
				<a href="', $scripturl, '?action=admin;area=portalblocks;sa=', $id, '">', $side['label'], ' ', $txt['sp-blocksBlocks'], '</a>
			</h3>
		</div>
		<table class="table_grid" cellspacing="0" width="100%">
			<thead>
				<tr class="catbg">';
        if ($context['block_move']) {
            echo '
				<th scope="col" class="first_th" width="5%">', $txt['sp-adminColumnMove'], '</th>';
        }
        foreach ($context['columns'] as $column) {
            echo '
					<th scope="col"', isset($column['class']) ? ' class="' . $column['class'] . '"' : '', isset($column['width']) ? ' width="' . $column['width'] . '"' : '', '>', $column['label'], '</th>';
        }
        echo '
				</tr>
			</thead>
			<tbody>';
        if (empty($context['blocks'][$side['name']])) {
            echo '
				<tr class="windowbg2">
					<td class="sp_center" colspan="4">', $txt['error_sp_no_block'], '</td>
				</tr>';
        }
        foreach ($context['blocks'][$side['name']] as $block) {
            echo '
				<tr class="windowbg2">';
            if ($context['block_move']) {
                echo '
				<td class="sp_center">', $block['id'] != $context['block_move'] ? $block['move_insert'] : '', '</td>';
            }
            echo '
					<td>', $block['id'] == $context['block_move'] ? '<strong>' . $block['label'] . '</strong>' : $block['label'], '</td>
					<td>', $block['type_text'], '</td>
					<td class="sp_center">', implode(' ', $block['actions']), '</td>
				</tr>';
        }
        if ($context['block_move'] && (empty($side['last']) || $context['block_move'] != $side['last'])) {
            echo '
			<tr class="windowbg2">
				<td class="sp_center"><a href="', $scripturl, '?action=admin;area=portalblocks;sa=move;block_id=', $context['block_move'], ';col=', $side['id'], ';', $context['session_var'], '=', $context['session_id'], '">', sp_embed_image('arrow', $txt['sp-blocks_move_here']), '</a></td>
				<td></td>
				<td></td>
				<td></td>
			</tr>';
        }
        echo '
			</tbody>
		</table>';
    }
    echo '
	</div>';
}
/**
 * Template for viewing a specific article in the system
 * Also used to preview an article from the new article form
 */
function template_view_article()
{
    global $context, $txt;
    echo '
	<div id="sp_view_article">
		<h3 class="category_header">
			', $context['article']['title'], '
		</h3>
		<div class="sp_content_padding">
			<div class="sp_article_detail">';
    if (!empty($context['article']['author']['avatar']['image'])) {
        echo $context['article']['author']['avatar']['image'];
    }
    echo '
				<span class="sp_article_latest">
					', sprintf(!empty($context['using_relative_time']) ? $txt['sp_posted_on_in_by'] : $txt['sp_posted_in_on_by'], $context['article']['category']['link'], $context['article']['date'], $context['article']['author']['link']);
    if (!empty($context['article']['author']['avatar']['image'])) {
        echo '
					<br />';
    } else {
        echo '
				</span>
				<span class="floatright">';
    }
    echo '
					', sprintf($context['article']['view_count'] == 1 ? $txt['sp_viewed_time'] : $txt['sp_viewed_times'], $context['article']['view_count']), ', ', sprintf($context['article']['comment_count'] == 1 ? $txt['sp_commented_on_time'] : $txt['sp_commented_on_times'], $context['article']['comment_count']), '
				</span>
			</div>
			<hr />
			<div>', $context['article']['body'], '
			</div>
		</div>';
    // Not just previewing the new article?
    if (empty($context['preview'])) {
        echo '
		<div id="sp_view_comments">
			<h3 class="category_header">
				', $txt['sp-comments'], '
			</h3>';
        if (empty($context['article']['comments'])) {
            echo '
			<div class="infobox">
					', $txt['error_sp_no_comments'], '
			</div>';
        }
        foreach ($context['article']['comments'] as $comment) {
            echo '
			<div id="comment', $comment['id'], '" class="content">
				<div class="sp_content_padding flow_auto">
					<div class="sp_comment_detail">';
            if (!empty($comment['author']['avatar']['image'])) {
                echo $comment['author']['avatar']['image'];
            }
            // Show the edit icons if they are allowed
            if ($comment['can_moderate']) {
                echo '
						<div class="floatright">
							<a href="', $context['article']['href'], ';modify=', $comment['id'], ';', $context['session_var'], '=', $context['session_id'], '#sp_comment">', sp_embed_image('modify'), '</a>
							<a href="', $context['article']['href'], ';delete=', $comment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', sp_embed_image('delete'), '</a>
						</div>';
            }
            echo '
						<span class="sp_article_latest">', sprintf($txt['sp_posted_by'], $comment['time'], $comment['author']['link']), '</span>
					</div>
					<hr />
					<p class="sp_comment_body">
						', $comment['body'], '
					</p>
				</div>
			</div>';
        }
        // Pages as well?
        if (!empty($context['page_index'])) {
            template_pagesection();
        }
        // Show the comment box
        if ($context['article']['can_comment']) {
            echo '
			<div id="sp_comment" class="sp_content_padding">
				<form action="', $context['article']['href'], '" method="post" accept-charset="UTF-8">
					<textarea name="body" rows="5" cols="50" style="width: 100%;padding: 0.1em 0.2em" tabindex="', $context['tabindex']++, '">', !empty($context['article']['comment']['body']) ? $context['article']['comment']['body'] : '', '</textarea>
					<div class="submitbutton">
						<input type="submit" name="submit" value="', !empty($context['article']['comment']) ? $txt['sp_modify'] : $txt['sp_submit'], '" class="right_submit" />
						<input type="hidden" name="comment" value="', !empty($context['article']['comment']['id']) ? $context['article']['comment']['id'] : 0, '" />
						<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
					</div>
				</form>
			</div>';
        }
        echo '
		</div>';
    }
    echo '
	</div>';
    if (!empty($context['using_relative_time'])) {
        addInlineJavascript('$(\'.sp_article_latest\').addClass(\'relative\');', true);
    }
}
function template_category_list()
{
    global $context, $settings, $options, $scripturl, $txt;
    echo '
		<table class="table_grid" cellspacing="0" width="100%">
			<thead>
				<tr class="catbg">';
    foreach ($context['columns'] as $column) {
        echo '
					<th scope="col"', isset($column['class']) ? ' class="' . $column['class'] . '"' : '', isset($column['width']) ? ' width="' . $column['width'] . '"' : '', '>
						', $column['label'], '
					</th>';
    }
    echo '
				</tr>
			</thead>
			<tbody>';
    if (empty($context['categories'])) {
        echo '
					<tr class="windowbg2">
						<td class="sp_center" colspan="', count($context['columns']) + 1, '">&nbsp;</td>
					</tr>';
    }
    foreach ($context['categories'] as $category) {
        echo '
				<tr class="windowbg2">
					<td class="sp_center">', !empty($category['picture']['href']) ? $category['picture']['image'] : '', '</td>
					<td class="sp_left">', $category['name'], '</td>
					<td class="sp_center">', $category['articles'], '</td>
					<td class="sp_center"><a href="', $scripturl, '?action=admin;area=portalarticles;sa=statechange;category_id=', $category['id'], ';type=category;', $context['session_var'], '=', $context['session_id'], '">', empty($category['publish']) ? sp_embed_image('deactive', $txt['sp-stateNo']) : sp_embed_image('active', $txt['sp-stateYes']), '</a></td>
					<td class="sp_center"><a href="', $scripturl, '?action=admin;area=portalarticles;sa=editcategory;category_id=', $category['id'], ';', $context['session_var'], '=', $context['session_id'], '">', sp_embed_image('modify'), '</a> <a href="', $scripturl, '?action=admin;area=portalarticles;sa=deletecategory;category_id=', $category['id'], ';', $context['session_var'], '=', $context['session_id'], '"', empty($category['articles']) ? ' onclick="return confirm(\'' . $txt['sp-categoriesDeleteConfirm'] . '\');"' : '', '>', sp_embed_image('delete'), '</a></td>
				</tr>';
    }
    echo '
			</tbody>
		</table>';
}
function sportal_admin_articles_callback($reset = false)
{
    global $scripturl, $article_request, $txt, $context, $settings, $smcFunc;
    if ($article_request == false) {
        return false;
    }
    if (!($row = $smcFunc['db_fetch_assoc']($article_request))) {
        return false;
    }
    // Build up the array.
    $output = array('article' => array('id' => $row['id_article'], 'approved' => $row['approved']), 'category' => array('id' => $row['id_category'], 'name' => '<a href="' . $scripturl . '?action=admin;area=portalarticles;sa=editcategory;category_id=' . $row['id_category'] . '">' . $row['cname'] . '</a>'), 'message' => array('id' => $row['id_message'], 'subject' => $row['subject'], 'time' => timeformat($row['poster_time'], '%H:%M:%S, %d/%m/%y')), 'poster' => array('id' => $row['id_member'], 'name' => $row['poster_name'], 'link' => !empty($row['id_member']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>' : $row['poster_name']), 'topic' => array('id' => $row['id_topic'], 'replies' => $row['num_replies'], 'views' => $row['num_views'], 'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['subject'] . '</a>'), 'board' => array('id' => $row['id_board'], 'name' => $row['bname'], 'link' => '<a href="' . $scripturl . '?board=' . $row['id_board'] . '.0">' . $row['bname'] . '</a>'), 'edit' => '<a href="' . $scripturl . '?action=admin;area=portalarticles;sa=editarticle;article_id=' . $row['id_article'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '">' . sp_embed_image('modify') . '</a>', 'delete' => '<a href="' . $scripturl . '?action=admin;area=portalarticles;sa=deletearticle;article_id=' . $row['id_article'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" onclick="return confirm(\'' . $txt['sp-articlesDeleteConfirm'] . '\');">' . sp_embed_image('delete') . '</a>');
    return $output;
}