/**
  * AdmBlock_init().
  * Setup caching and classdef.
  */
 function pmxc_AdmBlock_init()
 {
     $this->block_classdef = PortaMx_getdefaultClass(true);
     // extended classdef
     $this->can_cached = 1;
     // enable caching
 }
    /**
     * AdmBlock_init().
     * Setup caching and returns the language file name.
     */
    function pmxc_AdmBlock_init()
    {
        global $context, $modSettings, $smcFunc;
        // get all subject for select
        $padlen = 0;
        $this->posts = array();
        if (!empty($context['pmx']['promotes'])) {
            $request = $smcFunc['db_query']('', '
				SELECT id_msg, subject
				FROM {db_prefix}messages
				WHERE id_msg IN ({array_int:messages})' . ($modSettings['postmod_active'] ? ' AND approved = {int:is_approved}' : '') . '
				ORDER BY id_msg DESC', array('messages' => $context['pmx']['promotes'], 'is_approved' => 1));
            while ($row = $smcFunc['db_fetch_assoc']($request)) {
                censorText($row['subject']);
                $padlen = $padlen == 0 ? strlen($row['id_msg']) : $padlen;
                $this->posts[$row['id_msg']] = '[' . str_pad($row['id_msg'], $padlen, ' ', STR_PAD_LEFT) . '] ' . $row['subject'];
            }
            $smcFunc['db_free_result']($request);
        }
        if (empty($this->cfg['config']['settings']['posts'])) {
            $this->cfg['config']['settings']['posts'] = array();
        }
        $this->block_classdef = PortaMx_getdefaultClass(true);
        // extended classdef
        $this->can_cached = 1;
        // enable caching
    }
    /**
     * This Methode is called on loadtime.
     * After all variables initiated, it calls the block dependent init methode.
     * Finaly the css is loaded if exist
     */
    function pmxc_AdmArticle_loadinit()
    {
        $this->smf_groups = PortaMx_getUserGroups();
        // get all usergroups
        $this->title_icons = PortaMx_getAllTitleIcons();
        // get all title icons
        $this->custom_css = PortaMx_getCustomCssDefs();
        // custom css definitions
        $this->usedClass = PortaMx_getdefaultClass(false, true);
        // default class types
        $this->categories = PortaMx_getCategories();
        // exist categories
        if ($this->cfg['ctype'] == 'php') {
            addInlineJavascript(str_replace("\n", "\n\t", PortaMx_compressJS('
			function php_syntax(elmid)
			{
				document.getElementById("check_" + elmid).className = "info_frame";
				var result = pmx_setCookie("pmx_php_check", document.getElementById(elmid).value, "php_snytax", false);
				result = result.replace(/@elm@/g, elmid);
				document.getElementById("check_" + elmid).innerHTML = result;
				Show_help("check_" + elmid);

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

					if(document.getElementById(elmid).setSelectionRange)
					{
						document.getElementById(elmid).focus();
						document.getElementById(elmid).setSelectionRange(count, count+lines[i].length);
					}
					else if(document.getElementById(elmid).createTextRange)
					{
						range=document.getElementById(elmid).createTextRange();
						range.collapse(true);
						range.moveStart("character", count);
						range.moveEnd("character", count+lines[i].length);
						range.select();
					}
				}
			}')));
        }
    }
 /**
  * This Methode is called on loadtime.
  * After all variables initiated, it calls the block dependent init methode.
  * Finaly the css is loaded if exist
  */
 function pmxc_AdmCategories_loadinit()
 {
     $this->smf_groups = PortaMx_getUserGroups();
     // get all usergroups
     $this->title_icons = PortaMx_getAllTitleIcons();
     // get all title icons
     $this->custom_css = PortaMx_getCustomCssDefs();
     // custom css definitions
     $this->usedClass = PortaMx_getdefaultClass(false, true);
     // default class types
     $this->categories = PortaMx_getCategories();
     // exist categories
 }
    /**
     * AdmBlock_settings().
     * Setup the config vars and output the block settings.
     * Returns the css classes they are used.
     */
    function pmxc_AdmBlock_settings()
    {
        global $context, $txt;
        // define the settings options
        echo '
					<td valign="top" style="padding:4px;">
						<div style="min-height:195px;">
							<input type="hidden" name="config[settings]" value="" />
							<input type="hidden" name="config[static_block]" value="1" />';
        // show the settings screen
        echo '
							<div class="cat_bar catbg_grid grid_padd">
								<h4 class="catbg catbg_grid"><span class="cat_left_title">' . sprintf($txt['pmx_blocks_settings_title'], $this->register_blocks[$this->cfg['blocktype']]['description']) . '</span></h4>
							</div>
							<div class="adm_input adm_sel">
								<span>' . $txt['pmx_catblock_cats'] . '</span>
								<select style="width:83%" name="config[settings][category]" size="1">';
        // output cats
        foreach ($context['pmx']['catorder'] as $order) {
            $cat = PortaMx_getCatByOrder($this->categories, $order);
            echo '
									<option value="' . $cat['name'] . '"' . (isset($this->cfg['config']['settings']['category']) && $this->cfg['config']['settings']['category'] == $cat['name'] ? ' selected="selected"' : '') . '>' . str_repeat('&bull;', $cat['level']) . ' ' . $cat['name'] . '</option>';
        }
        echo '
								</select>
							</div>';
        // show mode (titelbar/frame)
        $this->cfg['config']['settings']['usedframe'] = !isset($this->cfg['config']['settings']['usedframe']) ? 'block' : $this->cfg['config']['settings']['usedframe'];
        echo '
							<div class="adm_check">
								<span class="adm_w80">' . $txt['pmx_catblock_blockframe'] . '</span>
								<div><input class="input_check" type="radio" name="config[settings][usedframe]" value="block"' . (isset($this->cfg['config']['settings']['usedframe']) && $this->cfg['config']['settings']['usedframe'] == 'block' ? ' checked="checked"' : '') . ' /></div>
							</div>
							<div class="adm_check">
								<span class="adm_w80">' . $txt['pmx_catblock_catframe'] . '</span>
								<div><input class="input_check" type="radio" name="config[settings][usedframe]" value="cat"' . (isset($this->cfg['config']['settings']['usedframe']) && $this->cfg['config']['settings']['usedframe'] == 'cat' ? ' checked="checked"' : '') . ' /></div>
							</div>
							<div class="adm_check">
								<span class="adm_w80">' . $txt['pmx_catblock_inherit'] . '
									<img class="info_toggle" onclick=\'Show_help("pmxcatH01")\' src="' . $context['pmx_imageurl'] . 'information.png" alt="*" title="' . $txt['pmx_information_icon'] . '" />
								</span>
								<input type="hidden" name="config[settings][inherit_acs]" value="0" />
								<div><input class="input_check" type="checkbox" name="config[settings][inherit_acs]" value="1"' . (!empty($this->cfg['config']['settings']['inherit_acs']) ? ' checked="checked"' : '') . ' /></div>
							</div>
							<div id="pmxcatH01" class="info_frame" style="margin-top:4px;">' . $txt['pmx_catblock_inherithelp'] . '</div>
							<input type="hidden" name="config[show_sitemap]" value="0" />
						</div>';
        // return the used classnames
        return PortaMx_getdefaultClass(false, true);
        // default classdef
    }
 /**
  * This Methode is called on loadtime.
  * After all variables initiated, it calls the block dependent init methode.
  * Finaly the css and language is loaded if exist
  */
 function pmxc_AdmBlock_loadinit()
 {
     global $context;
     $this->smf_themes = PortaMx_getsmfThemes();
     // get all themes
     $this->smf_groups = PortaMx_getUserGroups();
     // get all usergroups
     $this->smf_boards = PortaMx_getsmfBoards();
     // get all smf boards
     $this->register_blocks = $context['pmx']['RegBlocks'];
     // get all registered block
     $this->block_classdef = PortaMx_getdefaultClass();
     // get default classes
     $this->title_icons = PortaMx_getAllTitleIcons();
     // get all title icons
     $this->custom_css = PortaMx_getCustomCssDefs();
     // custom css definitions
     $this->can_cached = 0;
     // default no caching
     // sort the registered blocks
     ksort($this->register_blocks, SORT_STRING);
     // call the blockdepend init methode
     $this->pmxc_AdmBlock_init();
 }