Пример #1
0
    $result = [];
    if (\Yii::$app instanceof \yii\console\Application) {
        return $result;
    }
    foreach (\Yii::$app->getComponents(true) as $id => $data) {
        try {
            $loadedComponent = \Yii::$app->get($id);
            if ($loadedComponent instanceof \skeeks\cms\base\Component) {
                $result[] = new \skeeks\cms\modules\admin\helpers\AdminMenuItemCmsConent(['label' => $loadedComponent->descriptor->name, 'url' => ["cms/admin-settings", "component" => $loadedComponent->className()]]);
            }
        } catch (\Exception $e) {
        }
    }
    return $result;
}
return ['content' => ['priority' => 0, 'label' => \Yii::t('app', 'Content'), "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/icon.tree.gif'], 'items' => array_merge([["label" => \Yii::t('app', "Sections"), "url" => ["cms/admin-tree"], "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/icon.tree.gif']], ["label" => \Yii::t('app', "File manager"), "url" => ["cms/admin-file-manager"], "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/folder.png']], ["label" => \Yii::t('app', "File storage"), "url" => ["cms/admin-storage-files/index"], "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/storage_file.png']]], contentMenu())], 'settings' => ['priority' => 10, 'label' => \Yii::t('app', 'Settings'), "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/settings.png'], 'items' => [["label" => \Yii::t('app', "Product settings"), "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/settings.png'], 'items' => [["label" => \Yii::t('app', 'Sites'), "url" => ["cms/admin-cms-site"], "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/www.png']], ["label" => \Yii::t('app', "Languages"), "url" => ["cms/admin-cms-lang"], "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/lang.png']], ["label" => \Yii::t('app', "Database of translations"), "url" => ["cms/admin-message/index"], "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/lang.png']], ["label" => \Yii::t('app', "Section markers"), "url" => ["cms/admin-tree-menu"], "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/icon.tree.menu.png']], ["label" => \Yii::t('app', "Server file storage"), "url" => ["cms/admin-storage/index"], "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/servers.png']], ["label" => \Yii::t('app', "Settings sections"), "url" => ["cms/admin-cms-tree-type"], "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/icon.tree.gif']], ["label" => \Yii::t('app', "Content settings"), "url" => ["cms/admin-cms-content-type"], "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/content.png'], 'items' => contentEditMenu()], ["label" => \Yii::t('app', "Module settings"), "url" => ["cms/admin-settings"], "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/settings.png'], 'items' => componentsMenu()], ["label" => \Yii::t('app', "Agents"), "url" => ["cms/admin-cms-agent"], "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/clock.png']]]], ['label' => \Yii::t('app', 'Users and Access'), 'priority' => 0, 'enabled' => true, "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/user.png'], 'items' => [["label" => \Yii::t('app', "User management"), "url" => ["cms/admin-user"], "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/user.png']], ["label" => \Yii::t('app', "User properties"), "url" => ["cms/admin-cms-user-universal-property"], "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/settings.png']], ["label" => \Yii::t('app', 'The base of {email} addresses', ['email' => 'email']), "url" => ["cms/admin-user-email"], "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/email-2.png']], ["label" => \Yii::t('app', "Base phones"), "url" => ["cms/admin-user-phone"], "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/phone.png']], ["label" => \Yii::t('app', "Social profiles"), "url" => ["cms/admin-user-auth-client"], "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/facebook.png']], ["label" => \Yii::t('app', 'Roles'), "url" => ["admin/admin-role"], "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/icon.users_role.png'], 'enabled' => true, 'priority' => 0], ["label" => \Yii::t('app', 'Privileges'), "url" => ["admin/admin-permission"], "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/access.png'], 'enabled' => true, 'priority' => 0]]], ["label" => \Yii::t('app', "Searching"), "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/search.png'], 'items' => [["label" => \Yii::t('app', "Settings"), "url" => ["cms/admin-settings", "component" => 'skeeks\\cms\\components\\CmsSearchComponent'], "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/settings.png'], "activeCallback" => function (\skeeks\cms\modules\admin\helpers\AdminMenuItem $adminMenuItem) {
    return (bool) (\Yii::$app->request->getUrl() == $adminMenuItem->getUrl());
}], ["label" => \Yii::t('app', "Statistic"), "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/statistics.png'], 'items' => [["label" => \Yii::t('app', "Jump list"), "url" => ["cms/admin-search-phrase"]], ["label" => \Yii::t('app', "Phrase list"), "url" => ["cms/admin-search-phrase-group"]]]]]], ['label' => \Yii::t('app', 'Instruments'), 'priority' => 0, 'enabled' => true, "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/tools.png'], 'items' => [["label" => \Yii::t('app', "Checking system"), "url" => ["admin/checker"], "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/tools.png']], ["label" => \Yii::t('app', "Information"), "url" => ["admin/info"], "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/icon.infoblock.png']], ["label" => \Yii::t('app', "Sending {email}", ['email' => 'email']), "url" => ["admin/email"], "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/email.png']], ["label" => \Yii::t('app', "Clearing temporary data"), "url" => ["admin/clear"], "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/clear.png']], ["label" => \Yii::t('app', "Work to database"), "url" => ["admin/db"], "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/icon.bd_arch.png']], ["label" => \Yii::t('app', "{ssh} console", ['ssh' => 'Ssh']), "url" => ["admin/ssh"], "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/ssh.png']], ["label" => \Yii::t('app', 'Code generator') . " gii", "url" => ["admin/gii"], "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/ssh.png'], "accessCallback" => function () {
    if ((bool) \Yii::$app->hasModule('gii')) {
        /**
         * @var $gii yii\gii\Module
         */
        $gii = \Yii::$app->getModule('gii');
        $ip = \Yii::$app->getRequest()->getUserIP();
        foreach ($gii->allowedIPs as $filter) {
            if ($filter === '*' || $filter === $ip || ($pos = strpos($filter, '*')) !== false && !strncmp($ip, $filter, $pos)) {
                return true;
            }
        }
    }
    return false;
Пример #2
0
                    $itemData['items'][] = ['label' => $content->name, 'url' => ["cms/admin-cms-content/update", "pk" => $content->id], "activeCallback" => function (\skeeks\cms\modules\admin\helpers\AdminMenuItem $adminMenuItem) {
                        return (bool) (\Yii::$app->controller->action->uniqueId == 'cms/admin-cms-content/update' && \yii\helpers\ArrayHelper::getValue($adminMenuItem->url, 'pk') == \Yii::$app->request->get('pk'));
                    }];
                }
            }
            $result[] = $itemData;
        }
    }
    return $result;
}
function componentsMenu()
{
    $result = [];
    if (\Yii::$app instanceof \yii\console\Application) {
        return $result;
    }
    foreach (\Yii::$app->getComponents(true) as $id => $data) {
        try {
            $loadedComponent = \Yii::$app->get($id);
            if ($loadedComponent instanceof \skeeks\cms\base\Component) {
                $result[] = new \skeeks\cms\modules\admin\helpers\AdminMenuItem(['label' => $loadedComponent->descriptor->name, 'url' => ["cms/admin-settings", "component" => $loadedComponent->className()], "activeCallback" => function (\skeeks\cms\modules\admin\helpers\AdminMenuItem $adminMenuItem) {
                    return (bool) (\Yii::$app->request->getUrl() == $adminMenuItem->getUrl());
                }]);
            }
        } catch (\Exception $e) {
        }
    }
    return $result;
}
return ['dashboard' => ['priority' => 90, 'label' => \Yii::t('skeeks/cms', 'Dashboards'), "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/dashboard.png'], 'items' => dashboardsMenu()], 'content' => ['priority' => 200, 'label' => \Yii::t('skeeks/cms', 'Content'), "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/sections.png'], 'items' => array_merge([["label" => \Yii::t('skeeks/cms', "Sections"), "url" => ["cms/admin-tree"], "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/sections.png']], ["label" => \Yii::t('skeeks/cms', "File manager"), "url" => ["cms/admin-file-manager"], "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/folder.png']], ["label" => \Yii::t('skeeks/cms', "File storage"), "url" => ["cms/admin-storage-files"], "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/storage_file.png']]], contentMenu())], 'users' => ['label' => \Yii::t('skeeks/cms', 'Users'), 'priority' => 200, 'enabled' => true, "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/user.png'], 'items' => [["label" => \Yii::t('skeeks/cms', "User management"), "url" => ["cms/admin-user"], "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/user.png'], 'priority' => 0], ["label" => \Yii::t('skeeks/cms', "User properties"), "url" => ["cms/admin-cms-user-universal-property"], "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/settings-big.png']], ["label" => \Yii::t('skeeks/cms', 'The base of {email} addresses', ['email' => 'email']), "url" => ["cms/admin-user-email"], "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/email-2.png']], ["label" => \Yii::t('skeeks/cms', "Base phones"), "url" => ["cms/admin-user-phone"], "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/phone.png']]]], 'settings' => ['priority' => 300, 'label' => \Yii::t('skeeks/cms', 'Settings'), "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/settings-big.png'], 'items' => [["label" => \Yii::t('skeeks/cms', 'Sites'), "url" => ["cms/admin-cms-site"], "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/www.png']], ["label" => \Yii::t('skeeks/cms', "Languages"), "url" => ["cms/admin-cms-lang"], "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/ru.png']], ["label" => \Yii::t('skeeks/cms', "Server file storage"), "url" => ["cms/admin-storage/index"], "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/servers.png']], ["label" => \Yii::t('skeeks/cms', "Settings sections"), "url" => ["cms/admin-cms-tree-type"], "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/icon.tree.gif']], ["label" => \Yii::t('skeeks/cms', "Content settings"), "url" => ["cms/admin-cms-content-type"], "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/content.png'], 'items' => contentEditMenu()], ["label" => \Yii::t('skeeks/cms', "Module settings"), "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/settings-big.png'], 'items' => componentsMenu()]]], 'other' => ['priority' => 500, 'label' => \Yii::t('skeeks/cms', 'Additionally'), "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/other.png'], 'items' => [['label' => \Yii::t('skeeks/cms', 'Instruments'), 'priority' => 0, 'enabled' => true, "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/tools.png'], 'items' => [["label" => \Yii::t('skeeks/cms', "Information"), "url" => ["admin/info"], "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/icon.infoblock.png']]]], ["label" => \Yii::t('skeeks/cms', "Clearing temporary data"), "url" => ["admin/clear"], "img" => ['\\skeeks\\cms\\modules\\admin\\assets\\AdminAsset', 'images/icons/clear.png']]]]];