示例#1
0
function configure_rm_plugin()
{
    $name = rmc_server_var($_GET, 'plugin', '');
    if ($name == '') {
        redirectMsg('plugins.php', __('You must specify a existing plugin', 'rmcommon'), 1);
        die;
    }
    $plugin = new RMPlugin($name);
    if ($plugin->isNew()) {
        redirectMsg('plugins.php', __('Specified plugin is not installed yet!', 'rmcommon'), 1);
        die;
    }
    if (!$plugin->getVar('status')) {
        redirectMsg('plugins.php', __('Specified plugin is not active!', 'rmcommon'), 1);
        die;
    }
    $rmc_config = RMFunctions::configs();
    $settings = RMFunctions::get()->plugin_settings($name, true);
    $form = new RMForm(sprintf(__('%s configuration', 'rmcommon'), $plugin->getVar('name')), 'frmconfig', 'plugins.php');
    $form->addElement(new RMFormHidden('plugin', $plugin->getVar('dir')));
    $form->addElement(new RMFormHidden('action', 'savesettings'));
    foreach ($plugin->options() as $config => $option) {
        if (isset($settings[$config])) {
            $option['value'] = $settings[$config];
        }
        if (isset($option['separator']) && !empty($option['separator'])) {
            $form->addElement(new RMFormSubTitle($option['separator']['title'], 1, '', $option['separator']['desc']));
            continue;
        }
        switch ($option['fieldtype']) {
            case 'checkbox_groups':
            case 'group_multi':
                $ele = new RMFormGroups($option['caption'], 'conf_' . $config, 1, 1, 3, $option['value']);
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'radio_groups':
                $ele = new RMFormGroups($option['caption'], 'conf_' . $config, 0, 1, 3, $option['value']);
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'group':
            case 'select_groups':
                $ele = new RMFormGroups($option['caption'], 'conf_' . $config, 0, 0, 3, $option['value']);
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'select_groups_multi':
                $ele = new RMFormGroups($option['caption'], 'conf_' . $config, 1, 0, 3, $option['value']);
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'editor':
                if ($rmc_config['editor_type'] == 'tiny') {
                    $tiny = TinyEditor::getInstance();
                    $tiny->add_config('elements', 'conf_' . $config);
                }
                $ele = new RMFormEditor($option['caption'], 'conf_' . $config, is_numeric($option['size']) ? '90%' : $option['size'], '300px', $option['value'], '', 1, array('op'));
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'theme':
            case 'select_theme':
                $ele = new RMFormTheme($option['caption'], 'conf_' . $config, 0, 0, $option['value'], 3);
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'theme_multi':
            case 'select_theme_multi':
                $ele = new RMFormTheme($option['caption'], 'conf_' . $config, 0, 1, $option['value'], 3);
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'checkbox_theme':
                $ele = new RMFormTheme($option['caption'], 'conf_' . $config, 1, 1, $option['value'], 4);
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'select_theme_admin':
                $ele = new RMFormTheme($option['caption'], 'conf_' . $config, 0, 0, $option['value'], 3, 'GUI');
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'yesno':
                $ele = new RMFormYesNo($option['caption'], 'conf_' . $config, $option['value']);
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'email':
                $ele = new RMFormText($option['caption'], 'conf_' . $config, $option['size'] > 0 ? $option['size'] : 50, null, $option['value']);
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele, false, 'email');
                break;
            case 'select':
                $ele = new RMFormSelect($option['caption'], 'conf_' . $config);
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                foreach ($option['options'] as $op => $opvalue) {
                    $ele->addOption($opvalue, $op, $opvalue == $option['value'] ? 1 : 0);
                }
                $form->addElement($ele);
                break;
            case 'select_multi':
                $ele = new RMFormSelect($option['caption'], 'conf_' . $config . '[]', 1, $option['value']);
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                foreach ($option['options'] as $op => $opvalue) {
                    $ele->addOption($opvalue, $op);
                }
                $form->addElement($ele);
                break;
            case 'language':
            case 'select_language':
                $ele = new RMFormLanguageField($option['caption'], 'conf_' . $config, 0, 0, $option['value'], 3);
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'select_language_multi':
                $ele = new RMFormLanguageField($option['caption'], 'conf_' . $config, 1, 0, $option['value'], 3);
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'checkbox_language':
                $ele = new RMFormLanguageField($option['caption'], 'conf_' . $config, 1, 1, $option['value'], 3);
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'startpage':
            case 'select_modules':
                $ele = new RMFormModules($option['caption'], 'conf_' . $config, 0, 0, $option['value'], 3);
                $ele->setInserted(array('--' => __('None', 'rmcommon')));
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'select_modules_multi':
                $ele = new RMFormModules($option['caption'], 'conf_' . $config, 1, 0, $option['value'], 3);
                $ele->setInserted(array('--' => __('None', 'rmcommon')));
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'checkbox_modules':
                $ele = new RMFormModules($option['caption'], 'conf_' . $config, 1, 1, $option['value'], 3);
                $ele->setInserted(array('--' => __('None', 'rmcommon')));
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'radio_modules':
                $ele = new RMFormModules($option['caption'], 'conf_' . $config, 0, 1, $option['value'], 3);
                $ele->setInserted(array('--' => __('None', 'rmcommon')));
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'timezone':
            case 'select_timezone':
                $ele = new RMFormTimeZoneField($option['caption'], 'conf_' . $config, 0, 0, $option['value'], 3);
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'select_timezone_multi':
                $ele = new RMFormTimeZoneField($option['caption'], 'conf_' . $config, 0, 1, $option['value'], 3);
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'checkbox_timezone':
                $ele = new RMFormTimeZoneField($option['caption'], 'conf_' . $config, 1, 1, $option['value'], 3);
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'radio_timezone':
                $ele = new RMFormTimeZoneField($option['caption'], 'conf_' . $config, 1, 0, $option['value'], 3);
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'tplset':
                $ele = new RMFormSelect($option['caption'], 'conf_' . $config);
                $tplset_handler =& exm_gethandler('tplset');
                $tplsetlist =& $tplset_handler->getList();
                asort($tplsetlist);
                foreach ($tplsetlist as $key => $name) {
                    $ele->addOption($key, $name, $option['value'] == $key ? 1 : 0);
                }
                $form->addElement($ele);
                break;
            case 'textarea':
                $ele = new RMFormTextArea($option['caption'], 'conf_' . $config, 5, $option['size'] > 0 ? $option['size'] : 50, $option['valuetype'] == 'array' ? $cleaner->htmlspecialchars(implode('|', $option['value'])) : $cleaner->htmlspecialchars($option['value']));
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'module_cache':
                $ele = new RMFormCacheModuleField($option['caption'], 'conf_' . $config, $option['value']);
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'user_select':
                $ele = new RMFormUser($option['caption'], 'conf_' . $config, $form->getName(), $option['value'], 'select', $limit = '300', '');
                $ele->setOnPage("document.forms[0].op.value='config';");
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'radio':
                $ele = new RMFormRadio($option['caption'], 'conf_' . $config, 1);
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                foreach ($option['options'] as $op => $opvalue) {
                    $ele->addOption($op, $opvalue, $opvalue == $option['value'] ? 1 : 0);
                }
                $form->addElement($ele);
                break;
            case 'font_select':
                $ele = new RMFormSelect($option['caption'], 'conf_' . $config, 0, array($option['value']));
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $fonts = EXMLists::getFileListAsArray(ABSPATH . '/rmcommon/fonts/');
                foreach ($fonts as $font) {
                    $info = pathinfo(ABSPATH . '/rmcommon/fonts/' . $font);
                    if (strtoupper($info['extension']) != 'TTF') {
                        continue;
                    }
                    $ele->addOption($font, $font);
                }
                $form->addElement($ele);
                break;
            case 'select_editor':
                $ele = new RMFormSelect($option['caption'], 'conf_' . $config, 0, array($option['value']));
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $ele->addOption('tiny', __('Visual Editor', 'rmcommon'));
                $ele->addOption('code', __('EXMCode Editor', 'rmcommon'));
                $ele->addOption('textarea', __('Simple Editor', 'rmcommon'));
                $ele->addOption('html', __('HTML Editor', 'rmcommon'));
                $form->addElement($ele);
                break;
            case 'textbox':
            case 'password':
            default:
                $ele = new RMFormText($option['caption'], 'conf_' . $config, $option['size'] > 0 ? $option['size'] : 50, null, $option['valuetype'] == 'array' ? implode('|', $option['value']) : $option['value'], $option['fieldtype'] == 'password' ? 1 : 0);
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele, false, $option['valuetype'] == 'int' || $option['valuetype'] == 'float' ? 'num' : '');
                break;
        }
    }
    $ele = new RMFormButtonGroup();
    $ele->addButton('', __('Save Settings', 'rmcommon'), 'submit');
    $ele->addButton('', __('Cancel', 'rmcommon'), 'button', 'onclick="history.go(-1);"');
    $form->addElement($ele);
    // Other components can add items to database
    $form = RMEvents::get()->run_event("rmcommon.settings.form", $form, $plugin);
    RMFunctions::create_toolbar();
    xoops_cp_header();
    $form->display();
    xoops_cp_footer();
}
function dt_block_items_edit($options)
{
    include_once RMCPATH . '/class/form.class.php';
    include_once XOOPS_ROOT_PATH . '/modules/dtransport/class/dtcategory.class.php';
    include_once XOOPS_ROOT_PATH . '/modules/dtransport/class/dtfunctions.class.php';
    $dtfunc = new DTFunctions();
    $elements = array();
    $ele = new RMFormSelect(__('Donwloads type', 'dtransport'), 'options[0]', 0, array($options[0]));
    $ele->addOption('all', __('All downloads', 'dtransport'));
    $ele->addOption('recent', __('Recent downloads', 'dtransport'));
    $ele->addOption('popular', __('Popular downloads', 'dtransport'));
    $ele->addOption('rated', __('Best rated downloads', 'dtransport'));
    $ele->addOption('featured', __('Featured download', 'dtransport'));
    $ele->addOption('daily', __('Daily downloads', 'dtransport'));
    $elements[] = array('title' => $ele->getCaption(), 'content' => $ele->render());
    // Categoría
    include_once XOOPS_ROOT_PATH . '/modules/dtransport/class/dtfunctions.class.php';
    $categos = array();
    $dtfunc->getCategos($categos, 0, 0, array(), false, 1);
    $ele = new RMFormSelect(__('Downloads from category', 'dtransport'), 'options[1]', false, $options[1]);
    $ele->addOption(0, __('All categories', 'dtransport'));
    foreach ($categos as $cat) {
        $ele->addOption($cat['id_cat'], str_repeat("—", $cat['jumps']) . ' ' . $cat['name']);
    }
    $elements[] = array('title' => $ele->getCaption(), 'content' => $ele->render());
    // Numero de Descargas
    $ele = new RMFormText(__('Items limit', 'dtransport'), 'options[2]', 5, 2, $options[2]);
    $elements[] = array('title' => $ele->getCaption(), 'content' => $ele->render());
    // Mostrar imágen
    $ele = new RMFormYesNo(__('Show image', 'dtransport'), 'options[3]', $options[3]);
    $elements[] = array('title' => $ele->getCaption(), 'content' => $ele->render());
    // Tamaño de imágen utilizado
    $ele = new RMFormText(__('Image size', 'dtransport'), 'options[11]', 20, 100, $options[11]);
    $ele->setDescription(__('This name must match with a size configured previously in image manager.', 'dtransport'));
    $elements[] = array('title' => $ele->getCaption(), 'content' => $ele->render());
    // Mostrar Descripción
    $ele = new RMFormYesNo(__('Show description', 'dtransport'), 'options[4]', $options[4]);
    $elements[] = array('title' => $ele->getCaption(), 'content' => $ele->render());
    // Mostrar Hits
    $ele = new RMFormYesNo(__('Show hits', 'dtransport'), 'options[5]', $options[5]);
    $elements[] = array('title' => $ele->getCaption(), 'content' => $ele->render());
    // Mostrar Ratig de Usuarios
    $ele = new RMFormYesNo(__('Show user rating', 'dtransport'), 'options[6]', $options[6]);
    $elements[] = array('title' => $ele->getCaption(), 'content' => $ele->render());
    // Mostrar Rating del Sitio
    $ele = new RMFormYesNo(__('Show site rating', 'dtransport'), 'options[7]', $options[7]);
    $elements[] = array('title' => $ele->getCaption(), 'content' => $ele->render());
    // Mostrar Enlace de descarga
    $ele = new RMFormYesNo(__('Show download link', 'dtransport'), 'options[8]', $options[8]);
    $elements[] = array('title' => $ele->getCaption(), 'content' => $ele->render());
    // Mostrar Nombre de Usuario
    $ele = new RMFormYesNo(__('Show author', 'dtransport'), 'options[9]', $options[9]);
    $elements[] = array('title' => $ele->getCaption(), 'content' => $ele->render());
    // Descargas de usuario
    $ele = new RMFormText(__('Show downloads from a single user', 'dtransport'), 'options[10]', 10, 100, $options[10]);
    $ele->setDescription(__('You can specify a user name or a integer id of the user.', 'dtransport'));
    $elements[] = array('title' => $ele->getCaption(), 'content' => $ele->render(), 'description' => $ele->getDescription());
    $form = '<table class="outer">';
    foreach ($elements as $ele) {
        $form .= '<tr><td>' . $ele['title'] . ($ele['description'] != '' ? '<span class="description">' . $ele['description'] . '</span>' : '') . '</td><td>' . $ele['content'] . '</td></tr>';
    }
    $form .= '</table>';
    return $form;
}
示例#3
0
/**
* Presenta las opciones para configurar la alerta
*/
function dt_widget_alert($edit = 0)
{
    //$widget['title'] = __('Inactivity Alert','dtransport');
    //$widget['icon'] = '../images/alert.png';
    if ($edit) {
        $sw = new DTSoftware(rmc_server_var($_GET, 'id', 0));
    } else {
        $sw = new DTSoftware();
    }
    // Alerta
    $field = new RMFormYesNo('', 'alert', $edit ? $type == 'edit' ? $fields['alert']['limit'] ? 1 : 0 : ($sw->alert() ? 1 : 0) : 0);
    $enable_alert = $field->render();
    unset($field);
    ob_start();
    ?>
    <div id="tab-alert" class="widgets_forms">
    <form name="frmAlert" id="frm-alert" method="post" action="items.php">
        <div class="item">
        <div class="dt_table">
            <div class="dt_row">
                <div class="dt_cell">
                    <label for="alert"><?php 
    echo _e('Enable alerts:', 'dtransport');
    ?>
</label>
                </div>
                <div class="dt_cell">
                    <?php 
    echo $enable_alert;
    ?>
                </div>
            </div>
        </div>
        </div>
        <div class="item">
            <label for="limitalert"><?php 
    _e('Limit of days', 'dtransport');
    ?>
</label>
            <input type="text" name="limitalert" id="limitalert" value="<?php 
    echo $edit ? $sw->alert()->limit() : '';
    ?>
" class="fullwidth" />
            <span class="description"><?php 
    _e('Maximum number of days that an item can be without downloads before to send an alert to author.', 'dtransport');
    ?>
</span>
        </div>
        <div class="item">
            <label for="mode"><?php 
    _e('Alert mode', 'dtransport');
    ?>
</label><br />
            <input type="radio" name="mode" id="mode" value="0"<?php 
    echo $edit ? $sw->alert()->mode() == 0 ? ' checked="checked"' : '' : '';
    ?>
 /><?php 
    _e('Private message', 'dtransport');
    ?>
            <input type="radio" name="mode" id="mode1" value="1"<?php 
    echo $edit ? $sw->alert()->mode() == 1 ? ' checked="checked"' : '' : '';
    ?>
 /><?php 
    _e('Email message', 'dtransport');
    ?>
        </div>
    </form>
    </div>
    <?php 
    //$widget['content'] = ob_get_clean();
    $content = ob_get_clean();
    return $content;
}