/** * Creamos una nueva categor?a */ function rmmfNew() { global $db, $mc; define('RMCLOCATION', 'newcategory'); MFFunctions::toolbar(); $form = new RMForm(__('New Category', 'admin_myfolder'), 'frmNew', 'categos.php'); $form->addElement(new RMFormText(__('Name', 'admin_mywords'), 'nombre', 50, 150)); $ele = new RMFormSelect(__('Parent category', 'admin_myfolder'), 'parent'); $ele->addOption('', __('Select category...', 'admin_myfolder'), 1); $result = array(); MFFunctions::get_categories($result); foreach ($result as $k => $v) { $ele->addOption($v['id_cat'], $v['nombre']); } $form->addElement($ele); $form->addElement(new RMFormText(__('Display order', 'admin_myfolder'), 'orden', 5, 5, 0)); $ele = new RMFormEditor(__('Description', 'admin_myfolder'), 'desc', '96%', '300px'); $form->addElement($ele); $ele = new RMFormButtonGroup(''); $ele->addButton('sbt', __('Create Category', 'admin_myfolder'), 'submit'); $ele->addButton('cancel', __('Cancel', 'admin_myfolder'), 'button', 'onclick="history.go(-1);"'); $form->addElement($ele, false); $form->addElement(new RMFormHidden('op', 'save')); xoops_cp_header(); $form->display(); xoops_cp_footer(); }
/** * @desc Formulario de licencias **/ function formLicences($edit = 0) { global $xoopsModule; $id = rmc_server_var($_REQUEST, 'id', 0); if ($edit) { //Verificamos si la licencia es válida if ($id <= 0) { redirectMsg('licenses.php', __('You must provide a valid licencse ID!', 'dtransport'), 1); die; } //Verificamos si la licencia existe $lc = new DTLicense($id); if ($lc->isNew()) { redirectMsg('licenses.php', __('Specified licence ID does not exists!', 'dtransport'), 1); die; } } xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> » " . ($edit ? __('Edit Licence', 'dtransport') : __('New Licence', 'dtransport'))); xoops_cp_header(); $form = new RMForm($edit ? __('Edit Licence', 'dtransport') : __('New Licence', 'dtransport'), 'frmlic', 'licenses.php'); $form->addElement(new RMFormText(__('Licence name', 'dtransport'), 'name', 50, 150, $edit ? $lc->name() : ''), true); $form->addElement(new RMFormText(__('Licence reference URL', 'dtransport'), 'url', 50, 255, $edit ? $lc->link() : '')); $ele = new RMFormSelect(__('Licence type', 'dtranport'), 'type'); $ele->addOption(0, __('Open source licence', 'dtransport'), $edit ? $lc->type() == 0 ? 1 : 0 : 0); $ele->addOption(1, __('Restrictive licence', 'dtranport'), $edit ? $lc->type() == 1 ? 1 : 0 : 0); $form->addElement($ele); $form->addElement(new RMFormHidden('action', $edit ? 'saveedit' : 'save')); $form->addElement(new RMFormHidden('id', $id)); $buttons = new RMFormButtonGroup(); $buttons->addButton('sbt', __('Save Changes', 'dtransport'), 'submit'); $buttons->addButton('cancel', __('Cancel', 'stransport'), 'button', 'onclick="window.location=\'licenses.php\';"'); $form->addElement($buttons); $form->display(); xoops_cp_footer(); }
function pw_comments_edit($options, &$form) { global $db; $form = new RMForm(__('Block Options', 'works')); $form->addElement(new RMFormText(__('Comments number', 'works'), 'options[0]', 5, 5, $options[0] ? $options[0] : 1), true); $ele = new RMFormSelect(__('Works type', 'works'), 'options[1]'); $ele->addOption(0, __('Random', 'works'), $options[1] == 0 ? 1 : 0); $ele->addOption(1, __('Recent works', 'works'), $options[1] == 1 ? 1 : 0); $form->addElement($ele); return $form->render(false); }
/** * @desc Formulario de creación/edición de clientes **/ function formClients($edit = 0) { global $xoopsModule, $db; $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0; $page = isset($_REQUEST['pag']) ? $_REQUEST['pag'] : ''; $limit = isset($_REQUEST['limit']) ? intval($_REQUEST['limit']) : 15; $ruta = "pag={$page}&limit={$limit}"; if ($edit) { //Verificamos si el cliente es válido if ($id <= 0) { redirectMsg('./clients.php?' . $ruta, __('You must provide a customer ID', 'works'), 1); die; } //Verificamos si el cliente existe $client = new PWClient($id); if ($client->isNew()) { redirectMsg('./clients.php?' . $ruta, __('Specified customer does not exists!', 'works'), 1); die; } } xoops_cp_location('<a href="./">' . $xoopsModule->name() . "</a> » <a href='./clients.php'>" . __('Customers', 'works') . "</a> »" . ($edit ? __('Edit Customer', 'works') : __('New Customer', 'works'))); RMTemplate::get()->assign('xoops_pagetitle', __('Customers', 'works')); PWFunctions::toolbar(); xoops_cp_header(); $form = new RMForm($edit ? __('Edit Customer', 'works') : __('New Customer', 'works'), 'frmClient', 'clients.php'); $form->addElement(new RMFormText(__('Name', 'works'), 'name', 50, 200, $edit ? $client->name() : ''), true); $form->addElement(new RMFormText(__('Company', 'works'), 'business', 50, 200, $edit ? $client->businessName() : '')); $form->addElement(new RMFormText(__('Email address', 'works'), 'mail', 50, 100, $edit ? $client->email() : '')); $form->addElement(new RMFormTextArea(__('Description', 'works'), 'desc', 4, 50, $edit ? $client->desc() : ''), true); //Tipos de Cliente $ele = new RMFormSelect(__('Type', 'works'), 'type'); $ele->addOption(0, _SELECT); $result = $db->query("SELECT * FROM " . $db->prefix('pw_types')); while ($row = $db->fetchArray($result)) { $ele->addOption($row['id_type'], $row['type'], $edit ? $row['id_type'] == $client->type() ? 1 : 0 : 0); } $form->addElement($ele, true, 'noselect:0'); $form->addElement(new RMFormHidden('op', $edit ? 'saveedit' : 'save')); $form->addElement(new RMFormHidden('id', $id)); $form->addElement(new RMFormHidden('page', $page)); $form->addElement(new RMFormHidden('limit', $limit)); $ele = new RMFormButtonGroup(); $ele->addButton('sbt', $edit ? __('Save Changes', 'works') : __('Create Customer', 'works'), 'submit'); $ele->addButton('cancel', __('Cancel', 'works'), 'button', 'onclick="window.location=\'clients.php?' . $ruta . '\';"'); $form->addElement($ele); //Event $form = RMEvents::get()->run_event('works.form.customers', $form); $form->display(); xoops_cp_footer(); }
/** * Show the form to edit or create a category * @param int edit */ function m_categories_form($edit = 0) { global $mc, $xoopsModule, $db; MCHFunctions::toolbar(); RMTemplate::get()->assign('xoops_pagetitle', $edit ? __('Edit Category', 'match') : __('Add Category', 'match')); xoops_cp_location('<a href="./">' . $xoopsModule->name() . "</a> » \n <a href='categories.php'>" . __('Categories', 'match') . '</a> » ' . ($edit ? __('Edit Category', 'match') : __('Add Category', 'match'))); xoops_cp_header(); $id = rmc_server_var($_REQUEST, 'id', 0); if ($edit) { //Verificamos si la categoría es válida if ($id <= 0) { redirectMsg('./categories.php', __('Provide a category ID!', 'match'), 1); die; } //Verificamos si la categoría existe $cat = new MCHCategory($id); if ($cat->isNew()) { redirectMsg('./categories.php', __('Specified category was not found!', 'match'), 1); die; } } $form = new RMForm($edit ? __('Edit Category', 'match') : __('Add Category', 'match'), 'frmNew', 'categories.php'); $form->addElement(new RMFormText(__('Name', 'match'), 'name', 50, 150, $edit ? $cat->getVar('name') : ''), true); if ($edit) { $form->addElement(new RMFormText(__('Short name', 'match'), 'nameid', 50, 150, $cat->getVar('nameid')), true); } $form->addElement(new RMFormEditor(__('Description', 'match'), 'desc', '100%', '250px', $edit ? $cat->getVar('description', 'e') : '')); $sel_cats = new RMFormSelect(__('Parent category:', 'match'), 'parent', 0, $edit ? $cat->getVar('parent') : 0); $categories = array(); MCHFunctions::categories_tree($categories, 0, 0, true, $edit ? $cat->id() : 0, '`name` ASC'); $sel_cats->addOption(0, __('Select category...', 'match'), $edit ? $cat->getVar('parent') == 0 ? 1 : 0 : 1); foreach ($categories as $catego) { $sel_cats->addOption($catego['id'], str_repeat('—', $catego['indent']) . ' ' . $catego['name']); } $form->addElement($sel_cats); $form->addElement(new RMFormYesNo(__('Enable category', 'match'), 'active', $edit ? $cat->getVar('active') : 1)); $form->addElement(new RMFormHidden('action', $edit ? 'saveedit' : 'save')); if ($edit) { $form->addElement(new RMFormHidden('id', $cat->id())); } $ele = new RMFormButtonGroup(); $ele->addButton('sbt', $edit ? __('Save Changes!', 'match') : __('Add Now!', 'match'), 'submit'); $ele->addButton('cancel', _CANCEL, 'button', 'onclick="window.location=\'categos.php\';"'); $form->addElement($ele); $form = RMEvents::get()->run_event('match.form.categories', $form); $form->display(); xoops_cp_footer(); }
/** * @desc Formulario de creación/edición de categorías **/ function formCategos($edit = 0) { global $xoopsModule, $db; $id = rmc_server_var($_GET, 'id', 0); if ($edit) { //Verificamos si categoría es válida if ($id <= 0) { redirectMsg('categories.php', __('Specified category is not valid!', 'dtransport'), 1); } //Verificamos si la categoría existe $cat = new DTCategory($id); if ($cat->isNew()) { redirectMsg('categories.php', __('Specified category does not exists!', 'dtransport'), 1); } } DTFunctions::toolbar(); xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> » " . ($edit ? __('Edit category', 'dtransport') : __('New category', 'dtransport'))); xoops_cp_header(); $form = new RMForm($edit ? __('Edit Category', 'dtransport') : __('New Category', 'dtransport'), 'frmcat', 'categories.php'); $form->addElement(new RMFormText(__('Category name', 'dtransport'), 'name', 50, 150, $edit ? $cat->name() : ''), true); if ($edit) { $form->addElement(new RMFormText(__('Category short name', 'dtransport'), 'nameid', 50, 150, $edit ? $cat->nameId() : '')); } $form->addElement(new RMFormTextArea(__('Description', 'dtransport'), 'desc', 5, 40, $edit ? $cat->desc('e') : '')); //Lista de categorías $ele = new RMFormSelect(__('Root category', 'dtransport'), 'parent'); $ele->addOption(0, __('Select category...', 'dtransport')); $categos = array(); DTFunctions::getCategos($categos, 0, 0, $edit ? $cat->id() : array()); foreach ($categos as $catego) { $ele->addOption($catego['id_cat'], str_repeat('--', $catego['jumps']) . ' ' . $catego['name'], $edit ? $catego['id_cat'] == $cat->parent() ? 1 : 0 : 0); } $form->addElement($ele); $form->addElement(new RMFormYesno(__('Active category', 'dtransport'), 'active', $edit ? $cat->active() : 1)); $form->addElement(new RMFormHidden('action', $edit ? 'saveedit' : 'save')); $form->addElement(new RMFormHidden('id', $id)); $buttons = new RMFormButtonGroup(); $buttons->addButton('sbt', __('Submit', 'dtransport'), 'submit'); $buttons->addButton('cancel', __('Cancel', 'dtransport'), 'button', 'onclick="window.location=\'categories.php\';"'); $form->addElement($buttons); $form->display(); xoops_cp_footer(); }
/** * Presenta un formulario para la creación de una nueva * categoría para los artículos */ function newForm($edit = 0) { global $xoopsModule; if ($edit) { $id = isset($_GET['id']) ? $_GET['id'] : 0; if ($id <= 0) { redirectMsg('cats.php', __('You must provide a category ID to edit!', 'qpages'), 1); die; } // Cargamos la categoría $catego = new QPCategory($id); // Si no existe entonces devolvemos un error if ($catego->isNew()) { redirectMsg('cats.php', __('Specified category does not exists!', 'qpages'), 1); die; } } xoops_cp_location('<a href="./">' . $xoopsModule->name() . '</a> » ' . ($edit ? __('Edit Category', 'qpages') : __('New Category', 'qpages'))); xoops_cp_header(); $cats = array(); qpArrayCategos($cats, 0, 0, $edit ? array($id) : 0); $form = new RMForm($edit ? __('Edit Category', 'qpages') : __('New Category', 'qpages'), 'frmNew', 'cats.php'); $form->addElement(new RMFormText(__('Category name', 'qpages'), 'nombre', 50, 150, $edit ? $catego->getName() : ''), true); $form->addElement(new RMFormTextArea(__('Description', 'qpages'), 'descripcion', 5, 45, $edit ? $catego->getVar('descripcion', 'e') : '')); $ele = new RMFormSelect(__('Category parent', 'qpages'), 'parent'); $ele->addOption(0, _SELECT, $edit ? $catego->getParent() == 0 ? 1 : 0 : 1); foreach ($cats as $k) { $ele->addOption($k['id_cat'], str_repeat("-", $k['saltos']) . ' ' . $k['nombre'], $edit ? $catego->getParent() == $k['id_cat'] ? 1 : 0 : 0); } $form->addElement($ele); $form->addElement(new RMFormHidden('op', $edit ? 'saveedit' : 'save')); if ($edit) { $form->addElement(new RMFormHidden('id', $id)); } $ele = new RMFormButtonGroup('', ' '); $ele->addButton('sbt', $edit ? __('Update Category', 'qpages') : __('Create Category', 'qpages'), 'submit'); $ele->addButton('cancel', __('Cancel', 'qpages'), 'button'); $ele->setExtra('cancel', "onclick='history.go(-1);'"); $form->addElement($ele); $form->display(); xoops_cp_footer(); }
/** * @desc Permitirá al administrador elegir los temas que serán * eliminados despues de un cierto período **/ function prune() { global $xoopsModule; xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> » " . __('Prune Posts', 'bxpress')); xoops_cp_header(); bXFunctions::menu_bar(); $db = XoopsDatabaseFactory::getDatabaseConnection(); $form = new RMForm(__('Prune Posts', 'bxpress'), 'frmprune', 'prune.php'); //Lista de foros $ele = new RMFormSelect(__('Prune from forum', 'bxpress'), 'forums'); $ele->addOption('', __('Select option...', 'bxpress')); $ele->addOption(0, __('All forums', 'bxpress')); $sql = "SELECT id_forum,name FROM " . $db->prefix('bxpress_forums'); $result = $db->queryF($sql); while ($row = $db->fetchArray($result)) { $ele->addOption($row['id_forum'], $row['name']); } $form->addElement($ele, true); //Dias de antigüedad de temas $days = new RMFormText(__('Days old', 'bxpress'), 'days', 3, 3, 30); $days->setDescription(__('Delete topics older than these days', 'bxpress')); $form->addElement($days, true); //Lista de opciones para purgar temas $opc = new RMFormSelect(__('Topics to delete', 'bxpress'), 'option'); $opc->addOption('', __('Select option', 'bxpress')); $opc->addOption(1, __('All topics', 'bxpress')); $opc->addOption(2, __('Unanswered Topics', 'bxpress')); $form->addElement($opc, true); //Temas fijos $form->addElement(new RMFormYesno(__('Delete Sticky Topics', 'bxpress'), 'fixed')); $buttons = new RMFormButtonGroup(); $buttons->addButton('sbt', __('Prune Now!'), 'submit', 'onclick="return confirm(\'' . __('Do you really wish to delete the topics? \\nThis action will delete the data permanently.', 'bxpress') . '\');"'); $buttons->addButton('cancel', __('Cancel', 'bxpress'), 'button', 'onclick="history.go(-1);"'); $form->addElement($buttons); $form->addElement(new RMFormHidden('action', 'deltopics')); $form->display(); xoops_cp_footer(); }
/** * @desc Muestra el formulario para creación de Foros * @param int $edit Determina si se esta editando un foro existente */ function bx_show_form($edit = 0) { global $xoopsModule, $xoopsConfig; if ($edit) { $id = rmc_server_var($_REQUEST, 'id', 0); if ($id <= 0) { redirectMsg('forums.php', __('Provided ID is not valid!', 'bxpress'), 1); die; } $forum = new bXForum($id); if ($forum->isNew()) { redirectMsg('forums.php', __('Specified forum does not exists!', 'bxpress'), 1); die; } } bXFunctions::menu_bar(); RMTemplate::get()->set_help('http://www.redmexico.com.mx/docs/bxpress-forums/foros/standalone/1/#crear-foro'); RMTemplate::get()->add_style('admin.css', 'bxpress'); xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> » " . ($edit ? __('Edit Forum', 'bxpress') : __('New Forum', 'bxpress'))); xoops_cp_header(); $bcHand = new bXCategoryHandler(); $bfHand = new bXForumHandler(); $form = new RMForm($edit ? __('Edit Forum', 'bxpress') : __('New Forum', 'bxpress'), 'frmForum', 'forums.php'); // Categorias $ele = new RMFormSelect(__('Category', 'bxpress'), 'cat', 0, $edit ? array($forum->category()) : null); $ele->addOption(0, __('Select category...', 'bxpress'), $edit ? 0 : 1); $ele->addOptionsArray($bcHand->getForSelect()); $form->addElement($ele, true, 'noselect:0'); // NOmbre $form->addElement(new RMFormText(__('Forum name', 'bxpress'), 'name', 50, 150, $edit ? $forum->name() : ''), true); // Descripcion $form->addElement(new RMFormEditor(__('Forum description', 'bxpress'), 'desc', '90%', '300px', $edit ? $forum->description() : '')); // Activo $form->addElement(new RMFormYesNo(__('Activate forum', 'bxpress'), 'active', $edit ? $forum->active() : 1)); // Firmas $form->addElement(new RMFormYesNo(__('Allow signatures in the posts', 'bxpress'), 'sig', $edit ? $forum->signature() : 1)); // Temas Populares $form->addElement(new RMFormText(__('Answers to match a topic as popular', 'bxpress'), 'hot_threshold', 10, 5, $edit ? $forum->hotThreshold() : 10), true, 'bigger:1'); // Orden en la lista $form->addElement(new RMFormText(__('Order in the list', 'bxpress'), 'order', 10, 5, $edit ? $forum->order() : 0), false, 'bigger:-1'); // Adjuntos $form->addElement(new RMFormYesNo(__('Allow attachments', 'bxpress'), 'attachments', $edit ? $forum->attachments() : 1)); $ele = new RMFormText(__('Maximum attachments file size', 'bxpress'), 'attach_maxkb', 10, 20, $edit ? $forum->maxSize() : 50); $ele->setDescription(__('Specify this value in Kilobytes', 'bxpress')); $form->addElement($ele, false, 'bigger:0'); $ele = new RMFormText(__('Allowed file types', 'bxpress'), 'attach_ext', 50, 0, $edit ? implode("|", $forum->extensions()) : 'zip|tar|jpg|gif|png|gz'); $ele->setDescription(__('Specified the extensions of allowed file types separating each one with "|" and without the dot.', 'bxpress')); $form->addElement($ele); // Grupos con permiso if ($edit) { $grupos = $forum->permissions(); } $form->addElement(new RMFormGroups(__('Can view the forum', 'bxpress'), 'perm_view', 1, 1, 5, $edit ? $grupos['view'] : array(0))); $form->addElement(new RMFormGroups(__('Can start new topics', 'bxpress'), 'perm_topic', 1, 1, 5, $edit ? $grupos['topic'] : array(1, 2))); $form->addElement(new RMFormGroups(__('Can answer', 'bxpress'), 'perm_reply', 1, 1, 5, $edit ? $grupos['reply'] : array(1, 2))); $form->addElement(new RMFormGroups(__('Can edit their posts', 'bxpress'), 'perm_edit', 1, 1, 5, $edit ? $grupos['edit'] : array(1, 2))); $form->addElement(new RMFormGroups(__('Can delete', 'bxpress'), 'perm_delete', 1, 1, 5, $edit ? $grupos['delete'] : array(1))); $form->addElement(new RMFormGroups(__('Can vote', 'bxpress'), 'perm_vote', 1, 1, 5, $edit ? $grupos['vote'] : array(1, 2))); $form->addElement(new RMFormGroups(__('Can attach', 'bxpress'), 'perm_attach', 1, 1, 5, $edit ? $grupos['attach'] : array(1, 2))); $form->addElement(new RMFormGroups(__('Can send without approval', 'bxpress'), 'perm_approve', 1, 1, 5, $edit ? $grupos['approve'] : array(1, 2))); $ele = new RMFormButtonGroup(); $ele->addButton('sbt', $edit ? __('Save Changes', 'bxpress') : __('Create Forum', 'bxpress'), 'submit', '', 1); $ele->addButton('cancel', __('Cancel', 'bxpress'), 'button', 'onclick="window.location=\'forums.php\';"'); $form->addElement($ele); $form->addElement(new RMFormHidden('action', $edit ? 'saveedit' : 'save')); if ($edit) { $form->addElement(new RMFormHidden('id', $forum->id())); } $form->display(); xoops_cp_footer(); }
foreach ($item->tags(true) as $tag) { $tags .= $tags == '' ? $tag->tag() : ", " . $tag->tag(); } } $form->addElement(new RMFormText(__('Tags', 'dtransport'), 'tags', 50, 255, $edit ? $tags : ''))->setDescription(__('Separate each tag with comma (,).', 'dtransport')); //Licencias $ele = new RMFormSelect(__('Licenses', 'dtransport'), 'licences[]', 1, $edit ? $item->licences() ? $item->licences() : array(0) : array(0)); $ele->addOption('0', __('Other', 'dtransport')); $sql = "SELECT * FROM " . $db->prefix('dtrans_licences'); $result = $db->queryF($sql); while ($rows = $db->fetchArray($result)) { $ele->addOption($rows['id_lic'], $rows['name']); } $form->addElement($ele, true); //Plataformas $ele = new RMFormSelect(__('Platforms', 'dtransport'), 'platforms[]', 1, $edit ? $item->platforms() ? $item->platforms() : array(0) : array(0)); $ele->addOption('0', __('Other', 'dtransport')); $sql = "SELECT * FROM " . $db->prefix('dtrans_platforms'); $result = $db->queryF($sql); while ($rows = $db->fetchArray($result)) { $ele->addOption($rows['id_platform'], $rows['name']); } $form->addElement($ele, true); // Grupos autorizados $form->addElement(new RMFormGroups(__('Allowed groups', 'dtransport'), 'groups', 1, 1, 1, $edit ? $item->getVar('groups') : array(0))); // Descarga segura if ($mc['secure_public']) { $form->addElement(new RMFormYesNo(__('Protected download', 'dtransport'), 'secure', $edit ? $item->getVar('secure') : 0))->setDescription(__('Protected downloads will be stored in a secure directory and only can not be download directly.', 'dtransport')); } // Descarga con contraseña if ($mc['pass_public']) {
function m_teams_form($edit = 0) { global $mc, $xoopsModule, $db; MCHFunctions::toolbar(); RMTemplate::get()->assign('xoops_pagetitle', $edit ? __('Edit Team', 'match') : __('Add Team', 'match')); xoops_cp_location('<a href="./">' . $xoopsModule->name() . "</a> » \n <a href='teams.php'>" . __('Teams', 'match') . '</a> » ' . ($edit ? __('Edit Team', 'match') : __('Add Team', 'match'))); xoops_cp_header(); $id = rmc_server_var($_REQUEST, 'id', 0); if ($edit) { //Verificamos si la categoría es válida if ($id <= 0) { redirectMsg('./teams.php', __('Provide a team ID!', 'match'), 1); die; } //Verificamos si la categoría existe $team = new MCHTeam($id); if ($team->isNew()) { redirectMsg('./teams.php', __('Specified team was not found!', 'match'), 1); die; } } $form = new RMForm($edit ? __('Edit Team', 'match') : __('Add Team', 'match'), 'frmNew', 'teams.php'); $form->setExtra('enctype="multipart/form-data"'); $form->addElement(new RMFormText(__('Name', 'match'), 'name', 50, 150, $edit ? $team->getVar('name') : ''), true); if ($edit) { $form->addElement(new RMFormText(__('Short name', 'match'), 'nameid', 50, 150, $team->getVar('nameid')), true); } $form->addElement(new RMFormEditor(__('Team Information', 'match'), 'info', '100%', '250px', $edit ? $team->getVar('info', 'e') : '')); $sel_cats = new RMFormSelect(__('Category:', 'match'), 'category', 0, $edit ? array($team->getVar('category')) : 0); $categories = array(); MCHFunctions::categories_tree($categories, 0, 0, true, 0, '`name` ASC'); $sel_cats->addOption(0, __('Select category...', 'match'), $edit ? $team->getVar('category') == 0 ? 1 : 0 : 1); foreach ($categories as $catego) { $sel_cats->addOption($catego['id'], str_repeat('—', $catego['indent']) . ' ' . $catego['name']); } $form->addElement($sel_cats, true); $form->addElement(new RMFormYesNo(__('Active', 'match'), 'active', $edit ? $team->getVar('active') : 1)); $form->addElement(new RMFormDate(__('Registered on', 'match'), 'created', $edit ? $team->getVar('created') : time(), false)); $form->addElement(new RMFormFile(__('Team logo', 'match'), 'logo', 45)); if ($edit) { $form->addElement(new RMFormLabel(__('Current logo', 'match'), '<img src="' . MCH_UP_URL . '/' . $team->getVar('logo') . '" alt="' . $team->getVar('name') . '" />')); } $form->addElement(new RMFormHidden('action', $edit ? 'saveedit' : 'save')); if ($edit) { $form->addElement(new RMFormHidden('id', $team->id())); } $ele = new RMFormButtonGroup(); $ele->addButton('sbt', $edit ? __('Save Changes!', 'match') : __('Add Now!', 'match'), 'submit'); $ele->addButton('cancel', _CANCEL, 'button', 'onclick="window.location=\'teams.php\';"'); $form->addElement($ele); $form = RMEvents::get()->run_event('match.form.teams', $form); $form->display(); xoops_cp_footer(); }
/** * 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(); }
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(); }
/** * Presenta un formulario para la creación de una nueva * categoría para los artículos */ function newForm() { global $xoopsModule; $id = isset($_GET['id']) ? $_GET['id'] : 0; if ($id <= 0) { redirectMsg('categories.php', __('You must specify a valid category', 'mywords'), 1); die; } // Cargamos la categoría $catego = new MWCategory($id); // Si no existe entonces devolvemos un error if ($catego->isNew()) { redirectMsg('cats.php', __('Specified category not exists!', 'mywords'), 1); die; } MWFunctions::include_required_files(); xoops_cp_location('<a href="./">' . $xoopsModule->name() . '</a> » ' . __('New Category', 'mywords')); xoops_cp_header(); $cats = array(); MWFunctions::categos_list($cats, 0, 0, true, $id); $form = new RMForm($edit ? __('Edit Category', 'mywords') : __('Edit Category', 'mywords'), 'frmNew', 'categories.php'); $form->styles('width: 30%;', 'odd'); $form->addElement(new RMFormText(__('Category name', 'mywords'), 'name', 50, 150, $catego->getVar('name')), true); $form->addElement(new RMFormText(__('Category slug', 'mywords'), 'shortname', '', '150', $catego->getVar('shortname', 'n'))); $form->addElement(new RMFormTextArea(__('Category description', 'mywords'), 'desc', 5, 45, $catego->getVar('description', 'e'))); $ele = new RMFormSelect(__('Category Parent', 'mywords'), 'parent'); $ele->addOption(0, _SELECT, $catego->getVar('parent') == 0 ? 1 : 0); foreach ($cats as $k) { $ele->addOption($k['id_cat'], str_repeat("-", $k['indent']) . ' ' . $k['name'], $catego->getVar('parent') == $k['id_cat'] ? 1 : 0); } $form->addElement($ele); $form->addElement(new RMFormHidden('op', 'saveedit')); $form->addElement(new RMFormHidden('id', $id)); $ele = new RMFormButtonGroup('', ' '); $ele->addButton('sbt', __('Update Category', 'mywords'), 'submit'); $ele->addButton('cancel', __('Cancel', 'mywords'), 'button'); $ele->setExtra('cancel', "onclick='history.go(-1);'"); $form->addElement($ele); $form->display(); xoops_cp_footer(); }
/** * Prepares the form field that will be shown on settings form * and returns the HTML code. * <br><br> * <p><strong>Usage:</strong></p> * <code>echo RMSettings::render_field( string 'field_id', array $field );</code> * * @param stdClass $field <p>An object with all field values, including caption, id, description, type, value, etc.</p> * @return string */ public static function render_field($field) { if (empty($field)) { return null; } $tc = TextCleaner::getInstance(); switch ($field->field) { case 'textarea': if ($field->type == 'array') { // this is exceptional.. only when value type is arrayneed a smarter way for this $ele = $field->value != '' ? new RMFormTextArea($field->caption, $field->name, 4, 45, $tc->specialchars(implode('|', $field->value))) : new RMFormTextArea($field->title, $field->name, 4, 45); } else { $ele = new RMFormTextArea($field->caption, $field->name, 4, 50, $tc->specialchars($field->value)); } break; case 'select': $ele = new RMFormSelect($field->caption, $field->name, 0, array($field->value)); foreach ($field->options as $caption => $value) { $ele->addOption($value, defined($caption) ? constant($caption) : $caption); } break; case 'select_multi': $ele = new RMFormSelect($field->caption, $field->name, 1, array($field->value)); $options = $field->options; foreach ($options as $value => $caption) { $value = defined($value) ? constant($value) : $value; $caption = defined($caption) ? constant($caption) : $caption; $ele->addOption($value, $caption); } break; case 'yesno': $ele = new RMFormYesNo($field->caption, $field->name, $field->value); break; case 'theme': case 'theme_multi': $ele = new RMFormTheme($field->caption, $field->name, $field->field == 'theme_multi' ? 1 : 0, 0, $field->value); break; case 'cu-theme': case 'cu-theme-multi': $ele = new RMFormTheme($field->caption, $field->name, $field->field == 'cu-theme-multi' ? 1 : 0, 0, $field->value, 1, 'GUI'); break; case 'tplset': $ele = new RMFormSelect($field->caption, $field->name, 0, array($field->value)); $tplset_handler =& xoops_gethandler('tplset'); $tplsetlist = $tplset_handler->getList(); asort($tplsetlist); foreach ($tplsetlist as $key => $name) { $ele->addOption($key, $name); } break; case 'cpanel': $ele = new RMFormSelect($field->caption, $field->name, 0, array($field->value)); xoops_load("cpanel", "system"); $list = XoopsSystemCpanel::getGuis(); $ele->addOptionArray($list); break; case 'timezone': $ele = new RMFormTimeZoneField($field->caption, $field->name, 0, 0, $field->value); break; case 'language': case 'language_multi': $langs = XoopsLists::getLangList(); $ele = new RMFormSelect($field->caption, $field->name, $field->field == 'language_multi' ? 1 : 0, $field->value); foreach ($langs as $caption => $value) { $ele->addOption($value, $caption); } break; case 'cu-language': case 'cu-language-multi': $ele = new RMFormLanguageField($field->caption, $field->name, $field->field == 'cu-language-multi' ? 1 : 0, 0, $field->value); break; case 'startpage': $ele = new RMFormSelect($field->caption, $field->name, 0, array($field->value)); $module_handler =& xoops_gethandler('module'); $criteria = new CriteriaCompo(new Criteria('hasmain', 1)); $criteria->add(new Criteria('isactive', 1)); $moduleslist = $module_handler->getList($criteria, true); $moduleslist['--'] = _MD_AM_NONE; $ele->addOptionsArray($moduleslist); break; case 'group': case 'group_multi': $ele = new RMFormGroups($field->caption, $field->name, $field->field == 'group_multi' ? 1 : 0, 0, 1, $field->value); break; case 'user': case 'user_multi': $ele = new RMFormUser($field->caption, $field->name, $field->field == 'user_multi' ? 1 : 0, $field->value); break; case 'module_cache': $ele = new RMFormCacheModuleField($field->caption, $field->name, $field->value); break; case 'site_cache': $ele = new RMFormSelect($field->caption, $field->name, 0, $field->value); $ele->addOptionArray(array('0' => __('No cache', 'rmcommon'), '30' => sprintf(__('%u seconds', 'rmcommon'), 30), '60' => __('1 minute', 'rmcommon'), '300' => sprintf(__('%u minutes', 'rmcommon'), 5), '1800' => sprintf(__('%u minutes', 'rmcommon'), 30), '3600' => __('One hour', 'rmcommon'), '18000' => sprintf(__('%u hours', 'rmcommon'), 5), '86400' => __('One day', 'rmcommon'), '259200' => sprintf(__('%u days', 'rmcommon'), 3), '604800' => __('One week', 'rmcommon'))); break; case 'password': $ele = new RMFormText($field->caption, $field->name, 50, 255, $field->value, true); break; case 'hidden': $ele = new RMFormHidden($field->name, $field->value); break; case 'modules-rewrite': $ele = new RMFormRewrite($field->caption, $field->name, $field->value); break; case 'textbox': default: $ele = new RMFormText($field->caption, $field->name, 50, 255, $tc->specialchars($field->value)); break; } /** * Allow to plugins and other modules create new form * elements types in settings form */ $ele = RMEvents::get()->trigger('rmcommon.load.form.field', $ele, $field); $ele->set('id', $field->id); $ele->add('class', 'form-control'); return $ele->render(); }
/** * Form to create a new player * * @param int Create (0) or edit (1) a player */ function m_coaches_form($edit = 0) { global $xoopsModule, $xoopsModuleConfig; MCHFunctions::toolbar(); RMTemplate::get()->assign('xoops_pagetitle', $edit ? __('Edit Coach', 'match') : __('Add Coach', 'match')); xoops_cp_location('<a href="./">' . $xoopsModule->name() . "</a> » \n <a href='coaches.php'>" . __('Coaches', 'match') . '</a> » ' . ($edit ? __('Edit Coach', 'match') : __('Add Coach', 'match'))); xoops_cp_header(); $id = rmc_server_var($_REQUEST, 'id', 0); if ($edit) { //Verificamos si la categoría es válida if ($id <= 0) { redirectMsg('./coaches.php', __('Provide a coach ID!', 'match'), 1); die; } //Verificamos si la categoría existe $coach = new MCHCoach($id); if ($coach->isNew()) { redirectMsg('./coaches.php', __('Specified coach was not found!', 'match'), 1); die; } } $form = new RMForm($edit ? __('Edit Coach', 'match') : __('Add Coach', 'match'), 'frmNew', 'coaches.php'); $form->setExtra('enctype="multipart/form-data"'); $form->addElement(new RMFormText(__('Name(s)', 'match'), 'name', 50, 200, $edit ? $coach->getVar('name') : ''), true); $form->addElement(new RMFormText(__('Lastname', 'match'), 'lastname', 50, 200, $edit ? $coach->getVar('lastname') : ''), true); $form->addElement(new RMFormText(__('Surname', 'match'), 'surname', 50, 200, $edit ? $coach->getVar('surname') : ''), true); if ($edit) { $form->addElement(new RMFormText(__('Short name', 'match'), 'nameid', 50, 200, $coach->getVar('nameid')), true); } $form->addElement(new RMFormEditor(__('Biography', 'match'), 'bio', '100%', '250px', $edit ? $coach->getVar('bio', 'e') : '')); $form->addElement(new MCHTeamsField(__('Team', 'match'), 'team', $edit ? $coach->getVar('team') : 0), true); $form->addElement(new RMFormDate(__('Registered', 'match'), 'created', $edit ? $coach->getVar('created') : time(), $xoopsModuleConfig['year_range']), 1); $charges = new RMFormSelect(__('Charge', 'match'), 'charge', 0, $edit ? array($coach->getVar('charge')) : 0); $charges->addOption(0, __('Select position...', 'match')); $charges->addOption(1, __('Manager', 'match')); $charges->addOption(2, __('Coach', 'match')); $charges->addOption(3, __('Assistant', 'match')); $form->addElement($charges); $form->addElement(new RMFormFile(__('Picture', 'match'), 'photo', 45)); if ($edit) { $form->addElement(new RMFormLabel(__('Current picture', 'match'), '<img src="' . MCH_UP_URL . '/coaches/ths/' . $coach->getVar('photo') . '" alt="' . $coach->getVar('name') . '" />')); } $form->addElement(new RMFormHidden('action', $edit ? 'saveedit' : 'save')); if ($edit) { $form->addElement(new RMFormHidden('id', $coach->id())); } $ele = new RMFormButtonGroup(); $ele->addButton('sbt', $edit ? __('Save Changes!', 'match') : __('Add Now!', 'match'), 'submit'); $ele->addButton('cancel', _CANCEL, 'button', 'onclick="window.location=\'coaches.php\';"'); $form->addElement($ele); $form = RMEvents::get()->run_event('match.form.coaches', $form); $form->display(); RMTemplate::get()->add_style('admin.css', 'match'); xoops_cp_footer(); }
/** * @desc Muestra el formulario para creación de Foros * @param int $edit Determina si se esta editando un foro existente */ function bx_show_form($edit = 0) { global $xoopsModule, $xoopsConfig; if (!RMfunctions::plugin_installed('advform')) { RMUris::redirect_with_message(sprintf(__('<a href="%s">AdvancedForms</a> must be installed before to create any forum. Please download and install it.', 'bxpress'), 'https://github.com/bitcero/advform'), 'forums.php', RMMSG_ERROR); } if ($edit) { $id = RMHttpRequest::request('id', 'integer', 0); if ($id <= 0) { RMUris::redirect_with_message(__('Provided ID is not valid!', 'bxpress'), 'forums.php', RMMSG_WARN); die; } $forum = new bXForum($id); if ($forum->isNew()) { RMUris::redirect_with_message(__('Specified forum does not exists!', 'bxpress'), 'forums.php', RMMSG_ERROR); die; } } RMTemplate::get()->add_style('admin.css', 'bxpress'); xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> » " . ($edit ? __('Edit Forum', 'bxpress') : __('New Forum', 'bxpress'))); xoops_cp_header(); $bcHand = new bXCategoryHandler(); $bfHand = new bXForumHandler(); $form = new RMForm($edit ? __('Edit Forum', 'bxpress') : __('New Forum', 'bxpress'), 'frmForum', 'forums.php'); // Categorias $ele = new RMFormSelect(__('Category', 'bxpress'), 'cat', 0, $edit ? array($forum->category()) : null); $ele->addOption(0, __('Select category...', 'bxpress'), $edit ? 0 : 1); $ele->addOptionsArray($bcHand->getForSelect()); $form->addElement($ele, true, 'noselect:0'); // NOmbre $form->addElement(new RMFormText(__('Forum name', 'bxpress'), 'name', 50, 150, $edit ? $forum->name() : ''), true); // Descripcion $form->addElement(new RMFormEditor(__('Forum description', 'bxpress'), 'desc', '90%', '300px', $edit ? $forum->getVar('desc', 'e') : '')); $form->addElement(new RMFormImageUrl(__('Forum image', 'bxpress'), 'image', $edit ? $forum->image : '')); // Activo $form->addElement(new RMFormYesNo(__('Activate forum', 'bxpress'), 'active', $edit ? $forum->active() : 1)); // Firmas $form->addElement(new RMFormYesNo(__('Allow signatures in the posts', 'bxpress'), 'sig', $edit ? $forum->signature() : 1)); // Temas Populares $form->addElement(new RMFormText(__('Answers to match a topic as popular', 'bxpress'), 'hot_threshold', 10, 5, $edit ? $forum->hotThreshold() : 10), true, 'bigger:1'); // Orden en la lista $form->addElement(new RMFormText(__('Order in the list', 'bxpress'), 'order', 10, 5, $edit ? $forum->order() : 0), false, 'bigger:-1'); // Adjuntos $form->addElement(new RMFormYesNo(__('Allow attachments', 'bxpress'), 'attachments', $edit ? $forum->attachments() : 1)); $ele = new RMFormText(__('Maximum attachments file size', 'bxpress'), 'attach_maxkb', 10, 20, $edit ? $forum->maxSize() : 50); $ele->setDescription(__('Specify this value in Kilobytes', 'bxpress')); $form->addElement($ele, false, 'bigger:0'); $ele = new RMFormText(__('Allowed file types', 'bxpress'), 'attach_ext', 50, 0, $edit ? implode("|", $forum->extensions()) : 'zip|tar|jpg|gif|png|gz'); $ele->setDescription(__('Specified the extensions of allowed file types separating each one with "|" and without the dot.', 'bxpress')); $form->addElement($ele); // Grupos con permiso if ($edit) { $grupos = $forum->permissions(); } $form->addElement(new RMFormGroups(__('Can view the forum', 'bxpress'), 'perm_view', 1, 1, 5, $edit ? $grupos['view'] : array(0))); $form->addElement(new RMFormGroups(__('Can start new topics', 'bxpress'), 'perm_topic', 1, 1, 5, $edit ? $grupos['topic'] : array(1, 2))); $form->addElement(new RMFormGroups(__('Can answer', 'bxpress'), 'perm_reply', 1, 1, 5, $edit ? $grupos['reply'] : array(1, 2))); $form->addElement(new RMFormGroups(__('Can edit their posts', 'bxpress'), 'perm_edit', 1, 1, 5, $edit ? $grupos['edit'] : array(1, 2))); $form->addElement(new RMFormGroups(__('Can delete', 'bxpress'), 'perm_delete', 1, 1, 5, $edit ? $grupos['delete'] : array(1))); $form->addElement(new RMFormGroups(__('Can vote', 'bxpress'), 'perm_vote', 1, 1, 5, $edit ? $grupos['vote'] : array(1, 2))); $form->addElement(new RMFormGroups(__('Can attach', 'bxpress'), 'perm_attach', 1, 1, 5, $edit ? $grupos['attach'] : array(1, 2))); $form->addElement(new RMFormGroups(__('Can send without approval', 'bxpress'), 'perm_approve', 1, 1, 5, $edit ? $grupos['approve'] : array(1, 2))); $ele = new RMFormButtonGroup(); $ele->addButton('sbt', $edit ? __('Save Changes', 'bxpress') : __('Create Forum', 'bxpress'), 'submit', '', 1); $ele->addButton('cancel', __('Cancel', 'bxpress'), 'button', 'onclick="window.location=\'forums.php\';"'); $form->addElement($ele); $form->addElement(new RMFormHidden('action', $edit ? 'saveedit' : 'save')); if ($edit) { $form->addElement(new RMFormHidden('id', $forum->id())); } $form->display(); xoops_cp_footer(); }
/** * 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> » ' . ($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(); }
function pw_works_edit($options) { global $db; include_once XOOPS_ROOT_PATH . '/modules/works/class/pwclient.class.php'; include_once XOOPS_ROOT_PATH . '/modules/works/class/pwcategory.class.php'; //Tipo de Trabajo $form = new RMForm(__('Block Options', 'works'), 'form_options', ''); $ele = new RMFormSelect(__('Works type', 'works'), 'options[0]'); $ele->addOption(0, __('Reandom works', 'works'), $options[0] == 0 ? 1 : 0); $ele->addOption(1, __('Featured works', 'works'), $options[0] == 1 ? 1 : 0); $ele->addOption(2, __('Recent works', 'works'), $options[0] == 2 ? 1 : 0); $form->addElement($ele); //Obtenemos las categorías $ele = new RMFormSelect(__('Category', 'works'), 'options[1]'); $ele->addOption(0, __('All categories', 'works')); $db = XoopsDatabaseFactory::getDatabaseConnection(); $result = $db->query("SELECT * FROM " . $db->prefix('pw_categos') . " WHERE active=1"); while ($row = $db->fetchArray($result)) { $cat = new PWCategory(); $cat->assignVars($row); $ele->addOption($cat->id(), $cat->name(), $options[1] == $cat->id() ? 1 : 0); } $form->addElement($ele, true); //Obtenemos los clientes $ele = new RMFormSelect(__('Customer', 'works'), 'options[2]'); $ele->addOption(0, __('All customers', 'works')); $result = $db->query("SELECT * FROM " . $db->prefix('pw_clients')); while ($row = $db->fetchArray($result)) { $client = new PWClient(); $client->assignVars($row); $ele->addOption($client->id(), $client->name(), isset($ptions[2]) ? $options[2] == $client->id() ? 1 : 0 : 0); } $form->addElement($ele, true); //Número de trabajos $form->addElement(new RMFormText(__('Works number', 'works'), 'options[3]', 5, 5, isset($options[3]) ? $options[3] : ''), true); $form->addElement(new RMFormText(__('Columns', 'works'), 'options[4]', 5, 5, isset($options[4]) ? $options[4] : ''), true); $form->addElement(new RMFormYesno(__('Show work image', 'works'), 'options[5]', isset($options[5]) ? $options[5] ? 1 : 0 : 0), true); $form->addElement(new RMFormYesno(__('Show description', 'works'), 'options[6]', isset($options[6]) ? $options[6] ? 1 : 0 : 0), true); return $form->render(false); }
/** * Muestra las características existentes de una descarga */ function dt_show_files($edit = 0) { global $xoopsOption, $db, $tpl, $xoopsTpl, $xoopsUser, $mc, $dtfunc, $page, $item, $xoopsConfig, $xoopsModuleConfig, $file; include 'header.php'; $dtfunc->cpHeader($item, sprintf(__('%s files', 'dtransport'), $item->getVar('name'))); if ($file > 0 && $edit) { $file = new DTFile($file); if ($file->isNew() || $file->software() != $item->id()) { redirect_header(DT_URL . ($mc['permalinks'] ? '/cp/files/' . $item->id() . '/' : '/?p=cpanel&action=files&id=' . $item->id()), 1, __('Specified feature does not exists!', 'dtransport')); } } $tc = TextCleaner::getInstance(); $tf = new RMTimeFormatter('', "%m%/%d%/%Y% %h%:%i%"); $rmu = RMUtilities::get(); $tfiles = $db->prefix('dtrans_files'); $tgroup = $db->prefix('dtrans_groups'); $sql = "SELECT * FROM {$tfiles} WHERE id_soft=" . $item->id(); $gcache = array(); $result = $db->queryF($sql); while ($rows = $db->fetchArray($result)) { $fl = new DTFile(); $fl->assignVars($rows); if (!isset($gcache[$fl->group()])) { $gcache[$fl->group()] = new DTFileGroup($fl->group()); } $group = $gcache[$fl->group()]; $xoopsTpl->append('files', array('id' => $fl->id(), 'title' => $fl->title(), 'date' => $tf->format($fl->date()), 'software' => $item->getVar('name'), 'remote' => $fl->remote(), 'size' => $rmu->formatBytesSize($fl->size()), 'hits' => $fl->hits(), 'date' => $tf->format($fl->date()), 'group' => $group->isNew() ? '' : $group->name(), 'links' => array('edit' => DT_URL . ($mc['permalinks'] ? '/cp/files/' . $item->getVar('nameid') . '/edit/' . $fl->id() . '/' : '/?p=cpanel&id=' . $item->id() . '&action=files&feature=' . $fl->id()), 'delete' => DT_URL . ($mc['permalinks'] ? '/cp/files/' . $item->getVar('nameid') . '/delete/' . $fl->id() . '/' : '/?p=cpanel&id=' . $item->id() . '&action=delete&feature=' . $fl->id())))); } $formurl = DT_URL . ($mc['permalinks'] ? '/cp/files/' . $item->id() . '/save/' . ($edit ? $file->id() : '0') . '/' : '/p=cpanel'); // files Form $form = new RMForm($edit ? sprintf(__('Editing file of "%s"', 'dtransport'), $item->getVar('name')) : sprintf(__('New file for "%s"', 'dtransport'), $item->getVar('name')), 'frmFile', $formurl); $form->setExtra('enctype="multipart/form-data"'); $form->addElement(new RMFormLabel(__('Download item', 'dtransport'), $item->getVar('name'))); $form->addElement(new RMFormText(__('File title', 'dtransport'), 'title', 50, 200, $edit ? $file->title() : ''), true); //Lista de grupos $sql = "SELECT * FROM " . $db->prefix('dtrans_groups') . " WHERE id_soft=" . $item->id(); $result = $db->query($sql); $groups = array(); while ($rows = $db->fetchArray($result)) { $group = new DTFileGroup(); $group->assignVars($rows); $groups[] = array('id' => $group->id(), 'name' => $group->name()); } $ele = new RMFormSelect(__('Group', 'dtransport'), 'group', 0, $edit ? $file->group() : ''); $ele->addOption('', __('Select group...', 'dtransport')); foreach ($groups as $group) { $ele->addOption($group['id'], $group['name']); } $form->addElement($ele); $form->addElement(new RMFormYesNo(__('Default file', 'dtransport'), 'default', $edit ? $file->isDefault() : 0)); $form->addElement(new RMFormYesNo(__('Remote file', 'dtransport'), 'remote', $edit ? $file->remote() : 0)); $form->addElement(new RMFormFile(__('File', 'dtransport'), 'thefile', 50, $xoopsModuleConfig['size_file'] * 1024 * 1024)); if ($edit) { $form->addElement(new RMFormLabel(__('Current file', 'dtransport'), $file->file())); } $form->addElement(new RMFormText(__('File URL', 'dtransport'), 'url', 50, 200, $edit ? $file->title() : ''))->setDescription(__('Used only when remote file is activated.', 'dtransport')); $form->addElement(new RMFormHidden('action', 'save')); $form->addElement(new RMFormHidden('id', $item->id())); $form->addElement(new RMFormHidden('file', $edit ? $file->id() : 0)); $form->addElement(new RMFormHidden('op', 'save')); $buttons = new RMFormButtonGroup(); $buttons->addButton('sbt', $edit ? __('Save Changes', 'dtransport') : __('Save File', 'dtransport'), 'submit'); $buttons->addButton('cancel', __('Cancel', 'dtransport'), 'button', 'onclick="window.location=\'' . (DT_URL . ($mc['permalinks'] ? '/cp/files/' . $item->id() . '/' : '/?p=cpanel&action=files&id=' . $item->id())) . '\';"'); $form->addElement($buttons); $xoopsTpl->assign('file_form', $form->render()); $tpl->add_xoops_style('cpanel.css', 'dtransport'); $tpl->add_head_script('$(document).ready(function(){ $("a.delete").click(function(){ if(!confirm("' . __('Do you really want to delete selected file?', 'dtransport') . '")) return false; }); });'); $xoopsTpl->assign('lang_id', __('ID', 'dtransport')); $xoopsTpl->assign('lang_title', __('Title', 'dtransport')); $xoopsTpl->assign('lang_group', __('Group', 'dtransport')); $xoopsTpl->assign('lang_remote', __('Remote', 'dtransport')); $xoopsTpl->assign('lang_size', __('Size', 'dtransport')); $xoopsTpl->assign('lang_hits', __('Hits', 'dtransport')); $xoopsTpl->assign('lang_date', __('Date', 'dtransport')); $xoopsTpl->assign('lang_edit', __('Edit', 'dtransport')); $xoopsTpl->assign('lang_delete', __('Delete', 'dtransport')); $xoopsTpl->assign('lang_addfile', __('Add File', 'dtransport')); $xoopsTpl->assign('edit', $edit); include 'footer.php'; }
/** * @desc Mover temas de un foro a otro */ function moveTopics() { global $db, $xoopsModuleConfig, $xoopsSecurity, $forum, $xoopsUser, $xoopsOption, $xoopsConfig; $topics = isset($_REQUEST['topics']) ? $_REQUEST['topics'] : null; $ok = isset($_POST['ok']) ? $_POST['ok'] : 0; $moveforum = rmc_server_var($_POST, 'moveforum', 0); if (empty($topics) || is_array($topics) && empty($topics)) { redirect_header('moderate.php?id=' . $moveforum, 2, __('Select at least a topic to moderate!', 'bxpress')); die; } $topics = !is_array($topics) ? array($topics) : $topics; if ($ok) { if (!$xoopsSecurity->check()) { redirect_header('moderate.php?id=' . $moveforum, 2, __('Session token expired!', 'bxpress')); die; } if ($moveforum <= 0) { redirect_header('moderate.php?id=' . $forum->id(), 2, __('Please select the target forum', 'bxpress')); die; } $mf = new bXForum($moveforum); if ($mf->isNew()) { redirect_header('moderate.php?id=' . $forum->id(), 2, __('Specified forum does not exists!', 'bxpress')); die; } $lastpost = false; foreach ($topics as $k) { $topic = new bXTopic($k); if ($topic->forum() != $forum->id()) { continue; } //Verificamos si el tema contiene el último mensaje del foro if (!$lastpost && array_key_exists($forum->lastPostId(), $topic->getPosts(0))) { $lastpost = true; } $topic->setForum($moveforum); if ($topic->save()) { //Decrementa el número de temas $forum->setTopics($forum->topics() - 1 > 0 ? $forum->topics() - 1 : 0); $forum->setPosts($forum->posts() - ($topic->replies() + 1) > 0 ? $forum->posts() - ($topic->replies() + 1) : 0); $forum->save(); $mf->setPosts($mf->posts() + ($topic->replies() + 1)); $mf->addTopic(); $mf->save(); //Cambiamos el foro de los mensajes del tema if ($topic->getPosts()) { foreach ($topic->getPosts() as $k => $v) { $v->setForum($moveforum); $v->save(); } } } } //Actualizamos el último mensaje del foro if ($lastpost) { $post = $forum->getLastPost(); $forum->setPostId($post); $forum->save(); } //Actualizamos el último mensaje del foro al que fue movido el tema $post = $mf->getLastPost(); $post ? $mf->setPostId($post) : ''; $mf->save(); redirect_header('moderate.php?id=' . $forum->id(), 1, __('Topics has been relocated!', 'bxpress')); die; } else { global $xoopsTpl; $tpl = $xoopsTpl; $xoopsOption['template_main'] = "bxpress_moderateforms.html"; $xoopsOption['module_subpage'] = "moderate"; include 'header.php'; bXFunctions::makeHeader(); $form = new RMForm(__('Move Topics', 'bxpress'), 'frmMove', 'moderate.php'); $form->addElement(new RMFormHidden('id', $forum->id())); $form->addElement(new RMFormHidden('op', 'move')); $form->addElement(new RMFormHidden('ok', '1')); $i = 0; foreach ($topics as $k) { $form->addElement(new RMFormHidden('topics[' . $i . ']', $k)); ++$i; } $form->addElement(new RMFormSubTitle(' ', 1, '')); $form->addElement(new RMFormSubTitle(__('Select the forum where you wish to move selected topics', 'bxpress'), 1, 'even')); $ele = new RMFormSelect(__('Forum', 'bxpress'), 'moveforum'); $ele->addOption(0, '', 1); $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' AND id_forum<>" . $forum->id() . " 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, true, "noselect:0"); $ele = new RMFormButtonGroup(); $ele->addButton('sbt', __('Move Topics Now!', 'bxpress'), 'submit'); $ele->addButton('cancel', __('Cancel', 'bxpress'), 'button', 'onclick="history.go(-1);"'); $form->addElement($ele); $tpl->assign('moderate_form', $form->render()); include 'footer.php'; } }
/** * @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> » " . ($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(); }
/** * @desc Formulario de imágenes **/ function formImages($edit = 0) { global $xoopsOption, $tpl, $db, $xoopsUser, $xoopsModuleConfig, $xoopsUser, $xoopsConfig, $id, $referer, $page; $mc =& $xoopsModuleConfig; if (!$referer) { $referer = GSFunctions::get_url() . ($mc['urlmode'] ? 'cp/images/pag/' . $page . '/' : '?cp=images&pag=' . $page); } else { $referer = base64_decode($referer); } if ($edit) { //Verificamos si la imagen es válida if ($id <= 0) { redirect_header($referer, 1, __('Sepecified images is not valid!', 'galleries')); die; } //Verificamos si la imagen existe $img = new GSImage($id); if ($img->isNew()) { redirect_header($referer, 1, __('Sepecified image does not exists!', 'galleries')); die; } //Verificamos que el usuario se el dueño de la imagen if ($img->owner() != $xoopsUser->uid()) { redirect_header($referer, 1, __('You are not authorized!', 'galleries')); die; } } $xoopsOption['template_main'] = 'gs_formpics.html'; include 'header.php'; GSFunctions::makeHeader(); $form = new RMForm($edit ? __('Edit Image', 'galleries') : __('New Image', 'galleries'), 'frmimg', GSFunctions::get_url() . ($mc['urlmode'] ? 'cp/saveedit/' : '?cp=saveedit')); $form->setExtra("enctype='multipart/form-data'"); $form->addElement(new RMFormText(__('Image title', 'galleries'), 'title', 50, 100, $edit ? $img->title(false) : '')); if ($edit) { $user = new GSUser($img->owner(), 1); $url = $user->filesURL(); $form->addElement(new RMFormLabel(__('Current picture', 'galleries'), "<img src='" . $url . "/ths/" . $img->image() . "' />")); } else { $form->addElement(new RMFormFile(__('Image file', 'galleries'), 'image', 45, $mc['size_image'] * 1024)); } $form->addElement(new RMFormTextArea(__('Description', 'galleries'), 'desc', 4, 50, $edit ? $img->desc() : '')); $ele = new RMFormSelect(__('Access level', 'galleries'), 'public'); $ele->addOption(0, __('Private', 'galleries'), $edit ? $img->isPublic() == 0 ? 1 : 0 : 0); $ele->addOption(1, __('Public for friends', 'galleries'), $edit ? $img->isPublic() == 1 ? 1 : 0 : 0); $ele->addOption(2, __('Public for all', 'galleries'), $edit ? $img->isPublic() == 2 ? 1 : 0 : 0); $form->addElement($ele, true); //Albumes if ($edit) { $albums = $img->sets(false); foreach ($albums as $k => $v) { $sets[] = $v['id_set']; } } $ele = new RMFormSelect(__('Albums', 'galleries'), 'albums[]', 1, $edit ? $sets : ''); $sql = "SELECT * FROM " . $db->prefix('gs_sets') . " WHERE owner='" . $xoopsUser->uid() . "'"; $result = $db->query($sql); while ($rows = $db->fetchArray($result)) { $ele->addOption($rows['id_set'], $rows['title']); } $form->addElement($ele); $ele = new RMFormText(__('Tags', 'galleries'), 'tags', 50, 255, $edit ? implode(", ", $img->tags(false, 'tag')) : ''); $ele->setDescription(__('Separe each tag with commas.', 'galleries')); $form->addElement($ele, true); $form->addElement(new RMFormHidden('op', $edit ? 'saveedit' : 'save')); $form->addElement(new RMFormHidden('id', $id)); $form->addElement(new RMFormHidden('page', $page)); $form->addElement(new RMFormHidden('referer', $referer)); $buttons = new RMFormButtonGroup(); $buttons->addButton('sbt', $edit ? __('Save Changes', 'galleries') : __('Create Image', 'galleries'), 'submit'); $buttons->addButton('cancel', __('Cancel', 'galleries'), 'button', 'onclick="window.location=\'' . $referer . '\'"'); $form->addElement($buttons); $tpl->assign('form_pics', $form->render()); createLinks(); RMTemplate::get()->add_style('panel.css', 'galleries'); include 'footer.php'; }
/** * @desc Formulario de creación/edición de imágenes **/ function formImages($edit = 0) { global $xoopsModule, $mc, $xoopsUser, $db; $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0; $page = isset($_REQUEST['page']) ? $_REQUEST['page'] : 1; $limit = isset($_REQUEST['limit']) ? intval($_REQUEST['limit']) : 10; $search = isset($_REQUEST['search']) ? $_REQUEST['search'] : ''; $owner = isset($_REQUEST['owner']) ? $_REQUEST['owner'] : ''; $uid = isset($_REQUEST['uid']) ? intval($_REQUEST['uid']) : 0; $sort = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : 'created'; $mode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : 0; $ruta = "page={$page}&limit={$limit}&search={$search}&owner={$owner}&sort={$sort}&mode={$mode}"; if ($edit) { //Verificamos si la imagen es válida if ($id <= 0) { redirectMsg('./images.php?' . $ruta, __('Image ID not valid!', 'galleries'), 1); die; } //Verificamos si la imagen existe $img = new GSImage($id); if ($img->isNew()) { redirectMsg('./images.php?' . $ruta, __('Specified image does not exists!', 'galleries'), 1); die; } } GSFunctions::toolbar(); xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> » <a href='./images.php'>" . __('Images', 'galleries') . "</a> » " . ($edit ? __('Edit image', 'galleries') : __('Add image', 'galleries'))); xoops_cp_header(); $form = new RMForm($edit ? __('Editing image', 'galleries') : __('Add image', 'galleries'), 'frmimg', 'images.php'); $form->setExtra("enctype='multipart/form-data'"); if (!$edit) { $ele = new RMFormUser(__('User', 'galleries'), 'uid', 0, $uid ? array($uid) : ($edit ? array($img->owner()) : array($xoopsUser->uid())), 50); $ele->onChange("\$('op').value='" . ($edit ? 'edit' : 'new') . "'; \$('frmimg').submit();"); $form->addElement($ele); } else { $xu = new XoopsUser($img->owner()); $form->addElement(new RMFormLabel(__('User', 'galleries'), $xu->uname())); $form->addElement(new RMFormHidden('uid', $img->owner())); } $form->addElement(new RMFormText(__('Title', 'galleries'), 'title', 50, 100, $edit ? $img->title() : '')); $form->addElement(new RMFormFile(__('Image file', 'galleries'), 'image', 45, $mc['size_image'] * 1024)); if ($edit) { $user = new GSUser($img->owner(), 1); $url = $user->filesURL(); $form->addElement(new RMFormLabel(__('Current image', 'galleries'), "<img src='" . $url . "/ths/" . $img->image() . "' />")); } $form->addElement(new RMFormTextArea(__('Description', 'galleries'), 'desc', 4, 50, $edit ? $img->desc() : '')); $ele = new RMFormSelect(__('Privacy', 'galleries'), 'public'); $ele->addOption(0, __('Private', 'galleries'), $edit ? $img->isPublic() == 0 ? 1 : 0 : 0); $ele->addOption(1, __('Visible for friends', 'galleries'), $edit ? $img->isPublic() == 1 ? 1 : 0 : 0); $ele->addOption(2, __('Visible for all', 'galleries'), $edit ? $img->isPublic() == 2 ? 1 : 0 : 1); $form->addElement($ele, true); $db = Database::getInstance(); //Albumes if ($edit) { $albums = $img->sets(false); foreach ($albums as $k => $v) { $sets[] = $v['id_set']; } } $ele = new RMFormSelect(__('Albums', 'galleries'), 'albums[]', 1, $edit ? $sets : ''); $sql = "SELECT * FROM " . $db->prefix('gs_sets') . " WHERE owner='" . ($uid ? $uid : ($edit ? $img->owner() : $xoopsUser->uid())) . "'"; $result = $db->query($sql); while ($rows = $db->fetchArray($result)) { $ele->addOption($rows['id_set'], $rows['title']); } $form->addElement($ele); $ele = new RMFormText(__('Tags', 'galleries'), 'tags', 50, 100, $edit ? implode(", ", $img->tags(false, 'tag')) : ''); $ele->setDescription(__('Separate each tag with a comma (,)', 'galleries')); $form->addElement($ele, true); $form->addElement(new RMFormHidden('op', $edit ? 'saveedit' : 'save')); if ($edit) { $form->addElement(new RMFormHidden('id', $id)); } $form->addElement(new RMFormHidden('page', $page)); $form->addElement(new RMFormHidden('limit', $limit)); $form->addElement(new RMFormHidden('search', $search)); $form->addElement(new RMFormHidden('owner', $owner)); $form->addElement(new RMFormHidden('sort', $sort)); $form->addElement(new RMFormHidden('mode', $mode)); $buttons = new RMFormButtonGroup(); $buttons->addButton('sbt', $edit ? __('Save changes', 'galleries') : __('Add image', 'galleries'), 'submit'); $buttons->addButton('cancel', __('Cancel', 'galleries'), 'button', 'onclick="window.location=\'images.php?' . $ruta . '\'"'); $form->addElement($buttons); $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; }
function showFormEdits() { global $xoopsModule, $xoopsConfig; $id = rmc_server_var($_GET, 'id', 0); if ($id <= 0) { redirectMsg('edits.php', __('You have not specified any waiting section!', 'docs'), 1); die; } $edit = new RDEdit($id); if ($edit->isNew()) { redirectMsg('edits.php', __('Specified content does not exists!', 'docs'), 1); die; } $sec = new RDSection($edit->getVar('id_sec')); if ($sec->isNew()) { redirectMsg('edits.php', __('This waiting content does not have any section assigned!', 'docs'), 1); die; } $res = new RDResource($sec->getVar('id_res')); $form = new RMForm(__('Editing Waiting Content', 'docs'), 'frmsec', 'edits.php'); $form->addElement(new RMFormLabel(__('Belong to', 'docs'), $res->getVar('title'))); $form->addElement(new RMFormText(__('Title', 'docs'), 'title', 50, 200, $edit->getVar('title')), true); $form->addElement(new RMFormEditor(__('Contenido', 'docs'), 'content', '90%', '300px', $edit->getVar('content', 'e')), true); // Arbol de Secciones $ele = new RMFormSelect(__('Parent Section', 'docs'), 'parent'); $ele->addOption(0, __('Select section...', 'docs')); $tree = array(); RDFunctions::sections_tree_index(0, 0, $res, '', '', false, $tree, false); foreach ($tree as $k) { $ele->addOption($k['id'], str_repeat('—', $k['jump']) . ' ' . $k['title'], $edit->getVar('parent') == $k['id'] ? 1 : 0); } $form->addElement($ele); $form->addElement(new RMFormText(__('Display order', 'docs'), 'order', 5, 5, $edit->getVar('order')), true); // Usuario $form->addElement(new RMFormUser(__('Owner', 'docs'), 'uid', 0, array($edit->getVar('uid')), 30)); $buttons = new RMFormButtonGroup(); $buttons->addButton('sbt', __('Save Now', 'docs'), 'submit'); $buttons->addButton('cancel', __('Cancel', 'docs'), 'button', 'onclick="window.location=\'edits.php\';"'); $form->addElement($buttons); $form->addElement(new RMFormHidden('action', 'save')); $form->addElement(new RMFormHidden('id', $edit->id())); xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> » <a href='./edits.php'>" . __('Waiting Content', 'docs') . "</a> » " . sprintf(__('Editing %s', 'docs'), $edit->getVar('title'))); xoops_cp_header(); RMTemplate::get()->assign('xoops_pagetitle', __('Editing Waiting Content', 'docs')); $form->display(); xoops_cp_footer(); }
/** * @desc Formulario de creación/edición de albums **/ function formAlbums($edit = 0) { global $xoopsModule, $xoopsUser; define('RMSUBLOCATION', 'newalbum'); $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0; $page = isset($_REQUEST['pag']) ? $_REQUEST['pag'] : ''; $limit = isset($_REQUEST['limit']) ? intval($_REQUEST['limit']) : 15; $sort = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : 'id_set'; $mode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : 0; $search = isset($_REQUEST['search']) ? $_REQUEST['search'] : ''; $ruta = "pag={$page}&sort={$sort}&mode={$mode}&search={$search}"; if ($edit) { //Verificamos que el album sea válido if ($id <= 0) { redirectMsg('./sets.php?' . $ruta, __('Please provide a valid ID!', 'galleries'), 1); die; } //Verificamos que el album exista $set = new GSSet($id); if ($set->isNew()) { redirectMsg('./sets.php?' . $ruta, __('Specified album does not exists!', 'galleries'), 1); die; } } GSFunctions::toolbar(); xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> » <a href='./sets.php'>" . __('Albums management', 'galleries') . "</a> » " . ($edit ? __('Edit album', 'galleries') : __('New album', 'galleries'))); xoops_cp_header(); $form = new RMForm($edit ? __('Edit album', 'galleries') : __('New Album', 'galleries'), 'frmsets', 'sets.php'); $form->addElement(new RMFormText(__('Album title', 'galleries'), 'title', 50, 100, $edit ? $set->title() : ''), true); $form->addElement(new RMFormEditor(__('Description', 'galleries'), 'description', '99%', '250px', $edit ? $set->getVar('description', 'e') : '')); $ele = new RMFormSelect(__('Privacy level', 'galleries'), 'public'); $ele->addOption(0, __('Private', 'galleries'), $edit ? $set->isPublic() == 0 ? 1 : 0 : 0); $ele->addOption(1, __('Public for friends', 'galleries'), $edit ? $set->isPublic() == 1 ? 1 : 0 : 0); $ele->addOption(2, __('Public', 'galleries'), $edit ? $set->isPublic() == 2 ? 1 : ($set->isPublic() == 0 ? 1 : 0) : 1); $form->addElement($ele, true); $form->addElement(new RMFormUser(__('Owner', 'galleries'), 'owner', 0, $edit ? array($set->owner()) : array($xoopsUser->uid()), 30)); $form->addElement(new RMFormHidden('op', $edit ? 'saveedit' : 'save')); $form->addElement(new RMFormHidden('id', $id)); $form->addElement(new RMFormHidden('page', $page)); $form->addElement(new RMFormHidden('limit', $limit)); $form->addElement(new RMFormHidden('sort', $sort)); $form->addElement(new RMFormHidden('mode', $mode)); $form->addElement(new RMFormHidden('search', $search)); $buttons = new RMFormButtonGroup(); $buttons->addButton('sbt', $edit ? __('Save Changes!', 'galleries') : __('Create Album!', 'galleries'), 'submit'); $buttons->addButton('cancel', __('Cancel', 'galleries'), 'button', 'onclick="window.location=\'sets.php?' . $ruta . '\'"'); $form->addElement($buttons); $form->display(); xoops_cp_footer(); }
/** * @desc Formulario de creacion/edición de trabajos **/ function formWorks($edit = 0) { global $xoopsModule, $xoopsModuleConfig; $page = rmc_server_var($_REQUEST, 'page', 1); $ruta = "page={$page}"; PWFunctions::toolbar(); xoops_cp_location('<a href="./">' . $xoopsModule->name() . "</a> » <a href='./works.php'>" . __('Works Management', 'works') . "</a> » " . ($edit ? __('Editing work', 'works') : __('New work', 'works'))); xoops_cp_header(); $id = rmc_server_var($_REQUEST, 'id', 0); if ($edit) { //Verificamos que el trabajo sea válido if ($id <= 0) { redirectMsg('./works.php?' . $ruta, __('Provided Work ID is not valid!', 'works'), 1); die; } //Verificamos que el trabajo exista $work = new PWWork($id); if ($work->isNew()) { redirectMsg('./works.php?' . $ruta, __('Specified work does not exists!', 'works'), 1); die; } } $form = new RMForm($edit ? __('Edit Work', 'works') : __('Create Work', 'works'), 'frmwork', 'works.php'); $form->setExtra("enctype='multipart/form-data'"); $form->addElement(new RMFormText(__('Title', 'works'), 'title', 50, 200, $edit ? $work->title() : ''), true); $form->addElement(new RMFormTextArea(__('Short description', 'works'), 'short', 4, 50, $edit ? $work->descShort() : ''), true); $form->addElement(new RMFormEditor(__('Description', 'works'), 'desc', '90%', '200px', $edit ? $work->desc('e') : ''), true); if ($edit) { $dohtml = $work->getVar('dohtml'); $doxcode = $work->getVar('doxcode'); $dobr = $work->getVar('dobr'); $dosmiley = $work->getVar('dosmiley'); $doimage = $work->getVar('doimage'); } else { $dohtml = 1; $doxcode = 0; $dobr = 0; $dosmiley = 0; $doimage = 0; } $form->addElement(new RMFormTextOptions(_OPTIONS, $dohtml, $doxcode, $doimage, $dosmiley, $dobr)); $ele = new RMFormSelect(__('Category', 'works'), 'catego'); $ele->addOption(0, __('Select...', 'works')); //Categorias existentes $db = XoopsDatabaseFactory::getDatabaseConnection(); $result = $db->query("SELECT * FROM " . $db->prefix("pw_categos") . " ORDER BY `order`"); while ($rows = $db->fetchArray($result)) { $ele->addOption($rows['id_cat'], $rows['name'], $edit ? $work->category() == $rows['id_cat'] ? 1 : 0 : ''); } $form->addElement($ele, true, 'noselect:0'); if ($xoopsModuleConfig['show_customer']) { //Clientes Existentes $ele = new RMFormSelect(__('Customer', 'works'), 'client'); $ele->addOption(0, __('Select...', 'works')); $sql = "SELECT * FROM " . $db->prefix('pw_clients'); $result = $db->query($sql); while ($row = $db->fetchArray($result)) { $ele->addOption($row['id_client'], $row['name'], $edit ? $work->client() == $row['id_client'] ? 1 : 0 : ''); } $form->addElement($ele, true, 'noselect:0'); $form->addElement(new RMFormTextArea(__('Customer comment', 'works'), 'comment', 4, 50, $edit ? $work->comment() : '')); } if ($xoopsModuleConfig['show_web']) { $form->addElement(new RMFormText(__('Web site', 'works'), 'site', 50, 150, $edit ? $work->nameSite() : '')); $form->addElement(new RMFormText(__('Site URL', 'works'), 'url', 50, 255, $edit ? $work->url() : '')); } $form->addElement(new RMFormDate(__('Start date', 'works'), 'start', $edit ? $work->start() : time())); $form->addElement(new RMFormText(__('Long time', 'works'), 'period', 50, 255, $edit ? $work->period() : '')); $form->addElement(new RMFormText(__('Monetary cost', 'works'), 'cost', 10, 20, $edit ? $work->cost() : 0)); $form->addElement(new RMFormYesno(__('Featured', 'works'), 'mark', $edit ? $work->mark() : 0)); $form->addElement(new RMFormYesno(__('Visible', 'works'), 'public', $edit ? $work->isPublic() : 1)); $form->addElement(new RMFormFile(__('Work image', 'works'), 'image', 45, $xoopsModuleConfig['size_image'] * 1024)); if ($edit) { $form->addElement(new RMFormLabel(__('Current image', 'works'), "<img src='" . XOOPS_UPLOAD_URL . "/works/ths/" . $work->image() . "' />")); } $ele = new RMFormSelect(__('Rating', 'works'), 'rating'); for ($i = 0; $i <= 10; $i++) { $ele->addOption($i, $i, $edit ? $work->rating() == $i ? 1 : 0 : 0); } $form->addElement($ele, true); $form->addElement(new RMFormHidden('op', $edit ? 'saveedit' : 'save')); $form->addElement(new RMFormHidden('id', $id)); $form->addElement(new RMFormHidden('page', $page)); $ele = new RMFormButtonGroup(); $ele->addButton('sbt', $edit ? __('Save Changes', 'works') : __('Create Work', 'works'), 'submit'); $ele->addButton('cancel', __('Cancel', 'works'), 'button', 'onclick="window.location=\'works.php?' . $ruta . '\';"'); $form->addElement($ele); if ($edit) { include RMTemplate::get()->get_template("admin/pw_work_options.php", 'module', 'works'); RMTemplate::get()->add_style('admin.css', 'works'); } $form->display(); xoops_cp_footer(); }