Beispiel #1
0
/**
 * Muestra el formulario para la creación de una nueva página enlazada
 */
function newLinkForm($edit = 0)
{
    global $db, $mc, $xoopsModule, $myts;
    foreach ($_REQUEST as $k => $v) {
        ${$k} = $v;
    }
    $pag = isset($page) ? $page : 1;
    if ($edit) {
        $id = isset($_REQUEST['id']) ? $_REQUEST['id'] : 0;
        if ($id <= 0) {
            redirectMsg("pages.php&cat={$cat}&page={$pag}", __('You must provide a page ID to edit', 'qpages'), 1);
            die;
        }
        $page = new QPPage($id);
    }
    xoops_cp_location('<a href="./">' . $xoopsModule->name() . '</a> &raquo; ' . ($edit ? __('Edit linked page', 'qpages') : __('New linked page', 'qpages')));
    RMTemplate::get()->add_script('../include/js/forms_pages.js');
    xoops_cp_header();
    $form = new RMForm($edit ? __('Edit Linked Page', 'qpages') : __('New Linked Page', 'qpages'), 'frmNew', 'pages.php');
    $form->addElement(new RMFormText(__('Page title', 'qpages'), 'titulo', 50, 255, $edit ? $page->getTitle() : ''), true);
    if ($edit) {
        $ele = new RMFormText(__('Friendly title', 'qpages'), 'titulo_amigo', 50, 255, $page->getFriendTitle());
        $ele->setDescription(__('This title will be used in friendly url.', 'qpages'));
        $form->addElement($ele);
        $form->addElement(new RMFormHidden('id', $page->getID()));
    }
    $ele = new RMFormSelect(__('Category', 'qpages'), 'catego', 0);
    $categos = array();
    qpArrayCategos($categos);
    $ele->addOption('0', _SELECT, $edit ? 0 : 1);
    foreach ($categos as $k) {
        $ele->addOption($k['id_cat'], str_repeat("-", $k['saltos']) . " " . $k['nombre'], $edit ? $k['id_cat'] == $page->getCategory() ? 1 : 0 : 0);
    }
    $form->addElement($ele, true, "Select:0");
    $form->addElement(new RMFormTextArea(__('Introduction', 'qpages'), 'desc', 5, 60, $edit ? $page->getDescription() : ''));
    // URL
    $form->addElement(new RMFormText(__('Target URL', 'qpages'), 'url', 50, 255, $edit ? $page->url() : ''), true);
    // Grupos
    $ele = new RMFormGroups(__('Allowed groups', 'qpages'), 'grupos', 1, 1, 3, $edit ? $page->getGroups() : array(0));
    $ele->setDescription(__('Only selected groups can access to this document.', 'qpages'));
    $form->addElement($ele);
    $ele = new RMFormRadio(__('Status', 'qpages'), 'acceso', 1);
    $ele->addOption(__('Public', 'qpages'), '1', $edit ? $page->getAccess() ? 1 : 0 : 0);
    $ele->addOption(__('Draft', 'qpages'), '0', $edit ? $page->getAccess() ? 0 : 1 : 1);
    $form->addElement($ele);
    $page_metas = $edit ? $page->get_meta() : array();
    $available_metas = qp_get_metas();
    include 'metas.php';
    $form->addElement(new RMFormLabel('', $meta_data));
    $ele = new RMFormButtonGroup();
    $ele->addButton('save', $edit ? __('Update Page', 'qpages') : __('Save Page', 'qpages'), 'submit');
    $ele->addButton('cancel', __('Cancel', 'qpages'), 'button', 'onclick="history.go(-1);"');
    $form->addElement($ele);
    $form->addElement(new RMFormHidden('op', $edit ? 'saveedit' : 'save'));
    $form->addElement(new RMFormHidden('type', 1));
    $form->addElement(new RMFormHidden('cat', $cat));
    $form->addElement(new RMFormHidden('page', $pag));
    $form->display();
    xoops_cp_footer();
}
Beispiel #2
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();
}
 if (is_file($cpath)) {
     include $cpath;
     $class = ucfirst($comment->getVar('id_obj')) . 'Controller';
     $controller = new $class();
 }
 $form = new RMForm(__('Edit Comment', 'rmcommon'), 'editComment', 'post_comment.php');
 $form->addElement(new RMFormLabel(__('In reply to', 'rmcommon'), $controller ? $controller->get_item($comment->getVar('params'), $comment) : ''));
 $form->addElement(new RMFormLabel(__('Posted date', 'rmcommon'), formatTimestamp($comment->getVar('posted'), 'mysql')));
 $form->addElement(new RMFormLabel(__('Module', 'rmcommon'), $comment->getVar('id_obj')));
 if ($xoopsUser->isAdmin()) {
     $user = new RMCommentUser($comment->getVar('user'));
     $ele = new RMFormUser(__('Poster', 'rmcommon'), 'user', false, $user->getVar('xuid') > 0 ? $user->getVar('xuid') : 0);
     $form->addElement($ele);
 }
 if ($xoopsUser->isAdmin($comment->getVAr('id_obj'))) {
     $ele = new RMFormRadio(__('Status', 'rmcommon'), 'status', 1, 0, 2);
     $ele->addOption(__('Approved', 'rmcommon'), 'approved', $comment->getVar('status') == 'approved' ? 1 : 0);
     $ele->addOption(__('Unapproved', 'rmcommon'), 'waiting', $comment->getVar('status') == 'waiting' ? 1 : 0);
     $form->addElement($ele);
 }
 $form->addElement(new RMFormTextArea(__('Content', 'rmcommon'), 'content', null, null, $comment->getVar('content', 'e'), '100%', '150px'), true);
 $form->addElement(new RMFormHidden('action', 'saveedit'));
 $ele = new RMFormButtonGroup();
 $ele->addButton('sbt', __('Update Comment', 'rmcommon'), 'submit');
 $ele->addButton('cancel', __('Cancel', 'rmcommon'), 'button', 'onclick="history.go(-1);"');
 $form->addElement($ele);
 $form->addElement(new RMFormHidden('ret', rmc_server_var($_GET, 'ret', XOOPS_URL)));
 $form->addElement(new RMFormHidden('id', $id));
 // Event to modify or add new elements to comments form
 $form = RMEvents::get()->run_event('rmcommon.edit.comment.form', $form);
 $form->display();
