function eshop_infovars_show() { global $CurrentHandler, $SYSTEM_FLAGS, $template, $lang, $mysql, $twig, $userROW, $ngCookieDomain; $SYSTEM_FLAGS["eshop"]["description_delivery"] = pluginGetVariable('eshop', 'description_delivery'); $SYSTEM_FLAGS["eshop"]["description_order"] = pluginGetVariable('eshop', 'description_order'); $SYSTEM_FLAGS["eshop"]["description_phones"] = pluginGetVariable('eshop', 'description_phones'); $eshop_dir = get_plugcfg_dir('eshop'); generate_currency_cache(); if (file_exists($eshop_dir . '/cache_currency.php')) { $currency_tEntry = unserialize(file_get_contents($eshop_dir . '/cache_currency.php')); } else { $currency_tEntry = array(); } /* $currency_link = checkLinkAvailable('eshop', 'currency')? generateLink('eshop', 'currency', array()): generateLink('core', 'plugin', array('plugin' => 'eshop', 'handler' => 'currency'), array()); $currency_tEntry = array(); foreach ($mysql->select("SELECT * FROM ".prefix."_eshop_currencies WHERE enabled = 1 ORDER BY position, id") as $row) { $row['currency_link'] = $currency_link."?id=".$row['id']; $currency_tEntry[] = $row; } */ $SYSTEM_FLAGS["eshop"]["currency"] = $currency_tEntry; $current_currency = array(); if (!isset($_COOKIE['ngCurrencyID'])) { $ngCurrencyID = $currency_tEntry[0]['id']; $current_currency = $currency_tEntry[0]; @setcookie('ngCurrencyID', $ngCurrencyID, time() + 86400 * 365, '/', $ngCookieDomain, 0, 1); } else { $ngCurrencyID = $_COOKIE['ngCurrencyID']; foreach ($currency_tEntry as $cc) { if ($cc['id'] == $ngCurrencyID) { $current_currency = $cc; } } if (empty($current_currency)) { $current_currency = $currency_tEntry[0]; } } $SYSTEM_FLAGS["eshop"]["current_currency"] = $current_currency; generate_catz_cache(); if (file_exists($eshop_dir . '/cache_catz.php')) { $catz_tEntry = unserialize(file_get_contents($eshop_dir . '/cache_catz.php')); } else { $catz_tEntry = array(); } $SYSTEM_FLAGS["eshop"]["catz"] = $catz_tEntry; generate_features_cache(); if (file_exists($eshop_dir . '/cache_features.php')) { $features_tEntry = unserialize(file_get_contents($eshop_dir . '/cache_features.php')); } else { $features_tEntry = array(); } $SYSTEM_FLAGS["eshop"]["features"] = $features_tEntry; generate_categories_features_cache(); if (file_exists($eshop_dir . '/cache_categories_features.php')) { $categories_features_tEntry = unserialize(file_get_contents($eshop_dir . '/cache_categories_features.php')); } else { $categories_features_tEntry = array(); } $SYSTEM_FLAGS["eshop"]["categories_features"] = $categories_features_tEntry; $twig->addFunction('IsCatFeatures', new Twig_Function_Function('IsCatFeatures')); $filter = array(); if (is_array($userROW)) { $filter[] = '(user_id = ' . db_squote($userROW['id']) . ')'; } if (isset($_COOKIE['ngTrackID']) && $_COOKIE['ngTrackID'] != '') { $filter[] = '(cookie = ' . db_squote($_COOKIE['ngTrackID']) . ')'; } $compare_link = checkLinkAvailable('eshop', 'compare') ? generateLink('eshop', 'compare', array()) : generateLink('core', 'plugin', array('plugin' => 'eshop', 'handler' => 'compare'), array()); $basket_link = checkLinkAvailable('eshop', 'ebasket_list') ? generateLink('eshop', 'ebasket_list', array()) : generateLink('core', 'plugin', array('plugin' => 'eshop', 'handler' => 'ebasket_list'), array()); if (count($filter) > 0) { $tCount = 0; $tEntries = array(); foreach ($mysql->select("SELECT * FROM " . prefix . "_eshop_compare WHERE " . join(" or ", $filter) . "") as $row) { $tEntries[] = $row; $tCount += 1; } $compare_tVars = array('count' => $tCount, 'link' => $compare_link, 'entries' => $tEntries); $tCount = 0; $tPrice = 0; $tEntries = array(); foreach ($mysql->select("SELECT * FROM " . prefix . "_eshop_ebasket WHERE " . join(" or ", $filter) . "") as $row) { $tEntries[] = $row; $tCount += 1; $tPrice += $row['price'] * $row['count']; } $basket_tVars = array('count' => $tCount, 'price' => $tPrice, 'entries' => $tEntries, 'basket_link' => $basket_link); } else { $compare_tVars = array('count' => 0, 'link' => $compare_link, 'entries' => array()); $basket_tVars = array('count' => 0, 'price' => 0, 'entries' => array(), 'basket_link' => $basket_link); } $SYSTEM_FLAGS["eshop"]["compare"] = $compare_tVars; $SYSTEM_FLAGS["eshop"]["basket"] = $basket_tVars; }
function edit_feature($params) { global $tpl, $template, $config, $mysql, $lang, $twig; $tpath = locatePluginTemplates(array('config/main', 'config/add_feature'), 'eshop', 1); $id = intval($_REQUEST['id']); $row = $mysql->record('SELECT * FROM ' . prefix . '_eshop_features WHERE id = ' . db_squote($id) . ' LIMIT 1'); if (isset($_REQUEST['submit'])) { $SQL['name'] = input_filter_com(convert($_REQUEST['name'])); if (empty($SQL['name'])) { $error_text[] = 'Название свойства не задано'; } $SQL['position'] = intval($_REQUEST['position']); if (empty($SQL['position'])) { $SQL['position'] = 0; } $SQL['in_filter'] = intval($_REQUEST['in_filter']); if (empty($SQL['in_filter'])) { $SQL['in_filter'] = 0; } $ftype = input_filter_com(convert($_REQUEST['ftype'])); switch ($ftype) { case 'text': $SQL['ftype'] = '0'; $SQL['fdefault'] = input_filter_com(convert($_REQUEST['text_default'])); break; case 'checkbox': $SQL['ftype'] = '1'; $SQL['fdefault'] = intval($_REQUEST['checkbox_default']); break; case 'select': $SQL['ftype'] = '2'; $SQL['fdefault'] = input_filter_com(convert($_REQUEST['select_default'])); $optlist = array(); if (isset($_REQUEST['so_data']) && is_array($_REQUEST['so_data'])) { foreach ($_REQUEST['so_data'] as $k => $v) { if (is_array($v) && isset($v[0]) && isset($v[1]) && ($v[0] != '' || $v[1] != '')) { if ($v[0] != '') { $optlist[$v[0]] = iconv("windows-1251", "utf-8", $v[1]); } else { $optlist[] = iconv("windows-1251", "utf-8", $v[1]); } } } } $SQL['foptions'] = json_encode($optlist); break; case 'html': $SQL['ftype'] = '3'; $SQL['fdefault'] = $_REQUEST['html_default']; break; } if (empty($error_text)) { $vnames = array(); foreach ($SQL as $k => $v) { $vnames[] = $k . ' = ' . db_squote($v); } $mysql->query('UPDATE ' . prefix . '_eshop_features SET ' . implode(', ', $vnames) . ' WHERE id = \'' . intval($id) . '\' '); $mysql->query("delete from " . prefix . "_eshop_categories_features where feature_id in ({$id})"); $ids = $_REQUEST['feature_categories']; foreach ($ids as $id_x) { $mysql->query('INSERT INTO ' . prefix . '_eshop_categories_features (category_id, feature_id) VALUES (' . db_squote($id_x) . ', ' . db_squote($id) . ' ) '); } generate_features_cache(true); generate_categories_features_cache(true); redirect_eshop('?mod=extra-config&plugin=eshop&action=list_feature'); } } if (!empty($error_text)) { foreach ($error_text as $error) { $error_input .= msg(array("type" => "error", "text" => $error)); } } else { $error_input = ''; } $res = mysql_query("SELECT * FROM " . prefix . "_eshop_categories ORDER BY id"); $cats = getCats($res); $cat_ids = array(); foreach ($mysql->select("SELECT * FROM " . prefix . "_eshop_categories_features WHERE feature_id = " . db_squote($id) . "") as $frow) { $cat_ids[] = $frow['category_id']; } foreach ($row as $k => $v) { $tEntry[$k] = $v; } $tEntry['error'] = $error_input; $tEntry['catz'] = getMultiTree($cats, $cat_ids, 0); $tEntry['foptions'] = json_decode($tEntry['foptions'], true); $sOpts = array(); $fNum = 1; if ($tEntry['ftype'] == '2') { if (is_array($tEntry['foptions'])) { foreach ($tEntry['foptions'] as $k => $v) { array_push($sOpts, '<tr><td><input size="12" name="so_data[' . $fNum . '][0]" type="text" value="' . ($tEntry['foptions'] ? htmlspecialchars($k, ENT_COMPAT | ENT_HTML401, 'cp1251') : '') . '"/></td><td><input type="text" size="55" name="so_data[' . $fNum . '][1]" value="' . iconv("utf-8", "windows-1251", $v) . '"/></td><td><a href="#" onclick="return false;"><img src="' . skins_url . '/images/delete.gif" alt="DEL" width="12" height="12" /></a></td></tr>'); $fNum++; } } } if (!count($sOpts)) { array_push($sOpts, '<tr><td><input size="12" name="so_data[1][0]" type="text" value=""/></td><td><input type="text" size="55" name="so_data[1][1]" value=""/></td><td><a href="#" onclick="return false;"><img src="' . skins_url . '/images/delete.gif" alt="DEL" width="12" height="12" /></a></td></tr>'); } $tEntry['sOpts'] = implode("\n", $sOpts); $xt = $twig->loadTemplate($tpath['config/add_feature'] . 'config/' . 'add_feature.tpl'); $tVars = array('entries' => isset($tEntry) ? $tEntry : '', 'mode' => "edit"); $xg = $twig->loadTemplate($tpath['config/main'] . 'config/' . 'main.tpl'); $tVars = array('entries' => $xt->render($tVars), 'php_self' => $PHP_SELF, 'plugin_url' => admin_url . '/admin.php?mod=extra-config&plugin=eshop', 'skins_url' => skins_url, 'admin_url' => admin_url, 'home' => home, 'current_title' => 'Свойства: Редактирование свойства'); print $xg->render($tVars); }