www.gusucode.com > Catfish(鲶鱼) CMS系统 PHP版 v4.8.21源码程序 > Catfishcms_v4.8.21/application/common/Package.php
<?php /** * Project: Catfish CMS. * Author: A.J <804644245@qq.com> * Copyright: http://www.catfish-cms.com All rights reserved. * Date: 2017/8/9 */ namespace app\common; use think\Cache; use think\Controller; use think\Db; use think\Lang; class Package extends Controller { protected $lang; protected $ccc; protected $plugins = []; protected $params = []; protected function getPlugins() { $plugins = Cache::get('plugins'); if($plugins == false) { $plugins = Db::name('options')->where('option_name','plugins')->field('option_value')->find(); if(!empty($plugins)) { $plugins = unserialize($plugins['option_value']); } else { $plugins = []; } Cache::set('plugins',$plugins,3600); } if(!empty($plugins)) { foreach($plugins as $key => $val) { $pluginFile = APP_PATH.'plugins/'.$val.'/'.ucfirst($val).'.php'; if(is_file($pluginFile)) { $plugins[$key] = 'app\\plugins\\'.$val.'\\'.ucfirst($val); //加载插件语言包 Lang::load(APP_PATH . 'plugins/'.$val.'/lang/'.$this->lang.'.php'); } else { unset($plugins[$key]); } } $this->plugins = $plugins; } } protected function filterLanguages($parameter) { $param = strtolower($parameter); if($param == 'zh' || strpos($param,'zh-hans') !== false || strpos($param,'zh-chs') !== false) { Lang::range('zh-cn'); return 'zh-cn'; } else if($param == 'zh-tw' || strpos($param,'zh-hant') !== false || strpos($param,'zh-cht') !== false){ Lang::range('zh-tw'); return 'zh-tw'; } else if(stripos($param,'zh') === false) { $paramsub = substr($param,0,2); switch($paramsub) { case 'de': Lang::range('de-de'); return 'de-de'; break; case 'fr': Lang::range('fr-fr'); return 'fr-fr'; break; case 'ja': Lang::range('ja-jp'); return 'ja-jp'; break; case 'ko': Lang::range('ko-kr'); return 'ko-kr'; break; case 'ru': Lang::range('ru-ru'); return 'ru-ru'; break; default: return $param; } } else { return $param; } } }