/**
     * This Methode is called on loadtime.
     * After all variables initiated, it calls the block dependent init methode.
     * Finaly the css is loaded if exist
     */
    function pmxc_AdmArticle_loadinit()
    {
        $this->smf_groups = PortaMx_getUserGroups();
        // get all usergroups
        $this->title_icons = PortaMx_getAllTitleIcons();
        // get all title icons
        $this->custom_css = PortaMx_getCustomCssDefs();
        // custom css definitions
        $this->usedClass = PortaMx_getdefaultClass(false, true);
        // default class types
        $this->categories = PortaMx_getCategories();
        // exist categories
        if ($this->cfg['ctype'] == 'php') {
            addInlineJavascript(str_replace("\n", "\n\t", PortaMx_compressJS('
			function php_syntax(elmid)
			{
				document.getElementById("check_" + elmid).className = "info_frame";
				var result = pmx_setCookie("pmx_php_check", document.getElementById(elmid).value, "php_snytax", false);
				result = result.replace(/@elm@/g, elmid);
				document.getElementById("check_" + elmid).innerHTML = result;
				Show_help("check_" + elmid);

				var errLine = /(on\\sline\\s)(\\d+)(.*)/;
				errLine.exec(result);
				errLine = RegExp.$2;
				php_showerrline(elmid, errLine);
			}
			function php_showerrline(elmid, errLine)
			{
				if(errLine != "" && !isNaN(errLine))
				{
					var lines = document.getElementById(elmid).value.split("\\n");
					var count = 0;
					for(var i = 0; i < errLine -1; i++)
						count += lines[i].length +1;

					if(document.getElementById(elmid).setSelectionRange)
					{
						document.getElementById(elmid).focus();
						document.getElementById(elmid).setSelectionRange(count, count+lines[i].length);
					}
					else if(document.getElementById(elmid).createTextRange)
					{
						range=document.getElementById(elmid).createTextRange();
						range.collapse(true);
						range.moveStart("character", count);
						range.moveEnd("character", count+lines[i].length);
						range.select();
					}
				}
			}')));
        }
    }
 /**
  * This Methode is called on loadtime.
  * After all variables initiated, it calls the block dependent init methode.
  * Finaly the css is loaded if exist
  */
 function pmxc_AdmCategories_loadinit()
 {
     $this->smf_groups = PortaMx_getUserGroups();
     // get all usergroups
     $this->title_icons = PortaMx_getAllTitleIcons();
     // get all title icons
     $this->custom_css = PortaMx_getCustomCssDefs();
     // custom css definitions
     $this->usedClass = PortaMx_getdefaultClass(false, true);
     // default class types
     $this->categories = PortaMx_getCategories();
     // exist categories
 }
 /**
  * This Methode is called on loadtime.
  * After all variables initiated, it calls the block dependent init methode.
  * Finaly the css and language is loaded if exist
  */
 function pmxc_AdmBlock_loadinit()
 {
     global $context;
     $this->smf_themes = PortaMx_getsmfThemes();
     // get all themes
     $this->smf_groups = PortaMx_getUserGroups();
     // get all usergroups
     $this->smf_boards = PortaMx_getsmfBoards();
     // get all smf boards
     $this->register_blocks = $context['pmx']['RegBlocks'];
     // get all registered block
     $this->block_classdef = PortaMx_getdefaultClass();
     // get default classes
     $this->title_icons = PortaMx_getAllTitleIcons();
     // get all title icons
     $this->custom_css = PortaMx_getCustomCssDefs();
     // custom css definitions
     $this->can_cached = 0;
     // default no caching
     // sort the registered blocks
     ksort($this->register_blocks, SORT_STRING);
     // call the blockdepend init methode
     $this->pmxc_AdmBlock_init();
 }
/**
* 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:3em;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'] . '" onclick="pmxWinGetTop(\'adm\',\'template\')">' . $desc . '</a>
					</li>';
        }
        echo '
				</ul>
			</div>';
    }
    $sections = $context['pmx']['subaction'] == 'all' ? array_keys($txt['pmx_admBlk_sides']) : Pmx_StrToArray($context['pmx']['subaction']);
    if (!allowPmx('pmx_admin', true) && allowPmx('pmx_blocks', true)) {
        if (!isset($context['pmx']['settings']['manager']['admin_pages'])) {
            $context['pmx']['settings']['manager']['admin_pages'] = array();
        }
        $showBlocks = array_intersect($sections, $context['pmx']['settings']['manager']['admin_pages']);
        $MenuTabs = array_merge(array('all'), $context['pmx']['settings']['manager']['admin_pages']);
    } else {
        $showBlocks = $sections;
        $MenuTabs = array_keys($txt['pmx_admBlk_panels']);
    }
    if ($context['pmx']['function'] == 'edit' || $context['pmx']['function'] == 'editnew') {
        $active = array($context['pmx']['editblock']->getConfigData('side'));
    } else {
        $active = explode(',', $context['pmx']['subaction']);
    }
    echo '
		<div class="cat_bar"><h3 class="catbg">' . $txt['pmx_adm_blocks'] . '</h3></div>
		<p class="information" style="margin: 0;padding: 8px;">' . $txt['pmx_admBlk_desc'] . '</p>

		<div id="adm_submenus" style="margin-bottom:6px;overflow:hidden;">
			<ul class="dropmenu">';
    foreach ($MenuTabs as $name) {
        echo '
				<li>
					<a class="firstlevel' . (in_array($name, $active) ? ' active' : '') . '" href="' . $scripturl . '?action=' . $context['pmx']['AdminMode'] . ';area=pmx_blocks;sa=' . $name . ';' . $context['session_var'] . '=' . $context['session_id'] . '" onclick="pmxWinGetTop(\'adm\',\'template\')">
						<span class="firstlevel">' . $txt['pmx_admBlk_panels'][$name] . '</span>
					</a>
				</li>';
    }
    echo '
			</ul>
		</div>';
    echo '
		<form id="pmx_form" accept-charset="' . $context['character_set'] . '" name="PMxAdminBlocks" action="' . $scripturl . '?action=' . $context['pmx']['AdminMode'] . ';area=pmx_blocks;sa=' . $context['pmx']['subaction'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '" method="post" style="margin: 0px 0px 6px 0;" onsubmit="submitonce(this);">
			<input type="hidden" name="sc" value="' . $context['session_id'] . '" />
			<input type="hidden" name="function" value="' . $context['pmx']['function'] . '" />
			<input type="hidden" name="sa" value="' . $context['pmx']['subaction'] . '" />
			<input id="common_field" type="hidden" value="" />
			<input id="extra_cmd" type="hidden" value="" />';
    // ---------------------
    // all Blocks overview
    // ---------------------
    if ($context['pmx']['function'] == 'overview') {
        $cfg_titleicons = PortaMx_getAllTitleIcons();
        $cfg_smfgroups = PortaMx_getUserGroups();
        $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.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.side" type="hidden" value="" />
			<input id="pWind.id" type="hidden" value="" />
			<input id="allAcsGroups" type="hidden" value="' . implode(',', $allGroups) . '" />
			<input id="allAcsNames" type="hidden" value="' . implode(',', $allNames) . '" />
			<script>
				var BlockActive = "' . $txt['pmx_status_activ'] . ' - ' . $txt['pmx_status_change'] . '";
				var BlockInactive = "' . $txt['pmx_status_inactiv'] . ' - ' . $txt['pmx_status_change'] . '";
			</script>';
        foreach ($showBlocks as $side) {
            $blockCnt = !empty($context['pmx']['blocks'][$side]) ? count($context['pmx']['blocks'][$side]) : 0;
            $paneldesc = htmlentities($txt['pmx_admBlk_sides'][$side], ENT_QUOTES, $context['pmx']['encoding']);
            echo '
			<div id="addnodes.' . $side . '"></div>
			<div style="margin-bottom:5px;">
				<div id="paneltop-' . $side . '" class="cat_bar catbg_grid">
					<h4 class="catbg catbg_grid">
						<span' . (allowPmx('pmx_admin') ? ' class="pmx_clickaddnew" title="' . sprintf($txt['pmx_add_sideblock'], $txt['pmx_admBlk_sides'][$side]) . '" onclick="SetpmxBlockType(\'' . $side . '\', \'' . $paneldesc . '\')"' : '') . '></span>
						<span class="cat_msg_title_center">
							<a href="' . $scripturl . '?action=' . $context['pmx']['AdminMode'] . ';area=pmx_blocks;sa=' . $side . ';' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['pmx_admBlk_sides'][$side] . '</a>
						</span>
					</h4>
				</div>
				<div class="windowbg2 wdbgtop" style="margin-bottom:4px;">
					<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_admBlk_order'] . '</b></div>';
            if (!empty($blockCnt)) {
                echo '
							<div class="pmx_tbl_tdgrid" onclick="pWindToggleLang(\'.' . $side . '\')" title="' . $txt['pmx_toggle_language'] . '" style="width:57%;cursor:pointer; padding:3px 5px;"><b>' . $txt['pmx_title'] . ' [<b id="pWind.def.lang.' . $side . '">' . $context['pmx']['currlang'] . '</b>]</b></div>';
            } else {
                echo '
							<div class="pmx_tbl_tdgrid" title="' . $txt['pmx_toggle_language'] . '" style="width:57%;"><b>' . $txt['pmx_title'] . ' [<b id="pWind.def.lang.' . $side . '">' . $context['pmx']['currlang'] . '</b>]</b></div>';
            }
            echo '
							<div class="pmx_tbl_tdgrid" style="width:36%;"><b>' . $txt['pmx_admBlk_type'] . '</b></div>
							<div class="pmx_tbl_tdgrid" id="RowMove-' . $side . '" style="width:126px;"><b>' . $txt['pmx_options'] . '</b></div>
							<div class="pmx_tbl_tdgrid" style="width:43px;"><div style="width:40px;"><b>' . $txt['pmx_status'] . '</b></div></div>
							<div class="pmx_tbl_tdgrid" style="width:105px;"><div style="width:105px;"><b>' . $txt['pmx_functions'] . '</b></div></div>
						</div>';
            // call PmxBlocksOverview for each side / block
            $blockIDs = array();
            if (!empty($blockCnt)) {
                foreach ($context['pmx']['blocks'][$side] as $block) {
                    if (PmxBlocksOverview($block, $side, $cfg_titleicons, $cfg_smfgroups) == true) {
                        $blockIDs[] = $block['id'];
                        $blocktypes[$side][$block['id']] = array('type' => $block['blocktype'], 'pos' => $block['pos']);
                    }
                }
            }
            echo '
					</div>';
            if (count($blockIDs) > 0) {
                // common Popup input fields
                echo '
					<input id="pWind.language.' . $side . '" type="hidden" value="' . $context['pmx']['currlang'] . '" />
					<input id="pWind.all.ids.' . $side . '" type="hidden" value="' . implode(',', $blockIDs) . '" />';
                $blockCnt = !empty($context['pmx']['blocks'][$side]) ? count($context['pmx']['blocks'][$side]) : 0;
                $paneldesc = htmlentities($txt['pmx_admBlk_sides'][$side], ENT_QUOTES, $context['pmx']['encoding']);
                if (count($blockIDs) == 1 && allowPmx('pmx_admin')) {
                    echo '
					<script type="text/javascript">
						document.getElementById("Img.RowMove-' . $blockIDs[0] . '").className = "pmx_clickrow";
						document.getElementById("Img.RowMove-' . $blockIDs[0] . '").title = "";
					</script>';
                }
            }
            echo '
				</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;">';
        // start row move popup
        echo '
					<tr id="popupRow">
						<td class="tdnogrid" style="width:46px;">
							<div id="pmxRowMove" class="smalltext" style="width:345px;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_block_move_error'] . '" />
									<div style="float:left;width:94px;">
										' . $txt['pmx_block_rowmove'] . '<br />
										<div style="margin-top:5px;">' . $txt['pmx_blockmove_place'] . '</div><br />
										<div style="margin-top:-10px;">' . $txt['pmx_blockmove_to'] . '</div>
									</div>
									<div style="padding-left:94px;">
										<div style="margin-left:5px; margin-top:2px;" id="pWind.move.blocktyp"></div>
										<div style="margin-top:3px;height:20px">
											<input id="pWind.place.0" class="input_check" type="radio" value="before" name="_" checked="checked" style="vertical-align:-3px;" /><span style="padding:0 3px;">' . $txt['rowmove_before'] . '</span>
											<input id="pWind.place.1" class="input_check" type="radio" value="after"  name="_" style="vertical-align:-3px;" /><span style="padding:0 3px;">' . $txt['rowmove_after'] . '</span><br />
										</div>';
        // output blocktypes
        foreach ($txt['pmx_admBlk_sides'] as $side => $d) {
            if (isset($blocktypes[$side])) {
                echo '
											<div style="width:145px;">
										<select id="pWind.select.' . $side . '" style="width:140px;margin-top:8px;margin-left:3px;display:none" size="1">';
                // output blocktypes
                foreach ($blocktypes[$side] as $id => $data) {
                    echo '
											<option style="padding:0;margin:0;" value="' . $id . '">[' . $data['pos'] . '] ' . $context['pmx']['RegBlocks'][$data['type']]['description'] . '</option>';
                }
                echo '
										</select>
										</div>';
            }
        }
        echo '
									</div>
									<div style="float:right; margin-top:-23px; height:20px;">
										<input class="button_submit" type="button" value="' . $txt['pmx_save'] . '" onclick="pmxSendRowMove()" />
									</div>
								</div>
							</div>
						</td>';
        // end Move popup
        // start title edit popup
        echo '
						<td class="tdnogrid" style="width:57%;">
							<div id="pmxSetTitle" class="smalltext" style="width:420px;z-index:9999;display:none;left:1px;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($block['config']['title_icon']) ? ucfirst(str_replace('.png', '', $block['config']['title_icon'])) : 'NoneF') . '" 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($block['config']['title_icon']) && $block['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>
						</td>';
        // end title edit popup
        echo '
						<td class="tdnogrid" style="width:36%;"></td>
						<td class="tdnogrid" style="width:126px;"></td>
						<td class="tdnogrid" style="width:43px;"></td>
						<td class="tdnogrid" style="width:105px;">';
        // 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>
							<script>
								var BlockActive = "' . $txt['pmx_status_activ'] . ' - ' . $txt['pmx_status_change'] . '";
								var BlockInactive = "' . $txt['pmx_status_inactiv'] . ' - ' . $txt['pmx_status_change'] . '";
							</script>';
        // end Access popup
        // start Clone / Move popup
        echo '
							<div id="pmxSetCloneMove" class="smalltext" style="width:230px;z-index:9999;display:none;margin-top:-30px;">
								' . pmx_popupHeader('pmxSetCloneMove', '<span id="title.clone.move"></span>') . '
									<input id="pWind.txt.clone" type="hidden" value="' . $txt['pmx_text_clone'] . '" />
									<input id="pWind.txt.move" type="hidden" value="' . $txt['pmx_text_move'] . '" />
									<input id="pWind.worktype" type="hidden" value="" />
									<input id="pWind.addoption" type="hidden" value="' . $txt['pmx_clone_move_toarticles'] . '" />
									<div id="pWind.clone.move.blocktype" style="float:left;"><b></b></div>
									<div style="clear:both; height:4px;"></div>
									<div>' . $txt['pmx_clone_move_side'] . '</div>
									<select id="pWind.sel.sides" style="width:115px;" size="1">';
        $sel = true;
        foreach ($txt['pmx_admBlk_sides'] as $side => $desc) {
            echo '
										<option value="' . $side . '"' . (!empty($sel) ? ' selected="selected"' : '') . '>' . $desc . '</option>';
            $sel = false;
        }
        echo '
									</select>
									<input style="float:right;" class="button_submit" type="button" value="' . $txt['pmx_save'] . '" onclick="pmxSendCloneMove()" />
								</div>
							</div>';
        // end Clone / Move popup
        // start delete popup
        echo '
							<div id="pmxSetDelete" class="smalltext" style="width:220px;z-index:9999;display:none;margin-top:-30px;">
								' . pmx_popupHeader('pmxSetDelete', $txt['pmx_delete_block']) . '
									<div><span id="pWind.delete.blocktype"></span></div>
									<div>' . $txt['pmx_confirm_blockdelete'] . '</div>
									<input id="pWind.blockid" type="hidden" value="" />
									<div style="height:20px"><input style="float:right;font-size:11px;font-weight:bold;" class="button_submit" type="button" value="' . $txt['pmx_delete_button'] . '" onclick="pmxSendDelete()" /></div>
								</div>
							</div>';
        // end delete popup
        // start blocktype selection popup
        $RegBlocks = eval($context['pmx']['registerblocks']);
        function cmpBDesc($a, $b)
        {
            return strcasecmp(str_replace(' ', '', $a["description"]), str_replace(' ', '', $b["description"]));
        }
        uasort($RegBlocks, 'cmpBDesc');
        echo '
							<div id="pmxBlockType" class="smalltext" style="width:256px;margin-top:-36px;display:none;">
								' . pmx_popupHeader('pmxBlockType', '') . '
									<div style="margin:-4px 0 5px 0;">' . $txt['pmx_blocks_blocktype'] . '</div>
									<input id="pWind.blocktype.title" type="hidden" value="' . $txt['pmx_add_new_blocktype'] . '" />
									<select id="pmx.block.type" style="width:150px;" size="1">';
        foreach ($RegBlocks as $blocktype => $blockDesc) {
            echo '
										<option value="' . $blocktype . '">' . $blockDesc['description'] . '</option>';
        }
        echo '
									</select>
									<div style="float:right;">
										<input class="button_submit" type="button" value="' . $txt['pmx_create'] . '" onclick="pmxSendBlockType()" />
									</div>
								</div>
							</div>';
        // end blocktype popup
        echo '
						</td>
					</tr>
				</table>
			</div>';
    } elseif ($context['pmx']['function'] == 'edit' || $context['pmx']['function'] == 'editnew') {
        echo '
			<table class="pmx_table" style="table-layout:fixed;margin-bottom:-10px;">
				<tr>
					<td style="text-align:center;padding-bottom:5px;">
						<div class="cat_bar" style="border-bottom-left-radius:6px;border-bottom-right-radius:6px">
							<h3 class="catbg">
							' . $txt['pmx_editblock'] . ' ' . $context['pmx']['RegBlocks'][$context['pmx']['editblock']->cfg['blocktype']]['description'] . '
							</h3>
						</div>
					</td>
				</tr>';
        // call the ShowAdmBlockConfig() methode
        $context['pmx']['editblock']->pmxc_ShowAdmBlockConfig();
        echo '
			</table>';
    }
    echo '
		</form>';
}
/**
* The main Subtemplate.
*/
function template_main()
{
    global $context, $txt, $scripturl;
    global $cfg_titleicons, $cfg_smfgroups;
    $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:3em;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>';
    }
    echo '
		<div class="cat_bar">
			<h3 class="catbg">' . $txt['pmx_adm_categories'] . '</h3>
		</div>
		<p class="information" style="margin: 0;padding: 8px;">' . $txt['pmx_categories_desc'] . '</p>
		<div style="height:0.5em;"></div>

		<form id="pmx_form" accept-charset="', $context['character_set'], '" name="PMxAdminCategories" action="' . $scripturl . '?action=' . $context['pmx']['AdminMode'] . ';area=pmx_categories;' . $context['session_var'] . '=' . $context['session_id'] . '" method="post" style="margin-bottom: 4px;">
			<input type="hidden" name="sc" value="', $context['session_id'], '" />
			<input type="hidden" name="sa" value="', $context['pmx']['subaction'], '" />
			<input id="common_field" type="hidden" value="" />
			<input id="extra_cmd" type="hidden" value="" />';
    // ------------------------
    // all categories overview
    // ------------------------
    if ($context['pmx']['subaction'] == 'overview') {
        $cfg_titleicons = PortaMx_getAllTitleIcons();
        $cfg_smfgroups = PortaMx_getUserGroups();
        $allNames = array();
        $allGroups = array();
        foreach ($cfg_smfgroups as $key => $grp) {
            $allGroups[] = $grp['id'];
            $allNames[] = str_replace(' ', '_', $grp['name']);
        }
        $categoryCnt = 0;
        $catIDs = array();
        // common Popup input fields
        echo '
			<input id="pWind.language.cat" 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.side" type="hidden" value="" />
			<input id="allAcsGroups" type="hidden" value="' . implode(',', $allGroups) . '" />
			<input id="allAcsNames" type="hidden" value="' . implode(',', $allNames) . '" />
			<div id="addnodes" style="display:none"></div>';
        echo '
			<div class="cat_bar catbg_grid">
				<h4 class="catbg catbg_grid">
					<span class="pmx_clickaddnew" title="' . $txt['pmx_categories_add'] . '" onclick="FormFunc(\'add_new_category\', \'1\')"></span>
					<span class="cat_msg_title_center">' . $txt['pmx_categories_overview'] . '</span>
				</h4>
			</div>
			<div class="windowbg2 wdbgtop" style="margin-bottom:4px;">
				<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_categories_order'] . '</b></div>
						<div class="pmx_tbl_tdgrid" style="width:57%;cursor:pointer;" onclick="pWindToggleLang(\'cat\')" title="' . $txt['pmx_toggle_language'] . '"><b>' . $txt['pmx_title'] . ' [<b id="pWind.def.lang.cat">' . $context['pmx']['currlang'] . '</b>]</b></div>
						<div class="pmx_tbl_tdgrid" style="width:34%;"><b>' . $txt['pmx_categories_name'] . '</b></div>
						<div class="pmx_tbl_tdgrid" style="width:84px;"><b>' . $txt['pmx_options'] . '</b></div>
						<div class="pmx_tbl_tdgrid" style="width:84px;"><b>' . $txt['pmx_functions'] . '</b></div>
					</div>';
        // call PmxCategoryOverview for each category
        foreach ($context['pmx']['catorder'] as $catorder) {
            $cat = PortaMx_getCatByOrder($context['pmx']['categories'], $catorder);
            PmxCategoryOverview($cat);
            $catIDs[] = $cat['id'];
        }
        echo '
				</div>
				<input id="pWind.all.ids.cat" type="hidden" value="' . implode(',', $catIDs) . '" />
			</div>';
        /**
        * Popup windows for overview
        **/
        echo '
			<div style="padding:0;margin:-10px 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 Move popup
        echo '
						<div id="pmxSetMove" class="smalltext" style="width:344px;z-index:9999;margin-top:-34px;display:none;">
							' . pmx_popupHeader('pmxSetMove', $txt['pmx_categories_movecat']) . '
								<input id="pWind.move.error" type="hidden" value="' . $txt['pmx_categories_move_error'] . '" />
								<div style="float:left;width:130px;">' . $txt['pmx_categories_move'] . '</div>
								<div style="margin-left:130px;" id="pWind.move.catname">&nbsp;</div>
								<div style="float:left;width:126px;">' . $txt['pmx_categories_moveplace'] . '</div>
								<div style="margin-left:126px;">';
        $opt = 0;
        foreach ($txt['pmx_categories_places'] as $artType => $artDesc) {
            echo '
								<input id="pWind.place.' . $opt . '" class="input_check" type="radio" name="_" value="' . $artType . '"' . ($artType == 'after' ? ' checked="checked"' : '') . ' /><span style="vertical-align:3px; padding:0 3px;">' . $artDesc . '</span>' . ($opt == 1 ? '<br />' : '');
            $opt++;
        }
        // all exist categories
        echo '
								</div>
								<div style="float:left; width:130px;margin-top:4px;">' . $txt['pmx_categories_tomovecat'] . '</div>
								<div style="margin-left:130px;margin-top:4px;">
									<select id="pWind.sel.destcat" style="width:180px;" size="1">';
        // output cats
        foreach ($context['pmx']['catorder'] as $catorder) {
            $cat = PortaMx_getCatByOrder($context['pmx']['categories'], $catorder);
            echo '
									<option value="' . $cat['id'] . '">[' . $catorder . ']' . str_repeat('&bull;', $cat['level']) . ' ' . $cat['name'] . '</option>';
        }
        echo '
									</select>
								</div>
								<div style="text-align:right; margin-top:8px;height:20px;">
									<input class="button_submit" type="button" value="' . $txt['pmx_save'] . '" onclick="pmxSaveMove()" />
								</div>
							</div>
						</div>';
        // end Move popup
        echo '
					</td>
					<td class="tdnogrid" style="width:57%;">';
        // start title edit popup
        echo '
						<div id="pmxSetTitle" class="smalltext" style="width:420px;z-index:9999;display:none;margin-top:-34px;">
							' . 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($category['config']['title_icon']) ? ucfirst(str_replace('.png', '', $category['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($category['config']['title_icon']) && $category['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:34%;">';
        // Categorie name popup
        echo '
						<div id="pmxSetCatName" class="smalltext" style="width:280px;z-index:9999;margin-top:-34px;display:none;">
							' . pmx_popupHeader('pmxSetCatName', $txt['pmx_categories_setname']) . '
								<div style="float:left;width:140px; height:25px;">' . $txt['pmx_categories_name'] . ':
									<img class="info_toggle" onclick=\'Show_help("pmxBH11")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<span id="check.name.error" style="display:none;">' . sprintf($txt['namefielderror'], $txt['pmx_categories_name']) . '</span>
								<div style="height:25px;">
									<input id="check.name" style="width:160px;" onkeyup="check_requestname(this)" onkeypress="check_requestname(this)" type="text" value="" />
								</div>
								<div id="pmxBH11" class="info_frame" style="margin-top:25px;">' . $txt['pmx_edit_pagenamehelp'] . '
								</div>
								<div style="text-align:right; height:20px;">
									<input class="button_submit" type="button" value="' . $txt['pmx_update_save'] . '" onclick="pmxUpdateCatName()" />
								</div>
							</div>
						</div>';
        // end Categorie name popup
        echo '
					</td>
					<td class="tdnogrid" style="width:84px;">';
        // start articles in cat popup
        echo '
						<div id="pmxShowArt" class="smalltext" style="width:250px;z-index:9999;margin-top:-34px;display:none;">
							' . pmx_popupHeader('pmxShowArt', $txt['pmx_categories_showarts']) . '
								<div id="artsorttxt" style="margin-top:-5px;"></div>
								<div id="artsort" class="smalltext" style="max-height: 30px; overflow:auto;"></div><hr class="pmx_hr" />
								<div id="showarts" style="max-height: 170px; overflow:auto;"></div>
							</div>
						</div>';
        // start articles in cat popup
        echo '
					</td>
					<td class="tdnogrid" style="width:83px;">';
        // start Access popup
        echo '
						<div id="pmxSetAcs" class="smalltext" style="width:210px;z-index:9999;display:none;margin-top:-34px;">
							' . 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="pmxSetCatClone" class="smalltext" style="width:220px;margin-top:-34px;z-index:9999;display:none;">
							' . pmx_popupHeader('pmxSetCatClone', $txt['pmx_cat_clone']) . '
								<div>' . $txt['pmx_confirm_catclone'] . '</div>
								<input id="pWind.catcloneid" 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="pmxSendCatClone()" />
								<div style="height:25px;"></div>
							</div>
						</div>';
        // end Clone popup
        // start delete popup
        echo '
			<div id="pmxSetCatDelete" class="smalltext" style="width:220px;;margin-top:-34px;z-index:9999;display:none;">
				' . pmx_popupHeader('pmxSetCatDelete', $txt['pmx_cat_delete']) . '
					<div>' . $txt['pmx_confirm_catdelete'] . '</div>
					<input id="pWind.catdelid" 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="pmxSendCatDelete()" />
					<div style="height:25px;"></div>
				</div>
			</div>';
        // end delete popup
        echo '
					</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_categories_edit'] . '
							</h3>
						</div>
					</td>
				</tr>';
        // call the ShowAdmCategoryConfig() methode
        $context['pmx']['editcategory']->pmxc_ShowAdmCategoryConfig();
        echo '
			</table>';
    }
    echo '
		</form>';
}
/**
* Receive all the Posts from Settings Manager, check and save it.
* Finally the Admin settings are prepared and the templare loaded.
*/
function PortaMx_AdminSettings()
{
    global $boarddir, $scripturl, $smcFunc, $context, $modSettings, $txt, $pmxCacheFunc;
    $admMode = PortaMx_makeSafe($_GET['action']);
    $pmx_area = PortaMx_makeSafe($_GET['area']);
    if (($admMode == 'admin' || $admMode == 'portamx') && ($pmx_area == 'pmx_settings' || $pmx_area == 'pmx_sefengine') && allowPmx('pmx_admin')) {
        if ($admMode == 'admin') {
            // fix the linktree
            foreach ($context['linktree'] as $key => $data) {
                if (strpos($data['url'], 'pmx_settings') !== false || strpos($data['url'], 'pmx_sefengine') !== false) {
                    $context['linktree'] = array_merge(array_slice($context['linktree'], 0, $key), array(array('url' => $scripturl . '?action=admin;area=pmx_center;' . $context['session_var'] . '=' . $context['session_id'], 'name' => $txt['pmx_extension'])), array_slice($context['linktree'], $key, count($context['linktree']) - $key));
                    break;
                }
            }
        }
        require_once $context['pmx_sourcedir'] . 'AdminSubs.php';
        $context['pmx']['subaction'] = isset($_GET['sa']) ? $_GET['sa'] : ($pmx_area == 'pmx_sefengine' ? '' : 'globals');
        // From template ?
        if (PortaMx_checkPOST()) {
            checkSession('post');
            $currentPanel = '';
            // check the Post array
            if (isset($_POST['save_settings']) && !empty($_POST['save_settings'])) {
                // check defined numeric vars (check_num_vars holds the posted array to check like [varname][varname] ...)
                if (isset($_POST['check_num_vars'])) {
                    foreach ($_POST['check_num_vars'] as $val) {
                        $data = explode(',', $val);
                        $post = '$_POST' . str_replace(array('[', ']'), array('[\'', '\']'), $data[0]);
                        if (eval("return isset({$post});") && eval("return !is_numeric({$post});")) {
                            eval("{$post} = {$data['1']};");
                        }
                    }
                    unset($_POST['check_num_vars']);
                }
                if (!empty($_POST['curPanel'])) {
                    $currentPanel = 'pn=' . $_POST['curPanel'] . ';';
                }
                // access update?
                if (!empty($_POST['update_access'])) {
                    $perms = array('pmx_promote' => array(), 'pmx_create' => array(), 'pmx_articles' => array(), 'pmx_blocks' => array(), 'pmx_admin' => array());
                    if (isset($_POST['setaccess'])) {
                        foreach ($_POST['setaccess'] as $acsname => $acsdata) {
                            $perms[$acsname] = $acsdata;
                        }
                    }
                    $smcFunc['db_insert']('replace', '
						{db_prefix}portamx_settings', array('varname' => 'string', 'config' => 'string'), array('permissions', serialize($perms)), array('varname'));
                    // clear settins cache
                    $pmxCacheFunc['clean']();
                } elseif (!empty($_POST['update_pmxsef'])) {
                    $arrayToken = array('pmxsef_stripchars', 'pmxsef_actions');
                    foreach ($_POST as $token => $value) {
                        if (substr($token, 0, 7) == 'pmxsef_') {
                            // check...
                            if ($token == 'pmxsef_spacechar') {
                                $_POST[$token] = !in_array(substr($_POST[$token], 0, 1), array('-', '_', '')) ? '-' : (!empty($_POST[$token]) ? substr($_POST[$token], 0, 1) : '');
                            } elseif ($token == 'pmxsef_ssefspace') {
                                $_POST[$token] = substr($_POST[$token], 0, 1);
                            } elseif ($token == 'pmxsef_aliasactions') {
                                $alias = array();
                                $tmp = Pmx_StrToArray($_POST[$token], ',');
                                foreach ($tmp as $d) {
                                    $t = Pmx_StrToArray($d, '=');
                                    if (!in_array($t[0], array('admin', 'portamx'))) {
                                        $alias[$t[1]] = $t[0];
                                    }
                                }
                                $_POST[$token] = serialize($alias);
                            } elseif ($token == 'pmxsef_ignorerequests') {
                                $alias = array();
                                $tmp = Pmx_StrToArray($_POST[$token], ',');
                                foreach ($tmp as $d) {
                                    $t = Pmx_StrToArray($d, '=');
                                    $alias[$t[0]] = $t[1];
                                }
                                $_POST[$token] = serialize($alias);
                            } elseif (in_array($token, $arrayToken)) {
                                $_POST[$token] = implode(',', Pmx_StrToArray($_POST[$token], ','));
                            }
                            if ($token != 'pmxsef_enable') {
                                $smcFunc['db_insert']('replace', '
									{db_prefix}settings', array('variable' => 'string', 'value' => 'string'), array($token, $_POST[$token]), array('variable'));
                            }
                        }
                    }
                    // alway disable SEF if no .htaccess or web.config found
                    if ((file_exists($boarddir . '/.htaccess') || file_exists($boarddir . '/web.config')) == false) {
                        $_POST['pmxsef_enable'] = '0';
                    }
                    // setup the the SMF hooks
                    $hooklist = array('integrate_pre_load' => 'pmxsef_convertSEF', 'integrate_buffer' => 'ob_pmxsef', 'integrate_redirect' => 'pmxsef_Redirect', 'integrate_outgoing_email' => 'pmxsef_EmailOutput', 'integrate_exit' => 'pmxsef_XMLOutput', 'integrate_fix_url' => 'pmxsef_fixurl');
                    // get the hooks from database
                    $smfhooks = array();
                    $request = $smcFunc['db_query']('', '
						SELECT variable, value FROM {db_prefix}settings
						WHERE variable IN ({array_string:hooks})', array('hooks' => array_keys($hooklist)));
                    if ($smcFunc['db_num_rows']($request) > 0) {
                        while ($row = $smcFunc['db_fetch_assoc']($request)) {
                            $smfhooks[$row['variable']] = $row['value'];
                        }
                        $smcFunc['db_free_result']($request);
                    }
                    // update the hooks
                    foreach ($hooklist as $hookname => $value) {
                        if (isset($smfhooks[$hookname])) {
                            $smfhooks[$hookname] = trim((!empty($_POST['pmxsef_enable']) ? $value . ',' : '') . trim(str_replace($value, '', $smfhooks[$hookname]), ','), ',');
                        } else {
                            $smfhooks[$hookname] = trim(!empty($_POST['pmxsef_enable']) ? $value : '');
                        }
                        $smcFunc['db_insert']('replace', '
							{db_prefix}settings', array('variable' => 'string', 'value' => 'string'), array($hookname, $smfhooks[$hookname]), array('variable'));
                    }
                    if (!empty($_POST['pmxsef_enable'])) {
                        $oldState = intval(!empty($modSettings['queryless_urls']));
                        updateSettings(array('queryless_urls' => '0'));
                        $smcFunc['db_insert']('replace', '
								{db_prefix}settings', array('variable' => 'string', 'value' => 'string'), array('oldstate_queryless_urls', $oldState), array('variable'));
                    } else {
                        if (isset($modSettings['oldstate_queryless_urls'])) {
                            updateSettings(array('queryless_urls' => $modSettings['oldstate_queryless_urls']));
                        }
                    }
                    // clear cache
                    $pmxCacheFunc['clean']();
                } else {
                    $config = array();
                    $request = $smcFunc['db_query']('', '
							SELECT config
							FROM {db_prefix}portamx_settings
							WHERE varname = {string:settings}', array('settings' => 'settings'));
                    if ($smcFunc['db_num_rows']($request) > 0) {
                        $row = $smcFunc['db_fetch_assoc']($request);
                        $smcFunc['db_free_result']($request);
                        $config = unserialize($row['config']);
                    }
                    $setKeys = array_diff(array_keys($_POST), array('pmx_fronttheme', 'pmx_frontthempg', 'pmx_ecl', 'pmx_eclmodal', 'pmx_eclmodalmobi', 'pmx_eclmodaltop', 'pmx_eclmodalaction', 'save_settings', 'sa', 'sc'));
                    foreach ($setKeys as $key) {
                        if ($key == 'promotes') {
                            $promo = Pmx_StrToIntArray($_POST[$key]);
                            $smcFunc['db_query']('', '
								UPDATE {db_prefix}portamx_settings
									SET config = {string:config}
									WHERE varname = {string:settings}', array('config' => serialize($promo), 'settings' => 'promotes'));
                            // find all promoted block
                            $blocks = null;
                            $request = $smcFunc['db_query']('', '
								SELECT id
								FROM {db_prefix}portamx_blocks
								WHERE active = 1 AND blocktype = {string:blocktype}', array('blocktype' => 'promotedposts'));
                            while ($row = $smcFunc['db_fetch_assoc']($request)) {
                                $blocks[] = $row['id'];
                            }
                            $smcFunc['db_free_result']($request);
                            $_SESSION['pmx_refresh_promote'] = $blocks;
                        } else {
                            if ($key == 'dl_access') {
                                $_POST['dl_access'] = implode(',', $_POST['dl_access']);
                            }
                            $config[$key] = $_POST[$key];
                        }
                    }
                    $smcFunc['db_query']('', '
						UPDATE {db_prefix}portamx_settings
							SET config = {string:config}
							WHERE varname = {string:settings}', array('config' => serialize($config), 'settings' => 'settings'));
                    // other settings they stored in smf_settings table
                    $setKeys = array('pmx_fronttheme', 'pmx_frontthempg', 'pmx_ecl', 'pmx_eclmodal', 'pmx_eclmodalmobi', 'pmx_eclmodaltop', 'pmx_eclmodalaction', 'pmx_quickreply');
                    foreach ($setKeys as $key) {
                        if (isset($_POST[$key])) {
                            $smcFunc['db_insert']('replace', '
								{db_prefix}settings', array('variable' => 'string', 'value' => 'string'), array($key, $_POST[$key]), array('variable'));
                        }
                    }
                    // set frontmode flag
                    $smcFunc['db_insert']('replace', '
						{db_prefix}settings', array('variable' => 'string', 'value' => 'string'), array('pmx_frontmode', $config['frontpage'] == 'none' ? '0' : '1'), array('variable'));
                    if (isset($_POST['pmx_ecl'])) {
                        pmx_setcookie('pmx_eclauth', '');
                        if (!empty($_POST['pmx_ecl'])) {
                            pmx_setECL_Cookie(true);
                        }
                    }
                    // clear cached values
                    $pmxCacheFunc['clean']();
                }
            }
            redirectexit('action=' . $admMode . ';area=' . $pmx_area . (!empty($context['pmx']['subaction']) ? ';sa=' . $context['pmx']['subaction'] : '') . ';' . $currentPanel . $context['session_var'] . '=' . $context['session_id']);
        }
        // SEF engine settings ?
        if ($pmx_area == 'pmx_sefengine') {
            // pmxsef default settings
            $context['pmx']['pmxsef_enable'] = '0';
            $context['pmx']['pmxsef_lowercase'] = '1';
            $context['pmx']['pmxsef_autosave'] = '0';
            $context['pmx']['pmxsef_spacechar'] = '-';
            $context['pmx']['pmxsef_ssefspace'] = '';
            $context['pmx']['pmxsef_stripchars'] = '&quot;,&amp;,&lt;,&gt;,~,!,@,#,$,%,^,&,*,(,),-,=,+,<,[,{,],},>,;,:,\',",/,?,\\,|';
            $context['pmx']['pmxsef_singletoken'] = 'add,advanced,all,asc,calendar,check,children,conversation,desc,home,kstart,nw,profile,save,sound,togglebar,topicseen,view,viewweek,xml';
            $context['pmx']['pmxsef_actions'] = 'about:mozilla,about:unknown,activate,admin,announce,attachapprove,buddy,calendar,clock,collapse,community,coppa,credits,deletemsg,display,dlattach,editpoll,editpoll2,emailuser,findmember,groups,help,helpadmin,im,jseditor,jsmodify,jsoption,keepalive,lock,lockvoting,login,login2,logout,markasread,mergetopics,mlist,moderate,modifycat,modifykarma,movetopic,movetopic2,notify,notifyboard,openidreturn,pm,portamx,post,post2,printpage,profile,promote,quotefast,quickmod,quickmod2,recent,register,register2,reminder,removepoll,removetopic2,reporttm,requestmembers,restoretopic,search,search2,sendtopic,smstats,suggest,spellcheck,splittopics,stats,sticky,trackip,unread,unreadreplies,verificationcode,viewprofile,vote,viewquery,viewsmfile,who,.xml,xmlhttp';
            $context['pmx']['pmxsef_ignoreactions'] = '';
            $context['pmx']['pmxsef_aliasactions'] = '';
            $context['pmx']['pmxsef_ignorerequests'] = '';
            $context['pmx']['pmxsef_codepages'] = '/PortaMx/sefcodepages/x';
            $nocheck = array('pmxsef_enable', 'pmxsef_lowercase', 'pmxsef_spacechar');
            // read the settings from database
            $request = $smcFunc['db_query']('', '
				SELECT variable, value FROM {db_prefix}settings
				WHERE variable LIKE {string:variable}', array('variable' => 'pmxsef_%'));
            if ($smcFunc['db_num_rows']($request) > 0) {
                while ($row = $smcFunc['db_fetch_assoc']($request)) {
                    $value = trim($row['value']);
                    if ($row['variable'] == 'pmxsef_aliasactions') {
                        $tmp = unserialize($value);
                        if (!empty($tmp)) {
                            foreach ($tmp as $act => $alias) {
                                $context['pmx'][$row['variable']][] = $alias . '=' . $act;
                            }
                            $context['pmx'][$row['variable']] = implode(',', $context['pmx'][$row['variable']]);
                        }
                    } elseif ($row['variable'] == 'pmxsef_ignorerequests') {
                        $tmp = unserialize($value);
                        if (!empty($tmp)) {
                            foreach ($tmp as $act => $alias) {
                                $context['pmx'][$row['variable']][] = $act . '=' . $alias;
                            }
                            $context['pmx'][$row['variable']] = implode(',', $context['pmx'][$row['variable']]);
                        }
                    } elseif (in_array($row['variable'], $nocheck) || !empty($value)) {
                        $context['pmx'][$row['variable']] = $value;
                    }
                }
                $smcFunc['db_free_result']($request);
            }
            // check if enabled
            $request = $smcFunc['db_query']('', '
				SELECT value FROM {db_prefix}settings
				WHERE variable = {string:hook}', array('hook' => 'integrate_pre_load'));
            if ($smcFunc['db_num_rows']($request) > 0) {
                $row = $smcFunc['db_fetch_assoc']($request);
                $smcFunc['db_free_result']($request);
                if (strpos($row['value'], 'pmxsef_convertSEF') !== false) {
                    $context['pmx']['pmxsef_enable'] = '1';
                }
            }
        } else {
            $context['pmx']['admthemes'] = PortaMx_getsmfThemes();
            $context['pmx']['admgroups'] = PortaMx_getUserGroups(true);
            $context['pmx']['limitgroups'] = PortaMx_getUserGroups(true, false);
            $context['pmx']['acsgroups'] = PortaMx_getUserGroups(false, !empty($context['pmx']['settings']['postcountacs']));
            $context['pmx']['sysstat'] = $pmxCacheFunc['stat']();
            $request = $smcFunc['db_query']('', '
				SELECT variable, value FROM {db_prefix}settings
				WHERE variable IN ({array_string:vars})', array('vars' => array('pmx_fronttheme', 'pmx_frontthempg', 'pmx_ecl', 'pmx_eclmodal', 'pmx_eclmodalmobi', 'pmx_eclmodaltop', 'pmx_eclmodalaction')));
            if ($smcFunc['db_num_rows']($request) > 0) {
                while ($row = $smcFunc['db_fetch_assoc']($request)) {
                    $context['pmx'][$row['variable']] = $row['value'];
                }
                $smcFunc['db_free_result']($request);
            }
        }
        // setup pagetitle
        $context['page_title'] = $txt['pmx_settings'];
        $context['pmx']['AdminMode'] = $admMode;
        // load language and execute template
        loadLanguage($context['pmx_templatedir'] . 'AdminSettings');
        loadTemplate($context['pmx_templatedir'] . 'AdminSettings');
    } else {
        fatal_error($txt['pmx_acces_error']);
    }
}
/**
* 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>';
}