### Installation Template Structure Source: https://github.com/dayrui/xunruicms/blob/master/dayrui/Fcms/View/install/3.html Basic template tags used for rendering the installation header, footer, and error handling logic. ```html {template "install/header.html"} {dr_lang('正在安装数据结构')} {if $error} {nl2br($error)} {else} {dr_lang('正在执行安装程序')} ``` ```html {/if} {if $error} [{dr_lang('返回上一步')}]({$pre_url}) {/if} {template "install/footer.html"} ``` -------------------------------- ### Handle Update and Installation Processes Source: https://github.com/dayrui/xunruicms/blob/master/dayrui/Fcms/View/cloud_todo_update.html Functions to manage the file download progress and trigger the installation process via AJAX requests. ```javascript ) { $('#dr_check_html').append('

'); dr_checking_install(); } is_ok_lock = 1; } else { $('#dr_check_html').append(json.msg); $('#dr_check_button_ing').html(' 下载进度 '+json.code+'%'); } } }, error: function(HttpRequest, ajaxOptions, thrownError) { dr_ajax_alert_error(HttpRequest, this, thrownError); } }); }, 1000); } function dr_checking_install() { $('#dr_check_html').html(""); $('#dr_check_result').html($('#dr_check_ing').html()); $('#dr_check_div').show(); $('#dr_check_result').show(); $('#dr_check_reing').remove(); $('#dr_check_button_ing').addClass('blue'); $('#dr_check_button_ing').removeClass('red'); $('#dr_check_button_ing').html(' 更新中'); $('#dr_check_html').append('

'); $.ajax({ type: "GET", dataType: "json", url: "{dr_url('cloud/update_file_install')}&id={$app_id}&ls={$ls}", success: function (json) { if (json.code == 1) { // 升级完成 $('#dr_check_button').html(''); $('#dr_check_html').html('

恭喜你,升级完成,请刷新后台之后再更新后台缓存

'); // 避免多次请求赋值 $('#dr_check_html').attr('id', "test"); $('#dr_check_button').attr('id', "test2"); } else { $('#dr_check_button_ing').html(' 升级失败'); $('#dr_check_button_ing').addClass('red'); $('#dr_check_button_ing').removeClass('blue'); $('#dr_check_button').append(''); $('#dr_check_html').append('

'); } }, error: function(HttpRequest, ajaxOptions, thrownError) { dr_ajax_alert_error(HttpRequest, this, thrownError); } }); } ``` -------------------------------- ### Handle Installation Errors and Display Results Source: https://github.com/dayrui/xunruicms/blob/master/dayrui/Fcms/View/install/4.html This template logic handles the display of installation results. It shows error messages if the installation failed or success messages with login details if it succeeded. Use this to provide user feedback after installation attempts. ```html {template "install/header.html"} {dr_lang('安装结果')} {if $error} {nl2br($error)} {else} {dr_lang('安装完成')} {dr_lang('账号')}:{$data.username} {dr_lang('密码')}:{$data.password} [{dr_lang('登录项目后台')}]({$admin}.php?c=login) {/if} {if $error} [{dr_lang('返回上一步')}]({$pre_url}) {/if} {template "install/footer.html"} ``` -------------------------------- ### AJAX Installation Script Source: https://github.com/dayrui/xunruicms/blob/master/dayrui/Fcms/View/install/3.html JavaScript function to handle the sequential installation of data via AJAX requests. ```javascript $(function(){ dr_ajax2ajax(1); }); function dr_ajax2ajax(page) { $.ajax({ type: "GET", dataType: "json", url: "{$do_url}&page="+page, success: function (json) { $('#dr_check_html').append("

"+json.msg+"

"); document.getElementById('dr_check_html').scrollTop = document.getElementById('dr_check_html').scrollHeight; if (json.code == 0) { $('#dr_check_html').append("

出现故障:"+json.msg+"

"); $('#dr_error_html').show(); return; } else { if (json.data.page == 99 ) { // 完成 var loading = layer.load(2, { shade: [0.3,'#fff'], //0.1透明度的白色背景 time: 100000000 }); window.location.href = "{$next_url}&protocol="+document.location.protocol; } else { dr_ajax2ajax(json.data.page); } } }, error: function(HttpRequest, ajaxOptions, thrownError) { dr_ajax_alert_error(HttpRequest, this, thrownError);; $('#dr_check_html').append("

