/** * Display the detail page for the product. * * @return string HTML for the product page. */ public function Detail() { global $_CONF, $_PP_CONF, $_TABLES, $LANG_PP, $_USER, $_SYSTEM; USES_lib_comments(); $prod_id = $this->id; if ($prod_id < 1 || !$this->enabled || !$this->isAvailable()) { return PAYPAL_errorMessage($LANG_PP['invalid_product_id'], 'info'); } $retval = COM_startBlock(); // Set the template dir based on the configured template version $tpl_dir = PAYPAL_PI_PATH . '/templates/detail/' . $_PP_CONF['product_tpl_ver']; $T = new Template($tpl_dir); $T->set_file('product', 'product_detail_attrib.thtml'); $name = $this->name; $l_desc = PLG_replaceTags($this->description); $s_desc = PLG_replaceTags($this->short_description); // Highlight the query terms if coming from a search if (isset($_REQUEST['query']) && !empty($_REQUEST['query'])) { $name = COM_highlightQuery($name, $_REQUEST['query']); $l_desc = COM_highlightQuery($l_desc, $_REQUEST['query']); $s_desc = COM_highlightQuery($s_desc, $_REQUEST['query']); } $onsale = $this->isOnSale(); $act_price = $onsale ? $this->sale_price : $this->price; $qty_disc_txt = ''; foreach ($this->qty_discounts as $qty => $pct) { $qty_disc_txt .= sprintf('Buy %d, save %.02f%%<br />', $qty, $pct); } // Get custom text input fields if ('' != $this->custom) { $T->set_block('product', 'CustAttrib', 'cAttr'); $text_field_names = explode('|', $this->custom); foreach ($text_field_names as $id => $text_field_name) { $T->set_var(array('fld_id' => "cust_text_fld_{$id}", 'fld_name' => htmlspecialchars($text_field_name))); $T->parse('cAttr', 'CustAttrib', true); } } $T->set_var(array('is_uikit' => $_SYSTEM['framework'] == 'uikit' ? 'true' : '', 'have_attributes' => $this->hasAttributes(), 'id' => $prod_id, 'name' => $name, 'short_description' => $s_desc, 'description' => $l_desc, 'cur_decimals' => $this->currency->Decimals(), 'price' => $this->currency->FormatValue($act_price), 'orig_price' => $this->currency->Format($this->price), 'on_sale' => $onsale ? 'true' : '', 'img_cell_width' => $_PP_CONF['max_thumb_size'] + 20, 'price_prefix' => $this->currency->Pre(), 'price_postfix' => $this->currency->Post(), 'onhand' => $this->track_onhand ? $this->onhand : '', 'qty_disc' => $qty_disc_txt)); // Retrieve the photos and put into the template $sql = "SELECT img_id, filename\n FROM {$_TABLES['paypal.images']} \n WHERE product_id='{$prod_id}'"; //echo $sql;die; $img_res = DB_query($sql); $photo_detail = ''; $T->set_var('have_photo', ''); // assume no photo available if ($img_res && DB_numRows($img_res) > 0) { for ($i = 0; $prow = DB_fetchArray($img_res, false); $i++) { if ($prow['filename'] != '' && file_exists("{$_PP_CONF['image_dir']}/{$prow['filename']}")) { if ($i == 0) { $T->set_var('main_img', PAYPAL_ImageUrl($prow['filename'], $tpl_config['lg_img_width'] - 20, $tpl_config['lg_img_height'] - 20)); } $T->set_block('product', 'Thumbnail', 'PBlock'); $T->set_var(array('img_file' => $prow['filename'], 'disp_img' => PAYPAL_ImageUrl($prow['filename'], $tpl_config['lg_img_width'] - 20, $tpl_config['lg_img_height'] - 20), 'lg_img' => PAYPAL_URL . '/images/products/' . $prow['filename'], 'img_url' => PAYPAL_URL . '/images/products', 'thumb_url' => PAYPAL_ImageUrl($prow['filename']), 'tn_width' => $_PP_CONF['max_thumb_size'], 'tn_height' => $_PP_CONF['max_thumb_size'])); $T->parse('PBlock', 'Thumbnail', true); } } } // Get the product options, if any, and set them into the form $cbrk = ''; $T->set_block('product', 'AttrSelect', 'attrSel'); foreach ($this->options as $id => $Attr) { /*if ($Attr['attr_value'] === '') { $type = 'text'; } else { $type = 'select'; }*/ $type = 'select'; if ($Attr['attr_name'] != $cbrk) { if ($cbrk != '') { // end block if not the first element $T->set_var(array('attr_name' => $cbrk, 'attr_options' => $attributes, 'opt_id' => $id)); $T->parse('attrSel', 'AttrSelect', true); } $cbrk = $Attr['attr_name']; $attributes = ''; } if ($type == 'select') { if ($Attr['attr_price'] != 0) { $attr_str = sprintf(" ( %+.2f )", $Attr['attr_price']); } else { $attr_str = ''; } $attributes .= '<option value="' . $id . '|' . $Attr['attr_value'] . '|' . $Attr['attr_price'] . '">' . $Attr['attr_value'] . $attr_str . '</option>' . LB; /*} else { $attributes .= "<input type=\"hidden\" name=\"on{$i}\" value=\"{$Attr['attr_name']}\">\n"; $attributes .= $Attr['attr_name'] . ':</td> <td><input class="uk-contrast uk-form" type"text" name="os' . $i. '" value="" size="32" /></td></tr>'; */ } } if ($cbrk != '') { // finish off the last selection $T->set_var(array('attr_name' => $cbrk, 'attr_options' => $attributes, 'opt_id' => $id)); $T->parse('attrSel', 'AttrSelect', true); } $buttons = $this->PurchaseLinks(); $T->set_block('product', 'BtnBlock', 'Btn'); foreach ($buttons as $name => $html) { if ($name == 'add_cart') { // Set the add to cart button in the main form $T->set_var('add_cart_button', $html); } else { $T->set_var('buy_now_button', $html); $T->parse('Btn', 'BtnBlock', true); } } // Show the user comments if enabled globally and for this product if (plugin_commentsupport_paypal() && $this->comments_enabled != PP_COMMENTS_DISABLED) { // if enabled or closed if ($_CONF['commentsloginrequired'] == 1 && COM_isAnonUser()) { // Set mode to "disabled" $mode = -1; } else { $mode = $this->comments_enabled; } $T->set_var('usercomments', CMT_userComments($prod_id, $this->short_description, 'paypal', '', '', 0, 1, false, false, $mode)); } if ($this->rating_enabled == 1) { $PP_ratedIds = RATING_getRatedIds('paypal'); if (in_array($prod_id, $PP_ratedIds)) { $static = true; $voted = 1; } elseif (plugin_canuserrate_paypal($A['id'], $_USER['uid'])) { $static = 0; $voted = 0; } else { $static = 1; $voted = 0; } $rating_box = RATING_ratingBar('paypal', $prod_id, $this->votes, $this->rating, $voted, 5, $static, 'sm'); $T->set_var('rating_bar', $rating_box); } else { $T->set_var('ratign_bar', ''); } if ($this->isAdmin) { // Add the quick-edit link for administrators $T->set_var(array('pi_admin_url' => PAYPAL_ADMIN_URL, 'can_edit' => 'true')); } $retval .= $T->parse('output', 'product'); // Update the hit counter DB_query("UPDATE {$_TABLES['paypal.products']}\n SET views = views + 1\n WHERE id = '{$prod_id}'"); $retval .= COM_endBlock(); return $retval; }
/** * Display the detail page for the product. * * @return string HTML for the product page. */ public function Detail() { global $_CONF, $_PP_CONF, $_TABLES, $LANG_PP, $_USER; USES_lib_comments(); $prod_id = $this->id; if ($prod_id < 1 || !$this->enabled) { return PAYPAL_errorMessage($LANG_PP['invalid_product_id'], 'info'); } $retval = COM_startBlock(); // Set the template dir based on the configured template version $T = new Template(PAYPAL_PI_PATH . '/templates/detail' . $_PP_CONF['tpl_ver_detail']); if ($this->hasAttributes()) { $detail_template = 'product_detail_attrib.thtml'; } else { $detail_template = 'product_detail.thtml'; } $T->set_file('product', $detail_template); $name = $this->name; $l_desc = PLG_replaceTags($this->description); $s_desc = PLG_replaceTags($this->short_description); // Highlight the query terms if coming from a search if (isset($_REQUEST['query']) && !empty($_REQUEST['query'])) { $name = COM_highlightQuery($name, $_REQUEST['query']); $l_desc = COM_highlightQuery($l_desc, $_REQUEST['query']); $s_desc = COM_highlightQuery($s_desc, $_REQUEST['query']); } $act_price = $this->sale_price == $this->price ? $this->price : $this->sale_price; $T->set_var(array('id' => $prod_id, 'name' => $name, 'short_description' => $s_desc, 'description' => $l_desc, 'cur_decimals' => $this->currency->Decimals(), 'price' => $this->currency->FormatValue($act_price), 'orig_price' => $this->currency->Format($this->price), 'on_sale' => $act_price == $this->price ? '' : 'true', 'img_cell_width' => $_PP_CONF['max_thumb_size'] + 20, 'price_prefix' => $this->currency->Pre(), 'price_postfix' => $this->currency->Post(), 'onhand' => $this->track_onhand ? $this->onhand : '')); // Retrieve the photos and put into the template $sql = "SELECT img_id, filename\n FROM {$_TABLES['paypal.images']} \n WHERE product_id='{$prod_id}'"; //echo $sql;die; $img_res = DB_query($sql); $photo_detail = ''; $T->set_var('have_photo', ''); // assume no photo available if ($img_res && DB_numRows($img_res) > 0) { for ($i = 0; $prow = DB_fetchArray($img_res, false); $i++) { if ($prow['filename'] != '' && file_exists("{$_PP_CONF['image_dir']}/{$prow['filename']}")) { if ($i == 0) { $T->set_var('main_img', $prow['filename']); } $T->set_block('product', 'Thumbnail', 'PBlock'); $T->set_var('img_file', $prow['filename']); $T->set_var('img_url', PAYPAL_URL . '/images/products'); $T->set_var('thumb_url', PAYPAL_ImageUrl($prow['filename'])); $T->parse('PBlock', 'Thumbnail', true); $T->set_var('have_photo', 'true'); } } } // Get the product options, if any, and set them into the form $i = 0; $cbrk = ''; $attributes = ''; foreach ($this->options as $id => $Attr) { if ($Attr['attr_name'] != $cbrk) { if ($i > 0) { $attributes .= "</select></td></tr>\n"; } else { $attributes = '<table border="0">' . "\n"; } $cbrk = $Attr['attr_name']; $attributes .= "<tr><td>\n <input type=\"hidden\" name=\"on{$i}\" \n value=\"{$Attr['attr_name']}\">\n\n <input type=\"hidden\" name=\"os{$i}\" \n value=\"\">\n\n {$Attr['attr_name']}:</td>\n <td align=\"left\">\n <select name=\"options[]\"\n onchange=\"ProcessForm(this.form);\">\n"; /*<td align=\"left\"><select name=\"pp_os{$i}\"*/ $i++; } if ($Attr['attr_price'] != 0) { $attr_str = sprintf(" ( %+.2f )", $Attr['attr_price']); } else { $attr_str = ''; } $attributes .= '<option value="' . $id . '|' . $Attr['attr_value'] . '|' . $Attr['attr_price'] . '">' . $Attr['attr_value'] . $attr_str . '</option>' . LB; } if ($attributes != '') { $attributes .= "</select></td></tr></table>\n"; $T->set_var('attributes', $attributes); } $buttons = $this->PurchaseLinks(); $T->set_block('product', 'BtnBlock', 'Btn'); foreach ($buttons as $name => $html) { $T->set_var('button', $html); $T->parse('Btn', 'BtnBlock', true); } // Show the user comments if enabled globally and for this product if (plugin_commentsupport_paypal() && $this->comments_enabled != PP_COMMENTS_DISABLED) { // if enabled or closed if ($_CONF['commentsloginrequired'] == 1 && COM_isAnonUser()) { // Set mode to "disabled" $mode = -1; } else { $mode = $this->comments_enabled; } $T->set_var('usercomments', CMT_userComments($prod_id, $this->short_description, 'paypal', '', '', 0, 1, false, false, $mode)); } if ($this->rating_enabled == 1) { $PP_ratedIds = RATING_getRatedIds('paypal'); if (in_array($prod_id, $PP_ratedIds)) { $static = true; $voted = 1; } elseif (plugin_canuserrate_paypal($A['id'], $_USER['uid'])) { $static = 0; $voted = 0; } else { $static = 1; $voted = 0; } $rating_box = RATING_ratingBar('paypal', $prod_id, $this->votes, $this->rating, $voted, 5, $static, 'sm'); $T->set_var('rating_bar', $rating_box); } else { $T->set_var('ratign_bar', ''); } if ($this->isAdmin) { // Add the quick-edit link for administrators $T->set_var(array('pi_admin_url' => PAYPAL_ADMIN_URL, 'can_edit' => 'true')); } $retval .= $T->parse('output', 'product'); // Update the hit counter DB_query("UPDATE {$_TABLES['paypal.products']}\n SET views = views + 1\n WHERE id = '{$prod_id}'"); $retval .= COM_endBlock(); return $retval; }
/** * Diaplay the product catalog items. * * @return string HTML for product catalog. */ function PAYPAL_ProductList($cat = 0, $search = '') { global $_TABLES, $_CONF, $_PP_CONF, $LANG_PP, $_USER, $_PLUGINS, $_IMAGE_TYPE, $_GROUPS; USES_paypal_class_product(); if (SEC_hasRights('paypal.admin')) { $isAdmin = true; } else { $isAdmin = false; } $my_groups = implode(',', $_GROUPS); $cat_name = ''; $breadcrumbs = ''; $img_url = ''; $display = ''; if ($cat != 0) { $breadcrumbs = PAYPAL_Breadcrumbs($cat); $cat = (int) $cat; $A = DB_fetchArray(DB_query("SELECT cat_name, image\n FROM {$_TABLES['paypal.categories']}\n WHERE cat_id='{$cat}' " . COM_getPermSQL('AND')), false); if (!empty($A)) { $cat_name = $A['cat_name']; if (!empty($A['image']) && is_file($_CONF['path_html'] . $_PP_CONF['pi_name'] . '/images/categories/' . $A['image'])) { $img_url = PAYPAL_URL . '/images/categories/' . $A['image']; } } } // Display categories if (isset($_PP_CONF['cat_columns']) && $_PP_CONF['cat_columns'] > 0) { $sql = "SELECT cat.cat_id, cat.cat_name, count(prod.id) AS cnt \n FROM {$_TABLES['paypal.categories']} cat\n LEFT JOIN {$_TABLES['paypal.products']} prod\n ON prod.cat_id = cat.cat_id\n WHERE cat.enabled = '1' AND cat.parent_id = '{$cat}' \n AND prod.enabled = '1' " . COM_getPermSQL('AND', 0, 2, 'cat') . " GROUP BY cat.cat_id\n ORDER BY cat.cat_name"; //HAVING cnt > 0 //echo $sql;die; $CT = new Template(PAYPAL_PI_PATH . '/templates'); $CT->set_file(array('table' => 'category_table.thtml', 'row' => 'category_row.thtml', 'category' => 'category.thtml')); $CT->set_var('width', floor(100 / $_PP_CONF['cat_columns'])); if ($breadcrumbs != '') { $CT->set_var('breadcrumbs', $breadcrumbs); } if ($img_url != '') { $CT->set_var('catimg_url', $img_url); } $res = DB_query($sql); $A = array(); while ($C = DB_fetchArray($res, false)) { $A[$C['cat_id']] = array($C['cat_name'], $C['cnt']); } // Now get categories from plugins foreach ($_PLUGINS as $pi_name) { $function = 'USES_' . $pi_name . '_paypal'; if (function_exists($function)) { $function(); $function = 'plugin_paypal_getcategories_' . $pi_name; if (function_exists($function)) { $pi_cats = $function(); foreach ($pi_cats as $catid => $data) { $A[$catid] = $data; } } } } $i = 1; $nrows = count($A); foreach ($A as $category => $info) { $CT->set_var(array('category_name' => $info[0], 'category_link' => PAYPAL_URL . '/index.php?category=' . urlencode($category))); /*if ($category == $cat) { $CT->set_var('curr', 'current'); $cat_name = $info[0]; } else { $CT->set_var('curr', 'other'); }*/ $CT->parse('catrow', 'category', true); if ($i % $_PP_CONF['cat_columns'] == 0) { $CT->parse('categories', 'row', true); $CT->set_var('catrow', ''); } $i++; } if ($nrows % $_PP_CONF['cat_columns'] != 0) { $CT->parse('categories', 'row', true); } $display .= $CT->parse('', 'table'); } /*$sortby_opts = array( 'name' => $LANG_PP['name'], 'price' => $LANG_PP['price'], 'dt_add' => $LANG_PP['dt_add'], ); switch ($_REQUEST['sortby']){ case 'name': case 'price': case 'dt_add': $sortby = $_REQUEST['sortby']; break; default: $sortby = $_PP_CONF['order']; break; } $sortby_options = ''; foreach ($sortby_opts as $value=>$text) { $sel = $value == $sortby ? ' selected="selected"' : ''; $sortby_options .= "<option value=\"$value\" $sel>$text</option>\n"; } $sortdir = $_REQUEST['sortdir'] == 'DESC' ? 'DESC' : 'ASC';*/ $sortby = $_PP_CONF['order']; $sortdir = 'ASC'; // Get products from database. "c.enabled is null" is to allow products // with no category defined $sql = " FROM {$_TABLES['paypal.products']} p\n LEFT JOIN {$_TABLES['paypal.categories']} c\n ON p.cat_id = c.cat_id\n WHERE p.enabled=1 \n AND (\n (c.enabled=1 " . COM_getPermSQL('AND', 0, 2, 'c') . ")\n OR c.enabled IS NULL\n )\n AND (\n p.track_onhand = 0 OR p.onhand > 0 OR p.oversell < 2\n )"; $pagenav_args = array(); // If applicable, limit by category if (!empty($_REQUEST['category'])) { $cat_list = $_REQUEST['category']; $cat_list .= PAYPAL_recurseCats('PAYPAL_callbackCatCommaList', 0, $_REQUEST['category']); if (!empty($cat_list)) { $sql .= " AND c.cat_id IN ({$cat_list})"; } $pagenav_args[] = 'category=' . urlencode($_REQUEST['category']); } else { $cat_list = ''; } // If applicable, limit by search string if (!empty($_REQUEST['search_name'])) { $srch = DB_escapeString($_REQUEST['search_name']); $sql .= " AND (p.name like '%{$srch}%' OR \n p.short_description like '%{$srch}%' OR\n p.description like '%{$srch}%' OR\n p.keywords like '%{$srch}%')"; //if (!$isAdmin) $sql .= " AND p.grp_access IN ($my_groups) "; $pagenav_args[] = 'search_name=' . urlencode($_REQUEST['search_name']); } // If applicable, order by $sql .= " ORDER BY {$sortby} {$sortdir}"; // If applicable, handle pagination of query if (isset($_PP_CONF['prod_per_page']) && $_PP_CONF['prod_per_page'] > 0) { // Count products from database $res = DB_query('SELECT COUNT(*) as cnt ' . $sql); $x = DB_fetchArray($res, false); if (isset($x['cnt'])) { $count = (int) $x['cnt']; } else { $count = 0; } // Make sure page requested is reasonable, if not, fix it if (!isset($_REQUEST['page']) || $_REQUEST['page'] <= 0) { $_REQUEST['page'] = 1; } $page = (int) $_REQUEST['page']; $start_limit = ($page - 1) * $_PP_CONF['prod_per_page']; if ($start_limit > $count) { $page = ceil($count / $_PP_CONF['prod_per_page']); } // Add limit for pagination (if applicable) if ($count > $_PP_CONF['prod_per_page']) { $sql .= " LIMIT {$start_limit}, {$_PP_CONF['prod_per_page']}"; } } // Re-execute query with the limit clause in place $res = DB_query('SELECT DISTINCT p.id ' . $sql); // Create product template $product = new Template(PAYPAL_PI_PATH . '/templates'); $product->set_file(array('start' => 'product_list_start.thtml', 'end' => 'product_list_end.thtml', 'product' => 'product_list_item.thtml', 'download' => 'buttons/btn_download.thtml', 'login_req' => 'buttons/btn_login_req.thtml', 'btn_details' => 'buttons/btn_details.thtml')); if ($nrows == 0 && COM_isAnonUser()) { $product->set_var('anon_and_empty', 'true'); } $product->set_var(array('pi_url' => PAYPAL_URL, 'user_id' => $_USER['uid'], 'currency' => $_PP_CONF['currency'])); if (!empty($cat_name)) { $product->set_var('title', $cat_name); } else { $product->set_var('title', $LANG_PP['blocktitle']); } /*$product->set_var('sortby_options', $sortby_options); if ($sortdir == 'DESC') { $product->set_var('sortdir_desc_sel', ' selected="selected"'); } else { $product->set_var('sortdir_asc_sel', ' selected="selected"'); } $product->set_var('sortby', $sortby); $product->set_var('sortdir', $sortdir);*/ $display .= $product->parse('', 'start'); // Create an empty product object $P = new Product(); if ($_PP_CONF['ena_ratings'] == 1) { $PP_ratedIds = RATING_getRatedIds('paypal'); } // Display each product while ($A = DB_fetchArray($res, false)) { $P->Read($A['id']); if ($_PP_CONF['ena_ratings'] == 1 && $P->rating_enabled == 1) { if (in_array($A['id'], $PP_ratedIds)) { $static = true; $voted = 1; } elseif (plugin_canuserrate_paypal($A['id'], $_USER['uid'])) { $static = false; $voted = 0; } else { $static = true; $voted = 0; } $rating_box = RATING_ratingBar('paypal', $A['id'], $P->votes, $P->rating, $voted, 5, $static, 'sm'); $product->set_var('rating_bar', $rating_box); } else { $product->set_var('rating_bar', ''); } $product->set_var(array('id' => $A['id'], 'name' => $P->name, 'short_description' => PLG_replacetags($P->short_description), 'img_cell_width' => $_PP_CONF['max_thumb_size'] + 20, 'encrypted' => '', 'item_url' => COM_buildURL(PAYPAL_URL . '/detail.php?id=' . $A['id']), 'img_cell_width' => $_PP_CONF['max_thumb_size'] + 20, 'track_onhand' => $P->track_onhand ? 'true' : '', 'qty_onhand' => $P->onhand)); if ($P->price > 0) { //$product->set_var('price', COM_numberFormat($P->price, 2)); $product->set_var('price', $P->currency->Format($P->price)); } else { $product->clear_var('price'); } if ($isAdmin) { $product->set_var('is_admin', 'true'); $product->set_var('pi_admin_url', PAYPAL_ADMIN_URL); $product->set_var('edit_icon', "{$_CONF['layout_url']}/images/edit.{$_IMAGE_TYPE}"); } $pic_filename = DB_getItem($_TABLES['paypal.images'], 'filename', "product_id = '{$A['id']}'"); if ($pic_filename) { $product->set_var('small_pic', PAYPAL_ImageUrl($pic_filename)); } else { $product->set_var('small_pic', ''); } // FIXME: If a user purchased once with no expiration, this query // will not operate correctly /*$time = DB_getItem($_TABLES['paypal.purchases'], 'MAX(UNIX_TIMESTAMP(expiration))', "user_id = {$_USER['uid']} AND product_id ='{$A['id']}'"); */ $product->set_block('product', 'BtnBlock', 'Btn'); if (!$P->hasAttributes()) { // Buttons only show in the list if there are no options to select $buttons = $P->PurchaseLinks(); foreach ($buttons as $name => $html) { $product->set_var('button', $html); $product->parse('Btn', 'BtnBlock', true); } } else { if ($_PP_CONF['ena_cart']) { // If the product has attributes, then the cart must be // enabled to allow purchasing $button = $product->parse('', 'btn_details') . ' '; $product->set_var('button', $button); $product->parse('Btn', 'BtnBlock', true); } } $display .= $product->parse('', 'product'); $product->clear_var('Btn'); } // Get products from plugins. // For now, this hack shows plugins only on the first page, since // they're not included in the page calculation. if ($page == 1 && empty($cat_list)) { // Get the currency class for formatting prices USES_paypal_class_currency(); $Cur = new ppCurrency($_PP_CONF['currency']); $product->clear_var('rating_bar'); // no ratings for plugins (yet) foreach ($_PLUGINS as $pi_name) { $status = LGLIB_invokeService($pi_name, 'getproducts', array(), $plugin_data, $svc_msg); if ($status != PLG_RET_OK || empty($plugin_data)) { continue; } foreach ($plugin_data as $A) { // Reset button values $buttons = ''; $product->set_var(array('id' => $A['id'], 'name' => $A['name'], 'short_description' => $A['short_description'], 'display' => '; display: none', 'small_pic' => '', 'encrypted' => '', 'item_url' => $A['url'], 'track_onhand' => '')); if ($A['price'] > 0) { $product->set_var('price', $Cur->Format($A['price'])); } else { $product->clear_var('price'); } if ($A['price'] > 0 && $_USER['uid'] == 1 && !$_PP_CONF['anon_buy']) { $buttons .= $product->set_var('', 'login_req') . ' '; } elseif ($A['prod_type'] > PP_PROD_PHYSICAL && $A['price'] == 0) { // Free items or items purchases and not expired, download. $buttons .= $product->set_var('', 'download') . ' '; } elseif (is_array($A['buttons'])) { // Buttons for everyone else $product->set_block('product', 'BtnBlock', 'Btn'); foreach ($A['buttons'] as $type => $html) { $product->set_var('button', $html); $product->parse('Btn', 'BtnBlock', true); } } //$product->set_var('buttons', $buttons); $display .= $product->parse('', 'product'); $product->clear_var('Btn'); } // foreach plugin_data } // foreach $_PLUGINS } // if page == 1 $pagenav_args = empty($pagenav_args) ? '' : '?' . implode('&', $pagenav_args); // Display pagination if (isset($_PP_CONF['prod_per_page']) && $_PP_CONF['prod_per_page'] > 0 && $count > $_PP_CONF['prod_per_page']) { $product->set_var('pagination', COM_printPageNavigation(PAYPAL_URL . '/index.php' . $pagenav_args, $page, ceil($count / $_PP_CONF['prod_per_page']))); } else { $product->set_var('pagination', ''); } $display .= $product->parse('', 'end'); return $display; }
if (isset($_GET['reply'])) { $reply = COM_applyFilter($_GET['reply']); } } if (empty($sid)) { COM_404(); } if (strcasecmp($order, 'ASC') != 0 && strcasecmp($order, 'DESC') != 0) { $order = ''; } $result = DB_query("SELECT COUNT(*) AS count FROM {$_TABLES['stories']} WHERE sid = '" . DB_escapeString($sid) . "'" . COM_getPermSql('AND')); $A = DB_fetchArray($result); if ($A['count'] > 0) { $ratedIds = array(); if ($_CONF['rating_enabled'] != 0) { $ratedIds = RATING_getRatedIds('article'); } $story = new Story(); $args = array('sid' => $sid, 'mode' => 'view'); $output = STORY_LOADED_OK; $result = PLG_invokeService('story', 'get', $args, $output, $svc_msg); if ($result == PLG_RET_OK) { /* loadFromArray cannot be used, since it overwrites the timestamp */ reset($story->_dbFields); while (list($fieldname, $save) = each($story->_dbFields)) { $varname = '_' . $fieldname; if (array_key_exists($fieldname, $output)) { $story->{$varname} = $output[$fieldname]; } } $story->_username = $output['username'];
$numCategoriesPerRow = 6; $myts = new MyTextSanitizer(); $mytree = new XoopsTree($_DB_name, $_TABLES['filemgmt_cat'], 'cid', 'pid'); $mytree->setGroupAccessFilter($_GROUPS); $page = isset($_GET['page']) ? COM_applyFilter($_GET['page'], true) : 0; $cid = isset($_GET['cid']) ? COM_applyFilter($_GET['cid'], true) : 0; $orderby = isset($_GET['orderby']) ? @html_entity_decode(COM_applyFilter($_GET['orderby'], false)) : ''; $groupsql = filemgmt_buildAccessSql(); $sql = "SELECT COUNT(*) FROM {$_TABLES['filemgmt_cat']} WHERE cid='" . intval($cid) . "' {$groupsql}"; list($category_rows) = DB_fetchArray(DB_query($sql)); if ($cid == 0 or $category_rows == 0) { echo COM_refresh($_CONF['site_url'] . '/filemgmt/index.php'); exit; } $FM_ratedIds = array(); $FM_ratedIds = RATING_getRatedIds('filemgmt'); $display = FM_siteHeader($LANG_FILEMGMT['usermenu1']); $p = new Template($_CONF['path'] . 'plugins/filemgmt/templates'); $p->set_file(array('page' => 'filelisting.thtml', 'records' => 'filelisting_record.thtml', 'category' => 'filelisting_subcategory.thtml', 'sortmenu' => 'sortmenu.thtml')); $p->set_var('tablewidth', $mydownloads_shotwidth + 10); $p->set_var('block_header', COM_startBlock(_MD_CATEGORYTITLE)); $p->set_var('block_footer', COM_endBlock()); $trimDescription = true; // Set to false if you do not want to auto trim the description and insert the <more..> link if (!isset($page) || $page == 0) { // If no page sent then assume the first. $page = 1; } $show = $mydownloads_perpage; $offset = ($page - 1) * $show; if (isset($orderby) && $orderby != "") {