/**
     * ShowContent
     * Output the content and add necessary javascript
     */
    function pmxc_ShowContent()
    {
        global $settings, $txt;
        // Write out the content
        echo $this->cfg['content'];
        $thid = !empty($settings['theme_id']) ? $settings['theme_id'] : '1';
        echo '
	<script type="text/javascript">
		var server_query_string = "' . base64_encode(pmx_http_build_query($_GET)) . '";
		document.getElementById("thumbnail").title = "' . $txt['pmx_theme_change'] . '";
		document.getElementById("thumbnail").src = themeimages[' . $thid . '];
		var elm = document.getElementById("pmx' . $this->cfg['id'] . 'themeselect");
		for(var idx = 0; idx < this.elm.length; idx++)
			elm.options[idx].selected = elm.options[idx].value == ' . $thid . ';
	</script>';
    }
    /**
     * ShowContent
     * Output the content.
     */
    function pmxc_ShowContent()
    {
        global $context, $scripturl, $txt;
        // User logged in?
        if ($context['user']['is_logged']) {
            // avatar
            if (!empty($context['user']['avatar']) && !empty($this->cfg['config']['settings']['show_avatar'])) {
                $avasize = getimagesize($context['user']['avatar']['href']);
                $fact = $avasize[0] > $avasize[1] ? 50 / $avasize[0] : 50 / $avasize[1];
                $leftpad = strval(intval($avasize[0] * $fact + 8));
                echo '
									<div style="padding-left:' . $leftpad . 'px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;"' . (isset($this->cfg['config']['visuals']['hellotext']) ? ' class="' . $this->cfg['config']['visuals']['hellotext'] . '"' : '') . '>' . $txt['pmx_hello'] . '<br /><a href="' . $scripturl . '?action=profile;u=' . $context['user']['id'] . '" title="' . $context['user']['name'] . '"><b>' . $context['user']['name'] . '</b></a>
									</div>';
                // avatar
                if (!empty($context['user']['avatar']) && !empty($this->cfg['config']['settings']['show_avatar'])) {
                    echo '
									<div style="float:left;margin-top:-38px;">
										<a style="float-left;margin-top:-20px;" class="pmx_avatar" href="' . $scripturl . '?action=profile;u=' . $context['user']['id'] . '" title="' . $context['user']['name'] . '">' . $context['user']['avatar']['image'] . '</a>
									</div>';
                }
            } else {
                echo '
									<div' . (isset($this->cfg['config']['visuals']['hellotext']) ? 'block;" class="' . $this->cfg['config']['visuals']['hellotext'] . '"' : '') . '>' . $txt['pmx_hello'] . '<a href="' . $scripturl . '?action=profile;u=' . $context['user']['id'] . '"><b>' . $context['user']['name'] . '</b></a>
									</div>';
            }
            $img = '<img src="' . $context['pmx_syscssurl'] . 'Images/bullet_blue.gif" alt="*" title="" />';
            $img1 = '<img src="' . $context['pmx_syscssurl'] . 'Images/bullet_red.gif" alt="*" title="" />';
            if (!empty($context['user']['avatar']) && !empty($this->cfg['config']['settings']['show_avatar'])) {
                echo '
									<ul style="margin-top:20px;" class="userlogin">';
            } else {
                echo '
									<ul class="userlogin smalltext">';
            }
            // show pm?
            if (!empty($this->cfg['config']['settings']['show_pm']) && $context['allow_pm']) {
                echo '
										<li>' . ($context['user']['unread_messages'] > 0 ? $img1 : $img) . '<span><a href="' . $scripturl . '?action=pm">' . $txt['pmx_pm'] . ($context['user']['unread_messages'] > 0 ? ': ' . $context['user']['unread_messages'] . ' <img src="' . $context['pmx_imageurl'] . 'newpm.gig" alt="*" title="' . $context['user']['unread_messages'] . '" />' : '') . '</a></span></li>';
            }
            // Are there any members waiting for approval?
            if (!empty($this->cfg['config']['settings']['show_unapprove']) && !empty($context['unapproved_members'])) {
                echo '
										<li>' . $img1 . '<span><a href="' . $scripturl . '?action=admin;area=viewmembers;sa=browse;type=approve">' . $txt['pmx_unapproved_members'] . ' <b>' . $context['unapproved_members'] . '</b></a></span></li>';
            }
            // show post?
            if (!empty($this->cfg['config']['settings']['show_posts'])) {
                echo '
										<li>' . $img . '<span><a href="' . $scripturl . '?action=unread">' . $txt['pmx_unread'] . '</a></span></li>
										<li>' . $img . '<span><a href="' . $scripturl . '?action=unreadreplies">' . $txt['pmx_replies'] . '</a></span></li>
										<li>' . $img . '<span><a href="' . $scripturl . '?action=profile;area=showposts;u=' . $context['user']['id'] . '">' . $txt['pmx_showownposts'] . '</a></span></li>';
            }
            echo '
									</ul>';
            // Is the forum in maintenance mode?
            if ($context['in_maintenance'] && $context['user']['is_admin']) {
                echo '
									<b>' . $txt['pmx_maintenace'] . '</b><br />';
            }
            // Show the total time logged in?
            if (!empty($context['user']['total_time_logged_in']) && isset($this->cfg['config']['settings']['show_logtime']) && $this->cfg['config']['settings']['show_logtime'] == 1) {
                $totm = $context['user']['total_time_logged_in'];
                $form = '%s: %s%s %s%s %s%s';
                echo sprintf($form, $txt['pmx_loggedintime'], $totm['days'], $txt['pmx_Ldays'], $totm['hours'], $txt['pmx_Lhours'], $totm['minutes'], $txt['pmx_Lminutes']);
                echo '<br />';
            }
        } else {
            if (!empty($this->cfg['config']['settings']['show_login']) && pmx_checkECL_Cookie(true)) {
                echo '
									<div style="padding-top:4px;">
										<form action="', $scripturl, '?action=login2;quicklogin" method="post" accept-charset="', $context['character_set'], '">
											<input id=username" type="text" name="user" size="10" class="input_text" style="width:48%;float:left;margin-bottom:3px;" value="' . $txt['pmxdummyuser'] . '" onclick="usercheck(this)" />
											<input type="password" name="passwrd" size="10" class="input_password" value="" style="width:48%;float:right;margin-bottom:3px;margin-right:4px;" />
											<select name="cookielength">
												<option value="60">', $txt['one_hour'], '</option>
												<option value="1440">', $txt['one_day'], '</option>
												<option value="10080">', $txt['one_week'], '</option>
												<option value="43200">', $txt['one_month'], '</option>
												<option value="-1" selected="selected">', $txt['forever'], '</option>
											</select>
											<input type="hidden" name="hash_passwrd" value="" />
											<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
											<input type="hidden" name="', $context['login_token_var'], '" value="', $context['login_token'], '" />
											<input style="float:right;margin-right:4px;" type="submit" value="' . $txt['login'] . '" />
										</form>
										<script type="text/javascript">function usercheck(elm){if(elm.value=="' . $txt['pmxdummyuser'] . '"){elm.value = "";}}</script>
									' . $txt['login_dec'] . '
									</div>';
            }
        }
        // show current time?
        if (!empty($this->cfg['config']['settings']['show_time'])) {
            if (!empty($this->cfg['config']['settings']['show_realtime'])) {
                $cdate = date('Y,n-1,j,G,', Forum_Time()) . intval(date('i', Forum_Time())) . ',' . intval(date('s', Forum_Time()));
                echo '
								<span id="ulClock' . $this->cfg['id'] . '"></span>
								<script type="text/javascript">
								ulClock("' . $this->cfg['id'] . '");
								</script>';
            } else {
                echo $context['current_time'];
            }
        }
        // show logout button?
        if ($context['user']['is_logged'] && !empty($this->cfg['config']['settings']['show_logout'])) {
            echo '
								<br />
								<div style="text-align:center;margin-top:5px;">
									<input class="button_submit" type="button" value="' . $txt['logout'] . '" onclick="DoLogout()" />
								</div>
								<script type="text/javascript">
									function DoLogout()
									{
										window.location = "' . $scripturl . '?action=logout;' . $context['session_var'] . '=' . $context['session_id'] . '";
									}
								</script>';
        }
        // show a language dropdown selector
        if (!empty($this->cfg['config']['settings']['show_langsel']) && count($context['pmx']['languages']) > 1) {
            echo '
								<script type="text/javascript">
									if(document.getElementById("languages_form"))
									{
										document.getElementById("languages_form").style.display = "none";
										if(document.getElementsByName("search2"))
											document.getElementsByName("search2")[0].style.marginRight = "0";
									}
								</script>';
            if (isset($_GET['language'])) {
                unset($_GET['language']);
            }
            echo '
								<form id="pmxlangchg' . $this->cfg['id'] . '" accept-charset="' . $context['character_set'] . '" method="post">
									' . (pmx_checkECL_Cookie(true) ? '<input type="hidden" name="redir" value="' . pmx_http_build_query($_GET) . '" />' : '') . '
									<input type="hidden" id="pmxlangval' . $this->cfg['id'] . '" name="language" value="" />
								</form>
								<hr class="pmx_hr" />' . $txt['pmx_langsel'] . '
								<div style="padding-top:3px;">
									<select size="1" style="width:100%;" onchange="pmxSetlang(this, \'' . $this->cfg['id'] . '\')">';
            foreach ($context['pmx']['languages'] as $lang => $sel) {
                echo '
										<option value="' . $lang . '"' . (!empty($sel) ? ' selected="selected"' : '') . '>' . ucfirst($lang) . '</option>';
            }
            echo '
									</select>
								</div>';
        }
    }