出现故障:"+HttpRequest.responseText+"

"); } }); } ``` -------------------------------- ### Include Installation Templates Source: https://github.com/dayrui/xunruicms/blob/master/dayrui/Fcms/View/install/0.html Template tags used to include the header and footer files in the installation process. ```html {template "install/header.html"} ``` ```html {template "install/footer.html"} ``` -------------------------------- ### JavaScript for Installation Form Submission Source: https://github.com/dayrui/xunruicms/blob/master/dayrui/Fcms/View/install/2.html Handles the submission of the installation form using AJAX. It serializes form data and sends it to the server. Displays success messages or alerts for errors. Includes error handling for network issues. ```javascript function dr_next_install() { var loading = layer.load(2, { shade: [0.3, '#fff'], //0.1透明度的白色背景 time: 100000000 }); $('#dr_loading').show(); $.ajax({ type: "POST", dataType: "json", url: '{$do_url}', data: $("#myform").serialize(), success: function(json) { if (json.code == 1) { window.location.href = json.msg; } else { layer.close(loading); layer.alert(json.msg); $('#dr_loading').hide(); } }, error: function(HttpRequest, ajaxOptions, thrownError) { layer.closeAll('loading'); $('#dr_loading').hide(); layer.open({ type: 1, title: "{dr_lang('系统故障')}", fix: true, shadeClose: true, shade: 0, area: ['50%', '50%'], content: "
" + HttpRequest.responseText + "
" }); } }); } ``` -------------------------------- ### Initiate Loading Indicator for Installation Source: https://github.com/dayrui/xunruicms/blob/master/dayrui/Fcms/View/install/4.html This JavaScript function `dr_next_install` is designed to display a loading indicator using the `layer.load` method. It's intended to be called during the installation process to provide visual feedback to the user. The loading indicator is configured with a semi-transparent white background and a long timeout. ```javascript function dr_next_install() { var loading = layer.load(2, { shade: [0.3,'#fff'], //0.1透明度的白色背景 time: 100000000 }); } ``` -------------------------------- ### Handling Application Installation and Uninstallation in Xunruicms Source: https://github.com/dayrui/xunruicms/blob/master/dayrui/Fcms/View/cloud_app.html Provides buttons for installing, uninstalling, or deleting applications. It uses JavaScript functions like dr_load_ajax and dr_install_app for these actions, with conditional logic for different app types. ```html {if $t.install} {if $t.menu} {if count($t.menu) > 1} {dr_lang('进入')} {loop $t.menu $b}* [{dr_lang($b.name)}]({$b.url}) {/loop} {else} [{dr_lang('进入')}]({$t['menu'][0]['url']}) {/if} {/if} [{dr_lang('卸载')}](javascript:dr_load_ajax ('{dr_lang($dir == 'module' ? '卸载建站系统会清空所有栏目及其内容,确定要卸载吗?' : '确定卸载此程序吗?' )}', '{dr_url ('cloud/uninstall', ['dir'=>$dir] )}', 1 );) {else} [{dr_lang('安装')}](javascript:{if !$t.mtype && $t.ftype=='module'}dr_install_module_select ('{dr_url ('cloud/install', ['dir'=>$dir] )}'){else}dr_install_app ('{dr_url ('cloud/install', ['dir'=>$dir] )}'){/if};) [{dr_lang('删除')}](javascript:dr_iframe ('{dr_lang ('删除提示' )}', '{dr_url ('cloud/app_delete', ['dir'=>$dir] )}', '600px', '320px' );) {/if} [{dr_lang('文件')}](javascript:dr_iframe_show ('{dr_lang ('文件浏览' )}', '{dr_url ('cloud/app_file', ['dir'=>$dir] )}', '600px', '320px' );) ``` -------------------------------- ### Initiate Backup and Check Update Source: https://github.com/dayrui/xunruicms/blob/master/dayrui/Fcms/View/cloud_todo_update.html Starts the backup process and then proceeds to check for updates. Handles success and failure scenarios for the backup API call. ```javascript $(function () { dr_checking(); }); function dr_checking() { $('#dr_check_html').html(""); $('#dr_check_result').html($('#dr_check_ing').html()); $('#dr_check_div').show(); $('#dr_check_result').show(); $('#dr_check_reing').remove(); $('#dr_check_button_ing').addClass('blue'); $('#dr_check_button_ing').removeClass('red'); $('#dr_check_button_ing').html(' 准备中'); $('#dr_check_html').append('

