if ($action == 'edit' && $item->pictureExists($i)) { $pictureTray = new XoopsFormElementTray(_AM_OLEDRION_CURRENT_PICTURE, '<br />'); $pictureTray->addElement(new XoopsFormLabel('', "<img src='" . $item->getPictureUrl($i) . "' alt='' border='0' />")); $deleteCheckbox = new XoopsFormCheckBox('', 'delpicture' . $i); $deleteCheckbox->addOption(1, _DELETE); $pictureTray->addElement($deleteCheckbox); $sform->addElement($pictureTray); unset($pictureTray, $deleteCheckbox); } $sform->addElement(new XoopsFormFile(_AM_OLEDRION_PICTURE . ' ' . $i, 'attachedfile' . $i, oledrion_utils::getModuleOption('maxuploadsize')), false); } $button_tray = new XoopsFormElementTray('', ''); $submit_btn = new XoopsFormButton('', 'post', $label_submit, 'submit'); $button_tray->addElement($submit_btn); $sform->addElement($button_tray); $sform = oledrion_utils::formMarkRequiredFields($sform); $sform->display(); show_footer(); break; // **************************************************************************************************************** // **************************************************************************************************************** case 'saveedit': // Sauvegarde d'un fabricant // **************************************************************************************************************** xoops_cp_header(); $id = isset($_POST['manu_id']) ? intval($_POST['manu_id']) : 0; if (!empty($id)) { $edit = true; $item = $h_oledrion_manufacturer->get($id); if (!is_object($item)) { oledrion_utils::redirect(_AM_OLEDRION_NOT_FOUND, $baseurl, 5);
function listForm($op, $product_id = 0) { global $handlers, $baseurl; if ($op == 'edit') { $title = _OLEDRION_EDIT_LIST; $label_submit = _AM_OLEDRION_MODIFY; $list_id = isset($_GET['list_id']) ? intval($_GET['list_id']) : 0; if (empty($list_id)) { oledrion_utils::redirect(_AM_OLEDRION_ERROR_21, $baseurl, 5); } $item = null; $item = $handlers->h_oledrion_lists->get($list_id); if (!is_object($item)) { oledrion_utils::redirect(_AM_OLEDRION_NOT_FOUND, $baseurl, 5); } // Vérification, est-ce que l'utilisateur courant est bien le propriétaire de cette liste ? if (!$handlers->h_oledrion_lists->isThisMyList($list_id)) { oledrion_utils::redirect(_OLEDRION_ERROR25, $baseurl, 8); } $edit = true; $label_submit = _AM_OLEDRION_MODIFY; } else { $title = _OLEDRION_ADD_LIST; $label_submit = _AM_OLEDRION_ADD; $item = $handlers->h_oledrion_lists->create(true); $edit = false; } $sform = new XoopsThemeForm($title, 'frmList', $baseurl); $sform->addElement(new XoopsFormHidden('op', 'save')); $sform->addElement(new XoopsFormHidden('list_id', $item->getVar('list_id'))); $sform->addElement(new XoopsFormText(_AM_OLEDRION_TITLE, 'list_title', 50, 255, $item->getVar('list_title', 'e')), true); //$sform->addElement(new XoopsFormText(_OLEDRION_LIST_PASSWORD, 'list_password', 50, 50, $item->getVar('list_password','e')), false); $selectTypes = oledrion_lists::getTypesArray(); $selectType = new XoopsFormSelect(_OLEDRION_LIST_TYPE, 'list_type', $item->getVar('list_type', 'e')); $selectType->addOptionArray($selectTypes); $sform->addElement($selectType, true); $sform->addElement(new XoopsFormTextArea(_OLEDRION_DESCRIPTION, 'list_description', $item->getVar('list_description', 'e'), 7, 60), false); $listProducts = array(); if ($edit) { $listProducts = $handlers->h_oledrion_lists->getListProducts($item); if (count($listProducts) > 0) { $productsTray = new XoopsFormElementTray(_OLEDRION_PROD_IN_THIS_LIST, '<br />'); $productsTray->addElement(new XoopsFormLabel(_OLEDRION_CHECK_PRODUCTS), false); foreach ($listProducts as $product) { $caption = "<a target='_blank' href='" . $product->getLink() . "'>" . $product->getVar('product_title') . '</a>'; $checkbox = new XoopsFormCheckBox($caption, 'productsList[]'); $checkbox->addOption($product->getVar('product_id'), _DELETE); $productsTray->addElement($checkbox); unset($caption, $checkbox); } $sform->addElement($productsTray, false); } } if ($product_id > 0) { $product = null; $product = $handlers->h_oledrion_products->get($product_id); if (is_object($product) && $product->isProductVisible()) { $content = "<a target='_blank' href='" . $product->getLink() . "'>" . $product->getVar('product_title') . '</a>'; $sform->addElement(new XoopsFormLabel(_OLEDRION_PRODUCT_DO_ADD, $content)); $sform->addElement(new XoopsFormHidden('product_id', $product_id)); } } $button_tray = new XoopsFormElementTray('', ''); $submit_btn = new XoopsFormButton('', 'post', $label_submit, 'submit'); $button_tray->addElement($submit_btn); $sform->addElement($button_tray); $sform = oledrion_utils::formMarkRequiredFields($sform); return $sform; }