/**
* Replacement for http_build_query
*/
function pmx_http_build_query($data, $prefix = '', $sep = ';')
{
    $ret = array();
    foreach ((array) $data as $k => $v) {
        $k = urlencode($k);
        if (is_int($k) && !empty($prefix)) {
            $k = $prefix . $k;
        }
        if (is_array($v) || is_object($v)) {
            array_push($ret, pmx_http_build_query($v, '', $sep));
        } elseif ($v == '') {
            array_push($ret, $k);
        } else {
            array_push($ret, $k . '=' . urlencode($v));
        }
    }
    if (empty($sep)) {
        $sep = ini_get("arg_separator.output");
    }
    return implode($sep, $ret);
}
/**
* Create Linktree and Page Title
**/
function pmx_MakeLinktree()
{
    global $context, $scripturl, $txt, $mbname;
    // Setup page title
    if (empty($context['current_board']) && empty($context['current_topic']) && empty($_REQUEST['action'])) {
        $context['page_title'] = $context['forum_name'];
    }
    // build the linktree
    $pmxforum = '';
    if (empty($context['linktree'])) {
        $context['linktree'] = array(array('url' => $scripturl, 'name' => $mbname));
    }
    if (!empty($_GET['pmxerror'])) {
        $pmxforum[] = array('url' => $scripturl . '?pmxerror=' . $_GET['pmxerror'], 'name' => $context['pmx_error_title']);
    }
    $pmxhome[] = array_shift($context['linktree']);
    $inForum = !empty($context['current_board']) || !empty($context['current_topic']) || (!empty($_REQUEST['action']) && in_array($_REQUEST['action'], array('community', 'unread', 'unreadreplies', 'markasread')) || isset($_REQUEST['board']) || isset($_REQUEST['topic']));
    if ($context['pmx']['settings']['frontpage'] != 'none' && empty($context['pmx']['pageReq']) && !empty($context['pmx']['showhome']) && !empty($inForum)) {
        $pmxhome[] = array('url' => $scripturl . '?action=community', 'name' => $txt['forum']);
    }
    if (!empty($context['pmx']['pageReq'])) {
        if (!isset($context['pmx']['pagenames'])) {
            $context['pmx']['pagenames'] = $txt['page_reqerror_title'];
        } else {
            if (array_key_exists('spage', $context['pmx']['pagenames']) && isset($_GET['spage'])) {
                $pmxforum[] = array('url' => $scripturl . '?spage=' . $_GET['spage'], 'name' => $context['pmx']['pagenames']['spage']);
                $context['page_title'] .= ' - ' . $context['pmx']['pagenames']['spage'];
            } else {
                if (array_key_exists('cat', $context['pmx']['pagenames']) && isset($_GET['cat'])) {
                    $pmxforum[0] = array('url' => $scripturl . '?cat=' . $_GET['cat'], 'name' => $context['pmx']['pagenames']['cat']);
                    $context['page_title'] .= ' - ' . $context['pmx']['pagenames']['cat'];
                }
                if (array_key_exists('child', $context['pmx']['pagenames']) && isset($_GET['cat']) && isset($_GET['child'])) {
                    $pmxforum[0] = array('url' => $scripturl . '?cat=' . $_GET['cat'] . ';child=' . $_GET['child'], 'name' => $context['pmx']['pagenames']['child']);
                    $context['page_title'] = $context['forum_name'] . ' - ' . $context['pmx']['pagenames']['child'];
                }
                if (array_key_exists('art', $context['pmx']['pagenames']) && isset($_GET['art'])) {
                    $context['page_title'] .= ' - ' . $context['pmx']['pagenames']['art'];
                    if (array_key_exists('child', $context['pmx']['pagenames']) && isset($_GET['cat']) && isset($_GET['child']) && isset($_GET['art'])) {
                        $pmxforum[0] = array('url' => $scripturl . '?cat=' . $_GET['cat'] . ';child=' . $_GET['child'] . ';art=' . $_GET['art'], 'name' => $context['pmx']['pagenames']['art']);
                    } elseif (array_key_exists('cat', $context['pmx']['pagenames']) && isset($_GET['cat']) && isset($_GET['art'])) {
                        $pmxforum[0] = array('url' => $scripturl . '?cat=' . $_GET['cat'] . ';art=' . $_GET['art'], 'name' => $context['pmx']['pagenames']['art']);
                    } elseif (isset($_GET['art'])) {
                        $pmxforum[0] = array('url' => $scripturl . '?art=' . $_GET['art'], 'name' => $context['pmx']['pagenames']['art']);
                    }
                }
            }
        }
    } else {
        if (!empty($_GET['action']) && $_GET['action'] == 'portamx') {
            $context['linktree'][0] = array('url' => $scripturl . '?' . pmx_http_build_query($_GET), 'name' => $txt['pmx_extension']);
        }
    }
    if (empty($pmxforum)) {
        $context['linktree'] = array_merge($pmxhome, $context['linktree']);
    } else {
        $context['linktree'] = array_merge($pmxhome, $pmxforum, $context['linktree']);
    }
}
    /**
     * ShowContent
     */
    function pmxc_ShowContent()
    {
        global $scripturl, $context, $user_info, $txt;
        echo '
				<div style="padding-bottom:4px;"' . (isset($this->cfg['config']['visuals']['questiontext']) ? ' class="' . $this->cfg['config']['visuals']['questiontext'] . '"' : '') . '>
					<a href="' . $scripturl . '?topic=' . $this->polls['topic'] . '.0"><b>' . $this->polls['question'] . '</b></a>';
        if (!empty($this->polls['is_locked']) && (!empty($this->polls['allow_view_results']) || empty($this->polls['allow_view_results']) && empty($this->polls['allow_vote']) && empty($this->polls['is_expired']))) {
            echo '<span' . (isset($this->cfg['config']['visuals']['bodytext']) ? ' class="' . $this->cfg['config']['visuals']['bodytext'] . '"' : '') . '>' . $txt['pmx_poll_select_locked'] . '</span>';
        }
        echo '
				</div>';
        if (!empty($this->polls['allow_vote'])) {
            echo '
				<div id="pxm_allowvotepoll' . $this->cfg['id'] . '"' . (!empty($this->polls['allow_view_results']) && $this->currentpoll['state'] == '1' ? ' style="display:none"' : '') . '>
					<form id="pmx_voteform' . $this->cfg['id'] . '" action="' . $scripturl . '?action=vote;topic=' . $this->polls['topic'] . ';poll=' . $this->polls['id'] . '" method="post" accept-charset="', $context['character_set'], '">
						<input type="hidden" name="poll" value="' . $this->polls['id'] . '" />
						<input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '" />
						<input type="hidden" name="pmx_votepoll" value="' . pmx_http_build_query($_GET) . '" />
						<div style="padding-top:4px;line-height:1em;">';
            $i = 0;
            foreach ($this->polls['options'] as $option) {
                echo '
							<div class="polloptions"><label id="pmx_pollopt' . $this->cfg['id'] . '_' . $i . '" style="border:none; background:transparent;" for="' . $option['id'] . '">' . $option['vote_button'] . ' <span style="vertical-align:3px;">' . $option['option'], '</span></label></div>';
                $i++;
            }
            echo '
						</div>
						<div>' . $this->polls['allowed_warning'] . '</div>';
            if (!empty($this->polls['expired'])) {
                echo '
						<div style="padding-top:4px;"><b>' . $txt['poll_expires_on'] . ':</b> ' . $this->polls['expired'] . '</div>';
            }
            echo '
						<hr class="pmx_hr" />
						<input style="margin:2px;float:right;" type="button" class="button_submit" name="button" value="' . $txt['poll_vote'] . '" onmouseup="pmx_VotePoll(\'' . $this->cfg['id'] . '\', this)" />';
            if ($this->polls['allow_view_results']) {
                echo '
						<input style="margin:2px;float:left;" type="button" class="button_submit" name="button" value="' . $txt['pmx_poll_results'] . '" onmouseup="pmx_ShowPollResult(\'' . $this->cfg['id'] . '\', this)" />';
            }
            echo '
					</form>
				</div>';
        }
        if (!empty($this->polls['allow_view_results'])) {
            echo '
				<div id="pxm_allowviewpoll' . $this->cfg['id'] . '"' . (!empty($this->polls['allow_vote']) && $this->currentpoll['state'] == '0' ? ' style="display:none"' : '') . '>
					<table class="pmx_table">';
            $tablen = 100 / $this->polls['tablen'];
            $tablen = $tablen > 100 ? 100 : $tablen;
            $ownpolls = isset($this->PollChoices[$this->polls['id']]) ? $this->PollChoices[$this->polls['id']] : array();
            // Guestpolls
            // ;id,timestamp,[vote,vote...]; etc
            $cook = pmx_getcookie('guest_poll_vote');
            if (empty($cook)) {
                $guestpolls = array();
            } else {
                $guestinfo = explode(';', trim($cook, ';'));
                // Find the poll we're after.
                foreach ($guestinfo as $i => $guestvoted) {
                    $temp = explode(',', $guestvoted);
                    if ($temp[0] != $this->polls['id']) {
                        continue;
                    } else {
                        $guestpolls[] = $temp[2];
                    }
                }
            }
            foreach ($this->polls['options'] as $key => $option) {
                $barlen = $option['percent'] == 0 ? '0' : ceil($option['percent'] * $tablen);
                $barlen = $barlen > 100 ? 100 : $barlen;
                $strong = $option['percent'] > 0 && ($user_info['is_guest'] && is_array($guestpolls) && in_array($key, $guestpolls)) || !$user_info['is_guest'] && is_array($ownpolls) && in_array($key, $ownpolls) ? array(0 => '<b>', 1 => '</b>') : array(0 => '', 1 => '');
                echo '
				<tr>
					<td style="text-align:left;height:35px;width:95%;">' . $strong[0] . $option['option'] . $strong[1] . '
						<div style="height: 10px;width:' . $barlen . '%;"' . ($barlen > 0 ? ' class="poll_bar"' : '') . '></div>
					</td>
					<td style="text-align:right;">
						<div style="margin-top:14px;white-space:nowrap;margin-left:8px;">
						 ' . $strong[0] . $option['votes'] . ' (' . $option['percent'] . '%)' . $strong[1] . '
						</div>
					</td>
				</tr>';
            }
            echo '
					</table>
					<div style="clear:both; padding-top:8px;"><b>' . $txt['poll_total_voters'] . ':</b> ' . $this->polls['total_votes'] . '</div>';
            if (!empty($this->polls['expired'])) {
                echo '
					<div style="padding-top:4px;"><b>' . (!empty($this->polls['is_expired']) ? $txt['pmx_poll_closed'] . '</b>' : $txt['poll_expires_on'] . ':</b> ' . $this->polls['expired']) . '</div>';
            }
            if (!empty($this->polls['allow_vote']) || !empty($this->polls['allow_change_vote'])) {
                echo '
					<hr class="pmx_hr" />';
                if (!empty($this->polls['allow_vote'])) {
                    echo '
						<input style="margin:2px;float:right;" type="button" class="button_submit" name="button" value="' . $txt['poll_return_vote'] . '" onmouseup="pmx_ShowPollVote(' . $this->cfg['id'] . ', ' . $this->currentpoll['id'] . ')" />';
                }
                if (!empty($this->polls['allow_change_vote'])) {
                    echo '
					<input  style="margin:2px;float:right;" type="button" class="button_submit" name="button" value="' . $txt['poll_change_vote'] . '" onmouseup="pmx_ChangePollVote(' . $this->cfg['id'] . ', this)" />
					<form id="pmx_voteform' . $this->cfg['id'] . '" action="' . $scripturl . '?action=vote;topic=' . $this->polls['topic'] . ';poll=' . $this->polls['id'] . '" method="post" accept-charset="', $context['character_set'], '">
						<input type="hidden" name="poll" value="' . $this->polls['id'] . '" />
						<input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '" />
						<input type="hidden" name="pmx_votepoll" value="' . pmx_http_build_query($_GET) . '" />
					</form>';
                }
            }
            echo '
				</div>';
        }
        if (empty($this->polls['allow_view_results']) && empty($this->polls['allow_vote']) && empty($this->polls['is_expired'])) {
            echo '
				<div style="padding:0 3px;">';
            foreach ($this->polls['options'] as $option) {
                echo '
					' . $option['option'] . '<div style="line-height:0.8em; padding-bottom:0.5em;">&nbsp;&laquo;&ndash;&raquo;</div>';
            }
            if (!empty($this->polls['expired'])) {
                echo '
					<div style="padding-top:4px;"><b>' . (!empty($this->polls['is_expired']) ? $txt['pmx_poll_closed'] . '</b>' : $txt['poll_expires_on'] . ':</b> ' . $this->polls['expired']) . '</div>';
            }
            echo '
				</div>';
            if (!empty($this->polls['allow_vote']) || !empty($this->polls['allow_change_vote'])) {
                echo '
				<hr class="pmx_hr" />';
                if (!empty($this->polls['allow_change_vote'])) {
                    echo '
				<input  style="margin:2px;float:right;" type="button" class="button_submit" name="button" value="' . $txt['poll_change_vote'] . '" onmouseup="pmx_ChangePollVote(' . $this->cfg['id'] . ', this)" />
				<form id="pmx_voteform' . $this->cfg['id'] . '" action="' . $scripturl . '?action=vote;topic=' . $this->polls['topic'] . ';poll=' . $this->polls['id'] . '" method="post" accept-charset="', $context['character_set'], '">
					<input type="hidden" name="poll" value="' . $this->polls['id'] . '" />
					<input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '" />
					<input type="hidden" name="pmx_votepoll" value="' . pmx_http_build_query($_GET) . '" />
				</form>';
                }
            }
        }
        // multiple polls enabled?
        if (count($this->pollquestions) > 1) {
            $maxwidth = in_array($this->cfg['side'], array('right', 'left')) ? '98%' : 0;
            $cact = empty($_SERVER['QUERY_STRING']) ? '' : '?' . PortaMx_makeSafe($_SERVER['QUERY_STRING']);
            echo '
				<form id="pmx_votechange' . $this->cfg['id'] . '" action="' . $scripturl . $cact . '" method="post" accept-charset="', $context['character_set'], '">
					<input id="pollchanged' . $this->cfg['id'] . '" type="hidden" name="pollchanged' . $this->cfg['id'] . '" value="' . $this->polls['id'] . '" />
					<input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '" />
					<div style="padding:5px 0 2px 0;">' . $txt['pmx_pollmultiview'] . '</div>
						<select name="pollselect"' . (!empty($maxwidth) ? ' style="width:' . $maxwidth . ';"' : '') . ' onchange="pmx_ChangeCurrentPoll(\'' . $this->cfg['id'] . '\', this);">';
            foreach ($this->pollquestions as $id => $question) {
                echo '
							<option value="' . $id . '"' . ($id == $this->currentpoll['id'] ? ' selected="selected"' : '') . '>' . $question . '</option>';
            }
            echo '
					</select>
				</form>';
        }
    }
