/**
     * Output the Category config screen
     */
    function pmxc_ShowAdmCategoryConfig()
    {
        global $context, $settings, $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="parent" value="' . $this->cfg['parent'] . '" />
									<input type="hidden" name="level" value="' . $this->cfg['level'] . '" />
									<input type="hidden" name="catorder" value="' . $this->cfg['catorder'] . '" />
									<input type="hidden" name="config[settings]" value="" />
									<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_categories_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;">';
        // show placement for new categories
        if ($context['pmx']['subaction'] == 'editnew') {
            if (!empty($this->categories)) {
                echo '
									<div style="padding-top:4px;">
										<div style="float:left; width:145px;">' . $txt['pmx_categories_type'] . '</div>';
                $opt = 0;
                foreach ($txt['pmx_categories_places'] as $artType => $artDesc) {
                    echo '
											<input id="pWind.place.' . $opt . '" class="input_check" type="radio" name="catplace" value="' . $artType . '"' . ($artType == 'after' ? ' checked="checked"' : '') . ' /><span style="vertical-align:3px; padding:0 3px;">' . $artDesc . '</span>';
                    $opt++;
                }
                // all exist categories
                echo '
									</div>
									<div style="float:left; width:150px;padding-top:11px;padding-bottom:8px;">' . $txt['pmx_categories_cats'] . '</div>
										<select style="width:53%;margin-top:10px;margin-bottom:8px;" size="1" name="catid">';
                // output cats
                foreach ($context['pmx']['catorder'] as $order) {
                    $cat = PortaMx_getCatByOrder($this->categories, $order);
                    echo '
											<option value="' . $cat['id'] . '"' . ($this->cfg['id'] == $cat['id'] ? ' selected="selected"' : '') . '>' . str_repeat('&bull;', $cat['level']) . ' ' . $cat['name'] . '</option>';
                }
                echo '
										</select>';
            } else {
                echo '
										<input type="hidden" name="catid" value="0" />
										<input type="hidden" name="catplace" value="0" />';
            }
        }
        // category name
        echo '
									<div class="adm_clear" style="float:left;width:150px; padding-top:3px;">' . $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>
									<input id="check.name" style="width:53%; margin-top:1px;" onkeyup="check_requestname(this)" onkeypress="check_requestname(this)" type="text" name="name" value="' . $this->cfg['name'] . '" />
									<div id="pmxBH11" class="info_frame" style="margin-top:5px;">' . $txt['pmx_edit_pagenamehelp'] . '
									</div>
									</div>
								</td>
							</tr>

							<tr>
								<td style="padding:4px;width:50%;">
									<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_categories_settings_title'] . '</span></h4>
									</div>';
        // show mode (titelbar/frame)
        foreach ($txt['pmx_categories_showmode'] as $key => $value) {
            echo '
									<div class="adm_check" style="min-height:38px;">
										<img align="left" src="' . $context['pmx_imageurl'] . 'ca_frame_' . $key . '.png" alt="*" />
										<div style="float:left; width:72%; padding:0 10px;">' . $value . '</div>
										<input style="float:right;margin-right:20px;" name="config[settings][framemode]" class="input_radio" type="radio" value="' . $key . '"' . ($this->cfg['config']['settings']['framemode'] == $key ? ' checked="checked"' : '') . ' />
									</div>';
        }
        // show mode also for articles
        echo '
									<div class="adm_check" style="height:20px;">
										<div style="float:left; width:82%;">' . $txt['pmx_categories_visual'] . '</div>
										<input style="float:right;margin-right:20px;" name="config[settings][catstyle]" type="checkbox" class="input_check" value="1"' . (!empty($this->cfg['config']['settings']['catstyle']) ? ' checked="checked"' : '') . ' />
									</div>';
        // show mode (sidebar)
        echo '
									<div class="adm_check" style="height:20px;">
										<div style="float:left; width:82%;">' . $txt['pmx_categories_modsidebar'] . '</div>
										<input id="shm.sidebar" style="float:right;margin-right:20px;" onclick="check_PageMode(this, \'pages\')" name="config[settings][showmode]" class="input_radio" type="radio" value="sidebar"' . ($this->cfg['config']['settings']['showmode'] == 'sidebar' ? ' checked="checked"' : '') . ' />
									</div>';
        // show mode (pages)
        echo '
									<div class="adm_check" style="height:20px;">
										<div style="float:left; width:82%;">' . $txt['pmx_categories_modpage'] . '</div>
										<input id="shm.pages" style="float:right;margin-right:20px;" onclick="check_PageMode(this, \'sidebar\')" name="config[settings][showmode]" class="input_radio" type="radio" value="pages"' . ($this->cfg['config']['settings']['showmode'] == 'pages' ? ' checked="checked"' : '') . ' />
									</div>';
        // options for SideBar mode
        echo '
									<div id="opt.sidebar" class="adm_clear" style="padding-top:0px;' . ($this->cfg['config']['settings']['showmode'] == 'pages' ? ' display:none;' : '') . '">
										<div style="height:25px;margin-top:0px;">
											<div style="float:left; width:80%;">' . $txt['pmx_categories_sidebarwith'] . '</div>
											<input style="float:right;margin-right:20px;margin-top:-2px;" onkeyup="check_numeric(this)" type="text" size="3" name="config[settings][sidebarwidth]" value="' . (!empty($this->cfg['config']['settings']['sidebarwidth']) ? $this->cfg['config']['settings']['sidebarwidth'] : '') . '" />
										</div>
										<div style="height:25px;margin-top:0px;">
											<div style="float:left;">' . $txt['pmx_categories_sidebaralign'] . '</div>
											<div style="float:right; margin-right:20px;margin-top:0px;">
												<input class="input_radio" type="radio" name="config[settings][sbmalign]" value="1"' . (!empty($this->cfg['config']['settings']['sbmalign']) ? ' checked="checked"' : '') . ' /><span style="display:inline-block;margin-top:2px;">' . $txt['pmx_categories_sbalign'][0] . '&nbsp;&nbsp;&nbsp;</span>
												<input class="input_radio" type="radio" name="config[settings][sbmalign]" value="0"' . (empty($this->cfg['config']['settings']['sbmalign']) ? ' checked="checked"' : '') . ' /><span style="display:inline-block;margin-top:2px;">' . $txt['pmx_categories_sbalign'][1] . '</span>
											</div>
										</div>
										<div style="height:21px;margin-top:0px;">
											<div style="float:left; width:82%;">' . $txt['pmx_categories_addsubcats'] . '</div>
											<input type="hidden" name="config[settings][addsubcats]" value="0" />
											<input style="float:right;margin-right:20px;" type="checkbox" class="input_check" name="config[settings][addsubcats]" value="1"' . (!empty($this->cfg['config']['settings']['addsubcats']) ? ' checked="checked"' : '') . ' />
										</div>
									</div>';
        // options for Pages mode
        echo '
									<div id="opt.pages" class="adm_clear" style="padding-top:0px;' . ($this->cfg['config']['settings']['showmode'] == 'sidebar' ? 'display:none;' : '') . '">
										<div style="height:20px;">
											<div style="float:left;width:80%;">' . $txt['pmx_categories_modpage_count'] . '</div>
											<input style="float:right;margin-right:20px;margin-top:-2px;" onkeyup="check_numeric(this)" type="text" size="3" name="config[settings][pages]" value="' . (!empty($this->cfg['config']['settings']['pages']) ? $this->cfg['config']['settings']['pages'] : '') . '" />
										</div>
										<div style="height:20px;margin-top:7px;">
											<div style="float:left;width:80%;">' . $txt['pmx_categories_modpage_pageindex'] . '</div>
											<input style="float:right;margin-right:20px;" type="checkbox" class="input_check" name="config[settings][pageindex]" value="1"' . (!empty($this->cfg['config']['settings']['pageindex']) ? ' checked="checked"' : '') . ' />
										</div>
										<div style="height:20px;margin-top:5px;">
											<div style="float:left; width:82%;">' . $txt['pmx_categories_showsubcats'] . '</div>
											<input type="hidden" name="config[settings][showsubcats]" value="0" />
											<input id="opt.pages.sbar.check" style="float:right;margin-right:20px;" type="checkbox" class="input_check" name="config[settings][showsubcats]" value="1"' . (!empty($this->cfg['config']['settings']['showsubcats']) ? ' checked="checked"' : '') . ' onclick="set_PageMode(this)" />
										</div>
									</div>
									<div id="opt.pages.sbar" class="adm_clear" style="padding-top:2px;' . ($this->cfg['config']['settings']['showmode'] == 'pages' && !empty($this->cfg['config']['settings']['showsubcats']) ? '' : 'display:none;') . '">
										<div style="height:23px;margin-top:3px;">
											<div style="float:left; width:80%;">' . $txt['pmx_categories_sidebarwith'] . '</div>
											<input style="float:right;margin-right:20px;" onkeyup="check_numeric(this)" type="text" size="3" name="config[settings][catsbarwidth]" value="' . (!empty($this->cfg['config']['settings']['catsbarwidth']) ? $this->cfg['config']['settings']['catsbarwidth'] : '') . '" />
										</div>
										<div style="height:20px;margin-top:3px;">
											<div style="float:left;">' . $txt['pmx_categories_sidebaralign'] . '</div>
											<div style="float:right; margin-right:20px;margin-top:0px;">
												<input class="input_radio" type="radio" name="config[settings][sbpalign]" value="1"' . (!empty($this->cfg['config']['settings']['sbpalign']) ? ' checked="checked"' : '') . ' /><span style="vertical-align:2px;">' . $txt['pmx_categories_sbalign'][0] . '&nbsp;&nbsp;&nbsp;</span>
												<input class="input_radio" type="radio" name="config[settings][sbpalign]" value="0"' . (empty($this->cfg['config']['settings']['sbpalign']) ? ' checked="checked"' : '') . ' /><span style="vertical-align:2px;">' . $txt['pmx_categories_sbalign'][1] . '</span>
											</div>
										</div>
									</div>
									<div class="adm_check" style="height:20px; padding-top:4px;">
										<div style="float:left; width:82%;">
											<img class="info_toggle" align="right style="padding:2px 5px;" onclick=\'Show_help("pmxCH06")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
											' . $txt['pmx_categorie_inherit'] . '
										</div>
										<input style="float:right;margin-right:20px;" name="config[settings][inherit_acs]" class="input_check" type="checkbox" value="1"' . (!empty($this->cfg['config']['settings']['inherit_acs']) ? ' checked="checked"' : '') . ' />
									</div>
									<div id="pmxCH06" class="info_frame">' . $txt['pmx_categories_inherithelp'] . '</div>';
        // article sort
        echo '
									<div class="adm_clear" style="padding-top:4px; height:70px;">
										<div style="float:left; width:150px;">
											<img class="info_toggle" align="right style="padding:2px 5px;" onclick=\'Show_help("pmxCH05")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
											' . $txt['pmx_categorie_articlesort'] . '
										</div>
										<select style="float:right;margin-right:20px; width:45%;margin-top:3px;" name="artsort[]" id="pmxartsort" onchange="changed(\'pmxartsort\');" size="4" multiple="multiple">';
        if (!empty($this->cfg['artsort'])) {
            $sortdata = array();
            $sortval = Pmx_StrToArray($this->cfg['artsort']);
            foreach ($sortval as $sort) {
                @(list($k, $v) = Pmx_StrToArray($sort, '='));
                $sortdata[$k] = $v;
            }
        } else {
            $sortdata = array('id' => 1);
        }
        foreach ($txt['pmx_categories_artsort'] as $key => $value) {
            echo '
											<option value="' . $key . '=' . (array_key_exists($key, $sortdata) ? $sortdata[$key] . '" selected="selected' : '1') . '">' . (array_key_exists($key, $sortdata) ? $sortdata[$key] == '0' ? '^' : '' : '') . $value . '</option>';
        }
        echo '
										</select>
									</div>
									<div class"adm_clear"></div>
									<div id="pmxCH05" class="info_frame">' . $txt['pmx_categories_sorthelp'] . '</div>
									<script type="text/javascript">
										var pmxartsort = new MultiSelect("pmxartsort");
									</script>';
        // Categorie for common use
        echo '
									<input type="hidden" name="config[check_ecl]" value="0" />
									<input type="hidden" name="config[check_eclbots]" value="0" />
									<div class="cat_bar catbg_grid grid_padd" style="margin-top:10px;">
										<h4 class="catbg catbg_grid"><span class="cat_left_title">' . $txt['pmx_categories_globalcat'] . '</span></h4>
									</div>
									<div class="adm_check" style="min-height:25px;">
										<span class="adm_w80">' . $txt['pmx_categorie_global'] . '
											<img class="info_toggle" onclick=\'Show_help("pmxHCAT02")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
										</span>
										<input class="input_check" style="float:right; margin-right:20px;" type="checkbox" name="config[global]" value="1"' . (!empty($this->cfg['config']['global']) ? ' checked="checked"' : '') . ' />
										<div id="pmxHCAT02" class="info_frame" style="margin-top:4px;">' . $txt['pmx_categories_gloablcathelp'] . '</div>
									</div>
									<div class="adm_check" style="min-height:25px;">
										<span class="adm_w80">' . $txt['pmx_categorie_request'] . '
											<img class="info_toggle" onclick=\'Show_help("pmxHCAT03")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
										</span>
										<input class="input_check" style="float:right; margin-right:20px;" type="checkbox" name="config[request]" value="1"' . (!empty($this->cfg['config']['request']) ? ' checked="checked"' : '') . ' />
										<div id="pmxHCAT03" class="info_frame" style="margin-top:4px;">' . $txt['pmx_categorie_requesthelp'] . '</div>
									</div>
									<div class="adm_check" style="min-height:25px;">
										<span class="adm_w80">' . $txt['pmx_check_catelcmode'] . '
										 <img class="info_toggle" onclick=\'Show_help("pmxCateclHelp")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
										</span>
										<input class="input_check" style="float:right; margin-right:20px;" type="checkbox" name="config[check_ecl]" value="1"' . (!empty($this->cfg['config']['check_ecl']) ? ' checked="checked"' : '') . ' onclick="showeclbots(this)" />
									</div>
									<div id="pmxCateclHelp" class="info_frame" style="margin-top:0;">' . $txt['pmx_cat_eclcheckhelp'] . '</div>
									<div class="adm_check" id="eclextend" style="min-height:25px;display:' . (!empty($this->cfg['config']['check_ecl']) ? 'block' : 'none') . '">
										<span class="adm_w80">' . $txt['pmx_check_catelcbots'] . '
										 <img class="info_toggle" onclick=\'Show_help("pmxeclHelpbots")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
										</span>
										<input id="eclextendinp" class="input_check" style="float:right; margin-right:20px;" type="checkbox" name="config[check_eclbots]" value="1"' . (!empty($this->cfg['config']['check_eclbots']) ? ' checked="checked"' : '') . ' />
									</div>
									<div id="pmxeclHelpbots" class="info_frame" style="margin-top:0;">' . $txt['pmx_cat_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:174px;"><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:176px; 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">' . $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:176px; 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>';
        }
        // the group access
        echo '
									<div class="adm_clear cat_bar catbg_grid grid_padd" style="margin-top:2px;">
										<h4 class="catbg catbg_grid" style="margin-left:173px;">
											<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_categories_groups'] . '</span>
										</h4>
									</div>
									<select name="acsgrp[]" id="pmxgroups" onchange="changed(\'pmxgroups\');" style="width:47%;margin-left:178px;" 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" style="margin-top:5px;">' . $txt['pmx_categories_groupshelp'] . '</div>
									<script type="text/javascript">
										var pmxgroups = new MultiSelect("pmxgroups");
									</script>
								</td>
							</tr>
							<tr>
							<tr>
								<td colspan="2" style="text-align:center;padding:4px 4px 0 4px;"><hr class="pmx_hr" />
									<div style="padding-top: 5px;">
									<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\')" />
									</div>
								</td>
							</tr>
						</table>
						</div>
					</td>
				</tr>';
    }
