Ejemplo n.º 1
0
<?php

echo form_open($base . AMP . 'method=save_settings');
$this->table->set_template($cp_table_template);
$this->table->set_heading(array(array('style' => 'width: 50%', 'data' => lang('preference')), lang('setting')));
$this->table->add_row(lang('wygwam_license_key', 'license_key'), form_input('license_key', $license_key, 'id="license_key" style="width: 98%"'));
$file_browser_options = array('ee' => 'EE File Manager', 'ckfinder' => 'CKFinder');
// is Assets installed?
if (Wygwam_helper::is_assets_installed()) {
    $file_browser_options['assets'] = 'Assets';
}
$this->table->add_row(lang('wygwam_file_browser', 'file_browser') . '<br />' . lang('wygwam_file_browser_desc'), form_dropdown('file_browser', $file_browser_options, $file_browser, 'id="file_browser"'));
echo $this->table->generate();
echo form_submit(array('name' => 'submit', 'value' => lang('submit'), 'class' => 'submit'));
echo form_close();
Ejemplo n.º 2
0
    /**
     * Edit Config
     */
    function config_edit()
    {
        $default_config_settings = Wygwam_helper::default_config_settings();
        if (($config_id = $this->EE->input->get('config_id')) && ($query = $this->EE->db->get_where('wygwam_configs', array('config_id' => $config_id))) && $query->num_rows()) {
            $config = $query->row_array();
            $config['settings'] = unserialize(base64_decode($config['settings']));
            $config['settings'] = array_merge($default_config_settings, $config['settings']);
            // duplicate?
            if ($this->EE->input->get('clone') == 'y') {
                $config['config_id'] = '';
                $config['config_name'] .= ' ' . lang('wygwam_clone');
                $this->_set_page_title(lang('wygwam_create_config'));
            } else {
                $this->_set_page_title(lang('wygwam_edit_config') . ' - ' . $config['config_name']);
            }
        } else {
            $config = array('config_id' => '', 'config_name' => '', 'settings' => $default_config_settings);
            $this->_set_page_title(lang('wygwam_create_config'));
        }
        $vars['config'] = $config;
        $vars['base'] = $this->base;
        $this->EE->load->library('table');
        // -------------------------------------------
        //  Upload Directory
        // -------------------------------------------
        $wygwam_settings = Wygwam_helper::get_global_settings();
        $msm = $this->EE->config->item('multiple_sites_enabled') == 'y';
        // If we're using Assets and it is installed, let's show Assets sources instead of just EE filedirs.
        if (isset($wygwam_settings['file_browser']) && $wygwam_settings['file_browser'] == 'assets' && Wygwam_helper::is_assets_installed()) {
            // Initialize the Assets lib
            require_once PATH_THIRD . 'assets/helper.php';
            $assets_helper = new Assets_helper();
            if ($msm) {
                $query = $this->EE->db->query("SELECT site_id, site_label FROM exp_sites")->result();
                foreach ($query as $row) {
                    $site_map[$row->site_id] = $row->site_label;
                }
            }
            $upload_dirs = array('' => '--');
            $all_sources = ee()->assets_lib->get_all_sources();
            foreach ($all_sources as $source) {
                $upload_dirs[$source->type . ':' . $source->id] = ($msm && $source->type == 'ee' ? $site_map[$source->site_id] . ' - ' : '') . $source->name;
            }
        } else {
            $dir_query = $this->EE->db->query('SELECT u.id, u.name, s.site_label
											   FROM exp_upload_prefs u, exp_sites s
											   WHERE u.site_id = s.site_id
											   ORDER BY site_label, name');
            if ($dir_query->num_rows()) {
                $upload_dirs = array('' => '--');
                foreach ($dir_query->result_array() as $row) {
                    $upload_dirs[$row['id']] = ($msm ? $row['site_label'] . ' - ' : '') . $row['name'];
                }
            }
        }
        if (!empty($upload_dirs)) {
            $vars['upload_dir'] = form_dropdown('settings[upload_dir]', $upload_dirs, $config['settings']['upload_dir'], 'id="upload_dir"');
        } else {
            $this->EE->lang->loadfile('admin_content');
            $vars['upload_dir'] = lang('no_upload_prefs');
        }
        // -------------------------------------------
        //  Advanced Settings
        // -------------------------------------------
        // which settings have we already shown?
        $skip = array_keys($default_config_settings);
        // get settings that should be treated as lists
        $config_lists = Wygwam_helper::config_lists();
        // sort settings by key
        ksort($config['settings']);
        $js = '';
        foreach ($config['settings'] as $setting => $value) {
            // skip?
            if (in_array($setting, $skip)) {
                continue;
            }
            // format_tags?
            if ($setting == 'format_tags') {
                $value = explode(';', $value);
            }
            // list?
            if (in_array($setting, $config_lists)) {
                $value = implode("\n", $value);
            }
            $json = Wygwam_helper::get_json($value);
            $js .= 'new wygwam_addSettingRow("' . $setting . '", ' . $json . ');' . NL;
        }
        // Resources
        Wygwam_helper::include_theme_css('lib/ckeditor/skins/wygwam3/editor.css');
        Wygwam_helper::include_theme_css('styles/config_edit.css');
        $this->EE->cp->add_js_script(array('ui' => 'draggable'));
        Wygwam_helper::include_theme_js('lib/ckeditor/ckeditor.js');
        Wygwam_helper::include_theme_js('scripts/config_edit_toolbar.js');
        Wygwam_helper::include_theme_js('scripts/config_edit_advanced.js');
        Wygwam_helper::insert_js('jQuery(document).ready(function(){' . NL . $js . '});');
        Wygwam_helper::insert_js('jQuery("#restrict_html").ptSwitch();');
        return $this->EE->load->view('config_edit', $vars, TRUE);
    }