### Install dependencies with Composer Source: https://github.com/zyx0814/dzzoffice/blob/master/core/api/Qcos/README.md Runs the Composer install command to create a vendor folder with the SDK dependencies and autoload.php. ```bash php composer.phar install ``` -------------------------------- ### 初始化客户端(临时密钥) Source: https://github.com/zyx0814/dzzoffice/blob/master/core/api/Qcos/README.md 使用临时密钥创建 COS 客户端实例。需要额外提供 token 字段。 ```APIDOC ### 配置文件 ```php $cosClient = new Qcloud\Cos\Client(array( 'region' => '', 'credentials' => array( 'secretId' => '', 'secretKey' => '', 'token' => '' ) )); ``` ``` -------------------------------- ### Download Composer Source: https://github.com/zyx0814/dzzoffice/blob/master/core/api/Qcos/README.md Downloads the Composer installer script using curl, as part of the Composer installation steps. ```bash curl -sS https://getcomposer.org/installer | php ``` -------------------------------- ### 使用临时密钥初始化 COS 客户端 Source: https://github.com/zyx0814/dzzoffice/blob/master/core/api/Qcos/README.md 使用临时密钥初始化客户端,需额外提供 token 字段(XCosSecurityToken)。适用于临时密钥授权场景。 ```php $cosClient = new Qcloud\Cos\Client(array( 'region' => '', 'credentials' => array( 'secretId' => '', 'secretKey' => '', 'token' => '' ) )); ``` -------------------------------- ### getObject(下载文件) Source: https://github.com/zyx0814/dzzoffice/blob/master/core/api/Qcos/README.md 使用 getObject 接口下载文件,支持下载到内存、下载到本地、指定下载范围以及设置返回 header。 ```APIDOC ### 下载到内存 ```php //bucket 的命名规则为{name}-{appid} ,此处填写的存储桶名称必须为此格式 try { $result = $cosClient->getObject(array( 'Bucket' => $bucket, 'Key' => $key)); echo($result['Body']); } catch (\Exception $e) { echo "$e\n"; } ``` ### 下载到本地 ```php try { $result = $cosClient->getObject(array( 'Bucket' => $bucket, 'Key' => $key, 'SaveAs' => $local_path)); } catch (\Exception $e) { echo "$e\n"; } ``` ### 指定下载范围 ```php /* * Range 字段格式为 'bytes=a-b' */ try { $result = $cosClient->getObject(array( 'Bucket' => $bucket, 'Key' => $key, 'Range' => 'bytes=0-10', 'SaveAs' => $local_path)); } catch (\Exception $e) { echo "$e\n"; } ``` ### 设置返回header ```php try { $result = $cosClient->getObject(array( 'Bucket' => $bucket, 'Key' => $key, 'ResponseCacheControl' => 'string', 'ResponseContentDisposition' => 'string', 'ResponseContentEncoding' => 'string', 'ResponseContentLanguage' => 'string', 'ResponseContentType' => 'string', 'ResponseExpires' => 'mixed type: string (date format)|int (unix timestamp)|\DateTime', 'SaveAs' => $local_path)); } catch (\Exception $e) { echo "$e\n"; } ``` ``` -------------------------------- ### putObject(上传文件,最大支持5G) Source: https://github.com/zyx0814/dzzoffice/blob/master/core/api/Qcos/README.md 使用 putObject 接口上传文件,支持上传内存中的字符串、文件流,并可设置 header 和 meta。 ```APIDOC ### 上传内存中的字符串 ```php //bucket 的命名规则为{name}-{appid} ,此处填写的存储桶名称必须为此格式 try { $result = $cosClient->putObject(array( 'Bucket' => $bucket, 'Key' => $key, 'Body' => 'Hello World!')); print_r($result); } catch (\Exception $e) { echo "$e\n"; } ``` ### 上传文件流 ```php try { $result = $cosClient->putObject(array( 'Bucket' => $bucket, 'Key' => $key, 'Body' => fopen($local_path, 'rb'))); print_r($result); } catch (\Exception $e) { echo "$e\n"; } ``` ### 设置header和meta ```php try { $result = $cosClient->putObject(array( 'Bucket' => $bucket, 'Key' => $key, 'Body' => fopen($local_path, 'rb'), 'ACL' => 'string', 'CacheControl' => 'string', 'ContentDisposition' => 'string', 'ContentEncoding' => 'string', 'ContentLanguage' => 'string', 'ContentLength' => integer, 'ContentType' => 'string', 'Expires' => 'mixed type: string (date format)|int (unix timestamp)|\DateTime', 'Metadata' => array( 'string' => 'string', ), 'StorageClass' => 'string')); print_r($result); } catch (\Exception $e) { echo "$e\n"; } ``` ``` -------------------------------- ### Require autoload.php for source installation Source: https://github.com/zyx0814/dzzoffice/blob/master/core/api/Qcos/README.md Loads the SDK from the source distribution by including the autoload script. ```php require '/path/to/cos-php-sdk-v5/vendor/autoload.php'; ``` -------------------------------- ### Upload(高级上传接口,默认分块上传,最大支持50T) Source: https://github.com/zyx0814/dzzoffice/blob/master/core/api/Qcos/README.md 使用 Upload 接口进行高级上传,支持上传内存中的字符串、文件流,并可设置 header 和 meta。 ```APIDOC ### 上传内存中的字符串 ```php try { $result = $cosClient->Upload( $bucket = $bucket, $key = $key, $body = 'Hello World!'); print_r($result); } catch (\Exception $e) { echo "$e\n"; } ``` ### 上传文件流 ```php try { $result = $cosClient->Upload( $bucket = $bucket, $key = $key, $body = fopen($local_path, 'rb')); print_r($result); } catch (\Exception $e) { echo "$e\n"; } ``` ### 设置header和meta ```php try { $result = $cosClient->Upload( $bucket= $bucket, $key = $key, $body = fopen($local_path, 'rb'), $options = array( 'ACL' => 'string', 'CacheControl' => 'string', 'ContentDisposition' => 'string', 'ContentEncoding' => 'string', 'ContentLanguage' => 'string', 'ContentLength' => integer, 'ContentType' => 'string', 'Expires' => 'mixed type: string (date format)|int (unix timestamp)|\DateTime', 'Metadata' => array( 'string' => 'string', ), 'StorageClass' => 'string')); print_r($result); } catch (\Exception $e) { echo "$e\n"; } ``` ``` -------------------------------- ### Install PHP cURL extension on Ubuntu Source: https://github.com/zyx0814/dzzoffice/blob/master/core/api/Qcos/README.md Use apt-get to install the PHP cURL extension on Ubuntu systems, as required by the SDK. ```bash sudo apt-get install php-curl ``` -------------------------------- ### Require autoload.php for Composer installation Source: https://github.com/zyx0814/dzzoffice/blob/master/core/api/Qcos/README.md Includes the Composer autoload script to use the SDK in your project. ```php require '/path/to/vendor/autoload.php'; ``` -------------------------------- ### Install PHP cURL extension on CentOS Source: https://github.com/zyx0814/dzzoffice/blob/master/core/api/Qcos/README.md Use yum to install the PHP cURL extension on CentOS systems, as required by the SDK. ```bash sudo yum install php-curl ``` -------------------------------- ### Require phar file for Phar installation Source: https://github.com/zyx0814/dzzoffice/blob/master/core/api/Qcos/README.md Includes the downloaded phar file to use the SDK via the Phar installation method. ```php require '/path/to/cos-sdk-v5.phar'; ``` -------------------------------- ### getObjectUrl(获取文件URL) Source: https://github.com/zyx0814/dzzoffice/blob/master/core/api/Qcos/README.md 使用 getObjectUrl 接口获取文件的预签名 URL,可指定有效期。 ```APIDOC ```php try { $signedUrl = $cosClient->getObjectUrl($bucket, $key, '+10 minutes'); echo $signedUrl; } catch (\Exception $e) { print_r($e); } ``` ``` -------------------------------- ### Upload 高级上传接口(字符串、文件流、设置 header 和 meta) Source: https://github.com/zyx0814/dzzoffice/blob/master/core/api/Qcos/README.md 使用 Upload 接口上传文件,默认使用分块上传,最大支持 50T。包含三种用法:上传内存字符串、上传文件流、设置 header 和 meta。 ```php ## Upload(高级上传接口,默认使用分块上传最大支持50T) ### 上传内存中的字符串 try { $result = $cosClient->Upload( $bucket = $bucket, $key = $key, $body = 'Hello World!'); print_r($result); } catch (\Exception $e) { echo "$e\n"; } ### 上传文件流 try { $result = $cosClient->Upload( $bucket = $bucket, $key = $key, $body = fopen($local_path, 'rb')); print_r($result); } catch (\Exception $e) { echo "$e\n"; } ### 设置header和meta try { $result = $cosClient->Upload( $bucket= $bucket, $key = $key, $body = fopen($local_path, 'rb'), $options = array( 'ACL' => 'string', 'CacheControl' => 'string', 'ContentDisposition' => 'string', 'ContentEncoding' => 'string', 'ContentLanguage' => 'string', 'ContentLength' => integer, 'ContentType' => 'string', 'Expires' => 'mixed type: string (date format)|int (unix timestamp)|\DateTime', 'Metadata' => array( 'string' => 'string', ), 'StorageClass' => 'string')); print_r($result); } catch (\Exception $e) { echo "$e\n"; } ``` -------------------------------- ### getObjectUrl 获取文件下载 URL Source: https://github.com/zyx0814/dzzoffice/blob/master/core/api/Qcos/README.md 使用 getObjectUrl 接口获取文件下载 URL,可指定有效期(如 '+10 minutes')。返回签名 URL 并输出。 ```php ## getObjectUrl(获取文件UrL) try { $signedUrl = $cosClient->getObjectUrl($bucket, $key, '+10 minutes'); echo $signedUrl; } catch (\Exception $e) { print_r($e); } ``` -------------------------------- ### putObject 上传文件(字符串、文件流、设置 header 和 meta) Source: https://github.com/zyx0814/dzzoffice/blob/master/core/api/Qcos/README.md 使用 putObject 接口上传文件,最大支持 5G。包含三种用法:上传内存字符串、上传文件流、设置 header 和 meta。Bucket 命名规则为 {name}-{appid}。 ```php # 上传文件 ## putObject(上传接口,最大支持上传5G文件) ### 上传内存中的字符串 //bucket 的命名规则为{name}-{appid} ,此处填写的存储桶名称必须为此格式 try { $result = $cosClient->putObject(array( 'Bucket' => $bucket, 'Key' => $key, 'Body' => 'Hello World!')); print_r($result); } catch (\Exception $e) { echo "$e\n"; } ### 上传文件流 try { $result = $cosClient->putObject(array( 'Bucket' => $bucket, 'Key' => $key, 'Body' => fopen($local_path, 'rb'))); print_r($result); } catch (\Exception $e) { echo "$e\n"; } ### 设置header和meta try { $result = $cosClient->putObject(array( 'Bucket' => $bucket, 'Key' => $key, 'Body' => fopen($local_path, 'rb'), 'ACL' => 'string', 'CacheControl' => 'string', 'ContentDisposition' => 'string', 'ContentEncoding' => 'string', 'ContentLanguage' => 'string', 'ContentLength' => integer, 'ContentType' => 'string', 'Expires' => 'mixed type: string (date format)|int (unix timestamp)|\DateTime', 'Metadata' => array( 'string' => 'string', ), 'StorageClass' => 'string')); print_r($result); } catch (\Exception $e) { echo "$e\n"; } ``` -------------------------------- ### 初始化客户端(永久密钥) Source: https://github.com/zyx0814/dzzoffice/blob/master/core/api/Qcos/README.md 使用永久密钥创建 COS 客户端实例。需要指定 region 和 credentials 中的 secretId 与 secretKey。 ```APIDOC ### 配置文件 ```php $cosClient = new Qcloud\Cos\Client(array( 'region' => '', 'credentials' => array( 'secretId' => '', 'secretKey' => '' ) )); ``` ``` -------------------------------- ### 使用永久密钥初始化 COS 客户端 Source: https://github.com/zyx0814/dzzoffice/blob/master/core/api/Qcos/README.md 配置文件示例,使用永久密钥(SecretId 和 SecretKey)创建 Qcloud\Cos\Client 实例。需要将 、、 替换为实际值。 ```php $cosClient = new Qcloud\Cos\Client(array( 'region' => '', 'credentials' => array( 'secretId' => '', 'secretKey' => '' ) )); ``` -------------------------------- ### getObject 下载文件(内存、本地、范围、设置返回 header) Source: https://github.com/zyx0814/dzzoffice/blob/master/core/api/Qcos/README.md 使用 getObject 接口下载文件。包含四种用法:下载到内存、下载到本地、指定下载范围(Range 格式为 'bytes=a-b')、设置返回 header。Bucket 命名规则为 {name}-{appid}。 ```php # 下载文件 ## getObject(下载文件) ### 下载到内存 //bucket 的命名规则为{name}-{appid} ,此处填写的存储桶名称必须为此格式 try { $result = $cosClient->getObject(array( 'Bucket' => $bucket, 'Key' => $key)); echo($result['Body']); } catch (\Exception $e) { echo "$e\n"; } ### 下载到本地 try { $result = $cosClient->getObject(array( 'Bucket' => $bucket, 'Key' => $key, 'SaveAs' => $local_path)); } catch (\Exception $e) { echo "$e\n"; } ### 指定下载范围 /* * Range 字段格式为 'bytes=a-b' */ try { $result = $cosClient->getObject(array( 'Bucket' => $bucket, 'Key' => $key, 'Range' => 'bytes=0-10', 'SaveAs' => $local_path)); } catch (\Exception $e) { echo "$e\n"; } ### 设置返回header try { $result = $cosClient->getObject(array( 'Bucket' => $bucket, 'Key' => $key, 'ResponseCacheControl' => 'string', 'ResponseContentDisposition' => 'string', 'ResponseContentEncoding' => 'string', 'ResponseContentLanguage' => 'string', 'ResponseContentType' => 'string', 'ResponseExpires' => 'mixed type: string (date format)|int (unix timestamp)|\DateTime', 'SaveAs' => $local_path)); } catch (\Exception $e) { echo "$e\n"; } ``` -------------------------------- ### Create composer.json for cos-sdk-v5 Source: https://github.com/zyx0814/dzzoffice/blob/master/core/api/Qcos/README.md Defines the required dependency on qcloud/cos-sdk-v5 version 2.* in a composer.json file. ```json { "require": { "qcloud/cos-sdk-v5": "2.*" } } ``` -------------------------------- ### Search button functionality Source: https://github.com/zyx0814/dzzoffice/blob/master/admin/systemlog/template/list.htm Handles the search button click to reload the table with a keyword filter and update the URL query parameter. Starts from page 1 and preserves the operation filter. ```JavaScript // 搜索按钮功能 $(document).on('click', '#search-btn', function () { keyword = $('#keyword').val(); table.reloadData('table', { where: {operation: operation,keyword: keyword}, page: { curr: 1 //重新从第 1 页开始 } }); try { var currentUrl = new URL(window.location.href); if (keyword) { currentUrl.searchParams.set('keyword', keyword); } else { currentUrl.searchParams.delete('keyword'); } history.pushState(null, null, currentUrl.toString()); } catch (e) {} }); ``` -------------------------------- ### Show selected share information with layer.alert Source: https://github.com/zyx0814/dzzoffice/blob/master/dzz/share/template/share.htm Builds an HTML template from selected table row data and displays it in a layer.alert dialog titled '选中的分享信息'. Used when the toolbar event is 'get'. ```JavaScript template += ''; template += ''; template += ''; }); template += ''; layer.alert(template, { title: '选中的分享信息' }); ``` -------------------------------- ### Reload table data with search parameters Source: https://github.com/zyx0814/dzzoffice/blob/master/dzz/share/template/share.htm Reloads the 'table' instance with current filter values (type, keyword, username) and resets to page 1. Used in the toolbar 'get' event and search button click. ```JavaScript table.reloadData('table', { where: {type: $('#filetype').val(),keyword:$('#keyword').val(),username:$('#username').val()}, // 清空搜索参数 page: { curr: 1 //重新从第 1 页开始 } }); ``` -------------------------------- ### Initialize Music Dialog and Handle OK/Cancel Source: https://github.com/zyx0814/dzzoffice/blob/master/dzz/system/ueditor/dialogs/music/music.html Creates a Music instance and assigns dialog callbacks. On OK, executes the music action; on cancel, clears the preview element with ID 'J_preview'. ```JavaScript var music = new Music; dialog.onok = function () { music.exec(); }; dialog.oncancel = function () { $G('J\_preview').innerHTML = ""; }; ``` -------------------------------- ### Database driver configuration in config.php Source: https://github.com/zyx0814/dzzoffice/blob/master/admin/system/template/database.htm Shows how to set the database driver to 'pdo' or 'mysqli' in the config file. The driver field defaults to empty (mysqli). Modify /config/config.php and refresh the page; no service restart needed. Backup config.php before changing. ```PHP // 数据库驱动配置(二选一) // 1. 启用 PDO 驱动(推荐,支持参数化查询,更安全) {eval echo '$_config["db"]["driver"] = "pdo";';} // 2. 启用 mysqli 驱动(默认方式) {eval echo '$_config["db"]["driver"] = "mysqli";';} ``` -------------------------------- ### Copy share link and password to clipboard Source: https://github.com/zyx0814/dzzoffice/blob/master/dzz/share/template/share.htm Creates a temporary input element, sets its value to the share name, link, and optional password, then copies it using document.execCommand('copy'). Shows a success message via layer.msg. ```JavaScript function copyShareInfo(data) { // 创建临时的 input 元素用于复制链接 var tempInput = document.createElement("input"); document.body.appendChild(tempInput); var copyText = data.name + "\\n " + data.sharelink; if (data.password) { copyText += " \\n密码: " + data.password; } tempInput.value = copyText; tempInput.select(); document.execCommand("copy"); document.body.removeChild(tempInput); layer.msg('信息已复制到剪贴板'); } ``` -------------------------------- ### Display share details in layer.alert with row highlighting Source: https://github.com/zyx0814/dzzoffice/blob/master/dzz/share/template/share.htm Constructs a detailed HTML template from row data (title, status, time, user, link, password, etc.) and shows it in a layer.alert. Highlights the selected row by adding 'layui-table-click' class. ```JavaScript function showDataTemplate(obj) { var data = obj.dataCache; var template = '

