/**
     * AdmBlock_content().
     * Load the WYSIWYG Editor, to create or edit the content.
     * Returns the AdmBlock_settings
     */
    function pmxc_AdmBlock_content()
    {
        global $context, $txt, $boarddir;
        // show the content area
        echo '
					<td valign="top" colspan="2" style="padding:4px;">
						<div class="cat_bar catbg_grid">
							<h4 class="catbg catbg_grid"><span class="cat_left_title">' . $txt['pmx_edit_content'] . '</span></h4>
						</div>';
        // show the editor
        $allow = allowPmx('pmx_admin') || allowPmx('pmx_blocks');
        $fnd = explode('/', str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']));
        $smfpath = str_replace('\\', '/', $boarddir);
        foreach ($fnd as $key => $val) {
            $fnd[$key] = $val;
            $rep[] = '';
        }
        $filepath = trim(str_replace($fnd, $rep, $smfpath), '/') . '/CustomImages';
        if (count($fnd) == count(explode('/', $smfpath))) {
            $filepath = '/' . $filepath;
        }
        $_SESSION['pmx_ckfm'] = array('ALLOW' => $allow, 'FILEPATH' => $filepath);
        echo '
						<textarea name="' . $context['pmx']['htmledit']['id'] . '">' . $context['pmx']['htmledit']['content'] . '</textarea>
						<script type="text/javascript">
							CKEDITOR.replace("' . $context['pmx']['htmledit']['id'] . '", {filebrowserBrowseUrl: "ckeditor/fileman/index.php"});
						</script>
					</td>
				</tr>
				<tr>';
        // return the default settings
        return $this->pmxc_AdmBlock_settings();
    }
/**
* Init all variables and load the settings from the database.
* Check the requests and prepare the templates to load.
*/
function PortaMxAllocator()
{
    global $context, $txt;
    $allocate = array('pmx_center' => array('AdminCenter.php', 'PortaMx_AdminCenter'), 'pmx_languages' => array('AdminCenter.php', 'PortaMx_ShowLanguages'), 'pmx_settings' => array('AdminSettings.php', 'PortaMx_AdminSettings'), 'pmx_blocks' => array('AdminBlocks.php', 'PortaMx_AdminBlocks'), 'pmx_articles' => array('AdminArticles.php', 'PortaMx_AdminArticles'), 'pmx_categories' => array('AdminCategories.php', 'PortaMx_AdminCategories'), 'pmx_sefengine' => array('AdminSettings.php', 'PortaMx_AdminSettings'));
    // load admin language and javascript
    if (isset($_GET['area']) && in_array($_GET['area'], explode(',', $context['pmx']['areas']))) {
        if (allowPmx('pmx_admin, pmx_blocks, pmx_articles, pmx_create')) {
            $_GET[$context['session_var']] = $context['session_id'];
            require_once $context['pmx_sourcedir'] . $allocate[$_GET['area']][0];
            $allocate[$_GET['area']][1]();
        } else {
            fatal_error($txt['pmx_acces_error']);
        }
    } else {
        fatal_error($txt['pmx_acces_error']);
    }
}
    /**
     * Output the Block config screen
     */
    function pmxc_ShowAdmBlockConfig()
    {
        global $context, $settings, $modSettings, $options, $txt;
        echo '
				<tr>
					<td>
						<div class="windowbg" style="margin-top:-3px;">
						<table class="pmx_table">
							<tr>
								<td style="width:50%;padding:4px;">
									<input type="hidden" name="id" value="' . $this->cfg['id'] . '" />
									<input type="hidden" name="pos" value="' . $this->cfg['pos'] . '" />
									<input type="hidden" name="side" value="' . $this->cfg['side'] . '" />
									<input type="hidden" name="active" value="' . $this->cfg['active'] . '" />
									<input type="hidden" name="cache" value="' . $this->cfg['cache'] . '" />
									<input type="hidden" name="contenttype" value="' . ($this->cfg['blocktype'] == 'download' ? 'bbc_script' : $this->cfg['blocktype']) . '" />
									<input type="hidden" name="check_num_vars[]" value="[config][maxheight], \'\'" />
									<div style="height:61px;">
										<div style="float:left;width:100px; padding-top:1px;">' . $txt['pmx_edit_title'] . '</div>';
        // all titles depend on language
        $curlang = '';
        foreach ($context['pmx']['languages'] as $lang => $sel) {
            $curlang = !empty($sel) ? $lang : $curlang;
            echo '
										<span id="' . $lang . '" style="white-space:nowrap;' . (!empty($sel) ? '' : ' display:none;') . '">
											<input style="width:65%;" type="text" name="config[title][' . $lang . ']" value="' . (isset($this->cfg['config']['title'][$lang]) ? htmlspecialchars($this->cfg['config']['title'][$lang], ENT_QUOTES) : '') . '" />
										</span>';
        }
        echo '
										<input id="curlang" type="hidden" value="' . $curlang . '" />
										<div style="clear:both; height:10px;">
											<img style="float:left;" src="' . $context['pmx_imageurl'] . 'arrow_down.gif" alt="*" title="" />
										</div>
										<div style="float:left;width:100px;">' . $txt['pmx_edit_title_lang'] . '
											<img class="info_toggle" onclick=\'Show_help("pmxBH01")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
										</div>
										<select style="float:left;width:165px;" size="1" onchange="setTitleLang(this)">';
        foreach ($context['pmx']['languages'] as $lang => $sel) {
            echo '
											<option value="' . $lang . '"' . (!empty($sel) ? ' selected="selected"' : '') . '>' . $lang . '</option>';
        }
        echo '
										</select>
										<div style="margin-left:280px;">
											<span style="vertical-align:6px;">' . $txt['pmx_edit_title_align'] . '</span>';
        // title align
        if (!isset($this->cfg['config']['title_align'])) {
            $this->cfg['config']['title_align'] = 'left';
        }
        echo '
											<input type="hidden" id="titlealign" name="config[title_align]" value="' . $this->cfg['config']['title_align'] . '" />';
        foreach ($txt['pmx_edit_title_align_types'] as $key => $val) {
            echo '
											<img id="img' . $key . '" src="' . $context['pmx_imageurl'] . 'text_align_' . $key . '.gif" alt="*" title="' . $txt['pmx_edit_title_helpalign'] . $val . '" style="cursor:pointer;vertical-align:1px;' . ($this->cfg['config']['title_align'] == $key ? 'background-color:#e02000;' : '') . '" onclick="setAlign(\'\', \'' . $key . '\')" />';
        }
        echo '
										</div>
									</div>
									<div id="pmxBH01" style="margin-top:5px;" class="info_frame">' . $txt['pmx_edit_titlehelp'] . '
									</div>';
        // Title icons
        $this->cfg['config']['title_icon'] = empty($this->cfg['config']['title_icon']) || $this->cfg['config']['title_icon'] == 'none.gif' ? 'none.png' : $this->cfg['config']['title_icon'];
        echo '
									<div style="float:left;height:40px;">
										<div style="float:left;width:100px; padding-top:8px;">' . $txt['pmx_edit_titleicon'] . '</div>
										<div class="ttliconDiv" onclick="setNewIcon(document.getElementById(\'pWind.icon_sel\'), event)">
											<input id="post_image" type="hidden" name="config[title_icon]" value="' . $this->cfg['config']['title_icon'] . '" />
											<input id="iconDD" value="' . ucfirst(str_replace('.png', '', $this->cfg['config']['title_icon'])) . '" readonly />
											<img id="pWind.icon" class="pwindiconBlk" src="' . $context['pmx_Iconsurl'] . $this->cfg['config']['title_icon'] . '" alt="*" />
											<img class="ddImageBlk" src="' . $context['pmx_imageurl'] . 'state_expanded.png" alt="*" title="" />
										</div>
										<ul class="ttlicondd Blkedit" id="pWind.icon_sel" onclick="updIcon(this)">';
        foreach ($this->title_icons as $file => $name) {
            echo '
											<li id="' . $file . '" class="ttlicon' . ($this->cfg['config']['title_icon'] == $file ? ' active' : '') . '">
												<img src="' . $context['pmx_Iconsurl'] . $file . '" alt="*" /><span>' . $name . '</span>
											</li>';
        }
        echo '
										</ul>
										<script>$("li").hover(function(){$(this).toggleClass("active")});</script>
									</div>';
        // show registered block types
        echo '
								</td>
								<td style="padding:4px;">
									<div style="min-height:50px;">
										<div style="float:left; width:130px; padding-top:2px;">' . $txt['pmx_edit_type'] . '</div>';
        if (allowPmx('pmx_admin')) {
            echo '
										<select id="pmx.check.type" style="width:56%;" size="1" name="blocktype" onchange="FormFunc(\'chg_blocktype\', 1)">';
            foreach ($this->register_blocks as $blocktype => $blockDesc) {
                echo '
											<option value="' . $blocktype . '"' . ($this->cfg['blocktype'] == $blocktype ? ' selected="selected"' : '') . '>' . $blockDesc['description'] . '</option>';
            }
            echo '
										</select>
										<input id="cache_value" type="hidden" name="cache" value="0" />
										<div style="clear:both; line-height:7px;">&nbsp;</div>';
        } else {
            echo '
										<input type="hidden" name="blocktype" value="' . $this->cfg['blocktype'] . '" />
										<input style="width:50%;" type="text" value="' . $this->cfg['blocktype'] . '" disabled="disabled" />';
        }
        // cache settings
        if (!empty($this->can_cached)) {
            echo '
										<div style="float:left; width:127px; padding-top:4px;">' . $txt['pmx_edit_cache'] . '</div>';
            if (in_array($this->cfg['blocktype'], array_keys($context['pmx']['cache']['blocks']))) {
                echo '
										<input style="float:left; margin-top:9px !important;" id="cacheflag" class="input_check" type="checkbox" name="cacheflag" onclick="checkPmxCache(this, ' . $this->cache_time . ')" value="1"' . (!empty($this->cfg['cache']) ? ' checked="checked"' : '') . ' />
										<div style="float:left; margin-left:15px; padding-top:5px;">' . $txt['pmx_edit_cachetime'] . '</div>
										<input style="float:left; margin-top:3px; margin-left:6px;' . (empty($this->cfg['cache']) ? 'background-color:#8898b0;' : '') . '" onkeyup="check_numeric(this)" id="cacheval" type="text" name="cache" value="' . (empty($this->cfg['cache']) ? '0' : (empty($this->cfg['cache']) ? $this->cache_time : $this->cfg['cache'])) . '" size="7" />
										<div class="smalltext" style="float:left; margin-left:3px; padding-top:7px;">' . $txt['pmx_edit_cachetimesec'];
            }
            echo '
											<img class="info_toggle" style="vertical-align:text-top;" onclick=\'Show_help("pmxBH02")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
										</div>
										<div style="clear:both; line-height:4px; margin-top:-4px;">&nbsp;</div>
									</div>';
            if (in_array($this->cfg['blocktype'], array_keys($context['pmx']['cache']['blocks']))) {
                echo '
									<div id="pmxBH02" class="info_frame" style="margin-top:4px">' . $txt['pmx_edit_pmxcachehelp'] . '</div>';
            }
        } else {
            echo '
									<div style="float:left; margin-top:5px; height:20px;">';
            if (empty($this->can_cached)) {
                echo '
										' . $txt['pmx_edit_nocachehelp'];
            }
            echo '
									</div>';
        }
        // Pagename
        if ($this->cfg['side'] == 'pages') {
            echo '
									<div class="adm_clear">
										<div class="adm_clear" style="float:left;width:130px; padding-top:7px;">' . $txt['pmx_edit_pagename'] . '
											<img class="info_toggle" onclick=\'Show_help("pmxBH11")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
										</div>
										<input style="width:56%; margin-top:5px;" onkeyup="check_requestname(this)" type="text" name="config[pagename]" value="' . (!empty($this->cfg['config']['pagename']) ? $this->cfg['config']['pagename'] : '') . '" />
									</div>

									<div id="pmxBH11" class="info_frame" style="margin-top:5px;">' . $txt['pmx_edit_pagenamehelp'] . '
									</div>';
        } else {
            echo '
									<input type="hidden" name="config[pagename]" value="' . (!empty($this->cfg['config']['pagename']) ? $this->cfg['config']['pagename'] : '') . '" />';
        }
        echo '
								</td>
							</tr>
							<tr>';
        /**
         * Call the block depended settings.
         * Because each block can have his own settings, we have to call the settings now.
         */
        $usedClass = $this->pmxc_AdmBlock_content();
        // the group access
        echo '
									<div class="cat_bar catbg_grid grid_padd grid_top">
										<h4 class="catbg catbg_grid">
											<img class="grid_click_image pmxleft" onclick=\'Show_help("pmxBH03")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
											<span class="cat_msg_title">' . $txt['pmx_edit_groups'] . '</span>
										</h4>
									</div>
									<select id="pmxgroups" onchange="changed(\'pmxgroups\');" style="width:83%;" name="acsgrp[]" multiple="multiple" size="5">';
        if (!empty($this->cfg['acsgrp'])) {
            list($grpacs, $denyacs) = Pmx_StrToArray($this->cfg['acsgrp'], ',', '=');
        } else {
            $grpacs = $denyacs = array();
        }
        foreach ($this->smf_groups as $grp) {
            echo '
										<option value="' . $grp['id'] . '=' . intval(!in_array($grp['id'], $denyacs)) . '"' . (in_array($grp['id'], $grpacs) ? ' selected="selected"' : '') . '>' . (in_array($grp['id'], $denyacs) ? '^' : '') . $grp['name'] . '</option>';
        }
        echo '
									</select>
									<div id="pmxBH03" class="info_frame">' . $txt['pmx_edit_groups_help'] . '</div>
									<script type="text/javascript">
										var pmxgroups = new MultiSelect("pmxgroups");
									</script>';
        // Block moderate && ECL block hidden
        if (!isset($this->cfg['config']['can_moderate'])) {
            $this->cfg['config']['can_moderate'] = allowPmx('pmx_admin') ? 0 : 1;
        }
        if (allowPmx('pmx_blocks', true)) {
            echo '
									<input type="hidden" name="config[can_moderate]" value="' . $this->cfg['config']['can_moderate'] . '" />';
        }
        echo '
									<input type="hidden" name="config[check_ecl]" value="0" />';
        // Block moderate and ECL
        if (!empty($modSettings['pmx_ecl']) || !allowPmx('pmx_blocks', true)) {
            echo '
									<div class="cat_bar catbg_grid grid_padd grid_top">
										<h4 class="catbg catbg_grid">
											<span class="cat_msg_title">' . $txt['pmx_block_other_settings'] . '</span>
											</h4>
									</div>';
        }
        if (!allowPmx('pmx_blocks', true)) {
            echo '
									<div class="adm_check">
										<span class="adm_w80">' . $txt['pmx_block_moderate'] . '
											<img class="info_toggle" onclick=\'Show_help("pmxBModHelp")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
										</span>
										<input type="hidden" name="config[can_moderate]" value="0" />
										<div><input class="input_check" type="checkbox" name="config[can_moderate]" value="1"' . (!empty($this->cfg['config']['can_moderate']) ? ' checked="checked"' : '') . ' /></div>
									</div>
									<div id="pmxBModHelp" class="info_frame" style="margin-top:0;">' . $txt['pmx_block_moderatehelp'] . '</div>
									<input type="hidden" name="config[check_ecl]" value="0" />
									<input type="hidden" name="config[check_eclbots]" value="0" />';
        }
        // Block hidden on ECL
        if (!empty($modSettings['pmx_ecl'])) {
            echo '
									<div class="adm_check">
										<span class="adm_w80">' . $txt['pmx_check_elcmode'] . '
										 <img class="info_toggle" onclick=\'Show_help("pmxBeclHelp")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
										</span>
										<div>
											<input class="input_check" type="checkbox" name="config[check_ecl]" value="1"' . (!empty($this->cfg['config']['check_ecl']) ? ' checked="checked"' : '') . ' onclick="showeclbots(this)" />
										</div>
									</div>
									<div id="pmxBeclHelp" class="info_frame" style="margin-top:0;">' . $txt['pmx_block_eclcheckhelp'] . '</div>
									<div id="eclextend" style="display:' . (!empty($this->cfg['config']['check_ecl']) ? 'block' : 'none') . '">
									<div class="adm_check">
										<span class="adm_w80">' . $txt['pmx_check_elcbots'] . '
										 <img class="info_toggle" onclick=\'Show_help("pmxeclHelpbots")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
										</span>
										<div><input id="eclextendinp" class="input_check" type="checkbox" name="config[check_eclbots]" value="1"' . (!empty($this->cfg['config']['check_eclbots']) ? ' checked="checked"' : '') . ' /></div>
									</div>
									<div id="pmxeclHelpbots" class="info_frame" style="margin-top:0;">' . $txt['pmx_block_eclcheckbotshelp'] . '</div>
									<script type="text/javascript">
										function showeclbots(elm) {if(elm.checked == true) document.getElementById("eclextend").style.display = "block"; else {document.getElementById("eclextend").style.display = "none"; document.getElementById("eclextendinp").checked = false;}}
									</script>';
        }
        // the visual options
        echo '
								</td>
								<td style="padding:4px;">
									<div class="cat_bar catbg_grid grid_padd">
										<h4 class="catbg catbg_grid"><span class="cat_left_title">' . $txt['pmx_edit_visuals'] . '</span></h4>
									</div>
									<div style="float:left; height:30px; width:177px;">' . $txt['pmx_edit_cancollapse'] . '</div>
									<input style="padding-left:141px;" type="hidden" name="config[collapse]" value="0" />
									<input class="input_check" id="collapse" type="checkbox" name="config[collapse]" value="1"' . ($this->cfg['config']['visuals']['header'] == 'none' ? ' disabled="disabled"' : ($this->cfg['config']['collapse'] == 1 ? ' checked="checked"' : '')) . ' />
									<div style="clear:both;" /></div>
									<div style="float:left; height:30px; width:180px;">' . $txt['pmx_edit_collapse_state'] . '</div>
									<select style="width:46%;" size="1" name="config[collapse_state]">';
        foreach ($txt['pmx_collapse_mode'] as $key => $text) {
            echo '
										<option value="' . $key . '"' . (isset($this->cfg['config']['collapse_state']) && $this->cfg['config']['collapse_state'] == $key ? ' selected="selected"' : '') . '>' . $text . '</option>';
        }
        echo '
									</select>
									<br style="clear:both;" />
									<div style="float:left; height:30px; width:180px;">' . $txt['pmx_edit_overflow'] . '</div>
									<select style="width:46%;" size="1" id="mxhgt" name="config[overflow]" onchange="checkMaxHeight(this);">';
        foreach ($txt['pmx_overflow_actions'] as $key => $text) {
            echo '
										<option value="' . $key . '"' . (isset($this->cfg['config']['overflow']) && $this->cfg['config']['overflow'] == $key ? ' selected="selected"' : '') . '>' . $text . '</option>';
        }
        echo '
									</select>
									<br style="clear:both;" />
									<div style="float:left; min-height:30px; width:99%;">
										<div style="float:left; min-height:30px; width:180px;">' . $txt['pmx_edit_height'] . '</div>
										<div style="float:left; width:46%">
											<input onkeyup="check_numeric(this)" id="maxheight" type="text" size="4" name="config[maxheight]" value="' . (isset($this->cfg['config']['maxheight']) ? $this->cfg['config']['maxheight'] : '') . '"' . (!isset($this->cfg['config']['overflow']) || empty($this->cfg['config']['overflow']) ? ' disabled="disabled"' : '') . ' /><span class="smalltext">' . $txt['pmx_pixel'] . '</span><span style="display:inline-block; width:3px;"></span>
											<select id="maxheight_sel" style="float:right;width:52%;margin-right:-1%;" size="1" name="config[height]">';
        foreach ($txt['pmx_edit_height_mode'] as $key => $text) {
            echo '
												<option value="' . $key . '"' . (isset($this->cfg['config']['height']) && $this->cfg['config']['height'] == $key ? ' selected="selected"' : '') . '>' . $text . '</option>';
        }
        echo '
											</select>
										</div>
									</dv>
									<br style="clear:both;" />
									<script type="text/javascript">
										checkMaxHeight(document.getElementById("mxhgt"));
									</script>

									<div style="float:left; height:30px; width:180px;">' . $txt['pmx_edit_innerpad'] . '</div>
									<input onkeyup="check_numeric(this, \',\')" type="text" size="4" name="config[innerpad]" value="' . (isset($this->cfg['config']['innerpad']) ? $this->cfg['config']['innerpad'] : '4') . '" /><span class="smalltext">' . $txt['pmx_pixel'] . ' (xy/y,x)</span>
									<br style="clear:both;" />';
        // CSS class settings
        echo '
									<div class="cat_bar catbg_grid grid_padd">
										<h4 class="catbg catbg_grid grid_botpad">
											<div style="float:left; width:177px;"><span class="cat_left_title">' . $txt['pmx_edit_usedclass_type'] . '</span></div>
											<span class="cat_left_title">' . $txt['pmx_edit_usedclass_style'] . '</span>
										</h4>
									</div>
									<div style="margin:0px 2px;">';
        // write out the classes
        foreach ($usedClass as $ucltyp => $ucldata) {
            echo '
										<div style="float:left; width:180px; height:30px; padding-top:2px;">' . $ucltyp . '</div>
										<select' . ($ucltyp == 'frame' || $ucltyp == 'postframe' ? ' id="pmx_' . $ucltyp . '" ' : ' ') . 'style="width:46%;" name="config[visuals][' . $ucltyp . ']" onchange="checkCollapse(this)">';
            foreach ($ucldata as $cname => $class) {
                echo '
											<option value="' . $class . '"' . (!empty($this->cfg['config']['visuals'][$ucltyp]) ? $this->cfg['config']['visuals'][$ucltyp] == $class ? ' selected="selected"' : '' : (substr($cname, 0, 1) == '+' ? ' selected="selected"' : '')) . '>' . substr($cname, 1) . '</option>';
            }
            echo '
										</select>
										<br style="clear:both;" />';
        }
        echo '
									</div>
									<div class="cat_bar catbg_grid grid_padd" style="margin-top:-2px;">
										<h4 class="catbg catbg_grid"><span class="cat_left_title" style="margin-left:-3px;">' . $txt['pmx_edit_canhavecssfile'] . '</span></h4>
									</div>
									<div style="float:left; margin:0px 2px; width:176px;">' . $txt['pmx_edit_cssfilename'] . '</div>
									<select id="sel.css.file" style="width:46%;margin-bottom:2px;" name="config[cssfile]" onchange="pmxChangeCSS(this)">
										<option value=""></option>';
        // custon css files exist ?
        if (!empty($this->custom_css)) {
            // write out custom mpt/css definitions
            foreach ($this->custom_css as $custcss) {
                if (is_array($custcss)) {
                    echo '
										<option value="' . $custcss['file'] . '"' . ($this->cfg['config']['cssfile'] == $custcss['file'] ? ' selected="selected"' : '') . '>' . $custcss['file'] . '</option>';
                }
            }
            echo '
									</select>
									<div style="clear:both;"></div>';
            // write out all class definitions (hidden)
            foreach ($this->custom_css as $custcss) {
                if (is_array($custcss)) {
                    echo '
									<div id="' . $custcss['file'] . '" style="display:none;">';
                    foreach ($custcss['class'] as $key => $val) {
                        if (in_array($key, array_keys($usedClass))) {
                            echo '
										<div style="float:left; width:180px; padding:0 2px;">' . $key . '</div>' . (empty($val) ? sprintf($txt['pmx_edit_nocss_class'], $settings['theme_id']) : $val) . '<br />';
                        }
                    }
                    echo '
									</div>';
                }
            }
            echo '
									<script type="text/javascript">
										var elm = document.getElementById("sel.css.file");
										var fname = elm.options[elm.selectedIndex].value;
										if(document.getElementById(fname))
											document.getElementById(fname).style.display = "";
										function pmxChangeCSS(elm)
										{
											for(i=0; i<elm.length; i++)
											{
												if(document.getElementById(elm.options[i].value))
													document.getElementById(elm.options[i].value).style.display = "none";
											}
											var fname = elm.options[elm.selectedIndex].value;
											if(document.getElementById(fname))
												document.getElementById(fname).style.display = "";
										}
									</script>';
        } else {
            echo '
									</select>
									<div style="clear:both; height:6px;"></div>';
        }
        echo '
								</td>
							</tr>
							<tr>
								<td colspan="2" style="text-align:center;padding:0px 4px 0 4px;"><hr class="pmx_hr" />
									<input class="button_submit" type="button" style="margin-right:10px;" value="' . $txt['pmx_save_exit'] . '" onclick="FormFunc(\'save_edit\', \'1\')" />
									<input class="button_submit" type="button" style="margin-right:10px;" value="' . $txt['pmx_save_cont'] . '" onclick="FormFunc(\'save_edit_continue\', \'1\')" />
									<input class="button_submit" type="button" style="margin-right:10px;" value="' . $txt['pmx_cancel'] . '" onclick="FormFunc(\'cancel_edit\', \'1\')" />
								</td>
							</tr>';
        // the dynamic visibility options
        if (empty($context['pmx']['settings']['manager']['collape_visibility'])) {
            $options['collapse_visual'] = 1;
        } else {
            $options['collapse_visual'] = intval($this->getExtoptions());
        }
        echo '
							<tr>
								<td colspan="2" style="padding:15px 4px 0 4px;">
									<div class="title_bar">
										<h3';
        echo ' class="catbg">';
        echo '
											<span id="upshrinkImgVisual" class="floatright ' . (!empty($options['collapse_visual']) ? 'toggle_up"' : 'toggle_down"') . ' align="bottom"></span>
											<span class="pmxtitle pmxcenter pmxadj_right"><span>' . $txt['pmx_edit_ext_opts'] . '</span></span>
										</h3>
									</div>

									<div id="upshrinkVisual" style="display:' . (!empty($options['collapse_visual']) ? 'block' : 'none') . ';">
										<div class="info_text plainbox" style="margin:5px 0 0;display:block;">
											<img style="vertical-align:-3px;" onclick=\'Toggle_help("pmxBH05")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
											<span>' . $txt['pmx_edit_ext_opts_help'] . '</span>
											<div id="pmxBH05" style="display:none;"><hr class="pmx_hr" />' . $txt['pmx_edit_ext_opts_morehelp'] . '</div>
										</div>
									</div>
								</td>
							</tr>
							<tr>
								<td colspan="2">
									<div id="upshrinkVisual1"' . (!empty($options['collapse_visual']) ? '' : ' style="display:none;"') . '>
										<table class="pmx_table" style="table-layout:fixed;">
											<tr>';
        // on default actions
        echo '
												<td style="padding:4px;">
													<div class="cat_bar catbg_grid grid_padd">
														<h4 class="catbg catbg_grid">
															<img class="grid_click_image pmxleft" onclick=\'Show_help("pmxBH06")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
															<span class="cat_msg_title">' . $txt['pmx_edit_ext_opts_action'] . '</span>
														</h4>
													</div>
													<select id="pmxact" onchange="changed(\'pmxact\');" style="width:90%;" name="config[ext_opts][pmxact][]" multiple="multiple" size="8">';
        // get config data
        $data = $this->getConfigData('config, ext_opts, pmxact');
        foreach ($txt['pmx_action_names'] as $act => $actdesc) {
            echo '
														<option value="' . $act . '=' . (array_key_exists($act, $data) ? $data[$act] . '" selected="selected' : '1') . '">' . (array_key_exists($act, $data) ? $data[$act] == 0 ? '^' : '' : '') . $actdesc . '</option>';
        }
        echo '
													</select>
													<div id="pmxBH06" class="info_frame">' . $txt['pmx_edit_ext_opts_selnote'] . '</div>
													<script type="text/javascript">
														var pmxact = new MultiSelect("pmxact");
													</script>';
        // on boards
        echo '
													<div class="cat_bar catbg_grid grid_padd grid_top">
														<h4 class="catbg catbg_grid">
															<img class="grid_click_image pmxleft" onclick=\'Show_help("pmxBH08")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
															<span class="cat_msg_title">' . $txt['pmx_edit_ext_opts_boards'] . '</span>
														</h4>
													</div>
													<select id="pmxbrd" onchange="changed(\'pmxbrd\');" style="width:90%;" name="config[ext_opts][pmxbrd][]" multiple="multiple" size="8">';
        // get config data
        $data = $this->getConfigData('config, ext_opts, pmxbrd');
        foreach ($this->smf_boards as $brd) {
            echo '
														<option value="' . $brd['id'] . '=' . (array_key_exists($brd['id'], $data) ? $data[$brd['id']] . '" selected="selected' : '1') . '">' . (array_key_exists($brd['id'], $data) ? $data[$brd['id']] == '0' ? '^' : '' : '') . $brd['name'] . '</option>';
        }
        echo '
													</select>
													<div id="pmxBH08" class="info_frame">' . $txt['pmx_edit_ext_opts_selnote'] . '</div>
													<script type="text/javascript">
														var pmxbrd = new MultiSelect("pmxbrd");
													</script>';
        // on theme
        echo '
													<div class="cat_bar catbg_grid grid_padd grid_top">
														<h4 class="catbg catbg_grid">
															<img class="grid_click_image pmxleft" onclick=\'Show_help("pmxBH09a")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
															<span class="cat_msg_title">' . $txt['pmx_edit_ext_opts_themes'] . '</span>
														</h4>
													</div>
													<select id="pmxthm" onchange="changed(\'pmxthm\');" style="width:90%;" name="config[ext_opts][pmxthm][]" multiple="multiple" size="2">';
        // get config data
        $data = $this->getConfigData('config, ext_opts, pmxthm');
        foreach ($this->smf_themes as $thid => $thdata) {
            echo '
														<option value="' . $thid . '=' . (array_key_exists($thid, $data) ? $data[$thid] . '" selected="selected' : '1') . '">' . (array_key_exists($thid, $data) ? $data[$thid] == 0 ? '^' : '' : '') . $thdata['name'] . ' (' . $thid . ')</option>';
        }
        echo '
													</select>
													<div id="pmxBH09a" class="info_frame">' . $txt['pmx_edit_ext_opts_selnote'] . '</div>
													<script type="text/javascript">
														var pmxthm = new MultiSelect("pmxthm");
													</script>
												</td>';
        // custom action
        echo '
												<td style="padding:4px;">
													<div class="cat_bar catbg_grid grid_padd">
														<h4 class="catbg catbg_grid">
															<img class="grid_click_image pmxleft" onclick=\'Show_help("pmxBH07")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
															<span class="cat_msg_title">' . $txt['pmx_edit_ext_opts_custaction'] . '</span>
														</h4>
													</div>
													<textarea class="adm_textarea" style="min-height:69px;width:90% !important;" rows="2" name="config[ext_opts][pmxcust]">' . $this->cfg['config']['ext_opts']['pmxcust'] . '</textarea>
													<div id="pmxBH07" class="info_frame" style="margin-top:5px;">' . $txt['pmx_edit_ext_opts_custhelp'] . '</div>';
        // hide on Maintenance?
        echo '
													<div class="adm_check grid_top">
														<span class="adm_w80">' . $txt['pmx_edit_ext_maintenance'] . '</span>
														<input type="hidden" name="config[maintenance_mode]" value="0" />
														<input class="input_check" type="checkbox" name="config[maintenance_mode]" value="1"' . (!empty($this->cfg['config']['maintenance_mode']) ? ' checked="checked"' : '') . ' />
													</div>';
        // on language
        echo '
													<div class="cat_bar catbg_grid grid_padd grid_top">
														<h4 class="catbg catbg_grid">
															<img class="grid_click_image pmxleft" onclick=\'Show_help("pmxBH09")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
															<span class="cat_msg_title">' . $txt['pmx_edit_ext_opts_languages'] . '</span>
														</h4>
													</div>
													<select id="pmxlng" onchange="changed(\'pmxlng\');" style="width:90%;" name="config[ext_opts][pmxlng][]" multiple="multiple" size="2">';
        // get config data
        $data = $this->getConfigData('config, ext_opts, pmxlng');
        foreach ($context['pmx']['languages'] as $lang => $sel) {
            echo '
														<option value="' . $lang . '=' . (array_key_exists($lang, $data) ? $data[$lang] . '" selected="selected' : '1') . '">' . (array_key_exists($lang, $data) ? $data[$lang] == 0 ? '^' : '' : '') . ucfirst($lang) . '</option>';
        }
        echo '
													</select>
													<div id="pmxBH09" class="info_frame">' . $txt['pmx_edit_ext_opts_selnote'] . '</div>
													<script type="text/javascript">
														var pmxlng = new MultiSelect("pmxlng");
													</script>';
        // mobile or other devices
        echo '
													<div class="cat_bar catbg_grid grid_padd grid_top">
														<h4 class="catbg catbg_grid">
															<img class="grid_click_image pmxleft" onclick=\'Show_help("pmxBHmb")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
															<span class="cat_msg_title">' . $txt['pmx_blocks_devices'] . '</span>
														</h4>
													</div>
													<input type="hidden" name="config[ext_opts][device]" value="0" />
													<div class="adm_check"><span class="adm_w80">' . $txt['pmx_devices']['all'] . '</span>
														<input class="input_check" type="radio" name="config[ext_opts][device]" value="0"' . (empty($this->cfg['config']['ext_opts']['device']) ? ' checked="checked"' : '') . ' />
													</div>
													<div class="adm_check"><span class="adm_w80">' . $txt['pmx_devices']['mobil'] . '</span>
														<input class="input_check" type="radio" name="config[ext_opts][device]" value="1"' . (!empty($this->cfg['config']['ext_opts']['device']) && $this->cfg['config']['ext_opts']['device'] == '1' ? ' checked="checked"' : '') . ' />
													</div>
													<div class="adm_check"><span class="adm_w80">' . $txt['pmx_devices']['desk'] . '</span>
														<input class="input_check" type="radio" name="config[ext_opts][device]" value="2"' . (!empty($this->cfg['config']['ext_opts']['device']) && $this->cfg['config']['ext_opts']['device'] == '2' ? ' checked="checked"' : '') . ' />
													</div>
													<div id="pmxBHmb" class="info_frame">' . $txt['pmx_blocks_deviceshelp'] . '</div>';
        // Frontpage block placing on Page request
        if ($this->cfg['side'] == 'front') {
            echo '
													<div class="cat_bar catbg_grid grid_padd">
														<h4 class="catbg catbg_grid">
															<img class="grid_click_image pmxleft" onclick=\'Show_help("pmxBHf1")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
															<span class="cat_msg_title">' . $txt['pmx_edit_frontplacing'] . '</span>
														</h4>
													</div>
													<input type="hidden" name="config[frontmode]" value="" />
													<input type="hidden" name="config[frontview]" value="" />

													<div class="adm_check"><span class="adm_w80">' . $txt['pmx_edit_frontplacing_hide'] . '</span>
														<input class="input_check" type="radio" name="config[frontplace]" value="hide"' . (isset($this->cfg['config']['frontplace']) && $this->cfg['config']['frontplace'] == 'hide' || empty($this->cfg['config']['frontplace']) ? ' checked="checked"' : '') . ' />
													</div>
													<div class="adm_check"><span class="adm_w80">' . $txt['pmx_edit_frontplacing_before'] . '</span>
														<input class="input_check" type="radio" name="config[frontplace]" value="before"' . (isset($this->cfg['config']['frontplace']) && $this->cfg['config']['frontplace'] == 'before' ? ' checked="checked"' : '') . ' />
													</div>
													<div class="adm_check"><span class="adm_w80">' . $txt['pmx_edit_frontplacing_after'] . '</span>
														<input class="input_check" type="radio" name="config[frontplace]" value="after"' . (isset($this->cfg['config']['frontplace']) && $this->cfg['config']['frontplace'] == 'after' ? ' checked="checked"' : '') . ' />
													</div>
													<div id="pmxBHf1" class="info_frame">' . $txt['pmx_edit_frontplacinghelp'] . '</div>';
        } elseif ($this->cfg['side'] == 'pages') {
            echo '
													<div class="cat_bar catbg_grid grid_padd grid_top">
														<h4 class="catbg catbg_grid">
															<img class="grid_click_image pmxleft" onclick=\'Show_help("pmxBHf2")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
															<span class="cat_msg_title">' . $txt['pmx_edit_frontmode'] . '</span>
														</h4>
													</div>
													<input type="hidden" name="config[frontplace]" value="hide" />
													<input type="hidden" name="config[frontview]" value="" />

													<div class="adm_check"><span class="adm_w80">' . $txt['pmx_edit_frontmode_none'] . '</span>
														<input class="input_check" type="radio" name="config[frontmode]" value=""' . (empty($this->cfg['config']['frontmode']) ? ' checked="checked"' : '') . ' />
													</div>
													<div class="adm_check"><span class="adm_w80">' . $txt['pmx_edit_frontmode_center'] . '</span>
														<input class="input_check" type="radio" name="config[frontmode]" value="centered"' . (isset($this->cfg['config']['frontmode']) && $this->cfg['config']['frontmode'] == 'centered' ? ' checked="checked"' : '') . ' />
													</div>
													<div class="adm_check"><span class="adm_w80">' . $txt['pmx_edit_frontmode_full'] . '</span>
														<input class="input_check" type="radio" name="config[frontmode]" value="fullsize"' . (isset($this->cfg['config']['frontmode']) && $this->cfg['config']['frontmode'] == 'fullsize' ? ' checked="checked"' : '') . ' />
													</div>
													<div id="pmxBHf2" class="info_frame">' . $txt['pmx_edit_frontmodehelp'] . '</div>';
        } else {
            echo '
													<div class="cat_bar catbg_grid grid_padd grid_top">
														<h4 class="catbg catbg_grid">
															<img class="grid_click_image pmxleft" onclick=\'Show_help("pmxBHf3")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
															<span class="cat_msg_title">' . $txt['pmx_edit_frontview'] . '</span>
														</h4>
													</div>
													<input type="hidden" name="config[frontplace]" value="hide" />
													<input type="hidden" name="config[frontmode]" value="" />

													<div class="adm_check"><span class="adm_w80">' . $txt['pmx_edit_frontview_any'] . '</span>
														<input class="input_check" type="radio" name="config[frontview]" value=""' . (empty($this->cfg['config']['frontview']) ? ' checked="checked"' : '') . ' />
													</div>
													<div class="adm_check"><span class="adm_w80">' . $txt['pmx_edit_frontview_center'] . '</span>
														<input class="input_check" type="radio" name="config[frontview]" value="centered"' . (isset($this->cfg['config']['frontview']) && $this->cfg['config']['frontview'] == 'centered' ? ' checked="checked"' : '') . ' />
													</div>
													<div class="adm_check"><span class="adm_w80">' . $txt['pmx_edit_frontview_full'] . '</span>
														<input class="input_check" type="radio" name="config[frontview]" value="fullsize"' . (isset($this->cfg['config']['frontview']) && $this->cfg['config']['frontview'] == 'fullsize' ? ' checked="checked"' : '') . ' />
													</div>
													<div id="pmxBHf3" class="info_frame">' . $txt['pmx_edit_frontviewhelp'] . '</div>';
        }
        echo '
												</td>
											</tr>
											<tr>
												<td colspan="2" style="text-align:center;padding:4px;"><hr class="pmx_hr" />
													<input class="button_submit" type="button" style="margin-right:10px;" value="' . $txt['pmx_save_exit'] . '" onclick="FormFunc(\'save_edit\', \'1\')" />
													<input class="button_submit" type="button" style="margin-right:10px;" value="' . $txt['pmx_save_cont'] . '" onclick="FormFunc(\'save_edit_continue\', \'1\')" />
													<input class="button_submit" type="button" style="margin-right:10px;" value="' . $txt['pmx_cancel'] . '" onclick="FormFunc(\'cancel_edit\', \'1\')" />
												</td>
											</tr>
										</table>
									</div>
								</td>
							</tr>
						</table>
						</div>
					</td>
				</tr>';
        // add visual upshrink
        $tmp = '
		var upshrinkVis = new smc_Toggle({
			bToggleEnabled: true,
			bCurrentlyCollapsed: ' . (empty($options['collapse_visual']) ? 'true' : 'false') . ',
			aSwappableContainers: [
				\'upshrinkVisual\',
				\'upshrinkVisual1\'
			],
			aSwapImages: [{
					sId: \'upshrinkImgVisual\',
					altCollapsed: ' . JavaScriptEscape($txt['pmx_expand'] . $txt['pmx_edit_ext_opts']) . ',
					altExpanded: ' . JavaScriptEscape($txt['pmx_collapse'] . $txt['pmx_edit_ext_opts']) . '
			}],
			oCookieOptions: {
				bUseCookie: false
			},
			oThemeOptions: {
				bUseThemeSettings: true,
				sOptionName: \'collapse_visual\',
				sSessionVar: ' . JavaScriptEscape($context['session_var']) . ',
				sSessionId: ' . JavaScriptEscape($context['session_id']) . ',
				sThemeId: \'1\'
			}
		});';
        addInlineJavascript(str_replace("\n", "\n\t", PortaMx_compressJS($tmp)), true);
        unset($tmp);
    }
/**
* Top frame
**/
function Pmx_Frame_top($cfg, $count)
{
    global $context, $scripturl, $options, $txt;
    $context['pmx_framecount']++;
    $context['pmx_frames'][$context['pmx_framecount']] = true;
    if (!empty($cfg['config']['skip_outerframe'])) {
        $context['pmx_frames'][$context['pmx_framecount']] = false;
        return null;
    }
    // get the block title for user language have it or forum default
    $blocktitle = PortaMx_getTitle($cfg['config']);
    // the title align
    $ttladjust = '';
    switch ($cfg['config']['title_align']) {
        case 'left':
            $imgalign = 'right';
            $txtalign = 'left';
            $ttlimg = $txtalign;
            $toggleClass = 'class="float' . $imgalign;
            break;
        case 'right':
            $imgalign = 'left';
            $txtalign = 'right';
            $ttlimg = $txtalign;
            $toggleClass = 'class="float' . $imgalign;
            break;
        case 'center':
            $imgalign = 'right';
            $txtalign = 'center';
            $ttlimg = 'left';
            $toggleClass = 'class="float' . $imgalign;
    }
    if ($cfg['config']['title_icon'] == 'none.png') {
        $cfg['config']['title_icon'] = '';
    }
    if (empty($cfg['config']['title_icon'])) {
        $ttladjust = ' pmxadj';
    }
    if ($cfg['config']['title_align'] == 'center') {
        if (!empty($cfg['config']['title_icon']) && !empty($cfg['config']['collapse']) && $context['pmx']['settings']['shrinkimages'] != 2) {
            $ttladjust = ' pmxadj_center';
        } elseif (empty($cfg['config']['title_icon']) && empty($cfg['config']['collapse'])) {
            $ttladjust = '';
        } elseif (empty($cfg['config']['title_icon'])) {
            $ttladjust = ' pmxadj_' . $imgalign;
        } else {
            $ttladjust = ' pmxadj_' . $ttlimg;
        }
    }
    $cfg['config']['innerpad'] = isset($cfg['config']['innerpad']) ? $cfg['config']['innerpad'] : '4';
    $innerPad = Pmx_getInnerPad($cfg['config']['innerpad']);
    // custom css ?
    if (!empty($cfg['customclass'])) {
        $isCustHeader = !empty($cfg['customclass']['header']);
        $isCustFrame = !empty($cfg['customclass']['frame']);
    } else {
        $isCustHeader = $isCustFrame = false;
    }
    $IDtype = $cfg['blocktype'] . $cfg['id'];
    $frame = false;
    $cfg['noID'] = in_array($cfg['blocktype'], array('category', 'article', 'static_category', 'static_article'));
    $showAcs = allowPmxGroup($cfg['acsgrp']);
    $cfg['active'] = !isset($cfg['active']) ? true : $cfg['active'];
    echo '
						<div' . (empty($cfg['noID']) ? ' id="block.id.' . $cfg['id'] . '" ' : '') . ' style="margin-bottom:' . (empty($count) ? '0' : $context['pmx']['settings']['panelpad']) . 'px; overflow:hidden;' . (in_array(strtolower($cfg['side']), array('left', 'right')) ? 'width:' . $context['pmx']['settings'][strtolower($cfg['side']) . '_panel']['size'] . 'px; padding-' . (strtolower($cfg['side']) == 'left' ? 'right:' : 'left:') . $context['pmx']['settings']['panelpad'] . 'px;' : '') . (empty($cfg['active']) || empty($showAcs) ? 'display:none;' : '') . '">';
    // show the collapse, if set and have a header
    $head_bar = !empty($cfg['config']['visuals']['header']) && $cfg['config']['visuals']['header'] !== 'hide' ? str_replace('bg', '_bar', $cfg['config']['visuals']['header']) : '';
    if (!empty($cfg['config']['visuals']['header']) && $cfg['config']['visuals']['header'] != 'none' || empty($cfg['config']['visuals']['header']) && !empty($cfg['config']['visuals']['body'])) {
        echo '
							<div class="' . (!empty($head_bar) ? $head_bar : 'title_no_bar') . '">
								<h3';
        if (!empty($cfg['config']['collapse']) && $context['pmx']['settings']['shrinkimages'] != 2) {
            if (!isset($options['collapse' . $IDtype])) {
                $cook = pmx_getcookie('pmx_upshr' . $IDtype, false);
                $options['collapse' . $IDtype] = is_null($cook) ? '0' : $cook;
            }
        } else {
            $options['collapse' . $IDtype] = '0';
        }
        echo ' class="' . (!empty($cfg['config']['visuals']['header']) ? $cfg['config']['visuals']['header'] : $cfg['config']['visuals']['body']) . ' cbodypad">';
        // show the collapse / expand icon
        if (!empty($cfg['config']['collapse'])) {
            echo '
									<span id="upshrink_' . $IDtype . '_Img" ' . (empty($options['collapse' . $IDtype]) ? $toggleClass . $context['pmx_img_expand'] : $toggleClass . $context['pmx_img_colapse']) . ' title="' . (empty($options['collapse' . $IDtype]) ? $txt['pmx_collapse'] : $txt['pmx_expand']) . $blocktitle . '"></span>';
        }
        // show the title icon is set
        if (!empty($cfg['config']['title_icon'])) {
            echo '
									<img class="title_images pmx' . $ttlimg . '" src="' . $context['pmx_Iconsurl'] . $cfg['config']['title_icon'] . '" alt="*" title="' . $blocktitle . '" />';
        }
        echo '
									<span class="pmxtitle pmx' . $txtalign . $ttladjust . '">';
        // if quickedit link the title to blockedit?
        if (!empty($context['pmx']['settings']['manager']['qedit']) && allowPmx('pmx_admin') && !empty($blocktitle)) {
            $btyp = str_replace('static_', '', $cfg['blocktype']);
            echo '
										<a href="' . $scripturl . '?action=' . (allowPmx('pmx_admin', true) ? 'portamx' : 'admin') . ';area=pmx_' . (in_array($btyp, array('category', 'article')) ? $btyp == 'category' ? 'categories;sa=edit;id=' . preg_replace('/_[0-9]+/', '', $cfg['catid']) : 'articles;sa=edit;id=' . preg_replace('/_[0-9]+/', '', $cfg['id']) : 'blocks;sa=' . $cfg['side']) . ';edit=' . preg_replace('/_[0-9]+/', '', $cfg['id']) . ';' . $context['session_var'] . '=' . $context['session_id'] . '" onclick="pmxsetEditTop(this)">' . $blocktitle . '</a>';
        } else {
            echo '
									' . (empty($blocktitle) ? '&nbsp;' : $blocktitle);
        }
        echo '
									</span>
								</h3>
							</div>';
    }
    // show content frame
    $frameclass = $cfg['config']['visuals']['frame'] . ' ' . $cfg['config']['visuals']['body'] . (strpos($head_bar, 'notrnd') !== false ? ' notrnd' : '');
    if (!empty($cfg['config']['visuals']['frame']) || $isCustFrame) {
        echo '
							<div' . (!empty($cfg['config']['collapse']) ? ' id="upshrink_' . $IDtype . '"' . (empty($options['collapse' . $IDtype]) ? '' : ' style="display:none;"') : '') . '>
								<div class="' . $frameclass . '" style="padding:' . $innerPad[0] . 'px ' . $innerPad[1] . 'px !important; margin-top:0px;">
									<div';
    } else {
        echo '
							<div' . (!empty($cfg['config']['collapse']) ? ' id="upshrink_' . $IDtype . '"' . (empty($options['collapse' . $IDtype]) ? '' : ' style="display:none;"') : '') . (!empty($cfg['config']['visuals']['body']) ? ' class="blockcontent fr_' . $head_bar . ' ' . $cfg['config']['visuals']['body'] . '"' : '') . '>
								<div' . (!empty($hashead) ? ' class="pmx_noframe_' . $cfg['blocktype'] . '"' : '') . ' style="padding:' . $innerPad[0] . 'px ' . $innerPad[1] . 'px !important;">
									<div';
    }
    // have a bodytext class ?
    if (!empty($cfg['config']['visuals']['bodytext'])) {
        echo ' class="' . $cfg['config']['visuals']['bodytext'] . '"';
    }
    // have overflow and (min-/max-)height?
    if (!empty($cfg['config']['overflow'])) {
        echo ' style="' . (isset($cfg['config']['maxheight']) && !empty($cfg['config']['maxheight']) ? (empty($cfg['config']['height']) ? 'max-height' : $cfg['config']['height']) . ':' . $cfg['config']['maxheight'] . 'px;' : '') . 'overflow:' . $cfg['config']['overflow'] . ';text-overflow:ellipsis;white-space:nowrap;"';
    }
    echo '>';
    // if header or frame and can collaps?
    if (!empty($cfg['config']['collapse']) && $cfg['config']['visuals']['header'] != 'none') {
        $tmp = '
		var ' . $IDtype . ' = new smc_Toggle({
		bToggleEnabled: true,
		bCurrentlyCollapsed: ' . (empty($options['collapse' . $IDtype]) ? 'false' : 'true') . ',
		aSwappableContainers: [
			\'upshrink_' . $IDtype . '\'
		],
		aSwapImages: [
			{
				sId: \'upshrink_' . $IDtype . '_Img\',';
        if ($context['pmx']['settings']['shrinkimages'] == '0') {
            $tmp .= '
				srcCollapsed: \'' . $context['pmx_img_colapse'] . '\',
				altCollapsed: ' . JavaScriptEscape($txt['pmx_expand'] . $blocktitle) . ',';
        } else {
            $tmp .= '
				altCollapsed: ' . JavaScriptEscape($txt['pmx_expand'] . $blocktitle) . ',';
        }
        if ($context['pmx']['settings']['shrinkimages'] == '0') {
            $tmp .= '
				srcExpanded: \'' . $context['pmx_img_expand'] . '\',
				altExpanded: ' . JavaScriptEscape($txt['pmx_collapse'] . $blocktitle) . '
			}';
        } else {
            $tmp .= '
				altExpanded: ' . JavaScriptEscape($txt['pmx_collapse'] . $blocktitle) . '
			}';
        }
        $tmp .= '
		],
		oCookieOptions: {
			bUseCookie: true,
			sCookieName: \'' . 'pmx_upshr' . $IDtype . '\',
			sCookieValue: \'' . $options['collapse' . $IDtype] . '\'
		}
	});';
        addInlineJavascript("\t" . str_replace("\n", "\n\t", PortaMx_compressJS($tmp)), true);
        unset($tmp);
    }
}
 /**
  * InitContent.
  * Checks the cache status and create the content.
  */
 function pmxc_InitContent()
 {
     global $context, $pmxCacheFunc;
     // requested category and limited to admins??
     if (empty($this->cfg['static_block'])) {
         if (!empty($this->cfg['config']['request']) && !allowPmx('pmx_admin')) {
             $this->visible = false;
         }
         // requested category ecl check
         if (!empty($this->cfg['config']['check_ecl']) && !pmx_checkECL_Cookie(!empty($this->cfg['config']['check_eclbots']))) {
             $this->visible = false;
         }
     }
     // if visible init the content
     if ($this->visible) {
         $this->postKey = 'pmxpost_' . (!empty($this->cfg['static_block']) ? 'cat_block' : $this->cfg['blocktype']) . $this->cfg['id'] . (!empty($this->inBlockCall) ? '_0' : '');
         $this->postarray[$this->postKey] = array('cat' => '', 'child' => '', 'art' => '', 'pg' => '0');
         // cleanup $_GET for vars we need here
         $GETpost = null;
         if (!empty($_GET)) {
             $GETpost = $_GET;
             $tmp = array_diff(array_keys($this->postarray[$this->postKey]), array_keys($GETpost));
             while (list($d, $key) = each($tmp)) {
                 unset($GETpost[$key]);
             }
         }
         if (empty($GETpost) && empty($_POST[$this->postKey]) && !empty($_SESSION['PortaMx'][$this->postKey])) {
             $this->postarray[$this->postKey] = array_merge($this->postarray[$this->postKey], $_SESSION['PortaMx'][$this->postKey]);
         }
         if (empty($this->postarray[$this->postKey]['cat']) && !empty($this->cfg['static_block'])) {
             $this->postarray[$this->postKey]['cat'] = $this->cfg['config']['settings']['category'];
         }
         // reset current page ?
         if (!empty($_POST[$this->postKey])) {
             $data = array('cat' => '', 'child' => '', 'art' => '', 'pg' => '0');
             if (!empty($_POST[$this->postKey])) {
                 $this->postarray[$this->postKey] = pmx_GetPostKey($this->postKey, $data);
             } else {
                 if (isset($_SESSION['PortaMx'][$this->postKey])) {
                     $this->postarray[$this->postKey] = $_SESSION['PortaMx'][$this->postKey];
                 }
                 $data = $this->postarray[$this->postKey] = array_merge($this->postarray[$this->postKey], $GETpost);
             }
         } elseif (empty($GETpost) && empty($_POST[$this->postKey]) && isset($_SESSION['PortaMx'][$this->postKey])) {
             $this->postarray[$this->postKey] = $_SESSION['PortaMx'][$this->postKey];
         }
         if (!empty($GETpost)) {
             $this->postarray[$this->postKey] = array_merge($this->postarray[$this->postKey], $GETpost);
         }
         $_SESSION['PortaMx'][$this->postKey] = $this->postarray[$this->postKey];
         // called from static category block?
         if (!empty($this->cfg['static_block'])) {
             // get the category
             if (!empty($this->cfg['cache'])) {
                 $cachedata = $pmxCacheFunc['get']($this->cache_key, $this->cache_mode);
             } else {
                 $cachedata = null;
             }
             if ($cachedata !== null) {
                 list($this->categories, $this->articles) = $cachedata;
                 $cats = $this->categories[$this->cfg['config']['settings']['category']];
             } else {
                 $cats = PortaMx_getCatByID(null, $this->cfg['config']['settings']['category']);
                 $cats['config'] = unserialize($cats['config']);
                 // inherit acs from block?
                 if (!empty($this->cfg['config']['settings']['inherit_acs'])) {
                     $cats['acsgrp'] = $this->cfg['acsgrp'];
                 }
                 // Main cat can show?
                 if (!allowPmxGroup($cats['acsgrp'])) {
                     return false;
                 }
                 // Main cat ecl check
                 if (!empty($cats['config']['check_ecl']) && !pmx_checkECL_Cookie(!empty($cats['config']['check_eclbots']))) {
                     return false;
                 }
                 // get category(s) and articles
                 $this->getCatsAndChilds($cats, $cats['acsgrp'], !empty($cats['config']['settings']['inherit_acs']));
                 if (!empty($this->cfg['cache'])) {
                     $pmxCacheFunc['put']($this->cache_key, array($this->categories, $this->articles), $this->cache_time, $this->cache_mode);
                 }
             }
             // check category elc
             foreach ($this->categories as $eclKey => $eclCat) {
                 if (!empty($eclCat['config']['check_ecl']) && !pmx_checkECL_Cookie(!empty($eclCat['config']['check_eclbots']))) {
                     unset($this->categories[$eclKey]);
                 }
             }
             $this->postarray[$this->postKey]['cat'] = $cats['name'];
             $this->firstcat = !empty($this->postarray[$this->postKey]['child']) ? $this->postarray[$this->postKey]['child'] : $cats['name'];
             $this->curCat = null;
             if (isset($this->categories[$this->firstcat])) {
                 $this->curCat = $this->categories[$this->firstcat];
             }
             if (!is_null($this->curCat) && !empty($this->postarray[$this->postKey]['art'])) {
                 $found = false;
                 foreach ($this->articles[$this->curCat['name']] as $article) {
                     $found = $article['name'] == $this->postarray[$this->postKey]['art'] ? true : $found;
                 }
             } else {
                 $found = true;
             }
             if (!is_null($this->curCat) && !empty($found)) {
                 if ($this->cfg['config']['settings']['usedframe'] == 'block') {
                     $this->curCat['config']['visuals'] = $this->cfg['config']['visuals'];
                     $this->curCat['config']['csfile'] = $this->cfg['config']['cssfile'];
                 }
                 // check framemode
                 if ($this->cfg['config']['settings']['usedframe'] == 'cat') {
                     $this->cfg['config']['skip_outerframe'] = true;
                     $this->curCat['catid'] = $this->curCat['id'];
                 } else {
                     $this->curCat['config']['skip_outerframe'] = true;
                     $this->curCat['config']['visuals']['frame'] = $this->cfg['config']['visuals']['frame'];
                     $this->cfg['catid'] = $this->cfg['id'];
                     $this->cfg['blocktype'] = 'catblock';
                 }
             } else {
                 $this->visible = false;
             }
         } else {
             // get cat data and all childs
             $cats = PortaMx_getCatByID(null, $this->postarray[$this->postKey]['cat']);
             // Main cat can show?
             if (!allowPmxGroup($cats['acsgrp'])) {
                 return false;
             }
             // Main cat ecl check
             if (!empty($cats['config']['check_ecl']) && !pmx_checkECL_Cookie(!empty($cats['config']['check_eclbots']))) {
                 return false;
             }
             // get categoy(s) and articles
             $this->getCatsAndChilds($cats, $cats['acsgrp'], !empty($cats['config']['settings']['inherit_acs']));
             $this->firstcat = !empty($this->postarray[$this->postKey]['child']) ? $this->postarray[$this->postKey]['child'] : $this->postarray[$this->postKey]['cat'];
             $this->curCat = null;
             if (isset($this->categories[$this->firstcat])) {
                 $this->curCat = $this->categories[$this->firstcat];
             }
             if (!is_null($this->curCat) && !empty($this->postarray[$this->postKey]['art'])) {
                 $found = false;
                 foreach ($this->articles[$this->curCat['name']] as $article) {
                     $found = $article['name'] == $this->postarray[$this->postKey]['art'] ? true : $found;
                 }
             } else {
                 $found = true;
             }
             if (!is_null($this->curCat) && !empty($found)) {
                 // save titles for linktree
                 $context['pmx']['pagenames']['cat'] = $this->categories[$cats['name']]['title'];
                 if (empty($context['pmx']['pagenames']['cat'])) {
                     $context['pmx']['pagenames']['cat'] = htmlspecialchars($cats['name'], ENT_QUOTES);
                 }
                 if (!empty($this->postarray[$this->postKey]['child'])) {
                     $context['pmx']['pagenames']['child'] = $this->curCat['title'];
                     if (empty($context['pmx']['pagenames']['child'])) {
                         $context['pmx']['pagenames']['child'] = htmlspecialchars($this->curCat['name'], ENT_QUOTES);
                     }
                 }
                 $this->cfg['uniID'] = 'cat' . $this->categories[$cats['name']]['id'];
                 $this->cfg['config']['skip_outerframe'] = true;
                 $this->curCat['catid'] = $this->curCat['id'];
             } else {
                 $this->visible = false;
             }
         }
     }
     if (!empty($this->visible) && !empty($this->articles)) {
         // handle special php articles
         foreach ($this->articles as $cn => $artlist) {
             foreach ($artlist as $id => $article) {
                 if ($article['ctype'] == 'php' && preg_match('~\\[\\?pmx_initphp(.*)pmx_initphp\\?\\]~is', $article['content'], $match)) {
                     eval($match[1]);
                 }
                 if (!empty($article['config']['cssfile'])) {
                     $this->getCustomCSS($article);
                 }
             }
         }
     }
     return $this->visible;
 }