Beispiel #4
0
/**
* This function prepares an option to show in confgiuration form
* @param array Configuration option
* @return string
*/
function xt_form_field($name, $option, $ret = 0)
{
    global $xtAssembler, $xtFunctions;
    static $ids = 0;
    $form = new RMForm('', '', '');
    if ($xtAssembler->theme()->settings($name) !== false) {
        $option['value'] = $xtAssembler->theme()->settings($name);
    } else {
        $option['value'] = $option['default'];
    }
    $cleaner = TextCleaner::getInstance();
    $name = 'conf_' . $name;
    switch ($option['type']) {
        case 'checkbox_groups':
        case 'group_multi':
            $ele = new RMFormGroups($option['caption'], $name, 1, 1, 3, $option['value']);
            break;
        case 'radio_groups':
            $ele = new RMFormGroups($option['caption'], $name, 0, 1, 3, $option['value']);
            break;
        case 'group':
        case 'select_groups':
            $ele = new RMFormGroups($option['caption'], $name, 0, 0, 3, $option['value']);
            break;
        case 'select_groups_multi':
            $ele = new RMFormGroups($option['caption'], $name, 1, 0, 3, $option['value']);
            break;
        case 'editor':
            /*if ($rmc_config['editor_type']=='tiny'){
                  $tiny = TinyEditor::getInstance();
                  $tiny->add_config('elements',$name);
              }*/
            $ele = new RMFormEditor($option['caption'], $name, isset($option['size']) ? $option['size'] : '100%', '300px', $option['value'], '', 1, array('op'));
            break;
        case 'theme':
        case 'select_theme':
            $ele = new RMFormTheme($option['caption'], $name, 0, 0, $option['value'], 3);
            break;
        case 'theme_multi':
        case 'select_theme_multi':
        case 'checkbox_theme':
            $ele = new RMFormTheme($option['caption'], $name, 1, 1, $option['value'], 3);
            break;
        case 'gui':
            $ele = new RMFormTheme($option['caption'], $name, 0, 0, $option['value'], 3, 'GUI');
            break;
        case 'gui_multi':
            $ele = new RMFormTheme($option['caption'], $name, 1, 1, $option['value'], 3, 'GUI');
            break;
        case 'yesno':
            $ele = new RMFormYesNo($option['caption'], $name, $option['value']);
            break;
        case 'email':
            $ele = new RMFormText($option['caption'], $name, isset($option['size']) && $option['size'] > 0 ? $option['size'] : 50, null, $option['value']);
            $ele->setClass('email');
            break;
        case 'select':
            $ele = new RMFormSelect($option['caption'], $name);
            foreach ($option['options'] as $opvalue => $op) {
                $ele->addOption($opvalue, $op, $opvalue == $option['value'] ? 1 : 0);
            }
            break;
        case 'select_multi':
            $ele = new RMFormSelect($option['caption'], $name . '[]', 1, $option['value']);
            foreach ($option['options'] as $opvalue => $op) {
                $ele->addOption($opvalue, $op);
            }
            break;
        case 'language':
        case 'select_language':
            $ele = new RMFormLanguageField($option['caption'], $name, 0, 0, $option['value'], 3);
            break;
        case 'select_language_multi':
        case 'checkbox_language':
        case 'language_multi':
            $ele = new RMFormLanguageField($option['caption'], $name, 1, 1, !is_array($option['value']) ? array($option['value']) : $option['value'], 3);
            break;
        case 'modules':
            $ele = new RMFormModules($option['caption'], $name, 0, 0, $option['value'], 3);
            $ele->setInserted(array('--' => __('None', 'rmcommon')));
            break;
        case 'modules_multi':
        case 'checkbox_modules':
            $ele = new RMFormModules($option['caption'], $name, 1, 1, $option['value'], 3);
            $ele->setInserted(array('--' => __('None', 'rmcommon')));
            break;
        case 'timezone':
        case 'select_timezone':
            $ele = new RMFormTimeZoneField($option['caption'], $name, 0, 0, $option['value'], 3);
            break;
        case 'timezone_multi':
            $ele = new RMFormTimeZoneField($option['caption'], $name, 0, 1, $option['value'], 3);
            break;
        case 'textarea':
            $ele = new RMFormTextArea($option['caption'], $name, 5, isset($option['size']) && $option['size'] > 0 ? $option['size'] : 50, $option['content'] == 'array' ? $cleaner->specialchars(implode('|', $option['value'])) : $cleaner->specialchars($option['value']));
            break;
        case 'user':
            $ele = new RMFormUser($option['caption'], $name, false, $option['value'], 300);
            break;
        case 'user_multi':
            $ele = new RMFormUser($option['caption'], $name, true, !is_array($option['value']) ? array($option['value']) : $option['value'], 300);
            break;
        case 'radio':
            $ele = new RMFormRadio($option['caption'], $name, 1);
            foreach ($option['options'] as $opvalue => $op) {
                $ele->addOption($op, $opvalue, $opvalue == $option['value'] ? 1 : 0);
            }
            break;
        case 'webfonts':
            $ele = new RMFormWebfonts($option['caption'], $name, $option['value']);
            break;
        case 'imageurl':
            $ele = new RMFormImageUrl($option['caption'], $name, $option['value']);
            break;
        case 'slider':
            if ($ret) {
                return;
            }
            $ele = new RMFormSlider($option['caption'], $name, $option['value']);
            $ele->addField('title', array('caption' => __('Slider Title', 'xthemes'), 'description' => __('Show the slider title', 'xthemes'), 'type' => 'textbox'));
            $i = 0;
            foreach ($option['options'] as $id => $data) {
                $ele->addField($id, $data);
            }
            break;
        case 'color':
            $ele = new RMFormColorSelector($option['caption'], $name, $option['value'], true);
            break;
        case 'imageselect':
            $ele = new RMFormImageSelect($option['caption'], $name, $option['value']);
            foreach ($option['options'] as $v => $url) {
                $ele->addImage($v, $url);
            }
            break;
        case 'textbox':
        case 'password':
        default:
            $ele = new RMFormText($option['caption'], $name, isset($option['size']) && $option['size'] > 0 ? $option['size'] : 50, null, $option['value'], $option['type'] == 'password' ? 1 : 0);
            break;
    }
    if (isset($option['attributes'])) {
        $ele->attrs($option['attributes']);
    }
    $ele->setId('xtfield-' . $ids);
    $ids++;
    return $ret ? $ele : $ele->render();
}
Beispiel #5
0
function edit_comment()
{
    $id = rmc_server_var($_GET, 'id', 0);
    $page = rmc_server_var($_GET, 'page', 1);
    $filter = rmc_server_var($_GET, 'filter', '');
    $w = rmc_server_var($_GET, 'w', '1');
    $qs = "w={$w}&page={$page}&filter={$filter}";
    if ($id <= 0) {
        redirectMsg('comments.php?' . $qs, __('Sorry, comment id is not valid', 'rmcommon'), 1);
        die;
    }
    $comment = new RMComment($id);
    if ($comment->isNew()) {
        redirectMsg('comments.php?' . $qs, __('Sorry, comment does not found', 'rmcommon'), 1);
        die;
    }
    $cpath = XOOPS_ROOT_PATH . '/modules/' . $comment->getVar('id_obj') . '/class/' . $comment->getVar('id_obj') . 'controller.php';
    if (is_file($cpath)) {
        include $cpath;
        $class = ucfirst($comment->getVar('id_obj')) . 'Controller';
        $controller = new $class();
    }
    $form = new RMForm(__('Edit Comment', 'rmcommon'), 'editComment', 'comments.php');
    $form->addElement(new RMFormLabel(__('In reply to', 'rmcommon'), $controller ? $controller->get_item($comment->getVar('params'), $comment) : ''));
    $form->addElement(new RMFormLabel(__('Posted date', 'rmcommon'), formatTimestamp($comment->getVar('posted'), 'mysql')));
    $form->addElement(new RMFormLabel(__('Module', 'rmcommon'), $comment->getVar('id_obj')));
    $form->addElement(new RMFormLabel(__('IP', 'rmcommon'), $comment->getVar('ip')));
    $user = new RMCommentUser($comment->getVar('user'));
    $ele = new RMFormUser(__('Poster', 'rmcommon'), 'user', false, $user->getVar('xuid') > 0 ? $user->getVar('xuid') : 0);
    $form->addElement($ele);
    $ele = new RMFormRadio(__('Status', 'rmcommon'), 'status', 1, 0, 2);
    $ele->addOption(__('Approved', 'rmcommon'), 'approved', $comment->getVar('status') == 'approved' ? 1 : 0);
    $ele->addOption(__('Unapproved', 'rmcommon'), 'waiting', $comment->getVar('status') == 'waiting' ? 1 : 0);
    $form->addElement($ele);
    $form->addElement(new RMFormTextArea(__('Content', 'rmcommon'), 'content', null, null, $comment->getVar('content', 'e'), '100%', '150px'), true);
    $form->addElement(new RMFormHidden('page', $page));
    $form->addElement(new RMFormHidden('filter', $filter));
    $form->addElement(new RMFormHidden('w', $w));
    $form->addElement(new RMFormHidden('id', $id));
    $form->addElement(new RMFormHidden('action', 'save'));
    $ele = new RMFormButtonGroup();
    $ele->addButton('sbt', __('Update Comment', 'rmcommon'), 'submit');
    $ele->addButton('cancel', __('Cancel', 'rmcommon'), 'button', 'onclick="history.go(-1);"');
    $form->addElement($ele);
    RMFunctions::create_toolbar();
    xoops_cp_header();
    $form->display();
    xoops_cp_footer();
}
/**
* @desc Presenta el formulario para creación o edición de un anuncio
*/
function showForm($edit = 0)
{
    global $tpl, $xoopsModule, $db;
    if ($edit) {
        $id = rmc_server_var($_GET, 'id', 0);
        if ($id <= 0) {
            redirectMsg('announcements.php', __('Provided ID is not valid!', 'bxpress'), 1);
            die;
        }
        $an = new bXAnnouncement($id);
        if ($an->isNew()) {
            redirectMsg('announcements.php', __('Specified announcement does not exists!', 'bxpress'), 1);
            die;
        }
    }
    RMTemplate::get()->set_help('http://www.redmexico.com.mx/docs/bxpress-forums/anuncios/standalone/1/#crear-un-anuncio');
    bXFunctions::menu_bar();
    xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> &raquo; " . ($edit ? __('Edit Announcement', 'bxpress') : __('New Announcement', 'bxpress')));
    xoops_cp_header();
    $form = new RMForm($edit ? __('Edit Announcement', 'bxpress') : __('New Announcement', 'bxpress'), 'frmAnnouncements', 'announcements.php');
    $form->oddClass('oddForm');
    $form->addElement(new RMFormEditor(__('Text', 'bxpress'), 'text', '100%', '300px', $edit ? $an->text('e') : ''), true);
    // Caducidad
    $ele = new RMFormDate(__('Expire on', 'bxpress'), 'expire', $edit ? $an->expire() : time());
    $form->addElement($ele);
    // Mostran en
    $ele = new RMFormRadio(__('Show on', 'bxpress'), 'where', 1, 0);
    $ele->addOption(__('Module home page', 'bxpress'), 0, $edit ? $an->where() == 0 : 1);
    $ele->addOption(__('Forum', 'bxpress'), 1, $edit ? $an->where() == 1 : 0);
    $ele->addOption(__('All module', 'bxpress'), 2, $edit ? $an->where() == 2 : 0);
    $form->addElement($ele);
    // Foros
    $ele = new RMFormSelect(__('Forum', 'bxpress'), 'forum', 0, $edit ? array($an->forum()) : array());
    $ele->setDescription(__('Please select the forum where this announcement will be shown. This option only is valid when "In Forum" has been selected.', 'bxpress'));
    $tbl1 = $db->prefix("bxpress_categories");
    $tbl2 = $db->prefix("bxpress_forums");
    $sql = "SELECT b.*, a.title FROM {$tbl1} a, {$tbl2} b WHERE b.cat=a.id_cat AND b.active='1' ORDER BY a.order, b.order";
    $result = $db->query($sql);
    $categories = array();
    while ($row = $db->fetchArray($result)) {
        $cforum = array('id' => $row['id_forum'], 'name' => $row['name']);
        if (isset($categores[$row['cat']])) {
            $categories[$row['cat']]['forums'][] = $cforum;
        } else {
            $categories[$row['cat']]['title'] = $row['title'];
            $categories[$row['cat']]['forums'][] = $cforum;
        }
    }
    foreach ($categories as $cat) {
        $ele->addOption(0, $cat['title'], 0, true, 'color: #000; font-weight: bold; font-style: italic; border-bottom: 1px solid #c8c8c8;');
        foreach ($cat['forums'] as $cforum) {
            $ele->addOption($cforum['id'], $cforum['name'], 0, false, 'padding-left: 10px;');
        }
    }
    $form->addElement($ele);
    $ele = new RMFormButtonGroup();
    $ele->addButton('sbt', $edit ? __('Save Changes', 'bxpress') : __('Create Announcement', 'bxpress'), 'submit');
    $ele->addButton('cancel', __('Cancel', 'bxpress'), 'button', 'onclick="window.location=\'announcements.php\';"');
    $form->addElement($ele);
    $form->addElement(new RMFormHidden('action', $edit ? 'saveedit' : 'save'));
    if ($edit) {
        $form->addElement(new RMFormHidden('id', $id));
    }
    $form = RMEvents::get()->run_event('bxpress.form.announcement', $form);
    $form->display();
    xoops_cp_footer();
}
Beispiel #7
0
function formTeams($edit = 0)
{
    global $db, $xoopsModule, $mc, $xoopsConfig;
    if ($edit) {
        $id = TCFunctions::get('id');
        if ($id <= 0) {
            redirectMsg('teams.php', __('Id not valid', 'admin_team'), 1);
            die;
        }
        $team = new TCTeam($id);
        if ($team->isNew()) {
            redirectMsg('teams.php', __('No existe el equipo especificado', 'admin_team'), 1);
            die;
        }
    }
    xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> &raquo; <a href='./teams.php'>" . __('Equipos', 'admin_team') . "</a>\n\t\t\t&raquo; " . ($edit ? __('Editar Equipo', 'admin_team') : __('Crear Equipo', 'admin_team')));
    xoops_cp_header();
    $form = new RMForm($edit ? __('Editar Equipo', 'admin_team') : __('Crear Equipo', 'admin_team'), 'frmTeam', 'teams.php');
    $form->setExtra('enctype="multipart/form-data"');
    $form->oddClass('oddForm');
    $ele = new RMFormRadio(__('Categoría', 'admin_team'), 'cat', 0, 1, 1);
    $result = $db->query("SELECT * FROM " . $db->prefix("coach_categos") . " ORDER BY name");
    while ($row = $db->fetchArray($result)) {
        $ele->addOption($row['name'], $row['id_cat'], $edit ? $team->category() == $row['id_cat'] ? 1 : 0 : 0);
    }
    $form->addElement($ele, true, 'checked');
    $form->addElement(new RMFormText(__('Nombre', 'admin_team'), 'name', 50, 100, $edit ? $team->name() : ''), true);
    if ($edit) {
        $form->addElement(new RMFormText(__('Nombre corto', 'admin_team'), 'nameid', 50, 100, $edit ? $team->nameId() : ''));
    }
    $form->addElement(new RMFormFile(__('Imagen', 'admin_team'), 'image', 46, $mc['filesize'] * 1024));
    if ($edit && $team->image() != '') {
        $form->addElement(new RMFormLabel(__('Imagen actual', 'admin_team'), '<img src="' . XOOPS_URL . '/uploads/teams/ths/' . $team->image() . '" alt="" />'));
    }
    $form->addElement(new RMFormEditor(__('Información', 'admin_team'), 'desc', '90%', '300px', $edit ? $team->desc('e') : ''));
    if ($edit) {
        $html = $team->getVar('dohtml');
        $xcode = $team->getVar('doxcode');
        $doimage = $team->getVar('doimage');
        $smiley = $team->getVar('dosmiley');
        $br = $team->getVar('dobr');
    } else {
        $html = $xoopsConfig['editor_type'] == 'tiny' ? 1 : 0;
        $xcode = $xoopsConfig['editor_type'] == 'tiny' ? 0 : 1;
        $doimage = $xoopsConfig['editor_type'] == 'tiny' ? 0 : 1;
        $smiley = $xoopsConfig['editor_type'] == 'tiny' ? 0 : 1;
        $br = $xoopsConfig['editor_type'] == 'tiny' ? 0 : 1;
    }
    $form->addElement(new RMFormTextOptions(__('Opciones', 'admin_team'), $html, $xcode, $doimage, $smiley, $br));
    $form->addElement(new RMFormSubTitle(__('Entrenadores', 'admin_team'), 1));
    $ele = new RMFormCheck(__('Entrenadores', 'admin_team'));
    $ele->asTable(3);
    $result = $db->query("SELECT * FROM " . $db->prefix("coach_coachs") . " ORDER BY name");
    if ($edit) {
        $coachs = $team->coachs(false);
    }
    while ($row = $db->fetchArray($result)) {
        $coach = new TCCoach();
        $coach->assignVars($row);
        $ele->addOption($coach->name(), 'coachs[]', $coach->id(), $edit ? in_array($coach->id(), $coachs) ? 1 : 0 : 0);
    }
    $form->addElement($ele);
    $ele = new RMFormButtonGroup();
    $ele->addButton('sbt', __('Enviar', 'admin_team'), 'submit');
    $ele->addButton('cancel', __('Cancelar', 'admin_team'), 'button', 'onclick="window.location=\'teams.php\';"');
    $form->addElement($ele);
    $form->addElement(new RMFormHidden('op', $edit ? 'saveedit' : 'save'));
    if ($edit) {
        $form->addElement(new RMFormHidden('id', $team->id()));
    }
    $form->display();
    xoops_cp_footer();
}
Beispiel #8
0
/**
* Form to create or edit products
*
* @param int Indicates if we are editing an existing product or creating new one
*/
function shop_new_product($edit = 0)
{
    global $xoopsModuleConfig, $xoopsModule, $xoopsConfig, $xoopsSecurity;
    if ($edit) {
        $id = rmc_server_var($_REQUEST, 'id', 0);
        if ($id <= 0) {
            redirectMsg('products.php', __('You must provide a valid product ID!', 'shop'), 1);
            die;
        }
        $product = new ShopProduct($id);
        if ($product->isNew()) {
            redirectMsg('products.php', __('Specified product does not exists!', 'shop'), 1);
            die;
        }
    }
    define('RMCSUBLOCATION', 'new_product');
    xoops_cp_location('<a href="./">' . $xoopsModule->name() . '</a> &raquo; ' . ($edit ? sprintf(__('Editing %s', 'shop'), $product->getVar('name')) : __('Create Product', 'shop')));
    xoops_cp_header();
    ShopFunctions::include_required_files();
    RMTemplate::get()->assign('xoops_pagetitle', $edit ? sprintf(__('Edit "%s"', 'shop'), $product->getVar('name')) : __('Create Product', 'shop'));
    RMTemplate::get()->add_style('admin.css', 'shop');
    RMTemplate::get()->add_local_script('dashboard.js', 'shop');
    $form = new RMForm($edit ? __('Edit Product', 'shop') : __('New Product', 'shop'), 'frmProduct', 'products.php');
    $form->setExtra('enctype="multipart/form-data"');
    $form->addElement(new RMFormText(__('Name', 'shop'), 'name', 50, 200, $edit ? $product->getVar('name') : ''), true);
    $form->addElement(new RMFormEditor(__('Description', 'shop'), 'description', '100%', '250px', $edit ? $product->getVar("description", 'e') : '', $xoopsModuleConfig['editor']), true);
    $form->addElement(new RMFormText(__('Price', 'shop'), 'price', 10, 100, $edit ? $product->getVar('price') : ''));
    $form->addElement(new RMFormText(__('Buy link', 'shop'), 'buy', 50, 255, $edit ? $product->getVar('buy') : 'http://'));
    $categories = array();
    ShopFunctions::categos_list($categories);
    if ($edit) {
        $pcats = $product->get_categos();
    } else {
        $pcats = array();
    }
    $cats = new RMFormCheck('');
    foreach ($categories as $c) {
        $cats->addOption(str_repeat("&#8212;", $c['indent']) . ' ' . $c['name'], 'cats[]', $c['id_cat'], in_array($c['id_cat'], $pcats) ? 1 : 0);
    }
    $form->addElement(new RMFormLabel(__('Categories', 'shop'), '<div class="cats_field">' . $cats->render() . '</div>'));
    $ele = new RMFormRadio(__('Type', 'shop'), 'type', 1);
    $ele->addOption(__('Normal', 'shop'), 0, 1);
    $ele->addOption(__('Digital', 'shop'), 1, 0);
    $form->addElement($ele);
    unset($ele);
    $form->addElement(new RMFormYesNo(__('Available', 'shop'), 'available', 1));
    $form->addElement(new RMFormFile(__('Default image', 'shop'), 'image'));
    if ($edit && $product->getVar('image') != '') {
        $form->addElement(new RMFormLabel(__('Current Image', 'shop'), '<img src="' . XOOPS_UPLOAD_URL . '/minishop/ths/' . $product->getVar('image') . '" />'));
    }
    $metas = $edit ? $product->get_meta() : array();
    ob_start();
    include RMTemplate::get()->get_template('admin/shop_products_form.php', 'module', 'shop');
    $metas_tpl = ob_get_clean();
    $form->addElement(new RMFormLabel(__('Custom Fields', 'shop'), $metas_tpl));
    $buts = new RMFormButtonGroup('');
    $buts->addButton('cancel', __('Cancel', 'shop'), 'button', 'onclick="window.location.href=\'products.php\'"');
    $buts->addButton('sbt', $edit ? __('Save Changes', 'shop') : __('Create Product', 'shop'), 'submit');
    $form->addElement($buts);
    $form->addElement(new RMFormHidden('action', $edit ? 'saveedit' : 'save'));
    if ($edit) {
        $form->addElement(new RMFormHidden('id', $product->id()));
    }
    $form->display();
    xoops_cp_footer();
}