CI_Table::set_template PHP Méthode

set_template() public méthode

Set the template
public set_template ( array $template ) : boolean
$template array
Résultat boolean
    public function set_template($template)
    {
        if (!is_array($template)) {
            return FALSE;
        }
        $this->template = $template;
        return TRUE;
    }

Usage Example

Exemple #1
0
    /**
     * Display Global Settings
     */
    function display_global_settings()
    {
        $this->_update_global_settings();
        // load the language file
        $this->EE->lang->loadfile('playa');
        // load the table lib
        $this->EE->load->library('table');
        // load the CSS
        $this->_include_theme_css('styles/global_settings.css');
        // use the default template known as
        // $cp_pad_table_template in the views
        $this->EE->table->set_template(array('table_open' => '<table class="mainTable padTable" border="0" cellspacing="0" cellpadding="0">', 'row_start' => '<tr class="even">', 'row_alt_start' => '<tr class="odd">'));
        // "Preference" and "Setting" table headings
        $this->EE->table->set_heading(array('data' => lang('preference'), 'style' => 'width: 50%'), lang('setting'));
        // -------------------------------------------
        //  License Key
        // -------------------------------------------
        $this->EE->table->add_row(lang('license_key', 'license_key'), form_input('license_key', $this->settings['license_key'], 'id="license_key" size="40"'));
        // -------------------------------------------
        //  Filter Min
        // -------------------------------------------
        $this->EE->table->add_row(lang('filter_min', 'filter_min') . '<br/>' . lang('filter_min_desc'), form_input('filter_min', $this->settings['filter_min'], 'id="filter_min" size="3" style="width: 3em;"'));
        // -------------------------------------------
        //  Relationship field conversion
        // -------------------------------------------
        // Accomodate the schema changes
        if (version_compare(APP_VER, '2.6', '<')) {
            $field_types = array('"rel"', '"mrel"');
        } else {
            $field_types = array('"relationship"');
        }
        $field_types = implode(",", $field_types);
        $query = $this->EE->db->query('SELECT cf.field_id, cf.field_label, fg.group_name
		                               FROM exp_channel_fields AS cf
		                               INNER JOIN exp_field_groups AS fg ON cf.group_id = fg.group_id
		                               WHERE cf.field_type IN (' . $field_types . ')');
        if ($query->num_rows()) {
            // load the Admin Content lang file
            $this->EE->lang->loadfile('admin_content');
            // initialize a new Table object
            $table = new CI_Table();
            // set the template
            $table->set_template(array('table_open' => '<table class="playaConvertRel" border="0" cellspacing="0" cellpadding="0"'));
            // "Field Group", "Field Name", and "Convert?" table headings
            $table->set_heading(lang('field_group'), lang('field_name'), lang('convert'));
            // add each of the Rel fields
            foreach ($query->result() as $field) {
                $table->add_row($field->group_name, $field->field_label, form_radio('convert_rel_field[' . $field->field_id . ']', 'y', FALSE, 'id="convert_rel_field_' . $field->field_id . '_y"') . NL . lang('yes', 'convert_rel_field_' . $field->field_id . '_y') . NBS . NBS . NBS . NBS . NBS . NL . form_radio('convert_rel_field[' . $field->field_id . ']', 'n', TRUE, 'id="convert_rel_field_' . $field->field_id . '_n"') . NL . lang('no', 'convert_rel_field_' . $field->field_id . '_n'));
            }
            // add the row to the main table
            $this->EE->table->add_row(lang('convert_rel_fields', 'convert_rel_fields') . '<br/>' . lang('convert_rel_fields_info'), $table->generate());
        }
        // -------------------------------------------
        //  Related Entries conversion
        // -------------------------------------------
        if ($this->EE->db->table_exists('related_entries')) {
            // Convert Related Entries?
            $this->EE->table->add_row(lang('convert_related_entries', 'convert_related_entries_y') . '<br/>' . lang('convert_related_entries_info'), form_radio('convert_related_entries', 'y', FALSE, 'id="convert_related_entries_y"') . NL . lang('yes', 'convert_related_entries_y') . NBS . NBS . NBS . NBS . NBS . NL . form_radio('convert_related_entries', 'n', TRUE, 'id="convert_related_entries_n"') . NL . lang('no', 'convert_related_entries_n'));
        }
        return $this->EE->table->generate();
    }
All Usage Examples Of CI_Table::set_template