您现在的位置是:首页 > cms教程 > Ecshop商城教程Ecshop商城教程

ecshop全局变量的设置和加载方式

听蓉2025-02-06Ecshop商城教程已有人查阅

导读$_CFG数组主要是放置一些系统参数,并且全站共享的数据,在使用的时候,ecshop里面常常以$GLOBALS['_CFG']全局变量的模式来处理。

$_CFG数组主要是放置一些系统参数,并且全站共享的数据,在使用的时候,ecshop里面常常以$GLOBALS['_CFG']全局变量的模式来处理。
ecshop 的$GLOBALS['_CFG'],主要是在includes/init.php中出现并且初始化,$_CFG = load_config();load_config()函数负责将参数取出来。includes\lib_common.php 文件中包含了这个ecshop函数。
function load_config()
{
$arr = array();
$data = read_static_cache('shop_config');
if ($data === false)
{
$sql = 'SELECT code, value FROM ' . $GLOBALS['ecs']->table('shop_config') . ' WHERE parent_id > 0';
$res = $GLOBALS['db']->getAll($sql);
foreach ($res AS $row)
{
$arr[$row['code']] = $row['value'];
}
/* 对数值型设置处理 */
$arr['watermark_alpha'] = intval($arr['watermark_alpha']);
$arr['market_price_rate'] = floatval($arr['market_price_rate']);
$arr['integral_scale'] = floatval($arr['integral_scale']);
//$arr['integral_percent'] = floatval($arr['integral_percent']);
$arr['cache_time'] = intval($arr['cache_time']);
$arr['thumb_width'] = intval($arr['thumb_width']);
$arr['thumb_height'] = intval($arr['thumb_height']);
$arr['image_width'] = intval($arr['image_width']);
$arr['image_height'] = intval($arr['image_height']);
$arr['best_number'] = !empty($arr['best_number']) && intval($arr['best_number']) > 0 ? intval($arr['best_number']) : 3;
$arr['new_number'] = !empty($arr['new_number']) && intval($arr['new_number']) > 0 ? intval($arr['new_number']) : 3;
$arr['hot_number'] = !empty($arr['hot_number']) && intval($arr['hot_number']) > 0 ? intval($arr['hot_number']) : 3;
$arr['promote_number'] = !empty($arr['promote_number']) && intval($arr['promote_number']) > 0 ? intval($arr['promote_number']) : 3;
$arr['top_number'] = intval($arr['top_number']) > 0 ? intval($arr['top_number']) : 10;
$arr['history_number'] = intval($arr['history_number']) > 0 ? intval($arr['history_number']) : 5;
$arr['comments_number'] = intval($arr['comments_number']) > 0 ? intval($arr['comments_number']) : 5;
$arr['article_number'] = intval($arr['article_number']) > 0 ? intval($arr['article_number']) : 5;
$arr['page_size'] = intval($arr['page_size']) > 0 ? intval($arr['page_size']) : 10;
$arr['bought_goods'] = intval($arr['bought_goods']);
$arr['goods_name_length'] = intval($arr['goods_name_length']);
$arr['top10_time'] = intval($arr['top10_time']);
$arr['goods_gallery_number'] = intval($arr['goods_gallery_number']) ? intval($arr['goods_gallery_number']) : 5;
$arr['no_picture'] = !empty($arr['no_picture']) ? str_replace('../', './', $arr['no_picture']) : 'images/no_picture.gif'; // 修改默认商品图片的路径
$arr['qq'] = !empty($arr['qq']) ? $arr['qq'] : '';
$arr['ww'] = !empty($arr['ww']) ? $arr['ww'] : '';
$arr['default_storage'] = isset($arr['default_storage']) ? intval($arr['default_storage']) : 1;
$arr['min_goods_amount'] = isset($arr['min_goods_amount']) ? floatval($arr['min_goods_amount']) : 0;
$arr['one_step_buy'] = empty($arr['one_step_buy']) ? 0 : 1;
$arr['invoice_type'] = empty($arr['invoice_type']) ? array('type' => array(), 'rate' => array()) : unserialize($arr['invoice_type']);
$arr['show_order_type'] = isset($arr['show_order_type']) ? $arr['show_order_type'] : 0; // 显示方式默认为列表方式
$arr['help_open'] = isset($arr['help_open']) ? $arr['help_open'] : 1; // 显示方式默认为列表方式
if (!isset($GLOBALS['_CFG']['ecs_version']))
{
/* 如果没有版本号则默认为2.0.5 */
$GLOBALS['_CFG']['ecs_version'] = 'v2.0.5';
}
//限定语言项
$lang_array = array('zh_cn', 'zh_tw', 'en_us');
if (empty($arr['lang']) || !in_array($arr['lang'], $lang_array))
{
$arr['lang'] = 'zh_cn'; // 默认语言为简体中文
}
if (empty($arr['integrate_code']))
{
$arr['integrate_code'] = 'ecshop'; // 默认的会员整合插件为 ecshop
}
write_static_cache('shop_config', $arr);
}
else
{
$arr = $data;
}
return $arr;
}

本文标签:

很赞哦! ()

相关教程

相关源码

  • (自适应)行业协会工会机构单位pbootcms网站源码本模板基于PbootCMS内核开发,为行业协会、工会组织及机构单位量身打造。采用响应式布局设计,可自动适配手机、平板等移动设备,数据实时同步更新。模板包含行业资讯查看源码
  • (自适应)蓝色自动溶剂萃取仪器设备类网站pbootcms模板下载本模板为溶剂萃取设备、实验室仪器等精密仪器行业设计,采用PbootCMS内核开发,具有高度专业性和行业适配性。模板设计充分考虑了仪器设备行业展示需求,能够呈现各类精密仪器的技术参数、应用场景和解决方案。查看源码
  • (自适应)文案文档作文写作word资源网站模板下载本模板基于PbootCMS系统深度开发,针对电影解说、文案分享类网站的特殊需求设计。采用响应式布局技术,确保在手机端和桌面端都能呈现专业的内容展示效果,帮助运营者高效管理影视解说资源。查看源码
  • (自适应)简繁双语响应式服装服饰西装工装校服定制pbootcms模板本模板基于PbootCMS内核开发,为服装服饰行业量身打造,尤其适合西装定制、工装生产、校服订制等服装类企业使用。模板采用响应式布局设计,确保在手机、平板、电脑查看源码
  • 自适应黑色建筑装饰设计公司个人工作室pbootcms模板基于PbootCMS内核开发的黑金风格模板,为建筑装饰、工程设计类企业打造,采用‌开源架构‌,支持跨行业快速适配,核心优势如下: 查看源码
  • (自适应)代理记账财务会计咨询服务个人公司网站模板该响应式网站模板为代理记账、财政咨询及财务会计类企业设计,基于PbootCMS内核开发。通过自适应手机端的HTML5技术,帮助企业高效构建专业财税服务平台查看源码
分享笔记 (共有 篇笔记)
验证码:

本栏推荐