/**
* AdmCategoryOverview
* Called for each category.
*/
function PmxCategoryOverview($category)
{
    global $context, $txt;
    global $cfg_smfgroups;
    $category['config'] = unserialize($category['config']);
    if (empty($category['config']['title_align'])) {
        $category['config']['title_align'] = 'left';
    }
    if (empty($category['config']['title_icon'])) {
        $category['config']['title_icon'] = 'none.png';
    }
    echo '
					<div class="pmx_tbl_tr">';
    // Move row
    echo '
						<div class="pmx_tbl_tdgrid" id="RowMove-' . $category['id'] . '" style="white-space:nowrap;">
							<div class="pmx_clickrow' . (count($context['pmx']['catorder']) > 1 ? ' pmx_moveimg" title="' . $txt['pmx_move_categories'] . '" onclick="pmxSetMove(\'' . $category['id'] . '\')"' : '"') . '>
								<div style="padding-left:20px;margin-top:-2px;width:22px;">' . $category['catorder'] . '</div>
							</div>
						</div>';
    // title row
    echo '
						<div class="pmx_tbl_tdgrid">
							<div onclick="pmxSetTitle(\'' . $category['id'] . '\', \'cat\')"  title="' . $txt['pmx_click_edit_ttl'] . '" style="cursor:pointer;">
								<img id="uTitle.icon.' . $category['id'] . '" style="padding-right:4px;" src="' . $context['pmx_Iconsurl'] . $category['config']['title_icon'] . '" alt="*" title="' . substr($txt['pmx_edit_titleicon'], 0, -1) . '" />
								<img id="uTitle.align.' . $category['id'] . '" src="' . $context['pmx_imageurl'] . 'text_align_' . $category['config']['title_align'] . '.gif" alt="*" title="' . $txt['pmx_edit_title_align'] . $txt['pmx_edit_title_align_types'][$category['config']['title_align']] . '" />
								<span id="sTitle.text.' . $category['id'] . '.cat">' . (isset($category['config']['title'][$context['pmx']['currlang']]) ? htmlspecialchars($category['config']['title'][$context['pmx']['currlang']], ENT_QUOTES) : '') . '</span>';
    foreach ($context['pmx']['languages'] as $lang => $sel) {
        echo '
								<input id="sTitle.text.' . $lang . '.' . $category['id'] . '.cat" type="hidden" value="' . (isset($category['config']['title'][$lang]) ? htmlspecialchars($category['config']['title'][$lang], ENT_QUOTES) : '') . '" />';
    }
    echo '
								<input id="sTitle.icon.' . $category['id'] . '" type="hidden" value="' . $category['config']['title_icon'] . '" />
								<input id="sTitle.align.' . $category['id'] . '" type="hidden" value="' . $category['config']['title_align'] . '" />
							</div>
						</div>';
    // name row
    $details = PortaMx_getCatDetails($category, $context['pmx']['categories']);
    echo '
						<div class="pmx_tbl_tdgrid" style="cursor:pointer;" onclick="pmxSetCatName(\'' . $category['id'] . '\')">
							<input id="pWind.parent.id.' . $category['id'] . '" type="hidden" value="' . $category['parent'] . '" />
							<input id="pWind.move.cat.' . $category['id'] . '" type="hidden" value="[' . $category['catorder'] . ']' . ($category['level'] > 0 ? ' ' : '') . str_repeat('&bull;', $category['level']) . ' ' . $category['name'] . '" />
							<div id="pmxSetMove.' . $category['id'] . '" title="' . $details['parent'] . $txt['pmx_editname_categories'] . '" class="' . $details['class'] . '"><b>' . $details['level'] . '</b>
								<span id="pmxSetAcs.' . $category['id'] . '"><span id="pWind.cat.name.' . $category['id'] . '" class="cat_names">' . $category['name'] . '</span></span>
							</div>
						</div>';
    if (!empty($category['acsgrp'])) {
        list($grpacs, $denyacs) = Pmx_StrToArray($category['acsgrp'], ',', '=');
    } else {
        $grpacs = $denyacs = array();
    }
    $groups = array();
    foreach ($cfg_smfgroups as $grp) {
        if (in_array($grp['id'], $grpacs)) {
            $groups[] = '+' . $grp['id'] . '=' . intval(!in_array($grp['id'], $denyacs));
        } else {
            $groups[] = ':' . $grp['id'] . '=1';
        }
    }
    $sort = array();
    $catarts = array();
    $sorts = explode(',', $category['artsort']);
    foreach ($sorts as $s) {
        $sort[] = htmlentities($txt['pmx_categories_artsort'][str_replace(array('=0', '=1'), array('', ''), $s)], ENT_QUOTES, $context['pmx']['encoding']) . $txt['pmx_artsort'][intval(substr($s, -1, 1))];
    }
    if (!empty($category['articles'])) {
        foreach ($category['articles'] as $arts) {
            $catarts[] = '[' . $arts['id'] . '] ' . $arts['name'];
        }
    }
    // create acs groups for acs Popup
    if (!empty($category['acsgrp'])) {
        list($grpacs, $denyacs) = Pmx_StrToArray($category['acsgrp'], ',', '=');
    } else {
        $grpacs = $denyacs = array();
    }
    // options row
    echo '
						<div class="pmx_tbl_tdgrid">
							<input id="grpAcs.' . $category['id'] . '" type="hidden" value="' . implode(',', $grpacs) . '" />
							<input id="denyAcs.' . $category['id'] . '" type="hidden" value="' . implode(',', $denyacs) . '" />
							<input id="pWind.catarts.' . $category['id'] . '" type="hidden" value="' . implode('|', $catarts) . '" />
							<input id="pWind.artsorttxt.' . $category['id'] . '" type="hidden" value="' . $txt['pmx_categorie_articlesort'] . '" />
							<input id="pWind.artsort.' . $category['id'] . '" type="hidden" value="' . implode('|', $sort) . '" />
							<div id="pWind.grp.' . $category['id'] . '" class="pmx_clickrow' . (!empty($category['acsgrp']) ? ' pmx_access" title="' . $txt['pmx_categories_groupaccess'] : '') . '"></div>
							<div class="pmx_clickrow' . (!empty($category['config']['cssfile']) ? ' pmx_custcss" title="' . $txt['pmx_categories_cssfile'] : '') . '"></div>
							<div class="pmx_clickrow' . (!empty($category['config']['check_ecl']) ? ' pmx_eclsettings" title="' . $txt['pmx_have_catecl_settings'] : '') . '"></div>
							<div class="pmx_clickrow' . (!empty($category['artsum']) ? ' pmx_articles" title="' . sprintf($txt['pmx_categories_articles'], $category['artsum']) . '" onclick="pmxShowArt(\'' . $category['id'] . '\')"' : '"') . '></div>
						</div>';
    // functions row
    echo '
						<div class="pmx_tbl_tdgrid">
							<div class="pmx_clickrow pmx_pgedit" title="' . $txt['pmx_edit_categories'] . '" onclick="FormFunc(\'edit_category\', \'' . $category['id'] . '\')"></div>
							<div class="pmx_clickrow pmx_grpacs" title="' . $txt['pmx_chg_categoriesaccess'] . '" onclick="pmxSetAcs(\'' . $category['id'] . '\', \'cat\')"></div>
							<div class="pmx_clickrow pmx_pgclone" title="' . $txt['pmx_clone_categories'] . '"  onclick="pmxSetCatClone(\'' . $category['id'] . '\')"></div>
							<div class="pmx_clickrow pmx_pgdelete" title="' . $txt['pmx_delete_categories'] . '" onclick="pmxSetCatDelete(\'' . $category['id'] . '\')"></div>
						</div>
					</div>';
}
/**
* Get all Category detais
**/
function pmx_getAllCatDetais($allcats, &$detais)
{
    global $txt;
    foreach ($allcats as $cat) {
        $detais[$cat['id']] = PortaMx_getCatDetails($cat, PortaMx_getCategories());
        if (!empty($cat['childs'])) {
            pmx_getAllCatDetais($cat['childs'], $detais);
        }
    }
    $detais[0] = array('class' => 'cat_none', 'level' => '0', 'parent' => $txt['pmx_categories_none'], 'name' => $txt['pmx_categories_none']);
}
/**
* The main Subtemplate.
*/
function template_main()
{
    global $context, $txt, $scripturl;
    $curarea = isset($_GET['area']) ? $_GET['area'] : 'pmx_center';
    if (allowPmx('pmx_admin', true)) {
        $AdmTabs = array('pmx_center' => $txt['pmx_admincenter'], 'pmx_settings' => $txt['pmx_settings'], 'pmx_blocks' => $txt['pmx_blocks'], 'pmx_categories' => $txt['pmx_categories'], 'pmx_articles' => $txt['pmx_articles'], 'pmx_sefengine' => $txt['pmx_sefengine']);
        echo '
			<div style="height:2.8em;margin-top:5px;">
				<ul id="pmxmenu_nav" class="dropmenu sf-js-enabled">';
        foreach ($AdmTabs as $name => $desc) {
            echo '
					<li id="' . $name . '" class="subsections">
						<a ' . ($name == $curarea ? 'class="active"' : '') . 'href="' . $scripturl . '?action=portamx;area=' . $name . ';' . $context['session_var'] . '=' . $context['session_id'] . '">' . $desc . '</a>
					</li>';
        }
        echo '
				</ul>
			</div>';
    }
    if (!isset($context['pmx']['articlestart'])) {
        $context['pmx']['articlestart'] = 0;
    }
    echo '
		<div class="cat_bar"><h3 class="catbg">' . $txt['pmx_adm_articles'] . '</h3></div>
		<p class="information" style="margin: 0;padding: 8px;">' . $txt['pmx_articles_desc'] . '</p>
		<div style="height:0.5em;"></div>';
    if ($context['pmx']['subaction'] == 'overview') {
        // create the pageindex
        $cururl = !empty($_GET) ? pmx_http_build_query($_GET, '', ';') . ';' : '';
        $pageindex = constructPageIndex($scripturl . '?' . $cururl . 'pg=%1$d', $context['pmx']['articlestart'], $context['pmx']['totalarticles'], $context['pmx']['settings']['manager']['artpage'], true);
        $pageindex = str_replace(';start=%1$d', '', $pageindex);
    }
    echo '
		<form id="pmx_form" accept-charset="' . $context['character_set'] . '" name="PMxAdminArticles" action="' . $scripturl . '?action=' . $context['pmx']['AdminMode'] . ';area=pmx_articles;' . $context['session_var'] . '=' . $context['session_id'] . '" method="post" style="margin: 0px;" onsubmit="submitonce(this);">
			<input type="hidden" name="sc" value="' . $context['session_id'] . '" />
			<input type="hidden" name="sa" value="' . $context['pmx']['subaction'] . '" />
			<input type="hidden" name="articlestart" value="' . $context['pmx']['articlestart'] . '" />
			<input type="hidden" name="fromblock" value="' . (!empty($context['pmx']['fromblock']) ? $context['pmx']['fromblock'] : '') . '" />
			<input type="hidden" id="pWind.all.cats" value="' . pmx_getAllCatID() . '" />
			<input id="common_field" type="hidden" value="" />
			<input id="extra_cmd" type="hidden" value="" />
			<script>
				var Art = [];
				Art["active"] = "' . $txt['pmx_status_activ'] . ' - ' . $txt['pmx_status_change'] . '";
				Art["notactive"] = "' . $txt['pmx_status_inactiv'] . ' - ' . $txt['pmx_status_change'] . '";
				Art["approved"] = "' . $txt['pmx_article_approved'] . ' - ' . $txt['pmx_status_change'] . '";
				Art["notapproved"] = "' . $txt['pmx_article_not_approved'] . ' - ' . $txt['pmx_status_change'] . '";
			</script>';
    // ---------------------
    // all articles overview
    // ---------------------
    if ($context['pmx']['subaction'] == 'overview') {
        $cfg_titleicons = PortaMx_getAllTitleIcons();
        $cfg_smfgroups = PortaMx_getUserGroups();
        $categories = PortaMx_getCategories();
        $allNames = array();
        $allGroups = array();
        foreach ($cfg_smfgroups as $key => $grp) {
            $allGroups[] = $grp['id'];
            $allNames[] = str_replace(' ', '_', $grp['name']);
        }
        // common Popup input fields
        echo '
			<input id="pWind.language." type="hidden" value="' . $context['pmx']['currlang'] . '" />
			<input id="pWind.icon.url" type="hidden" value="' . $context['pmx_Iconsurl'] . '" />
			<input id="pWind.image.url" type="hidden" value="' . $context['pmx_imageurl'] . '" />
			<input id="pWind.name" type="hidden" value="" />
			<input id="pWind.id" type="hidden" value="" />
			<input id="pWind.catsel" type="hidden" value="" />
			<input id="pWind.side" type="hidden" value="" />
			<input id="set.filter.category" type="hidden" name="filter[category]" value="' . $_SESSION['PortaMx']['filter']['category'] . '" />
			<input id="set.filter.approved" type="hidden" name="filter[approved]" value="' . $_SESSION['PortaMx']['filter']['approved'] . '" />
			<input id="set.filter.active" type="hidden" name="filter[active]" value="' . $_SESSION['PortaMx']['filter']['active'] . '" />
			<input id="set.filter.myown" type="hidden" name="filter[myown]" value="' . $_SESSION['PortaMx']['filter']['myown'] . '" />
			<input id="set.filter.member" type="hidden" name="filter[member]" value="' . $_SESSION['PortaMx']['filter']['member'] . '" />
			<input id="allAcsGroups" type="hidden" value="' . implode(',', $allGroups) . '" />
			<input id="allAcsNames" type="hidden" value="' . implode(',', $allNames) . '" />
			<div id="addnodes" style="display:none"></div>';
        $filterActive = $_SESSION['PortaMx']['filter']['category'] != '' || $_SESSION['PortaMx']['filter']['approved'] != 0 || $_SESSION['PortaMx']['filter']['active'] != 0 || $_SESSION['PortaMx']['filter']['myown'] != 0 || $_SESSION['PortaMx']['filter']['member'] != '';
        // top pageindex
        echo '
			<div class="smalltext pmx_pgidx_top">' . $pageindex . '</div>';
        echo '
			<div style="margin-bottom:-10px;">
				<div class="cat_bar catbg_grid">
					<h4 class="catbg catbg_grid">
						<span' . (allowPmx('pmx_create, pmx_articles, pmx_admin') ? ' class="pmx_clickaddnew" title="' . $txt['pmx_articles_add'] . '" onclick="SetpmxArticleType()"' : '') . '></span>
						<span class="cat_msg_title_center">' . $txt['pmx_articles_overview'] . '</span>
					</h4>
				</div>
				<div class="windowbg wdbgtop" style="margin-bottom:4px;" id="RowMove-0">
					<div class="pmx_tbl" style="margin-bottom:3px;">
						<div class="pmx_tbl_tr windowbg2 normaltext" style="height:27px;">
							<div class="pmx_tbl_tdgrid" style="width:45px;"><b>' . $txt['pmx_article_order'] . '</b></div>
							<div class="pmx_tbl_tdgrid" onclick="pWindToggleLang(\'\')" title="' . $txt['pmx_toggle_language'] . '" style="width:48%;cursor:pointer;"><b>' . $txt['pmx_title'] . ' [<b id="pWind.def.lang.">' . $context['pmx']['currlang'] . '</b>]</b></div>
							<div class="pmx_tbl_tdgrid" style="width:25%;"><b>' . $txt['pmx_articles_type'] . '</b></div>
							<div class="pmx_tbl_tdgrid" style="width:25%;"><b>' . $txt['pmx_articles_catname'] . '</b>
								<span class="pmx_' . (empty($filterActive) ? 'nofilter' : 'filter') . '" title="' . $txt['pmx_article_filter'] . '" onclick="pmxSetFilter()"></span>
							</div>
							<div class="pmx_tbl_tdgrid" style="width:84px;"><b>' . $txt['pmx_options'] . '</b></div>
							<div class="pmx_tbl_tdgrid" style="width:45px;"><b>' . $txt['pmx_status'] . '</b></div>
							<div class="pmx_tbl_tdgrid" style="width:84px;"><b>' . $txt['pmx_functions'] . '</b></div>
						</div>';
        // call PmxArticleOverview for each article
        $articleCnt = count($context['pmx']['articles']);
        $artIDs = array();
        $pgCount = 0;
        foreach ($context['pmx']['articles'] as $article) {
            if ($pgCount >= $context['pmx']['articlestart'] && $pgCount < $context['pmx']['articlestart'] + $context['pmx']['settings']['manager']['artpage']) {
                PmxArticleOverview($article, $cfg_titleicons, $cfg_smfgroups, $categories);
            }
            $pgCount++;
            $artIDs[] = $article['id'];
        }
        echo '
					</div>
					<input id="pWind.all.ids." type="hidden" value="' . implode(',', $artIDs) . '" />
				</div>
				<div style="height:30px">
					<div class="smalltext pmx_pgidx_bot">' . $pageindex . '</div>
				</div>
			</div>';
        /**
        * Popup windows for overview
        **/
        echo '
			<div style="padding:0;margin:-15px 6px 0 6px">
				<table class="pmx_table_grid" style="border-color:transparent;table-layout:fixed;">
					<tr id="popupRow">
						<td class="tdnogrid" style="width:46px;">';
        // start row move popup
        echo '
							<div id="pmxRowMove" class="smalltext" style="width:340px;z-index:9999;display:none;left:1px;margin-top:-30px;">
								' . pmx_popupHeader('pmxRowMove', $txt['pmx_rowmove_title']) . '
									<input id="pWind.move.error" type="hidden" value="' . $txt['pmx_rowmove_error'] . '" />
									<div style="float:left;width:110px;">
										' . $txt['pmx_rowmove'] . '
										<div style="margin-top:6px;">' . $txt['pmx_rowmove_place'] . '</div>
										<div style="margin-top:10px;">' . $txt['pmx_rowmove_to'] . '</div>
									</div>
									<div style="padding-left:112px;">
										<div style="margin-left:5px; margin-top:2px;" id="pWind.move.pos"></div>
										<div style="margin-top:5px;">
											<input id="pWind.place.0" class="input_radio" type="radio" name="_" value="before" /><span style="padding:0 3px;">' . $txt['pmx_rowmove_before'] . '</span>
											<input id="pWind.place.1" class="input_radio" type="radio" name="_" value="after" checked="checked" /><span style="padding:0 3px;">' . $txt['pmx_rowmove_after'] . '</span><br />
										</div>
										<select id="pWind.sel" style="width:190px; margin-top:8px; margin-left:5px;" size="1">';
        foreach ($context['pmx']['article_rows'] as $id => $data) {
            echo '
											<option value="' . $id . '">[' . $id . '] ' . $data['name'] . ' (' . (empty($data['cat']) ? $txt['pmx_default_none'] : $data['cat']) . ')</option>';
        }
        echo '
										</select>
									</div>
									<div style="clear:both; text-align:right; margin-top:7px;">
										<input class="button_submit" type="button" value="' . $txt['pmx_save'] . '" onclick="pmxSendArtMove()" />
										<div style="height:20px;"></div>
									</div>
								</div>
							</div>';
        // end Move popup
        echo '	</td>
						<td class="tdnogrid" style="width:48%;">';
        // start title edit popup
        echo '
							<div id="pmxSetTitle" class="smalltext" style="width:420px;z-index:9999;display:none;margin-top:-30px;">
								' . pmx_popupHeader('pmxSetTitle', $txt['pmx_edit_titles'], '112px') . '
									<div style="float:left; width:75px;">' . $txt['pmx_edit_title'] . '</div>
									<input id="pWind.text" style="width:310px;" type="text" value="" />
									<input id="pWindID" type="hidden" value="" />
									<div style="clear:both; height:10px;">
										<img style="float:left;margin-top:-3px;" src="' . $context['pmx_imageurl'] . 'arrow_down.gif" alt="*" title="" />
									</div>
									<div style="float:left; width:75px;">' . $txt['pmx_edit_title_lang'] . '</div>
									<select id="pWind.lang.sel" style="float:left; width:165px;" size="1" onchange="pmxChgTitles_Lang(this)">';
        // languages
        foreach ($context['pmx']['languages'] as $lang => $sel) {
            echo '
										<option value="' . $lang . '">' . $lang . '</option>';
        }
        echo '
									</select>
									<div style="float:right;padding-right:1px;"><span style="vertical-align:6px;">' . $txt['pmx_edit_title_align'] . '</span>';
        // Title align
        foreach ($txt['pmx_edit_title_align_types'] as $key => $val) {
            echo '
										<img id="pWind.align.' . $key . '" src="' . $context['pmx_imageurl'] . 'text_align_' . $key . '.gif" alt="*" title="' . $txt['pmx_edit_title_helpalign'] . $val . '" style="vertical-align:2px; cursor:pointer;" onclick="pmxChgTitles_Align(\'' . $key . '\')" />';
        }
        echo '
									</div>
									<br style="clear:both;" />
									<input style="float:right; margin-top:9px;margin-right:1px;" class="button_submit" type="button" value="' . $txt['pmx_update_save'] . '"  onclick="pmxUpdateTitles()" />
									<div style="float:left;width:75px; padding-top:8px;">' . $txt['pmx_edit_titleicon'] . '</div>';
        // Title icons
        echo '
									<div class="ttliconDiv" onclick="setNewIcon(document.getElementById(\'pWind.icon_sel\'), event)">
										<input id="post_image" type="hidden" name="config[title_icon]" value="" />
										<input id="iconDD" value="' . (isset($article['config']['title_icon']) ? ucfirst(str_replace('.png', '', $article['config']['title_icon'])) : 'None') . '" readonly />
										<img id="pWind.icon" class="pwindicon" src="' . $context['pmx_shortIconsurl'] . 'none.png" alt="*" />
										<img class="ddImage" src="' . $context['pmx_imageurl'] . 'state_expanded.png" alt="*" title="" />
									</div>
									<ul class="ttlicondd" id="pWind.icon_sel" onclick="updIcon(this)">';
        foreach ($cfg_titleicons as $file => $name) {
            echo '
										<li id="' . $file . '" class="ttlicon' . (isset($article['config']['title_icon']) && $article['config']['title_icon'] == $file ? ' active' : '') . '">
											<img src="' . $context['pmx_shortIconsurl'] . $file . '" alt="*" /><span>' . $name . '</span>
										</li>';
        }
        echo '
									</ul>
									<script>$("li").hover(function(){$(this).toggleClass("active")});</script>
								</div>
							</div>';
        // end title edit popup
        echo '
						</td>
						<td class="tdnogrid" style="width:25%;"></td>
						<td class="tdnogrid" style="width:25%;">';
        // categorie popup
        echo '
							<div id="pmxSetCats" class="smalltext" style="z-index:9999;width:220px;margin-top:-30px;display:none;">
								' . pmx_popupHeader('pmxSetCats', $txt['pmx_category_popup']) . '
									<select id="pWind.cats.sel" onchange="pmxChgCats(this)" style="width:100%;" size="6">';
        $selcats = array_merge(array(PortaMx_getDefaultCategory($txt['pmx_categories_none'])), $categories);
        $ordercats = array_merge(array(0), $context['pmx']['catorder']);
        $isWriter = allowPmx('pmx_create, pmx_articles', true);
        $isAdm = allowPmx('pmx_admin');
        $allcats = array();
        foreach ($ordercats as $catorder) {
            $cat = PortaMx_getCatByOrder($selcats, $catorder);
            $cfg = unserialize($cat['config']);
            // allcats html
            $details = PortaMx_getCatDetails($cat, $categories);
            $allcats[] = $cat['id'] . '|<div class="' . $details['class'] . '"><b>' . $details['level'] . '</b><span><span class="cat_names">' . $cat['name'] . '</span></span></div>';
            if (!empty($isAdm) || !empty($isWriter) && empty($cfg['global'])) {
                if (empty($cat)) {
                    $cat['id'] = 0;
                    $cat['name'] = $txt['pmx_categories_none'];
                }
                $details['parent'] .= $txt['pmx_chg_articlcats'];
                echo '
										<option value="' . $cat['id'] . '">' . str_repeat('&bull;', $cat['level']) . ' ' . $cat['name'] . '</option>';
            }
        }
        echo '
									</select><br />
									<div style="text-align:right;margin-top:7px;">
										<input class="button_submit" type="button" value="' . $txt['pmx_update_save'] . '" onclick="pmxUpdateCats()" />&nbsp;
										<input class="button_submit" type="button" value="' . $txt['pmx_update_all'] . '" onclick="pmxUpdateCats(\'all\')" />
									</div>
								</div>
							</div>';
        // end categorie popup
        // start filter popup
        echo '
							<div id="pmxSetFilter" class="smalltext" style="width:280px;z-index:9999;margin-top:-60px;padding-top:36px;display:none;">
								' . pmx_popupHeader('pmxSetFilter', $txt['pmx_article_setfilter']) . '
									<div style="padding-bottom:3px; margin-top:-4px;">' . $txt['pmx_article_filter_category'] . '<span style="float:right; cursor:pointer" onclick="pmxSetFilterCatClr()">[<b>' . $txt['pmx_article_filter_categoryClr'] . '</b>]</span></div>
									<select id="pWind.filter.category" style="width:100%;" size="4" multiple="multiple">';
        $selcats = array_merge(array(PortaMx_getDefaultCategory($txt['pmx_categories_none'])), $categories);
        $ordercats = array_merge(array(0), $context['pmx']['catorder']);
        $catfilter = Pmx_StrToArray($_SESSION['PortaMx']['filter']['category']);
        $isWriter = allowPmx('pmx_create, pmx_articles', true);
        $isAdm = allowPmx('pmx_admin');
        foreach ($ordercats as $catorder) {
            $cat = PortaMx_getCatByOrder($selcats, $catorder);
            $cfg = unserialize($cat['config']);
            if (!empty($isAdm) || !empty($isWriter) && empty($cfg['global'])) {
                echo '
									<option value="' . $cat['id'] . '"' . (in_array($cat['id'], $catfilter) ? ' selected="selected"' : '') . '>' . str_repeat('&bull;', $cat['level']) . ' ' . $cat['name'] . '</option>';
            }
        }
        echo '
								</select><br />
								<div style="height:22px;padding-top:4px;">
									' . $txt['pmx_article_filter_approved'] . '
									<input id="pWind.filter.approved" style="float:right;" class="input_check" type="checkbox" value="1"' . (!empty($_SESSION['PortaMx']['filter']['approved']) ? ' checked="checked"' : '') . ' />
								</div>
								<div style="height:22px;">
									' . $txt['pmx_article_filter_active'] . '
									<input id="pWind.filter.active" style="float:right;" class="input_check" type="checkbox" value="1"' . (!empty($_SESSION['PortaMx']['filter']['active']) ? ' checked="checked"' : '') . ' />
								</div>';
        if (allowPmx('pmx_articles, pmx_admin')) {
            echo '
								<div style="height:22px;">
									' . $txt['pmx_article_filter_myown'] . '
									<input id="pWind.filter.myown" style="float:right;" class="input_check" type="checkbox" value="1"' . (!empty($_SESSION['PortaMx']['filter']['myown']) ? ' checked="checked"' : '') . ' />
								</div>
								<div style="height:18px;">
									' . $txt['pmx_article_filter_member'] . '
									<input id="pWind.filter.member" style="float:right;width:130px;" class="input_text" type="text" value="' . $_SESSION['PortaMx']['filter']['member'] . '" />
								</div>' . $txt['pmx_article_filter_membername'];
        }
        echo '
								<div style="text-align:right;margin-top:-5px;">
									<input class="button_submit" type="button" value="' . $txt['set_article_filter'] . '" onclick="pmxSendFilter()" />
									<div style="height:20px;"></div>
								</div>
							</div>
						</div>';
        $filterActive = $_SESSION['PortaMx']['filter']['category'] != '' || $_SESSION['PortaMx']['filter']['approved'] != 0 || $_SESSION['PortaMx']['filter']['active'] != 0 || $_SESSION['PortaMx']['filter']['myown'] != 0 || $_SESSION['PortaMx']['filter']['member'] != '';
        // end filter popup
        echo '
						</td>
						<td class="tdnogrid" style="width:63px;"></td>
						<td class="tdnogrid" style="width:45px;"></td>
						<td class="tdnogrid" style="width:84px;">';
        // start blocktype selection popup
        $RegBlocks = $context['pmx']['RegBlocks'];
        foreach ($RegBlocks as $key => $val) {
            if (!in_array($key, array('html', 'script', 'bbc_script', 'php'))) {
                unset($RegBlocks[$key]);
            }
        }
        function cmpBDesc($a, $b)
        {
            return strcasecmp(str_replace(' ', '', $a["description"]), str_replace(' ', '', $b["description"]));
        }
        uasort($RegBlocks, 'cmpBDesc');
        // start articletype selection popup
        echo '
							<div id="pmxArticleType" class="smalltext" style="width:220px;z-index:9999;margin-top:-30px;display:none;">
								' . pmx_popupHeader('pmxArticleType', $txt['pmx_add_new_articletype'], '65px') . '
									<div style="margin:-4px 0 5px 0;">' . $txt['pmx_articles_articletype'] . '</div>
									<select id="pmx.article.type" style="width:120px;" size="1">';
        foreach ($RegBlocks as $type => $articleType) {
            echo '
										<option value="' . $type . '">' . $articleType['description'] . '</option>';
        }
        echo '
									</select>
									<div style="text-align:right; margin-top:-23px;">
										<input class="button_submit" type="button" value="' . $txt['pmx_create'] . '" onclick="pmxSendArticleType()" />
									</div>
								</div>
							</div>';
        // end popup
        // start Access popup
        echo '
							<div id="pmxSetAcs" class="smalltext" style="width:210px;z-index:9999;display:none;margin-top:-30px;">
								' . pmx_popupHeader('pmxSetAcs', $txt['pmx_article_groups']) . '
									<div style="height:15px;margin-top:-5px;">
										<input id="pWindAcsModeupd" onclick="pmxSetAcsMode(\'upd\')" class="input_check" type="radio" name="_" value="" /><span style="vertical-align:3px; padding:0 3px;">' . $txt['pmx_acs_repl'] . '</span>
									</div>
									<div style="height:15px;">
										<input id="pWindAcsModeadd" onclick="pmxSetAcsMode(\'add\')" class="input_check" type="radio" name="_" value="" /><span style="vertical-align:3px; padding:0 3px;">' . $txt['pmx_acs_add'] . '</span>&nbsp;&nbsp;
									</div>
									<div style="height:15px;margin-bottom:10px;">
										<input id="pWindAcsModedel" onclick="pmxSetAcsMode(\'del\')" class="input_check" type="radio" name="_" value="" /><span style="vertical-align:3px; padding:0 3px;">' . $txt['pmx_acs_rem'] . '</span>
									</div>
									<select id="pWindAcsGroup" style="width:100%;" multiple="multiple" size="6" onchange="changed(\'pWindAcsGroup\');">';
        foreach ($cfg_smfgroups as $grp) {
            echo '
										<option value="' . $grp['id'] . '=1">' . $grp['name'] . '</option>';
        }
        echo '
									</select><br />
									<script type="text/javascript">
										var pWindAcsGroup = new MultiSelect("pWindAcsGroup");
									</script>
									<div style="text-align:right; margin-top:7px;">
										<input class="button_submit" type="button" value="' . $txt['pmx_update_save'] . '" onclick="pmxUpdateAcs()" />&nbsp;
										<input id="acs_all_button" class="button_submit" type="button" value="' . $txt['pmx_update_all'] . '" onclick="pmxUpdateAcs(\'all\')" />
									</div>
								</div>
							</div>';
        // end Access popup
        // start clone popup
        echo '
							<div id="pmxSetArtClone" class="smalltext" style="width:220px;z-index:9999;margin-top:-30px;display:none;">
								' . pmx_popupHeader('pmxSetArtClone', $txt['pmx_art_clone']) . '
									<div>' . $txt['pmx_confirm_artclone'] . '</div>
									<input id="pWind.artcloneid" type="hidden" value="" />
									<input style="float:right;font-size:11px;font-weight:bold;margin-top:5px;" class="button_submit" type="button" value="' . $txt['pmx_delete_button'] . '" onclick="pmxSendArtClone()" />
									<div style="height:25px;"></div>
								</div>
							</div>';
        // end clone popup
        // start delete popup
        echo '
							<div id="pmxSetArtDelete" class="smalltext" style="width:220px;z-index:9999;margin-top:-30px;display:none;">
								' . pmx_popupHeader('pmxSetArtDelete', $txt['pmx_art_delete']) . '
									<div>' . $txt['pmx_confirm_artdelete'] . '</div>
									<input id="pWind.artdelid" type="hidden" value="" />
									<input style="float:right;font-size:11px;font-weight:bold;margin-top:5px;" class="button_submit" type="button" value="' . $txt['pmx_delete_button'] . '" onclick="pmxSendArtDelete()" />
									<div style="height:25px;"></div>
								</div>
							</div>';
        // end delete popup
        echo '
						</td>
						<td class="tdnogrid" style="width:84px;"></td>
					</tr>
				</table>
			</div>';
    } elseif ($context['pmx']['subaction'] == 'edit' || $context['pmx']['subaction'] == 'editnew') {
        echo '
			<table class="pmx_table" style="margin-bottom:5px;table-layout:fixed;">
				<tr>
					<td style="text-align:center">
						<div class="cat_bar" style="border-bottom-left-radius:6px;border-bottom-right-radius:6px">
							<h3 class="catbg">
							' . $txt['pmx_article_edit'] . ' ' . $txt['pmx_articles_types'][$context['pmx']['editarticle']->cfg['ctype']] . '
							</h3>
						</div>
					</td>
				</tr>';
        // call the ShowAdmArticleConfig() methode
        $context['pmx']['editarticle']->pmxc_ShowAdmArticleConfig();
        echo '
			</table>';
    }
    echo '
		</form>';
}