Example #1
0
     $file_product_id_select = new XoopsFormSelect(_MYSHOP_PRODUCT, 'file_product_id', $item->getVar('file_product_id', 'e'), 1, false);
     $file_product_id_select->addOptionArray($products);
     $sform->addElement($file_product_id_select, true);
     $sform->addElement(new XoopsFormText(_AM_MYSHOP_DESCRIPTION, 'file_description', 50, 255, $item->getVar('file_description', 'e')), true);
     if ($op == 'edit' && trim($item->getVar('file_filename')) != '' && $item->fileExists()) {
         $pictureTray = new XoopsFormElementTray(_AM_MYSHOP_CURRENT_FILE, '<br />');
         $pictureTray->addElement(new XoopsFormLabel('', "<a href='" . $item->getURL() . "' target='_blank' />" . $item->getVar('file_filename') . "</a>"));
         $sform->addElement($pictureTray);
         unset($pictureTray);
     }
     $sform->addElement(new XoopsFormFile(_AM_MYSHOP_FILENAME, 'attachedfile', myshop_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 = myshop_utils::formMarkRequiredFields($sform);
     $sform->display();
     break;
 case 'saveedit':
     xoops_cp_header();
     $id = isset($_POST['file_id']) ? intval($_POST['file_id']) : 0;
     if (!empty($id)) {
         $edit = true;
         $item = $h_myshop_files->get($id);
         if (!is_object($item)) {
             myshop_utils::redirect(_AM_MYSHOP_NOT_FOUND, $baseurl, 5);
         }
         $item->unsetNew();
     } else {
         $item = $h_myshop_files->create(true);
     }