### Plugin Installation Configuration Source: https://doc.funadmin.com/7 Configure hooks, routes, and menus for plugin installation. Ensure the `Plugin.php` file is correctly set up. ```php return array ( 'autoload' => true, 'hooks' => array ( 'bbs' => array ( 0 => 'bbshook',//这里是hooks钩子 ), ), 'route' => array ( 0 => array ( 'addons' => 'bbs', 'domain' => 'demobbs', 'rule' => array ( 'bbs' => 'bbs/frontend/index/index', 'bbs/i/[:id]/[:type]/[:page]' => 'bbs/frontend/bbs/index', 'bbs/d/[:id]' => 'bbs/frontend/bbs/detail', ), ), 'service' =>array (), ); ``` ```php $addonService = app\backend\service\AddonService::instance(); $name = '插件名'; $class = get_addons_instance($name); // 安装菜单 $menu_config=get_addons_menu($name); if(!empty($menu_config)){ if(isset($menu_config['is_nav']) && $menu_config['is_nav']==1){ $pid = 0; }else{ $pid = $addonService->addAddonManager()->id; } $menu[] = $menu_config['menu']; $addonService->addAddonMenu($menu,$pid); } ``` -------------------------------- ### Composer Install Dependencies Source: https://doc.funadmin.com/3/javascipt:;/javascipt:; After creating the project, run this command to install all necessary dependencies. ```bash cd funadmin && composer install ``` -------------------------------- ### General Table Column Configuration Examples Source: https://doc.funadmin.com/8 Provides examples of common table column configurations including ID, status switch, creation time, and operations. ```javascript 1. { field: 'id', title: __('ID'), }, 2. { 3. field: 'status', 4. search: 'select', 5. title: __('Status'), 6. filter: 'status', 7. tips: __('enabled') + '|' + __('disabled'), 8. selectList: {0: __('Disabled'), 1: __('Enabled')}, 9. sort: true, 10. templet: Table.templet.switch, 11. width: 100 12. }, 13. {field:'create_time', title: __('CreateTime'),align: 'center',sort:'sort',width: 170,search: 'timerage',}, 14. { 15. fixed:right, 16. width: 180, 17. align: "center", 18. title: __("Operat"), 19. init: Table.init, 20. templet: Table.templet.operat, 21. operat: ["edit","destroy","delete"] 22. }, 23. ``` -------------------------------- ### Install Database via ThinkPHP CLI Source: https://doc.funadmin.com/3 After creating a project with Composer, navigate to the project directory and run this command to install the database. ```bash php think install ``` -------------------------------- ### Configuring Composer Repository for Installation Source: https://doc.funadmin.com/index/index.html?id=7 These commands help resolve composer installation issues by setting the default package repository. It's recommended to use a reliable mirror like the one provided by Alibaba Cloud. ```bash composer config -l -g 2. 3. composer config -g repo.packagist composer https://packagist.org 4. 5. composer install 6. 7. composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ 8. 9. composer selfupdate ``` -------------------------------- ### Backend Controller Example Source: https://doc.funadmin.com/11/javascipt:; Example of a backend controller for member management, inheriting from the Backend base class. It demonstrates setting up model class and relation search. ```php modelClass = new MemberModel(); } /** * 默认的控制器所继承的父类中有index/add/edit/delete/destroy 等方法 * 因此在当前控制器中可不用编写增删改查的代码,如果需要自己在这里增加或者修改这里的逻辑 */ } ``` -------------------------------- ### Get List of Plugins Source: https://doc.funadmin.com/index/index.html?id=40 Call `get_addons_list` to retrieve a list of all installed plugins. ```php 1. $addonList = get_addons_list(); ``` -------------------------------- ### Backend Member Controller Example Source: https://doc.funadmin.com/11 Example of a backend controller for member management, inheriting from the Backend base class. It demonstrates setting up model class and relation search. ```php modelClass = new MemberModel(); } /** * 默认的控制器所继承的父类中有index/add/edit/delete/destroy 等方法 * 因此在当前控制器中可不用编写增删改查的代码,如果需要自己在这里增加或者修改这里的逻辑 */ } ``` -------------------------------- ### Plugin Configuration Hooks and Routes Source: https://doc.funadmin.com/index/index.html?id=7 Example of configuring plugin hooks and routes in `config/addons.php`. This is used for managing plugin functionalities and access. ```php return array ( 'autoload' => true, 'hooks' => array ( 'bbs' => array ( 0 => 'bbshook',//这里是hooks钩子 ), ), 'route' => array ( 0 => array ( 'addons' => 'bbs', 'domain' => 'demobbs', 'rule' => array ( 'bbs' => 'bbs/frontend/index/index', 'bbs/i/[:id]/[:type]/[:page]' => 'bbs/frontend/bbs/index', 'bbs/d/[:id]' => 'bbs/frontend/bbs/detail', ), ), 'service' =>array (), ); ``` -------------------------------- ### MySQL Database Configuration Source: https://doc.funadmin.com/5 Example configuration for a MySQL database connection. Ensure all connection details are correctly set for your environment. ```php 1. return [ 2. 'default' => 'mysql', 3. 'connections' => [ 4. 'mysql' => [ 5. // 数据库类型 6. 'type' => 'mysql', 7. // 服务器地址 8. 'hostname' => '127.0.0.1', 9. // 数据库名 10. 'database' => 'thinkphp', 11. // 数据库用户名 12. 'username' => 'root', 13. // 数据库密码 14. 'password' => '', 15. // 数据库连接端口 16. 'hostport' => '', 17. // 数据库连接参数 18. 'params' => [], 19. // 数据库编码默认采用utf8mb4 20. 'charset' => 'utf8mb4', 21. // 数据库表前缀 22. 'prefix' => 'fun_', 23. ], 24. ], 25. ]; ``` -------------------------------- ### xmSelect Grouped Data Example Source: https://doc.funadmin.com/12 Demonstrates how to structure data for grouped options in xmSelect, including custom click handlers for group actions. ```javascript {name: '销售员', children: [ {name: '李四', value: 4, selected: true}, {name: '王五', value: 5}, ]}, 6. //可在分组上定义click属性, 来定义点击事件 7. {name: '选中', children: [...], click: 'SELECT'}, 8. {name: '清空', children: [...], click: 'CLEAR'}, 9. {name: '自动', children: [...], click: 'AUTO'}, 10. {name: '自定义', children: [...], click: function(item){ 11. alert('自定义的, 想干嘛干嘛'); 12. }} ``` -------------------------------- ### Composer Project Creation Source: https://doc.funadmin.com/3 Use Composer to create a new FunAdmin project and install dependencies. Ensure the website entry point is deployed to the 'public' directory. ```bash composer create-project --prefer-dist funadmin/funadmin funadmin cd funadmin && composer install ``` -------------------------------- ### Get Plugin Information Source: https://doc.funadmin.com/index/index.html?id=40 Use `get_addons_info` with the plugin name as a parameter to fetch its information, typically parsed from the Plugin.ini file. ```php 1. $addoninfo= get_addons_info ('demo'); //参数插件名 ``` -------------------------------- ### Composer Command for Project Creation Source: https://doc.funadmin.com/3/javascipt:;/javascipt:; Use this command to create a new FunAdmin project via Composer. Ensure you have Composer installed and configured. ```bash composer create-project --prefer-dist funadmin/funadmin funadmin ``` -------------------------------- ### Global xmSelect Method Usage Source: https://doc.funadmin.com/12 Demonstrates the usage of global xmSelect methods for rendering, getting, and batch operations on initialized xmSelect instances. ```javascript //render 使用方式 xmSelect.render(OPTIONS); //get 使用方式 xmSelect.get('#demo1'); //指定某一个获取 xmSelect.get(/.*demo1.*/); //正则获取 //自定义方法获取 xmSelect.get(function(el){ return el == '#demo1' || el == '#demo2'; }); //单实例 xmSelect.get('#demo2', true); //batch 使用方式 //批量执行禁用 xmSelect.batch(/.*demo/, 'update', { disabled: true, }); //批量执行warning xmSelect.batch(/.*demo/, 'warning', '#F00', true); ``` -------------------------------- ### get_addons_list Source: https://doc.funadmin.com/index/index.html?id=40 Retrieves a list of all installed plugins in the FunAdmin system. ```APIDOC ## get_addons_list ### Description Retrieves a list of all installed plugins in the FunAdmin system. ### Method Not applicable (function call) ### Endpoint Not applicable (function call) ### Parameters None ### Usage Examples ```php $addonList = get_addons_list(); ``` ``` -------------------------------- ### SQL Injection Example - Malicious Command Execution Source: https://doc.funadmin.com/index/index.html?id=19 Illustrates how SQL injection can be used to execute unintended commands by exploiting comment syntax and adding conditions. This example aims to exhaust system resources. ```sql SELECT COUNT(*) AS 'num' FROM game_score WHERE game_id=24411 AND version='-1' OR 3 AND SLEEP(500) ``` -------------------------------- ### Configuring Dropdown Event for Table Initialization Source: https://doc.funadmin.com/index/index.html?id=8 Example of initializing table requests with a 'dropdown' event configuration. This includes settings for the dropdown's type, event name, class, URL, icon, text, title, dimensions, and an 'extend' array for nested dropdown items with custom events and callbacks. ```javascript Table.init = { table_elem: 'list', tableId: 'list', requests: { dropdown:{ type: 'dropdown', event: 'dropdown', class: 'layui-btn-xs layui-btn-green', url: 'member.member/edit', icon: 'layui-icon layui-icon-edit', text: __('Edit'), title: __('Edit'), // full: 1, width:'800', height:'600', extend:[ { title: 'add' ,id: 101 ,type: 'qita'//自定义事件 ,event: 'qita' ,url: 'member.member/add' ,icon: 'layui-icon layui-icon-edit' ,callback: 'demo'//自定义事件函数 从v3.3版本开始 这里支持函数写入 callback:function(obj,data){} }, { title: 'add' ,id: 101 ,type: 'open' ,event: 'open' ,url: 'member.member/add' ,icon: 'layui-icon layui-icon-edit' }] } }, }; ``` -------------------------------- ### Configuring an 'iframe' Event for Adding Full Content Source: https://doc.funadmin.com/index/index.html?id=8 Example of configuring an 'add_full' event to open a new iframe for adding content. This configuration specifies the event type, CSS classes, URL, icon, text, and dimensions. ```javascript add_full:{ type: 'iframe ', class: 'layui-btn-sm layui-btn-green', url: 'member.member/add', icon: 'layui-icon layui-icon-add', text: __('Add'), title: __('Add'), // full: 1, width:'800', height:'600', extend:'', }, ``` -------------------------------- ### Plugin Main File (Plugin.php) Source: https://doc.funadmin.com/28/javascipt:;/javascipt:;/javascipt:; This PHP file defines the core functionalities of a FunAdmin plugin, including installation, uninstallation, enabling, disabling, and hook implementations. ```php 0) { require(['xxx'], function (undefined) { //写你的逻辑 }) } }, }, }; return Editor.api.xxx() //调用代码 } }) ``` -------------------------------- ### Recycle Bin - Build Parameters Source: https://doc.funadmin.com/index/index.html?id=46 Prepares parameters for building the recycle bin view. It sets up pagination, sorting, and filtering based on request parameters. ```php if (request()->isAjax()) { list($this->page, $this->pageSize,$sort,$where) = $this->buildParames(); ``` -------------------------------- ### Show Full Columns of a Table Source: https://doc.funadmin.com/index/index.html?id=44 Use this command to display detailed information about the columns in the `fun_config` table. ```sql SHOW FULL COLUMNS FROM `fun_config` ``` -------------------------------- ### Get Plugin Configuration Source: https://doc.funadmin.com/index/index.html?id=40 Call `get_addons_config` with the plugin name to retrieve its configuration, typically parsed from the config.php file. ```php 1. //参数插件名 2. $config= get_addons_config('demo'); ``` -------------------------------- ### Write JavaScript in HTML Pages with Layui Source: https://doc.funadmin.com/7 Directly use Layui statements in your HTML pages. This example shows an icon picker. ```html {:form_icon('icon')} ``` -------------------------------- ### Generate Menu for Demo Module Source: https://doc.funadmin.com/9/javascipt:;/javascipt:;/javascipt:; Command to generate menu entries for a 'demo' module. Use '-a plugin_name' for plugin modules, '-f 1' for force overwrite, and '-d 1' for deletion. ```bash php think menu demo/test ``` ```bash php think menu -c demo/test -a demo -f 1 -d 1 ``` -------------------------------- ### Get Table Fields Source: https://doc.funadmin.com/33/javascipt:;/javascipt:; Retrieves table field names and their comments from the database schema. It constructs a SQL query to fetch this information from `information_schema.columns`. ```php protected function getTableField($modelClass = '',$field='COLUMN_NAME,COLUMN_COMMENT'){ $driver = Config::get('database.default'); $this->modelClass = $modelClass?:$this->modelClass; $database = $this->modelClass->get_databasename(); $table = Str::snake($this->modelClass->getName()); $tablePrefix = $this->modelClass->get_table_prefix(); $sql = "select $field from information_schema . columns where table_name = '" . $tablePrefix . $table . "' and table_schema = '" . $database . "'"; $tableField = Db::connect($driver)->query($sql); $fieldArr = []; foreach ($tableField as $field){ $fieldArr[$field['COLUMN_NAME']] = strtolower(trim($field['COLUMN_COMMENT'])); } return $fieldArr; } ``` -------------------------------- ### Basic Form Configuration Source: https://doc.funadmin.com/12 Use `form_config` to configure form elements for the `fun_config` table. ```php {:form_config($name,$options,$value)} //配置fun_config表的表单 ``` -------------------------------- ### XSS Attack Example Source: https://doc.funadmin.com/index/index.html?id=19 Demonstrates a basic XSS vulnerability where user input is directly echoed into the HTML without sanitization. This allows malicious scripts to be executed. ```html 1.
2. 6.We found: Absolutely nothing because this is a demo
8. ``` ```php search.php?q=%3Cscript%3Ealert(1)%3B%3C%2Fscript%3E ``` ```html 1. 2.We found: Absolutely nothing because this is a demo
4. ``` -------------------------------- ### Text Input with Verification Source: https://doc.funadmin.com/12 Configure a text input with required verification and custom tips. ```php {:form_input('username','text',['verify'=>'required','tips'=>'Between 4 and 25 characters.'])} ``` -------------------------------- ### Get Table Fields Source: https://doc.funadmin.com/index/index.html?id=33 Retrieves table field names and their comments from the database schema. It constructs a SQL query based on the model class and database configuration. ```php protected function getTableField($modelClass = '',$field = 'COLUMN_NAME,COLUMN_COMMENT'){ $driver = Config::get('database.default'); $this->modelClass = $modelClass ?: $this->modelClass; $database = $this->modelClass->get_databasename(); $table = Str::snake($this->modelClass->getName()); $tablePrefix = $this->modelClass->get_table_prefix(); $sql = "select $field from information_schema . columns where table_name = '" . $tablePrefix . $table . "' and table_schema = '" . $database . "'"; $tableField = Db::connect($driver)->query($sql); $fieldArr = []; foreach ($tableField as $field){ $fieldArr[$field['COLUMN_NAME']] = strtolower(trim($field['COLUMN_COMMENT'])); } return $fieldArr; } ``` -------------------------------- ### Select Article by Plugin and ID Source: https://doc.funadmin.com/index/index.html?id=34 Retrieves a single article from the 'fun_docs_article' table based on plugin ID and article ID. Ensures the article is not deleted. ```sql SELECT * FROM `fun_docs_article` WHERE ( ( `plugins_id` = index AND `id` = 34 ) AND `plugins_id` = index ) AND `fun_docs_article`.`delete_time` = '0' LIMIT 1 ``` -------------------------------- ### Configuration File (config.php) Source: https://doc.funadmin.com/28/javascipt:;/javascipt:;/javascipt:; This PHP file defines configuration options for the plugin, such as enabling or disabling frontend access. ```php [ 'title' => '启用前台:', 'type' => 'radio', 'rule' => 'required', 'content' => [ 0 => 'close', 1 => 'open', ], 'num' => '', 'value' => 1, 'msg' => '', 'tips' => '', 'ok' => '', ], ]; ``` -------------------------------- ### Get Table Status and Cache Information Source: https://doc.funadmin.com/33 Retrieves table status information and caches it using the table name as a tag. This is useful for dynamic table operations. ```php $tableInfo = Db::query("show table status like '{$tablePrefix}{$tableName}'"); Cache::tag($tableName)->set($tableName,$tableInfo); ``` -------------------------------- ### SelectPage Input (Multiple) Source: https://doc.funadmin.com/12 Configures a SelectPage input for selecting multiple items from a list, with required verification. Requires setup for the 'member.member/index' URL and 'username' field. ```php {:form_selectpage('list_id',$list = [],['url'=>'member.member/index','field'=>'username','multiple'=>true,'verify'=>'required'],$value)} ``` -------------------------------- ### Plugin Configuration File (plugin.ini) Source: https://doc.funadmin.com/38/javascipt:;/javascipt:; Defines the structure and parameters for a FunAdmin plugin's configuration file. Use this to set plugin metadata and status. ```ini 1. name = alisms //标记 和目录名一致 2. title = 阿里云短信插件 //标题 3. description = 阿里云短信插件-FunAdmin插件 //简介 4. status = 1 //状态 5. install = 0 //是否安装 6. author = yuege //作者 7. requires = 3.0 //需要的框架版本 8. version = 1.0 //插件般般 9. website = //插件演示地址 10. thumb = //插件缩略图 11. url = // 前台地址 12. publish_time = 2021-03-18 // 发布时间 13. autoload = 1 //vendor自动加载 ``` -------------------------------- ### Generate Menu for Demo Module Source: https://doc.funadmin.com/9/javascipt:;/javascipt:; Generates menu entries for the 'demo/test' controller within the default backend module using the 'think menu' command. ```bash php think menu demo/test ``` -------------------------------- ### Implementing Custom JavaScript Logic in a Plugin Source: https://doc.funadmin.com/39/javascipt:;/javascipt:;/javascipt:; Define custom JavaScript logic within a RequireJS module. This example shows how to bind events and initialize custom editors. ```javascript require(['form'], function (Form) { Form.events.bindevent = function (form) { let Editor = { init: { }, }, events: {}, api: { xxx: function () { let editor = document.querySelectorAll('*[lay-filter="editor"]') if (editor.length > 0) { require(['xxx'], function (undefined) { //写你的逻辑 }) } }, }, }; return Editor.api.xxx() //调用代码 } }) ``` -------------------------------- ### Get Paginated Data Source: https://doc.funadmin.com/index/index.html?id=46 Retrieves paginated data based on specified criteria, including filtering, sorting, and page size. Returns data items and total count. ```php $list = $this->modelClass->onlyTrashed() ->where($where) ->order($sort) ->paginate([ 'list_rows'=> $this->pageSize, 'page' => $this->page, ]); $result = ['code' => 0, 'msg' => lang('Get Data Success'), 'data' => $list->items(), 'count' =>$list->total()]; return json($result); ``` -------------------------------- ### Build a Form with Various Components Source: https://doc.funadmin.com/index/index.html?id=59 Demonstrates how to use the FormBuilder to construct a form by chaining various input and component methods. This is useful for quickly generating complex forms with minimal code. ```php 1. use fun\builder\FormBuilder; 2. 3. return FormBuilder::instance() 4. ->input($name) 5. ->rate($name) 6. ->editor($name) 7. ->city($name) 8. ->autocomplete($name) 9. ->text($name) 10. ->range($name) 11. ->slider($name) 12. ->radio($name) 13. ->switchs($name) 14. ->checkbox($name) 15. ->arrays($name) 16. ->textarea($name) 17. ->color($name) 18. ->icon($name) 19. ->selectn($name) 20. ->selectpage($name) 21. ->xmselect($name) 22. ->multiselect($name) 23. ->tags($name) 24. ->upload($name) 25. ->date($name) 26. ->region($name) 27. ->submitbtn() 28. ->js($name=[]) 29. ->link($name=[]) 30. ->script($name=[]) 31. ->extraHtml($html) 32. ->html($html) 33. ->extraJs($js) 34. ->style($style) 35. ->html($html) 36. ->assign() 37. ->view(); ``` -------------------------------- ### xmSelect Configuration Options Table Source: https://doc.funadmin.com/12 This table lists and describes the configuration parameters for xmSelect, including their types, optional values, and default values. ```markdown ### 配置项 参数 | 说明 | 类型 | 可选值 | 默认值 ---|---|---|---|--- language | 语言选择 | string | zn / en | zn data | 显示的数据 | array | - | [ ] content | 自定义下拉框html | string | - | - initValue | 初始化选中的数据, 需要在data中存在 | array | - | null tips | 默认提示, 类似于placeholder | string | - | 请选择 empty | 空数据提示 | string | - | 暂无数据 filterable | 是否开启搜索 | boolean | true / false | false searchTips | 搜索提示 | string | - | 请选择 delay | 搜索延迟 ms | int | - | 500 filterMethod | 搜索回调函数 | function(val, item, index, prop) val: 当前搜索值, item: 每个option选项, index: 位置数据中的下标, prop: 定义key | - | - filterDone | 搜索完成函数 | function(val, list) val: 当前搜索值, list: 过滤后的数据 | - | - remoteSearch | 是否开启自定义搜索 (远程搜索) | boolean | true / false | false remoteMethod | 自定义搜索回调函数 | function(val, cb, show, pageIndex) val: 当前搜索值, cb(arr, totalPage): 回调函数, 需要回调一个数组, 结构同data, 远程分页需要第二个参数: 总页码, show: 下拉框显示状态, pageIndex: 分页下当前页码 | - | - direction | 下拉方向 | string | auto / up / down | auto style | 自定义样式 | object | - | { } height | 默认最大高度 | string | - | 200px paging | 是否开启自定义分页 | boolean | true / false | false pageSize | 分页条数 | int | - | 10 pageEmptyShow | 分页无数据是否显示 | boolean | true / false | true pageRemote | 是否开启远程分页 | boolean | true / false | true radio | 是否开启单选模式 | boolean | true / false | false repeat | 是否开启重复性模式 | boolean | true / false | false clickClose | 是否点击选项后自动关闭下拉框 | boolean | true / false | false prop | 自定义属性名称, 具体看下表 | object | - | theme | 主题配置, 具体看下表 | object | - | model | 模型, 多选的展示方式, 具体见下表 | object | - | iconfont | 自定义选中图标 | object | - | show | 展开下拉的回调 | function | - | - hide | 隐藏下拉的回调 | function | - | - template | 自定义渲染选项 | function({ item, sels, name, value }) | - | - on | 监听选中变化 | function({ arr, change, isAdd }) | - | - max | 设置多选选中上限 | int | - | 0 maxMethod | 达到选中上限的回到 | function(sels, item), sels: 已选中数据, item: 当前选中的值 | - | - name | 表单提交时的name | string | - | select layVerify | 表单验证, 同layui的lay-verify | string | - | ‘’ layVerType | 表单验证, 同layui的lay-verType | string | - | ‘’ layReqText | 表单验证, 同layui的lay-reqText | string | - | ‘’ toolbar | 工具条, 具体看下表 | object | - | - showCount | 展示在下拉框中的最多选项数量 | int | - | 0 enableKeyboard | 是否启用键盘操作选项 | boolean | true / false | true enableHoverFirst | 是否默认选中第一项 | boolean | true / false | true selectedKeyCode | 选中的键盘KeyCode | int | 全部KeyCode, 也可xmSelect.KeyCode.Enter,xmSelect.KeyCode.Space | 13 autoRow | 是否开启自动换行(选项过多时) | boolean | true / false | false size | 尺寸 | string | large / medium / small / mini | medium disabled | 是否禁用多选 | boolean | true / false | false create | 创建条目 | function(val, data), val: 搜索的数据, data: 当前下拉数据 | - | null tree | 树形结构, 具体看下表 | object | - | - cascader | 级联结构, 具体看下表 | object | - | - submitConversion | 配置表单提交数据 | function(sels, prop), sels: 已选中数据, prop: 自定义的prop | - | - done | 渲染完成回调 | function | - | - ``` -------------------------------- ### Get Table Field Information Source: https://doc.funadmin.com/33 Retrieves column names and comments for a given table from the database schema. Returns an associative array mapping column names to their comments. ```php protected function getTableField($modelClass = '', $field = 'COLUMN_NAME,COLUMN_COMMENT'){ $driver = Config::get('database.default'); $this->modelClass = $modelClass ?: $this->modelClass; $database = $this->modelClass->get_databasename(); $table = Str::snake($this->modelClass->getName()); $tablePrefix = $this->modelClass->get_table_prefix(); $sql = "select $field from information_schema . columns where table_name = '" . $tablePrefix . $table . "' and table_schema = '" . $database . "'"; $tableField = Db::connect($driver)->query($sql); $fieldArr = []; foreach ($tableField as $field) { $fieldArr[$field['COLUMN_NAME']] = strtolower(trim($field['COLUMN_COMMENT'])); } return $fieldArr; } ``` -------------------------------- ### Define Custom Callback Function Source: https://doc.funadmin.com/index/index.html?id=43 Provides an example of a custom JavaScript callback function named 'demo' that can be associated with operation buttons. This function is intended for custom event logic. ```javascript demo = function(obj){ //这里写你的自定义事件逻辑 } ``` -------------------------------- ### Configure Add Button for Pop-up Window Source: https://doc.funadmin.com/7 Set `extend:'data-btn=""'` to disable the default buttons on a pop-up window. This example shows how to configure an 'Add' button. ```javascript add_full:{ type: 'open', class: 'layui-btn-sm layui-btn-green', url: 'member.member/add', icon: 'layui-icon layui-icon-add', text: __('Add'), title: __('Add'), node:false,//不使用节点权限 // full: 1, width:'800', height:'600', extend:'data-btn=""' }, ``` -------------------------------- ### System Runtime Information Snapshot Source: https://doc.funadmin.com/index/index.html?id=2 This snippet displays the runtime details of a specific request, including the request URL, HTTP method, execution time, memory consumption, and the number of database queries and cache operations. ```plaintext 1. 请求信息 : 2026-06-02 21:03:59 HTTP/2.0 GET : https://doc.funadmin.com/index/index.html?id=2 2. 运行时间 : 0.077753s [ 吞吐率:12.86req/s ] 内存消耗:1,031.11kb 文件加载:231 3. 查询信息 : 0 queries 4. 缓存信息 : 0 reads,0 writes 5. 会话信息 : SESSION_ID=1b091139e667a4f46f10fde57603188a ``` -------------------------------- ### Get File Data from Excel/CSV Source: https://doc.funadmin.com/index/index.html?id=46 Reads data from an uploaded Excel (xls, xlsx) or CSV file. It handles file validation, format detection, and uses PhpSpreadsheet to load the data. ```php protected function getFileData($file = ''){ $file = $file ?: $this->request->param('file'); if (!$file) { $this->error(lang("Parameter error")); } $file = public_path() . $file; //此处写导入逻辑 $file = iconv("utf-8", "gb2312", $file); if (empty($file) || !file_exists($file)) { $this->error(lang('file does not exist')); } $ext = pathinfo($file, PATHINFO_EXTENSION); if (!in_array($ext, ['csv', 'xls', 'xlsx'])) { $this->error(lang('file format not right')); } //实例化reader if ($ext === 'csv') { $reader = IOFactory::createReader('Csv')->setInputEncoding('GB2312'); } elseif ($ext === 'xls') { $reader = IOFactory::createReader('Xls'); } else { $reader = IOFactory::createReader('Xlsx'); } if (!$PHPExcel = $reader->load($file)) { $this->error(lang('Unknown data format')); } $excelData = $PHPExcel->getSheet(0)->toArray(); $excelData = array_filter($excelData); return $excelData; } ```