Esempio n. 1
0
/**
* Formulario para crear publicaciones
**/
function rd_show_form($edit = 0)
{
    global $xoopsModule, $xoopsConfig, $xoopsModuleConfig;
    RDFunctions::toolbar();
    xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> &raquo; " . ($edit ? __('Editing Document', 'docs') : __('Create Document', 'docs')));
    xoops_cp_header();
    $id = rmc_server_var($_GET, 'id', 0);
    $page = rmc_server_var($_GET, 'page', 1);
    if ($edit) {
        //Comprueba si la publicación es válida
        if ($id <= 0) {
            redirectMsg('./resources.php?page=' . $page, __('You must provide an ID from some Document to edit!', 'docs'), 1);
            die;
        }
        //Comprueba si la publicación existe
        $res = new RDResource($id);
        if ($res->isNew()) {
            redirectMsg('./resources.php?page=' . $page, __('Specified Document does not exists!', 'docs'), 1);
            die;
        }
    }
    $form = new RMForm($edit ? sprintf(__('Edit Document: %s', 'docs'), $res->getVar('title')) : __('New Document', 'docs'), 'frmres', 'resources.php');
    $form->addElement(new RMFormText(__('Document title', 'docs'), 'title', 50, 150, $edit ? $res->getVar('title') : ''), true);
    if ($edit) {
        $form->addElement(new RMFormText(__('Document slug', 'docs'), 'nameid', 50, 150, $res->getVar('nameid')));
    }
    $form->addElement(new RMFormTextArea(__('Description', 'docs'), 'desc', 5, 50, $edit ? $res->getVar('description', 'e') : ''), true);
    $form->addElement(new RMFormUser(__('Editors', 'docs'), 'editors', 1, $edit ? $res->getVar('editors') : '', 30));
    //Propietario de la publicacion
    if ($edit) {
        $form->addElement(new RMFormUser(__('Document owner', 'docs'), 'owner', 0, $edit ? array($res->getVar('owner')) : '', 30));
    }
    $form->addElement(new RMFormYesno(__('Approve content and changes by editors', 'docs'), 'approvededit', $edit ? $res->getVar('editor_approve') : 0));
    $form->addElement(new RMFormGroups(__('Groups that can see this Document', 'docs'), 'groups', 1, 1, 5, $edit ? $res->getVar('groups') : array(1, 2)), true);
    $form->addElement(new RMFormYesno(__('Set as public', 'docs', 'docs'), 'public', $edit ? $res->getVar('public') : 0));
    $form->addElement(new RMFormYesNo(__('Quick index', 'docs'), 'quick', $edit ? $res->getVar('quick') : 0));
    //Mostrar índice a usuarios sin permiso de publicación
    $form->addElement(new RMFormYesno(__('Show index to restricted users', 'docs'), 'showindex', $edit ? $res->getVar('show_index') : 0));
    $form->addElement(new RMFormYesno(__('Featured', 'docs'), 'featured', $edit ? $res->getVar('featured') : 0));
    $form->addElement(new RMFormYesno(__('Approve inmediatly', 'docs'), 'approvedres', $edit ? $res->getVar('approved') : 1));
    $form->addElement(new RMFormYesno(__('Show content in a single page', 'docs'), 'single', $edit ? $res->getVar('single') : 0));
    $form->element('single')->setDescription(__('When you enable this option the Document content will show in a single page.', 'docs'));
    $buttons = new RMFormButtonGroup();
    $buttons->addButton('sbt', $edit ? __('Update Document', 'docs') : __('Create Document', 'docs'), 'submit');
    $buttons->addButton('cancel', __('Cancel', 'docs'), 'button', 'onclick="window.location=\'resources.php\';"');
    $form->addElement($buttons);
    $form->addElement(new RMFormHidden('action', $edit ? 'saveedit' : 'save'));
    if ($edit) {
        $form->addElement(new RMFormHidden('id', $id));
    }
    $form->addElement(new RMFormHidden('page', $page));
    $form->addElement(new RMFormHidden('app', $edit ? $res->getVar('approved') : 0));
    $form->display();
    xoops_cp_footer();
}
Esempio n. 2
0
/**
* @desc Formulario de creación y edición de sección
**/
function rd_show_form($edit = 0)
{
    global $xoopsModule, $xoopsConfig, $xoopsSecurity, $xoopsUser, $xoopsModuleConfig, $rmc_config;
    define('RMCSUBLOCATION', 'newresource');
    $id = rmc_server_var($_GET, 'id', 0);
    $parent = rmc_server_var($_GET, 'parent', 0);
    if ($id <= 0) {
        redirectMsg('sections.php?id=' . $id, __('You must select a Document in order to create a new section', 'docs'), 1);
        die;
    }
    // Check if provided Document exists
    global $res;
    $res = new RDResource($id);
    if ($res->isNew()) {
        redirectMsg('sections.php?id=' . $id, __('Specified Document does not exists!', 'docs'), 1);
        die;
    }
    if ($edit) {
        $id_sec = rmc_server_var($_GET, 'sec', 0);
        //Verifica si la sección es válida
        if ($id_sec <= 0) {
            redirectMsg('sections.php?id=' . $id, __('Specify a section to edit', 'docs'), 1);
            die;
        }
        //Comprueba si la sección es existente
        $sec = new RDSection($id_sec);
        if ($sec->isNew()) {
            redirectMsg('sections.php?id=' . $id, __('Specified section does not exists', 'docs'), 1);
            die;
        }
    }
    // Get order
    $order = RDFunctions::order('MAX', $parent, $res->id());
    $order++;
    $rmc_config = RMFunctions::configs();
    $form = new RMForm('', 'frmsec', 'sections.php');
    if ($rmc_config['editor_type'] == 'tiny') {
        $tiny = TinyEditor::getInstance();
        $tiny->add_config('theme_advanced_buttons1', 'rd_refs');
        $tiny->add_config('theme_advanced_buttons1', 'rd_figures');
        $tiny->add_config('theme_advanced_buttons1', 'rd_toc');
    }
    $editor = new RMFormEditor('', 'content', '100%', '300px', $edit ? $rmc_config['editor_type'] == 'tiny' ? $sec->getVar('content') : $sec->getVar('content', 'e') : '', '', 0);
    $usrfield = new RMFormUser('', 'uid', false, $edit ? array($sec->getVar('uid')) : $xoopsUser->getVar('uid'));
    RMTemplate::get()->add_style('admin.css', 'docs');
    RMTemplate::get()->add_script('../include/js/scripts.php?file=metas.js');
    RMTemplate::get()->add_script(RMCURL . '/include/js/jquery.validate.min.js');
    RMTemplate::get()->add_head('<script type="text/javascript">var docsurl = "' . XOOPS_URL . '/modules/docs";</script>');
    RDFunctions::toolbar();
    xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> &raquo; " . ($edit ? __('Edit Section', 'docs') : __('Create Section', 'docs')));
    RMTemplate::get()->assign('xoops_pagetitle', $edit ? __('Edit Section', 'docs') : __('Create Section', 'docs'));
    xoops_cp_header();
    $sections = array();
    RDFunctions::getSectionTree($sections, 0, 0, $id, 'id_sec, title', isset($sec) ? $sec->id() : 0);
    include RMEvents::get()->run_event('docs.get.secform.template', RMTemplate::get()->get_template('admin/rd_sections_form.php', 'module', 'docs'));
    xoops_cp_footer();
}