{lang share\_title}: ' + data.title + '

' + '

{lang share\_status}: ' + data.status + '

' + '

{lang share\_time}: ' + data.dateline + '

' + '

{lang share\_user}: ' + data.username + '

' + '

{lang share\_address}: ' + data.sharelink + '

' + '

{lang extract\_password}: ' + data.password + '

' + '

{lang failure\_time}: ' + data.endtime + '

' + '

{lang view\_count}: ' + data.count + '{lang degree}

' + '

{lang download\_times}: ' + data.downs + '{lang degree}

' + '

{lang file\_type}: ' + data.type + '

{lang limited\_number}: ' + data.times + '

'; layer.alert(template, { title: 'ID:'+data.LAY\_NUM+' {lang detail}:' }); // 标注选中样式 obj.tr.addClass('layui-table-click').siblings().removeClass('layui-table-click'); } ``` -------------------------------- ### Apache mod_rewrite rules for WOPI and DingTalk redirect Source: https://github.com/zyx0814/dzzoffice/blob/master/htaccess_default.txt Configure Apache to route WOPI file requests and DingTalk redirects to the DZZOffice PHP backend. Requires mod_rewrite enabled and follows symlinks. The rules map /wopi/files/... URLs to core/api/wopi/index.php and /dingredirect/... to index.php. ```apache Options +FollowSymlinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^wopi\/files\/(\w+)\/contents(.*)$ core/api/wopi/index.php?action=contents&path=$1&$2 [QSA,PT,L] RewriteRule ^wopi\/files\/(\w+)\/(lock|unlock)(.*)$ core/api/wopi/index.php?action=$2&path=$1&$3 [QSA,PT,L] RewriteRule ^wopi\/files\/(\w+)(.*)$ core/api/wopi/index.php?path=$1&$2 [QSA,PT,L] RewriteRule ^wopi\/files\/(.*)$ core/api/wopi/index.php?$1 [QSA,PT,L] RewriteRule ^dingredirect\/(\w+)$ index.php?mod=dingtalk&op=dingredirect&url=$1 [QSA,PT,L] ``` -------------------------------- ### Table toolbar event handlers for detail, copy, sort, and row double-click Source: https://github.com/zyx0814/dzzoffice/blob/master/dzz/share/template/share.htm Listens for toolbar events 'detail' and 'copy' to call showDataTemplate or copyShareInfo. Also handles sort and row double-click events, triggering table reloads or detail display. ```JavaScript //监听工具条 table.on('tool(table)', function(obj){ var data = obj.dataCache; if(obj.event === 'detail'){ showDataTemplate(obj); } else if(obj.event === 'copy'){ copyShareInfo(data); } }); //触发排序事件 table.on('sort(table)', function(obj){ table.reloadData('table', { initSort: obj ,where: { field: obj.field ,order: obj.type } }); }); table.on('rowDouble(table)', function(obj){ showDataTemplate(obj); }); ``` -------------------------------- ### PHP config snippet to enable remote cron Source: https://github.com/zyx0814/dzzoffice/blob/master/admin/system/template/cron.htm PHP code to set configuration options for remote cron triggering, as shown in the template. ```php $_config['remote']['on']=1; $_config['remote']['cron']=1; ``` -------------------------------- ### Reset button functionality Source: https://github.com/zyx0814/dzzoffice/blob/master/admin/systemlog/template/list.htm Clears the keyword input and reloads the table without the keyword filter, resetting to page 1. Also removes the keyword from the URL query string. ```JavaScript // 重置按钮功能 $('#refreshsearch').click(function () { $('#keyword').val(''); table.reloadData('table', { where: {operation: operation}, // 清空搜索参数 page: { curr: 1 //重新从第 1 页开始 } }); try { var currentUrl = new URL(window.location.href); currentUrl.searchParams.delete('keyword'); history.pushState(null, null, currentUrl.toString()); } catch (e) {} }); ``` -------------------------------- ### Baidu Map API Custom Map JavaScript Source: https://github.com/zyx0814/dzzoffice/blob/master/dzz/system/ueditor/dialogs/map/show.html Initializes a Baidu Map with parameters from the URL, adds controls, and updates the parent iframe on map changes. Requires the Baidu Map API script and a parent editor context. ```javascript function getParam(name) { return location.href.match(new RegExp('\[?#&\]' + name + '=(\[^?#&\]+)', 'i')) ? RegExp.$1 : ''; } var map, marker; var centerParam = getParam('center'); var zoomParam = getParam('zoom'); var widthParam = getParam('width'); var heightParam = getParam('height'); var markersParam = getParam('markers'); var markerStylesParam = getParam('markerStyles'); //创建和初始化地图函数: function initMap() { // \[FF\]切换模式后报错 if (!window.BMap) { return; } var dituContent = document.getElementById('dituContent'); dituContent.style.width = widthParam + 'px'; dituContent.style.height = heightParam + 'px'; createMap();//创建地图 setMapEvent();//设置地图事件 addMapControl();//向地图添加控件 // 创建标注 var markersArr = markersParam.split(','); var point = new BMap.Point(markersArr\[0\], markersArr\[1\]); marker = new BMap.Marker(point); marker.enableDragging(); map.addOverlay(marker); // 将标注添加到地图中 if(parent.editor && parent.document.body.contentEditable=="true") { //在编辑状态下 setMapListener();//地图改变修改外层的iframe标签src属性 } } //创建地图函数: function createMap() { map = new BMap.Map("dituContent");//在百度地图容器中创建一个地图 var centerArr = centerParam.split(','); var point = new BMap.Point(parseFloat(centerArr\[0\]), parseFloat(centerArr\[1\]));//定义一个中心点坐标 map.centerAndZoom(point, parseInt(zoomParam));//设定地图的中心点和坐标并将地图显示在地图容器中 } //地图事件设置函数: function setMapEvent() { map.enableDragging();//启用地图拖拽事件,默认启用(可不写) map.enableScrollWheelZoom();//启用地图滚轮放大缩小 map.enableDoubleClickZoom();//启用鼠标双击放大,默认启用(可不写) map.enableKeyboard();//启用键盘上下左右键移动地图 } //地图控件添加函数: function addMapControl() { //向地图中添加缩放控件 var ctrl\_nav = new BMap.NavigationControl({anchor: BMAP\_ANCHOR\_TOP\_LEFT, type: BMAP\_NAVIGATION\_CONTROL\_LARGE}); map.addControl(ctrl\_nav); //向地图中添加缩略图控件 var ctrl\_ove = new BMap.OverviewMapControl({anchor: BMAP\_ANCHOR\_BOTTOM\_RIGHT, isOpen: 1}); map.addControl(ctrl\_ove); //向地图中添加比例尺控件 var ctrl\_sca = new BMap.ScaleControl({anchor: BMAP\_ANCHOR\_BOTTOM\_LEFT}); map.addControl(ctrl\_sca); } function setMapListener() { var editor = parent.editor, containerIframe, iframes = parent.document.getElementsByTagName('iframe'); for (var key in iframes) { if (iframes\[key\].contentWindow == window) { containerIframe = iframes\[key\]; break; } } if (containerIframe) { map.addEventListener('moveend', mapListenerHandler); map.addEventListener('zoomend', mapListenerHandler); marker.addEventListener('dragend', mapListenerHandler); } function mapListenerHandler() { var zoom = map.getZoom(), center = map.getCenter(), marker = window.marker.getPoint(); containerIframe.src = containerIframe.src. replace(new RegExp('(\[?#&\])center=(\[^?#&\]+)', 'i'), '$1center=' + center.lng + ',' + center.lat). replace(new RegExp('(\[?#&\])markers=(\[^?#&\]+)', 'i'), '$1markers=' + marker.lng + ',' + marker.lat). replace(new RegExp('(\[?#&\])zoom=(\[^?#&\]+)', 'i'), '$1zoom=' + zoom); editor.fireEvent('saveScene'); } } ``` -------------------------------- ### Check status button state updater Source: https://github.com/zyx0814/dzzoffice/blob/master/dzz/filemanage/template/list.htm Enables or disables the 'getCheckDataBtn' and 'deletebtn' buttons based on whether any table rows are selected. ```JavaScript function checkStatusBtn() { var checkStatus = table.checkStatus('table'); var isChecked = checkStatus.data.length > 0; var buttonIds = \['getCheckDataBtn', 'deletebtn'\]; buttonIds.forEach(function(btnId) { var btn = document.getElementById(btnId); if (btn) { if (isChecked) { btn.removeAttribute('disabled'); btn.classList.remove('layui-btn-disabled'); } else { btn.setAttribute('disabled', 'disabled'); btn.classList.add('layui-btn-disabled'); } } }); } ``` -------------------------------- ### JavaScript redirect after message Source: https://github.com/zyx0814/dzzoffice/blob/master/admin/system/template/cron.htm Redirects the user to a specified URL after a 2-second delay, used after displaying a message. ```javascript setTimeout(function(){location.href='{$redirecturl}';}, 2000); ``` -------------------------------- ### Type button functionality Source: https://github.com/zyx0814/dzzoffice/blob/master/admin/systemlog/template/list.htm Handles clicks on type buttons to set the active class, update the operation filter, clear the keyword, reload the table from page 1, and update the URL with the operation parameter while removing the keyword. ```JavaScript // 类型按钮功能 $(document).on('click', '.type-btn', function () { // 移除所有 .type-btn 的 active 类 $('.type-btn').removeClass('active'); // 为当前点击的按钮添加 active 类 $(this).addClass('active'); // 获取当前的 type 值 operation = $(this).data('operation'); $('#keyword').val(''); table.reloadData('table', { where: {operation: operation}, page: { curr: 1 //重新从第 1 页开始 } }); try { var currentUrl = new URL(window.location.href); if (operation) { currentUrl.searchParams.set('operation', operation); } else { currentUrl.searchParams.delete('operation'); } currentUrl.searchParams.delete('keyword'); history.pushState(null, null, currentUrl.toString()); } catch (e) {} }); ``` -------------------------------- ### Folder ID button click handler Source: https://github.com/zyx0814/dzzoffice/blob/master/dzz/filemanage/template/list.htm Handles clicks on folder buttons, reloading the table with the selected folder ID and resetting pagination to page 1. ```JavaScript $(document).on('click', '.fid-btn', function() { var fid = $(this).data('fid'); table.reloadData('table', { where: {type: type,pfid:fid}, // 清空搜索参数 page: { curr: 1 //重新从第 1 页开始 } }); }); ``` -------------------------------- ### Baidu Map API Custom Map HTML and CSS Source: https://github.com/zyx0814/dzzoffice/blob/master/dzz/system/ueditor/dialogs/map/show.html Sets up the page for the Baidu Map API custom map dialog. The CSS hides overflow and resets margins and padding. ```html 百度地图API自定义地图 ``` -------------------------------- ### Reset search button click handler Source: https://github.com/zyx0814/dzzoffice/blob/master/dzz/filemanage/template/list.htm Clears all search form fields and resets the table to show all files of the current type, also clearing URL search parameters. ```JavaScript // 重置按钮功能 $('#refreshsearch').click(function() { // 清空表单内容 $('#sel\_orgid\_{$org\['orgid'\]}').val(''); $('#filename').val(''); $('#username').val(''); $('#fileext').val(''); // 重置按钮内容 $('#orgid\_{$org\['orgid'\]}\_Menu').text('$org\[depart\]'); table.reloadData('table', { where: {type: type}, // 清空搜索参数 page: { curr: 1 //重新从第 1 页开始 } }); try { var currentUrl = new URL(window.location.href); currentUrl.searchParams.delete('filename'); currentUrl.searchParams.delete('username'); currentUrl.searchParams.delete('fileext'); history.pushState(null, null, currentUrl.toString()); } catch (e) {} }); ``` -------------------------------- ### Type button click handler Source: https://github.com/zyx0814/dzzoffice/blob/master/dzz/filemanage/template/list.htm Handles clicks on type filter buttons, toggling active state, clearing search fields, reloading the table with the selected type, and updating URL parameters. ```JavaScript // 类型按钮功能 $(document).on('click', '.type-btn', function() { // 移除所有 .type-btn 的 active 类 $('.type-btn').removeClass('active'); // 为当前点击的按钮添加 active 类 $(this).addClass('active'); // 获取当前的 type 值 type = $(this).data('type'); $('#filename').val(''); $('#username').val(''); $('#fileext').val(''); $('#sel\_orgid\_{$org\['orgid'\]}').val(''); $('#orgid\_{$org\['orgid'\]}\_Menu').text('$org\[depart\]'); table.reloadData('table', { where: {type: type}, page: { curr: 1 //重新从第 1 页开始 } }); try { var currentUrl = new URL(window.location.href); if (type) { currentUrl.searchParams.set('type', type); } else { currentUrl.searchParams.delete('type'); } currentUrl.searchParams.delete('filename'); currentUrl.searchParams.delete('username'); currentUrl.searchParams.delete('fileext'); history.pushState(null, null, currentUrl.toString()); } catch (e) {} }); ``` -------------------------------- ### executedynamisc_search function Source: https://github.com/zyx0814/dzzoffice/blob/master/dzz/explorer/template/mygroup.htm Reloads the 'mygroup' table with search parameters from input fields and resets to first page. ```javascript executedynamisc_search() { search_data.search = $('#mygroupsearch').val(); search_data.startdate = $('#selectDate').val(); search_data.enddate = $('#selectDate1').val(); layuiModules.table.reloadData('mygroup', { initSort: { field: search_data.sort, type: search_data.order }, where: search_data, page: { curr: 1 } }); } ``` -------------------------------- ### Search button click reloads table with filters Source: https://github.com/zyx0814/dzzoffice/blob/master/dzz/share/template/share.htm Binds a click event to '#search-btn' that reloads the table with current filter values and resets to page 1. ```JavaScript // 搜索按钮功能 $(document).on('click', '#search-btn', function() { table.reloadData('table', { where: {type: $('#filetype').val(), keyword: $('#keyword').val(),username:$('#username').val()}, page: { curr: 1 //重新从第 1 页开始 } }); }); ``` -------------------------------- ### jQuery search input focus, blur, keyup, and clear handlers Source: https://github.com/zyx0814/dzzoffice/blob/master/admin/appmarket/template/lyear/lyear_header_search.htm Handles search input styling and clear button visibility. On focus, adds 'focus' class to the closest '.input-search' container and shows '#emptysearchcondition' if the input is not empty. On blur, removes the class and hides the clear button if the input is empty. The keyup handler shows the clear button when typing. Clicking the clear button resets the input, submits the form, and hides itself. ```javascript jQuery('#searchval').focus(function (e) {//头部搜索框变颜色 jQuery(this).closest('.input-search').addClass('focus'); if(this.value!='') jQuery('#emptysearchcondition').show(); }); jQuery('#searchval').blur(function (e) {//失去焦点时 jQuery(this).closest('.input-search').removeClass('focus'); if(this.value=='') jQuery('#emptysearchcondition').hide(); }); jQuery('#searchval').keyup(function (e) {//失去焦点时 if(this.value!='') jQuery('#emptysearchcondition').show(); }); jQuery('#emptysearchcondition').on('click',function(){ jQuery('#searchval').val(''); jQuery('#searchval').closest('form').submit(); jQuery('#emptysearchcondition').hide(); return false; }); ``` -------------------------------- ### Check status button functionality Source: https://github.com/zyx0814/dzzoffice/blob/master/admin/systemlog/template/list.htm Enables or disables the 'getCheckDataBtn' button based on whether any rows are selected in the table. Adds or removes the 'layui-btn-disabled' class accordingly. ```JavaScript function checkStatusBtn() { var checkStatus = table.checkStatus('table'); var checkedCount = checkStatus.data.length; var getCheckDataBtn = document.getElementById('getCheckDataBtn'); if(checkedCount > 0) { getCheckDataBtn.removeAttribute('disabled'); getCheckDataBtn.classList.remove('layui-btn-disabled'); } else { getCheckDataBtn.setAttribute('disabled', 'disabled'); getCheckDataBtn.classList.add('layui-btn-disabled'); } } ``` -------------------------------- ### File extension filter button click handler Source: https://github.com/zyx0814/dzzoffice/blob/master/dzz/filemanage/template/list.htm Handles clicks on file extension filter buttons, updating the table reload with the selected file extension and updating the URL search parameters. ```JavaScript } else { currentUrl.searchParams.delete('fileext'); } history.pushState(null, null, currentUrl.toString()); } catch (e) {} }); ``` -------------------------------- ### Reset button clears filters and reloads table Source: https://github.com/zyx0814/dzzoffice/blob/master/dzz/share/template/share.htm Clears the username, keyword, and filetype input fields, then reloads the table with empty search parameters and resets to page 1. ```JavaScript // 重置按钮功能 $('#refreshsearch').click(function() { // 清空表单内容 $('#username').val(''); $('#keyword').val(''); $('#filetype').val(''); table.reloadData('table', { where: {}, // 清空搜索参数 page: { curr: 1 //重新从第 1 页开始 } }); }); ``` -------------------------------- ### Enable or disable action buttons based on row selection Source: https://github.com/zyx0814/dzzoffice/blob/master/dzz/share/template/share.htm Checks if any rows are selected in the table. If so, enables the buttons with IDs 'getCheckDataBtn', 'deletebtn', 'forbiddenbtn', 'allowbtn'; otherwise disables them and adds the 'layui-btn-disabled' class. ```JavaScript function checkStatusBtn() { var checkStatus = table.checkStatus('table'); var isChecked = checkStatus.data.length > 0; var buttonIds = \['getCheckDataBtn', 'deletebtn', 'forbiddenbtn', 'allowbtn'\]; buttonIds.forEach(function(btnId) { var btn = document.getElementById(btnId); if (btn) { if (isChecked) { btn.removeAttribute('disabled'); btn.classList.remove('layui-btn-disabled'); } else { btn.setAttribute('disabled', 'disabled'); btn.classList.add('layui-btn-disabled'); } } }); } ``` -------------------------------- ### selorg.add: Add selected organizations to control Source: https://github.com/zyx0814/dzzoffice/blob/master/dzz/orguser/template/detail_org.htm Adds organization buttons to the specified control, skipping duplicates. Uses icon rendering and appends a remove button. Calls selorg.set to update the hidden input. ```JavaScript var selorg={}; //添加 selorg.add=function(ctrlid,vals){ var html=''; var pregmatch = /^dzz(.+?)/; for(var i in vals){ if(jQuery('#'+ctrlid+'\_sl\_'+vals[i].orgid).length){ continue; } html+='