HEX
Server: nginx/1.28.1
System: Linux 10-41-63-61 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 x86_64
User: www (1001)
PHP: 7.4.33
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: /www/wwwroot//crm.jmfdbn.com/application/addons/util/AddonsBase.php
<?php
// +----------------------------------------------------------------------
// | Yzncms [ 御宅男工作室 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2018 http://yzncms.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 御宅男 <530765310@qq.com>
// +----------------------------------------------------------------------

// +----------------------------------------------------------------------
// | 前台插件类
// +----------------------------------------------------------------------
namespace app\addons\util;

use app\common\controller\Base;

class AddonsBase extends Base
{
    //插件标识
    public $addonName = null;
    //插件基本信息
    protected $addonInfo = null;
    //插件路径
    protected $addonPath = null;

    protected function initialize()
    {
        parent::initialize();
        $this->addonName = \think\Loader::parseName($this->request->controller());
        $this->addonPath = ADDON_PATH . $this->addonName . DIRECTORY_SEPARATOR;
    }

    /**
     * 加载模板输出
     * @access protected
     * @param  string $template 模板文件名
     * @param  array  $vars     模板输出变量
     * @param  array  $config   模板参数
     * @return mixed
     */
    protected function fetch($template = '', $vars = [], $config = [])
    {
        return $this->view->fetch($this->parseAddonTemplateFile($template, $this->addonPath), $vars, $config);
    }

    /**
     * 自动定位模板文件
     * @access private
     * @param  string $template 模板文件规则
     * @param type $addonPath 插件目录
     * @return string
     */
    private function parseAddonTemplateFile($template, $addonPath)
    {
        if (0 !== strpos($template, '/')) {
            $template = str_replace(['/', ':'], DIRECTORY_SEPARATOR, $template);
            if ($this->addonName) {
                if ('' == $template) {
                    // 如果模板文件名为空 按照默认规则定位
                    $template = str_replace('.', DIRECTORY_SEPARATOR, $this->addonName) . DIRECTORY_SEPARATOR . $this->request->action();
                } elseif (false === strpos($template, DIRECTORY_SEPARATOR)) {
                    $template = str_replace('.', DIRECTORY_SEPARATOR, $this->addonName) . DIRECTORY_SEPARATOR . $template;
                }
            }
        } else {
            $template = str_replace(['/', ':'], DIRECTORY_SEPARATOR, substr($template, 1));
        }
        return $addonPath . 'view' . DIRECTORY_SEPARATOR . ltrim($template, '/') . '.html';

    }
}