<?php

namespace app\manystoreapi\controller;

use app\common\controller\ManystoreApiBase;

/**
 * 机构API后台：首页接口
 */
class Index extends ManystoreApiBase
{
    protected $noNeedLogin = [];
//    protected $noNeedRight = ['index'];
    protected $layout = '';

    public function _initialize()
    {
        parent::_initialize();
        //移除HTML标签
        $this->request->filter('trim,strip_tags,htmlspecialchars');
    }


    /**
     * 后台首页
     */
    public function index()
    {
        //左侧菜单
        $cookieArr = ['adminskin' => "/^skin\-([a-z\-]+)\$/i", 'multiplenav' => "/^(0|1)\$/", 'multipletab' => "/^(0|1)\$/", 'show_submenu' => "/^(0|1)\$/"];
        foreach ($cookieArr as $key => $regex) {
            $cookieValue = $this->request->cookie($key);
            if (!is_null($cookieValue) && preg_match($regex, $cookieValue)) {
                config('fastadmin.' . $key, $cookieValue);
            }
        }
        list($menulist, $navlist, $fixedmenu, $referermenu) = $this->auth->getSidebar([
            'dashboard' => 'hot',
            'addon'     => ['new', 'red', 'badge'],
            'auth/rule' => __('Menu'),
            'general'   => ['new', 'purple'],
        ], $this->view->site['fixedpage']);
        $action = $this->request->request('action');
//        if ($this->request->isPost()) {
                $this->apisuccess('',  [
                    'menulist' => $menulist,
                    'navlist' => $navlist,
                    'cookie' => ['prefix' => config('cookie.prefix')],
                    "fixedmenu" =>$fixedmenu,
                    "referermenu" =>$referermenu,
                    "title", __('Home'),
                    "attachmentcategory"=>config("site.attachmentcategory")
                ]);

//        }
//        $this->assignconfig('cookie', ['prefix' => config('cookie.prefix')]);
//        $this->view->assign('menulist', $menulist);
//        $this->view->assign('navlist', $navlist);
//        $this->view->assign('fixedmenu', $fixedmenu);
//        $this->view->assign('referermenu', $referermenu);
//        $this->view->assign('title', __('Home'));
//        return $this->view->fetch();
    }

}