'); $.ajax({ type: "GET", dataType: "json", url: "{dr_url('cloud/update_backup')}&id={$app_id}&dir={$dir}&is_bf={$is_bf}", success: function (json) { if (json.code == 0) { $('#dr_check_button_ing').html(' 备份失败'); $('#dr_check_button_ing').addClass('red'); $('#dr_check_button_ing').removeClass('blue'); $('#dr_check_button').append(''); $('#dr_check_html').append('

'); $('#dr_check_html').append('

'); } else { $('#dr_check_html').append('

'); dr_do_check(); } }, error: function(HttpRequest, ajaxOptions, thrownError) { dr_ajax_alert_error(HttpRequest, this, thrownError); } }); } ``` -------------------------------- ### API Endpoint Examples Source: https://context7.com/dayrui/xunruicms/llms.txt Illustrates common API endpoint usage patterns for file uploads, downloads, and base64 image uploads. Also shows how to return JSON or message pages from controllers. ```php // 文件上传API接口调用 // POST /index.php?s=api&c=file&m=upload // 参数: file_data (文件), fid (字段ID), siteid (站点ID) // 下载文件API // GET /index.php?s=api&c=file&m=down&id=123&name=文件名 // Base64图片上传 // POST /index.php?s=api&c=api&m=upload_base64_image // 参数: file (base64编码的图片数据) ``` ```php // 控制器中返回JSON \Phpcmf\Service::C()->_json(1, '操作成功', $data); \Phpcmf\Service::C()->_json(0, '操作失败:参数错误'); // 返回消息页面 \Phpcmf\Service::C()->_msg(1, '保存成功', $redirectUrl); \Phpcmf\Service::C()->_msg(0, '保存失败'); ``` -------------------------------- ### Execute File Download and Monitor Progress Source: https://github.com/dayrui/xunruicms/blob/master/dayrui/Fcms/View/cloud_todo_update.html Initiates the file download and then starts a polling mechanism to check the download progress. Handles download failures and completion. ```javascript function dr_do_cron() { // 开始下载他 $('#dr_check_html').append('

'); $('#dr_check_button_ing').html(' 下载中'); $.ajax({ type: "GET", dataType: "json", url: "{dr_url('cloud/update_file_down')}&id={$app_id}&ls={$ls}&is_update=1", success: function (json) { if (json.code == 0) { $('#dr_check_button_ing').html(' 下载失败'); $('#dr_check_button_ing').addClass('red'); $('#dr_check_button_ing').removeClass('blue'); $('#dr_check_button').append(''); $('#dr_check_html').append('

'); clearInterval(interval_id); } else { } }, error: function(HttpRequest, ajaxOptions, thrownError) { dr_ajax_alert_error(HttpRequest, this, thrownError); } }); // 检测下载结果 var is_ok_lock = 0; var is_jd = 0; var is_count = 0; var interval_id = window.setInterval(function() { $.ajax({ type: "GET", dataType: "json", url: "{dr_url('cloud/update_file_check')}&id={$app_id}&ls={$ls}&is_count="+is_count+"&is_jd="+is_jd, success: function (json) { is_count++; document.getElementById('dr_check_html').scrollTop = document.getElementById('dr_check_html').scrollHeight; is_jd = json.code; if (json.code == 0) { $('#dr_check_button_ing').html(' 下载失败'); $('#dr_check_button_ing').addClass('red'); $('#dr_check_button_ing').removeClass('blue'); $('#dr_check_button').html(''); $('#dr_check_html').append('

