/** * Returns the content of a given staticpage * * @author mystral-kk - geeklog AT mystral-kk DOT net * @license GPL v2 * @param $sp_id string an id of a staticpage * @return string the content of the staticpage */ function CUSTOM_getStaticpage($sp_id) { global $_TABLES, $_PLUGINS, $_SP_CONF, $LANG_STATIC; $retval = ''; if (!in_array('staticpages', $_PLUGINS)) { return $retval; } $sql = "SELECT sp_php, sp_content FROM {$_TABLES['staticpage']} " . "WHERE (sp_id = '" . addslashes($sp_id) . "') " . "AND " . SP_getPerms(); $result = DB_query($sql); if (DB_error() or DB_numRows($result) == 0) { return $retval; } else { $A = DB_fetchArray($result); $sp_php = $A['sp_php']; $sp_content = stripslashes($A['sp_content']); } if ($_SP_CONF['allow_php'] == 1) { // Check for type (i.e. html or php) if ($sp_php == 1) { $retval .= eval($sp_content); } else { if ($sp_php == 2) { ob_start(); eval($sp_content); $retval .= ob_get_contents(); ob_end_clean(); } else { $retval .= PLG_replacetags($sp_content); } } } else { if ($sp_php != 0) { COM_errorLog("PHP in static pages is disabled. Cannot display page '{$sp_id}'.", 1); $retval .= $LANG_STATIC['deny_msg']; } else { $retval .= $sp_content; } } return $retval; }
function nexlistShowLists($listid, $page = 0, $pluginmode = '', $catmode = '') { global $_CONF, $_TABLES, $CONF_LL; $search = COM_applyFilter($_GET['search']); $p = new Template($_CONF['path_layout'] . 'nexlist'); $p->set_file(array('page' => 'viewitems.thtml', 'javascript' => 'javascript/listitems.thtml', 'headingfield' => 'listheading_field.thtml', 'list_rec' => 'list_record.thtml', 'rec_field' => 'list_record_field.thtml', 'new_item' => 'additem_record.thtml')); $actionurl = "{$_CONF['site_admin_url']}/plugins/nexlist/index.php"; $query = DB_query("SELECT name,description FROM {$_TABLES['nexlist']} WHERE id='{$listid}'"); list($listname, $listdesc) = DB_fetchArray($query); $p->set_var('layouturl', $_CONF['layout_url']); $p->set_var('actionurl', $actionurl); $p->set_var('listid', $listid); $p->set_var('listname', $listname); $p->set_var('listdesc', $listdesc); $p->set_var('pluginmode', $pluginmode); $p->set_var('catmode', $catmode); if ($GLOBALS['errmsg'] != '') { $p->set_var('error_msg', $GLOBALS['errmsg']); } else { $p->set_var('hide_errormsg', 'none'); } // Check if user has edit access to this list $GROUPS = SEC_getUserGroups($_USER['uid']); // List of groups user is a member of $sql = "SELECT id FROM {$_TABLES['nexlist']} WHERE edit_perms IN (" . implode(',', $GROUPS) . ") AND id={$listid}"; if (DB_numRows(DB_query($sql)) != 1) { $editright = false; $p->set_var('showhide_additem', 'hidden'); $p->set_var('show_edit_actions', 'none'); } else { $editright = true; } // Retrieve list of fields for this nexlist list and if a function is used for its value options $query = DB_query("SELECT id,fieldname,value_by_function,width FROM {$_TABLES['nexlistfields']} WHERE lid='{$listid}' ORDER BY id"); $numfields = 0; while (list($fieldid, $fieldname, $function, $width) = DB_fetchArray($query)) { $listfields[$fieldname] = $function; $listfieldwidths[$numfields] = $width; $numfields++; } if ($numfields == 0) { $p->set_var('help_msg', 'No fields have yet been defined for this definition'); $p->set_var('showhide_additem', 'hidden'); } else { $p->set_var('help_msg', 'The following are current list items. Click on [New Item] to add an new list item.'); // Headings of list fields $p->set_var('heading_label', 'Order'); $p->set_var('heading_cell_width', ''); $p->parse('heading_fields', 'headingfield'); $p->set_var('heading_label', 'ID'); $p->set_var('heading_cell_width', ''); $p->parse('heading_fields', 'headingfield', true); for ($i = 0; $i < $numfields; $i++) { $p->set_var('heading_label', key($listfields)); $width = $listfieldwidths[$i]; if ($width > 0) { $p->set_var('heading_cell_width', "width=\"{$width}%\""); } else { $p->set_var('heading_cell_width', ''); } $p->parse('heading_fields', 'headingfield', true); $p->set_var('newfield_name', key($listfields)); $function = current($listfields); // If field uses a function and it exists - then return the display value if (!empty($function) and function_exists($function)) { $edit_field_html = $function('edit', "field{$i}", $listvalues[$i], true); $p->set_var('newfield_html', $edit_field_html); } elseif (strpos($function, 'list:') > 0) { // Check if list autotag is used // Autotag being used - need to extract it and append to it to activate the read mode $autotag = explode('list:', $function); $autotag_contents = str_replace(']', '', $autotag[1]); $varname = "field{$i}"; $editautotag = "[list:{$autotag_contents},{$listvalues[$field]},edit,{$varname}]"; $p->set_var('newfield_html', PLG_replacetags($editautotag, 'nexlist')); } else { $p->set_var('newfield_html', '<input type="text" name="field' . $i . '">'); } $p->parse('additem_record', 'new_item', true); next($listfields); } if ($editright) { $p->set_var('heading_label', 'Actions'); $p->set_var('heading_cell_width', ''); $p->parse('heading_fields', 'headingfield', true); } $sql = "SELECT * FROM {$_TABLES['nexlistitems']} WHERE lid='{$listid}' "; if ($search != '') { $search = addslashes($search); $sql .= "AND value like '%{$search}%' "; } $query = DB_query($sql); $numRecords = DB_numRows($query); $numpages = ceil($numRecords / $CONF_LL['pagesize']); if ($page > 0) { $offset = ($page - 1) * $CONF_LL['pagesize']; } else { $offset = 0; $page = 1; } // Retrieve the list records and field values - checking if field uses a function $sql = "SELECT * FROM {$_TABLES['nexlistitems']} WHERE lid='{$listid}' "; if ($search != '') { $search = addslashes($search); $sql .= "AND value like '%{$search}%' "; } $sql .= "ORDER BY itemorder asc, id asc LIMIT {$offset},{$CONF_LL['pagesize']}"; $query = DB_query($sql); $cssid = 1; $p->set_var('num_records', DB_numRows($query)); $p->set_var('num_fields', $numfields); $rowid = 1; while ($B = DB_fetchArray($query, false)) { $p->set_var('cssid', $rowid % 2 + 1); $p->set_var('list_recid', $B['id']); $p->set_var('list_order', $B['itemorder']); $p->parse('listrec_fields', 'rec_field'); $p->set_var('rowid', $rowid); $listvalues = explode(',', $B['value']); reset($listfields); for ($field = 0; $field < $numfields; $field++) { $fldname = "item_{$rowid}_field{$field}"; $p->set_var('fieldid', $field); $function = current($listfields); // If field uses a function and it exists - then return the display value if (!empty($function) and function_exists($function)) { $fieldvalue = $function('read', '', $listvalues[$field]); $p->set_var('field_value', $fieldvalue); $edit_field_html = $function('edit', $fldname, $listvalues[$field]); $p->set_var('edit_field_html', $edit_field_html); } elseif (strpos($function, 'list:') > 0) { // Check if list autotag is used // Autotag being used - need to extract it and append to it to activate the read mode $autotag = explode('list:', $function); $autotag_contents = str_replace(']', '', $autotag[1]); $readautotag = "[list:{$autotag_contents},{$listvalues[$field]},read]"; $fieldvalue = PLG_replacetags($readautotag, 'nexlist'); $p->set_var('field_value', $fieldvalue); $varname = "item_{$rowid}_field{$field}"; $editautotag = "[list:{$autotag_contents},{$listvalues[$field]},edit,{$varname}]"; $p->set_var('edit_field_html', PLG_replacetags($editautotag, 'nexlist')); } else { $fieldvalue = $listvalues[$field]; $p->set_var('field_value', $fieldvalue); $p->set_var('edit_field_html', '<input type="text" name="' . $fldname . '" value="' . $fieldvalue . '">'); } next($listfields); if ($field == 0) { $p->parse('listrec_fields', 'rec_field'); } else { $p->parse('listrec_fields', 'rec_field', true); } } $editlink = '[ <a href="#" onClick="document.nexlist.op.value=\'edititem\';document.nexlist.item.value=\'' . $B['id'] . '\';nexlist.submit();">Edit</a> ]'; $deletelink = ' [ <a href="#">Delete</a> ]'; $p->set_var('edit_action', $editlink); $p->set_var('delete_action', $deletelink); $p->parse('list_records', 'list_rec', true); $rowid++; // For each list item - create the edit div and form } } $base_url = $_CONF['site_admin_url'] . '/plugins/nexlist/index.php?op=list_def&listid=' . $listid; $p->set_var('pagenavigation', COM_printPageNavigation($base_url, $page, $numpages)); $p->parse('javascript_code', 'javascript'); $p->parse('output', 'page'); $retval = $p->finish($p->get_var('output')); 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; }
$query = DB_query("SELECT id, value_by_function FROM {$_TABLES['nexlistfields']} WHERE lid='{$did}' ORDER BY id"); $retval = ''; // Cycle through the fields and the passed in matching values as selections while (list($id, $function) = DB_fetchArray($query)) { if (!empty($function) and function_exists($function)) { $fieldvalue = $function('read', '', current($values)); if ($CONF_LL['debug']) { COM_errorLog("Ajaxupdate: Function: {$function} AND value: {$fieldvalue}"); } } elseif (strpos($function, 'list:') > 0) { // Check if list autotag is used // Autotag being used - need to extract it and append to it to activate the read mode $autotag = explode('list:', $function); $autotag_contents = str_replace(']', '', $autotag[1]); $readautotag = "[list:{$autotag_contents}," . current($values) . ",read]"; $fieldvalue = PLG_replacetags($readautotag, 'nexlist'); if ($CONF_LL['debug']) { COM_errorLog("Ajaxupdate: Tag: {$readautotag} AND value: {$fieldvalue}"); } } else { $fieldvalue = current($values); } $fieldvalue = htmlspecialchars($fieldvalue); if ($retval == '') { $retval = $fieldvalue; } else { $retval .= ':' . $fieldvalue; } next($values); } // If this field uses a function then we want to return the new value for the updated item
function fnclist($pi_name, $template, $group_id, $perpage, $page, $order, $gcode) { global $_CONF; global $_TABLES; global $_DATABOX_CONF; global $perpage; global $LANG_DATABOX; global $LANG_DATABOX_ADMIN; if ($group_id === "") { if ($gcode != "") { $group_id = DATABOX_codetoid($gcode, 'DATABOX_def_group', "group_id"); } } //----- if ($page == 0) { $page = 1; } //----- $tbl1 = $_TABLES['DATABOX_category']; $tbl2 = $_TABLES['DATABOX_base']; $tbl3 = $_TABLES['DATABOX_def_category']; $tbl4 = $_TABLES['DATABOX_def_group']; //@@@@@ //----- $sql = "SELECT " . LB; $sql .= " t1.category_id " . LB; $sql .= " ,t3.name " . LB; $sql .= " ,t3.code " . LB; $sql .= " ,t3.description " . LB; $sql .= " ,Count(t1.id) AS count" . LB; $sql .= " ,t4.name AS group_name " . LB; $sql .= " ,t4.group_id " . LB; $sql .= " ,t4.code AS group_code " . LB; $sql .= " FROM " . LB; $sql .= " {$tbl1} AS t1 " . LB; $sql .= " ,{$tbl2} AS t2 " . LB; $sql .= " ,{$tbl3} AS t3 " . LB; $sql .= " ,{$tbl4} AS t4 " . LB; $sql .= " WHERE " . LB; $sql .= " t1.id = t2.id " . LB; $sql .= " AND t1.category_id = t3.category_id " . LB; if ($group_id != "") { $sql .= " AND t3.categorygroup_id = " . $group_id . LB; } $sql .= " AND t3.categorygroup_id = t4.group_id " . LB; //管理者の時,下書データも含む //if ( SEC_hasRights('databox.admin')) { //}else{ $sql .= " AND t2.draft_flag=0" . LB; //} //アクセス権のないデータ はのぞく $sql .= COM_getPermSql('AND', 0, 2, "t2") . LB; //公開日以前のデータはのぞく $sql .= " AND (released <= NOW())" . LB; //公開終了日を過ぎたデータはのぞく $sql .= " AND (expired=0 OR expired > NOW())" . LB; $sql .= " GROUP BY " . LB; $sql .= " t1.category_id" . LB; $sql .= " ORDER BY " . LB; $sql .= " t4.orderno,t3.orderno" . LB; $result = DB_query($sql); $cnt = DB_numRows($result); $pages = 0; if ($perpage > 0) { $pages = ceil($cnt / $perpage); } //ヘッダ、左ブロック if ($page > 1) { $page_title = sprintf('%s (%d)', $LANG_DATABOX['category_top'], $page); } else { $page_title = sprintf('%s ', $LANG_DATABOX['category_top']); } $headercode = "<title>" . $_CONF['site_name'] . " - " . $page_title . "</title>"; // Meta Tags $headercode .= DATABOX_getheadercode("category", $template, $pi_name, 0, $_CONF['site_name'], $_CONF['meta_description'], $_CONF['smeta_keywords'], $_CONF['meta_description']); $retval .= DATABOX_siteHeader($pi_name, '', $page_title, $headercode); // $tmplfld = DATABOX_templatePath('category', $template, $pi_name); $templates = new Template($tmplfld); $templates->set_file(array('list' => 'list.thtml', 'nav' => 'navigation.thtml', 'row' => 'row.thtml', 'col' => "col.thtml", 'grp' => "grp.thtml", 'pagenav' => 'pagenavigation.thtml')); $languageid = COM_getLanguageId(); $language = COM_getLanguage(); $templates->set_var('languageid', $languageid); $templates->set_var('language', $language); if ($languageid != "") { $templates->set_var('_languageid', "_" . $languageid); } else { $templates->set_var('_languageid', ""); } // $templates->set_var('site_url', $_CONF['site_url']); $templates->set_var('this_script', THIS_SCRIPT); $templates->set_var('home', $LANG_DATABOX['home']); if ($group_id != "") { $group_name = DB_getItem($tbl4, 'name', "group_id = " . $group_id); $templates->set_var('lang_category_list_h2', $group_name . $LANG_DATABOX['category_top']); } else { $templates->set_var('lang_category_list_h2', $LANG_DATABOX['category_top']); } //page $offset = ($page - 1) * $perpage; $sql .= " LIMIT {$offset}, {$perpage}"; $lin1 = $offset + 1; $lin2 = $lin1 + $perpage - 1; if ($lin2 > $cnt) { $lin2 = $cnt; } $templates->set_var('lang_view', $LANG_DATABOX['view']); $templates->set_var('lin', $lin1 . "-" . $lin2); $templates->set_var('cnt', $cnt); $templates->set_var('lang_name', $LANG_DATABOX_ADMIN['name']); $templates->set_var('lang_count', $LANG_DATABOX['count']); $result = DB_query($sql); $numrows = DB_numRows($result); $old_group_name = ""; if ($numrows > 0) { for ($i = 0; $i < $numrows; $i++) { $A = DB_fetchArray($result); $A = array_map('stripslashes', $A); $group_name = COM_applyFilter($A['group_name']); $name = COM_applyFilter($A['name']); $description = COM_applyFilter($A['description']); $url = $_CONF['site_url'] . "/" . THIS_SCRIPT; $url .= "?"; //コード使用の時 if ($_DATABOX_CONF['categorycode']) { $url .= "code=" . $A['code']; $url .= "&m=code"; } else { $url .= "id=" . $A['category_id']; $url .= "&m=id"; } $url = COM_buildUrl($url); $link = COM_createLink($name, $url); $templates->set_var('category_link', $link); $templates->set_var('category_name', $name); $templates->set_var('category_description', $description); $templates->set_var('category_url', $url); $templates->set_var('count', $A['count']); $templates->set_var('category_id', $A['category_id']); $templates->set_var('category_code', $A['code']); //===== if ($old_group_name != $group_name) { $url = $_CONF['site_url'] . "/" . THIS_SCRIPT; $url .= "?"; //コード使用の時 if ($_DATABOX_CONF['groupcode']) { $url .= "gcode=" . $A['group_code']; //@@@@@ $url .= "&m=gcode"; } else { $url .= "gid=" . $A['group_id']; //@@@@@ $url .= "&m=gid"; } $url = COM_buildUrl($url); $link = COM_createLink($group_name, $url); $templates->set_var('group_link', $link); $templates->set_var('group_name', $group_name); $templates->parse('grp_var', 'grp', true); $old_group_name = $group_name; } $templates->parse('col_var', 'col', true); $templates->parse('row_var', 'row', true); $templates->set_var('grp_var', ''); $templates->set_var('col_var', ''); } // Call to plugins to set template variables in the databox PLG_templateSetVars('databox', $templates); //ページなび //$url = $_CONF['site_url'] . '/'.THIS_SCRIPT."?m=".$m;//."?order=$order"; $url = $_CONF['site_url'] . '/' . THIS_SCRIPT; $templates->set_var('page_navigation', COM_printPageNavigation($url, $page, $pages)); //------------ $templates->parse('nav_var', 'nav', true); $templates->set_var('blockfooter', COM_endBlock()); $templates->set_var('msg', ""); $templates->parse('output', 'list'); $school_content = $templates->finish($templates->get_var('output')); $retval .= $school_content; } else { $templates->set_var('msg', $LANG_DATABOX["nohit"]); $templates->parse('output', 'list'); $content = $templates->finish($templates->get_var('output')); $retval .= $content; } $retval = PLG_replacetags($retval); return $retval; }
function nexcontent_formatPage($catid, $pageid, $content) { global $_CONF, $CONF_SE, $_TABLES; $result = DB_query("SELECT imagefile,imagenum,autoscale FROM {$_TABLES['nexcontent_images']} WHERE page_id = '{$pageid}' ORDER BY imagenum"); $nrows = DB_numRows($result); $errors = array(); $pageImageDir = $CONF_SE['uploadpath'] . "/{$pageid}/"; $pageImageURL = $CONF_SE['public_url'] . "/images/{$pageid}/"; $breaktag = '[break]'; // Count the number of break tags to figure out the column width to use. $offset = 0; $startpos = 0; $columns = 1; $strpos = strpos($content, $breaktag, $offset); while ($strpos !== FALSE) { $columns++; $offset = $strpos + 7; $strpos = strpos($content, $breaktag, $offset); } $width = round(100 / $columns); $newtag = '</td><td class="content" width="' . $width . '%">'; $content = str_replace($breaktag, $newtag, $content); $content = PLG_replacetags($content); /* For each image - format page location */ for ($i = 1; $i <= $nrows; $i++) { list($image, $imagenum, $scaleopt) = DB_fetchArray($result); if (file_exists($pageImageDir . $image)) { if ($scaleopt == '0') { // If don't use scaled image and there is an original image - use it. $pos = strrpos($image, '.'); $filename = strtolower(substr($image, 0, $pos)); $ext = strtolower(substr($image, $pos)); $origimage = "{$filename}_original{$ext}"; if (file_exists($pageImageDir . $origimage)) { $image = $origimage; } } $dimensions = GetImageSize($pageImageDir . $image); if (!empty($dimensions[0]) and !empty($dimensions[1])) { $sizeattributes = 'width="' . $dimensions[0] . '" height="' . $dimensions[1] . '" '; } else { $sizeattributes = ''; } //$sizeattributes = 'width="100%"'; $norm = '[image' . $imagenum . ']'; $center = '[image' . $imagenum . '_center]'; $left = '[image' . $imagenum . '_left]'; $right = '[image' . $imagenum . '_right]'; $icount = substr_count($content, $norm) + substr_count($content, $left) + substr_count($content, $right) + substr_count($content, $center); if ($icount > 0) { $imgSrc = $pageImageURL . $image; $content = str_replace($norm, '<img class="se_image" ' . $sizeattributes . ' src="' . $imgSrc . '" alt="">', $content); $content = str_replace($center, '<div style="width:100%;text-align:center;padding:5px 0px 5px 0px;"><img ' . $sizeattributes . ' src="' . $imgSrc . '" alt=""></div>', $content); $content = str_replace($left, '<img class="se_image_left" ' . $sizeattributes . ' src="' . $imgSrc . '" alt="">', $content); $content = str_replace($right, '<img class="se_image_right" ' . $sizeattributes . ' src="' . $imgSrc . '" alt="">', $content); } } } /* Strip out any custom block formatting tags */ $content = nexcontent_stripBlockTags($content); return $content; }
$product->set_var(array('name_button' => $A['name'] . ' | ' . $A['item_id'], 'name' => $A['name'])); } else { $product->set_var(array('name' => $A['name'], 'name_button' => $A['name'])); } if ($A['active'] == 0 && SEC_hasRights('paypal.admin')) { $product->set_var('active', '<strong><font color="red">' . $LANG_PAYPAL_1['active'] . '</font></strong><br/>'); } else { $product->set_var('active', ''); } $product->set_var('short_description', PLG_replacetags($A['short_description'])); if ($A['item_id'] != '' && $_PAY_CONF['display_item_id'] == 1) { $product->set_var('item_id', '<p class="product-item-id">' . $A['item_id'] . '</p>'); } else { $product->set_var('item_id', ''); } $product->set_var('description', PLG_replacetags($A['description'])); $product->set_var('price_label', $LANG_PAYPAL_1['price_label']); $product->set_var('display_price', ''); $product->set_var('price2', PAYPAL_productPrice($A)); $product->set_var('price', number_format(PAYPAL_productPrice($A), $_CONF['decimal_count'], $_CONF['decimal_separator'], $_CONF['thousand_separator'])); $product->set_var(array('price_ref' => '', 'discount' => '')); if ($A['price_ref'] != '' && $A['price_ref'] != 0) { $product->set_var('price_ref', '<span class="price_deleted">' . number_format($A['price_ref'], $_CONF['decimal_count'], $_CONF['decimal_separator'], $_CONF['thousand_separator']) . '</span>'); } if ($A['discount_a'] != '' && $A['discount_a'] != 0) { $product->set_var('discount', '<span class="price_promo">-' . number_format($A['discount_a'], $_CONF['decimal_count'], $_CONF['decimal_separator'], $_CONF['thousand_separator']) . $_PAY_CONF['currency'] . '</span>'); $product->set_var('price_ref', '<span class="price_deleted">' . number_format($A['price'], $_CONF['decimal_count'], $_CONF['decimal_separator'], $_CONF['thousand_separator']) . '</span>'); } else { if ($A['discount_p'] != '' && $A['discount_p'] != 0) { $product->set_var('discount', '<span class="price_promo">-' . number_format($A['discount_p'], $_CONF['decimal_count'], $_CONF['decimal_separator'], $_CONF['thousand_separator']) . '%' . ' </span>'); $product->set_var('price_ref', '<span class="price_deleted">' . number_format($A['price'], $_CONF['decimal_count'], $_CONF['decimal_separator'], $_CONF['thousand_separator']) . '</span>');
function fnclist($id, $template) { global $_CONF; global $_TABLES; global $_USER_CONF; global $perpage; global $LANG_USERBOX; global $LANG_USERBOX_ADMIN; global $LANG_USERBOX_NOYES; //----- $page = COM_applyFilter($_REQUEST['page'], true); if (!isset($page) or $page == 0) { $page = 1; } $pi_name = "userbox"; $field_def = DATABOX_getadditiondef($pi_name); //----- $tbl1 = $_TABLES['USERBOX_addition']; $tbl2 = $_TABLES['USERBOX_base']; $tbl3 = $_TABLES['USERBOX_def_field']; $tbl5 = $_TABLES['users']; //----- $sql = "SELECT " . LB; $sql .= " t1.field_id " . LB; $sql .= " ,t1.value " . LB; $sql .= " ,t3.name " . LB; $sql .= " ,t3.templatesetvar" . LB; $sql .= " ,t3.description " . LB; $sql .= " ,Count(t1.id) AS count" . LB; $sql .= " FROM " . LB; $sql .= " {$tbl1} AS t1 " . LB; $sql .= " ,{$tbl2} AS t2 " . LB; $sql .= " ,{$tbl3} AS t3 " . LB; $sql .= " ,{$tbl5} AS t5 " . LB; $sql .= " WHERE " . LB; $sql .= " t1.value <>''" . LB; $sql .= " AND t1.id = t2.id " . LB; $sql .= " AND t1.id = t5.uid " . LB; $sql .= " AND t1.field_id = t3.field_id " . LB; //TYPE[0] = '一行テキストフィールド'; //TYPE[2] = 'いいえ/はい'; //TYPE[3] = '日付 (date picker対応)'; //TYPE[7] = 'オプションリスト'; //TYPE[8] = 'ラジオボタンリスト'; //TYPE[9] = 'オプションリスト(マスタ) (既定リスト)'; $sql .= " AND t3.type IN (0,2,3,4,7,8,9,16) " . LB; //ALLOW_DISPLAY[0] ='表示する(orderに指定可能)'; //ALLOW_DISPLAY[1] ='ログインユーザのみ表示する'; if (COM_isAnonUser()) { $sql .= " AND t3.allow_display=0 " . LB; } else { $sql .= " AND t3.allow_display IN (0,1) " . LB; } if ($id != 0) { $sql .= " AND t1.field_id = " . $id . LB; } //管理者の時,下書データも含む //if ( SEC_hasRights('userbox.admin')) { //}else{ $sql .= " AND t2.draft_flag=0" . LB; //} //アクセス権のないデータ はのぞく $sql .= COM_getPermSql('AND', 0, 2, "t2") . LB; //公開日以前のデータはのぞく $sql .= " AND (released <= NOW())" . LB; //公開終了日を過ぎたデータはのぞく $sql .= " AND (expired=0 OR expired > NOW())" . LB; $sql .= " GROUP BY " . LB; $sql .= " t1.field_id , t1.value" . LB; $sql .= " ORDER BY " . LB; $sql .= " t1.field_id,t1.value" . LB; $result = DB_query($sql); $cnt = DB_numRows($result); $pages = 0; if ($perpage > 0) { $pages = ceil($cnt / $perpage); } //ヘッダ、左ブロック //@@@@@@ 修正要 if ($id == 0) { $w = $LANG_USERBOX['attribute_top']; $attribute_top = $w; $field_top = ""; $col = "col.thtml"; } else { $url = $_CONF['site_url'] . "/userbox/attribute.php"; $attribute_top = ":<a href='" . $url . "'>" . $LANG_USERBOX['attribute_top'] . "</a>"; $w = $field_def[$id]['name'] . $LANG_USERBOX['countlist']; $field_top = $w; $col = "col2.thtml"; } if ($page > 1) { $page_title = sprintf('%s (%d)', $w, $page); } else { $page_title = sprintf('%s ', $w); } $headercode .= DATABOX_getheadercode("attribute", $template, $pi_name, 0, $_CONF['site_name'], $_CONF['meta_description'], $_CONF['meta_keywords'], $_CONF['meta_description']); $retval .= DATABOX_siteHeader($pi_name, '', $page_title, $headercode); // $tmplfld = DATABOX_templatePath('attribute', $template, $pi_name); $templates = new Template($tmplfld); $templates->set_file(array('list' => 'list.thtml', 'nav' => 'navigation.thtml', 'row' => 'row.thtml', 'col' => $col, 'pagenav' => 'pagenavigation.thtml')); $languageid = COM_getLanguageId(); $language = COM_getLanguage(); $templates->set_var('languageid', $languageid); $templates->set_var('language', $language); if ($languageid != "") { $templates->set_var('_languageid', "_" . $languageid); } else { $templates->set_var('_languageid', ""); } // $templates->set_var('site_url', $_CONF['site_url']); $templates->set_var('this_script', THIS_SCRIPT); $templates->set_var('home', $LANG_USERBOX['home']); $templates->set_var('attribute_top', $attribute_top); $templates->set_var('field_top', $field_top); //page $offset = ($page - 1) * $perpage; $lin1 = $offset + 1; $lin2 = $lin1 + $perpage - 1; if ($lin2 > $cnt) { $lin2 = $cnt; } $templates->set_var('lang_view', $LANG_USERBOX['view']); $templates->set_var('lin', $lin1 . "-" . $lin2); $templates->set_var('cnt', $cnt); // $templates->set_var('lang_name', $LANG_USERBOX_ADMIN['name']); $templates->set_var('lang_count', $LANG_USERBOX['count']); $sql .= " LIMIT {$offset}, {$perpage}"; $result = DB_query($sql); $numrows = DB_numRows($result); if ($numrows > 0) { for ($i = 0; $i < $numrows; $i++) { $A = DB_fetchArray($result); $name = COM_applyFilter($A['name']); $description = COM_applyFilter($A['description']); $fid = $A["field_id"]; $value = $A["value"]; $fieldvalue = DATABOX_getfieldvalue($value, $field_def[$fid]['type'], $field_def[$fid]['selectionary'], $LANG_USERBOX_NOYES, $field_def[$fid]['selectlist'], $pi_name); $url = $_CONF['site_url'] . "/" . THIS_SCRIPT; $url .= "?"; $url .= "id=" . $A['field_id']; $url .= "&m=id"; $url2 = $url . "&value=" . $A['value']; $url = COM_buildUrl($url); $link = COM_createLink($name, $url); $url2 = COM_buildUrl($url2); $link2 = COM_createLink($fieldvalue, $url2); $templates->set_var('field_link', $link); $templates->set_var('value_link', $link2); $templates->set_var('field_description', $description); $templates->set_var('field_name', $name); $templates->set_var('field_url', $url); $templates->set_var('value_url', $url2); $templates->set_var('value', $fieldvalue); $templates->set_var('count', $A['count']); //===== $templates->parse('col_var', 'col', true); $templates->parse('row_var', 'row', true); $templates->set_var('col_var', ''); } // Call to plugins to set template variables in the databox PLG_templateSetVars('userbox', $templates); //ページなび //$url = $_CONF['site_url'] . '/'.THIS_SCRIPT."?m=".$m;//."?order=$order"; $url = $_CONF['site_url'] . '/' . THIS_SCRIPT; $templates->set_var('page_navigation', COM_printPageNavigation($url, $page, $pages)); //------------ $templates->parse('nav_var', 'nav', true); $templates->set_var('blockfooter', COM_endBlock()); $templates->set_var('msg', ""); $templates->parse('output', 'list'); $school_content = $templates->finish($templates->get_var('output')); $retval .= $school_content; } else { $templates->set_var('msg', $LANG_USERBOX["nohit"]); $templates->parse('output', 'list'); $content = $templates->finish($templates->get_var('output')); $retval .= $content; } $retval = PLG_replacetags($retval); return $retval; }