Exemplo n.º 1
0
function formCoachs($edit = 0)
{
    global $xoopsModule, $db, $mc, $xoopsConfig;
    if ($edit) {
        $id = TCFunctions::get('id');
        if ($id <= 0) {
            redirectMsg('coachs.php', __('Id no válido', 'admin_team'), 1);
            die;
        }
        $coach = new TCCoach($id);
        if ($coach->isNew()) {
            redirectMsg('coachs.php', __('El entrenador especificado no existe', 'admin_team'), 1);
            die;
        }
    }
    xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> &raquo; <a href='./coachs.php'>" . __('Entrenadores', 'admin_team') . "</a> &raquo; " . ($edit ? __('Editar entrenador', 'admin_team') : __('Crear entrenador', 'admin_team')));
    $cHead = '<link href="' . TC_URL . '/styles/admin.css" media="all" rel="stylesheet" type="text/css" />';
    xoops_cp_header($cHead);
    $form = new RMForm($edit ? __('Editar Entrenador', 'admin_team') : __('Crear Entrenador', 'admin_team'), 'frmNew', 'coachs.php', 'post');
    $form->oddClass('oddForm');
    $form->setExtra('enctype="multipart/form-data"');
    $form->addElement(new RMFormText(__('Nombre', 'admin_team'), 'name', 50, 150, $edit ? $coach->name() : ''), true);
    if ($edit) {
        $form->addElement(new RMFormText(__('Nombre corto', 'admin_team'), 'nameid', 50, 150, $coach->nameId()));
    }
    $form->addElement(new RMFormText(__('Cargo', 'admin_team'), 'role', 50, 150, $edit ? $coach->role() : ''), true);
    $form->addElement(new RMFormFile(__('Imagen', 'admin_team'), 'image', 45, $mc['filesize'] * 1024));
    if ($edit && $coach->image() != '') {
        $form->addElement(new RMFormLabel(__('Imagen actual', 'admin_team'), "<img src='" . XOOPS_URL . "/uploads/teams/coachs/ths/" . $coach->image() . "' alt='' />"));
    }
    $form->addElement(new RMFormEditor(__('Biografía', 'admin_team'), 'bio', '90%', '300px', $edit ? $coach->bio('e') : ''));
    $form->addElement(new RMFormSubTitle(__('Equipos', 'admin_team'), 1));
    $ele = new RMFormCheck(__('Seleccionar equipos', 'admin_team'));
    $ele->asTable(3);
    $sql = "SELECT * FROM " . $db->prefix("coach_teams") . " ORDER BY name";
    $result = $db->query($sql);
    if ($edit) {
        $teams = $coach->teams(false);
    }
    while ($row = $db->fetchArray($result)) {
        $team = new TCTeam();
        $team->assignVars($row);
        $cat =& $team->category(true);
        $ele->addOption($team->name() . " <span class='coachNameCat'>(" . $cat->name() . ")</span>", 'teams[]', $team->id(), $edit ? in_array($team->id(), $teams) ? 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=\'coachs.php\';"');
    $form->addElement($ele);
    $form->addElement(new RMFormHidden('op', $edit ? 'saveedit' : 'save'));
    if ($edit) {
        $form->addElement(new RMFormHidden('id', $id));
    }
    $form->display();
    xoops_cp_footer();
}
Exemplo n.º 2
0
 $ele = new RMFormButtonGroup();
 $ele->addButton('sbt', __('Save Changes', 'bxpress'), 'submit');
 $ele->addButton('cancel', _CANCEL, 'button', 'onclick="window.location = \'topic.php?pid=' . $post->id() . '#p' . $post->id() . '\'";');
 $form->addElement($ele);
 // Adjuntar Archivos
 if ($forum->attachments() && $forum->isAllowed($xoopsUser ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS, 'attach')) {
     $forma = new RMForm('<a name="attachments"></a>' . __('Attached Files', 'bxpress'), 'frmAttach', 'edit.php');
     $forma->addElement(new RMFormSubTitle(sprintf(__('You can upload new files to this post. You have a limit of <strong>%s</strong> attachment per post.', 'bxpress'), $xoopsModuleConfig['attachlimit']), 1, 'even'));
     if ($post->totalAttachments() < $xoopsModuleConfig['attachlimit']) {
         $ele = new RMFormFile(__('Attach File:', 'bxpress'), 'attach', 45, $xoopsModuleConfig['maxfilesize'] * 1024);
         $ele->setDescription(sprintf(__('Allowed File Types: %s', 'bxpress'), implode(',', $forum->extensions())));
         $forma->addElement($ele, true);
         $forma->setExtra('enctype="multipart/form-data"');
     }
     // Lista de Archivos Adjuntos
     $list = new RMFormCheck(__('Cuerrent Attachments', 'bxpress'));
     $list->asTable(1);
     foreach ($post->attachments() as $file) {
         $list->addOption("<img src='" . $file->getIcon() . "' align='absmiddle' /> " . $file->name() . " (" . RMUtilities::formatBytesSize($file->size()) . ")", 'files[]', $file->id());
     }
     $forma->addElement($list);
     $ele = new RMFormButtonGroup();
     if ($post->totalAttachments() < $xoopsModuleConfig['attachlimit']) {
         $ele->addButton('upload', __('Upload File', 'bxpress'), 'submit');
     }
     $ele->addButton('delete', __('Delete File(s)', 'bxpress'), 'button', 'onclick="document.forms[\'frmAttach\'].op.value=\'delete\'; submit();"');
     $ele->addButton('cancel', __('Cancel', 'bxpress'), 'button', 'onclick="window.location = \'topic.php?pid=' . $post->id() . '#p' . $post->id() . '\'";');
     $forma->addElement($ele);
     $forma->addElement(new RMFormHidden('op', 'upload'));
     $forma->addElement(new RMFormHidden('id', $id));
 }
Exemplo n.º 3
0
/**
* @desc Formulario de albumes
**/
function formSets()
{
    global $xoopsUser, $db, $xoopsConfig, $xoopsOption, $xoopsModuleConfig, $tpl, $ids, $referer;
    $page = rmc_server_var($_REQUEST, 'pag', 1);
    if (!$referer) {
        $referer = GSFunctions::get_url() . ($xoopsModuleConfig['urlmode'] ? 'cp/images/pag/' . $page . '/' : '?cp=images&amp;pag=' . $page);
    } else {
        $referer = base64_decode($referer);
    }
    $ids = empty($ids) ? rmc_server_var($_REQUEST, 'ids', 0) : $ids;
    $xoopsOption['template_main'] = 'gs_formaddsets.html';
    include 'header.php';
    GSFunctions::makeHeader();
    //Verificamos si nos proporcionaron al menos un imagen para actualizar
    if (!is_array($ids) && $ids <= 0) {
        redirect_header('./cpanel.php', 2, __('You must select one image at least!', 'galleries'));
        die;
    }
    if (!is_array($ids)) {
        $ids = array($ids);
    }
    $form = new RMForm(__('Add images to an album', 'galleries'), 'frmset', 'cpanel.php');
    //Obtenemos los albumes del usuario
    $ele = new RMFormCheck(__('Albums', 'galleries'));
    $ele->setDescription(__('Select the albums where you want to assign the selected images.', 'galleries'));
    $sql = "SELECT * FROM " . $db->prefix('gs_sets') . " WHERE owner='" . $xoopsUser->uid() . "'";
    $result = $db->query($sql);
    while ($rows = $db->fetchArray($result)) {
        $ele->addOption($rows['title'], 'albums[]', $rows['id_set']);
    }
    $form->addElement($ele, true);
    $form->addElement(new RMFormHidden('op', 'savesets'));
    foreach ($ids as $k => $v) {
        $form->addElement(new RMFormHidden('ids[' . $k . ']', $v));
    }
    $form->addElement(new RMFormHidden('page', $page));
    $form->addElement(new RMFormHidden('referer', $referer));
    $buttons = new RMFormButtonGroup();
    $buttons->addButton('sbt', _SUBMIT, 'submit');
    $buttons->addButton('cancel', _CANCEL, 'button', 'onclick="window.location=\'' . $referer . '\'"');
    $form->addElement($buttons);
    $tpl->assign('form_sets', $form->render());
    include 'footer.php';
}
Exemplo n.º 4
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();
}
Exemplo n.º 5
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();
}