'); clearInterval(interval_id); } else { $('#dr_check_result .progress-bar-success').attr('style', 'width:'+json.code+'%'); if (json.code == 100) { // 下在完成 clearInterval(interval_id); //dr_checking_install(); if (is_ok_lock == 0 ``` -------------------------------- ### Installation Agreement Countdown Timer Source: https://github.com/dayrui/xunruicms/blob/master/dayrui/Fcms/View/install/0.html A JavaScript timer that disables the agreement button for 10 seconds to ensure the user reads the terms. ```javascript var Seconds = 10; var setIntervalID; function ok() { var ok = $("#ok"); if (Seconds <= 0) { ok.html("同意协议"); ok.attr('href', '{$next_url}'); ok.attr('disabled', false); clearInterval(setIntervalID); } else { ok.html("请仔细阅读协议还剩下(" + Seconds + ")秒"); } Seconds--; } setIntervalID=setInterval("ok()", 1000); ``` -------------------------------- ### XunRuiCMS Template Syntax - Theme Path Source: https://github.com/dayrui/xunruicms/blob/master/dayrui/Fcms/View/cloud_update.html Example of referencing the theme path in XunRuiCMS templates. ```html {THEME_PATH}assets/images/loading-0.gif ``` -------------------------------- ### Initiate Core File Comparison Source: https://github.com/dayrui/xunruicms/blob/master/dayrui/Fcms/View/cloud_bf.html Starts the process of comparing local core files with server versions. It disables the button during the check and updates its status. This function makes an AJAX call to fetch the count of differences. ```javascript function dr_checking() { $('#dr_check_button').attr('disabled', true); $('#dr_check_button').html(' 准备中'); $('#dr_check_bf').html(""); $('#dr_check_html').html("正在准备中"); $.ajax({ type: "GET", dataType: "json", url: "{dr_url('cloud/bf_count')}", success: function (json) { if (json.code == 0) { dr_tips(0, json.msg); $('#dr_check_div').show(); $('#dr_check_result').show(); $('#dr_check_button').attr('disabled', false); $('#dr_check_button').html(' 重新对比'); $('#dr_check_html').append('

'+json.msg+'

'); } else { $('#dr_check_bf').html(""); $('#dr_check_html').html(""); $('#dr_check_result').html($('#dr_check_ing').html()); $('#dr_check_div').show(); $('#dr_check_result').show(); $('#dr_check_button').attr('disabled', true); $('#dr_check_bf').append('

本程序下载时间:{$cms_version.downtime}

'); $('#dr_check_bf').append('

服务端最近更新时间:'+json.msg+'

