{{:ModuleInclude('public/header')}}

<!-- right content start  -->
<div class="content-right">
    <div class="content">
        <!-- operation start -->
        <div class="am-g am-padding-bottom am-border-bottom-f8 am-margin-bottom">
            <div class="am-flex am-flex-justify-between am-flex-items-center am-flex-warp am-gap-12">
                <div>
                    {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true}}
                        <a href="{{:MyUrl('admin/pluginsadmin/saveinfo')}}" class="am-btn am-btn-primary am-radius am-btn-xs am-margin-right-sm">
                            <i class="iconfont icon-add am-show-sm-only"></i>
                            <span>{{:MyLang('add_title')}}</span>
                        </a>
                    {{/if}}
                    {{if AdminIsPower('pluginsadmin', 'upload')}}
                        <button type="button" class="am-btn am-btn-default-plain am-btn-xs am-radius submit-popup" data-url="{{:MyUrl('admin/pluginsadmin/index', ['view_type'=>'upload'])}}" data-title="{{:MyLang('pluginsadmin.base_upload_application_name')}}" data-full-max="1" data-full-max-size="xl">
                            <i class="iconfont icon-upload"></i>
                            <span>{{:MyLang('pluginsadmin.base_upload_application_name')}}</span>
                        </button>
                    {{/if}}
                </div>
                <div class="am-flex am-flex-items-center am-gap-24">
                    {{if !empty($data_list['db_data']) or !empty($data_list['dir_data'])}}
                        <div class="am-input-group am-input-group-sm plugins-search">
                            <input type="text" class="am-form-field am-radius" data-is-clearout="0" placeholder="{{:MyLang('pluginsadmin.base_search_input_placeholder')}}" />
                            <i class="iconfont icon-search search-event"></i>
                        </div>
                    {{/if}}
                    {{if AdminIsPower('packageinstall', 'index') and !empty($store_url)}}
                        <a class="am-text-sm am-flex nwarp" href="{{$store_url}}" target="_blank">
                            <i class="iconfont icon-download-b-line"></i> 
                            <span class="am-hide-sm-only am-margin-left-xs">{{:MyLang('pluginsadmin.base_nav_more_plugins_download_name')}}</span>
                        </a>
                    {{/if}}
                </div>
            </div>
        </div>
        <!-- operation end -->

        <div class="plugins-data-list am-cf">
            {{if !empty($data_list['db_data']) or !empty($data_list['dir_data'])}}
                <!-- 操作提示 -->
                <div class="am-operate-stretch-tips">
                    <div class="title">
                        <i class="iconfont icon-tips"></i>
                        <strong title="{{:MyLang('operate_list_tips_msg')}}">{{:MyLang('operate_list_tips_button_text')}}</strong>
                        <i class="iconfont icon-retract-diagonal contract" title="{{:MyLang('operate_list_tips_retract_text')}}"></i> 
                    </div>
                    <p>{{:MyLang('pluginsadmin.base_top_tips_one')}}</p>
                    {{if AdminIsPower('pluginsadmin', 'setupsave') or AdminIsPower('packageinstall', 'index')}}
                        <p>
                            {{if AdminIsPower('pluginsadmin', 'setupsave')}}
                                <span>{{:MyLang('pluginsadmin.base_top_tips_two')}}</span>
                                <a href="javascript:;" class="am-margin-left submit-move-setup-open">
                                    <i class="iconfont icon-setup"></i>
                                    <span>{{:MyLang('pluginsadmin.base_open_setup_title')}}</span>
                                </a>
                                <a href="javascript:;" class="am-margin-left submit-move-setup-save am-hide">
                                    <i class="iconfont icon-check"></i>
                                    <span>{{:MyLang('save_title')}}</span>
                                </a>
                                <a href="javascript:;" class="am-margin-left-sm submit-move-setup-cancel am-hide">
                                    <i class="iconfont icon-close-line"></i>
                                    <span>{{:MyLang('cancel_title')}}</span>
                                </a>
                            {{/if}}
                            {{if AdminIsPower('packageinstall', 'index')}}
                                <a href="javascript:;" class="am-margin-left-lg">
                                    <label class="am-checkbox-inline plugins-batch-update-submit">
                                        <input type="checkbox" value="1" data-am-ucheck {{if !empty($params) and isset($params['is_auto_update']) and $params['is_auto_update'] eq 1}}checked{{/if}} /> {{:MyLang('store_auto_update_name')}}
                                    </label>
                                </a>
                            {{/if}}
                        </p>
                    {{/if}}
                    {{if $is_not_bind_accounts eq 1}}
                        <p>
                            <span>{{:MyLang('store_bind_accounts_tips')}}</span>
                            <button type="button" class="am-btn am-btn-primary am-radius am-btn-xs am-margin-left-xs am-icon-gg store-accounts-event"> {{:MyLang('store_bind_accounts_name')}}</button>
                        </p>
                    {{/if}}
                </div>

                {{if !empty($data_list['db_data'])}}
                    <!-- 插件分类 -->
                    <div class="plugins-category-nav am-margin-bottom-lg am-flex am-flex-warp am-gap-12 am-flex-justify-between am-flex-items-center">
                        <div class="am-flex am-flex-warp am-gap-12">
                            <button type="button" class="am-btn am-btn-secondary am-radius am-btn-xs">{{:MyLang('all_title')}}</button>
                            {{if !empty($plugins_categosy_list)}}
                                {{foreach $plugins_categosy_list as $cv}}
                                    <button type="button" class="am-btn am-btn-default am-radius am-btn-xs" data-value="{{$cv.id}}">{{$cv.name}}</button>
                                {{/foreach}}
                            {{/if}}
                        </div>
                        {{if AdminIsPower('pluginscategory', 'index')}}
                            <a href="javascript:;" class="am-text-sm submit-popup am-flex" data-url="{{:MyUrl('admin/pluginscategory/index')}}" data-class="plugins-category-save-popup" data-title="{{:MyLang('pluginsadmin.plugins_category_title')}}">
                                <i class="iconfont icon-type-manage"></i>
                                <span class="am-hide-sm-only am-margin-left-xs">{{:MyLang('pluginsadmin.plugins_category_admin_title')}}</span>
                            </a>
                        {{/if}}
                    </div>

                    <!-- 已安装 -->
                    <ul class="already-install am-cf" data-setup-save-url="{{:MyUrl('admin/pluginsadmin/setupsave')}}">
                        {{foreach $data_list['db_data'] as $v}}
                            {{if isset($v['is_install']) and $v['is_install'] eq 1}}
                                <li class="plugins-category-{{$v.plugins_category_id}}" data-id="{{$v.id}}" data-plugins="{{$v.plugins}}">
                                    <div class="item {{if $v['is_enable'] eq 0}}am-active{{/if}}" id="data-list-{{$v.plugins}}">
                                        <!-- 拖拽排序 -->
                                        <div class="submit-move"></div>
                                        <!-- 插件内容 -->
                                        <img src="{{$v.logo}}" class="icon" />
                                        <div class="base">
                                            <h3 class="name">{{$v.name}}</h3>
                                            <div class="am-flex am-flex-items-center am-gap-1">
                                                {{if empty($site_store_info) or empty($site_store_info['vip']) or !isset($site_store_info['vip']['status']) or $site_store_info['vip']['status'] eq 0}}
                                                    <p>{{:MyLang('pluginsadmin.data_list_author_title')}}：{{$v.author}}</p>
                                                    <p>/</p>
                                                    <p class="am-hide-sm-only">{{:MyLang('pluginsadmin.data_list_author_url_title')}}：<a href="{{$v.author_url}}" class="am-pr z-i iconfont icon-home" target="_blank"></a></p>
                                                    <p class="am-hide-sm-only">/</p>
                                                {{/if}}
                                                <p>{{:MyLang('pluginsadmin.data_list_version_title')}}：{{$v.version}}</p>
                                                {{if !empty($upgrade_info) and isset($upgrade_info[$v['plugins']])}}
                                                    {{if !empty($upgrade_info[$v['plugins']]['version_main']) and $upgrade_info[$v['plugins']]['version_main'] neq $v['version']}}
                                                        <p>/</p>
                                                        <span class="am-text-danger">v{{$upgrade_info[$v['plugins']]['version_main']}}</span>
                                                    {{/if}}
                                                {{/if}}
                                            </div>
                                            <div class="desc">{{$v.desc}}</div>
                                        </div>
                                        <div class="operation">
                                            <a href="javascript:;" data-set-url="{{:PluginsAdminUrl($v['plugins'], 'admin', 'index')}}" data-name="{{$v.name}}" data-key="plugins-{{$v.plugins}}" class="am-btn am-btn-default am-btn-xs am-radius plugins-set-event am-padding-left-0">
                                                <i class="iconfont icon-application-set"></i>
                                                <span>{{:MyLang('setup_title')}}</span>
                                            </a>

                                            <a href="javascript:;" class="am-btn am-btn-default am-btn-xs plugins-status-event {{if $v['is_enable'] eq 1}}am-success{{/if}}" data-url="{{:MyUrl('admin/pluginsadmin/statusupdate')}}" data-value="{{$v.plugins}}" data-status="{{$v['is_enable']}}" data-open-text="{{:MyLang('open_title')}}" data-close-text="{{:MyLang('close_title')}}">
                                                <i class="iconfont icon-enable"></i>
                                                <span>{{if $v['is_enable'] eq 1}}{{:MyLang('close_title')}}{{else /}}{{:MyLang('open_title')}}{{/if}}</span>
                                            </a>

                                            {{if !empty($upgrade_info) and isset($upgrade_info[$v['plugins']])}}
                                                {{if isset($upgrade_info[$v['plugins']]['version_new']) and version_compare($upgrade_info[$v['plugins']]['version_new'], $v['version'], '>')}}
                                                    <button class="am-btn am-btn-danger am-btn-xs am-radius package-upgrade-event" data-type="plugins" data-name="{{$v.name}}" data-value="{{$v.plugins}}" data-json="{{:urlencode(json_encode($upgrade_info[$v['plugins']]))}}">
                                                        <i class="iconfont icon-application-update"></i>
                                                        <span>{{:MyLang('update_title')}}</span>
                                                    </button>
                                                {{/if}}
                                            {{/if}}

                                            {{if isset($v['is_home']) and $v['is_home'] eq true and !empty($v['home_url'])}}
                                                <a href="{{$v.home_url}}" class="am-btn am-btn-default am-btn-xs am-radius" target="_blank">
                                                    <i class="iconfont icon-home-line"></i>
                                                    <span>{{:MyLang('home_title')}}</span>
                                                </a>
                                            {{/if}}

                                            {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true}}
                                                <a href="{{:MyUrl('admin/pluginsadmin/saveinfo', array('id'=>$v['plugins']))}}" class="am-btn am-btn-default am-btn-xs am-radius">
                                                    <i class="iconfont icon-edit"></i>
                                                    <span>{{:MyLang('edit_title')}}</span>
                                                </a>
                                            {{/if}}
                                            
                                            <button class="am-btn am-btn-default am-btn-xs am-radius submit-ajax" data-url="{{:MyUrl('admin/pluginsadmin/uninstall')}}" data-id="{{$v.plugins}}" data-view="reload" data-msg="{{:MyLang('pluginsadmin.uninstall_confirm_tips')}}">
                                                <i class="iconfont icon-uninstall"></i>
                                                <span>{{:MyLang('uninstall_title')}}</span>
                                            </button>

                                            {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true}}
                                                <button class="am-btn am-btn-default am-btn-xs am-radius submit-popup" data-url="{{:MyUrl('admin/pluginsadmin/storeuploadinfo', ['id'=>$v['plugins']])}}" data-title="{{:MyLang('upload_title')}}">
                                                    <i class="iconfont icon-upload"></i>
                                                    <span>{{:MyLang('upload_title')}}</span>
                                                </button>
                                            {{/if}}

                                            {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true}}
                                                <a href="{{:MyUrl('admin/pluginsadmin/download', array('id'=>$v['plugins']))}}" class="am-btn am-btn-default am-btn-xs am-radius">
                                                    <i class="iconfont icon-download-btn"></i>
                                                    <span>{{:MyLang('download_title')}}</span>
                                                </a>
                                            {{/if}}
                                        </div>
                                        <div class="plugins-setup-container am-padding-main am-hide">
                                            {{if !empty($left_menu)}}
                                                <div class="am-inline-block chosen-select-item">
                                                    <select class="am-radius chosen-select" name="plugins_menu_control" data-placeholder="{{:MyLang('pluginsadmin.plugins_menu_control_title')}}">
                                                        <option value="">{{:MyLang('pluginsadmin.plugins_menu_control_title')}}</option>
                                                        {{foreach $left_menu as $nv}}
                                                            <option value="{{$nv.control}}" {{if isset($v['plugins_menu_control']) and $v['plugins_menu_control'] eq strtolower($nv['control'])}}selected{{/if}}>{{$nv.name}}</option>
                                                        {{/foreach}}
                                                    </select>
                                                </div>
                                            {{/if}}
                                            {{if !empty($plugins_categosy_list)}}
                                                <div class="am-inline-block chosen-select-item">
                                                    <select class="am-radius chosen-select" name="plugins_category_id" data-placeholder="{{:MyLang('pluginsadmin.plugins_category_title')}}">
                                                        <option value="">{{:MyLang('pluginsadmin.plugins_category_title')}}</option>
                                                        {{foreach $plugins_categosy_list as $cv}}
                                                            <option value="{{$cv.id}}" {{if isset($v['plugins_category_id']) and $cv['id'] eq $v['plugins_category_id']}}selected{{/if}}>{{$cv.name}}</option>
                                                        {{/foreach}}
                                                    </select>
                                                </div>
                                            {{/if}}
                                            {{if isset($v['is_home']) and $v['is_home'] eq true}}
                                                <div class="am-inline-block chosen-select-item am-background-white second-domain">
                                                    <label class="am-checkbox-inline" title="{{:MyLang('pluginsadmin.data_list_second_domain_tips')}}">
                                                        <input type="checkbox" name="plugins_is_second_domain" value="1" data-am-ucheck {{if isset($v['plugins_is_second_domain']) and $v['plugins_is_second_domain'] eq 1}}checked="true"{{/if}} /> {{:MyLang('pluginsadmin.data_list_second_domain_title')}}
                                                    </label>
                                                </div>
                                            {{/if}}
                                        </div>
                                    </div>
                                </li>
                            {{/if}}
                        {{/foreach}}
                    </ul>

                    <!-- 搜索无数据展示 -->
                    <div class="not-data-tips am-hide">
                        {{:ModuleInclude('public/not_data')}}
                    </div>
                {{/if}}

                {{if !empty($data_list['dir_data'])}}
                    <!-- 未安装 -->
                    <div class="am-margin-top-lg am-margin-bottom-xs am-nav-left">
                        <span class="am-text-sm am-font-weight">{{:MyLang('pluginsadmin.not_install_divide_title')}}</span>
                    </div>
                    <ul class="not-install am-cf" data-setup-save-url="{{:MyUrl('admin/pluginsadmin/sortsave')}}">
                        {{foreach $data_list['dir_data'] as $v}}
                            {{if !isset($v['is_install']) or $v['is_install'] eq 0}}
                                <li data-id="{{$v.id}}" data-plugins="{{$v.plugins}}">
                                    <div class="item am-active" id="data-list-{{$v.plugins}}">
                                        <img src="{{$v.logo}}" class="icon" />
                                        <div class="base">
                                            <h3 class="name">{{$v.name}}</h3>
                                            <div class="am-flex am-flex-items-center am-gap-1">
                                                <p>{{:MyLang('pluginsadmin.data_list_author_title')}}：{{$v.author}}</p>
                                                <p>/</p>
                                                {{if empty($site_store_info) or empty($site_store_info['vip']) or !isset($site_store_info['vip']['status']) or $site_store_info['vip']['status'] eq 0}}
                                                    <p class="am-hide-sm-only">{{:MyLang('pluginsadmin.data_list_author_url_title')}}：<a href="{{$v.author_url}}" class="iconfont icon-home" target="_blank"></a></p>
                                                    <p class="am-hide-sm-only">/</p>
                                                {{/if}}
                                                <p>{{:MyLang('pluginsadmin.data_list_version_title')}}：{{$v.version}}</p>
                                            </div>
                                            <div class="desc">{{$v.desc}}</div>
                                        </div>
                                        <div class="operation">
                                            <button class="am-btn am-btn-default am-btn-xs am-radius submit-ajax" data-url="{{:MyUrl('admin/pluginsadmin/install')}}" data-id="{{$v.plugins}}" data-view="reload" data-msg="{{:MyLang('install_confirm_tips')}}">
                                                <i class="iconfont icon-application-install"></i>
                                                <span>{{:MyLang('install_title')}}</span>
                                            </button>

                                            {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true}}
                                                <a href="{{:MyUrl('admin/pluginsadmin/saveinfo', array('id'=>$v['plugins']))}}" class="am-btn am-btn-default am-btn-xs am-radius">
                                                    <i class="iconfont icon-edit"></i>
                                                    <span>{{:MyLang('edit_title')}}</span>
                                                </a>
                                                <button class="am-btn am-btn-default am-btn-xs am-radius submit-popup" data-url="{{:MyUrl('admin/pluginsadmin/storeuploadinfo', ['id'=>$v['plugins']])}}">
                                                    <i class="iconfont icon-upload"></i>
                                                    <span>{{:MyLang('upload_title')}}</span>
                                                </button>
                                                <a href="{{:MyUrl('admin/pluginsadmin/download', array('id'=>$v['plugins']))}}" class="am-btn am-btn-default am-btn-xs am-radius">
                                                    <i class="iconfont icon-download-btn"></i>
                                                    <span>{{:MyLang('download_title')}}</span>
                                                </a>
                                            {{/if}}

                                            <button class="am-btn am-btn-default am-btn-xs am-radius submit-delete-modal" data-url="{{:MyUrl('admin/pluginsadmin/delete')}}" data-id="{{$v.plugins}}">
                                                <i class="iconfont icon-delete-dustbin"></i>
                                                <span>{{:MyLang('delete_title')}}</span>
                                            </button>
                                        </div>
                                    </div>
                                </li>
                            {{/if}}
                        {{/foreach}}
                    </ul>

                    <!-- 删除弹层 -->
                    <div class="am-modal am-modal-no-btn" tabindex="-1" id="plugins-delete-modal">
                        <div class="am-modal-dialog am-radius am-cf">
                            <div class="am-modal-hd">
                                <span>{{:MyLang('reminder_title')}}</span>
                                <a href="javascript: void(0)" class="am-close" data-am-modal-close>&times;</a>
                            </div>
                            <div class="am-modal-bd am-padding-lg">
                                <div class="am-alert am-margin-top-lg am-text-left">
                                    <p>{{:MyLang('pluginsadmin.delete_plugins_text')}}<span class="am-text-warning">{{:MyLang('pluginsadmin.delete_plugins_text_tips')}}</span></p>
                                    <p>{{:MyLang('pluginsadmin.delete_plugins_data_text')}}<span class="am-text-warning">{{:MyLang('pluginsadmin.delete_plugins_data_text_tips')}}</span></p>
                                </div>
                                <p class="am-text-danger am-margin-top-lg">{{:MyLang('pluginsadmin.delete_plugins_ps_tips')}}</p>
                                <div class="am-margin-top-sm">
                                    <button class="am-btn am-btn-danger am-btn-xs am-radius am-icon-circle-o submit-ajax" data-url="{{:MyUrl('admin/pluginsadmin/delete')}}" data-id="0" data-value="1" data-view="reload" data-msg="{{:MyLang('delete_confirm_tips')}}"> {{:MyLang('pluginsadmin.delete_plugins_data_button_name')}}</button>
                                    <button class="am-btn am-btn-warning am-btn-xs am-radius am-icon-remove submit-ajax" data-url="{{:MyUrl('admin/pluginsadmin/delete')}}" data-id="0" data-value="0" data-view="reload" data-msg="{{:MyLang('delete_confirm_tips')}}"> {{:MyLang('pluginsadmin.delete_plugins_button_name')}}</button>

                                    <button class="am-btn am-btn-success am-btn-xs am-radius am-icon-reply" data-am-modal-close> {{:MyLang('pluginsadmin.cancel_delete_plugins_button_name')}}</button>
                                </div>
                            </div>
                        </div>
                    </div>
                {{/if}}

                {{if AdminIsPower('pluginsadmin', 'upload')}}
                    <div class="am-text-center">
                        <a href="javascript:;" class="submit-popup" data-url="{{:MyUrl('admin/pluginsadmin/index', ['view_type'=>'upload', 'switch_active'=>'market'])}}" data-title="{{:MyLang('pluginsadmin.base_upload_application_name')}}" data-full-max="1" data-full-max-size="xl">{{:MyLang('pluginsadmin.more_plugins_store_to_text')}}</a>
                    </div>
                {{else /}}
                    {{if $is_system_show_base eq 1}}
                        <div class="am-padding-vertical-xl am-text-center">
                            <a href="{{$store_url}}" target="_blank" class="am-margin-left-xs">{{:MyLang('pluginsadmin.more_plugins_store_to_text')}}</a>
                        </div>
                    {{/if}}
                {{/if}}
            {{else /}}
                {{if $is_not_bind_accounts eq 1}}
                    {{:ModuleInclude('public/store_bind_accounts_tips')}}
                {{else /}}
                    {{:ModuleInclude('public/not_data', ['msg'=>MyLang('plugins_no_data_tips')])}}
                    {{if AdminIsPower('pluginsadmin', 'upload')}}
                        <div class="am-text-center">
                            <a href="javascript:;" class="submit-popup" data-url="{{:MyUrl('admin/pluginsadmin/index', ['view_type'=>'upload', 'switch_active'=>'market'])}}" data-title="{{:MyLang('pluginsadmin.base_upload_application_name')}}" data-full-max="1" data-full-max-size="xl">{{:MyLang('pluginsadmin.no_data_store_to_text')}}</a>
                        </div>
                    {{else /}}
                        {{if $is_system_show_base eq 1}}
                            <div class="am-margin-top-xl">
                                <a href="{{$store_url}}" target="_blank" class="am-margin-left-xs">{{:MyLang('pluginsadmin.no_data_store_to_text')}}</a>
                            </div>
                        {{/if}}
                    {{/if}}
                {{/if}}
            {{/if}}
        </div>
    </div>
</div>
<!-- right content end  -->

<!-- footer start -->
{{:ModuleInclude('public/footer')}}