PHPFusion\QuantumFields::display_module_form PHP Méthode

display_module_form() private méthode

Modules Form
private display_module_form ( )
    private function display_module_form()
    {
        global $aidlink;
        $form_action = FUSION_SELF . $aidlink;
        if ($this->module_debug == TRUE) {
            $this->debug = TRUE;
        }
        if (isset($_GET['action']) && $_GET['action'] == 'module_edit' && isset($_GET['module_id']) && isnum($_GET['module_id'])) {
            $form_action .= "&action=" . $_GET['action'] . "&module_id=" . $_GET['module_id'];
            $result = dbquery("SELECT * FROM " . $this->field_db . " WHERE field_id='" . $_GET['module_id'] . "'");
            if (dbrows($result) > 0) {
                $this->field_data = dbarray($result);
                if ($this->debug) {
                    print_p('Old Data');
                    print_p($this->field_data);
                }
            } else {
                if (!$this->debug) {
                    addNotice('warning', $this->locale['field_0205']);
                    redirect(FUSION_SELF . $aidlink);
                }
            }
        }
        $this->field_data['add_module'] = isset($_POST['add_module']) ? form_sanitizer($_POST['add_module']) : $this->field_data['field_name'];
        $user_field_name = '';
        $user_field_api_version = '';
        $user_field_desc = '';
        $user_field_dbname = '';
        $user_field_dbinfo = '';
        if (file_exists($this->plugin_locale_folder . stripinput($this->field_data['add_module']) . ".php") && file_exists($this->plugin_folder . stripinput($this->field_data['add_module']) . "_include_var.php")) {
            include $this->plugin_locale_folder . stripinput($this->field_data['add_module']) . ".php";
            include $this->plugin_folder . stripinput($this->field_data['add_module']) . "_include_var.php";
            $this->user_field_dbinfo = $user_field_dbinfo;
            if (!isset($user_field_dbinfo)) {
                addNotice('warning', $this->locale['fields_0602']);
            }
        } else {
            \defender::stop();
            addNotice('danger', $this->locale['fields_0109']);
        }
        // Script Execution
        if (isset($_POST['enable'])) {
            $this->field_data = array('add_module' => isset($_POST['add_module']) ? form_sanitizer($_POST['add_module']) : $this->field_data['field_name'], 'field_type' => 'file', 'field_id' => isset($_POST['field_id']) ? form_sanitizer($_POST['field_id'], '', 'field_id') : isset($_GET['module_id']) && isnum($_GET['module_id']) ? $_GET['module_id'] : 0, 'field_title' => form_sanitizer($_POST['field_title'], '', 'field_title'), 'field_name' => form_sanitizer($_POST['field_name'], '', 'field_name'), 'field_cat' => form_sanitizer($_POST['field_cat'], '', 'field_cat'), 'field_default' => form_sanitizer($_POST['field_default'], '', 'field_default'), 'field_error' => form_sanitizer($_POST['field_error'], '', 'field_error'), 'field_required' => isset($_POST['field_required']) ? 1 : 0, 'field_registration' => isset($_POST['field_registration']) ? 1 : 0, 'field_log' => isset($_POST['field_log']) ? 1 : 0, 'field_order' => form_sanitizer($_POST['field_order'], '0', 'field_order'));
            $this->field_data['field_name'] = str_replace(' ', '_', $this->field_data['field_name']);
            // make sure no space.
            $this->create_fields($this->field_data, 'module');
        }
        echo "<div class='m-t-20'>\n";
        echo openform('fieldform', 'post', $form_action, array('max_tokens' => 1));
        echo "<p class='strong text-dark'>" . $user_field_name . "</p>\n";
        echo "<div class='well'>\n";
        echo "<p class='strong'>" . $this->locale['fields_0400'] . "</p>\n";
        echo "<span class='text-dark strong'>" . $this->locale['fields_0401'] . "</span> " . ($user_field_api_version ? $user_field_api_version : $this->locale['fields_0402']) . "<br/>\n";
        echo "<span class='text-dark strong'>" . $this->locale['fields_0403'] . "</span>" . ($user_field_dbname ? "<br/>" . $user_field_dbname : '<br/>' . $this->locale['fields_0404']) . "<br/>\n";
        echo "<span class='text-dark strong'>" . $this->locale['fields_0405'] . "</span>" . ($user_field_dbinfo ? "<br/>" . $user_field_dbinfo : '<br/>' . $this->locale['fields_0406']) . "<br/>\n";
        echo "<span class='text-dark strong'>" . $this->locale['fields_0407'] . "</span>" . ($user_field_desc ? "<br/>" . $user_field_desc : '') . "<br/>\n";
        echo "</div>\n";
        echo "<hr/>\n";
        // start form.
        $disable_opts = array();
        foreach ($this->page_list as $index => $v) {
            $disable_opts[] = $index;
        }
        echo form_select_tree('field_cat', $this->locale['fields_0410'], $this->field_data['field_cat'], array('no_root' => 1, 'disable_opts' => $disable_opts), $this->category_db, 'field_cat_name', 'field_cat_id', 'field_parent');
        if ($user_field_dbinfo != "") {
            if (version_compare($user_field_api_version, "1.01.00", ">=")) {
                echo form_checkbox('field_required', $this->locale['fields_0411'], $this->field_data['field_required']);
            } else {
                echo "<p>\n" . $this->locale['428'] . "</p>\n";
            }
        }
        if ($user_field_dbinfo != "") {
            if (version_compare($user_field_api_version, "1.01.00", ">=")) {
                echo form_checkbox('field_log', $this->locale['fields_0412'], $this->field_data['field_log']);
            } else {
                echo "<p>\n" . $this->locale['429a'] . "</p>\n";
            }
        }
        if ($user_field_dbinfo != "") {
            echo form_checkbox('field_registration', $this->locale['fields_0413'], $this->field_data['field_registration']);
        }
        echo form_text('field_order', $this->locale['fields_0414'], $this->field_data['field_order']);
        echo form_hidden('add_module', '', $this->field_data['add_module']);
        echo form_hidden('field_name', '', $user_field_dbname);
        echo form_hidden('field_title', '', $user_field_name);
        // new api introduced
        echo form_hidden('field_default', '', isset($user_field_default) ? $user_field_default : '');
        echo form_hidden('field_options', '', isset($user_field_options) ? $user_field_options : '');
        echo form_hidden('field_error', '', isset($user_field_error) ? $user_field_error : '');
        echo form_hidden('field_config', '', isset($user_field_config) ? $user_field_config : '');
        echo form_hidden('field_id', '', $this->field_data['field_id']);
        echo form_button('enable', $this->field_data['field_id'] ? $this->locale['fields_0415'] : $this->locale['fields_0416'], $this->field_data['field_id'] ? $this->locale['fields_0415'] : $this->locale['fields_0416'], array('class' => 'btn-primary btn-sm'));
        echo closeform();
        echo "</div>\n";
    }