<?php
use Illuminate\Support\Facades\URL;
use Rvsitebuilder\Wysiwyg\Http\Controllers\Backend\SocialWidgetController;

$cdnURL = config('rvsitebuildercms.cdn');
$baseUrl = URL::to('/');
$widget = new SocialWidgetController();

// check production
if( env('APP_ENV')=='production' ){
    $rvsThemImage = $cdnURL.'/w/theme/uikit/images/';
    $WYS_IMG_URL = $cdnURL.'/w/theme/uikit/images/';
} else {
    $rvsThemImage = URL::to('/vendor/rvsitebuilder/wysiwyg/theme/uikit/images') . '/';
    $WYS_IMG_URL = URL::to('/vendor/rvsitebuilder/wysiwyg/theme/uikit/images') . '/';
}

/**
 * ตัวอย่างการ get $wex = config('wysiwyg.wex')
 * $wex['url']['baseUrl']
 * $wexjson = json_encode($wex);
 * $wexjson->url->basUrl
 */
return [
    'name' => 'Wysiwyg',
    'isWysiwyg' => true,

    //wex = wysiwyg export variable to wysiwyg backend
    'wex' => [
        //ไม่ได้ใช้แล้ว
        'jsonPageStructure' => [],
        'isDirectAdminMode' => '',
        // 'editmode' => true,
        // 'viewmode' => false,

        // append ทีหลัง process หาค่ามา update ที่หลังจาก controller
        'currentPage' => [], // current page data
        'globalSetting' => [], // global meta,js,css
        'allPageDataJSON' => [], //allpage
        'post' => [
            'allPostList' => [],
            'allPost' => []
        ],
        'users' => [
            'USER_EMAIL' => ''
        ],
        'menu' => [
            'left' => [],
            'right' => [],
            'top' => []
        ],
        'blog' => [
            'blog_categories' => [],
            'blog_listscategory' => [],
            'blog_lists' => [],
            'blog_recently' => [],
            'blog_first' => []
        ],
        'page' => [
            'page_onmenu' => [],
            'page_internal' => []
        ],
        'systempage' => [
            'systempage_lists' => [],
            'module_lists' => []
        ],
        'email' => [
            'admin' => [],
            'user' => []
        ],
        'email_config' => [],
        'isDevMode' => '1', //1 เสมอเนื่องจากย้ายจากระบบเดิม เพื่อให้ css/js update เสมอ ไม่ต้องรัน /live/setup.php
        'firstSave' => 0,
        'site' => [
            //update event edit site_brand
            'site_brand' => config('core.db.site_brand')
        ],
        'env' => [
            //get from env default false
            'debug' => env('APP_DEBUG') ? env('APP_DEBUG') : false
        ],
        'url' => [
            'baseUrl' => $baseUrl,
            'rvsThemImage' => $rvsThemImage,
            'WYS_SHOW_URL' => URL::to('/admin/wysiwyg/uikit/show/'),
            'WYS_EMAIL_URL' => URL::to('/admin/wysiwyg/uikit/email/'),
            'SGL_JS_WEBROOT' => $baseUrl . '/',
            'IMAGE_URL' => $baseUrl . '/',
            'MEDIA_URL' => $baseUrl . '/',
            'DOCUMENT_URL' => $baseUrl . '/',
            'LIBRARY_MEDIA_URL' => $baseUrl . '/',
            'WEB_THEME_URL' => $baseUrl,
            'WYS_IMG_URL' => $WYS_IMG_URL,
            'STORAGE_URL' => $baseUrl . '/storage',
        ],
        'cdn' => [
            'cdnURL' => $cdnURL,
            'LIBRARY_URL' => $cdnURL . '/templates/rvs_library',

            'cdnBlockDesign' => $cdnURL . '/service/getdesign.php?name=section',
            'cdnFormDesign' => $cdnURL . '/templates/rvs_library/100/formdesign.html',
            'cdnFormItem' => $cdnURL . '/templates/rvs_library/100/formitem.html',

            'cdnHeaderDesign' => $cdnURL . '/service/getdesign.php?name=header&icon=all',
            'cdnMenuDesign' => $cdnURL . '/service/getdesign.php?name=menu&icon=all',
            'cdnTopmenuDesign' => $cdnURL . '/service/getdesign.php?name=topmenu&icon=all',
            'cdnBannerDesign' => $cdnURL . '/service/getdesign.php?name=banner&icon=all',
            'cdnFooterDesign' => $cdnURL . '/service/getdesign.php?name=footer&icon=all',

            'cdnHeaderDesignEmail' => $cdnURL . '/service/getdesign.php?name=header&email=email&icon=all',
            'cdnBlockDesignEmail' => $cdnURL . '/service/getdesign.php?name=section&email=email',
            'cdnFooterDesignEmail' => $cdnURL . '/service/getdesign.php?name=footer&email=email&icon=all',
        ],
        'route_action' => [
            'routeCommonSaveImage' => URL::to('/admin/wysiwyg/common/saveimage'),
            'routeCommonUploadImage' => URL::to('admin/wysiwyg/common/uploadimage'),
            'routeCommonDeleteImage' => URL::to('admin/wysiwyg/common/deleteimage'),
            'routeCommonDefactImage' => URL::to('admin/wysiwyg/common/defacementimage'),
            'routeCommonBuildimages' => URL::to('admin/wysiwyg/common/buildimagesjson'),

            'routeCommonListDocument' => URL::to('admin/wysiwyg/common/listdocuments'), //ไม่ได้ใช้
            'routeCommonDeleteDocument' => URL::to('admin/wysiwyg/common/deletedocuments'), //ไม่ได้ใช้
            'routeCommonUploadDocument' => URL::to('admin/wysiwyg/common/uploaddocuments'), //ไม่ได้ใช้

            'routeCommonUrl' => URL::to('admin/wysiwyg/common'),
        ],
        'phpconf' => [
            'postMaxSize' => ini_get('post_max_size'), //if function_exist set default
            'maxUploadDocumentFile' => ini_get('upload_max_filesize'),
            'timezone_identifiers_list' => timezone_identifiers_list()
        ],
        'documents' => [
                //ซ้ำกับ backend ด้วย ให้แก้ไขทั้ง 2 ที่
            'documentFileType' => ".gz, .tgz, .bz2, .tbz2, .tb2, .zip, .tar, .doc, .html, .htm, .txt, .xhtml, .xht, .xml, .xl, .xls, .jpeg, .jpg, .ico, .gif, .png, .psd, .bmp, .ai, .svg, .js, .css, .pdf, .ppt, .PPTX, .PPSX, .pps, .wav, .wma, .ogg, .mp3, .rm, .wmv, .qt, .swf, .fla, .ASF, .ASX, .FLV, .H264, .MOV, .MP4, .WAX, .WPL, .XSPF",
            'msgAllowDocumentType' => "Only the following file types are allowed:"

        ],
        'aFont' => [
            'Arial' => 'Arial',
            'Courier ' => 'Courier',
            'Courier_New ' => 'Courier New',
            'Geneva ' => 'Geneva',
            'Georgia ' => 'Georgia',
            'Helvetica ' => 'Helvetica',
            'mono ' => 'mono',
            'sans_serif ' => 'sans serif',
            'serif ' => 'serif',
            'Sylfaen ' => 'Sylfaen',
            'Times ' => 'Times',
            'Times_New_Roman ' => 'Times New Roman',
            'trebuchet_MS ' => 'trebuchet MS',
            'Verdana ' => 'Verdana'
        ],

        //TODO Dynamic load plugin config
        //เรียกโดย เช่น parent.wex.plugins.blog.widget.xxx.yyy.zzz
        'plugins' => [
            'blog' => config('blog'),
            'systempage' => config('systempagewidget'),
//             'socialbutton' => config('systempagewidget.widget.socialWidget'),
            'socialbutton' => [
                'setting' => $widget->getSettingwidget()
            ]

        ],

    ],


];
