RichFileManager配置Json错误

时间:2018-02-07 12:53:50

标签: php json

我一直在尝试使用Rich file Manager,但我在浏览器控制台中遇到以下错误时陷入初始加载状态;我不明白为什么也找不到关于这个问题的任何文件。 RFM文件夹位于cc/admin/RichFilemanager

json: E_INVALID_PAR_TYPE: {"expected":"Plain Object","name":"json","value":"{\n  \"main\": {\n    \"en\": {\n      \"identity\": {\n        \"version\": {\n          \"_number\": \"$Revision: 13744 $\",\n          \"_cldrVersion\": 

这是我的filemanager.init.js,它具有github的默认配置:

$('.fm-container').richFilemanager({
// options for the plugin initialization step and callback functions, see:
// https://github.com/servocoder/RichFilemanager/wiki/Configuration-options#plugin-parameters

baseUrl: '/cc/admin/RichFilemanager',

callbacks: {
beforeCreateImageUrl: function (resourceObject, url) {
    return url += 'modified=ImageUrl';
},
beforeCreatePreviewUrl: function (resourceObject, url) {
    return url += '&modified=previewUrl';
},
beforeSelectItem: function (resourceObject, url) {
    return url += '&modified=selectItem';
},
afterSelectItem: function (resourceObject, url) {
    // example on how to set url into target input and close bootstrap modal window
    // assumes that filemanager is opened via iframe, which is at the same domain as parent
    // https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy
    $('#target-input', parent.document).val(url);
    $('#modal', parent.document).find('.close').click();
},
beforeSetRequestParams: function (requestMethod, requestParams) {
    // add "jwt" parameter with "your_token" value to both GET and POST requests
    if (requestMethod === 'POST' && $.isArray(requestParams)) { // form parameters
        requestParams.push({name: "jwt", value: "your_token"});
    } else {
        requestParams.jwt = 'your_token';
    }
    return requestParams;
},
beforeSendRequest: function (requestMethod, requestParams) {
    // prevent all GET requests that lack "jwt" request parameter
    if (requestMethod === 'GET' && requestParams.jwt === undefined) {
        return false;
    }
    return true;
}
  }
});

1 个答案:

答案 0 :(得分:0)

这似乎不像是一个bug,而更像是cldr lib中JS coreLoad函数的一个缺陷:

    var coreLoad = function( Cldr, source, jsons ) {
    var i, j, json;

    validatePresence( jsons[ 0 ], "json" );

    // Support arbitrary parameters, e.g., `Cldr.load({...}, {...})`.
    for ( i = 0; i < jsons.length; i++ ) {

        // Support array parameters, e.g., `Cldr.load([{...}, {...}])`.
        json = alwaysArray( jsons[ i ] ); /* here where the problem starts */

        for ( j = 0; j < json.length; j++ ) {
            validateTypePlainObject( json[ j ], "json" );
            source = jsonMerge( source, json[ j ] );
            coreSetAvailableBundles( Cldr, json[ j ] );
        }
    }

    return source;
};

在此注释行中,由于转义和特殊字符\n\" ...等,json被读为字符串而不是json对象,您需要使用以下命令更改json = alwaysArray( jsons[ i ] ) json = alwaysArray( jsons[ i ] ).map(e => JSON.parse(e)),问题在cldr.js的第517行显示。

我希望最好的帮助是Aggawa。