function generate_currency_cache($load = false) { global $mysql, $config; $eshop_dir = get_plugcfg_dir('eshop'); if (!file_exists($eshop_dir . '/cache_currency.php') or $load) { $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; } file_put_contents($eshop_dir . '/cache_currency.php', serialize($currency_tEntry)); } }
function generate_features_cache($load = false) { global $mysql, $config; $eshop_dir = get_plugcfg_dir('eshop'); if (!file_exists($eshop_dir . '/cache_features.php') or $load) { /* $ftext_values = array(); foreach ($mysql->select("SELECT DISTINCT o.feature_id, o.value FROM ".prefix."_eshop_options o LEFT JOIN ng_eshop_features f ON o.feature_id = f.id WHERE f.ftype = 0 ORDER BY feature_id") as $row) { $ftext_values[$row['feature_id']][] = $row['value']; } */ $features_tEntry = array(); foreach ($mysql->select("SELECT * FROM " . prefix . "_eshop_features ORDER BY position, id") as $row) { $foptions = array(); $foptions = json_decode($row['foptions'], true); $foptions = array_map(function ($array) { return iconv('UTF-8', 'Windows-1251', $array); }, $foptions); $row['foptions'] = $foptions; $features_tEntry[] = $row; } file_put_contents($eshop_dir . '/cache_features.php', serialize($features_tEntry)); } }
function plugin_m_eshop_catz_tree($overrideTemplateName) { global $config, $twig; $eshop_dir = get_plugcfg_dir('eshop'); generate_catz_cache(); if (file_exists($eshop_dir . '/cache_catz.php')) { $tVars = unserialize(file_get_contents($eshop_dir . '/cache_catz.php')); if ($overrideTemplateName) { $templateName = 'block/' . $overrideTemplateName; } else { $templateName = 'block/block_cats_tree'; } $tpath = locatePluginTemplates(array($templateName), 'eshop', pluginGetVariable('eshop', 'localsource')); $xt = $twig->loadTemplate($tpath[$templateName] . $templateName . '.tpl'); $output = $xt->render($tVars); } else { $output = ''; } return $output; }
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; }