/**
* Called for each block.
*/
function PmxBlocksOverview($block, $side, $cfg_titleicons, $cfg_smfgroups)
{
    global $context, $txt;
    if (!allowPmx('pmx_admin', true) && allowPmx('pmx_blocks', true)) {
        if (empty($block['config']['can_moderate'])) {
            return false;
        }
    }
    if (empty($block['config']['title_align'])) {
        $block['config']['title_align'] = 'left';
    }
    if (empty($block['config']['title_icon'])) {
        $block['config']['title_icon'] = 'none.png';
    }
    // pos row
    echo '
							<div class="pmx_tbl_tr">
								<div class="pmx_tbl_tdgrid" id="RowMove-' . $block['id'] . '" style="white-space:nowrap;">
									<div id="Img.RowMove-' . $block['id'] . '" class="pmx_clickrow' . (allowPmx('pmx_admin') ? ' pmx_moveimg" title="' . $txt['row_move_updown'] . '" onclick="pmxRowMove(\'' . $block['id'] . '\', \'' . $side . '\')"' : '"') . '>
										<div id="pWind.pos.' . $side . '.' . $block['id'] . '" style="padding-left:20px;margin-top:-2px;width:22px;">' . $block['pos'] . '</div>
									</div>
								</div>';
    // title row
    echo '
								<div class="pmx_tbl_tdgrid">
									<div onclick="pmxSetTitle(\'' . $block['id'] . '\', \'' . $side . '\')"  title="' . $txt['pmx_click_edit_ttl'] . '" style="cursor:pointer;">
										<img id="uTitle.icon.' . $block['id'] . '" style="text-align:left;padding-right:4px;" src="' . $context['pmx_Iconsurl'] . $block['config']['title_icon'] . '" alt="*" title="' . substr($txt['pmx_edit_titleicon'], 0, -1) . '" />
										<img id="uTitle.align.' . $block['id'] . '" style="text-align:right;" src="' . $context['pmx_imageurl'] . 'text_align_' . $block['config']['title_align'] . '.gif" alt="*" title="' . $txt['pmx_edit_title_align'] . $txt['pmx_edit_title_align_types'][$block['config']['title_align']] . '" />
										<span id="sTitle.text.' . $block['id'] . '.' . $side . '">' . (isset($block['config']['title'][$context['pmx']['currlang']]) ? htmlspecialchars($block['config']['title'][$context['pmx']['currlang']], ENT_QUOTES) : '') . '</span>';
    foreach ($context['pmx']['languages'] as $lang => $sel) {
        echo '
										<input id="sTitle.text.' . $lang . '.' . $block['id'] . '.' . $side . '" type="hidden" value="' . (isset($block['config']['title'][$lang]) ? htmlspecialchars($block['config']['title'][$lang], ENT_QUOTES) : '') . '" />';
    }
    echo '
										<input id="sTitle.icon.' . $block['id'] . '" type="hidden" value="' . $block['config']['title_icon'] . '" />
										<input id="sTitle.align.' . $block['id'] . '" type="hidden" value="' . $block['config']['title_align'] . '" />
									</div>
								</div>';
    // type row
    echo '
								<div class="pmx_tbl_tdgrid">
									<div id="pWind.desc.' . $side . '.' . $block['id'] . '" title="' . $context['pmx']['RegBlocks'][$block['blocktype']]['blocktype'] . ' ' . $context['pmx']['RegBlocks'][$block['blocktype']]['description'] . ' (ID:' . $block['id'] . ')' . ($block['side'] == 'pages' ? ', Name: ' . $block['config']['pagename'] : '') . '"><img src="' . $context['pmx_imageurl'] . 'type_' . $context['pmx']['RegBlocks'][$block['blocktype']]['icon'] . '.gif" alt="*" />&nbsp;<span style="cursor:default;">' . $context['pmx']['RegBlocks'][$block['blocktype']]['description'] . '</span></div>
								</div>';
    // create acs groups for acs Popup
    if (!empty($block['acsgrp'])) {
        list($grpacs, $denyacs) = Pmx_StrToArray($block['acsgrp'], ',', '=');
    } else {
        $grpacs = $denyacs = array();
    }
    // check extent options
    $extOpts = false;
    if (!empty($block['config']['ext_opts'])) {
        foreach ($block['config']['ext_opts'] as $k => $v) {
            $extOpts = !empty($v) ? true : $extOpts;
        }
    }
    // options row
    echo '
								<div class="pmx_tbl_tdgrid" id="RowAccess.' . $block['id'] . '">
									<input id="grpAcs.' . $block['id'] . '" type="hidden" value="' . implode(',', $grpacs) . '" />
									<input id="denyAcs.' . $block['id'] . '" type="hidden" value="' . implode(',', $denyacs) . '" />
									<div>
										<div id="pWind.grp.' . $block['id'] . '" class="pmx_clickrow' . (!empty($block['acsgrp']) ? ' pmx_access" title="' . $txt['pmx_have_groupaccess'] : '') . '"></div>
										<div class="pmx_clickrow' . (!empty($block['config']['can_moderate']) ? ' pmx_moderate"  title="' . $txt['pmx_have_modaccess'] : '') . '"></div>
										<div class="pmx_clickrow' . (!empty($extOpts) ? ' pmx_dynopts" title="' . $txt['pmx_have_dynamics'] : '') . '"></div>
										<div class="pmx_clickrow' . (!empty($block['config']['cssfile']) ? ' pmx_custcss" title="' . $txt['pmx_have_cssfile'] : '') . '"></div>
										<div class="pmx_clickrow' . (!empty($block['config']['check_ecl']) ? ' pmx_eclsettings" title="' . $txt['pmx_have_ecl_settings'] : '') . '"></div>
										<div class="pmx_clickrow' . (!empty($block['cache']) ? ' pmx_cache" title="' . $txt['pmx_have_caching'] . $block['cache'] . $txt['pmx_edit_cachetimesec'] : '') . '"></div>
									</div>
								</div>';
    // status row
    echo '
								<div class="pmx_tbl_tdgrid" style="text-align:center">
									<div style="margin-left:14px;" id="status.' . $block['id'] . '" class="pmx_clickrow' . ($block['active'] ? ' pmx_active" title="' . $txt['pmx_status_activ'] : ' pmx_notactive" title="' . $txt['pmx_status_inactiv']) . ' - ' . $txt['pmx_status_change'] . '" onclick="pToggleStatus(' . $block['id'] . ', \'' . $block['side'] . '\')"></div>
								</div>';
    // functions row
    echo '
								<div class="pmx_tbl_tdgrid">
									<div class="pmx_clickrow pmx_pgedit" title="' . $txt['pmx_edit_sideblock'] . '" onclick="FormFunc(\'edit_block\', \'' . $block['id'] . '\')"></div>
									<div class="pmx_clickrow pmx_grpacs" title="' . $txt['pmx_chg_blockaccess'] . '" onclick="pmxSetAcs(\'' . $block['id'] . '\', \'' . $block['side'] . '\')"></div>
									<div class="pmx_clickrow' . (allowPmx('pmx_admin') ? ' pmx_pgclone" title="' . $txt['pmx_clone_sideblock'] . '" onclick="pmxSetCloneMove(\'' . $block['id'] . '\', \'' . $block['side'] . '\', \'clone\', \'' . $block['blocktype'] . '\')"' : '"') . '></div>
									<div class="pmx_clickrow' . (allowPmx('pmx_admin') ? ' pmx_pgmove" title="' . $txt['pmx_move_sideblock'] . '" onclick="pmxSetCloneMove(\'' . $block['id'] . '\', \'' . $block['side'] . '\', \'move\', \'' . $block['blocktype'] . '\')"' : '"') . '></div>
									<div class="pmx_clickrow' . (allowPmx('pmx_admin') ? ' pmx_pgdelete" title="' . $txt['pmx_delete_sideblock'] . '" onclick="pmxSetDelete(\'' . $block['id'] . '\', \'' . $block['side'] . '\')"' : '"') . '></div>
								</div>
							</div>';
    return true;
}
    /**
     * Output the Article config screen
     */
    function pmxc_ShowAdmArticleConfig()
    {
        global $context, $settings, $modSettings, $boarddir, $options, $txt;
        echo '
				<tr>
					<td>
						<div class="windowbg">
						<table class="pmx_table">
							<tr>
								<td style="width:50%;padding:4px;">
									<input type="hidden" name="id" value="' . $this->cfg['id'] . '" />
									<input type="hidden" name="owner" value="' . $this->cfg['owner'] . '" />
									<input type="hidden" name="contenttype" value="' . $this->cfg['ctype'] . '" />
									<input type="hidden" name="config[settings]" value="" />
									<input type="hidden" name="active" value="' . $this->cfg['active'] . '" />
									<input type="hidden" name="approved" value="' . $this->cfg['approved'] . '" />
									<input type="hidden" name="approvedby" value="' . $this->cfg['approvedby'] . '" />
									<input type="hidden" name="created" value="' . $this->cfg['created'] . '" />
									<input type="hidden" name="updated" value="' . $this->cfg['updated'] . '" />
									<input type="hidden" name="updatedby" value="' . $this->cfg['updatedby'] . '" />
									<input type="hidden" name="check_num_vars[]" value="[config][maxheight], \'\'" />
									<div style="height:61px;">
										<div style="float:left;width:100px; padding-top:1px;">' . $txt['pmx_article_title'] . '</div>';
        // all titles depend on language
        $curlang = '';
        foreach ($context['pmx']['languages'] as $lang => $sel) {
            $curlang = !empty($sel) ? $lang : $curlang;
            echo '
										<span id="' . $lang . '" style="white-space:nowrap;' . (!empty($sel) ? '' : ' display:none;') . '">
											<input style="width:65%;" type="text" name="config[title][' . $lang . ']" value="' . (isset($this->cfg['config']['title'][$lang]) ? htmlspecialchars($this->cfg['config']['title'][$lang], ENT_QUOTES) : '') . '" />
										</span>';
        }
        echo '
										<input id="curlang" type="hidden" value="' . $curlang . '" />
										<div style="clear:both; height:10px;">
											<img style="float:left;" src="' . $context['pmx_imageurl'] . 'arrow_down.gif" alt="*" title="" />
										</div>
										<div style="float:left; width:100px;">' . $txt['pmx_edit_title_lang'] . '
											<img class="info_toggle" onclick=\'Show_help("pmxBH01")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
										</div>
										<select style="float:left; width:165px;" size="1" onchange="setTitleLang(this)">';
        foreach ($context['pmx']['languages'] as $lang => $sel) {
            echo '
											<option value="' . $lang . '"' . (!empty($sel) ? ' selected="selected"' : '') . '>' . $lang . '</option>';
        }
        echo '
										</select>
										<div style="margin-left:280px;">
											<span style="vertical-align:6px;">' . $txt['pmx_edit_title_align'] . '</span>';
        // title align
        if (!isset($this->cfg['config']['title_align'])) {
            $this->cfg['config']['title_align'] = 'left';
        }
        echo '
											<input type="hidden" id="titlealign" name="config[title_align]" value="' . $this->cfg['config']['title_align'] . '" />';
        foreach ($txt['pmx_edit_title_align_types'] as $key => $val) {
            echo '
											<img id="img' . $key . '" src="' . $context['pmx_imageurl'] . 'text_align_' . $key . '.gif" alt="*" title="' . $txt['pmx_edit_title_helpalign'] . $val . '" style="cursor:pointer;vertical-align:1px;' . ($this->cfg['config']['title_align'] == $key ? 'background-color:#e02000;' : '') . '" onclick="setAlign(\'\', \'' . $key . '\')" />';
        }
        echo '
										</div>
									</div>
									<div id="pmxBH01" style="margin-top:4px;" class="info_frame">' . $txt['pmx_edit_titlehelp'] . '
									</div>';
        // Title icons
        $this->cfg['config']['title_icon'] = empty($this->cfg['config']['title_icon']) || $this->cfg['config']['title_icon'] == 'none.gif' ? 'none.png' : $this->cfg['config']['title_icon'];
        echo '
									<div style="float:left;height:40px;">
										<div style="float:left;width:100px; padding-top:8px;">' . $txt['pmx_edit_titleicon'] . '</div>
										<div class="ttliconDiv" onclick="setNewIcon(document.getElementById(\'pWind.icon_sel\'), event)">
											<input id="post_image" type="hidden" name="config[title_icon]" value="' . $this->cfg['config']['title_icon'] . '" />
											<input id="iconDD" value="' . ucfirst(str_replace('.png', '', $this->cfg['config']['title_icon'])) . '" readonly />
											<img id="pWind.icon" class="pwindiconBlk" src="' . $context['pmx_Iconsurl'] . $this->cfg['config']['title_icon'] . '" alt="*" />
											<img class="ddImageBlk" src="' . $context['pmx_imageurl'] . 'state_expanded.png" alt="*" title="" />
										</div>
										<ul class="ttlicondd Artedit" id="pWind.icon_sel" onclick="updIcon(this)">';
        foreach ($this->title_icons as $file => $name) {
            echo '
											<li id="' . $file . '" class="ttlicon' . ($this->cfg['config']['title_icon'] == $file ? ' active' : '') . '">
												<img src="' . $context['pmx_Iconsurl'] . $file . '" alt="*" /><span>' . $name . '</span>
											</li>';
        }
        echo '
										</ul>
										<script>$("li").hover(function(){$(this).toggleClass("active")});</script>
									</div>';
        // show article types
        echo '
								</td>
								<td style="padding:4px;">
									<div style="float:left;width:130px;">' . $txt['pmx_article_type'] . '</div>';
        $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');
        if (allowPmx('pmx_admin, pmx_create')) {
            echo '
									<select style="width:60%;" size="1" name="ctype" onchange="FormFunc(\'edit_change\', \'1\')">';
            foreach ($RegBlocks as $type => $articleType) {
                echo '
										<option value="' . $type . '"' . ($this->cfg['ctype'] == $type ? ' selected="selected"' : '') . '>' . $articleType['description'] . '</option>';
            }
            echo '
									</select>';
        } else {
            echo '
									<input type="hidden" name="ctype" value="' . $this->cfg['ctype'] . '" />
									<input style="width:60%;" value="' . $RegBlocks[$this->cfg['ctype']]['description'] . '" disabled="disabled" />';
        }
        // all exist categories
        $selcats = array_merge(array(PortaMx_getDefaultCategory($txt['pmx_categories_none'])), $this->categories);
        $ordercats = array_merge(array(0), $context['pmx']['catorder']);
        $isWriter = allowPmx('pmx_create, pmx_articles', true);
        $isAdm = allowPmx('pmx_admin');
        echo '
										<div style="float:left;width:130px;margin-top:9px;">' . $txt['pmx_article_cats'] . '</div>
										<select style="width:60%;margin-top:9px;" size="1" name="catid">';
        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'] . '"' . ($cat['id'] == $this->cfg['catid'] ? ' selected="selected"' : '') . '">' . str_repeat('&bull;', $cat['level']) . ' ' . $cat['name'] . '</option>';
            }
        }
        echo '
										</select>
									</div>';
        // articlename
        echo '
									<div style="float:left;width:130px;margin-top:9px">' . $txt['pmx_article_name'] . '
										<img class="info_toggle" onclick=\'Show_help("pmxBH11")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
									</div>
									<input id="check.name" style="width:60%;margin-top:9px" onkeyup="check_requestname(this)" onkeypress="check_requestname(this)" type="text" name="name" value="' . $this->cfg['name'] . '" />
									<span id="check.name.error" style="display:none;">' . sprintf($txt['namefielderror'], $txt['pmx_article_name']) . '</span>
									<div id="pmxBH11" class="info_frame" style="margin-top:5px;">' . $txt['pmx_edit_pagenamehelp'] . '
									</div>
								</td>
							</tr>';
        // the editor area dependent on article type
        echo '
							<tr>
								<td colspan="2" style="padding:4px 4px 10px 4px;">';
        // show the editor
        if ($this->cfg['ctype'] == 'html') {
            $allow = allowPmx('pmx_admin') || allowPmx('pmx_blocks');
            $fnd = explode('/', str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']));
            $smfpath = str_replace('\\', '/', $boarddir);
            foreach ($fnd as $key => $val) {
                $fnd[$key] = $val;
                $rep[] = '';
            }
            $filepath = trim(str_replace($fnd, $rep, $smfpath), '/') . '/CustomImages';
            if (count($fnd) == count(explode('/', $smfpath))) {
                $filepath = '/' . $filepath;
            }
            $_SESSION['pmx_ckfm'] = array('ALLOW' => $allow, 'FILEPATH' => $filepath);
            echo '
								<div class="cat_bar catbg_grid">
									<h4 class="catbg catbg_grid"><span class="cat_left_title">' . $txt['pmx_edit_content'] . '</span></h4>
								</div>
								<textarea name="' . $context['pmx']['htmledit']['id'] . '">' . $context['pmx']['htmledit']['content'] . '</textarea>
								<script type="text/javascript">
									CKEDITOR.replace("' . $context['pmx']['htmledit']['id'] . '", {filebrowserBrowseUrl: "ckeditor/fileman/index.php"});
								</script>';
        } elseif ($this->cfg['ctype'] == 'bbc_script') {
            echo '
								<style type="text/css">
									.sceditor-container iframe{width:99.1% !important;}
									.sceditor-container{max-width:inherit;width:inherit !important; margin-right:-2px;}
									textarea{max-width:99% !important;width:99.2% !important;}
								</style>
								<div class="cat_bar catbg_grid" style="margin-right:1px;">
									<h4 class="catbg catbg_grid"><span class="cat_left_title">' . $txt['pmx_edit_content'] . '</span></h4>
								</div>
								<input type="hidden" id="smileyset" value="PortaMx" />
								<div id="bbcBox_message"></div>
								<div id="smileyBox_message"></div>
								<div style="padding-right:3px;margin-top:-10px;">', template_control_richedit($context['pmx']['editorID'], 'smileyBox_message', 'bbcBox_message'), '</div>';
        } elseif ($this->cfg['ctype'] == 'php') {
            $options['collapse_phpinit'] = empty($context['pmx']['phpInit']['havecont']);
            echo '
								<div class="cat_bar catbg_grid">
									<h4 class="catbg catbg_grid">
										<span style="float:right;display:block;margin-top:-2px;">
											<img onclick="php_syntax(\'' . $context['pmx']['phpShow']['id'] . '\')" style="padding:3px 5px 3px 10px;cursor:pointer;" alt="Syntax check" title="' . $txt['pmx_check_phpsyntax'] . '" src="' . $context['pmx_imageurl'] . 'syntaxcheck.png" class="pmxright" />
										</span>
										<span class="cat_left_title">' . $txt['pmx_edit_content'] . '
										<span id="upshrinkPHPinitCont"' . (empty($options['collapse_phpinit']) ? '' : ' style="display:none;"') . '>' . $txt['pmx_edit_content_show'] . '</span></span>
									</h4>
								</div>

								<div id="check_' . $context['pmx']['phpShow']['id'] . '" class="info_frame" style="line-height:1.4em;margin:1px 0;"></div>

								<textarea name="' . $context['pmx']['phpShow']['id'] . '" id="' . $context['pmx']['phpShow']['id'] . '" style="display:block;resize:vertical;width:' . $context['pmx']['phpShow']['width'] . ';height:' . $context['pmx']['phpShow']['height'] . ';">' . $context['pmx']['phpShow']['value'] . '</textarea>

								<div class="plainbox info_text" style="margin-top:5px;margin-right:0px;padding:5px 0 7px 0;display:block;">
									<div class="normaltext" style="margin:0 10px;">
									' . (empty($context['pmx']['phpInit']['havecont']) ? '<span style="margin-top:2px;margin-right:-4px;" id="upshrinkPHPshowImg" class="floatright ' . (empty($options['collapse_visual']) ? 'toggle_up" align="bottom"' : 'toggle_down" align="bottom"') . ' title="' . (empty($options['collapse_visual']) ? $txt['pmx_collapse'] : $txt['pmx_expand']) . $txt['pmx_php_partblock'] . '">
										</span>' : '') . '
										<span>' . $txt['pmx_php_partblock_note'] . '
											<img class="info_toggle" onclick=\'Toggle_help("pmxPHPH01")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" style="vertical-align: -3px;" />
										</span>
									</div>
									<div id="pmxPHPH01" style="display:none; margin:4px 10px 0;">' . $txt['pmx_php_partblock_help'] . '</div>
								</div>

								<div id="upshrinkPHPshowCont"' . (empty($options['collapse_phpinit']) ? '' : ' style="margin-top:5px;display:none;"') . '>
									<div class="cat_bar catbg_grid">
										<h4 class="catbg catbg_grid">
											<span style="float:right;display:block;margin-top:-2px;">
												<img onclick="php_syntax(\'' . $context['pmx']['phpInit']['id'] . '\')" style="padding:3px 5px 3px 10px;cursor:pointer;" title="' . $txt['pmx_check_phpsyntax'] . '" alt="Syntax check" src="' . $context['pmx_imageurl'] . 'syntaxcheck.png" class="pmxright" />
											</span>
											<span class="cat_left_title">' . $txt['pmx_edit_content'] . $txt['pmx_edit_content_init'] . '</span>
										</h4>
									</div>
									<div id="check_' . $context['pmx']['phpInit']['id'] . '" class="info_frame" style="line-height:1.4em;margin:1px 0;"></div>

									<textarea name="' . $context['pmx']['phpInit']['id'] . '" id="' . $context['pmx']['phpInit']['id'] . '" style="display:block;width:' . $context['pmx']['phpInit']['width'] . ';height:' . $context['pmx']['phpInit']['height'] . ';">' . $context['pmx']['phpInit']['value'] . '</textarea>
								</div>';
            if (empty($context['pmx']['phpInit']['havecont'])) {
                addInlineJavascript("\t" . str_replace("\n", "\n\t", PortaMx_compressJS('
						var upshrinkPHPshow = new smc_Toggle({
							bToggleEnabled: true,
							bCurrentlyCollapsed: ' . (empty($options['collapse_phpinit']) ? 'false' : 'true') . ',
							aSwappableContainers: [
								\'upshrinkPHPshowCont\',
								\'upshrinkPHPinitCont\'
							],
							aSwapImages: [
								{
									sId: \'upshrinkPHPshowImg\',
									altCollapsed: ' . JavaScriptEscape($txt['pmx_expand'] . $txt['pmx_php_partblock']) . ',
									altExpanded: ' . JavaScriptEscape($txt['pmx_collapse'] . $txt['pmx_php_partblock']) . '
								}
							],
							oCookieOptions: {
									bUseCookie: false
								}
						});')), true);
            }
        } else {
            echo '
									<div class="cat_bar catbg_grid">
										<h4 class="catbg catbg_grid"><span class="cat_left_title">' . $txt['pmx_edit_content'] . '</span></h4>
									</div>
									<textarea name="' . $context['pmx']['script']['id'] . '" id="' . $context['pmx']['script']['id'] . '" style="display:block;width:' . $context['pmx']['script']['width'] . ';height:' . $context['pmx']['script']['height'] . ';">' . $context['pmx']['script']['value'] . '</textarea>';
        }
        echo '
								</td>
							</tr>
							<tr>
								<td style="padding:4px;">
									<div style="min-height:182px;">
										<input type="hidden" name="config[settings]" value="" />';
        // show the settings area
        echo '
										<div class="cat_bar catbg_grid grid_padd">
											<h4 class="catbg catbg_grid"><span class="cat_left_title">' . $txt['pmx_articles_types'][$this->cfg['ctype']] . ' ' . $txt['pmx_article_settings_title'] . '</span></h4>
										</div>
										<div>';
        if ($this->cfg['ctype'] == 'html') {
            echo '
											<div class="adm_check">
												<span class="adm_w80">' . $txt['pmx_html_teaser'] . '
													<img class="info_toggle" onclick=\'Show_help("pmxHTMLH01")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
												</span>
												<input type="hidden" name="config[settings][teaser]" value="0" />
												<div><input class="input_check" type="checkbox" name="config[settings][teaser]" value="1"' . (isset($this->cfg['config']['settings']['teaser']) && !empty($this->cfg['config']['settings']['teaser']) ? ' checked="checked"' : '') . ' /></div>
											</div>
											<div id="pmxHTMLH01" class="info_frame" style="margin-top:4px;">' . str_replace('@@', '<img src="' . $context['pmx_imageurl'] . 'pgbreak.png" alt="*" style="vertical-align:-5px;"/>', $txt['pmx_html_teasehelp']) . '</div>';
        } elseif ($this->cfg['ctype'] != 'php') {
            echo '
											<div class="adm_check">
												<span class="adm_w80">' . sprintf($txt['pmx_article_teaser'], $txt['pmx_teasemode'][intval(!empty($context['pmx']['settings']['teasermode']))]) . '
													<img class="info_toggle" onclick=\'Show_help("pmxHTMLH02")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
												</span>
												<div><input type="text" size="5" name="config[settings][teaser]" value="' . (isset($this->cfg['config']['settings']['teaser']) ? $this->cfg['config']['settings']['teaser'] : '') . '" /></div>
											</div>
											<div id="pmxHTMLH02" class="info_frame" style="margin-top:4px;">' . $txt['pmx_article_teasehelp'] . '</div>';
        }
        echo '
											<div class="adm_check">
												<span class="adm_w80">' . $txt['pmx_content_print'] . '</span>
												<input type="hidden" name="config[settings][printing]" value="0" />
												<div><input class="input_check" type="checkbox" name="config[settings][printing]" value="1"' . (!empty($this->cfg['config']['settings']['printing']) ? ' checked="checked"' : '') . ' /></div>
											</div>

											<div class="adm_check">
												<span class="adm_w80">' . $txt['pmx_article_footer'] . '
													<img class="info_toggle" onclick=\'Show_help("pmxARTH01")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
												</span>
												<input type="hidden" name="config[settings][showfooter]" value="0" />
												<div><input class="input_check" type="checkbox" name="config[settings][showfooter]" value="1"' . (isset($this->cfg['config']['settings']['showfooter']) && !empty($this->cfg['config']['settings']['showfooter']) ? ' checked="checked"' : '') . ' /></div>
											</div>
											<div id="pmxARTH01" class="info_frame" style="margin-top:4px;">' . $txt['pmx_article_footerhelp'] . '</div>
											<input type="hidden" name="config[show_sitemap]" value="0" />';
        if ($this->cfg['ctype'] != 'php') {
            echo '
											<div class="adm_check">
												<span class="adm_w80">' . $txt['pmx_articles_disableHSimage'] . '</span>
												<input type="hidden" name="config[settings][disableHSimg]" value="0" />
												<div><input class="input_check" type="checkbox" name="config[settings][disableHSimg]" value="1"' . (isset($this->cfg['config']['settings']['disableHSimg']) && !empty($this->cfg['config']['settings']['disableHSimg']) ? ' checked="checked"' : '') . (!empty($context['pmx']['settings']['disableHS']) ? ' disabled="disabled"' : '') . ' /></div>
											</div>';
        }
        echo '
										</div>
									</div>';
        // the group access
        echo '
									<div class="cat_bar catbg_grid grid_padd grid_top">
										<h4 class="catbg catbg_grid">
											<img class="grid_click_image pmxleft" onclick=\'Show_help("pmxBH03")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
											<span class="cat_msg_title">' . $txt['pmx_article_groups'] . '</span>
										</h4>
									</div>
									<select id="pmxgroups" onchange="changed(\'pmxgroups\');" style="width:83%;" name="acsgrp[]" multiple="multiple" size="5">';
        if (!empty($this->cfg['acsgrp'])) {
            list($grpacs, $denyacs) = Pmx_StrToArray($this->cfg['acsgrp'], ',', '=');
        } else {
            $grpacs = $denyacs = array();
        }
        foreach ($this->smf_groups as $grp) {
            echo '
										<option value="' . $grp['id'] . '=' . intval(!in_array($grp['id'], $denyacs)) . '"' . (in_array($grp['id'], $grpacs) ? ' selected="selected"' : '') . '>' . (in_array($grp['id'], $denyacs) ? '^' : '') . $grp['name'] . '</option>';
        }
        echo '
									</select>
									<div id="pmxBH03" class="info_frame">' . $txt['pmx_article_groupshelp'] . '</div>
									<script type="text/javascript">
										var pmxgroups = new MultiSelect("pmxgroups");
									</script>';
        // article moderate
        if (!isset($this->cfg['config']['can_moderate'])) {
            $this->cfg['config']['can_moderate'] = 1;
        }
        if (allowPmx('pmx_articles, pmx_create', true)) {
            echo '
									<input type="hidden" name="config[can_moderate]" value="' . $this->cfg['config']['can_moderate'] . '" />';
        }
        if (allowPmx('pmx_admin, pmx_articles, pmx_create')) {
            echo '
									<div class="cat_bar catbg_grid grid_padd grid_top">
										<h4 class="catbg catbg_grid">
											<span class="cat_msg_title">' . $txt['pmx_article_moderate_title'] . '</span>
										</h4>
									</div>';
        }
        if (allowPmx('pmx_admin')) {
            echo '
									<div class="adm_check">
										<span class="adm_w80">' . $txt['pmx_article_moderate'] . '
										</span>
										<input type="hidden" name="config[can_moderate]" value="0" />
										<div><input class="input_check" type="checkbox" name="config[can_moderate]" value="1"' . (!empty($this->cfg['config']['can_moderate']) ? ' checked="checked"' : '') . ' /></div>
									</div>';
        }
        echo '
									<input type="hidden" name="config[check_ecl]" value="0" />
									<input type="hidden" name="config[check_eclbots]" value="0" />';
        if (allowPmx('pmx_admin, pmx_articles, pmx_create') && !empty($modSettings['pmx_ecl'])) {
            echo '
									<div class="adm_check">
										<span class="adm_w80">' . $txt['pmx_check_artelcmode'] . '
										 <img class="info_toggle" onclick=\'Show_help("pmxArteclHelp")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
										</span>
										<div><input class="input_check" type="checkbox" name="config[check_ecl]" value="1"' . (!empty($this->cfg['config']['check_ecl']) ? ' checked="checked"' : '') . ' onclick="showeclbots(this)" /></div>
									</div>
									<div id="pmxArteclHelp" class="info_frame" style="margin-top:0px;">' . $txt['pmx_art_eclcheckhelp'] . '</div>
									<div id="eclextend" style="display:' . (!empty($this->cfg['config']['check_ecl']) ? 'block' : 'none') . '">
									<div class="adm_check">
										<span class="adm_w80">' . $txt['pmx_check_artelcbots'] . '
										 <img class="info_toggle" onclick=\'Show_help("pmxeclHelpbots")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
										</span>
										<div><input id="eclextendinp" class="input_check" type="checkbox" name="config[check_eclbots]" value="1"' . (!empty($this->cfg['config']['check_eclbots']) ? ' checked="checked"' : '') . ' /></div>
									</div>
									<div id="pmxeclHelpbots" class="info_frame" style="margin-top:0;">' . $txt['pmx_art_eclcheckbotshelp'] . '</div>
									<script type="text/javascript">
										function showeclbots(elm) {if(elm.checked == true) document.getElementById("eclextend").style.display = "block"; else {document.getElementById("eclextend").style.display = "none"; document.getElementById("eclextendinp").checked = false;}}
									</script>
								</td>';
        }
        // the visual options
        echo '
								<td id="set_col" style="padding:4px;">
									<div class="cat_bar catbg_grid grid_padd">
										<h4 class="catbg catbg_grid"><span class="cat_left_title">' . $txt['pmx_edit_visuals'] . '</span></h4>
									</div>
									<div style="float:left; height:30px; width:177px;">' . $txt['pmx_edit_cancollapse'] . '</div>
									<input style="padding-left:141px;" type="hidden" name="config[collapse]" value="0" />
									<input class="input_check" id="collapse" type="checkbox" name="config[collapse]" value="1"' . ($this->cfg['config']['visuals']['header'] == 'none' ? ' disabled="disabled"' : ($this->cfg['config']['collapse'] == 1 ? ' checked="checked"' : '')) . ' />
									<div style="clear:both;" /></div>
									<div style="float:left; height:30px; width:180px;">' . $txt['pmx_edit_collapse_state'] . '</div>
									<select style="width:46%;" size="1" name="config[collapse_state]">';
        foreach ($txt['pmx_collapse_mode'] as $key => $text) {
            echo '
										<option value="' . $key . '"' . (isset($this->cfg['config']['collapse_state']) && $this->cfg['config']['collapse_state'] == $key ? ' selected="selected"' : '') . '>' . $text . '</option>';
        }
        echo '
									</select>
									<br style="clear:both;" />
									<div style="float:left; height:30px; width:180px;">' . $txt['pmx_edit_overflow'] . '</div>
									<select style="width:46%;" size="1" id="mxhgt" name="config[overflow]" onchange="checkMaxHeight(this);">';
        foreach ($txt['pmx_overflow_actions'] as $key => $text) {
            echo '
										<option value="' . $key . '"' . (isset($this->cfg['config']['overflow']) && $this->cfg['config']['overflow'] == $key ? ' selected="selected"' : '') . '>' . $text . '</option>';
        }
        echo '
									</select>
									<br style="clear:both;" />
									<div style="float:left; min-height:30px; width:99%;">
										<div style="float:left; min-height:30px; width:180px;">' . $txt['pmx_edit_height'] . '</div>
										<div style="float:left; width:46%">
											<input onkeyup="check_numeric(this)" id="maxheight" type="text" size="4" name="config[maxheight]" value="' . (isset($this->cfg['config']['maxheight']) ? $this->cfg['config']['maxheight'] : '') . '"' . (!isset($this->cfg['config']['overflow']) || empty($this->cfg['config']['overflow']) ? ' disabled="disabled"' : '') . ' /><span class="smalltext">' . $txt['pmx_pixel'] . '</span><span style="display:inline-block; width:3px;"></span>
											<select id="maxheight_sel" style="float:right;width:52%;margin-right:-1%;" size="1" name="config[height]">';
        foreach ($txt['pmx_edit_height_mode'] as $key => $text) {
            echo '
												<option value="' . $key . '"' . (isset($this->cfg['config']['height']) && $this->cfg['config']['height'] == $key ? ' selected="selected"' : '') . '>' . $text . '</option>';
        }
        echo '
											</select>
										</div>
									</div>
									<br style="clear:both;" />
									<script type="text/javascript">
										checkMaxHeight(document.getElementById("mxhgt"));
									</script>

									<div style="float:left; height:30px; width:180px;">' . $txt['pmx_edit_innerpad'] . '</div>
									<input onkeyup="check_numeric(this, \',\')" type="text" size="4" name="config[innerpad]" value="' . (isset($this->cfg['config']['innerpad']) ? $this->cfg['config']['innerpad'] : '4') . '" /><span class="smalltext">' . $txt['pmx_pixel'] . ' (xy/y,x)</span>
									<br style="clear:both;" />';
        // CSS class settings
        echo '
									<div class="cat_bar catbg_grid grid_padd">
										<h4 class="catbg catbg_grid grid_botpad">
											<div style="float:left; width:177px;"><span class="cat_left_title">' . $txt['pmx_edit_usedclass_type'] . '</span></div>
											<span class="cat_left_title">' . $txt['pmx_edit_usedclass_style'] . '</span>
										</h4>
									</div>
									<div style="margin:0px 2px;">';
        // write out the classes
        foreach ($this->usedClass as $ucltyp => $ucldata) {
            echo '
										<div style="float:left; width:180px; height:30px; padding-top:2px;">' . $ucltyp . '</div>
										<select' . ($ucltyp == 'frame' || $ucltyp == 'postframe' ? ' id="pmx_' . $ucltyp . '" ' : ' ') . 'style="width:46%;" name="config[visuals][' . $ucltyp . ']" onchange="checkCollapse(this)">';
            foreach ($ucldata as $cname => $class) {
                echo '
											<option value="' . $class . '"' . (!empty($this->cfg['config']['visuals'][$ucltyp]) ? $this->cfg['config']['visuals'][$ucltyp] == $class ? ' selected="selected"' : '' : (substr($cname, 0, 1) == '+' ? ' selected="selected"' : '')) . '>' . substr($cname, 1) . '</option>';
            }
            echo '
										</select>
										<br style="clear:both;" />';
        }
        echo '
									</div>
									<div class="cat_bar catbg_grid grid_padd" style="margin-top:-2px;">
										<h4 class="catbg catbg_grid"><span class="cat_left_title" style="margin-left:-3px;">' . $txt['pmx_edit_canhavecssfile'] . '</span></h4>
									</div>
									<div style="float:left; margin:0px 2px; width:176px;">' . $txt['pmx_edit_cssfilename'] . '</div>
									<select id="sel.css.file" style="width:46%;margin-bottom:2px;" name="config[cssfile]" onchange="pmxChangeCSS(this)">
										<option value=""></option>';
        // custon css files exist ?
        if (!empty($this->custom_css)) {
            // write out custom mpt/css definitions
            foreach ($this->custom_css as $custcss) {
                if (is_array($custcss)) {
                    echo '
										<option value="' . $custcss['file'] . '"' . ($this->cfg['config']['cssfile'] == $custcss['file'] ? ' selected="selected"' : '') . '>' . $custcss['file'] . '</option>';
                }
            }
            echo '
									</select>
									<div style="clear:both; height:2px;"></div>';
            // write out all class definitions (hidden)
            foreach ($this->custom_css as $custcss) {
                if (is_array($custcss)) {
                    echo '
									<div id="' . $custcss['file'] . '" style="display:none;">';
                    foreach ($custcss['class'] as $key => $val) {
                        if (in_array($key, array_keys($this->usedClass))) {
                            echo '
										<div style="float:left; width:180px; padding:0 2px;">' . $key . '</div>' . (empty($val) ? sprintf($txt['pmx_edit_nocss_class'], $settings['theme_id']) : $val) . '<br />';
                        }
                    }
                    echo '
									</div>';
                }
            }
            echo '
									<script type="text/javascript">
										var elm = document.getElementById("sel.css.file");
										var fname = elm.options[elm.selectedIndex].value;
										if(document.getElementById(fname))
											document.getElementById(fname).style.display = "";
										function pmxChangeCSS(elm)
										{
											for(i=0; i<elm.length; i++)
											{
												if(document.getElementById(elm.options[i].value))
													document.getElementById(elm.options[i].value).style.display = "none";
											}
											var fname = elm.options[elm.selectedIndex].value;
											if(document.getElementById(fname))
												document.getElementById(fname).style.display = "";
										}
									</script>';
        } else {
            echo '
									</select>
									<div style="clear:both; height:6px;"></div>';
        }
        echo '
								</td>
							</tr>
							<tr>
								<td colspan="2" style="text-align:center;padding:4px 4px 0 4px;"><hr class="pmx_hr" />
									<div style="height:10px;"></div>
									<input class="button_submit" type="button" style="margin-right:10px;" value="' . $txt['pmx_save_exit'] . '" onclick="FormFuncCheck(\'save_edit\', \'1\')" />
									<input class="button_submit" type="button" style="margin-right:10px;" value="' . $txt['pmx_save_cont'] . '" onclick="FormFuncCheck(\'save_edit_continue\', \'1\')" />
									<input class="button_submit" type="button" style="margin-right:10px;" value="' . $txt['pmx_cancel'] . '" onclick="FormFunc(\'cancel_edit\', \'1\')" />
								</td>
							</tr>
						</table>
						</div>
					</td>
				</tr>';
    }
/**
* add actions for the Who display
* Called from hook integrate_whos_online
**/
function PortaMx_whos_online($actions)
{
    global $txt, $context, $modSettings;
    if (empty($modSettings['pmxportal_disabled'])) {
        $result = '';
        if (!empty($actions['action']) && $actions['action'] == 'community') {
            $result = $txt['who_index'];
        } elseif (isset($actions['spage']) || isset($actions['art']) || isset($actions['cat']) || isset($actions['child'])) {
            $result = getWhoTitle($actions);
        } elseif (empty($actions['action']) && empty($actions['topic']) && empty($actions['board'])) {
            $frontpage = true;
            if (!empty($context['pmx']['settings']['other_actions'])) {
                $reqtyp = Pmx_StrToArray($context['pmx']['settings']['other_actions']);
                foreach ($reqtyp as $rtyp) {
                    @(list($rtyp, $rval) = Pmx_StrToArray($rtyp, '='));
                    $frontpage = isset($_REQUEST[$rtyp]) && (is_null($rval) || $_REQUEST[$rtyp] == $rval) ? false : $frontpage;
                }
            }
            if (!empty($frontpage)) {
                $result = $txt['pmx_who_frontpage'];
            }
        } elseif (!empty($actions['action']) && allowPmx('pmx_admin')) {
            if ($actions['action'] == 'portamx' && isset($txt['pmx_who_acts'][$actions['area']])) {
                $result = sprintf($txt['pmx_who_portamx'], $txt['pmx_who_acts'][$actions['area']]);
            } elseif (isset($actions['area']) && $actions['action'] == $actions['area'] && isset($txt['pmx_who_acts'][$actions['area']])) {
                $result = sprintf($txt['pmx_who_portamx'], $txt['pmx_who_acts'][$actions['area']]);
            }
        }
        return $result;
    }
}
    /**
     * ShowContent
     * Prepare and output the content.
     */
    function pmxc_ShowContent()
    {
        global $context, $scripturl, $settings, $modSettings, $txt;
        $is_adj = $context['browser']['is_ie'] || $context['browser']['is_opera'];
        $img = '<img src="' . $context['pmx_syscssurl'] . 'Images/bullet_blue.gif" alt="*" title="" />';
        $format = "{$img}<span>%1\$s:&nbsp;%2\$s</span>";
        $Rule = '';
        if (!empty($this->cfg['config']['settings']['stat_member'])) {
            echo '
									<div' . (!empty($this->cfg['config']['visuals']['stats_text']) ? ' class="' . $this->cfg['config']['visuals']['stats_text'] . '"' : '') . '>
										<img src="' . $settings['theme_url'] . '/images/icons/members.png" alt="*" title="' . $txt['pmx_memberlist_icon'] . '" />
										<a href="' . $scripturl . '?action=mlist"><strong>' . $txt['pmx_stat_member'] . '</strong></a>
									</div>
									<ul class="statistics">
										<li>' . sprintf($format, $txt['pmx_stat_totalmember'], isset($modSettings['memberCount']) ? $modSettings['memberCount'] : $modSettings['totalMembers']) . '</li>
										<li style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">' . sprintf($format, $txt['pmx_stat_lastmember'], '<a href="' . $scripturl . '?action=profile;u=' . $modSettings['latestMember'] . '"><strong>' . $modSettings['latestRealName'] . '</strong></a>') . '</li>
									</ul>';
            $Rule = '
									<hr class="pmx_hr" />';
        }
        if (!empty($this->cfg['config']['settings']['stat_stats'])) {
            echo $Rule . '
									<div' . (!empty($this->cfg['config']['visuals']['stats_text']) ? ' class="' . $this->cfg['config']['visuals']['stats_text'] . '"' : '') . '>
										<img src="' . $context['pmx_imageurl'] . 'stats.png" alt="*" title="' . $txt['pmx_statistics_icon'] . '" />
										<a href="' . $scripturl . '?action=stats"><strong>' . $txt['pmx_stat_stats'] . '</strong></a>
									</div>
									<ul class="statistics">
										<li>' . sprintf($format, $txt['pmx_stat_stats_post'], $modSettings['totalMessages']) . '</li>
										<li>' . sprintf($format, $txt['pmx_stat_stats_topic'], $modSettings['totalTopics']) . '</li>
										<li>' . sprintf($format, $txt['pmx_stat_stats_ol_today'], $modSettings['mostOnlineToday']) . '</li>
										<li>' . sprintf($format, $txt['pmx_stat_stats_ol_ever'], $modSettings['mostOnline']) . '</li>
									</ul>
									(' . timeformat($modSettings['mostDate']) . ')';
            $Rule = '
									<hr class="pmx_hr" />';
        }
        if (!empty($this->cfg['config']['settings']['stat_users']) || !empty($this->cfg['config']['settings']['stat_olheight'])) {
            if (!empty($this->cfg['config']['settings']['stat_users'])) {
                echo $Rule . '
									<div' . (!empty($this->cfg['config']['visuals']['stats_text']) ? ' class="' . $this->cfg['config']['visuals']['stats_text'] . '"' : '') . '>
										<img src="' . $context['pmx_imageurl'] . 'online.gif" alt="*" title="' . $txt['pmx_online_user_icon'] . '" />
										<a href="' . $scripturl . '?action=who"><strong>' . $txt['pmx_stat_users'] . '</strong></a>
									</div>
									<ul class="statistics">
										<li>' . sprintf($format, $txt['pmx_stat_users_reg'], $this->online['num_users_online']) . '</li>';
                if (!empty($this->cfg['config']['settings']['stat_spider']) && (!empty($modSettings['show_spider_online']) && ($modSettings['show_spider_online'] < 3 || allowPmx('pmx_admin')) && !empty($modSettings['spider_name_cache']))) {
                    echo '
										<li>' . sprintf($format, $txt['pmx_stat_users_guest'], $this->online['num_guests'] - $this->online['num_spiders']) . '</li>
										<li>' . sprintf($format, $txt['pmx_stat_users_spider'], $this->online['num_spiders']) . '</li>';
                } else {
                    echo '
										<li>' . sprintf($format, $txt['pmx_stat_users_guest'], $this->online['num_guests']) . '</li>';
                }
                echo '
										<li>' . sprintf($format, $txt['pmx_stat_users_total'], $this->online['num_guests'] + $this->online['num_users_online']) . '</li>
									</ul>';
                $Rule = '
									<hr class="pmx_hr" />';
            }
            if (!empty($this->cfg['config']['settings']['stat_olheight']) && !empty($this->online['users_online'])) {
                $img = '<img src="' . $context['pmx_syscssurl'] . 'Images/bullet_green.gif" alt="*" title="" />';
                echo $Rule . '
									<div id="olLst' . $this->cfg['id'] . '" class="onlinelist">
									<ul class="statistics">';
                $lines = !empty($this->cfg['config']['settings']['stat_olheight']) ? $this->cfg['config']['settings']['stat_olheight'] : '5';
                foreach ($this->online['users_online'] as $user) {
                    echo '
											<li' . ($user['is_last'] == true ? ' id="olElm' . $this->cfg['id'] . '"' : '') . ' style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;">' . $img . '<span>' . ($user['hidden'] ? '<i>' . $user['link'] . '</i>' : $user['link']) . '</span></li>';
                }
                echo '
										</ul>
									</div>
									<script>
										var olheight = (document.getElementById("olElm' . $this->cfg['id'] . '").clientHeight * ' . $lines . ');
										document.getElementById("olLst' . $this->cfg['id'] . '").style.maxHeight = olheight +"px";
									</script>';
            }
        }
    }
/**
* Create all the Informationen for the Admin Center.
* Finally load the templare.
*/
function PortaMx_AdminCenter()
{
    global $smcFunc, $context, $settings, $sourcedir, $scripturl, $txt, $pmxCacheFunc;
    // fix the linktree
    $admMode = isset($_GET['action']) ? $_GET['action'] : '';
    if ($admMode == 'admin') {
        foreach ($context['linktree'] as $key => $data) {
            if (strpos($data['url'], 'pmx_center') !== false) {
                $context['linktree'][$key]['name'] = $txt['pmx_extension'];
                break;
            }
        }
    }
    if (($admMode == 'admin' || $admMode == 'portamx') && allowPmx('pmx_admin')) {
        $context['pmx']['subaction'] = isset($_GET['sa']) ? $_GET['sa'] : 'main';
        if ($context['pmx']['subaction'] == 'settings') {
            $context['pmx']['subaction'] = 'main';
        }
        $context['pmx']['pmx_area'] = $_GET['area'];
        $context['pmx']['admmode'] = $admMode;
        // Admin center main?
        if ($context['pmx']['subaction'] == 'main') {
            // show the Admin center
            $liveinfo = getLiveInfo();
            $context['pmx_info'] = $liveinfo;
            $context['pmx_info']['installed'] = getInstalledPackage();
            $context['pmx_info']['versionOK'] = !empty($liveinfo['version']) && $liveinfo['version'] <= $context['pmx_info']['installed'];
            // If update available, get server from package_server table
            if (!empty($context['pmx_info']['update']) && empty($context['pmx_info']['versionOK'])) {
                $request = $smcFunc['db_query']('', '
						SELECT id_server
						FROM {db_prefix}package_servers
						WHERE url = {string:url}', array('url' => substr($context['pmx']['server']['url'], 0, -1)));
                if ($row = $smcFunc['db_fetch_assoc']($request)) {
                    $context['pmx_info']['updserver'] = $row['id_server'];
                    $smcFunc['db_free_result']($request);
                } else {
                    $smcFunc['db_insert']('', '
						{db_prefix}package_servers', array('name' => 'string', 'url' => 'string'), array('PortaMx File Server', substr($context['pmx']['server']['url'], 0, -1)), array('id_server'));
                    $context['pmx_info']['updserver'] = $smcFunc['db_insert_id']('{db_prefix}package_servers', 'id_server');
                }
            }
        } elseif ($context['pmx']['subaction'] == 'flist') {
            checkSession('get');
            $srcdir = $sourcedir;
            $thmdir = $settings['default_theme_dir'];
            $dirs = array('pmx_source_files' => array($srcdir => array('/PortaMx/', '/PortaMx/Class/', '/PortaMx/Class/System/')), 'pmx_template_files' => array($thmdir => array('/PortaMx/', '/PortaMx/SysCss/', '/PortaMx/BlockCss/', '/PortaMx/Scripts/')), 'pmx_language_files' => array($thmdir . '/languages' => array('/PortaMx/')));
            $allfiles = array();
            $fileExt = array();
            $installed = getInstalledLanguages();
            foreach ($installed as $data) {
                $fileExt[] = $data['langext'] . '.php';
            }
            // read all dirs
            foreach ($dirs as $dirname => $basedirs) {
                foreach ($basedirs as $base => $subdirs) {
                    foreach ($subdirs as $dir) {
                        if (is_dir($base . $dir)) {
                            $files = array();
                            if ($dh = opendir($base . $dir)) {
                                while (($file = readdir($dh)) !== false) {
                                    if (is_file($base . $dir . $file)) {
                                        $files[] = $file;
                                    }
                                }
                                closedir($dh);
                            }
                        }
                        if (!empty($files)) {
                            $allfiles[$dirname][$dir] = array('dir' => $base . $dir, 'subdir' => $dir, 'files' => $files);
                        }
                    }
                }
            }
            // cleanup..
            unset($dirs[$dirname]);
            // get lifeinfo
            $currentversion = getLiveInfo('version');
            // Package ...
            $result['pmx_filepackage']['files'][''] = array();
            $result['pmx_filepackage']['current'] = $currentversion;
            $result['pmx_filepackage']['installed'] = getInstalledPackage();
            // check all files
            foreach ($allfiles as $dirtext => $dirname) {
                $lowdate = '01.01.1900';
                $lowversion = '';
                foreach ($dirname as $data) {
                    $subdir = $data['subdir'];
                    foreach ($data['files'] as $file) {
                        if ($file != 'index.php' && substr($file, -1, 1) != '~') {
                            $handle = fopen($data['dir'] . $file, "r");
                            $content = fread($handle, 512);
                            fclose($handle);
                            $versOK = preg_match("~\\*\\s.version\\s([A-Za-z0-9\\.\\-\\s]+)~i", $content, $version) != 0;
                            if ($versOK && strcasecmp(trim($version[1]), $lowversion) >= 0) {
                                $lowversion = $version[1];
                            }
                            $dateOK = preg_match("~\\*\\s.date\\s([A-Za-z0-9\\.\\-]+)~i", $content, $date) != 0;
                            if ($dateOK && $date[1] > $lowdate) {
                                $lowdate = $date[1];
                            }
                            $result[$dirtext]['files'][$file] = array('subdir' => $subdir, 'version' => $versOK ? $version[1] : '?.???', 'date' => $dateOK ? $date[1] : '??.??.????');
                            unset($content);
                        }
                    }
                }
                $result[$dirtext]['current'] = $currentversion;
                $result[$dirtext]['installed'] = $lowversion;
                $result[$dirtext]['lowdate'] = $lowdate;
            }
            $context['pmx_info'] = $result;
            $context['pmx_installed_ext'] = $fileExt;
            unset($result);
        } elseif ($context['pmx']['subaction'] == 'showlang') {
            checkSession('get');
            // fix the linktree
            if ($context['pmx']['admmode'] == 'admin') {
                foreach ($context['linktree'] as $key => $data) {
                    if (strpos($data['url'], 'pmx_languages') !== 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;
                    }
                }
            }
            // get all installed languages
            $context['pmx']['instlang'] = getInstalledLanguages();
            // get all existing languages
            $info = readDocServer($context['pmx']['server']['lang']);
            if (!empty($info)) {
                if (GetFirstChildContentByName($info, 'copyright') == 'PortaMx') {
                    $elmlist = GetChildByPathAndName($info, '', 'item');
                    foreach ($elmlist as $elm) {
                        $context['pmx']['langsets'][] = array('name' => GetFirstChildContentByName($elm, 'name'), 'version' => GetFirstChildContentByName($elm, 'version'), 'charset' => GetFirstChildContentByName($elm, 'charset'), 'link' => GetFirstChildContentByName($elm, 'link'));
                    }
                }
            }
            // check for manually installable languages
            getManuallyLanguages($context['pmx']['instlang']);
        } elseif ($context['pmx']['subaction'] == 'admlang') {
            checkSession('post');
            // lang delete ?
            if (isset($_POST['lang_delete']) && !empty($_POST['lang_delete'])) {
                // get the values...
                $langId = PortaMx_makeSafe($_POST['lang_delete']);
                $failed = AdmCenterLangDelete($langId);
                if (empty($failed)) {
                    redirectexit('action=' . $admMode . ';area=' . $context['pmx']['pmx_area'] . ';sa=showlang;' . $context['session_var'] . '=' . $context['session_id']);
                } else {
                    AdmCenterError($txt['pmx_center_langdelfailed'], $txt['pmx_center_langdelerror'], 'showlang');
                }
            } elseif (isset($_POST['lang_install']) && !empty($_POST['lang_install'])) {
                // Get the install values ...
                $InstLink = PortaMx_makeSafe($_POST['lang_install']);
                $failed = true;
                $info = readDocServer($context['pmx']['server']['lang'] . $InstLink);
                if (GetFirstChildContentByName($info, 'copyright') == 'PortaMx') {
                    // get the language description
                    $langSet = array();
                    $langSet['name'] = GetFirstChildContentByName($info, 'name');
                    $langSet['version'] = GetFirstChildContentByName($info, 'version');
                    $langSet['charset'] = GetFirstChildContentByName($info, 'charset');
                    $langSet['langext'] = GetFirstChildContentByName($info, 'langext');
                    // get installed languages
                    $langlist = getInstalledLanguages();
                    $instId = '';
                    foreach ($langlist as $id => $data) {
                        $instId = compareLang($langSet, $data) ? $id : $instId;
                    }
                    // if Update, delete old lang first
                    $failed = false;
                    if (!empty($instId)) {
                        $failed = AdmCenterLangDelete($instId);
                    } else {
                        $instId = 'lang' . $langSet['langext'];
                    }
                    if (empty($failed)) {
                        // get filelist
                        $langfiles = array();
                        $elmlist = GetChildByPathAndName($info, '', 'item');
                        foreach ($elmlist as $elm) {
                            $fname = GetFirstChildContentByName($elm, 'name');
                            $langfiles[$fname] = GetFirstChildContentByName($elm, 'path');
                        }
                        // now get languagefiles from Portamx server
                        foreach ($langfiles as $file => $path) {
                            $content = readDocServer($context['pmx']['server']['lang'] . $InstLink . 'PortaMx/' . $file . $langSet['langext'], '<?php');
                            $content = trim($content);
                            if (!empty($content)) {
                                $fsize = strlen($content);
                                $filename = $settings['default_theme_dir'] . $path . $file . $langSet['langext'] . '.php';
                                if (file_exists($filename)) {
                                    if (!is_writable($filename)) {
                                        @chmod($filename, 0644);
                                        if (!is_writable($filename)) {
                                            @chmod($filename, 0777);
                                        }
                                    }
                                }
                                if (empty($failed)) {
                                    $written = 0;
                                    $fhd = fopen($filename, 'w');
                                    if ($fhd) {
                                        $written = fwrite($fhd, $content);
                                        fclose($fhd);
                                    }
                                }
                                if (!empty($failed) || $written != $fsize) {
                                    $failed = true;
                                    break;
                                }
                            } else {
                                $failed = true;
                                break;
                            }
                        }
                        if (empty($failed)) {
                            sleep(1);
                            // add or replace the installed language
                            $lset = array('name' => $langSet['name'], 'version' => $langSet['version'], 'charset' => $langSet['charset'], 'langext' => $langSet['langext']);
                            // save installed languages
                            $smcFunc['db_insert']('replace', '
								{db_prefix}portamx_settings', array('varname' => 'string', 'config' => 'string'), array($instId, serialize($lset)), array('varname'));
                            // clear the filecache and redirect exit
                            // clear cache
                            $pmxCacheFunc['clean']();
                            redirectexit('action=' . $admMode . ';area=' . $context['pmx']['pmx_area'] . ';sa=showlang;' . $context['session_var'] . '=' . $context['session_id']);
                        }
                    }
                }
                if (!empty($failed)) {
                    if (isset($context['pmx']['feed_error_text']) && !empty($context['pmx']['feed_error_text'])) {
                        AdmCenterError($txt['pmx_center_langfetchfailed'] . '<br />' . $context['pmx']['feed_error_text'], $txt['pmx_center_langinsterror'], 'showlang');
                    } else {
                        AdmCenterError($txt['pmx_center_langfetchfailed'], $txt['pmx_center_langinsterror'], 'showlang');
                    }
                }
            } elseif (isset($_POST['lang_install_manually']) && !empty($_POST['lang_install_manually'])) {
                // Get the install values ...
                $manlang = PortaMx_makeSafe($_POST['lang_install_manually']);
                $langlist = getInstalledLanguages();
                getManuallyLanguages($langlist);
                $langSet = $context['pmx']['manualylangsets'][$manlang];
                $instId = '';
                foreach ($langlist as $id => $data) {
                    $instId = compareLang($data, $langSet) ? $id : $instId;
                }
                // new id if lang not exist
                if (empty($instId)) {
                    $instId = $manlang;
                }
                // add or replace the installed language
                $lset = array('name' => $langSet['name'], 'version' => $langSet['version'], 'charset' => $langSet['charset'], 'langext' => $langSet['langext'], 'manually' => true);
                // save installed language
                $smcFunc['db_insert']('replace', '
						{db_prefix}portamx_settings', array('varname' => 'string', 'config' => 'string'), array($instId, serialize($lset)), array('varname'));
                // clear the filecache and redirect exit
                $pmxCacheFunc['clean']();
                redirectexit('action=' . $admMode . ';area=' . $context['pmx']['pmx_area'] . ';sa=showlang;' . $context['session_var'] . '=' . $context['session_id']);
            } else {
                AdmCenterError($txt['pmx_actionfault']);
            }
        }
        // setup pagetitle
        $context['page_title'] = $txt['pmx_admin_center'];
        // load the template
        loadTemplate($context['pmx_templatedir'] . 'AdminCenter');
    } else {
        fatal_error($txt['pmx_acces_error']);
    }
}
    /**
     * ShowContent
     */
    function pmxc_ShowContent()
    {
        global $context, $scripturl, $user_info, $txt;
        $context['pmx']['shout_edit'] = -1;
        // smiley && bb codes popup
        $innerPad = Pmx_getInnerPad($this->cfg['config']['innerpad']);
        $bodyclass = $this->cfg['config']['visuals']['body'] == 'windowbg' ? 'windowbg2 ' : 'windowbg ';
        echo '
			<div id="bbcodes' . $this->cfg['id'] . '" style="position:absolute;z-index:9999;width:340px;height:110px;display:none">
				<div>
					<div class="' . $bodyclass . ' roundframe shoutbox_round ' . str_replace('pmxborder', '', $this->cfg['config']['visuals']['frame']) . '" style="margin:auto;text-align:center;border-radius:6px;border-width:1px;box-shadow:none;">';
        echo '
						<div style="height:25px;">';
        $half = 10;
        foreach ($this->smileys as $sm) {
            echo '
						<img onclick="InsertSmiley(' . $this->cfg['id'] . ', \'' . addslashes($sm['code']) . '\')" src="' . $sm['image'] . '" alt="*" title="' . $sm['title'] . '" style="float:left;cursor:pointer;padding:2px 7px;" />';
            $half--;
            if ($half == 0) {
                echo '
						</div>
						<div style="height:25px;">';
            }
        }
        echo '
						</div>
						<hr class="pmx_hr" />
						<div style="height:28px;">';
        foreach ($this->bb_code as $sm) {
            echo '
							<img onclick="InsertBBCode(' . $this->cfg['id'] . ', \'' . $sm['code'] . '\'); return false;" src="' . $sm['image'] . '" alt="*" title="' . $sm['title'] . '" class="shoutbox_bbcimg" />';
        }
        echo '
							<select id="shout_color' . $this->cfg['id'] . '" size="1" onchange="InsertBBColor(' . $this->cfg['id'] . ', this); return false;" style="float:right; margin:3px 4px 0 0px; width:100px;">';
        foreach ($this->bb_colors as $coltxt => $colname) {
            echo '
								<option value="' . $colname . '"' . ($colname == $coltxt ? ' selected="selected"' : '') . '>' . $coltxt . '</option>';
        }
        echo '
							</select>
						</div>
					</div>
				</div>
			</div>';
        echo '
			<div class="' . $this->cfg['side'] . '" id="shoutframe' . $this->cfg['id'] . '" style="' . (isset($this->cfg['config']['settings']['maxheight']) ? 'max-height:' . $this->cfg['config']['settings']['maxheight'] . 'px; overflow:auto; ' : '') . 'padding:0px;">';
        $haveshouts = false;
        $allowAdmin = allowPmx('pmx_admin');
        $cnt = 0;
        foreach ($this->shouts as $id => $data) {
            echo '
				<div id="shoutitem' . $this->cfg['id'] . '-' . $id . '">
					<div class="tborder shoutbox_user">';
            // show the edit/delete images
            if ($allowAdmin || $user_info['id'] == $data['uid'] && !empty($this->cfg['config']['settings']['allowedit']) && $this->canShout) {
                $haveshouts = $allowAdmin || $user_info['id'] == $data['uid'] ? true : $haveshouts;
                echo '
						<img id="' . $cnt . 'shoutimg' . $this->cfg['id'] . '" onclick="DeleteShout(' . $this->cfg['id'] . ', ' . $id . ', ' . intval(!empty($this->cfg['config']['settings']['boxcollapse'])) . ', ' . intval(!empty($this->cfg['config']['settings']['boxcollapse'])) . ');" style="cursor:pointer; margin-top:2px; display:none;float:right;margin-right:2px;" src="' . $context['pmx_imageurl'] . 'shout_del.gif" alt="*" title="' . $txt['pmx_shoutbox_shoutdelete'] . '" />';
                $cnt++;
                echo '
						<img id="' . $cnt . 'shoutimg' . $this->cfg['id'] . '" onclick="EditShout(' . $this->cfg['id'] . ', ' . $id . ', \'' . addslashes($data['post']) . '\');" style="cursor:pointer;margin-top:2px;padding-right:4px;display:none;float:right;" src="' . $context['pmx_imageurl'] . 'shout_edit.gif" alt="*" title="' . $txt['pmx_shoutbox_shoutedit'] . '" />';
                $cnt++;
            }
            // show the ip image
            if ($allowAdmin && !empty($data['ip'])) {
                echo '
						<a id="' . $cnt . 'shoutimg' . $this->cfg['id'] . '" href="' . $scripturl . '?action=trackip;searchip=' . $data['ip'] . '" style="display:none;">
							<img src="' . $context['pmx_imageurl'] . 'ip.gif" style="padding:4px 3px 0 0;float:right;margin-top:-3px;" title="' . $data['ip'] . '" alt="*" />
						</a>';
                $cnt++;
            }
            // convert smileys and bb codes
            $data['post'] = $this->BBCtoHTML($data['post'], true);
            // Guest shout?
            if ($data['uid'] != 0 && isset($this->memdata[$data['uid']])) {
                echo '
						<a style="display:block; margin-top:-2px;" href="' . $scripturl . '?action=profile;u=' . $data['uid'] . '"><span' . (isset($this->memdata[$data['uid']]['color']) && !empty($this->memdata[$data['uid']]['color']) ? ' style="color:' . $this->memdata[$data['uid']]['color'] . ';"' : '') . '>' . $this->memdata[$data['uid']]['name'] . '</span></a>';
            } else {
                $data['uid'] = 0;
                echo '
						' . $this->memdata[$data['uid']]['name'];
            }
            echo '<div class="smalltext shoutbox_date">' . timeformat($data['time']) . '</div>
					</div>
					<div class="shoutbox_post">
						' . $data['post'] . '
					</div>
				</div>';
        }
        echo '
				<input type="hidden" id="shoutcount' . $this->cfg['id'] . '" value="' . $cnt . '" />
			</div>';
        // have shout access?
        if ($this->canShout) {
            $canEdit = !$user_info['is_guest'] && ($allowAdmin && $haveshouts || $haveshouts && !empty($this->cfg['config']['settings']['allowedit']));
            $Admimg[0] = $context['pmx_imageurl'] . ($canEdit ? 'shout_admon.gif' : 'empty.gif');
            $Admimg[1] = $context['pmx_imageurl'] . ($canEdit ? 'shout_admoff.gif' : 'empty.gif');
            if (pmx_checkECL_Cookie(true)) {
                echo '
			<div style="overflow:hidden;margin-bottom:2px;margin-top:4px;">
				<input type="hidden" name="shoutbox_action" value="shout" />
				<input type="hidden" name="shoutbox_id" value="' . $this->cfg['id'] . '" />
				<input type="hidden" name="sc" value="' . $context['session_id'] . '" />
				<input type="hidden" id="shout' . $this->cfg['id'] . '" name="pmx_shout" value="" />
				<input type="hidden" id="shoutid' . $this->cfg['id'] . '" name="shoutid" value="" />
				<div id="shoutcontdiv' . $this->cfg['id'] . '" style="display:none;">
					<textarea id="shoutcontent' . $this->cfg['id'] . '"  style="height:80px;min-height:80px;max-height:250px;width:100%;resize:vertical;" name="post"></textarea>
				</div>
				<div style="border-top:1px solid #ddd;margin-top:2px;padding-top:2px;">
					<img id="shoutbbon' . $this->cfg['id'] . '" style="cursor:pointer;margin-top:6px;float:left;' . (!empty($this->cfg['config']['settings']['boxcollapse']) ? 'display:none;' : '') . '" onclick="ShoutPopup(' . $this->cfg['id'] . ');" src="' . $context['pmx_imageurl'] . 'type_bbc.gif" alt="*" title="' . $txt['pmx_shoutbox_bbc_code'] . '" />';
                if (!empty($this->cfg['config']['settings']['boxcollapse'])) {
                    echo '
					<img id="shoutbboff' . $this->cfg['id'] . '" style="margin-top:6px;float:left;" src="' . $context['pmx_imageurl'] . 'empty.gif" alt="*" title="" />';
                }
                echo '
					<img id="shout_toggle' . $this->cfg['id'] . '" style="' . ($canEdit ? 'cursor:pointer;' : '') . 'margin-top:6px;float:right;"' . ($canEdit ? ' onclick="ShoutAdmin(' . $this->cfg['id'] . ',\'check\');"' : '') . ' src="' . $Admimg[0] . '" alt="*" title="' . $txt['pmx_shoutbox_toggle'] . '" />
					<input id="shout_key' . $this->cfg['id'] . '" onclick="SendShout(' . $this->cfg['id'] . ', ' . intval(!empty($this->cfg['config']['settings']['boxcollapse'])) . ')" class="button_submit shoutbutton" type="button" name="button" value="' . (!empty($this->cfg['config']['settings']['boxcollapse']) ? $txt['pmx_shoutbox_button_open'] : $txt['pmx_shoutbox_button']) . '" title="' . (!empty($this->cfg['config']['settings']['boxcollapse']) ? $txt['pmx_shoutbox_button_title'] : $txt['pmx_shoutbox_send_title']) . '" />
				</div>
			</div>';
            }
        }
    }
/**
* 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 Articles Manager, check and save it.
* Finally the articles are prepared and the template loaded.
*/
function PortaMx_AdminBlocks()
{
    global $smcFunc, $context, $sourcedir, $scripturl, $user_info, $pmxCacheFunc, $modSettings, $txt;
    $_GET = PortaMx_makeSafe($_GET);
    $admMode = $_GET['action'];
    $pmx_area = $_GET['area'];
    $newBlockSide = '';
    // fix the linktree
    if ($admMode == 'admin') {
        foreach ($context['linktree'] as $key => $data) {
            if (strpos($data['url'], 'pmx_blocks') !== 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;
            }
        }
    }
    if (($admMode == 'admin' || $admMode == 'portamx') && $pmx_area == 'pmx_blocks') {
        if (allowPmx('pmx_admin, pmx_blocks')) {
            require_once $context['pmx_sourcedir'] . 'AdminSubs.php';
            $context['pmx']['subaction'] = isset($_POST['sa']) ? $_POST['sa'] : 'all';
            // From template ?
            if (PortaMx_checkPOST()) {
                // check the Post array
                checkSession('post');
                $context['pmx']['function'] = $_POST['function'];
                // actions from overview ?
                if ($context['pmx']['function'] == 'overview') {
                    // update action from overview?
                    if (!empty($_POST['upd_overview'])) {
                        $updates = array();
                        $chgSides = array();
                        foreach ($_POST['upd_overview'] as $side => $sidevalues) {
                            $chgSides[] = $side;
                            foreach ($sidevalues as $updkey => $updvalues) {
                                foreach ($updvalues as $id => $values) {
                                    if ($updkey == 'title') {
                                        foreach ($values as $key => $val) {
                                            if ($key == 'lang') {
                                                foreach ($val as $langname => $langvalue) {
                                                    $updates[$id]['config'][$updkey][$langname] = $langvalue;
                                                }
                                            } else {
                                                $updates[$id]['config'][$updkey . '_' . $key] = $val;
                                            }
                                        }
                                    } else {
                                        $updates[$id][$updkey] = $values;
                                    }
                                }
                            }
                        }
                        // save all updates (title, access)
                        foreach ($updates as $id => $values) {
                            $request = $smcFunc['db_query']('', '
								SELECT config, acsgrp, blocktype
								FROM {db_prefix}portamx_blocks
								WHERE id = {int:id}', array('id' => $id));
                            $row = $smcFunc['db_fetch_assoc']($request);
                            $smcFunc['db_free_result']($request);
                            $blocktype = $row['blocktype'];
                            foreach ($values as $rowname => $data) {
                                // update config array
                                if ($rowname == 'config') {
                                    $cfg = unserialize($row['config']);
                                    foreach ($data as $ckey => $cval) {
                                        if ($ckey == 'title') {
                                            foreach ($cval as $lang => $val) {
                                                $cfg[$ckey][$lang] = $val;
                                            }
                                        } else {
                                            $cfg[$ckey] = $cval;
                                        }
                                    }
                                    $smcFunc['db_query']('', '
										UPDATE {db_prefix}portamx_blocks
										SET config = {string:config}
										WHERE id = {int:id}', array('id' => $id, 'config' => serialize($cfg)));
                                } else {
                                    if (!empty($_POST['xml']) && !isset($xmlResult)) {
                                        $xmlResult = '';
                                    }
                                    // update (replace)
                                    $mode = substr($rowname, 0, 3);
                                    if ($mode == 'upd') {
                                        $newacs = explode(',', $data);
                                    } elseif ($mode == 'add') {
                                        $newacs = array_unique(array_merge(explode(',', $row['acsgrp']), explode(',', $data)));
                                    } else {
                                        $newacs = array_unique(array_diff(explode(',', $row['acsgrp']), explode(',', $data)));
                                    }
                                    $smcFunc['db_query']('', '
										UPDATE {db_prefix}portamx_blocks
										SET acsgrp = {string:val}
										WHERE id = {int:id}', array('id' => $id, 'val' => implode(',', $newacs)));
                                    // send by xml?
                                    if (isset($xmlResult)) {
                                        $request = $smcFunc['db_query']('', '
											SELECT active
											FROM {db_prefix}portamx_blocks
											WHERE id = {int:id}', array('id' => $id));
                                        list($active) = $smcFunc['db_fetch_row']($request);
                                        $smcFunc['db_free_result']($request);
                                        $count = count($newacs);
                                        $newacs = implode(',', $newacs);
                                        $xmlResult .= (!empty($xmlResult) ? '&' : '') . $id . '|' . $newacs . '|' . $count . '|' . intval(allowPmxGroup($newacs)) . '|' . $active;
                                    }
                                }
                            }
                            // clear cache
                            $pmxCacheFunc['clean']();
                        }
                        if (!empty($_POST['xml']) && isset($xmlResult)) {
                            // return update acces result
                            ob_start();
                            echo $xmlResult;
                            ob_end_flush();
                            exit;
                        }
                    } elseif (!empty($_POST['chg_status'])) {
                        $id = PortaMx_makeSafe($_POST['chg_status']);
                        $request = $smcFunc['db_query']('', '
							SELECT side, blocktype
							FROM {db_prefix}portamx_blocks
							WHERE id = {int:id}', array('id' => $id));
                        list($side, $blocktype) = $smcFunc['db_fetch_row']($request);
                        $smcFunc['db_free_result']($request);
                        $smcFunc['db_query']('', '
							UPDATE {db_prefix}portamx_blocks
							SET active = CASE WHEN active = 0 THEN 1 ELSE 0 END
							WHERE id = {int:id}', array('id' => $id));
                        // Post send by xml http ?
                        if (!empty($_POST['xml'])) {
                            // check if we have active blocks in this panel
                            $request = $smcFunc['db_query']('', '
								SELECT acsgrp, active
								FROM {db_prefix}portamx_blocks
								WHERE id = {int:id}', array('id' => $id));
                            list($acs, $status) = $smcFunc['db_fetch_row']($request);
                            $smcFunc['db_free_result']($request);
                            // clear cache
                            $pmxCacheFunc['clean']();
                            // return result
                            ob_start();
                            echo $status . ',' . intval(allowPmxGroup($acs));
                            ob_end_flush();
                            exit;
                        }
                    }
                    // add new block
                    if (!empty($_POST['add_new_block'])) {
                        $id = null;
                        $context['pmx']['function'] = 'editnew';
                        list($newBlockSide) = array_keys($_POST['add_new_block']);
                        list($block) = array_values($_POST['add_new_block']);
                    } elseif (!empty($_POST['upd_rowpos'])) {
                        list($side) = each($_POST['upd_rowpos']);
                        list($fromID, $place, $toID) = Pmx_StrToArray($_POST['upd_rowpos'][$side]['rowpos']);
                        $request = $smcFunc['db_query']('', '
							SELECT id, pos
							FROM {db_prefix}portamx_blocks
							WHERE id IN({array_int:ids})', array('ids' => array($fromID, $toID)));
                        while ($row = $smcFunc['db_fetch_assoc']($request)) {
                            $moveData[$row['id']] = $row['pos'];
                        }
                        $smcFunc['db_free_result']($request);
                        // create the query...
                        if ($moveData[$fromID] > $moveData[$toID]) {
                            $query = 'SET pos = pos + 1 WHERE side = \'' . $side . '\' AND pos >= ' . $moveData[$toID] . ' AND pos <= ' . $moveData[$fromID];
                        } else {
                            $query = 'SET pos = pos - 1 WHERE side = \'' . $side . '\' AND pos >= ' . $moveData[$fromID] . ' AND pos <= ' . $moveData[$toID];
                        }
                        // .. and execute
                        $smcFunc['db_query']('', 'UPDATE {db_prefix}portamx_blocks ' . $query, array());
                        // update the fromID pos
                        $smcFunc['db_query']('', '
							UPDATE {db_prefix}portamx_blocks
							SET pos = {int:pos}
							WHERE id = {int:id}', array('id' => $fromID, 'pos' => $moveData[$toID]));
                    } elseif (!empty($_POST['edit_block'])) {
                        $id = $_POST['edit_block'];
                        $context['pmx']['function'] = 'edit';
                        $block = null;
                    } elseif (!empty($_POST['clone_block']) || !empty($_POST['move_block'])) {
                        if (!empty($_POST['clone_block'])) {
                            list($id, $side) = Pmx_StrToArray($_POST['clone_block']);
                        } else {
                            list($id, $side) = Pmx_StrToArray($_POST['move_block']);
                        }
                        // load the block for move/clone
                        $request = $smcFunc['db_query']('', '
							SELECT *
							FROM {db_prefix}portamx_blocks
							WHERE id = {int:id}', array('id' => $id));
                        $row = $smcFunc['db_fetch_assoc']($request);
                        $smcFunc['db_free_result']($request);
                        // redirect on move/clone to articles..
                        if ($side == 'articles') {
                            redirectexit('action=' . $admMode . ';area=pmx_articles;sa=edit;id=' . $id . ';from=' . (!empty($_POST['clone_block']) ? 'clone.' : 'move.') . $_GET['sa'] . ';' . $context['session_var'] . '=' . $context['session_id']);
                        }
                        // block move
                        if (!empty($_POST['move_block'])) {
                            // update all pos >= moved id
                            $smcFunc['db_query']('', '
								UPDATE {db_prefix}portamx_blocks
								SET pos = pos - 1
								WHERE side = {string:side} AND pos >= {int:pos}', array('side' => $row['side'], 'pos' => $row['pos']));
                            // get max pos for destination panel
                            $request = $smcFunc['db_query']('', '
								SELECT MAX(pos)
								FROM {db_prefix}portamx_blocks
								WHERE side = {string:side}', array('side' => $side));
                            list($dbpos) = $smcFunc['db_fetch_row']($request);
                            $smcFunc['db_free_result']($request);
                            $block['pos'] = strval(1 + ($dbpos === null ? 0 : $dbpos));
                            $block['side'] = $side;
                            // now update the block
                            $smcFunc['db_query']('', '
								UPDATE {db_prefix}portamx_blocks
								SET pos = {int:pos}, side = {string:side}
								WHERE id = {int:id}', array('id' => $id, 'pos' => $block['pos'], 'side' => $block['side']));
                            // clear cache
                            $pmxCacheFunc['clean']();
                            $context['pmx']['function'] = 'overview';
                            if ($context['pmx']['subaction'] != 'all') {
                                $context['pmx']['subaction'] = $block['side'];
                            }
                        } else {
                            $block = array('id' => $row['id'], 'side' => $row['side'], 'pos' => $row['pos'], 'active' => $row['active'], 'cache' => $row['cache'], 'blocktype' => $row['blocktype'], 'acsgrp' => $row['acsgrp'], 'config' => $row['config'], 'content' => $row['content']);
                            $block['side'] = $side;
                            $block['active'] = 0;
                            $context['pmx']['function'] = 'editnew';
                            if ($context['pmx']['subaction'] != 'all') {
                                $context['pmx']['subaction'] = $block['side'];
                            }
                        }
                    } elseif (!empty($_POST['block_delete'])) {
                        $request = $smcFunc['db_query']('', '
							SELECT side, pos, blocktype
							FROM {db_prefix}portamx_blocks
							WHERE id = {int:id}', array('id' => $_POST['block_delete']));
                        list($side, $pos, $blocktype) = $smcFunc['db_fetch_row']($request);
                        $smcFunc['db_free_result']($request);
                        // update all pos >= deleted id
                        $smcFunc['db_query']('', '
							UPDATE {db_prefix}portamx_blocks
							SET pos = pos - 1
							WHERE side = {string:side} AND pos >= {int:pos}', array('side' => $side, 'pos' => $pos));
                        // delete the block
                        $smcFunc['db_query']('', '
							DELETE FROM {db_prefix}portamx_blocks
							WHERE id = {int:id}', array('id' => $_POST['block_delete']));
                        // clear cache
                        $pmxCacheFunc['clean']();
                    }
                    // Post send by xml http ?
                    if (!empty($_POST['xml'])) {
                        // return result
                        ob_start();
                        echo $_POST['result'];
                        ob_end_flush();
                        exit;
                    }
                    // redirect ?
                    if ($context['pmx']['function'] == 'overview') {
                        redirectexit('action=' . $admMode . ';area=' . $pmx_area . ';sa=' . $context['pmx']['subaction'] . ';' . $context['session_var'] . '=' . $context['session_id']);
                    }
                }
                // edit block canceled ?
                if (!empty($_POST['cancel_edit'])) {
                    $context['pmx']['function'] = 'overview';
                } elseif (empty($_POST['edit_block']) && empty($_POST['add_new_block']) && ($context['pmx']['function'] == 'editnew' || $context['pmx']['function'] == 'edit')) {
                    // 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']};");
                            }
                        }
                    }
                    // add a change date to config array
                    $_POST['config']['created'] = time();
                    // blocktype change?
                    if (!empty($_POST['chg_blocktype'])) {
                        if (isset($_POST['content']) && PortaMx_makeSafeContent($_POST['content']) != '') {
                            // convert html/script to bbc
                            if ($_POST['blocktype'] == 'bbc_script' && in_array($_POST['contenttype'], array('html', 'script'))) {
                                $_POST['content'] = PortaMx_SmileyToBBC($_POST['content']);
                                if (preg_match_all('/<img.*(style[^\\"]*\\"([^\\"]*\\"))[^>]*>/U', $_POST['content'], $match) > 0) {
                                    foreach ($match[0] as $key => $val) {
                                        $repl = ' ' . str_replace(array('"', ': ', ':', 'px;'), array('', '="', '="', '" '), $match[2][$key]);
                                        $_POST['content'] = str_replace($val, str_replace($match[1][$key], $repl, $val), $_POST['content']);
                                    }
                                }
                                require_once $sourcedir . '/Subs-Editor.php';
                                $modSettings['smiley_enable'] = true;
                                $user_info['smiley_set'] = 'PortaMx';
                                $_POST['content'] = html_to_bbc($_POST['content']);
                            } elseif ($_POST['contenttype'] == 'bbc_script' && in_array($_POST['blocktype'], array('html', 'script'))) {
                                $_POST['content'] = PortaMx_BBCsmileys(parse_bbc(PortaMx_makeSafeContent($_POST['content'], $_POST['contenttype']), false));
                                $_POST['content'] = str_replace(array('<hr>', '<br>'), array('<hr />', '<br />'), $_POST['content']);
                                $_POST['content'] = preg_replace_callback('/<\\/[^>]*>|<[^\\/]*\\/>|<ul[^>]*>|<ol[^>]*>/', create_function('$matches', 'return $matches[0] ."\\n";'), $_POST['content']);
                                if (preg_match_all('/<img[^w]*(width=\\"([0-9]+)\\")(\\sheight=\\"([\\s0-9]+)\\")[^>]*>/', $_POST['content'], $match) > 0) {
                                    foreach ($match[0] as $key => $val) {
                                        $_POST['content'] = str_replace($match[1][$key], '', $_POST['content']);
                                        $_POST['content'] = str_replace($match[3][$key], 'style="width: ' . $match[2][$key] . 'px;height: ' . $match[4][$key] . 'px;"', $_POST['content']);
                                    }
                                    $_POST['content'] = preg_replace('/px;"[^c]*class=/', 'px;" class=', $_POST['content']);
                                }
                            } elseif ($_POST['blocktype'] == 'php') {
                                if ($_POST['contenttype'] == 'php') {
                                    pmxPHP_convert();
                                }
                            }
                        }
                        $id = $_POST['id'];
                    }
                    // save data
                    if (empty($_POST['move_block']) && (!empty($_POST['save_edit']) || !empty($_POST['save_edit_continue']) || !empty($_POST['chg_blocktype']))) {
                        if ($_POST['blocktype'] == 'php' && $_POST['contenttype'] == 'php') {
                            pmxPHP_convert();
                        } elseif ($_POST['blocktype'] == 'html') {
                            $_POST['content'] = str_replace('/ckeditor/../Smileys/', '/Smileys/', $_POST['content']);
                            if (preg_match_all('~<img.*(class[^r]*resized[^\\"]*\\")[^>]*>~', $_POST['content'], $match) > 0) {
                                foreach ($match[0] as $key => $val) {
                                    $endChr = substr($val, -2) !== '/>' ? array('>', ' />') : array(' />', '/>');
                                    $repl = str_replace($match[1][$key], '', $val);
                                    $_POST['content'] = str_replace($val, str_replace($endChr[0], ' class="bbc_img resized"' . $endChr[1], $repl), $_POST['content']);
                                }
                            } elseif (preg_match_all('~<img[^>]*>~', $_POST['content'], $match) > 0) {
                                foreach ($match[0] as $key => $val) {
                                    $endChr = substr($val, -2) !== '/>' ? array('>', ' />') : array(' />', '/>');
                                    if (strpos($val, '/Smileys/') === false) {
                                        $_POST['content'] = str_replace($val, str_replace($endChr[0], ' class="bbc_img resized"' . $endChr[1], $val), $_POST['content']);
                                    }
                                }
                            }
                        } elseif ($_POST['blocktype'] != 'shoutbox') {
                            $_POST['content'] = isset($_POST['content']) ? PortaMx_makeSafeContent($_POST['content'], $_POST['blocktype']) : '';
                        }
                        $block = array('id' => $_POST['id'], 'side' => $_POST['side'], 'pos' => $_POST['pos'], 'active' => $_POST['active'], 'cache' => $_POST['cache'], 'blocktype' => $_POST['blocktype'], 'acsgrp' => !empty($_POST['acsgrp']) ? implode(',', $_POST['acsgrp']) : '', 'config' => serialize($_POST['config']), 'content' => $_POST['content']);
                        $id = $_POST['id'];
                    }
                    // save block..
                    if (!empty($_POST['save_edit']) || !empty($_POST['save_edit_continue'])) {
                        // if new block get the last id
                        if ($context['pmx']['function'] == 'editnew') {
                            $request = $smcFunc['db_query']('', '
								SELECT MAX(a.id), MAX(b.pos)
								FROM {db_prefix}portamx_blocks as a
								LEFT JOIN {db_prefix}portamx_blocks as b ON(b.side = {string:side})
								GROUP BY b.side', array('side' => $block['side']));
                            list($dbid, $dbpos) = $smcFunc['db_fetch_row']($request);
                            $smcFunc['db_free_result']($request);
                            $block['id'] = strval(1 + ($dbid === null ? 0 : $dbid));
                            $block['pos'] = strval(1 + ($dbpos === null ? 0 : $dbpos));
                        }
                        // now save all data
                        $smcFunc['db_insert']('replace', '
							{db_prefix}portamx_blocks', array('id' => 'int', 'side' => 'string', 'pos' => 'int', 'active' => 'int', 'cache' => 'int', 'blocktype' => 'string', 'acsgrp' => 'string', 'config' => 'string', 'content' => 'string'), array($block['id'], $block['side'], $block['pos'], $block['active'], $block['cache'], $block['blocktype'], $block['acsgrp'], $block['config'], $block['content']), array('id'));
                        // clear cache
                        $pmxCacheFunc['clean']();
                        $postKey = 'pmxpost_' . $block['blocktype'] . $block['id'];
                        if (isset($_SESSION['PortaMx'][$postKey])) {
                            unset($_SESSION['PortaMx'][$postKey]);
                        }
                        if (isset($_SESSION['PortaMx'][$postKey . '_0'])) {
                            unset($_SESSION['PortaMx'][$postKey . '_0']);
                        }
                        $context['pmx']['function'] = 'edit';
                    }
                    // end edit ?
                    if (!empty($_POST['save_edit'])) {
                        $context['pmx']['function'] = 'overview';
                        if (!empty($block['active'])) {
                            redirectexit('action=' . $admMode . ';area=' . $pmx_area . ';sa=' . $context['pmx']['subaction'] . ';' . $context['session_var'] . '=' . $context['session_id']);
                        }
                    } elseif (!empty($_POST['save_edit_continue'])) {
                        if (!empty($block['active'])) {
                            $_SESSION['pmx_save_edit_continue'] = $block['id'];
                            redirectexit('action=' . $admMode . ';area=' . $pmx_area . ';sa=' . $context['pmx']['subaction'] . ';' . $context['session_var'] . '=' . $context['session_id']);
                        }
                    }
                }
            } else {
                $context['pmx']['subaction'] = isset($_GET['sa']) && $_GET['sa'] != 'settings' ? $_GET['sa'] : 'all';
                $context['pmx']['function'] = 'overview';
                // direct edit request?
                if (isset($_GET['edit']) && intval($_GET['edit']) != 0) {
                    $id = $_GET['edit'];
                    $context['pmx']['function'] = 'edit';
                    $block = null;
                } elseif (isset($_SESSION['pmx_save_edit_continue'])) {
                    $block = null;
                    $id = $_SESSION['pmx_save_edit_continue'];
                    unset($_SESSION['pmx_save_edit_continue']);
                    $context['pmx']['function'] = 'edit';
                }
            }
            // load template and languages, setup pagetitle
            loadTemplate($context['pmx_templatedir'] . 'AdminBlocks');
            loadLanguage($context['pmx_templatedir'] . 'AdminBlocks');
            $context['pmx']['RegBlocks'] = eval($context['pmx']['registerblocks']);
            $context['page_title'] = $txt['pmx_blocks'];
            $context['pmx']['AdminMode'] = $admMode;
            // continue edit or overview ?
            if ($context['pmx']['function'] == 'overview') {
                // load blocks data for overview
                $context['pmx']['blocks'] = array();
                $request = $smcFunc['db_query']('', '
					SELECT id, side, pos, active, cache, blocktype, acsgrp, config
					FROM {db_prefix}portamx_blocks
					WHERE side IN ({array_string:side})
					ORDER BY side, pos', array('side' => Pmx_StrToArray($context['pmx']['subaction'] == 'all' ? implode(',', array_keys($txt['pmx_admBlk_sides'])) : $context['pmx']['subaction'])));
                if ($smcFunc['db_num_rows']($request) > 0) {
                    while ($row = $smcFunc['db_fetch_assoc']($request)) {
                        $context['pmx']['blocks'][$row['side']][$row['pos']] = array('id' => $row['id'], 'side' => $row['side'], 'pos' => $row['pos'], 'active' => $row['active'], 'cache' => $row['cache'], 'blocktype' => $row['blocktype'], 'acsgrp' => $row['acsgrp'], 'config' => unserialize($row['config']));
                    }
                    $smcFunc['db_free_result']($request);
                }
                // load popup js and css for overview
                loadJavascriptFile(PortaMx_loadCompressed('PortaMxPopup.js'), array('external' => true));
            } elseif (empty($_POST['save_edit'])) {
                // load the class file and create the object
                require_once $context['pmx_sysclassdir'] . 'PortaMx_AdminBlocksClass.php';
                $context['pmx']['editblock'] = PortaMx_getAdmEditBlock($id, $block, $newBlockSide);
            }
        } else {
            fatal_lang_error('pmx_acces_error', false);
        }
    }
}
/**
* 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']);
    }
}
/**
* AdmArticleOverview
* Called for each artile.
*/
function PmxArticleOverview($article, &$cfg_titleicons, &$cfg_smfgroups, $categories)
{
    global $context, $user_info, $txt;
    if (empty($article['config']['title_align'])) {
        $article['config']['title_align'] = 'left';
    }
    if (empty($article['config']['title_icon'])) {
        $article['config']['title_icon'] = 'none.png';
    }
    if (!empty($article['acsgrp'])) {
        list($grpacs, $denyacs) = Pmx_StrToArray($article['acsgrp'], ',', '=');
    } else {
        $grpacs = $denyacs = array();
    }
    // ID row
    echo '
							<div class="pmx_tbl_tr">
								<div class="pmx_tbl_tdgrid" id="RowMove-' . $article['id'] . '">';
    if (count($context['pmx']['article_rows']) > 1) {
        echo '
									<div class="pmx_clickrow' . (allowPmx('pmx_articles, pmx_admin') ? ' pmx_moveimg" title="' . $txt['pmx_rowmove_updown'] . '" onclick="pmxArtMove(\'' . $article['id'] . '\', \'<b>' . $article['name'] . '</b> - [' . (empty($article['cat']) ? $txt['pmx_default_none'] : $article['cat']) . ']\')"' : '"') . '>
										<div style="padding-left:20px;margin-top:-2px;width:22px;">' . $article['id'] . '</div>
									</div>';
    }
    echo '
								</div>';
    // title row
    echo '
								<div class="pmx_tbl_tdgrid" id="pWind.ypos.' . $article['id'] . '">
									<div onclick="pmxSetTitle(\'' . $article['id'] . '\')"  title="' . $txt['pmx_click_edit_ttl'] . '" style="cursor:pointer;">
										<img id="uTitle.icon.' . $article['id'] . '" style="padding-right:4px;" src="' . $context['pmx_Iconsurl'] . $article['config']['title_icon'] . '" alt="*" title="' . substr($txt['pmx_edit_titleicon'], 0, -1) . '" />
										<img id="uTitle.align.' . $article['id'] . '" src="' . $context['pmx_imageurl'] . 'text_align_' . $article['config']['title_align'] . '.gif" alt="*" title="' . $txt['pmx_edit_title_align'] . $txt['pmx_edit_title_align_types'][$article['config']['title_align']] . '" />
										<span id="sTitle.text.' . $article['id'] . '.">' . (isset($article['config']['title'][$context['pmx']['currlang']]) ? htmlspecialchars($article['config']['title'][$context['pmx']['currlang']], ENT_QUOTES) : '') . '</span>';
    foreach ($context['pmx']['languages'] as $lang => $sel) {
        echo '
										<input id="sTitle.text.' . $lang . '.' . $article['id'] . '." type="hidden" value="' . (isset($article['config']['title'][$lang]) ? htmlspecialchars($article['config']['title'][$lang], ENT_QUOTES) : '') . '" />';
    }
    echo '
										<input id="sTitle.icon.' . $article['id'] . '" type="hidden" value="' . $article['config']['title_icon'] . '" />
										<input id="sTitle.align.' . $article['id'] . '" type="hidden" value="' . $article['config']['title_align'] . '" />
									</div>
								</div>';
    // type row
    echo '
								<div class="pmx_tbl_tdgrid">
									<div style="cursor:default;" title="' . $context['pmx']['RegBlocks'][$article['ctype']]['blocktype'] . ' ' . $context['pmx']['RegBlocks'][$article['ctype']]['description'] . '"><img style="padding-right:5px;" src="' . $context['pmx_imageurl'] . 'type_' . $article['ctype'] . '.gif" alt="*" title="' . $article['ctype'] . '" /><span style="cursor:default;">' . $context['pmx']['RegBlocks'][$article['ctype']]['description'] . '</span></div>
								</div>';
    $detais = array();
    $cat = !empty($article['catid']) ? $article['catid'] : '0';
    pmx_getAllCatDetais(PortaMx_getCategories(), $detais, $txt['pmx_chg_articlcats']);
    $detais['0'] = array('class' => 'cat_none', 'level' => '0', 'parent' => $txt['pmx_categories_none'], 'name' => $txt['pmx_categories_none']);
    // category row
    echo '
								<div class="pmx_tbl_tdgrid">
									<input id="pWind.catid.' . $article['id'] . '" type="hidden" value="' . $cat . '" />
									<div onclick="pmxSetCats(\'' . $article['id'] . '\')" style="cursor:pointer;">';
    foreach ($detais as $cid => $catsDetais) {
        echo '
										<div id="pWind.cat.' . $cid . '.' . $article['id'] . '" title="' . $catsDetais['parent'] . $txt['pmx_chg_articlcats'] . '" class="' . $catsDetais['class'] . '"  style="display:' . ($cid == $cat ? 'block' : 'none') . ';">
											<b>' . $catsDetais['level'] . '</b>
											<span><span class="cat_names">' . $catsDetais['name'] . '</span></span>
										</div>';
    }
    echo '
									</div>
								</div>';
    // create acs groups for acs Popup
    if (!empty($article['acsgrp'])) {
        list($grpacs, $denyacs) = Pmx_StrToArray($article['acsgrp'], ',', '=');
    } else {
        $grpacs = $denyacs = array();
    }
    // options row
    echo '
								<div class="pmx_tbl_tdgrid">
									<input id="grpAcs.' . $article['id'] . '" type="hidden" value="' . implode(',', $grpacs) . '" />
									<input id="denyAcs.' . $article['id'] . '" type="hidden" value="' . implode(',', $denyacs) . '" />
									<div id="pmxSetArtDelete.' . $article['id'] . '"><span id="pmxSetArtClone.' . $article['id'] . '"></span>
										<div id="pWind.grp.' . $article['id'] . '" class="pmx_clickrow' . (!empty($article['acsgrp']) ? ' pmx_access" title="' . $txt['pmx_article_groupaccess'] : '') . '"></div>
										<div class="pmx_clickrow' . (!empty($article['config']['can_moderate']) ? ' pmx_moderate"  title="' . $txt['pmx_article_modaccess'] : '') . '"></div>
										<div class="pmx_clickrow' . (!empty($article['config']['check_ecl']) ? ' pmx_eclsettings" title="' . $txt['pmx_have_artecl_settings'] : '') . '"></div>
										<div class="pmx_clickrow' . (!empty($article['config']['cssfile']) ? ' pmx_custcss" title="' . $txt['pmx_article_cssfile'] : '') . '"></div>
									</div>
								</div>';
    // status row
    echo '
								<div class="pmx_tbl_tdgrid">
									<div class="pmx_clickrow' . ($article['approved'] ? ' pmx_approved" title="' . $txt['pmx_article_approved'] : ' pmx_notapproved" title="' . $txt['pmx_article_not_approved']) . (allowPmx('pmx_articles, pmx_admin') ? ' - ' . $txt['pmx_status_change'] . '" onclick="pToggleArtStatus(this,' . $article['id'] . ',\'approved\')' : '" style="cursor:default') . '"></div>
									<div class="pmx_clickrow' . ($article['active'] ? ' pmx_active" title="' . $txt['pmx_status_activ'] : ' pmx_notactive" title="' . $txt['pmx_status_inactiv']) . ' - ' . $txt['pmx_status_change'] . '" onclick="pToggleArtStatus(this,' . $article['id'] . ',\'active\')"></div>
								</div>';
    // functions row
    echo '
								<div class="pmx_tbl_tdgrid">
									<div class="pmx_clickrow pmx_pgedit" title="' . $txt['pmx_edit_article'] . '" onclick="FormFunc(\'edit_article\', \'' . $article['id'] . '\')"></div>
									<div class="pmx_clickrow pmx_grpacs" title="' . $txt['pmx_chg_articleaccess'] . '" onclick="pmxSetAcs(\'' . $article['id'] . '\')"></div>
									<div class="pmx_clickrow' . (allowPmx('pmx_admin, pmx_articles') || allowPmx('pmx_create') && $article['owner'] == $user_info['id'] ? ' pmx_pgclone" title="' . $txt['pmx_clone_article'] . '" onclick="pmxSetArtClone(\'' . $article['id'] . '\')"' : '"') . '></div>
									<div class="pmx_clickrow' . (allowPmx('pmx_admin, pmx_articles') || allowPmx('pmx_create') && $article['owner'] == $user_info['id'] ? ' pmx_pgdelete" title="' . $txt['pmx_delete_article'] . '" onclick="pmxSetArtDelete(\'' . $article['id'] . '\')"' : '"') . '></div>
								</div>
							</div>';
}
/**
* Receive all the Posts from Categories Manager, check and save it.
* Finally the categories are prepared and the templare loaded.
*/
function PortaMx_AdminCategories()
{
    global $smcFunc, $context, $scripturl, $pmxCacheFunc, $txt;
    $admMode = isset($_GET['action']) ? $_GET['action'] : '';
    // fix the linktree
    if ($admMode == 'admin') {
        foreach ($context['linktree'] as $key => $data) {
            if (strpos($data['url'], 'pmx_categories') !== 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;
            }
        }
    }
    if (($admMode == 'admin' || $admMode == 'portamx') && allowPmx('pmx_admin') && isset($_GET['area']) && $_GET['area'] == 'pmx_categories') {
        require_once $context['pmx_sourcedir'] . 'AdminSubs.php';
        $context['pmx']['subaction'] = isset($_POST['sa']) ? $_POST['sa'] : 'overview';
        // From template ?
        if (PortaMx_checkPOST()) {
            // check the Post session
            checkSession('post');
            // actions from overview ?
            if ($context['pmx']['subaction'] == 'overview' && empty($_POST['cancel_overview'])) {
                // updates from overview popups ?
                if (!empty($_POST['upd_overview'])) {
                    if (isset($_POST['xml'])) {
                        $xmlResult = '';
                    }
                    $updates = array();
                    foreach ($_POST['upd_overview'] as $updkey => $updvalues) {
                        foreach ($updvalues as $id => $values) {
                            if ($updkey == 'title') {
                                foreach ($values as $key => $val) {
                                    if ($key == 'lang') {
                                        foreach ($val as $langname => $langvalue) {
                                            $updates[$id]['config'][$updkey][$langname] = $langvalue;
                                        }
                                    } else {
                                        $updates[$id]['config'][$updkey . '_' . $key] = $val;
                                    }
                                }
                            } else {
                                $updates[$id][$updkey] = $values;
                            }
                        }
                    }
                    // save all updates
                    foreach ($updates as $id => $values) {
                        $request = $smcFunc['db_query']('', '
							SELECT config, acsgrp
							FROM {db_prefix}portamx_categories
							WHERE id = {int:id}', array('id' => $id));
                        $row = $smcFunc['db_fetch_assoc']($request);
                        $smcFunc['db_free_result']($request);
                        foreach ($values as $rowname => $data) {
                            // update config array
                            if ($rowname == 'config') {
                                $cfg = unserialize($row['config']);
                                foreach ($data as $ckey => $cval) {
                                    if ($ckey == 'title') {
                                        foreach ($cval as $lang => $val) {
                                            $cfg[$ckey][$lang] = $val;
                                        }
                                    } else {
                                        $cfg[$ckey] = $cval;
                                    }
                                }
                                $smcFunc['db_query']('', '
									UPDATE {db_prefix}portamx_categories
									SET config = {string:config}
									WHERE id = {int:id}', array('id' => $id, 'config' => serialize($cfg)));
                            } elseif ($rowname == 'catname') {
                                $smcFunc['db_query']('', '
									UPDATE {db_prefix}portamx_categories
									SET name = {string:val}
									WHERE id = {int:id}', array('id' => $id, 'val' => $data));
                            } else {
                                $mode = substr($rowname, 0, 3);
                                // update (replace)
                                if ($mode == 'upd') {
                                    $newacs = explode(',', $data);
                                } elseif ($mode == 'add') {
                                    $newacs = array_unique(array_merge(explode(',', $row['acsgrp']), explode(',', $data)));
                                } else {
                                    $newacs = array_unique(array_diff(explode(',', $row['acsgrp']), explode(',', $data)));
                                }
                                $smcFunc['db_query']('', '
									UPDATE {db_prefix}portamx_categories
									SET acsgrp = {string:val}
									WHERE id = {int:id}', array('id' => $id, 'val' => implode(',', $newacs)));
                                // send by xml?
                                if (isset($_POST['xml'])) {
                                    $acsnew = implode(',', $newacs);
                                    $xmlResult .= (!empty($xmlResult) ? '&' : '') . $id . '|' . $acsnew . '|' . count($newacs) . '|' . intval(allowPmxGroup($newacs)) . '|1';
                                }
                            }
                        }
                    }
                    // clear cache
                    $pmxCacheFunc['clean']();
                    if (isset($_POST['xml'])) {
                        // return update result
                        ob_start();
                        if (!empty($_POST['result'])) {
                            echo $_POST['result'];
                        } else {
                            echo $xmlResult;
                        }
                        ob_end_flush();
                        exit;
                    }
                }
                // add new category
                if (!empty($_POST['add_new_category'])) {
                    $category = PortaMx_getDefaultCategory();
                    $context['pmx']['subaction'] = 'editnew';
                } elseif (!empty($_POST['edit_category']) || !empty($_POST['clone_category'])) {
                    $id = PortaMx_makeSafe(!empty($_POST['clone_category']) ? $_POST['clone_category'] : $_POST['edit_category']);
                    // load the category for edit/clone
                    $request = $smcFunc['db_query']('', '
						SELECT *
						FROM {db_prefix}portamx_categories
						WHERE id = {int:id}', array('id' => $id));
                    $row = $smcFunc['db_fetch_assoc']($request);
                    $category = array('id' => $row['id'], 'name' => $row['name'], 'parent' => $row['parent'], 'level' => $row['level'], 'catorder' => $row['catorder'], 'acsgrp' => $row['acsgrp'], 'artsort' => $row['artsort'], 'config' => $row['config']);
                    $smcFunc['db_free_result']($request);
                    if (!empty($_POST['clone_category'])) {
                        $category['id'] = 0;
                        $category['parent'] = 0;
                        $category['level'] = 0;
                        $category['catorder'] = 0;
                        $context['pmx']['subaction'] = 'editnew';
                    } else {
                        $context['pmx']['subaction'] = 'edit';
                    }
                } elseif (!empty($_POST['delete_category'])) {
                    pmx_delete_cat(PortaMx_makeSafe($_POST['delete_category']));
                    // set catid in articles to none (0)
                    $smcFunc['db_query']('', '
						UPDATE {db_prefix}portamx_articles
						SET catid = 0
						WHERE catid = {int:id}', array('id' => PortaMx_makeSafe($_POST['delete_category'])));
                    // clear cache
                    $pmxCacheFunc['clean']();
                } elseif (!empty($_POST['move_category'])) {
                    pmx_move_cat(PortaMx_makeSafe($_POST['move_category']), PortaMx_makeSafe($_POST['catplace']), PortaMx_makeSafe($_POST['movetocat']));
                    // clear cache
                    $pmxCacheFunc['clean']();
                }
            } elseif (!empty($_POST['cancel_edit']) || !empty($_POST['cancel_overview'])) {
                $context['pmx']['subaction'] = 'overview';
            } elseif ($context['pmx']['subaction'] == 'editnew' || $context['pmx']['subaction'] == 'edit') {
                // check defined numeric vars (check_num_vars holds the posted array to check like [varname][varname] ...)
                if (isset($_POST['check_num_vars'])) {
                    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']};");
                            }
                        }
                    }
                }
                // get all data
                $category = array('id' => $_POST['id'], 'name' => PortaMx_makeSafe($_POST['name']), 'parent' => $_POST['parent'], 'level' => $_POST['level'], 'catorder' => $_POST['catorder'], 'acsgrp' => !empty($_POST['acsgrp']) ? implode(',', $_POST['acsgrp']) : '', 'artsort' => !empty($_POST['artsort']) ? implode(',', $_POST['artsort']) : '', 'config' => serialize($_POST['config']));
                // save category.
                if (empty($_POST['edit_change']) && (!empty($_POST['save_edit']) || !empty($_POST['save_edit_continue']))) {
                    // if new category get the last id and catorder
                    if ($context['pmx']['subaction'] == 'editnew') {
                        $category = pmx_insert_cat(PortaMx_makeSafe($_POST['catplace']), PortaMx_makeSafe($_POST['catid']), $category);
                        // get max catid
                        $request = $smcFunc['db_query']('', '
							SELECT MAX(id)
							FROM {db_prefix}portamx_categories', array());
                        list($maxid) = $smcFunc['db_fetch_row']($request);
                        $smcFunc['db_free_result']($request);
                        $category['id'] = strval(1 + ($maxid === null ? $category['id'] : $maxid));
                    }
                    // now save all data
                    $smcFunc['db_insert']('replace', '
						{db_prefix}portamx_categories', array('id' => 'int', 'name' => 'string', 'parent' => 'int', 'level' => 'int', 'catorder' => 'int', 'acsgrp' => 'string', 'artsort' => 'string', 'config' => 'string'), array($category['id'], $category['name'], $category['parent'], $category['level'], $category['catorder'], $category['acsgrp'], $category['artsort'], $category['config']), array('id'));
                    // clear cache
                    $pmxCacheFunc['clean']();
                    $context['pmx']['subaction'] = 'edit';
                }
                // continue edit ?
                if (!empty($_POST['save_edit'])) {
                    $context['pmx']['subaction'] = 'overview';
                }
            }
            if ($context['pmx']['subaction'] == 'overview') {
                redirectexit('action=' . $admMode . ';area=pmx_categories;' . $context['session_var'] . '=' . $context['session_id']);
            }
        }
        // load template, setup pagetitle
        loadTemplate($context['pmx_templatedir'] . 'AdminCategories');
        $context['page_title'] = $txt['pmx_categories'];
        $context['pmx']['AdminMode'] = $admMode;
        // direct edit request?
        if (isset($_GET['sa']) && PortaMx_makeSafe($_GET['sa']) == 'edit' && !empty($_GET['id'])) {
            // load the category for edit
            $request = $smcFunc['db_query']('', '
				SELECT *
				FROM {db_prefix}portamx_categories
				WHERE id = {int:id}', array('id' => PortaMx_makeSafe($_GET['id'])));
            if ($smcFunc['db_num_rows']($request) > 0) {
                $row = $smcFunc['db_fetch_assoc']($request);
                $category = array('id' => $row['id'], 'name' => $row['name'], 'parent' => $row['parent'], 'level' => $row['level'], 'catorder' => $row['catorder'], 'acsgrp' => $row['acsgrp'], 'artsort' => $row['artsort'], 'config' => $row['config']);
                $smcFunc['db_free_result']($request);
                $context['pmx']['subaction'] = 'edit';
            }
        }
        // continue edit or overview ?
        if ($context['pmx']['subaction'] == 'overview') {
            // load all categories
            $context['pmx']['categories'] = PortaMx_getCategories(true);
            // load popup js for overview
            loadJavascriptFile(PortaMx_loadCompressed('PortaMxPopup.js'), array('external' => true));
        } elseif (empty($_POST['save_edit'])) {
            // load the class file and create the object
            require_once $context['pmx_sysclassdir'] . 'PortaMx_AdminCategoriesClass.php';
            $context['pmx']['editcategory'] = new PortaMxC_SystemAdminCategories($category);
            $context['pmx']['editcategory']->pmxc_AdmCategories_loadinit();
        }
    } else {
        fatal_error($txt['pmx_acces_error']);
    }
}
/**
* Init all variables and load the settings from the database.
* Check the requests and prepare the templates to load.
*/
function PortaMx($doinit = false)
{
    global $context, $modSettings, $boardurl, $scripturl, $user_info, $maintenance, $language, $pmxCacheFunc, $sc, $cookiename, $txt;
    // we can exit on this...
    if (defined('PortaMx') || isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach' && empty($doinit)) {
        if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'dlattach' && !empty($user_info['possibly_robot'])) {
            redirectexit();
        } else {
            return;
        }
    }
    define('PortaMx', 1);
    // no sign up for robots please !!
    if (!empty($user_info['possibly_robot']) && !empty($_REQUEST['action']) && $_REQUEST['action'] == 'signup') {
        redirectexit();
    }
    if (empty($user_info['possibly_robot'])) {
        // portal enable/disable request ?
        if ((isset($_REQUEST['pmxportal']) || isset($_REQUEST['pmxsef'])) && allowedTo('admin_forum')) {
            $mode = 'pmx' . (isset($_REQUEST['pmxportal']) ? 'portal' : 'sef');
            updateSettings(array($mode . '_disabled' => $_REQUEST[$mode] == 'off' ? '1' : '0'));
            redirectexit();
        }
        // clear PortaMx cache request ?
        if (isset($_GET['action']) && isset($_GET['area']) && (in_array($_GET['action'], array('admin', 'portamx')) && $_GET['area'] == 'pmx_cache')) {
            if (isset($_GET[$_SESSION['session_var']]) && $_GET[$_SESSION['session_var']] == $sc) {
                $pmxCacheFunc['clean']();
                $_SESSION['pmx_cache_cleared'] = true;
            }
            if (isset($_SESSION['pmx_last_request'])) {
                redirectexit($_SESSION['pmx_last_request']);
            }
        } elseif (pmx_checkECL_Cookie() && strpos($_SERVER['REQUEST_URL'], 'viewsmfile') === false) {
            $_SESSION['pmx_last_request'] = $_SERVER['REQUEST_URL'];
        }
        $lang = $pmxCacheFunc['get']($user_info['ip'] . '-lang');
        if (!pmx_checkECL_Cookie()) {
            if ($lang === null) {
                // get browser language
                $browserlang = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']) : '';
                if (preg_match_all('~en\\b|de\\b~i', $browserlang, $temp) > 0) {
                    $avail = array_keys(PortaMx_getLanguages());
                    if (in_array('de', $temp[0])) {
                        if (in_array('german', $avail)) {
                            $lang = 'german';
                        } elseif (in_array('german-utf8', $avail)) {
                            $lang = 'german-utf8';
                        }
                    } else {
                        $lang = $language;
                    }
                    $_POST['language'] = $lang;
                    $_POST['redir'] = pmx_http_build_query($_GET);
                }
            } else {
                $context['pmx']['currlang'] = $context['user']['language'] = $user_info['language'] = $language = $lang;
            }
            // need to releoad base language
            loadLanguage('index+Modifications');
        } else {
            if ($lang !== null) {
                $_POST['language'] = $lang;
                $_POST['redir'] = pmx_http_build_query($_GET);
            }
        }
        // check if a language change requested
        if (!empty($_POST['language'])) {
            $pmxCacheFunc['clean']();
            $context['pmx']['currlang'] = $context['user']['language'] = $user_info['language'] = $language = $_POST['language'];
            if (pmx_checkECL_Cookie()) {
                // Make it permanent for members.
                if (!empty($user_info['id'])) {
                    updateMemberData($user_info['id'], array('lngfile' => $user_info['language']));
                } else {
                    $_SESSION['language'] = $user_info['language'];
                }
            } else {
                $pmxCacheFunc['put']($user_info['ip'] . '-lang', $language, 360, false);
                $_POST['redir'] = pmx_http_build_query($_GET);
            }
            if (isset($_POST['redir'])) {
                redirectexit($_POST['redir']);
            }
        }
    }
    if (empty($modSettings['pmx_eclmodal']) && !pmx_checkECL_Cookie() && (!empty($_REQUEST['action']) && $_REQUEST['action'] != 'xml' || !empty($_REQUEST['page']) || !empty($_REQUEST['cat']) || !empty($_REQUEST['art']))) {
        if (empty($user_info['possibly_robot']) && !empty($_REQUEST['action']) && $_REQUEST['action'] == 'login') {
            setupMenuContext();
            pmx_ECL_Error($_REQUEST['action']);
        } else {
            redirectexit();
        }
    }
    // redirect on illegal request
    if (!empty($_REQUEST['pmxportal']) || !empty($_REQUEST['pmxsef']) || !empty($_REQUEST['pmxerror']) && !empty($_REQUEST['action'])) {
        redirectexit('pmxerror=unknown');
    }
    // check if a permanent theme change requested
    if (isset($_REQUEST['theme']) && isset($_REQUEST['pmxrd'])) {
        PortaMx_ChangeTheme($_REQUEST['theme'], $_REQUEST['pmxrd']);
    }
    // load all settings
    PortaMx_getSettings();
    // shoutbox POST request?
    if (!empty($_POST['pmx_shout']) && !empty($_POST['shoutbox_id'])) {
        PortaMx_GetShoutbox($_POST['shoutbox_id']);
        if (pmx_checkECL_Cookie()) {
            $_SESSION['pmx_shoutreload'] = true;
        }
        exit;
    }
    // exit on follow actions
    $rqaction = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
    if (isset($_REQUEST['xml']) || in_array($rqaction, array('jseditor', 'jsoption', '.xml', 'xmlhttp', 'verificationcode', 'printpage'))) {
        return;
    }
    // login with redirect .. correct SEF url
    if ($rqaction == 'login' && !empty($_SESSION['old_url']) && function_exists('pmxsef_query')) {
        $_SESSION['old_url'] = $scripturl . pmx_http_build_query(pmxsef_query(rawurldecode(ltrim(str_replace($boardurl, '', $_SESSION['old_url']), '/'))));
    }
    // check if a pmxscriptdebug/pmxspidertest requested
    $tmp = isset($_GET['pmxscriptdebug']) ? 'pmxscriptdebug' : (isset($_GET['pmxspidertest']) ? 'pmxspidertest' : '');
    if (!empty($tmp) && in_array($_GET[$tmp], array('on', 'off'))) {
        if (allowPmx('pmx_admin')) {
            if ($tmp == 'pmxscriptdebug') {
                pmx_setcookie($tmp, $_GET[$tmp] == 'on' ? '1' : '');
                unset($_GET[$tmp]);
                redirectexit(pmx_http_build_query($_GET));
            } elseif ($tmp == 'pmxspidertest' && $_GET[$tmp] == 'on' && !empty($modSettings['pmx_ecl'])) {
                $logCook = pmx_getcookie($cookiename);
                pmx_setcookie($tmp, $logCook);
                pmx_setcookie($cookiename, '');
                pmx_setcookie('pmx_eclauth', '');
                pmx_setcookie('PHPSESSID', '');
                unset($logCook);
                redirectexit();
            }
        } elseif ($tmp == 'pmxspidertest' && $_GET[$tmp] == 'off' && pmx_getcookie('pmxspidertest')) {
            $udata = pmx_getcookie($tmp);
            if (isset($udata) && is_array($dtmp = unserialize($udata)) && count($dtmp == 4)) {
                pmx_setECL_Cookie();
                pmx_setcookie($cookiename, $udata, $dtmp[2]);
                unset($dtmp);
                unset($udata);
            }
            pmx_setcookie('pmxspidertest', '');
            redirectexit();
        }
    }
    // load common javascript
    loadJavascriptFile(PortaMx_loadCompressed('PortaMx.js'), array('external' => true));
    addInlineJavascript('
	var pmx_restore_top = ' . intval(!empty($context['pmx']['settings']['restoretop'])) . ';');
    if ($doinit || !empty($modSettings['pmxportal_disabled'])) {
        loadLanguage($context['pmx_templatedir'] . 'PortaMx');
        loadCSSFile(PortaMx_loadCompressed('portamx.css'), array('external' => true));
        return;
    }
    // on Admin or Moderate load admin language, css and javascript
    if (($rqaction == 'admin' || $rqaction == 'portamx') && isset($_REQUEST['area']) && in_array($_REQUEST['area'], explode(',', $context['pmx']['areas']))) {
        loadJavascriptFile(PortaMx_loadCompressed('PortaMxAdmin.js'), array('external' => true));
        loadCSSFile(PortaMx_loadCompressed('portamx_admin.css'), array('external' => true));
        loadLanguage($context['pmx_templatedir'] . 'Admin');
        addInlineJavascript("\n\t" . 'BlockActive=\'' . $txt['pmx_status_activ'] . ' - ' . $txt['pmx_status_change'] . '\';' . "\n\t" . 'BlockInactive=\'' . $txt['pmx_status_inactiv'] . ' - ' . $txt['pmx_status_change'] . '\';');
    }
    // Error request?
    if (!empty($_REQUEST['pmxerror'])) {
        return PmxError();
    }
    // check Error request, Forum request
    $context['pmx']['forumReq'] = !empty($_REQUEST['action']) || !empty($context['current_board']) || !empty($context['current_topic']);
    if (empty($context['pmx']['forumReq']) && !empty($context['pmx']['settings']['other_actions'])) {
        $reqtyp = Pmx_StrToArray($context['pmx']['settings']['other_actions']);
        foreach ($reqtyp as $rtyp) {
            @(list($rtyp, $rval) = Pmx_StrToArray($rtyp, '='));
            $context['pmx']['forumReq'] = $context['pmx']['forumReq'] || isset($_REQUEST[$rtyp]) && (is_null($rval) || $_REQUEST[$rtyp] == $rval);
        }
    }
    // check Page, category, article request
    $pmxRequestTypes = array('spage', 'art', 'cat', 'child');
    $context['pmx']['pageReq'] = array();
    foreach ($pmxRequestTypes as $type) {
        if (empty($_REQUEST['action']) && !empty($_REQUEST[$type])) {
            $context['pmx']['pageReq'][$type] = PortaMx_makeSafe($_REQUEST[$type]);
        }
    }
    // no request on forum or pages and no frontpage .. go to forum
    if (empty($context['pmx']['forumReq']) && empty($context['pmx']['pageReq']) && $context['pmx']['settings']['frontpage'] == 'none') {
        $_REQUEST['action'] = $_GET['action'] = 'community';
        $context['pmx']['forumReq'] = true;
    }
    // Disable HighSlide on action?
    if (isset($_REQUEST['action']) && isset($context['pmx']['settings']['noHS_onaction'])) {
        $noHighSlide = isset($context['pmx']['settings']['noHS_onaction']) ? Pmx_StrToArray($context['pmx']['settings']['noHS_onaction']) : array();
        if (in_array($_REQUEST['action'], $noHighSlide)) {
            $context['pmx']['settings']['disableHS'] = 1;
        }
    }
    // Admin panel/block hidding ?
    $hideRequest = array_intersect($context['pmx']['extracmd'], array_keys($_REQUEST));
    if (!empty($hideRequest) && allowPmx('pmx_admin')) {
        @(list($hideRequest) = array_values($hideRequest));
        $mode = substr($hideRequest, 5);
        $hidetyp = substr($hideRequest, 0, 5);
        $offparts = empty($modSettings['pmx_' . $hidetyp . 'off']) ? array() : Pmx_StrToArray($modSettings['pmx_' . $hidetyp . 'off']);
        if ($mode == 'off') {
            if ($hidetyp == 'panel') {
                $offparts = array_intersect($_REQUEST[$hideRequest] == 'all' ? $context['pmx']['block_sides'] : array_merge($offparts, Pmx_StrToArray($_REQUEST[$hideRequest])), $context['pmx']['block_sides']);
            } else {
                $offparts = array_merge($offparts, Pmx_StrToIntArray($_REQUEST[$hideRequest]));
            }
        } else {
            if ($hidetyp == 'panel') {
                $offparts = array_intersect($_REQUEST[$hideRequest] == 'all' ? array() : array_diff($offparts, Pmx_StrToArray($_REQUEST[$hideRequest])), $context['pmx']['block_sides']);
            } else {
                $offparts = $_REQUEST[$hideRequest] == 'all' ? array() : array_diff($offparts, Pmx_StrToIntArray($_REQUEST[$hideRequest]));
            }
        }
        updateSettings(array('pmx_' . $hidetyp . 'off' => implode(',', $offparts)));
        unset($_GET[$hideRequest]);
        redirectexit(pmx_http_build_query($_GET));
    }
    // check all the actions and more...
    if (empty($context['pmx']['forumReq'])) {
        // if a redirect request, exit
        $requrl = strpos($_SERVER['REQUEST_URL'], substr($scripturl, 0, strrpos($scripturl, '/'))) === false ? $_SERVER['REQUEST_URL'] : $scripturl;
        if (substr($requrl, 0, strrpos($requrl, '/')) != substr($scripturl, 0, strrpos($scripturl, '/'))) {
            return;
        }
        // we use the frontpage ?
        $useFront = $context['pmx']['settings']['frontpage'] == 'none' && empty($context['pmx']['pageReq']) ? '' : 'frontpage';
        // get all block on active panels they can view
        $context['pmx']['viewblocks'] = getPanelsToShow($useFront);
        // frontpage and/or Page blocks exist ?
        if (!empty($maintenance) && $context['pmx']['settings']['frontpage'] != 'none' || empty($useFront) || !empty($context['pmx']['show_pagespanel']) || !empty($context['pmx']['show_frontpanel']) && $context['pmx']['settings']['frontpage'] != 'none') {
            // setup headers
            PortaMx_headers('frontpage');
            $context['robot_no_index'] = empty($context['pmx']['settings']['indexfront']);
            if ($context['pmx']['settings']['frontpage'] == 'fullsize') {
                loadTemplate($context['pmx_templatedir'] . 'Frontpage');
                $context['template_layers'] = array('fronthtml', 'portamx');
                call_integration_hook('integrate_load_theme');
            } else {
                loadTemplate($context['pmx_templatedir'] . 'Mainindex');
                $context['template_layers'][] = 'portamx';
            }
            if (!empty($context['pmx']['pageReq']) || empty($context['pmx']['forumReq']) && $context['pmx']['settings']['frontpage'] != 'none') {
                loadTemplate($context['pmx_templatedir'] . 'PortaMx');
            }
        } else {
            // page req error?
            if (!empty($context['pmx']['pageReq']) && empty($context['pmx']['show_pagespanel'])) {
                redirectexit('pmxerror=page');
            }
            // else go to forum
            $_REQUEST['action'] = $_GET['action'] = !empty($maintenance) && empty($user_info['is_admin']) ? '' : 'community';
            $context['pmx']['forumReq'] = true;
            $context['pmx']['viewblocks'] = null;
        }
    }
    if (!empty($context['pmx']['forumReq'])) {
        // get the action
        $action = isset($_REQUEST['action']) ? $_REQUEST['action'] == 'collapse' ? 'community' : $_REQUEST['action'] : (isset($_REQUEST['board']) ? 'boards' : (isset($_REQUEST['topic']) ? 'topics' : ''));
        // get all block on active panels they can view
        $context['pmx']['viewblocks'] = getPanelsToShow($action);
        // setup headers
        PortaMx_headers($action);
        // load the "Main" template on pages, cats or arts
        if (!empty($context['pmx']['pageReq'])) {
            loadTemplate($context['pmx_templatedir'] . 'PortaMx');
        }
        loadTemplate($context['pmx_templatedir'] . 'Mainindex');
        $context['template_layers'][] = 'portamx';
    }
    // Load the Frame template
    loadTemplate($context['pmx_templatedir'] . 'Frames');
    // supress these links if ECL not accepted
    if (!empty($rqaction) && !pmx_checkECL_Cookie() && isset($modSettings['pmx_eclmodalaction']) && in_array($rqaction, Pmx_StrToArray($modSettings['pmx_eclmodalaction']))) {
        pmx_ECL_Error('request');
    }
    // Create the linktree
    return pmx_MakeLinktree();
}
/**
* \file AdminCenter.template.php
* Template for the Admin Center.
*
* \author PortaMx - Portal Management Extension
* \author Copyright 2008-2015 by PortaMx - http://portamx.com
* \version Virgo 2.0 Beta 2
* \date 14.09.2015
*/
function template_main()
{
    global $context, $scripturl, $txt;
    $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>';
    }
    if ($context['pmx']['subaction'] != 'showlang') {
        echo '
	<table class="pmx_table" style="margin-top:1px; overflow:hidden;">
		<tr>
			<td>
				<div class="cat_bar">
					<h3 class="catbg largetext">', $txt['pmx_admin_center'], '</h3>
				</div>
				<p class="information" style="margin: 0;padding: 8px;">
					<b>' . $txt['hello_guest'] . ' ' . $context['user']['name'] . '!</b>
					' . sprintf($txt['pmx_admin_main_welcome'], '<img src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="" style="vertical-align: text-bottom;" />') . '
				</p>
			</td>
		</tr>
		<tr>
			<td>';
    }
    // Admin center main ?
    if ($context['pmx']['subaction'] == 'main') {
        echo '
					<table class="pmx_table" style="margin-top:1em;">
						<tr>
							<td style="width:65%">
								<div class="cat_bar">
									<h3 class="catbg"><span class="pmxtitle pmxleft">' . $txt['pmx_center_news'] . '</span></h3>
								</div>
							</td>
							<td>&nbsp;&nbsp;&nbsp;</td>
							<td>
								<div class="cat_bar" style="overflow:hidden;">
									<h3 class="catbg"><span class="pmxtitle pmxleft">' . $txt['pmx_center_support'] . '</span></h3>
								</div>
							</td>
						</tr>
						<tr>
							<td>
								<div class="roundframe" style="border-top-left-radius:0;border-top-right-radius:0;margin-top:-1px;padding:5px">
									<div class="smalltext" style="margin:1px 4px 5px 4px;height:130px;overflow:auto;line-height:1.5em;s">';
        if (!empty($context['pmx_info']['item'])) {
            foreach ($context['pmx_info']['item'] as $data) {
                echo '
										' . $data['subject'] . ' on ' . $data['date'] . '
										<div style="padding:0 0 10px 0;border-top: 1px solid #808080;">' . $data['msg'] . '</div>';
            }
        } else {
            echo '
										<div>' . $txt['pmx_center_nolivedata'] . '</div>';
        }
        echo '
									</div>
								</div>
							</td>
							<td style="width:5px;padding:0px 7px;"></td>
							<td style="width:40%">
								<div class="roundframe" style="border-top-left-radius:0;border-top-right-radius:0;margin-top:-1px;padding:5px;overflow:hidden;">
									<div style="height:116px;">
										<div class="middletext" style="padding:2px 4px;">' . $txt['pmx_center_versioninfo'] . '<br />' . $txt['pmx_center_installed'] . '<i' . (empty($context['pmx_info']['versionOK']) ? ' style="color:#ff0000;"' : '') . '>' . $context['pmx_info']['installed'] . '</i><br />' . $txt['pmx_center_version'] . '<i>';
        echo $context['pmx_info']['version'];
        echo '</i>
										</div>
										<div class="middletext" style="padding:2px 3px;">';
        if (!empty($context['pmx_info']['update']) && empty($context['pmx_info']['versionOK'])) {
            echo '
											<a href="' . $scripturl . '?action=admin;area=packages;sa=download;get;server=' . $context['pmx_info']['updserver'] . ';package=' . $context['pmx']['server']['update'] . $context['pmx_info']['update'] . ';' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['pmx_center_update'] . '</a>';
        }
        echo '
										</div>
										<div class="middletext" style="padding:2px 3px;">';
        if (!empty($context['pmx_info']['download']) && empty($context['pmx_info']['versionOK'])) {
            echo '
										<a href="' . $context['pmx_info']['download'] . '">' . $txt['pmx_center_download'] . '</a>';
        }
        echo '
										</div>
									</div>
									<div class="middletext" style="position:relative; left:3px; bottom:3px;">
										<a href="' . $scripturl . '?action=' . $context['pmx']['admmode'] . ';area=pmx_center;sa=flist;' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['pmx_center_detailed'] . '</a>
									</div>
								</div>
							</td>
						</tr>
						<tr>
							<td colspan="3" style="padding:0.5em 0;">
								<div class="roundframe" style="padding:10px 5px">
									<table class="pmx_table middletext" style="padding:5px;">
										<tr>
											<td style="width:50%; padding:5px">
												<a href="' . $scripturl . '?action=' . $context['pmx']['admmode'] . ';area=pmx_settings;' . $context['session_var'] . '=' . $context['session_id'] . '"><img style="float:left;margin:5px 10px 20px;" src="' . $context['pmx_imageurl'] . 'admc_settings.png" alt="*" title="" /></a>
												<a href="' . $scripturl . '?action=' . $context['pmx']['admmode'] . ';area=pmx_settings;' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['pmx_center_mansettings'] . '</a><br /><span class="smalltext">' . $txt['pmx_center_mansettings_desc'] . '</span>
											</td>
											<td style="width:50%; padding:5px">
												<a href="' . $scripturl . '?action=' . $context['pmx']['admmode'] . ';area=pmx_blocks;' . $context['session_var'] . '=' . $context['session_id'] . '"><img style="float:left;margin:5px 10px 20px;" src="' . $context['pmx_imageurl'] . 'admc_blocks.png" alt="*" title="" /></a>
												<a href="' . $scripturl . '?action=' . $context['pmx']['admmode'] . ';area=pmx_blocks;' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['pmx_center_manblocks'] . '</a><br /><span class="smalltext">' . $txt['pmx_center_manblocks_desc'] . '</span>
											</td>
										</tr>
										<tr>
											<td style="width:50%; padding:5px">
												<a href="' . $scripturl . '?action=' . $context['pmx']['admmode'] . ';area=pmx_categories;' . $context['session_var'] . '=' . $context['session_id'] . '"><img style="float:left;margin:5px 10px 20px;" src="' . $context['pmx_imageurl'] . 'admc_category.png" alt="*" title="" /></a>
												<a href="' . $scripturl . '?action=' . $context['pmx']['admmode'] . ';area=pmx_categories;' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['pmx_center_mancategories'] . '</a><br /><span class="smalltext">' . $txt['pmx_center_mancategories_desc'] . '</span>
											</td>
											<td style="width:50%; padding:5px">
												<a href="' . $scripturl . '?action=' . $context['pmx']['admmode'] . ';area=pmx_articles;' . $context['session_var'] . '=' . $context['session_id'] . '"><img style="float:left;margin:5px 10px 20px;" src="' . $context['pmx_imageurl'] . 'admc_article.png" alt="*" title="" /></a>
												<a href="' . $scripturl . '?action=' . $context['pmx']['admmode'] . ';area=pmx_articles;' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['pmx_center_manarticles'] . '</a><br /><span class="smalltext">' . $txt['pmx_center_manarticles_desc'] . '</span>
											</td>
										</tr>
										<tr>
											<td style="width:50%; padding:5px">
												<a href="' . $scripturl . '?action=' . $context['pmx']['admmode'] . ';area=pmx_sefengine;' . $context['session_var'] . '=' . $context['session_id'] . '"><img style="float:left;margin:5px 10px 20px;" src="' . $context['pmx_imageurl'] . 'admc_pmxsef.png" alt="*" title="" /></a>
												<a href="' . $scripturl . '?action=' . $context['pmx']['admmode'] . ';area=pmx_sefengine;' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['pmx_center_mansefengine'] . '</a><br /><span class="smalltext">' . $txt['pmx_center_mansefengine_desc'] . '</span>
											</td>
											<td style="width:50%; padding:5px">
												<a href="' . $scripturl . '?action=' . $context['pmx']['admmode'] . ';area=pmx_languages;' . $context['session_var'] . '=' . $context['session_id'] . '"><img style="float:left;margin:5px 10px 20px;" src="' . $context['pmx_imageurl'] . 'admc_language.png" alt="*" title="" /></a>
												<a href="' . $scripturl . '?action=' . $context['pmx']['admmode'] . ';area=pmx_languages;' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['pmx_center_manlangs'] . '</a><br /><span class="smalltext">' . $txt['pmx_center_manlangs_desc'] . '</span>
											</td>
										</tr>
									</table>
								</div>
							</td>
						</tr>
					</table>';
    }
    // Detailed filelist ?
    if ($context['pmx']['subaction'] == 'flist') {
        echo '
					<table class="pmx_table" style="margin-top:1em;">
						<tr>
							<td>
								<div class="cat_bar">
									<h3 class="catbg">' . $txt['pmx_center_vercheck'] . '</h3>
								</div>
								<p class="information">' . $txt['pmx_center_vercheck_info'] . '</p>
							</td>
						</tr>
						<tr>
							<td style="padding:0 0 5px 0;"><div class="roundframe" style="margin-top:5px;">
								<table class="pmx_table middletext" style="margin:0 1px; padding:0 5px;">
									<tr>
										<td style="width:50%">' . $txt['pmx_center_file'] . '</td>
										<td style="text-align:right;width:25%">' . $txt['pmx_center_fileinstalled'] . '</td>
										<td style="text-align:right;width:25%">' . $txt['pmx_center_filecurrent'] . '</td>
									</tr>';
        foreach ($context['pmx_info'] as $dirtext => $data) {
            echo '
									<tr>
										<td>';
            if ($dirtext == 'pmx_filepackage') {
                echo $txt[$dirtext];
            } else {
                echo '<div class="admin_hover" onclick="Toggle_help(\'' . $dirtext . '\');"><span>' . $txt[$dirtext] . '</span></div>';
            }
            echo '
										</td>
										<td style="text-align:right;">' . $data['installed'] . '</td>
										<td style="text-align:right;">' . $data['current'] . '</td>
									</tr>
									<tr>
										<td colspan="3">
											<div id="' . $dirtext . '" style="display:none; padding:3px 0px 5px 10px;">
												<table class="pmx_table">
													<tr>
														<td style="width:60%">' . $txt['pmx_center_filename'] . '</td>
														<td style="width:25%;text-align:left">' . $txt['pmx_center_fileversion'] . '</td>
														<td style="width:15%;text-align:right">' . $txt['pmx_center_filedate'] . '</td>
													</tr>';
            if ($dirtext == 'pmx_language_files') {
                foreach ($context['pmx_installed_ext'] as $ext) {
                    foreach ($data['files'] as $file => $value) {
                        if (stripos($file, '.min.') === false) {
                            if (!empty($file) && strstr($file, '.') == $ext) {
                                echo '
													<tr>
														<td>' . $value['subdir'] . $file . '</td>
														<td style="text-align:left">' . $value['version'] . '</td>
														<td style="text-align:right">' . $value['date'] . '</td>
													</tr>';
                            }
                        }
                    }
                    echo '
													<tr>
														<td colspan="3"><div style="height:5px;"></div></td>
													</tr>';
                }
            } else {
                $cdir = '';
                foreach ($data['files'] as $file => $value) {
                    if (!empty($file)) {
                        if (stripos($file, '.min.') === false) {
                            if (empty($cdir)) {
                                $cdir = $value['subdir'];
                            } elseif ($cdir != $value['subdir']) {
                                $cdir = $value['subdir'];
                                echo '
														<tr>
															<td colspan="3"><div style="height:5px;"></div></td>
														</tr>';
                            }
                            echo '
													<tr>
														<td>' . $value['subdir'] . $file . '</td>
														<td style="text-align:left">' . $value['version'] . '</td>
														<td style="text-align:right">' . $value['date'] . '</td>
													</tr>';
                        }
                    }
                }
            }
            echo '
												</table>
											</div>
										</td>
									</tr>';
        }
        echo '
									<tr>
										<td colspan="3" style="padding:0.2em;text-align:center"><hr class="pmx_hr" />
											<input class="button_submit" type="button" name="back" value="' . $txt['page_reqerror_button'] . '" onclick="window.location.href=\'' . $scripturl . '?action=' . $context['pmx']['admmode'] . ';area=pmx_center\';pmxWinGetTop(\'adm\',\'template\')" />
										</td>
									</tr>
								</table>
								</div>
							</td>
						</tr>
					</table>';
    }
    // Show Error ?
    if ($context['pmx']['subaction'] == 'error') {
        echo '
					<table class="pmx_table" style="width:75%;margin:0 auto; margin-top:1em; text-align:center;">
						<tr>
							<td style="text-align:center">
								<div class="cat_bar">
									<h3 class="catbg largetext headerpadding">', $context['pmx']['AdmcError']['title'], '</h3>
								</div>
							</td>
						</tr>
						<tr>
							<td class="middletext">
									<div class="roundframe">
										' . $context['pmx']['AdmcError']['msg'] . '
										<div style="padding-top:10px;text-align:center">
											<input class="button_submit" type="button" name="back" value="' . $txt['page_reqerror_button'] . '" onclick="window.location.href=\'' . $scripturl . '?action=' . $context['pmx']['admmode'] . ';area=pmx_center' . (!empty($context['pmx']['AdmcError']['subact']) ? ';sa=' . $context['pmx']['AdmcError']['subact'] . ';' . $context['session_var'] . '=' . $context['session_id'] : '') . '\';pmxWinGetTop(\'adm\',\'template\')" />
										</div>
									</div>
							</td>
						</tr>
					</table>';
    }
    // Show languages ?
    if ($context['pmx']['subaction'] == 'showlang') {
        echo '
	<table class="pmx_table" style="margin-top:1px; overflow:hidden;">
		<tr>
			<td>
				<form id="pmx_form" accept-charset="' . $context['character_set'] . '" name="PMxAdmCenter" action="' . $scripturl . '?action=' . $context['pmx']['admmode'] . ';area=pmx_center;sa=admlang;' . $context['session_var'] . '=' . $context['session_id'] . '" method="post" style="margin: 0px;">
					<input type="hidden" name="sc" value="' . $context['session_id'] . '" />
					<input id="common_field" type="hidden" value="" />';
        $tmp = explode(' ', $txt['pmx_admin_center']);
        echo '
					<table class="pmx_table">
						<tr>
							<td>
								<div class="cat_bar">
									<h3 class="catbg">' . $tmp[0] . ' ' . $txt['pmx_center_showlang'] . '</h3>
								</div>
								<p class="information" style="margin: 0 0 20px 0;padding: 8px;">
									<span id="holding">' . $txt['pmx_center_showlang_info'] . '</span>
									<span id="loading" style="display:none;">' . $txt['pmx_processing'] . '<img style="padding:0 10px;vertical-align:-2px;" src="' . $context['pmx_imageurl'] . 'loading.gif" alt="*" title="" /></span>
								</p>
							</td>
						</tr>
						<tr>
							<td>
								<div class="cat_bar">
									<h3 class="catbg centertext">' . $txt['pmx_center_langinstalled'] . '	</h3>
								</div>
								<div class="windowbg wdbgtop">
									<table class="pmx_table_grid">
										<tr>
											<td class="normaltext" style="text-align:left;width:35%"><b>' . $txt['pmx_center_langname'] . '</b></td>
											<td class="normaltext" style="text-align:left;width:20%"><b>' . $txt['pmx_center_langcharset'] . '</b></td>
											<td class="normaltext" style="text-align:left;width:10%"><b>' . $txt['pmx_center_langversion'] . '</b></td>
											<td class="normaltext" style="text-align:right;width:15%"><b>' . $txt['pmx_center_langaction'] . '</b></td>
										</tr>';
        // show installed languages
        $installed = array();
        foreach ($context['pmx']['instlang'] as $id => $data) {
            $installed[$id] = $data;
            echo '
										<tr>
											<td class="middletext">' . (isset($data['manually']) ? '* ' : '') . $data['name'] . '</td>
											<td class="middletext">' . $data['charset'] . '</td>
											<td class="middletext">' . $data['version'] . '</td>
											<td class="middletext" style="text-align:right">';
            if ($id != 'lang.english') {
                echo '<a href="javascript:void(\'\')" onclick="FormFunc(\'lang_delete\', \'' . $id . '\', \'' . $txt['pmx_confirm_langdelete'] . '\');">' . $txt['pmx_center_langdelete'] . '</a>';
            }
            echo '
											</td>
										</tr>';
        }
        echo '
									</table>
								</div>
								<div style="margin-bottom:1em;">
								</div>

								<div class="cat_bar">
									<h3 class="catbg centertext">', $txt['pmx_center_langavailable'], '</h3>
								</div>

								<div class="windowbg wdbgtop">
									<table class="pmx_table_grid">
										<tr>
											<td class="normaltext" style="text-align:left;width:35%"><b>' . $txt['pmx_center_langname'] . '</b></td>
											<td class="normaltext" style="text-align:left;width:20%"><b>' . $txt['pmx_center_langcharset'] . '</b></td>
											<td class="normaltext" style="text-align:left;width:10%"><b>' . $txt['pmx_center_langversion'] . '</b></td>
											<td class="normaltext" style="text-align:right;width:15%"><b>' . $txt['pmx_center_langaction'] . '</b></td>
										</tr>';
        // show available languages
        if (!empty($context['pmx']['langsets'])) {
            foreach ($context['pmx']['langsets'] as $data) {
                // check is installed
                $isInst = compareLang($data, $installed['lang.english'], 'eq');
                $isUpd = false;
                foreach ($installed as $i => $inst) {
                    if (compareLang($data, $inst, 'gt')) {
                        $isInst = true;
                        if ($data['version'] > $inst['version']) {
                            $isUpd = true;
                        }
                        break;
                    }
                }
                echo '
									<tr>
										<td class="middletext">' . (isset($data['manually']) ? '* ' : '') . $data['name'] . '</td>
										<td class="middletext">' . $data['charset'] . '</td>
										<td class="middletext">' . $data['version'] . '</td>
										<td class="middletext" style="text-align:right">
											<a href="javascript:void(\'\')" onclick="FormFunc(\'lang_install\', \'' . $data['link'] . (!empty($isInst) || !empty($isUpd) ? '\', \'' . (empty($isUpd) ? $txt['pmx_confirm_langreplace'] : $txt['pmx_confirm_langupdate']) : '') . '\')">' . (empty($isInst) ? $txt['pmx_center_langinstall'] : (empty($isUpd) ? $txt['pmx_center_langreplace'] : $txt['pmx_center_langupdate'])) . '</a>
										</td>
									</tr>';
            }
        } else {
            echo '
										<tr>
											<td class="middletext" colspan="4">' . $txt['pmx_center_fetchlang_failed'] . '</td>
										</tr>';
        }
        echo '
									</table>
								</div>
								<div style="margin-bottom:1em;">
								</div>';
        // show manually instalable languages
        if (!empty($context['pmx']['manualylangsets'])) {
            echo '
								<div class="cat_bar">
									<h3 class="catbg centertext">', $txt['pmx_center_manuallylang'], '</h3>
								</div>
								<div class="windowbg wdbgtop">
									<table class="pmx_table_grid">
										<tr>
											<td class="normaltext" style="text-align:left;width:35%"><b>' . $txt['pmx_center_langname'] . '</b></td>
											<td class="normaltext" style="text-align:left;width:20%"><b>' . $txt['pmx_center_langcharset'] . '</b></td>
											<td class="normaltext" style="text-align:left;width:10%"><b>' . $txt['pmx_center_langversion'] . '</b></td>
											<td class="normaltext" style="text-align:right;width:15%"><b>' . $txt['pmx_center_langaction'] . '</b></td>
										</tr>';
            foreach ($context['pmx']['manualylangsets'] as $key => $data) {
                $isInst = false;
                $isUpd = false;
                foreach ($installed as $i => $inst) {
                    if (compareLang($data, $inst, 'gt')) {
                        $isInst = true;
                        if ($data['version'] > $inst['version']) {
                            $isUpd = true;
                        }
                        break;
                    }
                }
                echo '
										<tr>
											<td class="middletext">' . $data['name'] . '</td>
											<td class="middletext">' . $data['charset'] . '</td>
											<td class="middletext">' . $data['version'] . '</td>
											<td class="middletext" style="text-align:right">
												<a href="javascript:void(\'\')" onclick="FormFunc(\'lang_install_manually\', \'' . $key . '\')">' . (empty($isInst) ? $txt['pmx_center_langinstall'] : (empty($isUpd) ? $txt['pmx_center_langreplace'] : $txt['pmx_center_langupdate'])) . '</a>
											</td>
										</tr>';
            }
            echo '
									</table>
								</div>
								<div style="margin-bottom:1em;">
								</div>';
        }
        echo '
								<div style="padding:5px 10px;text-align:center">
									<input class="button_submit" type="button" name="back" value="' . $txt['page_reqerror_button'] . '" onclick="window.location.href=\'' . $scripturl . '?action=' . $context['pmx']['admmode'] . ';area=pmx_center\';pmxWinGetTop(\'adm\',\'template\')" />
								</div>
							</td>
						</tr>
					</table>
					<script type="text/javascript">
						function StartProgress()
						{
							document.getElementById("holding").style.display = "none";
							document.getElementById("loading").style.display = "";
						}
					</script>
					</form>';
    }
    echo '
				</td>
			</tr>
		</table>';
}
/**
* Receive all the posts from the articles manager, check it, then save it.
* Finally the articles are prepared and the template loaded.
*/
function PortaMx_AdminArticles()
{
    global $smcFunc, $pmxCacheFunc, $context, $sourcedir, $scripturl, $modSettings, $user_info, $txt;
    $admMode = isset($_GET['action']) ? $_GET['action'] : '';
    // fix the linktree
    if ($admMode == 'admin') {
        foreach ($context['linktree'] as $key => $data) {
            if (strpos($data['url'], 'pmx_articles') !== 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;
            }
        }
    }
    if (($admMode == 'admin' || $admMode == 'portamx') && isset($_GET['area']) && $_GET['area'] == 'pmx_articles') {
        if (allowPmx('pmx_admin, pmx_articles, pmx_create')) {
            require_once $context['pmx_sourcedir'] . 'AdminSubs.php';
            $context['pmx']['subaction'] = !empty($_POST['sa']) ? $_POST['sa'] : 'overview';
            // From template ?
            if (PortaMx_checkPOST()) {
                // Make sure we have a valid session...
                checkSession('post');
                // get current pageindex
                if (isset($_POST['articlestart'])) {
                    $context['pmx']['articlestart'] = $_POST['articlestart'];
                }
                // actions from overview?
                if ($context['pmx']['subaction'] == 'overview' && empty($_POST['cancel_overview'])) {
                    // from xml on overview?
                    if (isset($_POST['xml'])) {
                        $xmlResult = '';
                    }
                    // filter set ?
                    if (isset($_POST['filter'])) {
                        $_SESSION['PortaMx']['filter'] = $_POST['filter'];
                    }
                    // Row pos updates from overview?
                    if (!empty($_POST['upd_rowpos'])) {
                        list($fromID, $place, $idto) = Pmx_StrToArray($_POST['upd_rowpos']);
                        $request = $smcFunc['db_query']('', '
							SELECT id
							FROM {db_prefix}portamx_articles
							WHERE id ' . ($place == 'before' ? '<' : '>') . ' {int:id}
							LIMIT 1', array('id' => $idto));
                        list($toID) = $smcFunc['db_fetch_row']($request);
                        $smcFunc['db_free_result']($request);
                        $toID = is_null($toID) ? $place == 'before' ? -1 : 0 : $toID;
                        $request = $smcFunc['db_query']('', '
							SELECT MAX(id) +1
							FROM {db_prefix}portamx_articles', array());
                        list($maxID) = $smcFunc['db_fetch_row']($request);
                        $smcFunc['db_free_result']($request);
                        // create the query...
                        if ($toID == -1) {
                            // move from to first
                            $query = array('SET id = 0 WHERE id = ' . $fromID, 'SET id = id + 1 WHERE id >= 1 AND id <= ' . $fromID, 'SET id = 1 WHERE id = 0');
                        } elseif ($toID == 0) {
                            // move from to end
                            $query = array('SET id = ' . $maxID . ' WHERE id = ' . $fromID, 'SET id = id - 1 WHERE id >= ' . $fromID);
                        } elseif ($toID > $fromID) {
                            // to > from - move to after from
                            $query = array('SET id = id + 1 WHERE id >= ' . $toID, 'SET id = ' . $toID . ' WHERE id = ' . $fromID, 'SET id = id - 1 WHERE id >= ' . $fromID);
                        } else {
                            // to < from - move to before from
                            $query = array('SET id = 0 WHERE id = ' . $fromID, 'SET id = id + 1 WHERE id >= ' . $toID . ' AND id <= ' . $fromID, 'SET id = ' . $toID . ' WHERE id = 0');
                        }
                        // execute
                        foreach ($query as $qdata) {
                            $smcFunc['db_query']('', 'UPDATE {db_prefix}portamx_articles ' . $qdata, array());
                        }
                    }
                    // updates from overview popups ?
                    if (!empty($_POST['upd_overview'])) {
                        $updates = array();
                        foreach ($_POST['upd_overview'] as $updkey => $updvalues) {
                            foreach ($updvalues as $id => $values) {
                                if ($updkey == 'title') {
                                    foreach ($values as $key => $val) {
                                        if ($key == 'lang') {
                                            foreach ($val as $langname => $langvalue) {
                                                $updates[$id]['config'][$updkey][$langname] = $langvalue;
                                            }
                                        } else {
                                            $updates[$id]['config'][$updkey . '_' . $key] = $val;
                                        }
                                    }
                                } else {
                                    $updates[$id][$updkey] = $values;
                                }
                            }
                        }
                        // save all updates
                        $idList = array();
                        $catList = array();
                        foreach ($updates as $id => $values) {
                            $idList[] = $id;
                            foreach ($values as $rowname => $data) {
                                $request = $smcFunc['db_query']('', '
									SELECT config, catid, acsgrp
									FROM {db_prefix}portamx_articles
									WHERE id = {int:id}', array('id' => $id));
                                $row = $smcFunc['db_fetch_assoc']($request);
                                $smcFunc['db_free_result']($request);
                                $catList[] = $row['catid'];
                                // update config
                                if ($rowname == 'config') {
                                    $cfg = unserialize($row['config']);
                                    foreach ($data as $ckey => $cval) {
                                        if ($ckey == 'title') {
                                            foreach ($cval as $lang => $val) {
                                                $cfg[$ckey][$lang] = $val;
                                            }
                                        } else {
                                            $cfg[$ckey] = $cval;
                                        }
                                    }
                                    $smcFunc['db_query']('', '
										UPDATE {db_prefix}portamx_articles
										SET config = {string:config}
										WHERE id = {int:id}', array('id' => $id, 'config' => serialize($cfg)));
                                } elseif ($rowname == 'category') {
                                    $smcFunc['db_query']('', '
										UPDATE {db_prefix}portamx_articles
										SET catid = {int:val}
										WHERE id = {int:id}', array('id' => $id, 'val' => $data));
                                } else {
                                    $mode = substr($rowname, 0, 3);
                                    // update (replace)
                                    if ($mode == 'upd') {
                                        $newacs = explode(',', $data);
                                    } elseif ($mode == 'add') {
                                        $newacs = array_unique(array_merge(explode(',', $row['acsgrp']), explode(',', $data)));
                                    } else {
                                        $newacs = array_unique(array_diff(explode(',', $row['acsgrp']), explode(',', $data)));
                                    }
                                    $smcFunc['db_query']('', '
										UPDATE {db_prefix}portamx_articles
										SET acsgrp = {string:val}
										WHERE id = {int:id}', array('id' => $id, 'val' => implode(',', $newacs)));
                                    // send by xml?
                                    if (isset($_POST['xml'])) {
                                        $request = $smcFunc['db_query']('', '
											SELECT active
											FROM {db_prefix}portamx_articles
											WHERE id = {int:id}', array('id' => $id));
                                        list($active) = $smcFunc['db_fetch_row']($request);
                                        $smcFunc['db_free_result']($request);
                                        $acsnew = implode(',', $newacs);
                                        $xmlResult .= (!empty($xmlResult) ? '&' : '') . $id . '|' . $acsnew . '|' . count($newacs) . '|' . intval(allowPmxGroup($newacs)) . '|' . (!empty($active) ? '1' : '0');
                                    }
                                }
                            }
                        }
                        // clear cached blocks && Cat/Art Session Keys
                        $pmxCacheFunc['clean']();
                        if (isset($_SESSION['PortaMx'])) {
                            foreach ($_SESSION['PortaMx'] as $key => $val) {
                                if (strpos($key, 'pmxpost_') !== false) {
                                    unset($_SESSION['PortaMx'][$key]);
                                }
                            }
                        }
                        if (isset($_POST['xml'])) {
                            // return update result
                            ob_start();
                            if (!empty($_POST['result'])) {
                                echo $_POST['result'];
                            } else {
                                echo $xmlResult;
                            }
                            ob_end_flush();
                            exit;
                        }
                    }
                    // add a new article
                    if (!empty($_POST['add_new_article'])) {
                        $article = PortaMx_getDefaultArticle($_POST['add_new_article']);
                        $context['pmx']['subaction'] = 'editnew';
                    } elseif (!empty($_POST['edit_article']) || !empty($_POST['clone_article'])) {
                        $id = !empty($_POST['clone_article']) ? $_POST['clone_article'] : $_POST['edit_article'];
                        // load the article for edit/clone
                        $request = $smcFunc['db_query']('', '
							SELECT *
							FROM {db_prefix}portamx_articles
							WHERE id = {int:id}', array('id' => $id));
                        $row = $smcFunc['db_fetch_assoc']($request);
                        $article = array('id' => $row['id'], 'name' => $row['name'], 'catid' => $row['catid'], 'acsgrp' => $row['acsgrp'], 'ctype' => $row['ctype'], 'config' => $row['config'], 'content' => $row['content'], 'active' => $row['active'], 'owner' => $row['owner'], 'created' => $row['created'], 'approved' => $row['approved'], 'approvedby' => $row['approvedby'], 'updated' => $row['updated'], 'updatedby' => $row['updatedby']);
                        $smcFunc['db_free_result']($request);
                        if (!empty($_POST['clone_article'])) {
                            $article['id'] = 0;
                            $article['active'] = 0;
                            $article['approved'] = 0;
                            $article['owner'] = $user_info['id'];
                            $article['created'] = 0;
                            $article['updated'] = 0;
                            $article['updatedby'] = 0;
                            $context['pmx']['subaction'] = 'editnew';
                        } else {
                            $context['pmx']['subaction'] = 'edit';
                        }
                    } elseif (!empty($_POST['delete_article'])) {
                        $delid = $_POST['delete_article'];
                        // get the current page
                        $context['pmx']['articlestart'] = getCurrentPage($delid, $context['pmx']['settings']['manager']['artpage'], true);
                        $smcFunc['db_query']('', '
							DELETE FROM {db_prefix}portamx_articles
							WHERE id = {int:id}', array('id' => $delid));
                        // clear cached blocks
                        $pmxCacheFunc['clean']();
                    } elseif (!empty($_POST['chg_approved'])) {
                        $smcFunc['db_query']('', '
							UPDATE {db_prefix}portamx_articles
							SET approved = CASE WHEN approved = 0 THEN {int:apptime} ELSE 0 END, approvedby = {int:appmember}
							WHERE id = {int:id}', array('id' => $_POST['chg_approved'], 'apptime' => forum_time(), 'appmember' => $user_info['id']));
                        // clear cached blocks
                        $pmxCacheFunc['clean']();
                    } elseif (!empty($_POST['chg_active'])) {
                        $smcFunc['db_query']('', '
							UPDATE {db_prefix}portamx_articles
							SET active = CASE WHEN active = 0 THEN {int:apptime} ELSE 0 END
							WHERE id = {int:id}', array('id' => $_POST['chg_active'], 'apptime' => forum_time()));
                        // clear cached blocks
                        $pmxCacheFunc['clean']();
                    }
                    if (isset($_POST['xml']) && (!empty($_POST['chg_active']) || !empty($_POST['chg_approved']))) {
                        $id = !empty($_POST['chg_active']) ? $_POST['chg_active'] : $_POST['chg_approved'];
                        $request = $smcFunc['db_query']('', '
							SELECT active, approved
							FROM {db_prefix}portamx_articles
							WHERE id = {int:id}', array('id' => $id));
                        list($active, $approved) = $smcFunc['db_fetch_row']($request);
                        $smcFunc['db_free_result']($request);
                        // return update result
                        ob_start();
                        echo $id . ',' . (!empty($_POST['chg_active']) ? intval(!empty($active)) : intval(!empty($approved)));
                        ob_end_flush();
                        exit;
                    }
                } elseif (!empty($_POST['cancel_edit']) || !empty($_POST['cancel_overview'])) {
                    // called fron blocks move/clone ?
                    if (!empty($_POST['fromblock'])) {
                        // on cancel after saved remove the article
                        if ($_POST['sa'] == 'edit' && !empty($_POST['id'])) {
                            $smcFunc['db_query']('', '
								DELETE FROM {db_prefix}portamx_articles
								WHERE id = {int:id}', array('id' => $_POST['id']));
                            $pmxCacheFunc['clean']();
                        }
                        // redirect back to the blocks manager
                        @(list($mode, $side, $bid) = explode('.', $_POST['fromblock']));
                        redirectexit('action=' . $admMode . ';area=pmx_blocks;sa=' . $side . ';' . $context['session_var'] . '=' . $context['session_id']);
                    }
                    // Otherwise let's load the overview
                    $context['pmx']['subaction'] = 'overview';
                } elseif ($context['pmx']['subaction'] == 'editnew' || $context['pmx']['subaction'] == 'edit') {
                    $context['pmx']['fromblock'] = $_POST['fromblock'];
                    // 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']};");
                            }
                        }
                    }
                    if (isset($_POST['content']) && PortaMx_makeSafeContent($_POST['content']) != '') {
                        // convert html/script to bbc
                        if ($_POST['ctype'] == 'bbc_script' && in_array($_POST['contenttype'], array('html', 'script'))) {
                            $_POST['content'] = PortaMx_SmileyToBBC($_POST['content']);
                            if (preg_match_all('/<img.*(style[^\\"]*\\"([^\\"]*\\"))[^>]*>/U', $_POST['content'], $match) > 0) {
                                foreach ($match[0] as $key => $val) {
                                    $repl = ' ' . str_replace(array('"', ': ', ':', 'px;'), array('', '="', '="', '" '), $match[2][$key]);
                                    $_POST['content'] = str_replace($val, str_replace($match[1][$key], $repl, $val), $_POST['content']);
                                }
                            }
                            require_once $sourcedir . '/Subs-Editor.php';
                            $modSettings['smiley_enable'] = true;
                            $user_info['smiley_set'] = 'PortaMx';
                            $_POST['content'] = html_to_bbc($_POST['content']);
                        } elseif ($_POST['contenttype'] == 'bbc_script' && in_array($_POST['ctype'], array('html', 'script'))) {
                            $_POST['content'] = PortaMx_BBCsmileys(parse_bbc(PortaMx_makeSafeContent($_POST['content'], $_POST['contenttype']), false));
                            $_POST['content'] = str_replace(array('<hr>', '<br>'), array('<hr />', '<br />'), $_POST['content']);
                            $_POST['content'] = preg_replace_callback('/<\\/[^>]*>|<[^\\/]*\\/>|<ul[^>]*>|<ol[^>]*>/', create_function('$matches', 'return $matches[0] ."\\n";'), $_POST['content']);
                            if (preg_match_all('/<img[^w]*(width=\\"([0-9]+)\\")(\\sheight=\\"([\\s0-9]+)\\")[^>]*>/', $_POST['content'], $match) > 0) {
                                foreach ($match[0] as $key => $val) {
                                    $_POST['content'] = str_replace($match[1][$key], '', $_POST['content']);
                                    $_POST['content'] = str_replace($match[3][$key], 'style="width: ' . $match[2][$key] . 'px;height: ' . $match[4][$key] . 'px;"', $_POST['content']);
                                }
                                $_POST['content'] = preg_replace('/px;"[^c]*class=/', 'px;" class=', $_POST['content']);
                            }
                        } elseif ($_POST['ctype'] == 'php' && $_POST['contenttype'] == 'php') {
                            pmxPHP_convert();
                        } elseif ($_POST['ctype'] == 'html' && $_POST['contenttype'] == 'html') {
                            $_POST['content'] = str_replace('/ckeditor/../Smileys/', '/Smileys/', $_POST['content']);
                            if (preg_match_all('~<img.*(class[^r]*resized[^\\"]*\\")[^>]*>~', $_POST['content'], $match) > 0) {
                                foreach ($match[0] as $key => $val) {
                                    $endChr = substr($val, -2) !== '/>' ? array('>', '/>') : array(' />', '/>');
                                    $repl = str_replace($match[1][$key], '', $val);
                                    $_POST['content'] = str_replace($val, str_replace($endChr[0], ' class="bbc_img resized"' . $endChr[1], $repl), $_POST['content']);
                                }
                            } elseif (preg_match_all('~<img[^>]*>~', $_POST['content'], $match) > 0) {
                                foreach ($match[0] as $key => $val) {
                                    $endChr = substr($val, -2) !== ' />' ? array('>', '/>') : array(' />', '/>');
                                    if (strpos($val, '/Smileys/') === false) {
                                        $_POST['content'] = str_replace($val, str_replace($endChr[0], ' class="bbc_img resized"' . $endChr[1], $val), $_POST['content']);
                                    }
                                }
                            }
                        }
                    }
                    // get all data
                    $article = array('id' => $_POST['id'], 'name' => $_POST['name'], 'catid' => $_POST['catid'], 'acsgrp' => !empty($_POST['acsgrp']) ? implode(',', $_POST['acsgrp']) : '', 'ctype' => $_POST['ctype'], 'config' => serialize($_POST['config']), 'content' => $_POST['content'], 'active' => $_POST['active'], 'owner' => $_POST['owner'], 'created' => $_POST['created'], 'approved' => $_POST['approved'], 'approvedby' => $_POST['approvedby'], 'updated' => $_POST['updated'], 'updatedby' => $_POST['updatedby']);
                    // save article if have content..
                    if (!empty($article['content']) && empty($_POST['edit_change']) && (!empty($_POST['save_edit']) || !empty($article['content']) && !empty($_POST['save_edit_continue']))) {
                        // if new article get the last id
                        if ($context['pmx']['subaction'] == 'editnew') {
                            $request = $smcFunc['db_query']('', '
								SELECT MAX(id)
								FROM {db_prefix}portamx_articles', array());
                            list($dbid) = $smcFunc['db_fetch_row']($request);
                            $smcFunc['db_free_result']($request);
                            $article['id'] = strval(1 + ($dbid === null ? $article['id'] : $dbid));
                            $article['created'] = forum_time();
                            // auto approve for admins
                            if (allowPmx('pmx_admin')) {
                                $article['approved'] = forum_time();
                                $article['approvedby'] = $user_info['id'];
                            }
                            // insert new article
                            $smcFunc['db_insert']('ignore', '
								{db_prefix}portamx_articles', array('id' => 'int', 'name' => 'string', 'catid' => 'int', 'acsgrp' => 'string', 'ctype' => 'string', 'config' => 'string', 'content' => 'string', 'active' => 'int', 'owner' => 'int', 'created' => 'int', 'approved' => 'int', 'approvedby' => 'int', 'updated' => 'int', 'updatedby' => 'int'), $article, array());
                            // clear cache
                            $pmxCacheFunc['clean']();
                        } else {
                            $article['updated'] = forum_time();
                            $article['updatedby'] = $user_info['id'];
                            // update the article
                            $smcFunc['db_query']('', '
								UPDATE {db_prefix}portamx_articles
								SET name = {string:name}, catid = {int:catid}, acsgrp = {string:acsgrp}, ctype = {string:ctype}, config = {string:config},
										content = {string:content}, active = {int:active}, owner = {int:owner}, created = {int:created}, approved = {int:approved},
										approvedby = {int:approvedby}, updated = {int:updated}, updatedby = {int:updatedby}
								WHERE id = {int:id}', array('id' => $article['id'], 'name' => $article['name'], 'catid' => $article['catid'], 'acsgrp' => $article['acsgrp'], 'ctype' => $article['ctype'], 'config' => $article['config'], 'content' => $article['content'], 'active' => $article['active'], 'owner' => $article['owner'], 'created' => $article['created'], 'approved' => $article['approved'], 'approvedby' => $article['approvedby'], 'updated' => $article['updated'], 'updatedby' => $article['updatedby']));
                        }
                        // clear cache
                        $pmxCacheFunc['clean']();
                        $context['pmx']['subaction'] = 'edit';
                    }
                    // continue edit ?
                    if (!empty($_POST['save_edit']) || !empty($_POST['save_edit_continue'])) {
                        if (empty($_POST['save_edit_continue'])) {
                            // edit done, is it a move/clone from blocks?
                            if (!empty($context['pmx']['fromblock'])) {
                                @(list($mode, $side, $bid) = explode('.', $context['pmx']['fromblock']));
                                // was block moved?
                                if ($mode == 'move') {
                                    $request = $smcFunc['db_query']('', '
										SELECT pos, blocktype
										FROM {db_prefix}portamx_blocks
										WHERE id = {int:bid}', array('bid' => $bid));
                                    $block = $smcFunc['db_fetch_assoc']($request);
                                    $smcFunc['db_free_result']($request);
                                    // update all pos >= moved id
                                    $smcFunc['db_query']('', '
										UPDATE {db_prefix}portamx_blocks
										SET pos = pos - 1
										WHERE side = {string:side} AND pos >= {int:pos}', array('side' => $side, 'pos' => $block['pos']));
                                    // delete the block
                                    $smcFunc['db_query']('', '
										DELETE FROM {db_prefix}portamx_blocks
										WHERE id = {int:id}', array('id' => $bid));
                                    // clear cache and SEF pages list
                                    $pmxCacheFunc['clean']();
                                }
                            }
                            // go to article overview
                            $context['pmx']['subaction'] = 'overview';
                            $context['pmx']['articlestart'] = getCurrentPage($article['id'], $context['pmx']['settings']['manager']['artpage']);
                        }
                    }
                    // clear cached blocks
                    $pmxCacheFunc['clean']();
                }
                if ($context['pmx']['subaction'] == 'overview') {
                    if (!isset($context['pmx']['articlestart'])) {
                        $context['pmx']['articlestart'] = 0;
                    }
                    redirectexit('action=' . $admMode . ';area=pmx_articles;' . $context['session_var'] . '=' . $context['session_id'] . ';pg=' . $context['pmx']['articlestart']);
                }
            }
            // load the template, initialize the page title
            loadTemplate($context['pmx_templatedir'] . 'AdminArticles');
            $context['page_title'] = $txt['pmx_articles'];
            $context['pmx']['AdminMode'] = $admMode;
            $context['pmx']['RegBlocks'] = eval($context['pmx']['registerblocks']);
            // direct edit request?
            if (isset($_GET['sa']) && PortaMx_makeSafe($_GET['sa']) == 'edit' && !empty($_GET['id'])) {
                // move or clone from blocks?
                if (isset($_GET['from'])) {
                    $context['pmx']['fromblock'] = PortaMx_makeSafe($_GET['from']) . '.' . PortaMx_makeSafe($_GET['id']);
                    // load the block
                    $request = $smcFunc['db_query']('', '
						SELECT *
						FROM {db_prefix}portamx_blocks
						WHERE id = {int:id}', array('id' => PortaMx_makeSafe($_GET['id'])));
                    $row = $smcFunc['db_fetch_assoc']($request);
                    $smcFunc['db_free_result']($request);
                    // modify the config array
                    $cfg = unserialize($row['config']);
                    if (isset($cfg['pagename'])) {
                        $pgname = $cfg['pagename'];
                        unset($cfg['pagename']);
                    } else {
                        $pgname = '';
                    }
                    unset($cfg['ext_opts']);
                    if (isset($cfg['frontmode'])) {
                        unset($cfg['frontmode']);
                    }
                    $cfg['can_moderate'] = allowedTo('admin_forum') ? 0 : 1;
                    $article = array('id' => 0, 'name' => $pgname, 'catid' => 0, 'acsgrp' => $row['acsgrp'], 'ctype' => $row['blocktype'], 'config' => serialize($cfg), 'content' => $row['content'], 'active' => 0, 'owner' => $user_info['id'], 'created' => 0, 'approved' => 0, 'approvedby' => 0, 'updated' => 0, 'updatedby' => 0);
                    $context['pmx']['subaction'] = 'editnew';
                    $context['pmx']['articlestart'] = 0;
                } else {
                    $context['pmx']['fromblock'] = '';
                    $request = $smcFunc['db_query']('', '
						SELECT *
						FROM {db_prefix}portamx_articles
						WHERE id = {int:id}', array('id' => PortaMx_makeSafe($_GET['id'])));
                    if ($smcFunc['db_num_rows']($request) > 0) {
                        $row = $smcFunc['db_fetch_assoc']($request);
                        $article = array('id' => $row['id'], 'name' => $row['name'], 'catid' => $row['catid'], 'acsgrp' => $row['acsgrp'], 'ctype' => $row['ctype'], 'config' => $row['config'], 'content' => $row['content'], 'active' => $row['active'], 'owner' => $row['owner'], 'created' => $row['created'], 'approved' => $row['approved'], 'approvedby' => $row['approvedby'], 'updated' => $row['updated'], 'updatedby' => $row['updatedby']);
                        $smcFunc['db_free_result']($request);
                        $context['pmx']['subaction'] = 'edit';
                        $context['pmx']['articlestart'] = 0;
                    }
                }
            }
            // continue edit or overview?
            if ($context['pmx']['subaction'] == 'overview') {
                // load article data for overview
                if (!allowPmx('pmx_articles') && allowPmx('pmx_create', true)) {
                    $where = 'WHERE a.owner = {int:owner}';
                } else {
                    $where = '';
                }
                if (!isset($_SESSION['PortaMx']['filter'])) {
                    $_SESSION['PortaMx']['filter'] = array('category' => '', 'approved' => 0, 'active' => 0, 'myown' => 0, 'member' => '');
                }
                if ($_SESSION['PortaMx']['filter']['category'] != '') {
                    $where .= (empty($where) ? 'WHERE ' : ' AND ') . 'a.catid IN ({array_int:catfilter})';
                }
                if ($_SESSION['PortaMx']['filter']['approved'] != 0) {
                    $where .= empty($where) ? 'WHERE ' : ' AND ';
                    if ($_SESSION['PortaMx']['filter']['active'] != 0) {
                        $where .= '(a.approved = 0 OR a.active = 0)';
                    } else {
                        $where .= 'a.approved = 0';
                    }
                }
                if ($_SESSION['PortaMx']['filter']['active'] != 0) {
                    $where .= empty($where) ? 'WHERE ' : ' AND ';
                    if ($_SESSION['PortaMx']['filter']['approved'] != 0) {
                        $where .= '(a.active = 0 OR a.approved = 0)';
                    } else {
                        $where .= 'a.active = 0';
                    }
                }
                if ($_SESSION['PortaMx']['filter']['myown'] != 0) {
                    $where .= (empty($where) ? 'WHERE ' : ' AND ') . 'a.owner = {int:owner}';
                }
                if ($_SESSION['PortaMx']['filter']['member'] != '') {
                    $where .= (empty($where) ? 'WHERE ' : ' AND ') . 'm.member_name LIKE {string:memname}';
                }
                if (isset($_GET['pg']) && !is_array($_GET['pg'])) {
                    $context['pmx']['articlestart'] = PortaMx_makeSafe($_GET['pg']);
                    unset($_GET['pg']);
                } elseif (!isset($context['pmx']['articlestart'])) {
                    $context['pmx']['articlestart'] = 0;
                }
                $cansee = allowPmx('pmx_articles, pmx_create', true);
                $isadmin = allowPmx('pmx_admin');
                $memerIDs = array();
                $context['pmx']['articles'] = array();
                $context['pmx']['article_rows'] = array();
                $context['pmx']['totalarticles'] = 0;
                $result = null;
                $request = $smcFunc['db_query']('', '
					SELECT a.id, a.name, a.catid, a.acsgrp, a.ctype, a.config, a.active, a.owner, a.created, a.approved, a.approvedby, a.updated, a.updatedby, a.content, c.artsort, c.level, c.name AS catname
					FROM {db_prefix}portamx_articles AS a' . ($_SESSION['PortaMx']['filter']['member'] != '' ? '
					LEFT JOIN {db_prefix}members AS m ON (a.owner = m.id_member)' : '') . '
					LEFT JOIN {db_prefix}portamx_categories AS c ON (a.catid = c.id)
					' . $where . '
					ORDER BY a.id', array('catfilter' => Pmx_StrToArray($_SESSION['PortaMx']['filter']['category']), 'memname' => str_replace('*', '%', $_SESSION['PortaMx']['filter']['member']), 'owner' => $user_info['id']));
                if ($smcFunc['db_num_rows']($request) > 0) {
                    while ($row = $smcFunc['db_fetch_assoc']($request)) {
                        $cfg = unserialize($row['config']);
                        if (!empty($isadmin) || $cansee && !empty($cfg['can_moderate'])) {
                            $memerIDs[] = $row['owner'];
                            $memerIDs[] = $row['approvedby'];
                            $memerIDs[] = $row['updatedby'];
                            $context['pmx']['article_rows'][$row['id']] = array('name' => $row['name'], 'cat' => str_repeat('&bull;', $row['level']) . $row['catname']);
                            $result[] = array('id' => $row['id'], 'name' => $row['name'], 'catid' => $row['catid'], 'cat' => str_repeat('&bull;', $row['level']) . $row['catname'], 'acsgrp' => $row['acsgrp'], 'ctype' => $row['ctype'], 'config' => $cfg, 'active' => $row['active'], 'owner' => $row['owner'], 'created' => $row['created'], 'approved' => $row['approved'], 'approvedby' => $row['approvedby'], 'updated' => $row['updated'], 'updatedby' => $row['updatedby'], 'content' => $row['content']);
                        }
                    }
                    $smcFunc['db_free_result']($request);
                    if (!empty($result)) {
                        foreach ($result as $st => $data) {
                            $context['pmx']['articles'][$st] = $data;
                        }
                        $context['pmx']['totalarticles'] = count($result);
                        if ($context['pmx']['totalarticles'] <= $context['pmx']['articlestart']) {
                            $context['pmx']['articlestart'] = 0;
                        }
                        // get all members names
                        $request = $smcFunc['db_query']('', '
							SELECT id_member, member_name
							FROM {db_prefix}members
							WHERE id_member IN ({array_int:members})', array('members' => array_unique($memerIDs)));
                        if ($smcFunc['db_num_rows']($request) > 0) {
                            while ($row = $smcFunc['db_fetch_assoc']($request)) {
                                $context['pmx']['articles_member'][$row['id_member']] = $row['member_name'];
                            }
                            $smcFunc['db_free_result']($request);
                        }
                    }
                }
                // load popup js for overview
                loadJavascriptFile(PortaMx_loadCompressed('PortaMxPopup.js'), array('external' => true));
            } elseif (empty($_POST['save_edit'])) {
                // prepare the editor
                PortaMx_EditArticle($article['ctype'], 'content', $article['content']);
                // load the class file and create the object
                require_once $context['pmx_sysclassdir'] . 'PortaMx_AdminArticlesClass.php';
                $context['pmx']['editarticle'] = new PortaMxC_SystemAdminArticle($article);
                $context['pmx']['editarticle']->pmxc_AdmArticle_loadinit();
            }
        } else {
            fatal_error($txt['pmx_acces_error']);
        }
    }
}
/**
* The main Subtemplate.
*/
function template_main()
{
    global $context, $modSettings, $txt, $scripturl, $PortaMx_cache;
    $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>';
    }
    $MenuTabs = array('globals' => $txt['pmx_admSet_globals'], 'frontpage' => $txt['pmx_admSet_front'], 'panels' => $txt['pmx_admSet_panels'], 'control' => $txt['pmx_admSet_control'], 'access' => $txt['pmx_admSet_access']);
    $Descriptions = array('globals' => $txt['pmx_admSet_desc_global'], 'frontpage' => $txt['pmx_admSet_desc_front'], 'panels' => $txt['pmx_admSet_desc_panel'], 'control' => $txt['pmx_admSet_desc_control'], 'access' => $txt['pmx_admSet_desc_access']);
    if ($curarea == 'pmx_sefengine') {
        $context['pmx']['subaction'] = '';
    } else {
        echo '
			<div class="cat_bar"><h3 class="catbg">' . $txt['pmx_adm_settings'] . '</h3></div>
			<p class="information" style="margin:0;padding-top:8px;">' . $Descriptions[$context['pmx']['subaction']] . '</p>
			<div class="adm_submenus" style="margin-bottom:6px;overflow:hidden;">
				<ul class="dropmenu">';
        foreach ($MenuTabs as $name => $desc) {
            echo '
					<li id="' . $name . '" class="subsections">
						<a class="firstlevel' . ($name == $context['pmx']['subaction'] ? ' active' : '') . '" href="' . $scripturl . '?action=' . $context['pmx']['AdminMode'] . ';area=pmx_settings;sa=' . $name . ';' . $context['session_var'] . '=' . $context['session_id'] . ';" onclick="pmxWinGetTop(\'adm\',\'template\')">
							<span class="firstlevel">' . $desc . '</span>
						</a>
					</li>';
        }
        echo '
				</ul>
			</div>';
    }
    $admset = $context['pmx']['settings'];
    echo '
	<form id="pmx_form" accept-charset="', $context['character_set'], '" name="PMxAdminSettings" action="' . $scripturl . '?action=' . $context['pmx']['AdminMode'] . ';area=' . $curarea . (!empty($context['pmx']['subaction']) ? ';sa=' . $context['pmx']['subaction'] : '') . ';' . $context['session_var'] . '=' . $context['session_id'] . '" method="post" style="margin: 0px;">
		<input type="hidden" name="sc" value="', $context['session_id'], '" />
		<input id="common_field" type="hidden" value="" />';
    if ($context['pmx']['subaction'] == 'globals') {
        // define numeric vars to check
        echo '
		<input type="hidden" name="check_num_vars[]" value="[left_panel][size], 170" />
		<input type="hidden" name="check_num_vars[]" value="[right_panel][size], 170" />
		<input type="hidden" name="check_num_vars[]" value="[panels][padding], 4" />';
        // Global settings
        echo '
		<table class="pmx_table pmx_fixedtable" style="margin-bottom:5px;">
			<tr>
				<td style="text-align:center">
					<div class="cat_bar">
						<h3 class="catbg">', $txt['pmx_global_settings'], '</h3>
					</div>
				</td>
			</tr>
			<tr>
				<td>
					<div class="information" style="margin-bottom:0;">
					<table class="pmx_table">
						<tr>
							<td style="padding:10px 5px 0 5px;width:50%;text-align:right;">
								<div style="min-height:20px;">' . $txt['pmx_settings_ecl'] . '
									<img class="info_toggle" onclick="Show_help(\'pmxelc\', \'left\')" src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div id="pmxelc" class="info_frame">' . $txt['pmx_settings_eclhelp'] . '</div>
							</td>
							<td style="padding:10px 5px 0 5px;width:50%;">
								<div style="min-height:20px;margin-left:-4px;">
									<input type="hidden" name="pmx_ecl" value="0" />
									<input onchange="eclcheckmodal(this)" style="float:left;" class="input_check" type="checkbox" name="pmx_ecl" value="1"' . (!empty($context['pmx']['pmx_ecl']) ? ' checked="checked"' : '') . ' />
								</div>
							</td>
						</tr>
						<tr id="eclmodal" style="display:' . (!empty($context['pmx']['pmx_ecl']) ? '' : 'none;') . '">
							<td style="padding:5px 5px 0 5px;width:50%;text-align:right;">
								<div style="min-height:20px;">' . $txt['pmx_settings_eclmodal'] . '
									<img class="info_toggle" onclick="Show_help(\'pmxelcmodal\', \'left\')" src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div id="pmxelcmodal" class="info_frame">' . $txt['pmx_settings_eclhelpmodal'] . '</div>
							</td>
							<td style="padding:5px 5px 0 5px;width:50%;">
								<div style="min-height:20px;margin-left:-4px;">
									<input type="hidden" name="pmx_eclmodal" value="0" />
									<input onchange="eclcheckmodalmob(this)" style="float:left;" class="input_check" type="checkbox" name="pmx_eclmodal" value="1"' . (!empty($context['pmx']['pmx_eclmodal']) ? ' checked="checked"' : '') . ' />
								</div>
							</td>
						</tr>
						<tr id="eclmodalmobi" style="display:' . (!empty($context['pmx']['pmx_ecl']) && !empty($context['pmx']['pmx_eclmodal']) ? '' : 'none;') . '">
							<td style="padding:5px 5px 0 5px;width:50%;text-align:right;">
								<div style="min-height:20px;">' . $txt['pmx_settings_eclmodalmobi'] . '
									<img class="info_toggle" onclick="Show_help(\'pmxelcmodalmobihelp\', \'left\')" src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div id="pmxelcmodalmobihelp" class="info_frame">' . $txt['pmx_settings_eclmodalmobihelp'] . '</div>
							</td>
							<td style="padding:5px 5px 0 5px;width:50%;">
								<div style="min-height:20px;margin-left:-4px;">
									<input type="hidden" name="pmx_eclmodalmobi" value="0" />
									<input style="float:left;" class="input_check" type="checkbox" name="pmx_eclmodalmobi" value="1"' . (!empty($context['pmx']['pmx_eclmodalmobi']) ? ' checked="checked"' : '') . ' />
								</div>
							</td>
						</tr>
						<tr id="eclmodalact" style="display:' . (!empty($context['pmx']['pmx_ecl']) && !empty($context['pmx']['pmx_eclmodal']) ? '' : 'none;') . '">
							<td style="padding:5px 5px 0 5px;width:50%;text-align:right;">
								<div style="min-height:20px;">' . $txt['pmx_settings_eclmodalaction'] . '
									<img class="info_toggle" onclick="Show_help(\'pmxelcmodalactionhelp\', \'left\')" src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div id="pmxelcmodalactionhelp" class="info_frame">' . $txt['pmx_settings_eclmodalactionhelp'] . '</div>
							</td>
							<td style="padding:5px 5px 0 5px;width:50%;">
								<div style="min-height:20px;margin-left:-4px;">
									<textarea class="adm_textarea adm_w80" rows="1" cols="35" style="min-height:10px;max-height:60px;" name="pmx_eclmodalaction">' . (isset($context['pmx']['pmx_eclmodalaction']) ? $context['pmx']['pmx_eclmodalaction'] : 'calendar,mlist,search,search2,stats,who') . '</textarea>
								</div>
							</td>
						</tr>
						<tr id="eclmodaltop" style="display:' . (!empty($context['pmx']['pmx_ecl']) ? '' : 'none;') . '">
							<td style="padding:5px 5px 0 5px;width:50%;text-align:right;">
								<div style="min-height:20px;">' . $txt['pmx_settings_eclmodaltop'] . '
									<img class="info_toggle" onclick="Show_help(\'pmxelcmodaltophlp\', \'left\')" src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div id="pmxelcmodaltophlp" class="info_frame">' . $txt['pmx_settings_eclhelpmodaltop'] . '</div>
							</td>
							<td style="padding:5px 5px 0 5px;width:50%;">
								<div style="min-height:20px;margin-left:-4px;">
									<input type="hidden" name="eclmodaltop" value="3" />
									<input style="float:left;" type="text" size="2" name="pmx_eclmodaltop" value="' . (!empty($context['pmx']['pmx_eclmodaltop']) ? $context['pmx']['pmx_eclmodaltop'] : '32') . '" />&nbsp;' . $txt['pmx_pixel'] . '
								</div>
								<script type="text/javascript">
									function eclcheckmodal(elm) {
										document.getElementById("eclmodal").style.display = (elm.checked == true ? "" : "none");
										document.getElementById("eclmodaltop").style.display = (elm.checked == true ? "" : "none");
										document.getElementById("eclmodalmobi").style.display = (elm.checked == true ? "" : "none");
										document.getElementById("eclmodalact").style.display = (elm.checked == true ? "" : "none"); }
									function eclcheckmodalmob(elm) {
										document.getElementById("eclmodalmobi").style.display = (elm.checked == true ? "" : "none");
										document.getElementById("eclmodalact").style.display = (elm.checked == true ? "" : "none"); }
								</script>
							</td>
						</tr>
						<tr>
							<td style="padding:10px 5px 0 5px;width:50%;text-align:right;">
								<div style="min-height:25px;">' . $txt['pmx_settings_disableHS'] . '</div>
								<div style="min-height:25px;">' . $txt['pmx_settings_noHS_onfrontpage'] . '</div>
								<div style="min-height:25px;">' . $txt['pmx_settings_noHS_onattach'] . '</div>
								<div style="min-height:25px;">' . $txt['pmx_settings_noHS_onpost'] . '
									<img class="info_toggle" onclick="Show_help(\'pmxHS22\', \'left\')" src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div id="pmxHS22" class="info_frame">' . $txt['pmx_settings_noHS_onpostshelp'] . '</div>
								<div>' . $txt['pmx_settings_noHS_onaction'] . '
									<img class="info_toggle" onclick="Show_help(\'pmxH22\', \'left\')" src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div id="pmxH22" class="info_frame">' . $txt['pmx_settings_noHS_onactionhelp'] . '</div>
							</td>
							<td style="margin-left:1px; padding:10px 5px 0 5px;width:50%;">
								<div style="min-height:25px;margin-left:-4px;">
									<input type="hidden" name="disableHS" value="0" />
									<input style="float:left;" class="input_check" type="checkbox" name="disableHS" value="1"' . (!empty($admset['disableHS']) ? 'checked="checked"' : '') . ' />
								</div>
								<div style="min-height:25px;margin-left:-4px;">
									<input type="hidden" name="disableHSonfront" value="0" />
									<input style="float:left;" class="input_check" type="checkbox" name="disableHSonfront" value="1"' . (!empty($admset['disableHSonfront']) ? 'checked="checked"' : '') . ' />
								</div>
								<div style="min-height:25px;margin-left:-4px;">
									<input type="hidden" name="disableHSonattach" value="0" />
									<input style="float:left;" class="input_check" type="checkbox" name="disableHSonattach" value="1"' . (!empty($admset['disableHSonattach']) ? 'checked="checked"' : '') . ' />
								</div>
								<div style="min-height:25px;margin-left:-4px;">
									<input type="hidden" name="disableHSonpost" value="0" />
									<input style="float:left;" class="input_check" type="checkbox" name="disableHSonpost" value="1"' . (!empty($admset['disableHSonpost']) ? 'checked="checked"' : '') . ' />
								</div>
								<div style="min-height:25px;">
									<input class="adm_w80" type="text" name="noHS_onaction" value="' . (!empty($admset['noHS_onaction']) ? $admset['noHS_onaction'] : '') . '" />
								</div>
							</td>
						</tr>
						<tr>
							<td style="padding:10px 5px 0 5px;width:50%;text-align:right;">
								<div>' . $txt['pmx_settings_download'] . '
									<img class="info_toggle" onclick="Show_help(\'pmxH01\', \'left\')" src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div id="pmxH01" class="info_frame">' . $txt['pmx_settings_downloadhelp'] . '</div>
							</td>
							<td style="padding:10px 5px 0 5px;width:50%;">
								<div style="margin-left:-4px;">
									<input type="hidden" name="download" value="0" />
									<input onchange="chk_dlbutton(this)" style="float:left;" class="input_check" type="checkbox" name="download" value="1"' . (!empty($admset['download']) ? ' checked="checked"' : '') . ' />
								</div>
							</td>
						</tr>
						<tr id="dlbutchk1" style="display:' . (!empty($admset['download']) ? '' : 'none;') . '">
							<td style="padding:5px 5px 0 5px;width:50%;text-align:right;">
								<div>' . $txt['pmx_settings_download_action'] . '
									<img class="info_toggle" onclick="Show_help(\'pmxH20\', \'left\')" src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div id="pmxH20" class="info_frame">' . $txt['pmx_settings_dl_actionhelp'] . '</div>
							</td>
							<td style="padding:5px 5px 0 5px;width:50%;">
								<div style="min-height:25px;">
									<input class="adm_w80" type="text" name="dl_action" value="' . (!empty($admset['dl_action']) ? $admset['dl_action'] : '') . '" />
								</div>
							</td>
						</tr>
						<tr id="dlbutchk2" style="display:' . (!empty($admset['download']) ? '' : 'none;') . '">
							<td style="padding:5px;width:50%;text-align:right;">
								<div>' . $txt['pmx_settings_download_acs'] . '</div>
							</td>
							<td style="padding:10px 5px 0 5px;width:50%;">
								<select style="width:50%;" name="dl_access[]" size="5" multiple="multiple">';
        $dlaccess = !empty($admset['dl_access']) ? explode(',', $admset['dl_access']) : array();
        foreach ($context['pmx']['acsgroups'] as $group) {
            if ($group['id'] != 1) {
                echo '
									<option value="' . $group['id'] . '=1"' . (in_array($group['id'] . '=1', $dlaccess) ? ' selected="selected"' : '') . '>' . $group['name'] . '</option>';
            }
        }
        echo '
								</select>
								<script type="text/javascript">
									function chk_dlbutton(elm) {
										document.getElementById("dlbutchk1").style.display = (elm.checked == true ? "" : "none");
										document.getElementById("dlbutchk2").style.display = (elm.checked == true ? "" : "none");
									}
								</script>
							</td>
						</tr>
						<tr>
							<td style="padding:10px 5px 0 5px;width:50%;text-align:right;">
								<div>' . $txt['pmx_settings_other_actions'] . '
									<img class="info_toggle" onclick="Show_help(\'pmxH201\', \'left\')" src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div id="pmxH201" class="info_frame">' . $txt['pmx_settings_other_actionshelp'] . '</div>
							</td>
							<td style="padding:10px 5px 0 5px;width:50%;">
								<div style="min-height:25px;">
									<input class="adm_w80" type="text" name="other_actions" value="' . (!empty($admset['other_actions']) ? $admset['other_actions'] : '') . '" />
								</div>
							</td>
						</tr>
						<tr>
							<td style="padding:10px 5px 0 5px;width:50%;text-align:right;">
								<div style="min-height:25px;">' . $txt['pmx_settings_panelpadding'] . '
									<img class="info_toggle" onclick="Show_help(\'pmxHpenp\', \'left\')" src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div id="pmxHpenp" class="info_frame">' . $txt['pmx_settings_panelpadding_help'] . '</div>
							</td>
							<td style="padding:10px 5px 0 5px;width:50%;">
								<div style="min-height:25px;">
									<input onkeyup="check_numeric(this);" type="text" size="2" name="panelpad" value="' . (isset($admset['panelpad']) ? $admset['panelpad'] : '4') . '" />&nbsp;' . $txt['pmx_pixel'] . '
								</div>
							</td>
						</tr>
						<tr>
							<td style="padding:10px 5px 0 5px;width:50%;text-align:right;">
								<div>' . $txt['pmx_settings_restoretop'] . '
									<img class="info_toggle" onclick="Show_help(\'pmxHrst\', \'left\')" src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div id="pmxHrst" class="info_frame">' . $txt['pmx_settings_restoretop_help'] . '</div>
							</td>
							<td style="padding:10px 5px 0 5px;width:50%;">
								<div style="margin-left:-4px;">
									<input type="hidden" name="topfragment" value="0" />
									<input type="hidden" name="restoretop" value="0" />
									<input class="input_check" type="checkbox" name="restoretop" value="1"' . (!empty($admset['restoretop']) ? ' checked="checked"' : '') . ' />
								</div>
							</td>
						</tr>
						<tr>
							<td style="padding:10px 5px 0 5px;width:50%;text-align:right;">
								<div>' . $txt['pmx_settings_quickreply'] . '
									<img class="info_toggle" onclick="Show_help(\'pmxHqrv\', \'left\')" src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div id="pmxHqrv" class="info_frame">' . $txt['pmx_settings_quickreplyhelp'] . '</div>
							</td>
							<td style="padding:10px 5px 0 5px;width:50%;">
								<div style="margin-left:-4px;">
									<input type="hidden" name="pmx_quickreply" value="0" />
									<input style="float:left;" class="input_check" type="checkbox" name="pmx_quickreply" value="1"' . (!empty($admset['pmx_quickreply']) ? ' checked="checked"' : '') . ' />
								</div>
							</td>
						</tr>
						<tr>
							<td style="padding:15px 5px 0 5px;width:50%;text-align:right;">
								<div>' . $txt['pmx_settings_teasermode'][0] . '
									<img class="info_toggle" onclick="Show_help(\'pmxteasecnt\', \'left\')" src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div id="pmxteasecnt" class="info_frame">' . $txt['pmx_settings_pmxteasecnthelp'] . '</div>
							</td>
							<td style="padding:15px 5px 0 5px;width:50%;">
								<div style="min-height:25px; float:left; margin-left:-4px;">
									<input type="hidden" name="teasermode" value="0" />
									<div><input class="input_check" type="radio" name="teasermode" value="0"' . (empty($admset['teasermode']) ? ' checked="checked"' : '') . ' />&nbsp;' . $txt['pmx_settings_teasermode'][1] . '</div>
									<div><input class="input_check" type="radio" name="teasermode" value="1"' . (!empty($admset['teasermode']) ? ' checked="checked"' : '') . ' />&nbsp;' . $txt['pmx_settings_teasermode'][2] . '</div>
								</div>
							</td>
						</tr>
						<tr>
							<td style="padding:15px 5px 0 5px;width:50%;text-align:right;">
								<input type="hidden" name="shrinkimages" value="1" />
								<div>' . $txt['pmx_settings_hidecopyright'] . '
									<img class="info_toggle" onclick="Show_help(\'pmxH24c\', \'left\')" src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div id="pmxH24c" class="info_frame">' . $txt['pmx_settings_hidecopyrighthelp'] . '</div>
							</td>
							<td style="padding:15px 5px 0 5px;width:50%;">
								<div style="min-height:25px;">
									<input class="adm_w80" type="text" name="unlock" value="' . (!empty($admset['unlock']) ? $admset['unlock'] : '') . '" />
									' . (!empty($admset['unlock']) ? '<div class="smalltext"><b><i>' . $context['pmx']['sysstat'] . '</i></b></div>' : '') . '
								</div>
								<input type="hidden" name="cachestats" value="0" />
							</td>
						</tr>';
        if (!empty($PortaMx_cache['vals']['mode'])) {
            echo '
						<tr>
							<td style="padding:5px 5px 0 5px;width:50%;text-align:right;">
								<div>' . $txt['pmx_settings_blockcachestats'] . '
									<img class="info_toggle" onclick="Show_help(\'pmxH24a\', \'left\')" src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div id="pmxH24a" class="info_frame">' . $txt['pmx_settings_blockcachestatshelp'] . '</div>
							</td>
							<td style="padding:5px 5px 0 5px;width:50%;">
								<div style="margin-left:-4px;">
									<input type="hidden" name="cachestats" value="0" />
									<input style="float:left;" class="input_check" type="checkbox" name="cachestats" value="1"' . (!empty($admset['cachestats']) ? ' checked="checked"' : '') . ' />
									<span style="padding-left:5px;vertical-align:-1px">' . $txt['pmx_settings_blockcachedetect'] . ' <b>' . $txt['cachemode'][$PortaMx_cache['vals']['mode']] . '</b></span>
								</div>
							</td>
						</tr>';
        }
        echo '
						<tr>
							<td style="padding:10px 5px 0 5px;width:50%;text-align:right;">
								<div>' . $txt['pmx_settings_postcountacs'] . '
									<img class="info_toggle" onclick="Show_help(\'pmxH25\', \'left\')" src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div id="pmxH25" class="info_frame">' . $txt['pmx_settings_postcountacshelp'] . '</div>
							</td>
							<td style="padding:10px 5px 0 5px;width:50%;">
								<div style="margin-left:-4px;">
									<input type="hidden" name="postcountacs" value="0" />
									<input style="float:left;" class="input_check" type="checkbox" name="postcountacs" value="1"' . (!empty($admset['postcountacs']) ? ' checked="checked"' : '') . ' />
								</div>
							</td>
						</tr>
						<tr>
							<td style="padding:10px 5px 0 5px;width:50%;text-align:right;">
								<div>' . $txt['pmx_settings_enable_xbarkeys'] . '
									<img class="info_toggle" onclick="Show_help(\'pmxH02\', \'left\')" src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div id="pmxH02" class="info_frame">' . $txt['pmx_settings_xbarkeys_help'] . '</div>
							</td>
							<td style="padding:10px 5px 0 5px;width:50%;">
								<div style="margin-left:-4px;">
									<input type="hidden" name="xbarkeys" value="0" />
									<input style="float:left;" class="input_check" type="checkbox" name="xbarkeys" value="1"' . (!empty($admset['xbarkeys']) ? ' checked="checked"' : '') . ' />
								</div>
							</td>
						</tr>
						<tr>
							<td style="padding:5px 5px 0 5px;width:50%;text-align:right;">
								<div>' . $txt['pmx_settings_enable_xbars'] . '
									<img class="info_toggle" onclick="Show_help(\'pmxH03\', \'left\')" src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div id="pmxH03" class="info_frame">' . $txt['pmx_settings_xbars_help'] . '</div>
							</td>
							<td style="padding:5px 5px 0 5px;width:50%;">
								<div style="height:25px;">
									<img id="pmxTXB" class="adm_hover" onclick="ToggleCheckbox(this, \'xsel\', 0)" width="13" height="13" style="float:left;margin-top:5px;" src="' . $context['pmx_syscssurl'] . 'Images/bullet_plus.gif" alt="*" title="' . $txt['pmx_settings_all_toggle'] . '" />
								</div>
								<input type="hidden" name="xbars[]" value="" />';
        foreach ($txt['pmx_block_sides'] as $side => $sidename) {
            if ($side != 'front' && $side != 'pages') {
                echo '
								<div class="adm_clear" style="height:25px;margin-left:-4px;">
									<input id="xsel' . $side . '" class="input_check" type="checkbox" name="xbars[]" value="' . $side . '"' . (isset($admset['xbars']) && in_array($side, $admset['xbars']) ? ' checked="checked"' : '') . ' />&nbsp;<span style="vertical-align:2px;">' . $sidename . '</span>
								</div>';
            }
        }
        echo '
								<script type="text/javascript">
									ToggleCheckbox(document.getElementById("pmxTXB"), \'xsel\', 1)
								</script>
							</td>
						</tr>
						<tr>
							<td style="padding:15px 5px 0 5px;width:50%;text-align:right;">
								<div style="min-height:25px;">' . $txt['pmx_settings_xbar_topoffset'] . '</div>
							</td>
							<td style="padding:15px 5px 0 5px;width:50%;">
								<div style="min-height:25px;">
									<input onkeyup="check_numeric(this);" type="text" size="2" name="xbaroffset_top" value="' . (isset($admset['xbaroffset_top']) ? $admset['xbaroffset_top'] : '40') . '" />&nbsp;' . $txt['pmx_pixel'] . '
								</div>
							</td>
						</tr>
						<tr>
							<td style="padding:5px 5px 0 5px;width:50%;text-align:right;">
								<div style="min-height:25px;">' . $txt['pmx_settings_xbar_botoffset'] . '</div>
							</td>
							<td style="padding:5px 5px 0 5px;width:50%;">
								<div style="min-height:25px;">
									<input onkeyup="check_numeric(this);" type="text" size="2" name="xbaroffset_foot" value="' . (isset($admset['xbaroffset_foot']) ? $admset['xbaroffset_foot'] : '5') . '" />&nbsp;' . $txt['pmx_pixel'] . '
								</div>
							</td>
						</tr>
					</table>
					<hr />
					<p style="text-align:center; margin-top:10px;"><input class="button_submit" style="float:none;" type="button" value="' . $txt['pmx_save'] . '" onclick="FormFunc(\'save_settings\', \'yes\')" /></p>
					</div>
				</td>
			</tr>
		</table>';
    }
    if ($context['pmx']['subaction'] == 'control') {
        // Blockmanager control settings
        echo '
		<table class="pmx_table pmx_fixedtable" style="margin-bottom:5px;">
			<tr>
				<td style="text-align:center">
					<div class="cat_bar">
						<h3 class="catbg">' . $txt['pmx_global_program'] . '</h3>
					</div>
				</td>
			</tr>
			<tr>
				<td>
					<div class="information" style="margin-bottom:0;">
					<table class="pmx_table">
						<tr>
							<td style="padding:10px 5px 0 5px;width:50%;text-align:right;">
								<div style="min-height:25px;">' . $txt['pmx_settings_collapse_visibility'] . '
									<img class="info_toggle" onclick=\'Show_help("pmxH05")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div id="pmxH05" class="info_frame" style="text-align:left;">' . $txt['pmx_settings_collapse_vishelp'] . '</div>
							</td>
							<td style="padding:10px 5px 0 5px;width:50%;">
								<div style="margin-left:-4px;">
									<input type="hidden" name="manager[collape_visibility]" value="0" />
									<input style="float:left;" class="input_check" type="checkbox" name="manager[collape_visibility]" value="1"' . (!empty($admset['manager']['collape_visibility']) ? ' checked="checked"' : '') . ' />
								</div>
							</td>
						</tr>
						<tr>
							<td style="padding:1px 5px;width:50%;text-align:right;">
								<input type="hidden" name="manager[follow]" value="0" />
								<div style="min-height:25px;">' . str_replace('[##]', '<img style="vertical-align:-3px;" src="' . $context['pmx_imageurl'] . 'page_edit.gif" alt="*" title="" />', $txt['pmx_settings_quickedit']) . '
									<img class="info_toggle" onclick=\'Show_help("pmxH07")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
									<div id="pmxH07" class="info_frame" style="text-align:left;">' . $txt['pmx_settings_quickedithelp'] . '</div>
							</td>
							<td style="padding:1px 5px;width:50%;">
								<div style="margin-left:-4px;">
									<input type="hidden" name="manager[qedit]" value="0" />
									<input style="float:left;" class="input_check" type="checkbox" name="manager[qedit]" value="1"' . (!empty($admset['manager']['qedit']) ? ' checked="checked"' : '') . ' />
								</div>
							</td>
						</tr>

						<tr>
							<td style="padding:1px 5px;width:50%;text-align:right;">
								<div style="min-height:25px;">' . $txt['pmx_settings_enable_promote'] . '
									<img class="info_toggle" onclick=\'Show_help("pmxH1promo")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div id="pmxH1promo" class="info_frame" style="text-align:left;">' . $txt['pmx_settings_enable_promote_help'] . '</div>
							</td>
							<td style="padding:1px 5px;width:50%;">
								<div style="margin-left:-4px;">
									<input type="hidden" name="manager[promote]" value="0" />
									<input style="float:left;" class="input_check" type="checkbox" name="manager[promote]" value="1"' . (!empty($admset['manager']['promote']) ? ' checked="checked"' : '') . ' />
								</div>
							</td>
						</tr>
						<tr>
							<td style="padding:2px 5px; width:50%; text-align:right;">
								<div>' . $txt['pmx_settings_promote_messages'] . '
									<img class="info_toggle" onclick="Show_help(\'pmxH2promo\', \'left\')" src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div id="pmxH2promo" class="info_frame" style="text-align:left;">' . $txt['pmx_settings_promote_messages_help'] . '</div>
							</td>
							<td style="padding:2px 5px; width:50%;">
								<div style="min-height:25px;">
									<textarea class="adm_textarea adm_w80" rows="1" cols="35" style="min-height:10px;max-height:150px;" name="promotes">' . implode(',', $context['pmx']['promotes']) . '</textarea>
								</div>
							</td>
						</tr>

						<tr>
							<td style="padding:1px 5px;width:50%;text-align:right;">
								<div style="min-height:25px;">', $txt['pmx_settings_article_on_page'] . '
									<img class="info_toggle" onclick=\'Show_help("pmxH10")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div id="pmxH10" class="info_frame" style="text-align:left;">' . $txt['pmx_settings_article_on_pagehelp'] . '</div>
							</td>
							<td style="padding:1px 5px;width:50%;">
								<div>
									<input style="float:left;" type="text" name="manager[artpage]" size="3" value="' . (!empty($admset['manager']['artpage']) ? $admset['manager']['artpage'] : '25') . '" />
								</div>
							</td>
						</tr>
						<tr>
							<td style="padding:1px 5px;width:50%;text-align:right;">
								<div style="height:25px;">' . $txt['pmx_settings_adminpages'] . '
									<img class="info_toggle" onclick=\'Show_help("pmxH09")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div id="pmxH09" class="info_frame" style="text-align:left;">' . $txt['pmx_settings_adminpageshelp'] . '</div>
							</td>
							<td style="padding:1px 5px;width:50%;text-align:right;">
								<div style="height:25px;">
									<img id="pmxTMP" class="adm_hover" onclick="ToggleCheckbox(this, \'modsel\', 0)" width="13" height="13" style="float:left;margin-top:4px;" src="' . $context['pmx_syscssurl'] . 'Images/bullet_plus.gif" alt="*" title="' . $txt['pmx_settings_all_toggle'] . '" />
								</div>
							</td>
						</tr>
						<tr>
							<td style="padding:1px 5px;width:50%;text-align:right;">';
        foreach ($txt['pmx_block_sides'] as $side => $sidename) {
            echo '
								<div style="height:25px;">' . $sidename . ':</div>';
        }
        echo '
							</td>
							<td>';
        foreach ($txt['pmx_block_sides'] as $side => $sidename) {
            echo '
								<div class="adm_clear" style="height:25px;margin-left:-4px;">
									<input style="margin-left:10px;" id="modsel' . $side . '" class="input_check" type="checkbox" name="manager[admin_pages][]" value="' . $side . '"' . (isset($admset['manager']['admin_pages']) && in_array($side, $admset['manager']['admin_pages']) ? ' checked="checked"' : '') . ' />
								</div>';
        }
        echo '
									<script type="text/javascript">
									ToggleCheckbox(document.getElementById("pmxTMP"), \'modsel\', 1)
								</script>
							</td>
						</tr>
					</table>
					<hr />
					<p style="text-align:center;margin-top:10px;"><input class="button_submit" style="float:none;" type="button" value="' . $txt['pmx_save'] . '" onclick="FormFunc(\'save_settings\', \'yes\')" /></p>
					</div>
				</td>
			</tr>
		</table>';
    }
    if ($context['pmx']['subaction'] == 'panels') {
        // Global panel settings
        echo '
		<table class="pmx_table pmx_fixedtable" style="margin-bottom:5px;">
			<tr>
				<td style="text-align:center">
					<div class="cat_bar round">
						<h3 class="catbg round">' . $txt['pmx_panel_settings'] . '</h3>
					</div>
				</td>
			</tr>
			<tr>
				<td>';
        echo '
					<div class="adm_submenus" style="margin-bottom:6px;margin-top:-4px;overflow:hidden;">
						<ul class="dropmenu">';
        $ActPanel = isset($_REQUEST['pn']) ? $_REQUEST['pn'] : 'head';
        foreach ($txt['pmx_block_sides'] as $side => $sidename) {
            if ($side != 'front' && $side != 'pages') {
                echo '
							<li>
								<a class="firstlevel' . ($side == $ActPanel ? ' active' : '') . '" href="' . $scripturl . '?action=' . $context['pmx']['AdminMode'] . ';area=pmx_settings;sa=panels;pn=' . $side . ';' . $context['session_var'] . '=' . $context['session_id'] . '">
									<span class="firstlevel">' . $txt['pmx_settings_panel' . $side] . '</span>
								</a>
							</li>';
            }
        }
        echo '
						</ul>
					</div>
					<input type="hidden" name="curPanel" value="' . $ActPanel . '" />
				</td>
			</tr>
			<tr>
				<td>
					<div class="cat_bar catbg_grid">
						<h4 class="catbg catbg_grid">
							<span class="normaltext cat_msg_title">' . $txt['pmx_settings_panel' . $ActPanel] . '</span>
						</h4>
					</div>

					<div class="information" style="margin-bottom:0;">
					<table class="pmx_table" style="padding:0 5px;">
						<tr>
							<td style="padding:5px; width:50%; text-align:right;">
								<div style="float:left; padding-left:2px; padding-top:4px;">
									<img src="' . $context['pmx_imageurl'] . $ActPanel . '_panel.gif" alt="*" title="' . $txt['pmx_settings_panel' . $ActPanel] . '" />
								</div>
								<div style="min-height:25px;">' . $txt['pmx_settings_panel_collapse'] . '</div>
								<div style="min-height:60px;">' . $txt['pmx_settings_collapse_state'] . '</div>
								<div style="min-height:25px;padding-top:10px;">' . ($ActPanel == 'left' || $ActPanel == 'right' ? $txt['pmx_settings_panelwidth'] : $txt['pmx_settings_panelheight']) . '</div>';
        if (in_array($ActPanel, array('head', 'top', 'bottom', 'foot'))) {
            echo '
								<div style="min-height:25px;padding-top:7px;">' . $txt['pmx_settings_paneloverflow'] . '</div>';
        }
        echo '
								<div style="padding-top:7px;">
									' . $txt['pmx_settings_panelhidetitle'] . '&nbsp;<img class="info_toggle" style="text-align:right;padding-top:2px;" onclick="Show_help(\'pmxH_' . $ActPanel . '\', \'left\')" src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div id="pmxH_' . $ActPanel . '" class="info_frame">' . $txt['pmx_settings_hidehelp'] . '</div>
							</td>
							<td style="padding:5px; width:50%;">
								<input type="hidden" name="' . $ActPanel . '_panel[size]" value="0" />
								<input type="hidden" name="' . $ActPanel . '_panel[collapse]" value="0" />
								<div style="min-height:25px; margin-left:-4px;">
									<input class="input_check" type="checkbox" name="' . $ActPanel . '_panel[collapse]" value="1"' . (!empty($admset[$ActPanel . '_panel']['collapse']) ? ' checked="checked"' : '') . ' />
								</div>
								<div style="min-height:60px; margin-left:-5px;">';
        if (!isset($admset[$ActPanel . '_panel']['collapse_init'])) {
            $admset[$ActPanel . '_panel']['collapse_init'] = 0;
        }
        foreach ($txt['pmx_settings_collapse_mode'] as $key => $text) {
            echo '
									<div><input class="input_radio" type="radio" name="' . $ActPanel . '_panel[collapse_init]" value="' . $key . '"' . (isset($admset[$ActPanel . '_panel']['collapse_init']) && $admset[$ActPanel . '_panel']['collapse_init'] == $key ? ' checked="checked"' : '') . ' style="vertical-align:-3px;" /> ' . $text . '</div>';
        }
        echo '
								</div>
								<div style="min-height:25px;padding-top:10px;">
									<input id="pmx_size_' . $ActPanel . '" onkeyup="check_numeric(this);" type="text" size="3" name="' . $ActPanel . '_panel[size]" value="' . (!empty($admset[$ActPanel . '_panel']['size']) ? $admset[$ActPanel . '_panel']['size'] : '') . '" /> ' . $txt['pmx_hw_pixel'][$ActPanel] . '
								</div>';
        if (in_array($ActPanel, array('head', 'top', 'bottom', 'foot'))) {
            echo '
								<div style="min-height:25px;padding-top:7px;">
									<select id="pmx_chksize' . $ActPanel . '" class="adm_w60" size="1" name="' . $ActPanel . '_panel[overflow]" onchange="checkSizeInput(this, \'' . $ActPanel . '\')">';
            foreach ($txt['pmx_overflow_actions'] as $key => $text) {
                echo '
										<option value="' . $key . '"' . (isset($admset[$ActPanel . '_panel']['overflow']) && $admset[$ActPanel . '_panel']['overflow'] == $key ? ' selected="selected"' : '') . '>' . $text . '</option>';
            }
            echo '
									</select>
								</div>
								<script type="text/javascript">
									checkSizeInput(document.getElementById("pmx_chksize' . $ActPanel . '"), \'' . $ActPanel . '\');
								</script>';
        }
        echo '
								<div style="min-height:25px;padding-top:7px;">
									<select id="pmxact_' . $ActPanel . '" onchange="changed(\'pmxact_' . $ActPanel . '\');" class="adm_w60" name="' . $ActPanel . '_panel[hide][]" multiple="multiple" size="5">';
        $data = array();
        if (!empty($admset[$ActPanel . '_panel']['hide'])) {
            $hidevals = is_array($admset[$ActPanel . '_panel']['hide']) ? $admset[$ActPanel . '_panel']['hide'] : array($admset[$ActPanel . '_panel']['hide']);
            foreach ($hidevals as $val) {
                $tmp = Pmx_StrToArray($val, '=');
                if (isset($tmp[0]) && isset($tmp[1])) {
                    $data[$tmp[0]] = $tmp[1];
                }
            }
        }
        foreach ($txt['pmx_action_names'] as $act => $actdesc) {
            echo '
										<option value="' . $act . '=' . (array_key_exists($act, $data) ? $data[$act] . '" selected="selected' : '1') . '">' . (array_key_exists($act, $data) ? $data[$act] == 0 ? '^' : '' : '') . $actdesc . '</option>';
        }
        echo '
									</select>
								</div>
								<script type="text/javascript">
									var pmxact_' . $ActPanel . ' = new MultiSelect("pmxact_' . $ActPanel . '");
								</script>';
        $cust = isset($admset[$ActPanel . '_panel']['custom_hide']) ? $admset[$ActPanel . '_panel']['custom_hide'] : '';
        echo '
							</td>
						</tr>
						<tr>
							<td style="padding:2px 5px; width:50%; text-align:right;">
								<div>' . $txt['pmx_settings_panel_customhide'] . '
									<img class="info_toggle" onclick="Show_help(\'pmxH' . $ActPanel . '\', \'left\')" src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div id="pmxH' . $ActPanel . '" class="info_frame">' . $txt['pmx_settings_panel_custhelp'] . '</div>
							</td>
							<td style="padding:2px 5px; width:50%;">
								<div style="min-height:25px;">
									<textarea class="adm_textarea adm_w60" rows="2" cols="35" name="' . $ActPanel . '_panel[custom_hide]" style="min-height:10px; max-height:100px;">' . $cust . '</textarea>
								</div>
							</td>
						</tr>

						<tr>
							<td style="padding:2px 5px; width:50%; text-align:right;">
								<div style="min-height:25px;padding-top:4px;">' . $txt['pmx_settings_devices'] . '
									&nbsp;<img class="info_toggle" style="text-align:right;padding-top:2px;" onclick="Show_help(\'pmxDH_' . $ActPanel . '\', \'left\')" src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div id="pmxDH_' . $ActPanel . '" class="info_frame">' . $txt['pmx_settings_deviceshelp'] . '</div>
							</td>
							<td style="padding:5px; width:50%;">
								<input type="hidden" name="' . $ActPanel . '_panel[device]" value="0" />
								<div style="min-height:60px; margin-left:-5px;">
									<div style="width:95%;"><input class="input_radio" type="radio" name="' . $ActPanel . '_panel[device]" value="0"' . (empty($admset[$ActPanel . '_panel']['device']) ? ' checked="checked"' : '') . ' style="vertical-align:-3px;" /> ' . $txt['pmx_devices']['all'] . '</div>
									<div style="width:95%;"><input class="input_radio" type="radio" name="' . $ActPanel . '_panel[device]" value="1"' . (!empty($admset[$ActPanel . '_panel']['device']) && $admset[$ActPanel . '_panel']['device'] == '1' ? ' checked="checked"' : '') . ' style="vertical-align:-3px;" /> ' . $txt['pmx_devices']['mobil'] . '</div>
									<div style="width:95%;"><input class="input_radio" type="radio" name="' . $ActPanel . '_panel[device]" value="2"' . (!empty($admset[$ActPanel . '_panel']['device']) && $admset[$ActPanel . '_panel']['device'] == '2' ? ' checked="checked"' : '') . ' style="vertical-align:-3px;" /> ' . $txt['pmx_devices']['desk'] . '</div>
								</div>
							</td>
						</tr>

						<tr>
							<td colspan="2">
								<hr class="pmx_hr" />
								<div style="margin:0 auto;padding:8px;text-align:center;">
									<input class="button_submit" style="float:none;" type="button" value="' . $txt['pmx_save'] . '" onclick="FormFunc(\'save_settings\', \'yes\')" />
								</div>
							</td>
						</tr>
					</table>
					</div>
				</td>
			</tr>
		</table>';
    }
    if ($context['pmx']['subaction'] == 'frontpage') {
        // Frontpage settings
        echo '
		<table class="pmx_table pmx_fixedtable" style="margin-bottom:5px;">
			<tr>
				<td style="text-align:center">
					<div class="cat_bar">
						<h3 class="catbg">' . $txt['pmx_frontpage_settings'] . '</h3>
					</div>
				</td>
			</tr>
			<tr>
				<td>
					<div class="information" style="margin-bottom:0;">
					<table class="pmx_table">
						<tr>
							<td style="padding:5px;width:50%;text-align:right">
								<div style="min-height:25px;">' . $txt['pmx_settings_frontpage_fullsize'] . '
									<img class="info_toggle" onclick=\'Show_help("pmxH18")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div style="min-height:25px;">' . $txt['pmx_settings_frontpage_centered'] . '</div>
								<div style="min-height:25px;">' . $txt['pmx_settings_frontpage_none'] . '</div>
								<div style="min-height:25px;padding-top:5px;">' . $txt['pmx_settings_frontpage_menubar'] . '</div>
								<div id="pmxH18" class="info_frame" style="text-align:left;">
									' . $txt['pmx_frontpage_help'] . '
								</div>
							</td>
							<td style="padding:5px;width:50%;">
								<div style="float:left; width:28px;">
									<div style="min-height:25px;margin-left:-4px;">
										<input class="input_radio" type="radio" name="frontpage" value="fullsize"' . (isset($admset['frontpage']) && $admset['frontpage'] == 'fullsize' ? ' checked="checked"' : '') . ' />
									</div>
									<div style="min-height:25px;margin-left:-4px;">
										<input class="input_radio" type="radio" name="frontpage" value="centered"' . (isset($admset['frontpage']) && $admset['frontpage'] == 'centered' ? ' checked="checked"' : '') . ' />
									</div>
									<div style="min-height:25px;margin-left:-4px;">
										<input class="input_radio" type="radio" name="frontpage" value="none"' . (!isset($admset['frontpage']) || isset($admset['frontpage']) && $admset['frontpage'] == 'none' ? ' checked="checked"' : '') . ' />
									</div>
									<div style="min-height:25px; padding-top:5px; margin-left:-4px;">
										<input type="hidden" name="frontpagemenu" value="0" />
										<input class="input_check" type="checkbox" name="frontpagemenu" value="1"' . (!empty($admset['frontpagemenu']) ? ' checked="checked"' : '') . ' />
									</div>
								</div>
							</td>
						</tr>
						<tr>
							<td style="padding:5px;width:50%;text-align:right">
								<div style="min-height:25px;">' . $txt['pmx_settings_index_front'] . '
									<img class="info_toggle" onclick=\'Show_help("pmxH182")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div id="pmxH182" class="info_frame" style="text-align:left;">
									' . $txt['pmx_settings_index_front_help'] . '
								</div>
							</td>
							<td style="padding:5px;width:50%;">
								<div style="float:left; width:28px;">
									<div style="min-height:25px; margin-left:-4px;">
										<input type="hidden" name="indexfront" value="0" />
										<input class="input_check" type="checkbox" name="indexfront" value="1"' . (!empty($admset['indexfront']) ? ' checked="checked"' : '') . ' />
									</div>
								</div>
							</td>
						</tr>
						<tr>
							<td style="padding:5px;width:50%;text-align:right">
								<div>' . $txt['pmx_settings_pages_hidefront'] . '
									<img class="info_toggle" onclick="Show_help(\'pmxH20\')" src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div id="pmxH20" class="info_frame" style="text-align:left">' . $txt['pmx_settings_pages_help'] . '</div>
							</td>
							<td style="padding:5px;width:50%;">
								<div>
									<textarea class="adm_textarea adm_w90" rows="1" cols="50" name="hidefrontonpages" style="min-height:10px; max-height:100px;">' . $admset['hidefrontonpages'] . '</textarea>
								</div>
							</td>
						</tr>
						<tr>
							<td style="padding:15px 5px 0 5px;width:50%;text-align:right;">
								<div style="min-height:25px;">' . $txt['pmx_settings_fronttheme'] . '</div>
								<div style="min-height:25px; padding-top:5px;">' . $txt['pmx_settings_frontthemepages'] . '</div>
							</td>
							<td style="padding:15px 5px 0 5px;width:50%;">
								<div style="min-height:25px;">
									<select style="width:61%;" name="pmx_fronttheme" size="1">
										<option value="0"' . (empty($context['pmx']['pmx_fronttheme']) ? ' selected="selected"' : '') . '>' . $txt['pmx_front_default_theme'] . '</option>';
        foreach ($context['pmx']['admthemes'] as $thid => $data) {
            echo '
										<option value="' . $thid . '"' . (!empty($context['pmx']['pmx_fronttheme']) && $context['pmx']['pmx_fronttheme'] == $thid ? ' selected="selected"' : '') . '>' . $data['name'] . '</option>';
        }
        echo '
									</select>
								</div>
								<div style="min-height:25px; padding-top:5px; margin-left:-4px;">
									<input type="hidden" name="pmx_frontthempg" value="0" />
									<input class="input_check" type="checkbox" name="pmx_frontthempg" value="1"' . (!empty($context['pmx']['pmx_frontthempg']) ? ' checked="checked"' : '') . ' />
								</div>
							</td>
						</tr>
					</table>
					<hr class="pmx_hr" />
					<div style="margin:0 auto;padding:8px;text-align:center;">
						<input class="button_submit" style="float:none;" type="button" value="' . $txt['pmx_save'] . '" onclick="FormFunc(\'save_settings\', \'yes\')" />
					</div>
					</div>
				</td>
			</tr>
		</table>';
    }
    // Access settings
    if ($context['pmx']['subaction'] == 'access') {
        echo '
		<input type="hidden" name="update_access" value="1" />
		<table class="pmx_table pmx_fixedtable" style="margin-bottom:5px;">
			<tr>
				<td style="text-align:center">
					<div class="cat_bar">
						<h3 class="catbg">' . $txt['pmx_access_settings'] . '</h3>
					</div>
				</td>
			</tr>
			<tr>
				<td>
					<div class="information" style="margin-bottom:0;">
					<table class="pmx_table">
						<tr>
							<td style="padding:5px;width:50%;text-align:right">
								<div>' . $txt['pmx_access_promote'] . '
									<img class="info_toggle" onclick="Show_help(\'pmxH50\', \'left\')" src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div id="pmxH50" class="info_frame">' . $txt['pmx_access_promote_help'] . '</div>
							</td>
							<td style="padding:5px;width:50%;">
								<select style="width:61%;" name="setaccess[pmx_promote][]" size="5" multiple="multiple">';
        // 'pmx_articles' - Moderate articles
        foreach ($context['pmx']['limitgroups'] as $group) {
            if ($group['id'] != 1) {
                echo '
									<option value="' . $group['id'] . '"' . (in_array($group['id'], $context['pmx']['permissions']['pmx_promote']) ? ' selected="selected"' : '') . '>' . $group['name'] . '</option>';
            }
        }
        echo '
								</select>
							</td>
						</tr>

						<tr>
							<td style="padding:5px;width:50%;text-align:right">
								<div>' . $txt['pmx_access_articlecreate'] . '
									<img class="info_toggle" onclick="Show_help(\'pmxH30\', \'left\')" src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div id="pmxH30" class="info_frame">' . $txt['pmx_access_articlecreate_help'] . '</div>
							</td>
							<td style="padding:5px;width:50%;">
								<select style="width:61%;" name="setaccess[pmx_create][]" size="5" multiple="multiple">';
        // 'pmx_create' - Create and Write articles
        foreach ($context['pmx']['limitgroups'] as $group) {
            if ($group['id'] != 1) {
                echo '
									<option value="' . $group['id'] . '"' . (in_array($group['id'], $context['pmx']['permissions']['pmx_create']) ? ' selected="selected"' : '') . '>' . $group['name'] . '</option>';
            }
        }
        echo '
								</select>
							</td>
						</tr>

						<tr>
							<td style="padding:5px;width:50%;text-align:right">
								<div>' . $txt['pmx_access_articlemoderator'] . '
									<img class="info_toggle" onclick="Show_help(\'pmxH31\', \'left\')" src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div id="pmxH31" class="info_frame">' . $txt['pmx_access_articlemoderator_help'] . '</div>
							</td>
							<td style="padding:5px;width:50%;">
								<select style="width:61%;" name="setaccess[pmx_articles][]" size="5" multiple="multiple">';
        // 'pmx_articles' - Moderate articles
        foreach ($context['pmx']['limitgroups'] as $group) {
            if ($group['id'] != 1) {
                echo '
									<option value="' . $group['id'] . '"' . (in_array($group['id'], $context['pmx']['permissions']['pmx_articles']) ? ' selected="selected"' : '') . '>' . $group['name'] . '</option>';
            }
        }
        echo '
								</select>
							</td>
						</tr>

						<tr>
							<td style="padding:5px;width:50%;text-align:right">
								<div>' . $txt['pmx_access_blocksmoderator'] . '
									<img class="info_toggle" onclick="Show_help(\'pmxH32\', \'left\')" src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div id="pmxH32" class="info_frame">' . $txt['pmx_access_blocksmoderator_help'] . '</div>
							</td>
							<td style="padding:5px;width:50%;">
								<select style="width:61%;" name="setaccess[pmx_blocks][]" size="5" multiple="multiple">';
        // 'pmx_blocks' - Moderate blocks
        foreach ($context['pmx']['limitgroups'] as $group) {
            if ($group['id'] != 1) {
                echo '
									<option value="' . $group['id'] . '"' . (in_array($group['id'], $context['pmx']['permissions']['pmx_blocks']) ? ' selected="selected"' : '') . '>' . $group['name'] . '</option>';
            }
        }
        echo '
								</select>';
        if (allowedTo('admin_forum')) {
            echo '
							</td>
						</tr>
						<tr>
							<td style="padding:5px;width:50%;text-align:right">
								<div>' . $txt['pmx_access_pmxadmin'] . '
									<img class="info_toggle" onclick="Show_help(\'pmxH33\', \'left\')" src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div id="pmxH33" class="info_frame">' . $txt['pmx_access_pmxadmin_help'] . '</div>
							</td>
							<td style="padding:5px;width:50%;">
								<select style="width:61%;" name="setaccess[pmx_admin][]" size="5" multiple="multiple">';
            // 'pmx_admin' - PortaMx admin
            foreach ($context['pmx']['limitgroups'] as $group) {
                if ($group['id'] != 1) {
                    echo '
									<option value="' . $group['id'] . '"' . (in_array($group['id'], $context['pmx']['permissions']['pmx_admin']) ? ' selected="selected"' : '') . '>' . $group['name'] . '</option>';
                }
            }
            echo '
								</select>
							</td>
						</tr>';
        } else {
            // 'pmx_admin' - PortaMx admin
            foreach ($context['pmx']['limitgroups'] as $group) {
                if (in_array($group['id'], $context['pmx']['permissions']['pmx_admin'])) {
                    echo '
								<input type="hidden" name="setaccess[pmx_admin][]" value="' . $group['id'] . '" />';
                }
            }
            echo '
							</td>
						</tr>';
        }
        echo '
					</table>
					<hr class="pmx_hr" />
					<div style="margin:0 auto;padding:8px;text-align:center;">
						<input class="button_submit" style="float:none;" type="button" value="' . $txt['pmx_save'] . '" onclick="FormFunc(\'save_settings\', \'yes\')" />
					</div>
					</div>
				</td>
			</tr>
		</table>';
    }
    // SEF option settings
    if ($curarea == 'pmx_sefengine') {
        echo '
		<input type="hidden" name="update_pmxsef" value="1" />
		<table class="pmx_table pmx_fixedtable" style="margin-bottom:5px;">
			<tr>
				<td>
					<div class="cat_bar"><h3 class="catbg">' . $txt['pmx_sef_settings'] . '</h3></div>
					<p class="information">' . $txt['pmx_admSet_desc_pmxsef'] . '</p>
				</td>
			</tr>
			<tr>
				<td>
					<div class="roundframe" style="margin-top:0px;">
					<div style="text-align:center;padding:5px 0;">
						' . $txt['pmx_sef_engine'] . '
						<img class="info_toggle" onclick=\'Show_help("pmxH40")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
					</div>
					<div id="pmxH40" style="text-align:left;width:51%; margin:0 auto;" class="info_frame">
						' . $txt['pmx_sef_engine_helpAP'] . '<div id="pmxsefAP" style="margin-top:10px;cursor:pointer;font-weight:bold;white-space:pre-wrap;overflow:hidden;" title="' . $txt['pmx_sef_engine_APIS_copy'] . '" onclick="return smfSelectText(\'pmxsefAP\', true);">' . htmlentities($txt['pmx_sef_engine_APcode'], ENT_NOQUOTES, $context['pmx']['encoding']) . '</div>
					</div>
					<table class="pmx_table">
						<tr>
							<td style="padding:10px 5px 0 5px;width:50%;text-align:right;">
								<div style="min-height:25px;">
									' . $txt['pmx_sef_enable'] . '
									<img class="info_toggle" onclick=\'Show_help("pmxH40a")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div id="pmxH40a" style="text-align:left;" class="info_frame">' . $txt['pmx_sef_enable_help'] . '</div>
							</td>
							<td style="padding:10px 5px 0 5px;width:50%;">
								<div style="min-height:25px; margin-left:-4px;">
									<input type="hidden" name="pmxsef_enable" value="0" />
									<input class="input_check" type="checkbox" name="pmxsef_enable" value="1"' . (!empty($context['pmx']['pmxsef_enable']) ? ' checked="checked"' : '') . ' />';
        if (!empty($modSettings['pmxsef_disabled'])) {
            echo '
									<div style="float:right; margin-right:10px; width:90%;"><i>' . $txt['pmx_sef_engine_disabled'] . '</i></div>';
        }
        echo '
								</div>
							</td>
						</tr>
						<tr>
							<td style="padding:5px 5px 0 5px;width:50%;text-align:right;">
								<div style="min-height:25px;">
									' . $txt['pmx_sef_lowercase'] . '
									<img class="info_toggle" onclick=\'Show_help("pmxH41")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div id="pmxH41" style="text-align:left;" class="info_frame">' . $txt['pmx_sef_lowercase_help'] . '</div>
							</td>
							<td style="padding:5px 5px 0 5px;width:50%;">
								<div style="min-height:25px; margin-left:-4px;">
									<input type="hidden" name="pmxsef_lowercase" value="0" />
									<input class="input_check" type="checkbox" name="pmxsef_lowercase" value="1"' . (!empty($context['pmx']['pmxsef_lowercase']) ? ' checked="checked"' : '') . ' />
								</div>
							</td>
						</tr>
						<tr>
							<td style="padding:5px 5px 0 5px;width:50%;text-align:right;">
								<div style="min-height:25px;">
									' . $txt['pmx_sef_autosave'] . '
									<img class="info_toggle" onclick=\'Show_help("pmxH41a")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div id="pmxH41a" style="text-align:left;" class="info_frame">' . $txt['pmx_sef_autosave_help'] . '</div>
							</td>
							<td style="padding:5px 5px 0 5px;width:50%;">
								<div style="min-height:25px; margin-left:-4px;">
									<input type="hidden" name="pmxsef_autosave" value="0" />
									<input class="input_check" type="checkbox" name="pmxsef_autosave" value="1"' . (!empty($context['pmx']['pmxsef_autosave']) ? ' checked="checked"' : '') . ' />
								</div>
							</td>
						</tr>
						<tr>
							<td style="padding:5px 5px 0 5px;width:50%;text-align:right;">
								<div style="min-height:25px;">
									' . $txt['pmx_sef_spacechar'] . '
									<img class="info_toggle" onclick=\'Show_help("pmxH42")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div id="pmxH42" style="text-align:left;" class="info_frame">' . $txt['pmx_sef_spacechar_help'] . '</div>
							</td>
							<td style="padding:5px 5px 0 5px;width:50%;">
								<div style="min-height:25px;">
									<input type="text" size="1" name="pmxsef_spacechar" value="' . $context['pmx']['pmxsef_spacechar'] . '" />
								</div>
							</td>
						</tr>
						<tr>
							<td style="padding:5px 5px 0 5px;width:50%;text-align:right;">
								<div style="min-height:25px;">
									' . $txt['pmx_sef_stripchars'] . '
									<img class="info_toggle" onclick=\'Show_help("pmxH43")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div id="pmxH43" style="text-align:left;" class="info_frame">' . $txt['pmx_sef_stripchars_help'] . '</div>
							</td>
							<td style="padding:5px 5px 0 5px;width:50%;">
								<div style="min-height:25px;">
									<input style="width:98%;" type="text" name="pmxsef_stripchars" value="' . htmlentities($context['pmx']['pmxsef_stripchars'], ENT_QUOTES, $context['pmx']['encoding']) . '" />
								</div>
							</td>
						</tr>
						<tr>
							<td style="padding:5px 5px 0 5px;width:50%;text-align:right;">
								<div style="min-height:25px;">
									' . $txt['pmx_sef_single_token'] . '
									<img class="info_toggle" onclick=\'Show_help("pmxH45")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div id="pmxH45" style="text-align:left;" class="info_frame">' . $txt['pmx_sef_single_token_help'] . '</div>
							</td>
							<td style="padding:5px 5px 0 5px;width:50%;">
								<div style="min-height:25px;">
									<textarea class="adm_textarea" style="width:98%;min-height:50px; max-height:100px;" rows="1" cols="50" name="pmxsef_singletoken">' . $context['pmx']['pmxsef_singletoken'] . '</textarea>
								</div>
							</td>
						</tr>
						<tr>
							<td style="padding:5px 5px 0 5px;width:50%;text-align:right;">
								<div style="min-height:25px;">
									' . $txt['pmx_sef_actions'] . '
									<img class="info_toggle" onclick=\'Show_help("pmxH46")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div id="pmxH46" style="text-align:left;" class="info_frame">' . $txt['pmx_sef_actions_help'] . '</div>
							</td>
							<td style="padding:5px 5px 0 5px;width:50%;">
								<div style="min-height:25px;">
									<textarea class="adm_textarea" style="width:98%;min-height:160px; max-height:300px;" rows="1" cols="50" name="pmxsef_actions">' . $context['pmx']['pmxsef_actions'] . '</textarea>
								</div>
							</td>
						</tr>
						<tr>
							<td style="padding:5px 5px 0 5px;width:50%;text-align:right;">
								<div style="min-height:25px;">
									' . $txt['pmx_sef_aliasactions'] . '
									<img class="info_toggle" onclick=\'Show_help("pmxH46a")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div id="pmxH46a" style="text-align:left;" class="info_frame">' . $txt['pmx_sef_aliasactions_help'] . '</div>
							</td>
							<td style="padding:5px 5px 0 5px;width:50%;">
								<div style="min-height:25px;">
									<input style="width:98%;" type="text" name="pmxsef_aliasactions" value="' . $context['pmx']['pmxsef_aliasactions'] . '" />
								</div>
							</td>
						</tr>
						<tr>
							<td style="padding:5px 5px 0 5px;width:50%;text-align:right;">
								<div style="min-height:25px;">
									' . $txt['pmx_sef_ignoreactions'] . '
									<img class="info_toggle" onclick=\'Show_help("pmxH46i")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div id="pmxH46i" style="text-align:left;" class="info_frame">' . $txt['pmx_sef_ignoreactions_help'] . '</div>
							</td>
							<td style="padding:5px 5px 0 5px;width:50%;">
								<div style="min-height:25px;">
									<input style="width:98%;" type="text" name="pmxsef_ignoreactions" value="' . $context['pmx']['pmxsef_ignoreactions'] . '" />
								</div>
							</td>
						</tr>
						<tr>
							<td style="padding:5px 5px 0 5px;width:50%;text-align:right;">
								<div style="min-height:25px;">
									' . $txt['pmx_sef_ignorerequests'] . '
									<img class="info_toggle" onclick=\'Show_help("pmxH46r")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div id="pmxH46r" style="text-align:left;" class="info_frame">' . $txt['pmx_sef_ignorerequests_help'] . '</div>
							</td>
							<td style="padding:5px 5px 0 5px;width:50%;">
								<div style="min-height:25px;">
									<input style="width:98%;" type="text" name="pmxsef_ignorerequests" value="' . $context['pmx']['pmxsef_ignorerequests'] . '" />
								</div>
							</td>
						</tr>
						<tr>
							<td style="padding:5px 5px 0 5px;width:50%;text-align:right;">
								<div style="min-height:25px;">
									' . $txt['pmx_sef_simplesef_space'] . '
									<img class="info_toggle" onclick=\'Show_help("pmxH48")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</div>
								<div id="pmxH48" style="text-align:left;" class="info_frame">' . $txt['pmx_sef_simplesef_space_help'] . '</div>
							</td>
							<td style="padding:5px 5px 0 5px;width:50%;">
								<div style="min-height:25px;">
									<input type="text" size="1" name="pmxsef_ssefspace" value="' . $context['pmx']['pmxsef_ssefspace'] . '" />
								</div>
								<input type="hidden" name="pmxsef_codepages" value="' . $context['pmx']['pmxsef_codepages'] . '" />
							</td>
						</tr>';
        echo '
					</table>
					<hr />
					<p style="text-align:center;"><input class="button_submit" style="float:none;" type="button" value="' . $txt['pmx_save'] . '" onclick="FormFunc(\'save_settings\', \'yes\')" /></p>
					</div>
				</td>
			</tr>
		</table>';
    }
    echo '
	</form>';
}