/**
* The main Subtemplate.
*/
function template_main()
{
    global $context, $txt, $scripturl;
    $curarea = isset($_GET['area']) ? $_GET['area'] : 'pmx_center';
    if (allowPmx('pmx_admin', true)) {
        $AdmTabs = array('pmx_center' => $txt['pmx_admincenter'], 'pmx_settings' => $txt['pmx_settings'], 'pmx_blocks' => $txt['pmx_blocks'], 'pmx_categories' => $txt['pmx_categories'], 'pmx_articles' => $txt['pmx_articles'], 'pmx_sefengine' => $txt['pmx_sefengine']);
        echo '
			<div style="height:2.8em;margin-top:5px;">
				<ul id="pmxmenu_nav" class="dropmenu sf-js-enabled">';
        foreach ($AdmTabs as $name => $desc) {
            echo '
					<li id="' . $name . '" class="subsections">
						<a ' . ($name == $curarea ? 'class="active"' : '') . 'href="' . $scripturl . '?action=portamx;area=' . $name . ';' . $context['session_var'] . '=' . $context['session_id'] . '">' . $desc . '</a>
					</li>';
        }
        echo '
				</ul>
			</div>';
    }
    if (!isset($context['pmx']['articlestart'])) {
        $context['pmx']['articlestart'] = 0;
    }
    echo '
		<div class="cat_bar"><h3 class="catbg">' . $txt['pmx_adm_articles'] . '</h3></div>
		<p class="information" style="margin: 0;padding: 8px;">' . $txt['pmx_articles_desc'] . '</p>
		<div style="height:0.5em;"></div>';
    if ($context['pmx']['subaction'] == 'overview') {
        // create the pageindex
        $cururl = !empty($_GET) ? pmx_http_build_query($_GET, '', ';') . ';' : '';
        $pageindex = constructPageIndex($scripturl . '?' . $cururl . 'pg=%1$d', $context['pmx']['articlestart'], $context['pmx']['totalarticles'], $context['pmx']['settings']['manager']['artpage'], true);
        $pageindex = str_replace(';start=%1$d', '', $pageindex);
    }
    echo '
		<form id="pmx_form" accept-charset="' . $context['character_set'] . '" name="PMxAdminArticles" action="' . $scripturl . '?action=' . $context['pmx']['AdminMode'] . ';area=pmx_articles;' . $context['session_var'] . '=' . $context['session_id'] . '" method="post" style="margin: 0px;" onsubmit="submitonce(this);">
			<input type="hidden" name="sc" value="' . $context['session_id'] . '" />
			<input type="hidden" name="sa" value="' . $context['pmx']['subaction'] . '" />
			<input type="hidden" name="articlestart" value="' . $context['pmx']['articlestart'] . '" />
			<input type="hidden" name="fromblock" value="' . (!empty($context['pmx']['fromblock']) ? $context['pmx']['fromblock'] : '') . '" />
			<input type="hidden" id="pWind.all.cats" value="' . pmx_getAllCatID() . '" />
			<input id="common_field" type="hidden" value="" />
			<input id="extra_cmd" type="hidden" value="" />
			<script>
				var Art = [];
				Art["active"] = "' . $txt['pmx_status_activ'] . ' - ' . $txt['pmx_status_change'] . '";
				Art["notactive"] = "' . $txt['pmx_status_inactiv'] . ' - ' . $txt['pmx_status_change'] . '";
				Art["approved"] = "' . $txt['pmx_article_approved'] . ' - ' . $txt['pmx_status_change'] . '";
				Art["notapproved"] = "' . $txt['pmx_article_not_approved'] . ' - ' . $txt['pmx_status_change'] . '";
			</script>';
    // ---------------------
    // all articles overview
    // ---------------------
    if ($context['pmx']['subaction'] == 'overview') {
        $cfg_titleicons = PortaMx_getAllTitleIcons();
        $cfg_smfgroups = PortaMx_getUserGroups();
        $categories = PortaMx_getCategories();
        $allNames = array();
        $allGroups = array();
        foreach ($cfg_smfgroups as $key => $grp) {
            $allGroups[] = $grp['id'];
            $allNames[] = str_replace(' ', '_', $grp['name']);
        }
        // common Popup input fields
        echo '
			<input id="pWind.language." type="hidden" value="' . $context['pmx']['currlang'] . '" />
			<input id="pWind.icon.url" type="hidden" value="' . $context['pmx_Iconsurl'] . '" />
			<input id="pWind.image.url" type="hidden" value="' . $context['pmx_imageurl'] . '" />
			<input id="pWind.name" type="hidden" value="" />
			<input id="pWind.id" type="hidden" value="" />
			<input id="pWind.catsel" type="hidden" value="" />
			<input id="pWind.side" type="hidden" value="" />
			<input id="set.filter.category" type="hidden" name="filter[category]" value="' . $_SESSION['PortaMx']['filter']['category'] . '" />
			<input id="set.filter.approved" type="hidden" name="filter[approved]" value="' . $_SESSION['PortaMx']['filter']['approved'] . '" />
			<input id="set.filter.active" type="hidden" name="filter[active]" value="' . $_SESSION['PortaMx']['filter']['active'] . '" />
			<input id="set.filter.myown" type="hidden" name="filter[myown]" value="' . $_SESSION['PortaMx']['filter']['myown'] . '" />
			<input id="set.filter.member" type="hidden" name="filter[member]" value="' . $_SESSION['PortaMx']['filter']['member'] . '" />
			<input id="allAcsGroups" type="hidden" value="' . implode(',', $allGroups) . '" />
			<input id="allAcsNames" type="hidden" value="' . implode(',', $allNames) . '" />
			<div id="addnodes" style="display:none"></div>';
        $filterActive = $_SESSION['PortaMx']['filter']['category'] != '' || $_SESSION['PortaMx']['filter']['approved'] != 0 || $_SESSION['PortaMx']['filter']['active'] != 0 || $_SESSION['PortaMx']['filter']['myown'] != 0 || $_SESSION['PortaMx']['filter']['member'] != '';
        // top pageindex
        echo '
			<div class="smalltext pmx_pgidx_top">' . $pageindex . '</div>';
        echo '
			<div style="margin-bottom:-10px;">
				<div class="cat_bar catbg_grid">
					<h4 class="catbg catbg_grid">
						<span' . (allowPmx('pmx_create, pmx_articles, pmx_admin') ? ' class="pmx_clickaddnew" title="' . $txt['pmx_articles_add'] . '" onclick="SetpmxArticleType()"' : '') . '></span>
						<span class="cat_msg_title_center">' . $txt['pmx_articles_overview'] . '</span>
					</h4>
				</div>
				<div class="windowbg wdbgtop" style="margin-bottom:4px;" id="RowMove-0">
					<div class="pmx_tbl" style="margin-bottom:3px;">
						<div class="pmx_tbl_tr windowbg2 normaltext" style="height:27px;">
							<div class="pmx_tbl_tdgrid" style="width:45px;"><b>' . $txt['pmx_article_order'] . '</b></div>
							<div class="pmx_tbl_tdgrid" onclick="pWindToggleLang(\'\')" title="' . $txt['pmx_toggle_language'] . '" style="width:48%;cursor:pointer;"><b>' . $txt['pmx_title'] . ' [<b id="pWind.def.lang.">' . $context['pmx']['currlang'] . '</b>]</b></div>
							<div class="pmx_tbl_tdgrid" style="width:25%;"><b>' . $txt['pmx_articles_type'] . '</b></div>
							<div class="pmx_tbl_tdgrid" style="width:25%;"><b>' . $txt['pmx_articles_catname'] . '</b>
								<span class="pmx_' . (empty($filterActive) ? 'nofilter' : 'filter') . '" title="' . $txt['pmx_article_filter'] . '" onclick="pmxSetFilter()"></span>
							</div>
							<div class="pmx_tbl_tdgrid" style="width:84px;"><b>' . $txt['pmx_options'] . '</b></div>
							<div class="pmx_tbl_tdgrid" style="width:45px;"><b>' . $txt['pmx_status'] . '</b></div>
							<div class="pmx_tbl_tdgrid" style="width:84px;"><b>' . $txt['pmx_functions'] . '</b></div>
						</div>';
        // call PmxArticleOverview for each article
        $articleCnt = count($context['pmx']['articles']);
        $artIDs = array();
        $pgCount = 0;
        foreach ($context['pmx']['articles'] as $article) {
            if ($pgCount >= $context['pmx']['articlestart'] && $pgCount < $context['pmx']['articlestart'] + $context['pmx']['settings']['manager']['artpage']) {
                PmxArticleOverview($article, $cfg_titleicons, $cfg_smfgroups, $categories);
            }
            $pgCount++;
            $artIDs[] = $article['id'];
        }
        echo '
					</div>
					<input id="pWind.all.ids." type="hidden" value="' . implode(',', $artIDs) . '" />
				</div>
				<div style="height:30px">
					<div class="smalltext pmx_pgidx_bot">' . $pageindex . '</div>
				</div>
			</div>';
        /**
        * Popup windows for overview
        **/
        echo '
			<div style="padding:0;margin:-15px 6px 0 6px">
				<table class="pmx_table_grid" style="border-color:transparent;table-layout:fixed;">
					<tr id="popupRow">
						<td class="tdnogrid" style="width:46px;">';
        // start row move popup
        echo '
							<div id="pmxRowMove" class="smalltext" style="width:340px;z-index:9999;display:none;left:1px;margin-top:-30px;">
								' . pmx_popupHeader('pmxRowMove', $txt['pmx_rowmove_title']) . '
									<input id="pWind.move.error" type="hidden" value="' . $txt['pmx_rowmove_error'] . '" />
									<div style="float:left;width:110px;">
										' . $txt['pmx_rowmove'] . '
										<div style="margin-top:6px;">' . $txt['pmx_rowmove_place'] . '</div>
										<div style="margin-top:10px;">' . $txt['pmx_rowmove_to'] . '</div>
									</div>
									<div style="padding-left:112px;">
										<div style="margin-left:5px; margin-top:2px;" id="pWind.move.pos"></div>
										<div style="margin-top:5px;">
											<input id="pWind.place.0" class="input_radio" type="radio" name="_" value="before" /><span style="padding:0 3px;">' . $txt['pmx_rowmove_before'] . '</span>
											<input id="pWind.place.1" class="input_radio" type="radio" name="_" value="after" checked="checked" /><span style="padding:0 3px;">' . $txt['pmx_rowmove_after'] . '</span><br />
										</div>
										<select id="pWind.sel" style="width:190px; margin-top:8px; margin-left:5px;" size="1">';
        foreach ($context['pmx']['article_rows'] as $id => $data) {
            echo '
											<option value="' . $id . '">[' . $id . '] ' . $data['name'] . ' (' . (empty($data['cat']) ? $txt['pmx_default_none'] : $data['cat']) . ')</option>';
        }
        echo '
										</select>
									</div>
									<div style="clear:both; text-align:right; margin-top:7px;">
										<input class="button_submit" type="button" value="' . $txt['pmx_save'] . '" onclick="pmxSendArtMove()" />
										<div style="height:20px;"></div>
									</div>
								</div>
							</div>';
        // end Move popup
        echo '	</td>
						<td class="tdnogrid" style="width:48%;">';
        // start title edit popup
        echo '
							<div id="pmxSetTitle" class="smalltext" style="width:420px;z-index:9999;display:none;margin-top:-30px;">
								' . pmx_popupHeader('pmxSetTitle', $txt['pmx_edit_titles'], '112px') . '
									<div style="float:left; width:75px;">' . $txt['pmx_edit_title'] . '</div>
									<input id="pWind.text" style="width:310px;" type="text" value="" />
									<input id="pWindID" type="hidden" value="" />
									<div style="clear:both; height:10px;">
										<img style="float:left;margin-top:-3px;" src="' . $context['pmx_imageurl'] . 'arrow_down.gif" alt="*" title="" />
									</div>
									<div style="float:left; width:75px;">' . $txt['pmx_edit_title_lang'] . '</div>
									<select id="pWind.lang.sel" style="float:left; width:165px;" size="1" onchange="pmxChgTitles_Lang(this)">';
        // languages
        foreach ($context['pmx']['languages'] as $lang => $sel) {
            echo '
										<option value="' . $lang . '">' . $lang . '</option>';
        }
        echo '
									</select>
									<div style="float:right;padding-right:1px;"><span style="vertical-align:6px;">' . $txt['pmx_edit_title_align'] . '</span>';
        // Title align
        foreach ($txt['pmx_edit_title_align_types'] as $key => $val) {
            echo '
										<img id="pWind.align.' . $key . '" src="' . $context['pmx_imageurl'] . 'text_align_' . $key . '.gif" alt="*" title="' . $txt['pmx_edit_title_helpalign'] . $val . '" style="vertical-align:2px; cursor:pointer;" onclick="pmxChgTitles_Align(\'' . $key . '\')" />';
        }
        echo '
									</div>
									<br style="clear:both;" />
									<input style="float:right; margin-top:9px;margin-right:1px;" class="button_submit" type="button" value="' . $txt['pmx_update_save'] . '"  onclick="pmxUpdateTitles()" />
									<div style="float:left;width:75px; padding-top:8px;">' . $txt['pmx_edit_titleicon'] . '</div>';
        // Title icons
        echo '
									<div class="ttliconDiv" onclick="setNewIcon(document.getElementById(\'pWind.icon_sel\'), event)">
										<input id="post_image" type="hidden" name="config[title_icon]" value="" />
										<input id="iconDD" value="' . (isset($article['config']['title_icon']) ? ucfirst(str_replace('.png', '', $article['config']['title_icon'])) : 'None') . '" readonly />
										<img id="pWind.icon" class="pwindicon" src="' . $context['pmx_shortIconsurl'] . 'none.png" alt="*" />
										<img class="ddImage" src="' . $context['pmx_imageurl'] . 'state_expanded.png" alt="*" title="" />
									</div>
									<ul class="ttlicondd" id="pWind.icon_sel" onclick="updIcon(this)">';
        foreach ($cfg_titleicons as $file => $name) {
            echo '
										<li id="' . $file . '" class="ttlicon' . (isset($article['config']['title_icon']) && $article['config']['title_icon'] == $file ? ' active' : '') . '">
											<img src="' . $context['pmx_shortIconsurl'] . $file . '" alt="*" /><span>' . $name . '</span>
										</li>';
        }
        echo '
									</ul>
									<script>$("li").hover(function(){$(this).toggleClass("active")});</script>
								</div>
							</div>';
        // end title edit popup
        echo '
						</td>
						<td class="tdnogrid" style="width:25%;"></td>
						<td class="tdnogrid" style="width:25%;">';
        // categorie popup
        echo '
							<div id="pmxSetCats" class="smalltext" style="z-index:9999;width:220px;margin-top:-30px;display:none;">
								' . pmx_popupHeader('pmxSetCats', $txt['pmx_category_popup']) . '
									<select id="pWind.cats.sel" onchange="pmxChgCats(this)" style="width:100%;" size="6">';
        $selcats = array_merge(array(PortaMx_getDefaultCategory($txt['pmx_categories_none'])), $categories);
        $ordercats = array_merge(array(0), $context['pmx']['catorder']);
        $isWriter = allowPmx('pmx_create, pmx_articles', true);
        $isAdm = allowPmx('pmx_admin');
        $allcats = array();
        foreach ($ordercats as $catorder) {
            $cat = PortaMx_getCatByOrder($selcats, $catorder);
            $cfg = unserialize($cat['config']);
            // allcats html
            $details = PortaMx_getCatDetails($cat, $categories);
            $allcats[] = $cat['id'] . '|<div class="' . $details['class'] . '"><b>' . $details['level'] . '</b><span><span class="cat_names">' . $cat['name'] . '</span></span></div>';
            if (!empty($isAdm) || !empty($isWriter) && empty($cfg['global'])) {
                if (empty($cat)) {
                    $cat['id'] = 0;
                    $cat['name'] = $txt['pmx_categories_none'];
                }
                $details['parent'] .= $txt['pmx_chg_articlcats'];
                echo '
										<option value="' . $cat['id'] . '">' . str_repeat('&bull;', $cat['level']) . ' ' . $cat['name'] . '</option>';
            }
        }
        echo '
									</select><br />
									<div style="text-align:right;margin-top:7px;">
										<input class="button_submit" type="button" value="' . $txt['pmx_update_save'] . '" onclick="pmxUpdateCats()" />&nbsp;
										<input class="button_submit" type="button" value="' . $txt['pmx_update_all'] . '" onclick="pmxUpdateCats(\'all\')" />
									</div>
								</div>
							</div>';
        // end categorie popup
        // start filter popup
        echo '
							<div id="pmxSetFilter" class="smalltext" style="width:280px;z-index:9999;margin-top:-60px;padding-top:36px;display:none;">
								' . pmx_popupHeader('pmxSetFilter', $txt['pmx_article_setfilter']) . '
									<div style="padding-bottom:3px; margin-top:-4px;">' . $txt['pmx_article_filter_category'] . '<span style="float:right; cursor:pointer" onclick="pmxSetFilterCatClr()">[<b>' . $txt['pmx_article_filter_categoryClr'] . '</b>]</span></div>
									<select id="pWind.filter.category" style="width:100%;" size="4" multiple="multiple">';
        $selcats = array_merge(array(PortaMx_getDefaultCategory($txt['pmx_categories_none'])), $categories);
        $ordercats = array_merge(array(0), $context['pmx']['catorder']);
        $catfilter = Pmx_StrToArray($_SESSION['PortaMx']['filter']['category']);
        $isWriter = allowPmx('pmx_create, pmx_articles', true);
        $isAdm = allowPmx('pmx_admin');
        foreach ($ordercats as $catorder) {
            $cat = PortaMx_getCatByOrder($selcats, $catorder);
            $cfg = unserialize($cat['config']);
            if (!empty($isAdm) || !empty($isWriter) && empty($cfg['global'])) {
                echo '
									<option value="' . $cat['id'] . '"' . (in_array($cat['id'], $catfilter) ? ' selected="selected"' : '') . '>' . str_repeat('&bull;', $cat['level']) . ' ' . $cat['name'] . '</option>';
            }
        }
        echo '
								</select><br />
								<div style="height:22px;padding-top:4px;">
									' . $txt['pmx_article_filter_approved'] . '
									<input id="pWind.filter.approved" style="float:right;" class="input_check" type="checkbox" value="1"' . (!empty($_SESSION['PortaMx']['filter']['approved']) ? ' checked="checked"' : '') . ' />
								</div>
								<div style="height:22px;">
									' . $txt['pmx_article_filter_active'] . '
									<input id="pWind.filter.active" style="float:right;" class="input_check" type="checkbox" value="1"' . (!empty($_SESSION['PortaMx']['filter']['active']) ? ' checked="checked"' : '') . ' />
								</div>';
        if (allowPmx('pmx_articles, pmx_admin')) {
            echo '
								<div style="height:22px;">
									' . $txt['pmx_article_filter_myown'] . '
									<input id="pWind.filter.myown" style="float:right;" class="input_check" type="checkbox" value="1"' . (!empty($_SESSION['PortaMx']['filter']['myown']) ? ' checked="checked"' : '') . ' />
								</div>
								<div style="height:18px;">
									' . $txt['pmx_article_filter_member'] . '
									<input id="pWind.filter.member" style="float:right;width:130px;" class="input_text" type="text" value="' . $_SESSION['PortaMx']['filter']['member'] . '" />
								</div>' . $txt['pmx_article_filter_membername'];
        }
        echo '
								<div style="text-align:right;margin-top:-5px;">
									<input class="button_submit" type="button" value="' . $txt['set_article_filter'] . '" onclick="pmxSendFilter()" />
									<div style="height:20px;"></div>
								</div>
							</div>
						</div>';
        $filterActive = $_SESSION['PortaMx']['filter']['category'] != '' || $_SESSION['PortaMx']['filter']['approved'] != 0 || $_SESSION['PortaMx']['filter']['active'] != 0 || $_SESSION['PortaMx']['filter']['myown'] != 0 || $_SESSION['PortaMx']['filter']['member'] != '';
        // end filter popup
        echo '
						</td>
						<td class="tdnogrid" style="width:63px;"></td>
						<td class="tdnogrid" style="width:45px;"></td>
						<td class="tdnogrid" style="width:84px;">';
        // start blocktype selection popup
        $RegBlocks = $context['pmx']['RegBlocks'];
        foreach ($RegBlocks as $key => $val) {
            if (!in_array($key, array('html', 'script', 'bbc_script', 'php'))) {
                unset($RegBlocks[$key]);
            }
        }
        function cmpBDesc($a, $b)
        {
            return strcasecmp(str_replace(' ', '', $a["description"]), str_replace(' ', '', $b["description"]));
        }
        uasort($RegBlocks, 'cmpBDesc');
        // start articletype selection popup
        echo '
							<div id="pmxArticleType" class="smalltext" style="width:220px;z-index:9999;margin-top:-30px;display:none;">
								' . pmx_popupHeader('pmxArticleType', $txt['pmx_add_new_articletype'], '65px') . '
									<div style="margin:-4px 0 5px 0;">' . $txt['pmx_articles_articletype'] . '</div>
									<select id="pmx.article.type" style="width:120px;" size="1">';
        foreach ($RegBlocks as $type => $articleType) {
            echo '
										<option value="' . $type . '">' . $articleType['description'] . '</option>';
        }
        echo '
									</select>
									<div style="text-align:right; margin-top:-23px;">
										<input class="button_submit" type="button" value="' . $txt['pmx_create'] . '" onclick="pmxSendArticleType()" />
									</div>
								</div>
							</div>';
        // end popup
        // start Access popup
        echo '
							<div id="pmxSetAcs" class="smalltext" style="width:210px;z-index:9999;display:none;margin-top:-30px;">
								' . pmx_popupHeader('pmxSetAcs', $txt['pmx_article_groups']) . '
									<div style="height:15px;margin-top:-5px;">
										<input id="pWindAcsModeupd" onclick="pmxSetAcsMode(\'upd\')" class="input_check" type="radio" name="_" value="" /><span style="vertical-align:3px; padding:0 3px;">' . $txt['pmx_acs_repl'] . '</span>
									</div>
									<div style="height:15px;">
										<input id="pWindAcsModeadd" onclick="pmxSetAcsMode(\'add\')" class="input_check" type="radio" name="_" value="" /><span style="vertical-align:3px; padding:0 3px;">' . $txt['pmx_acs_add'] . '</span>&nbsp;&nbsp;
									</div>
									<div style="height:15px;margin-bottom:10px;">
										<input id="pWindAcsModedel" onclick="pmxSetAcsMode(\'del\')" class="input_check" type="radio" name="_" value="" /><span style="vertical-align:3px; padding:0 3px;">' . $txt['pmx_acs_rem'] . '</span>
									</div>
									<select id="pWindAcsGroup" style="width:100%;" multiple="multiple" size="6" onchange="changed(\'pWindAcsGroup\');">';
        foreach ($cfg_smfgroups as $grp) {
            echo '
										<option value="' . $grp['id'] . '=1">' . $grp['name'] . '</option>';
        }
        echo '
									</select><br />
									<script type="text/javascript">
										var pWindAcsGroup = new MultiSelect("pWindAcsGroup");
									</script>
									<div style="text-align:right; margin-top:7px;">
										<input class="button_submit" type="button" value="' . $txt['pmx_update_save'] . '" onclick="pmxUpdateAcs()" />&nbsp;
										<input id="acs_all_button" class="button_submit" type="button" value="' . $txt['pmx_update_all'] . '" onclick="pmxUpdateAcs(\'all\')" />
									</div>
								</div>
							</div>';
        // end Access popup
        // start clone popup
        echo '
							<div id="pmxSetArtClone" class="smalltext" style="width:220px;z-index:9999;margin-top:-30px;display:none;">
								' . pmx_popupHeader('pmxSetArtClone', $txt['pmx_art_clone']) . '
									<div>' . $txt['pmx_confirm_artclone'] . '</div>
									<input id="pWind.artcloneid" type="hidden" value="" />
									<input style="float:right;font-size:11px;font-weight:bold;margin-top:5px;" class="button_submit" type="button" value="' . $txt['pmx_delete_button'] . '" onclick="pmxSendArtClone()" />
									<div style="height:25px;"></div>
								</div>
							</div>';
        // end clone popup
        // start delete popup
        echo '
							<div id="pmxSetArtDelete" class="smalltext" style="width:220px;z-index:9999;margin-top:-30px;display:none;">
								' . pmx_popupHeader('pmxSetArtDelete', $txt['pmx_art_delete']) . '
									<div>' . $txt['pmx_confirm_artdelete'] . '</div>
									<input id="pWind.artdelid" type="hidden" value="" />
									<input style="float:right;font-size:11px;font-weight:bold;margin-top:5px;" class="button_submit" type="button" value="' . $txt['pmx_delete_button'] . '" onclick="pmxSendArtDelete()" />
									<div style="height:25px;"></div>
								</div>
							</div>';
        // end delete popup
        echo '
						</td>
						<td class="tdnogrid" style="width:84px;"></td>
					</tr>
				</table>
			</div>';
    } elseif ($context['pmx']['subaction'] == 'edit' || $context['pmx']['subaction'] == 'editnew') {
        echo '
			<table class="pmx_table" style="margin-bottom:5px;table-layout:fixed;">
				<tr>
					<td style="text-align:center">
						<div class="cat_bar" style="border-bottom-left-radius:6px;border-bottom-right-radius:6px">
							<h3 class="catbg">
							' . $txt['pmx_article_edit'] . ' ' . $txt['pmx_articles_types'][$context['pmx']['editarticle']->cfg['ctype']] . '
							</h3>
						</div>
					</td>
				</tr>';
        // call the ShowAdmArticleConfig() methode
        $context['pmx']['editarticle']->pmxc_ShowAdmArticleConfig();
        echo '
			</table>';
    }
    echo '
		</form>';
}
/**
* Add menu to MenuContext
* Called from hook integrate_menu_buttons
**/
function PortaMx_MenuContext(&$menudata)
{
    global $txt, $context, $modSettings, $scripturl, $boarddir;
    if (empty($modSettings['pmxportal_disabled'])) {
        // Init the Portal if not loaded
        if (!defined('PortaMx')) {
            PortaMx(true);
        }
        // add community button after 'home'
        $fnd = array_search('home', array_keys($menudata)) + 1;
        if (!empty($context['pmx']['showhome'])) {
            $menudata = array_merge(array_slice($menudata, 0, $fnd), array('community' => array('title' => $txt['forum'], 'href' => $scripturl . '?action=community', 'icon' => '<span class="generic_icons community"></span>', 'active_button' => false, 'sub_buttons' => array())), array_slice($menudata, $fnd, count($menudata) - $fnd));
            $fnd++;
        }
        // add download button if enabled and accessible
        $dlact = array(0 => '', 1 => '');
        $dlactErr = array(0 => '', 1 => '');
        $dlaccess = isset($context['pmx']['settings']['dl_access']) ? $context['pmx']['settings']['dl_access'] : '';
        if (allowPmxGroup($dlaccess) && !empty($context['pmx']['settings']['download']) && preg_match('/(p:|c:|a:|)(.*)$/i', $context['pmx']['settings']['dl_action'], $match) > 0) {
            if ($match[1] == 'a:') {
                $dlact = array(0 => 'art', 1 => $match[2]);
            } elseif ($match[1] == 'c:') {
                $dlact = array(0 => 'cat', 1 => $match[2]);
            } elseif ($match[1] == 'p:') {
                $dlact = array(0 => 'spage', 1 => $match[2]);
            } else {
                $dlact = array(0 => 'action', 1 => $match[2]);
            }
            if (!empty($_REQUEST['pmxerror']) && in_array($_REQUEST['pmxerror'], array('acs', 'fail'))) {
                $dlactErr = array(0 => 'pmxerror', 1 => $_REQUEST['pmxerror']);
            }
            $menudata = array_merge(array_slice($menudata, 0, $fnd), array('download' => array('title' => $txt['download'], 'href' => $scripturl . '?' . $dlact[0] . '=' . $dlact[1], 'icon' => '<span class="generic_icons download"></span>', 'active_button' => false, 'sub_buttons' => array())), array_slice($menudata, $fnd, count($menudata) - $fnd));
            if (isset($_REQUEST[$dlact[0]]) && $_REQUEST[$dlact[0]] == $dlact[1] || isset($_REQUEST[$dlactErr[0]]) && $_REQUEST[$dlactErr[0]] == $dlactErr[1]) {
                $context['current_action'] = 'download';
            }
        }
        // add admin submenu before 'featuresettings'
        if (!empty($context['allow_admin'])) {
            $curract = pmx_http_build_query($_GET);
            $fnd = array_search('featuresettings', array_keys($menudata['admin']['sub_buttons']));
            $menudata['admin']['sub_buttons'] = array_merge(array_slice($menudata['admin']['sub_buttons'], 0, $fnd), array('pmx_center' => array('title' => $txt['pmx_extension'], 'href' => $scripturl . '?action=admin;area=pmx_center;' . $context['session_var'] . '=' . $context['session_id'], 'show' => $context['allow_admin'], 'sub_buttons' => array('pmxcenter' => array('title' => $txt['pmx_admincenter'], 'href' => $scripturl . '?action=admin;area=pmx_center;' . $context['session_var'] . '=' . $context['session_id'], 'show' => $context['allow_admin']), 'pmxsettings' => array('title' => $txt['pmx_settings'], 'href' => $scripturl . '?action=admin;area=pmx_settings;sa=globals;' . $context['session_var'] . '=' . $context['session_id'], 'show' => $context['allow_admin']), 'pmxblocks' => array('title' => $txt['pmx_blocks'], 'href' => $scripturl . '?action=admin;area=pmx_blocks;sa=all;' . $context['session_var'] . '=' . $context['session_id'], 'show' => $context['allow_admin']), 'pmxcategories' => array('title' => $txt['pmx_categories'], 'href' => $scripturl . '?action=admin;area=pmx_categories;' . $context['session_var'] . '=' . $context['session_id'], 'show' => $context['allow_admin']), 'pmxarticles' => array('title' => $txt['pmx_articles'], 'href' => $scripturl . '?action=admin;area=pmx_articles;' . $context['session_var'] . '=' . $context['session_id'], 'show' => $context['allow_admin']), 'pmxsefengine' => array('title' => $txt['pmx_sefengine'], 'href' => $scripturl . '?action=admin;area=pmx_sefengine;' . $context['session_var'] . '=' . $context['session_id'], 'show' => $context['allow_admin']), 'pmxlanguages' => array('title' => $txt['pmx_languages'], 'href' => $scripturl . '?action=admin;area=pmx_languages;' . $context['session_var'] . '=' . $context['session_id'], 'show' => $context['allow_admin']), 'pmxcache' => array('title' => $txt['pmx_cache'], 'href' => $scripturl . '?action=admin;area=pmx_cache;' . $context['session_var'] . '=' . $context['session_id'], 'show' => $context['allow_admin'] && is_dir($boarddir . '/cachepmx'))))), array_slice($menudata['admin']['sub_buttons'], $fnd, count($menudata['admin']['sub_buttons']) - $fnd));
            foreach ($menudata['admin']['sub_buttons']['pmx_center']['sub_buttons'] as $button => $value) {
                if (empty($value['show'])) {
                    unset($menudata['admin']['sub_buttons']['pmx_center']['sub_buttons'][$button]);
                }
            }
        } else {
            if (allowedTo('profile_view_own') && allowPmx('pmx_admin, pmx_blocks, pmx_articles, pmx_create', true)) {
                $fnd = array_search('mlist', array_keys($menudata));
                $menudata = array_merge(array_slice($menudata, 0, $fnd), array('portamx' => array('title' => $txt['pmx_extension'], 'icon' => '<span class="generic_icons adm_center"></span>', 'href' => '', 'active_button' => false, 'sub_buttons' => array('pmxcenter' => array('title' => $txt['pmx_admincenter'], 'href' => $scripturl . '?action=portamx;area=pmx_center;' . $context['session_var'] . '=' . $context['session_id'], 'show' => allowPmx('pmx_admin', true)), 'pmxsettings' => array('title' => $txt['pmx_settings'], 'href' => $scripturl . '?action=portamx;area=pmx_settings;' . $context['session_var'] . '=' . $context['session_id'], 'show' => allowPmx('pmx_admin', true)), 'pmxblocks' => array('title' => $txt['pmx_blocks'], 'href' => $scripturl . '?action=portamx;area=pmx_blocks;' . $context['session_var'] . '=' . $context['session_id'], 'show' => allowPmx('pmx_admin, pmx_blocks', true)), 'pmxcategories' => array('title' => $txt['pmx_categories'], 'href' => $scripturl . '?action=portamx;area=pmx_categories;' . $context['session_var'] . '=' . $context['session_id'], 'show' => allowPmx('pmx_admin', true)), 'pmxarticles' => array('title' => $txt['pmx_articles'], 'href' => $scripturl . '?action=portamx;area=pmx_articles;' . $context['session_var'] . '=' . $context['session_id'], 'show' => allowPmx('pmx_admin, pmx_articles, pmx_create', true)), 'pmxsefengine' => array('title' => $txt['pmx_sefengine'], 'href' => $scripturl . '?action=portamx;area=pmx_sefengine;' . $context['session_var'] . '=' . $context['session_id'], 'show' => allowPmx('pmx_admin', true)), 'pmxcache' => array('title' => $txt['pmx_cache'], 'href' => $scripturl . '?action=portamx;area=pmx_cache;' . $context['session_var'] . '=' . $context['session_id'], 'show' => allowPmx('pmx_admin, pmx_blocks, pmx_articles, pmx_create', true) && is_dir($boarddir . '/cachepmx'))))), array_slice($menudata, $fnd, count($menudata) - $fnd));
                foreach ($menudata['portamx']['sub_buttons'] as $button => $value) {
                    if (empty($value['show'])) {
                        unset($menudata['portamx']['sub_buttons'][$button]);
                    }
                }
            }
        }
        /**
         * Highlight the active button
         **/
        // SimpleDesk stand alone mode ?
        if (!empty($context['pmx']['showhome'])) {
            if (isset($_REQUEST['board']) || isset($_REQUEST['topic'])) {
                $context['current_action'] = 'community';
            } elseif (!empty($_REQUEST['action']) && in_array($_REQUEST['action'], array('community', 'recent', 'unreadreplies', 'unread', 'who', 'collapse'))) {
                $context['current_action'] = 'community';
            }
        } elseif (!empty($context['pmx']['showhome'])) {
            if (empty($_REQUEST['action']) && empty($_REQUEST['board']) && empty($_REQUEST['topic'])) {
                $context['current_action'] = 'home';
            }
        }
        // Highlight the profile button on this..
        if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'portamx' && allowPmx('pmx_admin, pmx_blocks, pmx_articles, pmx_create', true)) {
            $context['current_action'] = 'portamx';
        }
    }
}