'); dr_ajax2ajax(1); } }, error: function(HttpRequest, ajaxOptions, thrownError) { dr_ajax_alert_error(HttpRequest, this, thrownError); } }); } ``` -------------------------------- ### Registering Custom Hooks Source: https://context7.com/dayrui/xunruicms/llms.txt Demonstrates how to register custom event listeners for system hooks within a plugin's configuration file. Includes examples for logging, data modification, and template variable injection. ```php // 在插件的 Config/Hooks.php 中注册钩子 // 文件路径: /App/YourApp/Config/Hooks.php table('login_log')->insert([ 'uid' => $member['id'], 'ip' => \Phpcmf\Service::L('input')->ip_address(), 'time' => time() ]); }); // 注册内容保存前钩子 \Phpcmf\Hooks::on('content_save_before', function(&$data, $id) { // 自动添加关键词 if (empty($data['keywords'])) { $data['keywords'] = dr_strcut($data['title'], 20); } }); // 注册模板显示钩子 \Phpcmf\Hooks::on('cms_view_display', function(&$options, $tplName, $dir) { // 添加全局模板变量 $options['global_notice'] = '系统公告内容'; }); // 常用系统钩子列表: // cms_index - 网站首页加载时 // cms_view - 模板加载之后 // cms_view_display - 模板加载之前 // cms_view_end - 模板结束之后 // member_login_after - 会员登录之后 // content_save_before - 内容保存之前 // content_save_after - 内容保存之后 // check_upload_auth - 验证上传权限 // down_file - 文件下载时 // image_edit - 图片编辑时 ``` -------------------------------- ### XunRuiCMS Template Syntax - Loop Source: https://github.com/dayrui/xunruicms/blob/master/dayrui/Fcms/View/cloud_update.html Example of a 'loop' construct in XunRuiCMS templates, used for iterating over a list. ```html {loop $list $dir $t} {/loop} ``` -------------------------------- ### File and Time/Date Helper Functions Source: https://context7.com/dayrui/xunruicms/llms.txt Functions for handling file operations like getting URLs, generating thumbnails, and extracting images, as well as formatting timestamps. ```php uid) { \Phpcmf\Service::C()->_json(0, '请先登录'); } // 获取请求参数 $id = (int)\Phpcmf\Service::L('input')->get('id'); $keyword = \Phpcmf\Service::L('input')->post('keyword', true); // 数据查询 $data = \Phpcmf\Service::M()->table('content') ->where('status', 1) ->where('uid', $this->uid) ->order_by('id', 'desc') ->getAll(10); // 返回JSON响应 \Phpcmf\Service::C()->_json(1, '获取成功', [ 'list' => $data, 'total' => count($data) ]); } } ``` -------------------------------- ### Loop Configuration Options Source: https://github.com/dayrui/xunruicms/blob/master/dayrui/Fcms/View/site_config.html Iterates through available themes, languages, and template paths for selection. ```php {loop $theme $t} {$t} {/loop} ``` ```php {loop $lang $t} {$t} {/loop} ``` ```php {loop $template_path $t} {$t} {/loop} ``` -------------------------------- ### Initialize Site Configuration UI Source: https://github.com/dayrui/xunruicms/blob/master/dayrui/Fcms/View/site_config.html Handles the visibility of site status and index generation settings based on data values. ```javascript {template "header.html"} $(function() { {if empty($data['SITE_CLOSE'])} $('.dr_close_msg').hide(); {else} $('.dr_close_msg').show(); {/if} {if empty($data['SITE_INDEX_HTML'])} $('.dr_index_time').hide(); {else} $('.dr_index_time').show(); {/if} dr_theme({$is_theme}); }); function dr_theme(id) { if (id == 1) { $("#dr_theme_html").html($("#dr_web").html()); } else { $("#dr_theme_html").html($("#dr_local").html()); } } ``` -------------------------------- ### XunRuiCMS Template Syntax - Conditional Source: https://github.com/dayrui/xunruicms/blob/master/dayrui/Fcms/View/cloud_update.html Example of an 'if' conditional statement in XunRuiCMS templates. ```html {if $t.id} {/if} ``` -------------------------------- ### Initialize Navigation and Content Source: https://github.com/dayrui/xunruicms/blob/master/dayrui/Fcms/View/iframe_content.html Sets up initial navigation state and loads content when the DOM is ready. Handles window resizing for layout adjustments. ```javascript function McLink(dir, url) { // 延迟提示 //var admin_loading = layer.load(2, { time: 10000 }); $('.iframe_menu_a a').removeClass('on'); $('#iframe_menu_a_'+dir+' a').addClass('on'); //$('.my-left-content li span').removeClass('selected'); //$('.my-left-content li').removeClass('active open'); /// $('.my-left-content2 li span').removeClass('selected'); //$('.my-left-content2 li').removeClass('active open'); //$('.left-content-'+dir+' ').addClass('active open'); // $('.left-content-'+dir+' span').addClass('selected'); $("#module-content-right").attr('src', url); $("#module-content-right").attr("url", url); } ``` ```javascript function wSize(){ var str=getWindowSize(); var strs= new Array(); //定义一数组 strs=str.toString().split(","); //字符分割 var heights = strs[0]-$('.page-bar').height(),Body = $('body'); $('#module-content-right').height(heights); } ``` ```javascript var getWindowSize = function(){ return ["Height","Width"].map(function(name){ return window["inner"+name] || document.compatMode === "CSS1Compat" && document.documentElement[ "client" + name ] || document.body[ "client" + name ] }); } ``` ```javascript window.onload = function (){ if(!+"\\v1" && !document.querySelector) { // for IE6 IE7 document.body.onresize = resize; } else { window.onresize = resize; } function resize() { wSize(); return false; } } ``` ```javascript $(function(){ wSize(); document.documentElement.style.overflowY = 'hidden' }); ``` -------------------------------- ### XunRuiCMS Template Syntax - Language String Source: https://github.com/dayrui/xunruicms/blob/master/dayrui/Fcms/View/cloud_update.html Example of retrieving a language string in XunRuiCMS templates using 'dr_lang'. ```html {dr_lang('检测版本')} ``` -------------------------------- ### XunRuiCMS Template Syntax - URL Generation Source: https://github.com/dayrui/xunruicms/blob/master/dayrui/Fcms/View/cloud_update.html Example of generating a URL within XunRuiCMS templates using the 'dr_url' function. ```html {dr_url('cloud/log_show')} ``` -------------------------------- ### Display Save Button Source: https://github.com/dayrui/xunruicms/blob/master/dayrui/Fcms/View/site_param.html This snippet displays a 'Save' button, using a language function to get the localized string for '保存'. ```html {dr_lang('保存')} ``` -------------------------------- ### Locate Project Files Source: https://github.com/dayrui/xunruicms/blob/master/template/pc/default/home/index.html File paths for the default template view and the home controller. ```text xunruicms/template/pc/default/home/index.html ``` ```text xunruicms/dayrui/Fcms/Control/Home.php ``` -------------------------------- ### Open Layer for Backup Source: https://github.com/dayrui/xunruicms/blob/master/dayrui/Fcms/View/cloud_update.html Opens a layer for program backup. Requires the 'layer' library. The success callback is used for backend permission verification. ```javascript function dr_open_backup(url) { layer.open({ type: 2, title: '备份程序', scrollbar: false, resize: true, maxmin: true, shade: 0, area: ['80%', '80%'], success: function(layero, index){ dr_iframe_error(layero, index, 0); }, content: url }); } ``` -------------------------------- ### Conditional Logic and Loops Source: https://github.com/dayrui/xunruicms/blob/master/dayrui/Fcms/View/role_auth.html Demonstrates conditional checks for module authorization and looping through menu data. ```html {if $module_auth}* [{dr_lang('内容权限')}](#tab_1) {/if} ``` ```html {php $uris=[];} {loop $menu_data $t} {/loop} ``` ```html {if $t.uri} {php $uris[]=$t.uri;} {/if} ``` ```html {php $ikey=0;} {loop $module_auth $dir $t} {loop $t.auth $uri $name} {if !dr_in_array($uri.'index', $uris)} {php $ikey++;} {/if} {/loop} ``` -------------------------------- ### Test Attachment Directory Source: https://github.com/dayrui/xunruicms/blob/master/dayrui/Fcms/View/site_image.html Tests the attachment directory by making an AJAX GET request. Displays tips based on the JSON response. ```javascript function dr_test_domain_dir(id) { $.ajax({ type: "GET", dataType:"json", url: admin_file+"?c=api&m=test_attach_dir&v="+encodeURIComponent($("#"+id).val()), success: function(json) { dr_tips(json.code, json.msg, -1); }, error: function(HttpRequest, ajaxOptions, thrownError) { dr_ajax_admin_alert_error(HttpRequest, ajaxOptions, thrownError) } }); } ``` -------------------------------- ### Preview Interface Configuration and Styles Source: https://github.com/dayrui/xunruicms/blob/master/dayrui/Fcms/View/api_demo.html Defines the layout, animation, and variables for the preview interface. ```html {dr_lang('预览')} var admin_file = '{SELF}';var is_min = '{$is_min}'; var is_oemcms = '{IS_OEM_CMS}'; var is_mobile_cms = '{$is_mobile}'; var is_admin = '{if dr_in_array(1, $admin.roleid)}1{else}2{/if}'; body { min-height: 100%; padding-top: 0; } .navbar-preview { height: 50px; padding-left: 0; padding-right: 0; margin-bottom: 0; border-radius: 0; position: fixed; top: 0; right: 0; left: 0; z-index: 1030; background: #40aae3; background: linear-gradient(270deg, #40aae3) center / cover; background-size: 800% 800%; -webkit-animation: navbaranimation 30s ease infinite; -moz-animation: navbaranimation 30s ease infinite; animation: navbaranimation 30s ease infinite; } .navbar-preview a { color: #fff; } .navbar-preview .col-xs-6 { height: 50px; line-height: 50px; } .iframe-preview { position: absolute; height: calc(100% - 55px); width: 100%; border: none; margin-top: 50px; } .iframe-preview-mobile { width: 400px; left: 50%; transform: translateX(-50%); box-shadow: 0 0 10px rgba(0, 0, 0, .085); } .nav-link { display: block; padding: .5rem 1rem; } .nav-preview { padding-left: 0; margin: 0; list-style: none; text-align: center; } .nav-preview li { display: inline; } .nav-preview li > a, .nav-preview li > span { display: inline-block; padding: 0 14px; font-size: 16px; } .nav-preview .popover-title { padding: 5px 14px; line-height: 28px; } @-webkit-keyframes navbaranimation { 0% { background-position: 0% 50% } 50% { background-position: 100% 50% } 100% { background-position: 0% 50% } } @-moz-keyframes navbaranimation { 0% { background-position: 0% 50% } 50% { background-position: 100% 50% } 100% { background-position: 0% 50% } } @keyframes navbaranimation { 0% { background-position: 0% 50% } 50% { background-position: 100% 50% } 100% { background-position: 0% 50% } } {if $demo == 'pc'} {else} {/if} ``` -------------------------------- ### Open Layer for Version Log Source: https://github.com/dayrui/xunruicms/blob/master/dayrui/Fcms/View/cloud_update.html Opens a layer to display version logs. Requires the 'layer' library. The content is dynamically generated using a URL with ID and version parameters. ```javascript function dr_show_log(id, v) { layer.open({ type: 2, title: '版本日志', scrollbar: false, resize: true, maxmin: true, shade: 0, area: ['80%', '80%'], content: '{dr_url("cloud/log_show")}&id='+id+'&version='+v }); } ``` -------------------------------- ### Field Iteration and Search Configuration Source: https://github.com/dayrui/xunruicms/blob/master/dayrui/Fcms/View/table_config.html Loops through available fields to display search and list configuration options. ```html {loop $field $t} {if dr_is_admin_search_field($t)} {dr_lang($t.name)} {/if} {/loop} ``` ```html {loop $field $n $t} {if $t.fieldname} {/if} {/loop} ``` -------------------------------- ### Login Background Initialization Source: https://github.com/dayrui/xunruicms/blob/master/dayrui/Fcms/View/login.html PHP and jQuery logic to initialize a background image slider for the login page when OEM mode is enabled. ```php jQuery(document).ready(function() { $.backstretch([ {implode(',', $bg)} ], { fade: 1000, duration: 8000 } ); }); ``` -------------------------------- ### Code Protection in XunRuiCMS Templates Source: https://context7.com/dayrui/xunruicms/llms.txt Prevents template tags within the `{code}` block from being parsed or rendered. Useful for displaying code examples or literal tag syntax. ```html {code} {$variable} 这里的标签不会被解析 {/code} ``` -------------------------------- ### Render Site Configuration Form Source: https://github.com/dayrui/xunruicms/blob/master/dayrui/Fcms/View/site_config.html Displays the main configuration form and dynamic server status information. ```php {$form} ``` ```php {php echo $data['SITE_CLOSE_MSG'] ? $data['SITE_CLOSE_MSG'] : '网站升级中....';} ``` ```php {if $run_time} {dr_lang('最近自动执行时间为:%s', $run_time)} {else} {dr_lang('当前服务器没有设置自动任务脚本')} {/if} ``` ```php {dr_date(time(), 'Y-m-d H:i:s')} ``` -------------------------------- ### Triggering System Hooks Source: https://context7.com/dayrui/xunruicms/llms.txt Shows how to trigger system events using the Hooks class, both for actions that don't require a return value and those that do (callback). ```php // 触发钩子(不需要返回值) \Phpcmf\Hooks::trigger('member_login_after', $memberData); \Phpcmf\Hooks::trigger('content_save_before', $data, $id); // 触发钩子(需要回调返回值) $result = \Phpcmf\Hooks::trigger_callback('check_upload_auth', $member, $error); if ($result && isset($result['code']) && !$result['code']) { // 钩子返回了错误 echo $result['msg']; } ``` -------------------------------- ### Site, Category, and Linkage Data Helpers Source: https://context7.com/dayrui/xunruicms/llms.txt Retrieve site configuration, category data, and linkage menu information using these helper functions. ```php uid('username'); // 通过用户名获取UID // 获取用户名 $username = $memberModel->username($uid); // 通过UID获取用户名 $author = $memberModel->author($uid); // 获取作者名(游客返回"游客") // 获取用户信息 $member = $memberModel->get_member($uid); // 完整会员信息 $info = $memberModel->member_info($uid); // 基础信息 // 获取用户联系方式 $phone = $memberModel->phone($uid); // Cookie管理 $uid = $memberModel->member_uid(); // 从Cookie获取当前登录UID // 保存登录Cookie $memberModel->save_cookie($memberData, 1); // 1表示记住登录 // 验证Cookie有效性 $valid = $memberModel->check_member_cookie($member); // 获取第三方登录信息 $oauth = $memberModel->oauth($uid); // 初始化会员(登录后调用) $memberModel->init_member($member); // 清除会员缓存 $memberModel->clear_cache($uid); ``` -------------------------------- ### Initialize jQuery File Upload Source: https://github.com/dayrui/xunruicms/blob/master/dayrui/Fcms/View/attachment_admin.html Configures the file upload plugin with parameters for size, extension validation, and progress tracking. ```javascript $(function() { $("#fileupload").fileupload({ disableImageResize: false, autoUpload: true, maxFileSize: "{$upload.param.size}", url: "{$upload.url}", dataType: "json", acceptFileTypes: "{$upload.param.exts}", maxChunkSize: '{$upload.param.chunk}', progressall: function (e, data) { // 上传进度条 all var progress = parseInt(data.loaded / data.total * 100, 10); $(".fileupload-progress").show(); $(".fileupload-progress").html(""+progress+"%"); }, add: function (e, data) { $(".fileupload-progress").hide(); data.submit(); }, done: function (e, data) { var count = parseInt($('#dr_file_count').val()) + 1; $('#dr_file_count').val(count); $(".fileupload-progress").hide(); if (data.result.code > 0) { dr_tips(data.result.code, data.result.msg); if (count == data.originalFiles.length) { setTimeout("window.location.href = '{$upload.back}'", 2000); } //setTimeout("window.location.href = '{$field.back}'", 2000); } else { dr_tips(data.result.code, data.result.msg, -1); } }, fail: function (e, data) { //console.log(data.errorThrown); dr_tips(0, "系统故障:"+data.errorThrown, -1); layer.closeAll('tips'); $(".fileupload-progress").hide(); }, }); }); ``` -------------------------------- ### AJAX Request for Field Options Source: https://github.com/dayrui/xunruicms/blob/master/dayrui/Fcms/View/field_add.html This JavaScript code makes an AJAX GET request to fetch field-specific options and styles based on the field type, related ID, and application namespace. It's used to dynamically load settings when a field type changes. ```javascript $(function() { set_required({intval($data['setting']['validate']['required'])}); $("#dr_loading").show(); $.ajax({type: "GET",dataType:"json", url: '{dr_url('api/field')}&rand='+Math.random(), data: {type:'{$data["fieldtype"]}','relatedid':'{$rid}', 'relatedname':'{$rname}', 'app':'{$namespace}', 'id':{intval($data.id)}}, success: function(data) { $('#dr_css').html(data.style); $('#dr_option').html(data.option); $("#dr_loading").hide(); App.init(); }, error: function(HttpRequest, ajaxOptions, thrownError) { dr_ajax_alert_error(HttpRequest, this, thrownError); } }); }); ``` -------------------------------- ### XunruiCMS Welcome and Message Section Source: https://github.com/dayrui/xunruicms/blob/master/template/pc/default/home/msg.html Content sections for welcoming users and displaying system messages or prompts. Includes conditional logic for redirect links. ```html 欢迎使用迅睿CMS开源框架 V ============== PHP8高性能·简单易用的免费开源框架 ------------------- 提示信息 ==== {$msg} {if $url} [如果您的浏览器没有自动跳转,请点击这里]({$url}) {else} [\['点击返回上一页'\]]({$backurl}) {/if} ``` -------------------------------- ### Include Template Files Source: https://github.com/dayrui/xunruicms/blob/master/dayrui/Fcms/View/api_login.html Use these tags to include header and footer files in your template. ```html {template "header.html"} ``` ```html {template "footer.html"} ``` -------------------------------- ### Render Template and Form Source: https://github.com/dayrui/xunruicms/blob/master/dayrui/Fcms/View/role_verify.html Include header and footer templates and output the form variable. ```html {template "header.html"} {$form} {loop $verify $v} {$v.name} {loop $rs.role $i $arr} {dr_lang('第%s次审核', $i)} {/loop} {/loop} {template "footer.html"} ```