/** * Creates the product edit form. * * Creates the form for editing a product. If a product ID is supplied, * then that product is read and becomes the current product. If not, * then the current product is edited. If an empty product was created, * then a new product is created here. * * @uses PAYPAL_getDocUrl() * @uses PAYPAL_errorMessage() * @uses PAYPAL_recurseCats() * @param integer $id Optional ID, current record used if zero * @return string HTML for edit form */ public function showForm($id = 0) { global $_TABLES, $_CONF, $_PP_CONF, $LANG_PP, $LANG24, $LANG_postmodes, $_SYSTEM; $id = (int) $id; if ($id > 0) { // If an id is passed in, then read that record if (!$this->Read($id)) { return PAYPAL_errorMessage($LANG_PP['invalid_product_id'], 'info'); } } $id = $this->id; $T = new Template(PAYPAL_PI_PATH . '/templates'); if ($_SYSTEM['framework'] == 'uikit') { $T->set_file('product', 'product_form.uikit.thtml'); } else { $T->set_file('product', 'product_form.thtml'); } // Set up the wysiwyg editor, if available switch (PLG_getEditorType()) { case 'ckeditor': $T->set_var('show_htmleditor', true); PLG_requestEditor('paypal', 'paypal_entry', 'ckeditor_paypal.thtml'); PLG_templateSetVars('paypal_entry', $T); break; case 'tinymce': $T->set_var('show_htmleditor', true); PLG_requestEditor('paypal', 'paypal_entry', 'tinymce_paypal.thtml'); PLG_templateSetVars('paypal_entry', $T); break; default: // don't support others right now $T->set_var('show_htmleditor', false); break; } // Add the current product ID to the form if it's an existing product. if ($id > 0) { $T->set_var('id', '<input type="hidden" name="id" value="' . $this->id . '" />'); $retval = COM_startBlock($LANG_PP['edit'] . ': ' . $this->name); } else { $T->set_var('id', ''); $retval = COM_startBlock($LANG_PP['new_product']); } $T->set_var(array('post_options' => $post_options, 'name' => htmlspecialchars($this->name, ENT_QUOTES, COM_getEncodingt()), 'category' => $this->cat_id, 'short_description' => htmlspecialchars($this->short_description, ENT_QUOTES, COM_getEncodingt()), 'description' => htmlspecialchars($this->description, ENT_QUOTES, COM_getEncodingt()), 'price' => sprintf('%.2f', $this->price), 'file' => htmlspecialchars($this->file, ENT_QUOTES, COM_getEncodingt()), 'expiration' => $this->expiration, 'pi_admin_url' => PAYPAL_ADMIN_URL, 'file_selection' => $this->FileSelector(), 'keywords' => htmlspecialchars($this->keywords, ENT_QUOTES, COM_getEncodingt()), 'cat_select' => PAYPAL_recurseCats('PAYPAL_callbackCatOptionList', $this->cat_id), 'currency' => $_PP_CONF['currency'], 'pi_url' => PAYPAL_URL, 'doc_url' => PAYPAL_getDocURL('product_form', $_CONF['language']), 'prod_type' => $this->prod_type, 'weight' => $this->weight, 'feat_chk' => $this->featured == 1 ? 'checked="checked"' : '', 'ena_chk' => $this->enabled == 1 ? 'checked="checked"' : '', 'tax_chk' => $this->taxable == 1 ? 'checked="checked"' : '', 'show_random_chk' => $this->show_random == 1 ? 'checked="checked"' : '', 'show_popular_chk' => $this->show_popular == 1 ? 'checked="checked"' : '', 'ship_sel_' . $this->shipping_type => 'selected="selected"', 'shipping_type' => $this->shipping_type, 'track_onhand' => $this->track_onhand, 'shipping_amt' => sprintf('%.2f', $this->shipping_amt), 'sel_comment_' . $this->comments_enabled => 'selected="selected"', 'rating_chk' => $this->rating_enabled == 1 ? 'checked="checked"' : '', 'trk_onhand_chk' => $this->track_onhand == 1 ? 'checked="checked"' : '', 'onhand' => $this->onhand, "oversell_sel{$this->oversell}" => 'selected="selected"', 'custom' => $this->custom, 'sale_price' => sprintf('%.2f', $this->sale_price), 'sale_beg' => $this->_InputDtFormat($this->sale_beg), 'sale_end' => $this->_InputDtFormat($this->sale_end), 'avail_beg' => $this->avail_beg, 'avail_end' => $this->avail_end)); // Create the button type selections. New products get the default // button selected, existing products get the saved button selected // or "none" if there is no button. $T->set_block('product', 'BtnRow', 'BRow'); $have_chk = false; foreach ($_PP_CONF['buttons'] as $key => $checked) { if ($key == $this->btn_type || $this->isNew && $checked) { $btn_chk = 'checked="checked"'; $have_chk = true; } else { $btn_chk = ''; } $T->set_var(array('btn_type' => $key, 'btn_chk' => $key == $this->btn_type || $this->isNew && $checked ? 'checked="checked"' : '', 'btn_name' => $LANG_PP['buttons'][$key])); $T->parse('BRow', 'BtnRow', true); } // Set the "none" selection if nothing was already selected $T->set_var('none_chk', $have_chk ? '' : 'checked="checked"'); $T->set_block('product', 'ProdTypeRadio', 'ProdType'); foreach ($LANG_PP['prod_types'] as $value => $text) { $T->set_var(array('type_val' => $value, 'type_txt' => $text, 'type_sel' => $this->prod_type == $value ? 'checked="checked"' : '')); $T->parse('ProdType', 'ProdTypeRadio', true); } /*$T->set_block('options', 'OptionRow', 'OptRow'); for ($i = 0; $i < 7; $i++) { $T->set_var(array( 'var' => $i, 'option_num' => $i + 1, 'on0_name' => $this->properties['options']['on0']['name'], 'on0_string' => $this->properties['options']['on0'][$i]['string'], 'on0_value' => $this->properties['options']['on0'][$i]['value'], 'on1_name' => $this->properties['options']['on1']['name'], 'on1_string' => $this->properties['options']['on1'][$i]['string'], 'on1_value' => $this->properties['options']['on1'][$i]['value'], ) ); $T->parse('OptRow', 'OptionRow', true); }*/ if (!$this->isUsed()) { $T->set_var('candelete', 'true'); } // Set up the photo fields. Use $photocount defined above. // If there are photos, read the $photo result. Otherwise, // or if this is a new ad, just clear the photo area $T->set_block('product', 'PhotoRow', 'PRow'); $i = 0; // Get the existing photos. Will only have photos with an // existing product entry. $photocount = 0; if ($this->id != NULL) { $sql = "SELECT img_id, filename \n FROM {$_TABLES['paypal.images']} \n WHERE product_id='" . $this->id . "'"; $photo = DB_query($sql); // save the count of photos for later use if ($photo) { $photocount = DB_numRows($photo); } // While we're checking the ID, set it as a hidden value // for updating this record $T->set_var('product_id', $this->id); } else { $T->set_var('product_id', ''); } // If there are any images, retrieve and display the thumbnails. if ($photocount > 0) { while ($prow = DB_fetchArray($photo)) { $i++; $T->set_var('img_url', PAYPAL_URL . "/images/products/{$prow['filename']}"); $T->set_var('thumb_url', PAYPAL_ImageUrl($prow['filename'])); $T->set_var('seq_no', $i); $T->set_var('del_img_url', PAYPAL_ADMIN_URL . '/index.php' . '?delete_img=x' . '&img_id=' . $prow['img_id'] . '&id=' . $this->id); $T->parse('PRow', 'PhotoRow', true); } } else { $T->parse('PRow', ''); } // add upload fields for unused images $T->set_block('product', 'UploadFld', 'UFLD'); for ($j = $i; $j < $_PP_CONF['max_images']; $j++) { $T->parse('UFLD', 'UploadFld', true); } $i = 0; foreach ($this->qty_discounts as $qty => $amt) { $T->set_var(array('disc_qty' . $i => $qty, 'disc_amt' . $i => $amt)); $i++; } /*$sql = "SELECT cat_id, cat_name FROM {$_TABLES['paypal.categories']} WHERE enabled=1 AND parent_id=0"; $res = DB_query($sql);*/ /*$str = ''; while ($A = DB_fetchArray($res, false)) { $str .= "<div><b>{$A['cat_name']}</b><br/> <ul>" . PAYPAL_recurseCats('prodform_catoption', 0, $A['cat_id'], '', '', '', 0, 0, array('<ol>', '</ol>')) . "</ul></div>"; } $T->set_var('catselect', $str);*/ $retval .= $T->parse('output', 'product'); /*@setcookie($_CONF['cookie_name'].'fckeditor', SEC_createTokenGeneral('advancededitor'), time() + 1200, $_CONF['cookie_path'], $_CONF['cookiedomain'], $_CONF['cookiesecure']); */ $retval .= COM_endBlock(); return $retval; }
/** * Creates the edit form. * * @param integer $id Attributeal ID, current record used if zero * @return string HTML for edit form */ function Edit() { global $_TABLES, $_CONF, $_PP_CONF, $LANG_PP; // If there are no products defined, return a formatted error message // instead of the form. if (DB_count($_TABLES['paypal.products']) == 0) { return PAYPAL_errMsg($LANG_PP['todo_noproducts']); } $T = new Template(PAYPAL_PI_PATH . '/templates'); $T->set_file(array('attrform' => 'attribute_form.thtml')); $id = $this->attr_id; // If we have a nonzero category ID, then we edit the existing record. // Otherwise, we're creating a new item. Also set the $not and $items // values to be used in the parent category selection accordingly. if ($id > 0) { $retval = COM_startBlock($LANG_PP['edit'] . ': ' . $this->attr_value); $T->set_var('attr_id', $id); } else { $retval = COM_startBlock($LANG_PP['new_option']); $T->set_var('attr_id', ''); } $T->set_var(array('action_url' => PAYPAL_ADMIN_URL, 'pi_url' => PAYPAL_URL, 'doc_url' => PAYPAL_getDocURL('attribute_form.html', $_CONF['language']), 'attr_value' => $this->attr_value, 'attr_price' => $this->attr_price, 'product_select' => COM_optionList($_TABLES['paypal.products'], 'id,name', $this->item_id), 'option_group_select' => COM_optionList($_TABLES['paypal.prod_attr'], 'DISTINCT attr_name,attr_name', $this->attr_name, 1), 'orderby' => $this->orderby, 'ena_chk' => $this->enabled == 1 ? ' checked="checked"' : '')); $retval .= $T->parse('output', 'attrform'); $retval .= COM_endBlock(); return $retval; }
/** * Creates the edit form. * * @param integer $id Optional ID, current record used if zero * @return string HTML for edit form */ public function showForm() { global $_TABLES, $_CONF, $_PP_CONF, $LANG_PP, $_SYSTEM; $T = new Template(PAYPAL_PI_PATH . '/templates'); if ($_SYSTEM['framework'] == 'uikit') { $T->set_file('category', 'category_form.uikit.thtml'); } else { $T->set_file('category', 'category_form.thtml'); } $id = $this->cat_id; // If we have a nonzero category ID, then we edit the existing record. // Otherwise, we're creating a new item. Also set the $not and $items // values to be used in the parent category selection accordingly. if ($id > 0) { $retval = COM_startBlock($LANG_PP['edit'] . ': ' . $this->cat_name); $T->set_var('cat_id', $id); $not = 'NOT'; $items = $id; } else { $retval = COM_startBlock($LANG_PP['create_category']); $T->set_var('cat_id', ''); $not = ''; $items = ''; } $T->set_var(array('action_url' => PAYPAL_ADMIN_URL, 'pi_url' => PAYPAL_URL, 'cat_name' => $this->cat_name, 'description' => $this->description, 'ena_chk' => $this->enabled == 1 ? 'checked="checked"' : '', 'parent_sel' => PAYPAL_recurseCats('PAYPAL_callbackCatOptionList', $this->parent_id, 0, '', $not, $items), 'group_sel' => SEC_getGroupDropdown($this->grp_access, 3, 'grp_access'), 'doc_url' => PAYPAL_getDocURL('category_form'))); if ($this->image != '') { $T->set_var('img_url', PAYPAL_PI_URL . '/images/categories/' . $this->image); } if (!$this->isUsed()) { $T->set_var('can_delete', 'true'); } /* // Might want this later to set default buttons per category $T->set_block('product', 'BtnRow', 'BRow'); foreach ($LANG_PP['buttons'] as $key=>$value) { $T->set_var(array( 'btn_type' => $key, 'btn_chk' => isset($this->buttons[$key]) ? 'checked="checked"' : '', 'btn_name' => $value, )); $T->parse('BRow', 'BtnRow', true); }*/ // If there's an image for this category, display it and offer // a link to delete it if ($this->image != '') { $T->set_var('img_url', PAYPAL_URL . '/images/categories/' . $this->image); $T->set_var('del_img_url', PAYPAL_ADMIN_URL . '/index.php?action=delete_img&img_id=' . $prow['img_id'] . '&id=' . $this->id); } $retval .= $T->parse('output', 'category'); @setcookie($_CONF['cookie_name'] . 'fckeditor', SEC_createTokenGeneral('advancededitor'), time() + 1200, $_CONF['cookie_path'], $_CONF['cookiedomain'], $_CONF['cookiesecure']); $retval .= COM_endBlock(); return $retval; }