/**
* 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']);
        }
    }
}
    /**
     * 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);
    }
/**
* 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();
}
/**
* 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;
}
 /**
  * Setting a config item.
  * The item can be a single value or a array
  */
 function setBlockConfig($itemstr = '', $value = '')
 {
     $result = $this->getBlockConfig($itemstr);
     if (!is_null($result)) {
         $item = Pmx_StrToArray($itemstr);
         $base =& $this->cfg;
         foreach ($item as $val) {
             $base =& $base[$val];
         }
         $base = $value;
     }
 }
/**
* AdmCategoryOverview
* Called for each category.
*/
function PmxCategoryOverview($category)
{
    global $context, $txt;
    global $cfg_smfgroups;
    $category['config'] = unserialize($category['config']);
    if (empty($category['config']['title_align'])) {
        $category['config']['title_align'] = 'left';
    }
    if (empty($category['config']['title_icon'])) {
        $category['config']['title_icon'] = 'none.png';
    }
    echo '
					<div class="pmx_tbl_tr">';
    // Move row
    echo '
						<div class="pmx_tbl_tdgrid" id="RowMove-' . $category['id'] . '" style="white-space:nowrap;">
							<div class="pmx_clickrow' . (count($context['pmx']['catorder']) > 1 ? ' pmx_moveimg" title="' . $txt['pmx_move_categories'] . '" onclick="pmxSetMove(\'' . $category['id'] . '\')"' : '"') . '>
								<div style="padding-left:20px;margin-top:-2px;width:22px;">' . $category['catorder'] . '</div>
							</div>
						</div>';
    // title row
    echo '
						<div class="pmx_tbl_tdgrid">
							<div onclick="pmxSetTitle(\'' . $category['id'] . '\', \'cat\')"  title="' . $txt['pmx_click_edit_ttl'] . '" style="cursor:pointer;">
								<img id="uTitle.icon.' . $category['id'] . '" style="padding-right:4px;" src="' . $context['pmx_Iconsurl'] . $category['config']['title_icon'] . '" alt="*" title="' . substr($txt['pmx_edit_titleicon'], 0, -1) . '" />
								<img id="uTitle.align.' . $category['id'] . '" src="' . $context['pmx_imageurl'] . 'text_align_' . $category['config']['title_align'] . '.gif" alt="*" title="' . $txt['pmx_edit_title_align'] . $txt['pmx_edit_title_align_types'][$category['config']['title_align']] . '" />
								<span id="sTitle.text.' . $category['id'] . '.cat">' . (isset($category['config']['title'][$context['pmx']['currlang']]) ? htmlspecialchars($category['config']['title'][$context['pmx']['currlang']], ENT_QUOTES) : '') . '</span>';
    foreach ($context['pmx']['languages'] as $lang => $sel) {
        echo '
								<input id="sTitle.text.' . $lang . '.' . $category['id'] . '.cat" type="hidden" value="' . (isset($category['config']['title'][$lang]) ? htmlspecialchars($category['config']['title'][$lang], ENT_QUOTES) : '') . '" />';
    }
    echo '
								<input id="sTitle.icon.' . $category['id'] . '" type="hidden" value="' . $category['config']['title_icon'] . '" />
								<input id="sTitle.align.' . $category['id'] . '" type="hidden" value="' . $category['config']['title_align'] . '" />
							</div>
						</div>';
    // name row
    $details = PortaMx_getCatDetails($category, $context['pmx']['categories']);
    echo '
						<div class="pmx_tbl_tdgrid" style="cursor:pointer;" onclick="pmxSetCatName(\'' . $category['id'] . '\')">
							<input id="pWind.parent.id.' . $category['id'] . '" type="hidden" value="' . $category['parent'] . '" />
							<input id="pWind.move.cat.' . $category['id'] . '" type="hidden" value="[' . $category['catorder'] . ']' . ($category['level'] > 0 ? ' ' : '') . str_repeat('&bull;', $category['level']) . ' ' . $category['name'] . '" />
							<div id="pmxSetMove.' . $category['id'] . '" title="' . $details['parent'] . $txt['pmx_editname_categories'] . '" class="' . $details['class'] . '"><b>' . $details['level'] . '</b>
								<span id="pmxSetAcs.' . $category['id'] . '"><span id="pWind.cat.name.' . $category['id'] . '" class="cat_names">' . $category['name'] . '</span></span>
							</div>
						</div>';
    if (!empty($category['acsgrp'])) {
        list($grpacs, $denyacs) = Pmx_StrToArray($category['acsgrp'], ',', '=');
    } else {
        $grpacs = $denyacs = array();
    }
    $groups = array();
    foreach ($cfg_smfgroups as $grp) {
        if (in_array($grp['id'], $grpacs)) {
            $groups[] = '+' . $grp['id'] . '=' . intval(!in_array($grp['id'], $denyacs));
        } else {
            $groups[] = ':' . $grp['id'] . '=1';
        }
    }
    $sort = array();
    $catarts = array();
    $sorts = explode(',', $category['artsort']);
    foreach ($sorts as $s) {
        $sort[] = htmlentities($txt['pmx_categories_artsort'][str_replace(array('=0', '=1'), array('', ''), $s)], ENT_QUOTES, $context['pmx']['encoding']) . $txt['pmx_artsort'][intval(substr($s, -1, 1))];
    }
    if (!empty($category['articles'])) {
        foreach ($category['articles'] as $arts) {
            $catarts[] = '[' . $arts['id'] . '] ' . $arts['name'];
        }
    }
    // create acs groups for acs Popup
    if (!empty($category['acsgrp'])) {
        list($grpacs, $denyacs) = Pmx_StrToArray($category['acsgrp'], ',', '=');
    } else {
        $grpacs = $denyacs = array();
    }
    // options row
    echo '
						<div class="pmx_tbl_tdgrid">
							<input id="grpAcs.' . $category['id'] . '" type="hidden" value="' . implode(',', $grpacs) . '" />
							<input id="denyAcs.' . $category['id'] . '" type="hidden" value="' . implode(',', $denyacs) . '" />
							<input id="pWind.catarts.' . $category['id'] . '" type="hidden" value="' . implode('|', $catarts) . '" />
							<input id="pWind.artsorttxt.' . $category['id'] . '" type="hidden" value="' . $txt['pmx_categorie_articlesort'] . '" />
							<input id="pWind.artsort.' . $category['id'] . '" type="hidden" value="' . implode('|', $sort) . '" />
							<div id="pWind.grp.' . $category['id'] . '" class="pmx_clickrow' . (!empty($category['acsgrp']) ? ' pmx_access" title="' . $txt['pmx_categories_groupaccess'] : '') . '"></div>
							<div class="pmx_clickrow' . (!empty($category['config']['cssfile']) ? ' pmx_custcss" title="' . $txt['pmx_categories_cssfile'] : '') . '"></div>
							<div class="pmx_clickrow' . (!empty($category['config']['check_ecl']) ? ' pmx_eclsettings" title="' . $txt['pmx_have_catecl_settings'] : '') . '"></div>
							<div class="pmx_clickrow' . (!empty($category['artsum']) ? ' pmx_articles" title="' . sprintf($txt['pmx_categories_articles'], $category['artsum']) . '" onclick="pmxShowArt(\'' . $category['id'] . '\')"' : '"') . '></div>
						</div>';
    // functions row
    echo '
						<div class="pmx_tbl_tdgrid">
							<div class="pmx_clickrow pmx_pgedit" title="' . $txt['pmx_edit_categories'] . '" onclick="FormFunc(\'edit_category\', \'' . $category['id'] . '\')"></div>
							<div class="pmx_clickrow pmx_grpacs" title="' . $txt['pmx_chg_categoriesaccess'] . '" onclick="pmxSetAcs(\'' . $category['id'] . '\', \'cat\')"></div>
							<div class="pmx_clickrow pmx_pgclone" title="' . $txt['pmx_clone_categories'] . '"  onclick="pmxSetCatClone(\'' . $category['id'] . '\')"></div>
							<div class="pmx_clickrow pmx_pgdelete" title="' . $txt['pmx_delete_categories'] . '" onclick="pmxSetCatDelete(\'' . $category['id'] . '\')"></div>
						</div>
					</div>';
}
    /**
     * 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>';
    }
/**
* 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>';
}
/**
* 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;
    }
}
/**
* 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>';
}