mirror of
https://github.com/humhub/humhub.git
synced 2025-01-17 22:28:51 +01:00
- Enh: Added humhub\libs\Html::addPjaxPrevention()
for link options
- Refactored old menu style creation
This commit is contained in:
parent
504877319e
commit
2a78f169e5
@ -15,7 +15,7 @@
|
||||
"require": {
|
||||
"php": ">=5.6.0",
|
||||
"npm-asset/animate.css": "*",
|
||||
"npm-asset/jquery-autosize": "1.*",
|
||||
"npm-asset/jquery-autosize": "1.*",
|
||||
"npm-asset/bluebird": "^3.3.5",
|
||||
"npm-asset/blueimp-file-upload": "9.24.*",
|
||||
"npm-asset/bootstrap-markdown": "2.10.*",
|
||||
|
@ -109,4 +109,9 @@ class Html extends \yii\bootstrap\Html
|
||||
throw new InvalidArgumentException('Content container type not supported!');
|
||||
}
|
||||
}
|
||||
|
||||
public static function addPjaxPrevention(&$options)
|
||||
{
|
||||
$options['data-pjax-prevent'] = 1;
|
||||
}
|
||||
}
|
||||
|
@ -8,10 +8,15 @@
|
||||
|
||||
namespace humhub\modules\admin\widgets;
|
||||
|
||||
use humhub\modules\ui\icon\widgets\Icon;
|
||||
use humhub\modules\ui\menu\MenuEntry;
|
||||
use humhub\modules\ui\menu\widgets\LeftNavigation;
|
||||
use Yii;
|
||||
use humhub\modules\admin\permissions\ManageModules;
|
||||
use humhub\modules\admin\permissions\ManageSpaces;
|
||||
use humhub\modules\admin\permissions\SeeAdminInformation;
|
||||
use humhub\modules\ui\menu\MenuLink;
|
||||
use humhub\modules\ui\menu\widgets\LeftNavigation;
|
||||
use humhub\modules\admin\permissions\ManageUsers;
|
||||
use humhub\modules\admin\permissions\ManageSettings;
|
||||
use humhub\modules\admin\permissions\ManageGroups;
|
||||
|
||||
/**
|
||||
* AdminMenu
|
||||
@ -33,57 +38,57 @@ class AdminMenu extends LeftNavigation
|
||||
{
|
||||
$this->panelTitle = Yii::t('AdminModule.widgets_AdminMenuWidget', '<strong>Administration</strong> menu');
|
||||
|
||||
$entry = new MenuEntry();
|
||||
$entry->setLabel(Yii::t('AdminModule.widgets_AdminMenuWidget', 'Users'));
|
||||
$entry->setUrl(['/admin/user']);
|
||||
$entry->setIcon('user');
|
||||
$entry->setSortOrder(200);
|
||||
$entry->setIsActive((Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && (Yii::$app->controller->id == 'user' || Yii::$app->controller->id == 'group' || Yii::$app->controller->id == 'approval' || Yii::$app->controller->id == 'authentication' || Yii::$app->controller->id == 'user-profile' || Yii::$app->controller->id == 'pending-registrations')));
|
||||
$entry->setIsVisible(Yii::$app->user->can([
|
||||
new \humhub\modules\admin\permissions\ManageUsers(),
|
||||
new \humhub\modules\admin\permissions\ManageSettings(),
|
||||
new \humhub\modules\admin\permissions\ManageGroups()
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('AdminModule.widgets_AdminMenuWidget', 'Users'),
|
||||
'url' => ['/admin/user'],
|
||||
'icon' => 'user',
|
||||
'sortOrder' => 200,
|
||||
'isActive' => MenuLink::isActiveState('admin', ['user', 'group', 'approval', 'authentication', 'user-profile', 'pending-registrations']),
|
||||
'isVisible' => Yii::$app->user->can([
|
||||
ManageUsers::class,
|
||||
ManageSettings::class,
|
||||
ManageGroups::class
|
||||
])
|
||||
]));
|
||||
$this->addEntry($entry);
|
||||
|
||||
$entry = new MenuEntry();
|
||||
$entry->setLabel(Yii::t('AdminModule.widgets_AdminMenuWidget', 'Spaces'));
|
||||
$entry->setUrl(['/admin/space']);
|
||||
$entry->setIcon('inbox');
|
||||
$entry->setSortOrder(400);
|
||||
$entry->setIsActive((Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'space'));
|
||||
$entry->setIsVisible(Yii::$app->user->can([
|
||||
new \humhub\modules\admin\permissions\ManageSpaces(),
|
||||
new \humhub\modules\admin\permissions\ManageSettings(),
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('AdminModule.widgets_AdminMenuWidget', 'Spaces'),
|
||||
'url' => ['/admin/space'],
|
||||
'icon' => 'inbox',
|
||||
'sortOrder' => 400,
|
||||
'isActive' => MenuLink::isActiveState('admin', 'space'),
|
||||
'isVisible' => Yii::$app->user->can([
|
||||
ManageSpaces::class,
|
||||
ManageSettings::class
|
||||
])
|
||||
]));
|
||||
$this->addEntry($entry);
|
||||
|
||||
$entry = new MenuEntry();
|
||||
$entry->setLabel(Yii::t('AdminModule.widgets_AdminMenuWidget', 'Modules'));
|
||||
$entry->setUrl(['/admin/module']);
|
||||
$entry->setIcon('rocket');
|
||||
$entry->setSortOrder(500);
|
||||
$entry->setIsActive((Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'module'));
|
||||
$entry->setIsVisible(Yii::$app->user->can(new \humhub\modules\admin\permissions\ManageModules()));
|
||||
$this->addEntry($entry);
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('AdminModule.widgets_AdminMenuWidget', 'Modules'),
|
||||
'url' => ['/admin/module'],
|
||||
'icon' => 'rocket',
|
||||
'sortOrder' => 500,
|
||||
'isActive' => MenuLink::isActiveState('admin', 'module'),
|
||||
'isVisible' => Yii::$app->user->can(ManageModules::class)
|
||||
]));
|
||||
|
||||
$entry = new MenuEntry();
|
||||
$entry->setLabel(Yii::t('AdminModule.widgets_AdminMenuWidget', 'Settings'));
|
||||
$entry->setUrl(['/admin/setting']);
|
||||
$entry->setIcon('gears');
|
||||
$entry->setSortOrder(600);
|
||||
$entry->setIsActive((Yii::$app->controller->module && Yii::$app->controller->module->id == 'setting'));
|
||||
$entry->setIsVisible(Yii::$app->user->can(new \humhub\modules\admin\permissions\ManageSettings()));
|
||||
$this->addEntry($entry);
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('AdminModule.widgets_AdminMenuWidget', 'Settings'),
|
||||
'url' => ['/admin/setting'],
|
||||
'icon' => 'gears',
|
||||
'sortOrder' => 600,
|
||||
'isActive' => MenuLink::isActiveState('admin', 'setting'),
|
||||
'isVisible' => Yii::$app->user->can(ManageSettings::class)
|
||||
]));
|
||||
|
||||
$entry = new MenuEntry();
|
||||
$entry->setLabel(Yii::t('AdminModule.widgets_AdminMenuWidget', 'Information'));
|
||||
$entry->setUrl(['/admin/information']);
|
||||
$entry->setIcon('info-circle');
|
||||
$entry->setSortOrder(1000);
|
||||
$entry->setIsActive((Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'information'));
|
||||
$entry->setIsVisible(Yii::$app->user->can(new \humhub\modules\admin\permissions\SeeAdminInformation()));
|
||||
$this->addEntry($entry);
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('AdminModule.widgets_AdminMenuWidget', 'Information'),
|
||||
'url' => ['/admin/information'],
|
||||
'icon' => 'info-circle',
|
||||
'sortOrder' => 1000,
|
||||
'isActive' => MenuLink::isActiveState('admin', 'information'),
|
||||
'isVisible' => Yii::$app->user->can(SeeAdminInformation::class)
|
||||
]));
|
||||
|
||||
parent::init();
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
namespace humhub\modules\admin\widgets;
|
||||
|
||||
use humhub\modules\ui\menu\MenuLink;
|
||||
use Yii;
|
||||
use yii\helpers\Url;
|
||||
use humhub\modules\ui\menu\widgets\SubTabMenu;
|
||||
@ -18,72 +19,73 @@ use humhub\modules\ui\menu\widgets\SubTabMenu;
|
||||
class AdvancedSettingMenu extends SubTabMenu
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('AdminModule.widgets_AdminMenuWidget', 'Caching'),
|
||||
'url' => Url::toRoute(['/admin/setting/caching']),
|
||||
'icon' => '<i class="fa fa-dashboard"></i>',
|
||||
'icon' => 'dashboard',
|
||||
'sortOrder' => 100,
|
||||
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'setting' && Yii::$app->controller->action->id == 'caching'),
|
||||
'isActive' => MenuLink::isActiveState('admin', 'setting', 'caching'),
|
||||
'isVisible' => Yii::$app->user->isAdmin(),
|
||||
]);
|
||||
]));
|
||||
|
||||
$this->addItem([
|
||||
'label' => Yii::t('AdminModule.widgets_AdminMenuWidget', 'Files'),
|
||||
'url' => Url::toRoute('/admin/setting/file'),
|
||||
'icon' => '<i class="fa fa-file"></i>',
|
||||
'sortOrder' => 200,
|
||||
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'setting' && Yii::$app->controller->action->id == 'file'),
|
||||
'isVisible' => Yii::$app->user->isAdmin(),
|
||||
]);
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('AdminModule.widgets_AdminMenuWidget', 'Files'),
|
||||
'url' => Url::toRoute('/admin/setting/file'),
|
||||
'icon' => 'file',
|
||||
'sortOrder' => 200,
|
||||
'isActive' => MenuLink::isActiveState('admin', 'setting', 'file'),
|
||||
'isVisible' => Yii::$app->user->isAdmin(),
|
||||
]));
|
||||
|
||||
$this->addItem([
|
||||
'label' => Yii::t('AdminModule.views_setting_mailing', 'E-Mail'),
|
||||
'url' => Url::toRoute(['/admin/setting/mailing-server']),
|
||||
'icon' => '<i class="fa fa-envelope"></i>',
|
||||
'sortOrder' => 250,
|
||||
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'setting' && Yii::$app->controller->action->id == 'mailing-server'),
|
||||
]);
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('AdminModule.views_setting_mailing', 'E-Mail'),
|
||||
'url' => Url::toRoute(['/admin/setting/mailing-server']),
|
||||
'icon' => 'envelope',
|
||||
'sortOrder' => 250,
|
||||
'isActive' => MenuLink::isActiveState('admin', 'setting', 'mailing-server'),
|
||||
'isVisible' => Yii::$app->user->isAdmin(),
|
||||
]));
|
||||
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('AdminModule.widgets_AdminMenuWidget', 'Proxy'),
|
||||
'url' => Url::toRoute('/admin/setting/proxy'),
|
||||
'icon' => '<i class="fa fa-sitemap"></i>',
|
||||
'icon' => 'sitemap',
|
||||
'sortOrder' => 300,
|
||||
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'setting' && Yii::$app->controller->action->id == 'proxy'),
|
||||
'isActive' => MenuLink::isActiveState('admin', 'setting', 'proxy'),
|
||||
'isVisible' => Yii::$app->user->isAdmin(),
|
||||
]);
|
||||
$this->addItem([
|
||||
]));
|
||||
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('AdminModule.widgets_AdminMenuWidget', 'Statistics'),
|
||||
'url' => Url::toRoute('/admin/setting/statistic'),
|
||||
'icon' => '<i class="fa fa-bar-chart-o"></i>',
|
||||
'icon' => 'bar-chart-o',
|
||||
'sortOrder' => 400,
|
||||
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'setting' && Yii::$app->controller->action->id == 'statistic'),
|
||||
'isActive' => MenuLink::isActiveState('admin', 'setting', 'statistic'),
|
||||
'isVisible' => Yii::$app->user->isAdmin(),
|
||||
]);
|
||||
]));
|
||||
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('AdminModule.widgets_AdminMenuWidget', 'OEmbed'),
|
||||
'url' => Url::toRoute('/admin/setting/oembed'),
|
||||
'icon' => '<i class="fa fa-cloud"></i>',
|
||||
'icon' => 'cloud',
|
||||
'sortOrder' => 500,
|
||||
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'setting' && (Yii::$app->controller->action->id == 'oembed' || Yii::$app->controller->action->id == 'oembed-edit')),
|
||||
'isActive' => MenuLink::isActiveState('admin', 'setting', 'oembed-edit'),
|
||||
'isVisible' => Yii::$app->user->isAdmin(),
|
||||
]);
|
||||
]));
|
||||
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('AdminModule.widgets_AdminMenuWidget', 'Logs'),
|
||||
'url' => Url::toRoute('/admin/setting/logs'),
|
||||
'icon' => '<i class="fa fa-terminal"></i>',
|
||||
'icon' => 'terminal',
|
||||
'sortOrder' => 600,
|
||||
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'setting' && (Yii::$app->controller->action->id == 'logs' || Yii::$app->controller->action->id == 'logs-edit')),
|
||||
'isActive' => MenuLink::isActiveState('admin', 'setting', ['logs', 'logs-edit']),
|
||||
'isVisible' => Yii::$app->user->isAdmin(),
|
||||
]);
|
||||
]));
|
||||
|
||||
parent::init();
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
namespace humhub\modules\admin\widgets;
|
||||
|
||||
use humhub\modules\ui\menu\MenuLink;
|
||||
use humhub\modules\ui\menu\widgets\SubTabMenu;
|
||||
use Yii;
|
||||
use yii\helpers\Url;
|
||||
@ -23,18 +24,19 @@ class AuthenticationMenu extends SubTabMenu
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('AdminModule.setting', 'General'),
|
||||
'url' => Url::toRoute(['/admin/authentication']),
|
||||
'url' => ['/admin/authentication'],
|
||||
'sortOrder' => 100,
|
||||
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'authentication' && Yii::$app->controller->action->id == 'index'),
|
||||
]);
|
||||
$this->addItem([
|
||||
'isActive' => MenuLink::isActiveState('admin', 'authentication', 'index'),
|
||||
]));
|
||||
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('AdminModule.setting', "LDAP"),
|
||||
'url' => Url::toRoute(['/admin/authentication/authentication-ldap']),
|
||||
'url' => ['/admin/authentication/authentication-ldap'],
|
||||
'sortOrder' => 200,
|
||||
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'authentication' && Yii::$app->controller->action->id == 'authentication-ldap'),
|
||||
]);
|
||||
'isActive' => MenuLink::isActiveState('admin', 'authentication', 'authentication-ldap'),
|
||||
]));
|
||||
|
||||
parent::init();
|
||||
}
|
||||
|
@ -8,9 +8,9 @@
|
||||
|
||||
namespace humhub\modules\admin\widgets;
|
||||
|
||||
use humhub\modules\ui\menu\widgets\SubTabMenu;
|
||||
use Yii;
|
||||
use yii\helpers\Url;
|
||||
use humhub\modules\ui\menu\MenuLink;
|
||||
use humhub\modules\ui\menu\widgets\SubTabMenu;
|
||||
|
||||
/**
|
||||
* Group Administration Menu
|
||||
@ -28,24 +28,27 @@ class GroupManagerMenu extends SubTabMenu
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('AdminModule.user', 'Settings'),
|
||||
'url' => Url::toRoute(['/admin/group/edit', 'id' => $this->group->id]),
|
||||
'url' => ['/admin/group/edit', 'id' => $this->group->id],
|
||||
'sortOrder' => 100,
|
||||
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'group' && Yii::$app->controller->action->id == 'edit'),
|
||||
]);
|
||||
$this->addItem([
|
||||
'isActive' => MenuLink::isActiveState('admin', 'group', 'edit')
|
||||
]));
|
||||
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('AdminModule.user', "Permissions"),
|
||||
'url' => Url::toRoute(['/admin/group/manage-permissions', 'id' => $this->group->id]),
|
||||
'url' => ['/admin/group/manage-permissions', 'id' => $this->group->id],
|
||||
'sortOrder' => 200,
|
||||
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'group' && Yii::$app->controller->action->id == 'manage-permissions'),
|
||||
]);
|
||||
$this->addItem([
|
||||
'isActive' => MenuLink::isActiveState('admin', 'group', 'manage-permissions')
|
||||
]));
|
||||
|
||||
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('AdminModule.user', "Members"),
|
||||
'url' => Url::toRoute(['/admin/group/manage-group-users', 'id' => $this->group->id]),
|
||||
'url' => ['/admin/group/manage-group-users', 'id' => $this->group->id],
|
||||
'sortOrder' => 200,
|
||||
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'group' && Yii::$app->controller->action->id == 'manage-group-users'),
|
||||
]);
|
||||
'isActive' => MenuLink::isActiveState('admin', 'group', 'manage-group-users')
|
||||
]));
|
||||
|
||||
parent::init();
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
namespace humhub\modules\admin\widgets;
|
||||
|
||||
use humhub\modules\ui\menu\MenuLink;
|
||||
use humhub\modules\ui\menu\widgets\SubTabMenu;
|
||||
use Yii;
|
||||
use yii\helpers\Url;
|
||||
@ -17,19 +18,17 @@ use yii\helpers\Url;
|
||||
*/
|
||||
class GroupMenu extends SubTabMenu
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('AdminModule.views_user_index', 'Overview'),
|
||||
'url' => Url::toRoute(['/admin/group/index']),
|
||||
'url' => ['/admin/group/index'],
|
||||
'sortOrder' => 100,
|
||||
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'group' && Yii::$app->controller->action->id == 'index'),
|
||||
]);
|
||||
|
||||
'isActive' => MenuLink::isActiveState('admin', 'group', 'index'),
|
||||
]));
|
||||
parent::init();
|
||||
}
|
||||
|
||||
|
@ -8,9 +8,10 @@
|
||||
|
||||
namespace humhub\modules\admin\widgets;
|
||||
|
||||
use humhub\modules\ui\menu\widgets\TabMenu;
|
||||
use Yii;
|
||||
use yii\helpers\Url;
|
||||
use humhub\modules\ui\menu\MenuLink;
|
||||
use humhub\modules\ui\menu\widgets\TabMenu;
|
||||
|
||||
|
||||
/**
|
||||
* Group Administration Menu
|
||||
@ -23,40 +24,40 @@ class InformationMenu extends TabMenu
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('AdminModule.information', 'About HumHub'),
|
||||
'url' => Url::to(['/admin/information/about']),
|
||||
'url' => ['/admin/information/about'],
|
||||
'sortOrder' => 100,
|
||||
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'information' && Yii::$app->controller->action->id == 'about'),
|
||||
]);
|
||||
'isActive' => MenuLink::isActiveState('admin', 'information', 'about')
|
||||
]));
|
||||
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('AdminModule.information', 'Prerequisites'),
|
||||
'url' => Url::to(['/admin/information/prerequisites']),
|
||||
'url' => ['/admin/information/prerequisites'],
|
||||
'sortOrder' => 200,
|
||||
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'information' && Yii::$app->controller->action->id == 'prerequisites'),
|
||||
]);
|
||||
'isActive' => MenuLink::isActiveState('admin', 'information', 'prerequisites')
|
||||
]));
|
||||
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('AdminModule.information', 'Database'),
|
||||
'url' => Url::to(['/admin/information/database']),
|
||||
'url' => ['/admin/information/database'],
|
||||
'sortOrder' => 300,
|
||||
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'information' && Yii::$app->controller->action->id == 'database'),
|
||||
]);
|
||||
'isActive' => MenuLink::isActiveState('admin', 'information', 'database')
|
||||
]));
|
||||
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('AdminModule.information', 'Background Jobs'),
|
||||
'url' => Url::to(['/admin/information/background-jobs']),
|
||||
'url' => ['/admin/information/background-jobs'],
|
||||
'sortOrder' => 400,
|
||||
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'information' && Yii::$app->controller->action->id == 'background-jobs'),
|
||||
]);
|
||||
'isActive' => MenuLink::isActiveState('admin', 'information', 'background-jobs')
|
||||
]));
|
||||
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('AdminModule.information', 'Logging'),
|
||||
'url' => Url::toRoute(['/admin/logging']),
|
||||
'url' => ['/admin/logging'],
|
||||
'sortOrder' => 500,
|
||||
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'logging'),
|
||||
]);
|
||||
'isActive' => MenuLink::isActiveState('admin', 'logging')
|
||||
]));
|
||||
|
||||
parent::init();
|
||||
}
|
||||
|
@ -8,9 +8,10 @@
|
||||
|
||||
namespace humhub\modules\admin\widgets;
|
||||
|
||||
use humhub\modules\ui\menu\widgets\TabMenu;
|
||||
use Yii;
|
||||
use yii\helpers\Url;
|
||||
use humhub\modules\ui\menu\MenuLink;
|
||||
use humhub\modules\ui\menu\widgets\TabMenu;
|
||||
use humhub\modules\admin\permissions\ManageSettings;
|
||||
|
||||
/**
|
||||
* Group Administration Menu
|
||||
@ -23,46 +24,46 @@ class SettingsMenu extends TabMenu
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$canEditSettings = Yii::$app->user->can(new \humhub\modules\admin\permissions\ManageSettings());
|
||||
$canEditSettings = Yii::$app->user->can(ManageSettings::class);
|
||||
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('AdminModule.widgets_AdminMenuWidget', 'General'),
|
||||
'url' => Url::toRoute('/admin/setting/index'),
|
||||
'url' => ['/admin/setting/index'],
|
||||
'sortOrder' => 100,
|
||||
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'setting' && Yii::$app->controller->action->id == 'basic'),
|
||||
'isActive' => MenuLink::isActiveState('admin', 'setting', 'basic'),
|
||||
'isVisible' => $canEditSettings
|
||||
]);
|
||||
]));
|
||||
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('AdminModule.widgets_AdminMenuWidget', 'Appearance'),
|
||||
'url' => Url::toRoute('/admin/setting/design'),
|
||||
'url' => ['/admin/setting/design'],
|
||||
'sortOrder' => 200,
|
||||
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'setting' && Yii::$app->controller->action->id == 'design'),
|
||||
'isActive' => MenuLink::isActiveState('admin', 'setting', 'design'),
|
||||
'isVisible' => $canEditSettings
|
||||
]);
|
||||
]));
|
||||
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('AdminModule.widgets_AdminMenuWidget', 'E-Mail summaries'),
|
||||
'url' => Url::toRoute('/activity/admin/defaults'),
|
||||
'url' => ['/activity/admin/defaults'],
|
||||
'sortOrder' => 300,
|
||||
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'activity' && Yii::$app->controller->id == 'admin' && (Yii::$app->controller->action->id == 'defaults')),
|
||||
'isActive' => MenuLink::isActiveState('activity', 'admin', 'defaults'),
|
||||
'isVisible' => $canEditSettings
|
||||
]);
|
||||
]));
|
||||
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('AdminModule.widgets_AdminMenuWidget', 'Notifications'),
|
||||
'url' => Url::toRoute('/notification/admin/defaults'),
|
||||
'url' => ['/notification/admin/defaults'],
|
||||
'sortOrder' => 400,
|
||||
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'notification' && Yii::$app->controller->id == 'admin' && (Yii::$app->controller->action->id == 'defaults')),
|
||||
'isActive' => MenuLink::isActiveState('notification', 'admin', 'defaults'),
|
||||
'isVisible' => $canEditSettings
|
||||
]);
|
||||
]));
|
||||
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('AdminModule.widgets_AdminMenuWidget', 'Advanced'),
|
||||
'url' => Url::toRoute('/admin/setting/advanced'),
|
||||
'url' => ['/admin/setting/advanced'],
|
||||
'sortOrder' => 1000,
|
||||
'isVisible' => $canEditSettings
|
||||
]);
|
||||
]));
|
||||
|
||||
parent::init();
|
||||
}
|
||||
|
@ -8,9 +8,9 @@
|
||||
|
||||
namespace humhub\modules\admin\widgets;
|
||||
|
||||
use humhub\modules\ui\menu\MenuEntry;
|
||||
use Yii;
|
||||
use yii\helpers\Url;
|
||||
use humhub\modules\ui\menu\MenuLink;
|
||||
use humhub\modules\admin\permissions\ManageSettings;
|
||||
use humhub\modules\admin\permissions\ManageSpaces;
|
||||
use humhub\modules\ui\menu\widgets\TabMenu;
|
||||
@ -28,21 +28,21 @@ class SpaceMenu extends TabMenu
|
||||
public function init()
|
||||
{
|
||||
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('AdminModule.views_space_index', 'Spaces'),
|
||||
'url' => Url::toRoute(['/admin/space/index']),
|
||||
'sortOrder' => 100,
|
||||
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'space' && Yii::$app->controller->action->id == 'index'),
|
||||
'isVisible' => Yii::$app->user->can(new ManageSpaces())
|
||||
]);
|
||||
'isActive' => MenuLink::isActiveState('admin', 'space', 'index'),
|
||||
'isVisible' => Yii::$app->user->can(ManageSpaces::class)
|
||||
]));
|
||||
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('AdminModule.views_space_index', 'Settings'),
|
||||
'url' => Url::toRoute(['/admin/space/settings']),
|
||||
'sortOrder' => 200,
|
||||
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'space' && Yii::$app->controller->action->id == 'settings'),
|
||||
'isVisible' => Yii::$app->user->can(new ManageSettings())
|
||||
]);
|
||||
'isActive' => MenuLink::isActiveState('admin', 'space', 'settings'),
|
||||
'isVisible' => Yii::$app->user->can(ManageSettings::class)
|
||||
]));
|
||||
|
||||
parent::init();
|
||||
}
|
||||
|
@ -8,13 +8,13 @@
|
||||
|
||||
namespace humhub\modules\admin\widgets;
|
||||
|
||||
use Yii;
|
||||
use humhub\modules\admin\models\UserApprovalSearch;
|
||||
use humhub\modules\admin\permissions\ManageGroups;
|
||||
use humhub\modules\admin\permissions\ManageSettings;
|
||||
use humhub\modules\admin\permissions\ManageUsers;
|
||||
use humhub\modules\ui\menu\MenuLink;
|
||||
use humhub\modules\ui\menu\widgets\TabMenu;
|
||||
use Yii;
|
||||
use yii\helpers\Url;
|
||||
|
||||
/**
|
||||
* User Administration Menu
|
||||
@ -29,60 +29,55 @@ class UserMenu extends TabMenu
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('AdminModule.views_user_index', 'Users'),
|
||||
'url' => Url::to(['/admin/user/index']),
|
||||
'url' => ['/admin/user/index'],
|
||||
'sortOrder' => 100,
|
||||
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && (Yii::$app->controller->id == 'user' || Yii::$app->controller->id == 'pending-registrations')),
|
||||
'isActive' => MenuLink::isActiveState('admin', ['user', 'pending-registrations']),
|
||||
'isVisible' => Yii::$app->user->can([
|
||||
new ManageUsers(),
|
||||
new ManageGroups(),
|
||||
ManageUsers::class,
|
||||
ManageGroups::class,
|
||||
])
|
||||
]);
|
||||
]));
|
||||
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('AdminModule.views_user_index', 'Settings'),
|
||||
'url' => Url::to(['/admin/authentication']),
|
||||
'url' => ['/admin/authentication'],
|
||||
'sortOrder' => 200,
|
||||
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'authentication'),
|
||||
'isVisible' => Yii::$app->user->can([
|
||||
new ManageSettings()
|
||||
])
|
||||
]);
|
||||
'isActive' => MenuLink::isActiveState('admin', 'authentication'),
|
||||
'isVisible' => Yii::$app->user->can(ManageSettings::class)
|
||||
]));
|
||||
|
||||
$approvalCount = UserApprovalSearch::getUserApprovalCount();
|
||||
|
||||
if ($approvalCount > 0) {
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('AdminModule.user', 'Pending approvals') . ' <span class="label label-danger">' . $approvalCount . '</span>',
|
||||
'url' => Url::to(['/admin/approval']),
|
||||
'url' => ['/admin/approval'],
|
||||
'sortOrder' => 300,
|
||||
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'approval'),
|
||||
'isActive' => MenuLink::isActiveState('admin', 'approval'),
|
||||
'isVisible' => Yii::$app->user->can([
|
||||
new ManageUsers(),
|
||||
new ManageGroups()
|
||||
ManageUsers::class,
|
||||
ManageGroups::class
|
||||
])
|
||||
]);
|
||||
]));
|
||||
}
|
||||
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('AdminModule.user', 'Profiles'),
|
||||
'url' => Url::to(['/admin/user-profile']),
|
||||
'url' => ['/admin/user-profile'],
|
||||
'sortOrder' => 400,
|
||||
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'user-profile'),
|
||||
'isVisible' => Yii::$app->user->can([
|
||||
new ManageUsers()
|
||||
])
|
||||
]);
|
||||
'isActive' => MenuLink::isActiveState('admin', 'user-profile'),
|
||||
'isVisible' => Yii::$app->user->can(ManageUsers::class)
|
||||
]));
|
||||
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('AdminModule.user', 'Groups'),
|
||||
'url' => Url::to(['/admin/group']),
|
||||
'url' => ['/admin/group'],
|
||||
'sortOrder' => 500,
|
||||
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'group'),
|
||||
'isVisible' => Yii::$app->user->can(
|
||||
new ManageGroups()
|
||||
)
|
||||
]);
|
||||
'isActive' => MenuLink::isActiveState('admin', 'group'),
|
||||
'isVisible' => Yii::$app->user->can(ManageGroups::class)
|
||||
]));
|
||||
|
||||
parent::init();
|
||||
}
|
||||
|
@ -8,9 +8,9 @@
|
||||
|
||||
namespace humhub\modules\admin\widgets;
|
||||
|
||||
use humhub\modules\ui\menu\widgets\TabMenu;
|
||||
use Yii;
|
||||
use yii\helpers\Url;
|
||||
use humhub\modules\ui\menu\MenuLink;
|
||||
use humhub\modules\ui\menu\widgets\TabMenu;
|
||||
|
||||
/**
|
||||
* User Administration Menu
|
||||
@ -25,18 +25,19 @@ class UserSettingMenu extends TabMenu
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('AdminModule.views_setting_authentication', 'General'),
|
||||
'url' => Url::toRoute(['/admin/setting/authentication']),
|
||||
'url' => ['/admin/setting/authentication'],
|
||||
'sortOrder' => 100,
|
||||
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'settings' && Yii::$app->controller->action->id == 'authentication'),
|
||||
]);
|
||||
$this->addItem([
|
||||
'isActive' => MenuLink::isActiveState('admin', 'settings', 'authentication'),
|
||||
]));
|
||||
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('AdminModule.views_setting_authentication', 'LDAP'),
|
||||
'url' => Url::toRoute(['/admin/setting/authentication-ldap']),
|
||||
'url' => ['/admin/setting/authentication-ldap'],
|
||||
'sortOrder' => 200,
|
||||
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'admin' && Yii::$app->controller->id == 'settings' && Yii::$app->controller->action->id == 'authentication-ldap'),
|
||||
]);
|
||||
'isActive' => MenuLink::isActiveState('admin', 'settings', 'authentication-ldap'),
|
||||
]));
|
||||
|
||||
parent::init();
|
||||
}
|
||||
|
@ -20,13 +20,14 @@ use humhub\modules\content\components\ContentContainerController;
|
||||
class ContentContainerHelper
|
||||
{
|
||||
/**
|
||||
* @param string|null $type type filter available since 1.4
|
||||
* @return ContentContainerActiveRecord|null currently active container from app context.
|
||||
*/
|
||||
public static function getCurrent()
|
||||
public static function getCurrent($type = null)
|
||||
{
|
||||
$controller = Yii::$app->controller;
|
||||
if($controller instanceof ContentContainerController) {
|
||||
return $controller->contentContainer;
|
||||
return (!$type || get_class($controller->contentContainer) === $type) ? $controller->contentContainer : null;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
namespace humhub\modules\dashboard;
|
||||
|
||||
use humhub\modules\ui\menu\MenuEntry;
|
||||
use humhub\modules\ui\menu\MenuLink;
|
||||
use humhub\widgets\TopMenu;
|
||||
use Yii;
|
||||
use yii\base\Event;
|
||||
@ -32,16 +32,14 @@ class Events
|
||||
/** @var TopMenu $topMenu */
|
||||
$topMenu = $event->sender;
|
||||
|
||||
$entry = new MenuEntry();
|
||||
|
||||
$entry->setId('dashboard');
|
||||
$entry->setLabel(Yii::t('DashboardModule.base', 'Dashboard'));
|
||||
$entry->setUrl(['/dashboard/dashboard']);
|
||||
$entry->setIcon('tachometer');
|
||||
$entry->setSortOrder(100);
|
||||
$entry->setIsActive((Yii::$app->controller->module && Yii::$app->controller->module->id === 'dashboard'));
|
||||
|
||||
$topMenu->addEntry($entry);
|
||||
$topMenu->addEntry(new MenuLink([
|
||||
'id' => 'dashboard',
|
||||
'label' => Yii::t('DashboardModule.base', 'Dashboard'),
|
||||
'url' => ['/dashboard/dashboard'],
|
||||
'icon' => 'tachometer',
|
||||
'sortOrder' => 100,
|
||||
'isActive' => MenuLink::isActiveState('dashboard')
|
||||
]));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
namespace humhub\modules\directory\widgets;
|
||||
|
||||
use Yii;
|
||||
use yii\helpers\Url;
|
||||
use humhub\modules\ui\menu\MenuLink;
|
||||
use humhub\modules\directory\Module;
|
||||
use humhub\modules\ui\menu\widgets\LeftNavigation;
|
||||
|
||||
@ -32,44 +32,38 @@ class Menu extends LeftNavigation
|
||||
$this->panelTitle = Yii::t('DirectoryModule.base', '<strong>Directory</strong> menu');
|
||||
|
||||
if ($module->isGroupListingEnabled()) {
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('DirectoryModule.base', 'Groups'),
|
||||
'group' => 'directory',
|
||||
'url' => Url::to(['/directory/directory/groups']),
|
||||
'url' => ['/directory/directory/groups'],
|
||||
'sortOrder' => 100,
|
||||
'isActive' => (Yii::$app->controller->action->id == "groups"),
|
||||
]);
|
||||
'isActive' => MenuLink::isActiveState('directory', 'directory', 'groups')
|
||||
]));
|
||||
}
|
||||
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('DirectoryModule.base', 'Members'),
|
||||
'group' => 'directory',
|
||||
'url' => Url::to(['/directory/directory/members']),
|
||||
'url' => ['/directory/directory/members'],
|
||||
'sortOrder' => 200,
|
||||
'isActive' => (Yii::$app->controller->action->id == "members"),
|
||||
]);
|
||||
'isActive' => MenuLink::isActiveState('directory', 'directory', 'members')
|
||||
]));
|
||||
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('DirectoryModule.base', 'Spaces'),
|
||||
'group' => 'directory',
|
||||
'url' => Url::to(['/directory/directory/spaces']),
|
||||
'url' => ['/directory/directory/spaces'],
|
||||
'sortOrder' => 300,
|
||||
'isActive' => (Yii::$app->controller->action->id == "spaces"),
|
||||
]);
|
||||
'isActive' => MenuLink::isActiveState('directory', 'directory', 'spaces')
|
||||
]));
|
||||
|
||||
if ($module->showUserProfilePosts) {
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('DirectoryModule.base', 'User profile posts'),
|
||||
'group' => 'directory',
|
||||
'url' => Url::to(['/directory/directory/user-posts']),
|
||||
'url' => ['/directory/directory/user-posts'],
|
||||
'sortOrder' => 400,
|
||||
'isActive' => (Yii::$app->controller->action->id == "user-posts"),
|
||||
]);
|
||||
'isActive' => MenuLink::isActiveState('directory', 'directory', 'user-posts')
|
||||
]));
|
||||
}
|
||||
|
||||
parent::init();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -8,9 +8,9 @@
|
||||
|
||||
namespace humhub\modules\friendship\widgets;
|
||||
|
||||
use humhub\modules\ui\menu\widgets\TabMenu;
|
||||
use Yii;
|
||||
use yii\helpers\Url;
|
||||
use humhub\modules\ui\menu\MenuLink;
|
||||
use humhub\modules\ui\menu\widgets\TabMenu;
|
||||
use humhub\modules\friendship\models\Friendship;
|
||||
|
||||
/**
|
||||
@ -30,28 +30,29 @@ class ManageMenu extends TabMenu
|
||||
public function init()
|
||||
{
|
||||
$friendCount = Friendship::getFriendsQuery($this->user)->count();
|
||||
$this->addItem([
|
||||
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('FriendshipModule.base', 'Friends') . ' (' . $friendCount . ')',
|
||||
'url' => Url::toRoute(['/friendship/manage/list']),
|
||||
'url' => ['/friendship/manage/list'],
|
||||
'sortOrder' => 100,
|
||||
'isActive' => (Yii::$app->controller->id == 'manage' && Yii::$app->controller->action->id == 'list'),
|
||||
]);
|
||||
'isActive' => MenuLink::isActiveState(null, 'manage', 'list')
|
||||
]));
|
||||
|
||||
$receivedRequestsCount = Friendship::getReceivedRequestsQuery($this->user)->count();
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('FriendshipModule.base', 'Requests') . ' (' . $receivedRequestsCount . ')',
|
||||
'url' => Url::toRoute(['/friendship/manage/requests']),
|
||||
'url' => ['/friendship/manage/requests'],
|
||||
'sortOrder' => 200,
|
||||
'isActive' => (Yii::$app->controller->id == 'manage' && Yii::$app->controller->action->id == 'requests'),
|
||||
]);
|
||||
'isActive' => MenuLink::isActiveState(null, 'manage', 'requests')
|
||||
]));
|
||||
|
||||
$sentRequestsCount = Friendship::getSentRequestsQuery($this->user)->count();
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('FriendshipModule.base', 'Sent requests') . ' (' . $sentRequestsCount . ')',
|
||||
'url' => Url::toRoute(['/friendship/manage/sent-requests']),
|
||||
'url' => ['/friendship/manage/sent-requests'],
|
||||
'sortOrder' => 300,
|
||||
'isActive' => (Yii::$app->controller->id == 'manage' && Yii::$app->controller->action->id == 'sent-requests'),
|
||||
]);
|
||||
'isActive' => MenuLink::isActiveState(null, 'manage', 'sent-requests')
|
||||
]));
|
||||
|
||||
parent::init();
|
||||
}
|
||||
|
@ -9,6 +9,7 @@
|
||||
namespace humhub\modules\space\modules\manage\widgets;
|
||||
|
||||
use Yii;
|
||||
use humhub\modules\ui\menu\MenuLink;
|
||||
use humhub\modules\ui\menu\widgets\TabMenu;
|
||||
|
||||
/**
|
||||
@ -29,19 +30,19 @@ class DefaultMenu extends TabMenu
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('AdminModule.manage', 'Basic'),
|
||||
'url' => $this->space->createUrl('/space/manage/default/index'),
|
||||
'sortOrder' => 100,
|
||||
'isActive' => (Yii::$app->controller->id == 'default' && Yii::$app->controller->action->id == 'index'),
|
||||
]);
|
||||
'isActive' => MenuLink::isActiveState(null, 'default', 'index')
|
||||
]));
|
||||
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('AdminModule.manage', 'Advanced'),
|
||||
'url' => $this->space->createUrl('/space/manage/default/advanced'),
|
||||
'sortOrder' => 200,
|
||||
'isActive' => (Yii::$app->controller->id == 'default' && Yii::$app->controller->action->id == 'advanced'),
|
||||
]);
|
||||
'isActive' => MenuLink::isActiveState(null, 'default', 'advanced')
|
||||
]));
|
||||
|
||||
parent::init();
|
||||
}
|
||||
|
@ -9,6 +9,7 @@
|
||||
namespace humhub\modules\space\modules\manage\widgets;
|
||||
|
||||
use Yii;
|
||||
use humhub\modules\ui\menu\MenuLink;
|
||||
use humhub\modules\space\models\Membership;
|
||||
use humhub\modules\space\modules\manage\models\MembershipSearch;
|
||||
use humhub\modules\ui\menu\widgets\TabMenu;
|
||||
@ -31,37 +32,37 @@ class MemberMenu extends TabMenu
|
||||
public function init()
|
||||
{
|
||||
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('SpaceModule.widgets_SpaceMembersMenu', 'Members'),
|
||||
'url' => $this->space->createUrl('/space/manage/member/index'),
|
||||
'sortOrder' => 100,
|
||||
'isActive' => (Yii::$app->controller->action->id == 'index' && Yii::$app->controller->id === 'member'),
|
||||
]);
|
||||
'isActive' => MenuLink::isActiveState(null, 'member', 'index')
|
||||
]));
|
||||
|
||||
if ($this->countPendingInvites() != 0) {
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('SpaceModule.widgets_SpaceMembersMenu', 'Pending Invites') . ' <span class="label label-danger">' . $this->countPendingInvites() . '</span>',
|
||||
'url' => $this->space->createUrl('/space/manage/member/pending-invitations'),
|
||||
'sortOrder' => 200,
|
||||
'isActive' => (Yii::$app->controller->action->id == 'pending-invitations'),
|
||||
]);
|
||||
'isActive' => MenuLink::isActiveState(null, 'member', 'pending-invitations')
|
||||
]));
|
||||
}
|
||||
if ($this->countPendingApprovals() != 0) {
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('SpaceModule.widgets_SpaceMembersMenu', 'Pending Approvals') . ' <span class="label label-danger">' . $this->countPendingApprovals() . '</span>',
|
||||
'url' => $this->space->createUrl('/space/manage/member/pending-approvals'),
|
||||
'sortOrder' => 300,
|
||||
'isActive' => (Yii::$app->controller->action->id == 'pending-approvals'),
|
||||
]);
|
||||
'isActive' => MenuLink::isActiveState(null, 'member', 'pending-approvals')
|
||||
]));
|
||||
}
|
||||
|
||||
if ($this->space->isSpaceOwner()) {
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('SpaceModule.widgets_SpaceMembersMenu', 'Owner'),
|
||||
'url' => $this->space->createUrl('/space/manage/member/change-owner'),
|
||||
'sortOrder' => 500,
|
||||
'isActive' => (Yii::$app->controller->action->id == 'change-owner'),
|
||||
]);
|
||||
'isActive' => MenuLink::isActiveState(null, 'member', 'change-owner')
|
||||
]));
|
||||
}
|
||||
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
namespace humhub\modules\space\modules\manage\widgets;
|
||||
|
||||
use humhub\modules\ui\menu\MenuLink;
|
||||
use humhub\modules\ui\menu\widgets\TabMenu;
|
||||
use Yii;
|
||||
|
||||
@ -29,19 +30,19 @@ class SecurityTabMenu extends TabMenu
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('AdminModule.manage', 'General'),
|
||||
'url' => $this->space->createUrl('/space/manage/security'),
|
||||
'sortOrder' => 100,
|
||||
'isActive' => (Yii::$app->controller->id == 'security' && Yii::$app->controller->action->id == 'index'),
|
||||
]);
|
||||
'isActive' => MenuLink::isActiveState(null, 'security', 'index'),
|
||||
]));
|
||||
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('AdminModule.manage', 'Permissions'),
|
||||
'url' => $this->space->createUrl('/space/manage/security/permissions'),
|
||||
'sortOrder' => 200,
|
||||
'isActive' => (Yii::$app->controller->id == 'security' && Yii::$app->controller->action->id == 'permissions'),
|
||||
]);
|
||||
'isActive' => MenuLink::isActiveState(null, 'security', 'permissions'),
|
||||
]));
|
||||
|
||||
parent::init();
|
||||
}
|
||||
|
@ -9,7 +9,9 @@
|
||||
namespace humhub\modules\space\widgets;
|
||||
|
||||
use humhub\modules\space\models\Space;
|
||||
use humhub\modules\ui\menu\widgets\DropDownMenu;
|
||||
use humhub\modules\ui\menu\DropdownDivider;
|
||||
use humhub\modules\ui\menu\MenuLink;
|
||||
use humhub\modules\ui\menu\widgets\DropdownMenu;
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
@ -19,7 +21,7 @@ use Yii;
|
||||
* @package humhub.modules_core.space.widgets
|
||||
* @since 0.5
|
||||
*/
|
||||
class HeaderControlsMenu extends DropDownMenu
|
||||
class HeaderControlsMenu extends DropdownMenu
|
||||
{
|
||||
/**
|
||||
* @var Space
|
||||
@ -44,83 +46,74 @@ class HeaderControlsMenu extends DropDownMenu
|
||||
|
||||
// check user rights
|
||||
if ($this->space->isAdmin()) {
|
||||
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('SpaceModule.base', 'Settings'),
|
||||
'url' => $this->space->createUrl('/space/manage'),
|
||||
'icon' => '<i class="fa fa-cogs"></i>',
|
||||
'sortOrder' => 100,
|
||||
'isActive' => (Yii::$app->controller->id === 'default'),
|
||||
]);
|
||||
'icon' => 'cogs',
|
||||
'sortOrder' => 100
|
||||
]));
|
||||
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('SpaceModule.widgets_SpaceAdminMenuWidget', 'Security'),
|
||||
'url' => $this->space->createUrl('/space/manage/security'),
|
||||
'icon' => '<i class="fa fa-lock"></i>',
|
||||
'icon' => 'lock',
|
||||
'sortOrder' => 200,
|
||||
'isActive' => (Yii::$app->controller->id === 'security'),
|
||||
]);
|
||||
]));
|
||||
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('SpaceModule.widgets_SpaceAdminMenuWidget', 'Members'),
|
||||
'url' => $this->space->createUrl('/space/manage/member'),
|
||||
'icon' => '<i class="fa fa-group"></i>',
|
||||
'sortOrder' => 200,
|
||||
'isActive' => (Yii::$app->controller->id === 'member'),
|
||||
]);
|
||||
'icon' => 'group',
|
||||
'sortOrder' => 300
|
||||
]));
|
||||
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('SpaceModule.widgets_SpaceAdminMenuWidget', 'Modules'),
|
||||
'url' => $this->space->createUrl('/space/manage/module'),
|
||||
'icon' => '<i class="fa fa-rocket"></i>',
|
||||
'sortOrder' => 300,
|
||||
'isActive' => (Yii::$app->controller->id === 'module'),
|
||||
]);
|
||||
'icon' => 'rocket',
|
||||
'sortOrder' => 400,
|
||||
]));
|
||||
|
||||
$this->addEntry(new DropdownDivider(['sortOrder' => 500]));
|
||||
}
|
||||
|
||||
if ($this->space->isMember()) {
|
||||
|
||||
$membership = $this->space->getMembership();
|
||||
|
||||
if (!$membership->send_notifications) {
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('SpaceModule.widgets_SpaceAdminMenuWidget', 'Receive Notifications for new content'),
|
||||
'url' => $this->space->createUrl('/space/membership/receive-notifications'),
|
||||
'icon' => '<i class="fa fa-bell"></i>',
|
||||
'sortOrder' => 300,
|
||||
'isActive' => (Yii::$app->controller->id === 'module'),
|
||||
'icon' => 'bell',
|
||||
'sortOrder' => 600,
|
||||
'htmlOptions' => ['data-method' => 'POST']
|
||||
]);
|
||||
]));
|
||||
} else {
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('SpaceModule.widgets_SpaceAdminMenuWidget', 'Don\'t receive notifications for new content'),
|
||||
'url' => $this->space->createUrl('/space/membership/revoke-notifications'),
|
||||
'icon' => '<i class="fa fa-bell-o"></i>',
|
||||
'sortOrder' => 300,
|
||||
'isActive' => (Yii::$app->controller->id === 'module'),
|
||||
'icon' => 'bell-o',
|
||||
'sortOrder' => 600,
|
||||
'htmlOptions' => ['data-method' => 'POST']
|
||||
]);
|
||||
]));
|
||||
}
|
||||
|
||||
if (!$this->space->isSpaceOwner() && $this->space->canLeave()) {
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('SpaceModule.widgets_SpaceAdminMenuWidget', 'Cancel Membership'),
|
||||
'url' => $this->space->createUrl('/space/membership/revoke-membership'),
|
||||
'icon' => '<i class="fa fa-times"></i>',
|
||||
'sortOrder' => 300,
|
||||
'isActive' => (Yii::$app->controller->id === 'module'),
|
||||
'icon' => 'times',
|
||||
'sortOrder' => 700,
|
||||
'htmlOptions' => ['data-method' => 'POST']
|
||||
]);
|
||||
]));
|
||||
}
|
||||
|
||||
if ($membership->show_at_dashboard) {
|
||||
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('SpaceModule.widgets_SpaceAdminMenuWidget', 'Hide posts on dashboard'),
|
||||
'url' => $this->space->createUrl('/space/membership/switch-dashboard-display', ['show' => 0]),
|
||||
'icon' => '<i class="fa fa-eye-slash"></i>',
|
||||
'sortOrder' => 400,
|
||||
'isActive' => (Yii::$app->controller->id === 'module'),
|
||||
'icon' => 'eye-slash',
|
||||
'sortOrder' => 800,
|
||||
'htmlOptions' => [
|
||||
'data-method' => 'POST',
|
||||
'class' => 'tt',
|
||||
@ -128,21 +121,20 @@ class HeaderControlsMenu extends DropDownMenu
|
||||
'data-placement' => 'left',
|
||||
'title' => Yii::t('SpaceModule.widgets_SpaceAdminMenuWidget', 'This option will hide new content from this space at your dashboard')
|
||||
]
|
||||
]);
|
||||
]));
|
||||
} else {
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('SpaceModule.widgets_SpaceAdminMenuWidget', 'Show posts on dashboard'),
|
||||
'url' => $this->space->createUrl('/space/membership/switch-dashboard-display', ['show' => 1]),
|
||||
'icon' => '<i class="fa fa-eye"></i>',
|
||||
'sortOrder' => 400,
|
||||
'isActive' => (Yii::$app->controller->id === 'module'),
|
||||
'icon' => 'fa-eye',
|
||||
'sortOrder' => 800,
|
||||
'htmlOptions' => ['data-method' => 'POST',
|
||||
'class' => 'tt',
|
||||
'data-toggle' => 'tooltip',
|
||||
'data-placement' => 'left',
|
||||
'title' => Yii::t('SpaceModule.widgets_SpaceAdminMenuWidget', 'This option will show new content from this space at your dashboard')
|
||||
]
|
||||
]);
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,9 @@
|
||||
namespace humhub\modules\space\widgets;
|
||||
|
||||
use humhub\modules\content\components\ContentContainerController;
|
||||
use humhub\modules\content\helpers\ContentContainerHelper;
|
||||
use humhub\modules\space\models\Space;
|
||||
use humhub\modules\ui\menu\MenuLink;
|
||||
use humhub\modules\ui\menu\widgets\LeftNavigation;
|
||||
use Yii;
|
||||
use yii\base\Exception;
|
||||
@ -31,27 +33,25 @@ class Menu extends LeftNavigation
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
if ($this->space === null && Yii::$app->controller instanceof ContentContainerController && Yii::$app->controller->contentContainer instanceof Space) {
|
||||
$this->space = Yii::$app->controller->contentContainer;
|
||||
if(!$this->space) {
|
||||
$this->space = ContentContainerHelper::getCurrent(Space::class);
|
||||
}
|
||||
|
||||
if ($this->space === null) {
|
||||
if (!$this->space) {
|
||||
throw new Exception('Could not instance space menu without space!');
|
||||
}
|
||||
|
||||
$this->id = 'navigation-menu-space-' . $this->space->getUniqueId();
|
||||
|
||||
|
||||
$this->panelTitle = Yii::t('SpaceModule.widgets_SpaceMenuWidget', '<strong>Space</strong> menu');
|
||||
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('SpaceModule.widgets_SpaceMenuWidget', 'Stream'),
|
||||
'group' => 'modules',
|
||||
'url' => $this->space->createUrl('/space/space/home'),
|
||||
'icon' => '<i class="fa fa-bars"></i>',
|
||||
'icon' => 'fa-bars',
|
||||
'sortOrder' => 100,
|
||||
'isActive' => (Yii::$app->controller->id == 'space' && (Yii::$app->controller->action->id == 'index' || Yii::$app->controller->action->id == 'home') && Yii::$app->controller->module->id == 'space'),
|
||||
]);
|
||||
'isActive' => MenuLink::isActiveState('space', 'space', ['index', 'home']),
|
||||
]));
|
||||
|
||||
parent::init();
|
||||
}
|
||||
@ -66,10 +66,11 @@ class Menu extends LeftNavigation
|
||||
public static function getAvailablePages()
|
||||
{
|
||||
//Initialize the space Menu to check which active modules have an own page
|
||||
$moduleItems = (new static())->getItems('modules');
|
||||
$entries = (new static())->getEntries(MenuLink::class);
|
||||
$result = [];
|
||||
foreach ($moduleItems as $moduleItem) {
|
||||
$result[$moduleItem['url']] = $moduleItem['label'];
|
||||
foreach ($entries as $entry) {
|
||||
/* @var $entry MenuLink */
|
||||
$result[$entry->getUrl()] = $entry->getLabel();
|
||||
}
|
||||
|
||||
return $result;
|
||||
@ -78,6 +79,7 @@ class Menu extends LeftNavigation
|
||||
/**
|
||||
* Returns space default / homepage
|
||||
*
|
||||
* @param Space $space
|
||||
* @return string|null the url to redirect or null for default home
|
||||
*/
|
||||
public static function getDefaultPageUrl($space)
|
||||
@ -89,10 +91,10 @@ class Menu extends LeftNavigation
|
||||
$pages = static::getAvailablePages();
|
||||
if (isset($pages[$indexUrl])) {
|
||||
return $indexUrl;
|
||||
} else {
|
||||
//Either the module was deactivated or url changed
|
||||
$settings->contentContainer($space)->delete('indexUrl');
|
||||
}
|
||||
|
||||
//Either the module was deactivated or url changed
|
||||
$settings->contentContainer($space)->delete('indexUrl');
|
||||
}
|
||||
|
||||
return null;
|
||||
@ -101,6 +103,7 @@ class Menu extends LeftNavigation
|
||||
/**
|
||||
* Returns space default / homepage
|
||||
*
|
||||
* @param $space Space
|
||||
* @return string|null the url to redirect or null for default home
|
||||
*/
|
||||
public static function getGuestsDefaultPageUrl($space)
|
||||
@ -112,10 +115,10 @@ class Menu extends LeftNavigation
|
||||
$pages = static::getAvailablePages();
|
||||
if (isset($pages[$indexUrl])) {
|
||||
return $indexUrl;
|
||||
} else {
|
||||
//Either the module was deactivated or url changed
|
||||
$settings->contentContainer($space)->delete('indexGuestUrl');
|
||||
}
|
||||
|
||||
//Either the module was deactivated or url changed
|
||||
$settings->contentContainer($space)->delete('indexGuestUrl');
|
||||
}
|
||||
|
||||
return null;
|
||||
|
38
protected/humhub/modules/ui/menu/DropdownDivider.php
Normal file
38
protected/humhub/modules/ui/menu/DropdownDivider.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @link https://www.humhub.org/
|
||||
* @copyright Copyright (c) 2018 HumHub GmbH & Co. KG
|
||||
* @license https://www.humhub.com/licences
|
||||
*/
|
||||
|
||||
namespace humhub\modules\ui\menu;
|
||||
|
||||
use humhub\modules\ui\menu\widgets\Menu;
|
||||
use yii\bootstrap\Html;
|
||||
|
||||
/**
|
||||
* Class DropdownDivider
|
||||
*
|
||||
* Used for rendering divider within a DropdownMenu.
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* ```php
|
||||
* $dropdown->addEntry(new DropdownDivider(['sortOrder' => 100]);
|
||||
* ```
|
||||
*
|
||||
* @since 1.4
|
||||
* @see Menu
|
||||
*/
|
||||
class DropdownDivider extends MenuEntry
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function render($extraHtmlOptions = [])
|
||||
{
|
||||
Html::addCssClass($extraHtmlOptions, 'divider');
|
||||
return Html::tag('li', '', $this->getHtmlOptions($extraHtmlOptions));
|
||||
}
|
||||
}
|
@ -8,143 +8,60 @@
|
||||
|
||||
namespace humhub\modules\ui\menu;
|
||||
|
||||
use humhub\modules\ui\icon\widgets\Icon;
|
||||
use humhub\modules\ui\menu\widgets\Menu;
|
||||
use Yii;
|
||||
use yii\base\BaseObject;
|
||||
use yii\bootstrap\Html;
|
||||
use yii\helpers\Url;
|
||||
|
||||
/**
|
||||
* Class MenuEntry
|
||||
*
|
||||
* A menu entry represents a link inside a navigation.
|
||||
* An abstract menu entry class. Subclasses need to extend the [[render()]] function.
|
||||
*
|
||||
* @since 1.4
|
||||
* @see Menu
|
||||
* @package humhub\modules\ui\widgets
|
||||
*/
|
||||
class MenuEntry extends BaseObject
|
||||
abstract class MenuEntry extends BaseObject
|
||||
{
|
||||
/**
|
||||
* @var string the label of the menu entry
|
||||
* @var string menu entry identifier (optional)
|
||||
*/
|
||||
protected $label;
|
||||
|
||||
/**
|
||||
* @var string|array the url or route
|
||||
*/
|
||||
protected $url;
|
||||
|
||||
/**
|
||||
* @var bool mark this entry as active
|
||||
*/
|
||||
protected $isActive = false;
|
||||
|
||||
/**
|
||||
* @var Icon the icon
|
||||
*/
|
||||
protected $icon;
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* @var int the sort order
|
||||
*/
|
||||
protected $sortOrder;
|
||||
|
||||
/**
|
||||
* @var string menu entry identifier (optional)
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* @var array additional html options for the link HTML tag
|
||||
*/
|
||||
protected $htmlOptions = [];
|
||||
|
||||
/**
|
||||
* @var bool use PJAX link if possible
|
||||
*/
|
||||
protected $pjaxEnabled = true;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $isVisible = true;
|
||||
|
||||
/**
|
||||
* @var string optional badge (e.g. new item count) not supported by all templates
|
||||
* @var bool mark this entry as active
|
||||
*/
|
||||
protected $badgeText;
|
||||
protected $isActive = false;
|
||||
|
||||
/**
|
||||
* Renders the link tag for this menu entry
|
||||
* Renders the entry html, this function should respect [[htmlOptions]] array by calling [[getHtmlOptions()]] and passing
|
||||
* the $extraHtmlOptions array as for example:
|
||||
*
|
||||
* @param $htmlOptions array additional html options for the link tag
|
||||
* ```php
|
||||
*
|
||||
* return Html::a($label, $url, $this->getHtmlOptions($extraHtmlOptions));
|
||||
*
|
||||
* ```
|
||||
*
|
||||
* @param array $extraHtmlOptions
|
||||
* @return string the Html link
|
||||
*/
|
||||
public function renderLinkTag($htmlOptions = [])
|
||||
{
|
||||
return Html::a(
|
||||
$this->getIcon() . ' ' . $this->getLabel(),
|
||||
$this->getUrl(),
|
||||
$this->getHtmlOptions($htmlOptions)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $label string the label
|
||||
*/
|
||||
public function setLabel($label)
|
||||
{
|
||||
$this->label = $label;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string the label
|
||||
*/
|
||||
public function getLabel()
|
||||
{
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Icon the icon
|
||||
*/
|
||||
public function getIcon()
|
||||
{
|
||||
return $this->icon;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $icon Icon|string the icon instance or icon name
|
||||
*/
|
||||
public function setIcon($icon)
|
||||
{
|
||||
$this->icon = Icon::get($icon);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the URL
|
||||
*
|
||||
* @param $url array|string
|
||||
*/
|
||||
public function setUrl($url)
|
||||
{
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the URL
|
||||
*
|
||||
* @param bool $asString return the URL as string
|
||||
* @return array|string
|
||||
*/
|
||||
public function getUrl($asString = true)
|
||||
{
|
||||
if ($asString) {
|
||||
return Url::to($this->url);
|
||||
}
|
||||
|
||||
return $this->url;
|
||||
}
|
||||
abstract public function render($extraHtmlOptions = []);
|
||||
|
||||
/**
|
||||
* @return boolean is active
|
||||
@ -164,18 +81,66 @@ class MenuEntry extends BaseObject
|
||||
|
||||
/**
|
||||
* @param $state boolean
|
||||
* @return static
|
||||
*/
|
||||
public function setIsActive($state)
|
||||
{
|
||||
$this->isActive = $state;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Activates this MenuEntry in case the given moduleId, controllerId and actionId matches the current request.
|
||||
* @param string $moduleId controller module id
|
||||
* @param array|string $controllerIds controller id
|
||||
* @param array|string $actionIds action id
|
||||
* @return static
|
||||
*/
|
||||
public function setIsActiveState($moduleId, $controllerIds = [], $actionIds = [])
|
||||
{
|
||||
|
||||
$this->isActive = static::isActiveState($moduleId,$controllerIds,$actionIds);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public static function isActiveState($moduleId = null, $controllerIds = [], $actionIds = [])
|
||||
{
|
||||
if($moduleId && (!Yii::$app->controller->module || Yii::$app->controller->module->id !== $moduleId)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(empty($controllerIds) && empty($actionIds)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if($controllerIds && !is_array($controllerIds)) {
|
||||
$controllerIds = [$controllerIds];
|
||||
}
|
||||
|
||||
if(!empty($controllerIds) && !in_array(Yii::$app->controller->id, $controllerIds)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if($actionIds && !is_array($actionIds)) {
|
||||
$actionIds = [$actionIds];
|
||||
}
|
||||
|
||||
if(!empty($actionIds) && !in_array(Yii::$app->controller->action->id, $actionIds)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $id string the id
|
||||
* @return static
|
||||
*/
|
||||
public function setId($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -186,51 +151,48 @@ class MenuEntry extends BaseObject
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares this entry with the given entry
|
||||
* @param MenuEntry $entry
|
||||
* @return bool
|
||||
*/
|
||||
public function compare(MenuEntry $entry)
|
||||
{
|
||||
return !empty($this->getId()) && $this->getId() === $entry->getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Html options for the menu entry link tag.
|
||||
*
|
||||
* @param $extraOptions array additional options to merge
|
||||
* @return array
|
||||
*/
|
||||
public function getHtmlOptions($extraOptions = [])
|
||||
{
|
||||
$options = $this->htmlOptions;
|
||||
|
||||
if (isset($extraOptions['class']) && isset($options['class'])) {
|
||||
if(isset($extraOptions['class'])) {
|
||||
Html::addCssClass($options, $extraOptions['class']);
|
||||
} elseif (isset($extraOptions['class'])) {
|
||||
$options['class'] = $extraOptions['class'];
|
||||
}
|
||||
|
||||
if(isset($extraOptions['style'])) {
|
||||
Html::addCssStyle($options, $extraOptions['style']);
|
||||
}
|
||||
|
||||
if ($this->isActive) {
|
||||
Html::addCssClass($options, 'active');
|
||||
}
|
||||
|
||||
return $options;
|
||||
return array_merge($extraOptions, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $htmlOptions
|
||||
* @return static
|
||||
*/
|
||||
public function setHtmlOptions($htmlOptions)
|
||||
{
|
||||
$this->htmlOptions = $htmlOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isPjaxEnabled()
|
||||
{
|
||||
return $this->pjaxEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $pjaxEnabled
|
||||
*/
|
||||
public function setPjaxEnabled($pjaxEnabled)
|
||||
{
|
||||
$this->pjaxEnabled = $pjaxEnabled;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -243,26 +205,12 @@ class MenuEntry extends BaseObject
|
||||
|
||||
/**
|
||||
* @param bool $isVisible
|
||||
* @return static
|
||||
*/
|
||||
public function setIsVisible($isVisible)
|
||||
{
|
||||
$this->isVisible = $isVisible;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getBadgeText()
|
||||
{
|
||||
return $this->badgeText;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $badgeText
|
||||
*/
|
||||
public function setBadgeText($badgeText)
|
||||
{
|
||||
$this->badgeText = $badgeText;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -275,75 +223,11 @@ class MenuEntry extends BaseObject
|
||||
|
||||
/**
|
||||
* @param int $sortOrder
|
||||
* @return static
|
||||
*/
|
||||
public function setSortOrder($sortOrder)
|
||||
{
|
||||
$this->sortOrder = $sortOrder;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates MenuEntry by old and deprecated array structure
|
||||
*
|
||||
* @deprecated since 1.4
|
||||
* @param $item
|
||||
* @return MenuEntry
|
||||
*/
|
||||
public static function createByArray($item)
|
||||
{
|
||||
$entry = new static;
|
||||
|
||||
if (isset($item['id'])) {
|
||||
$entry->id = $item['id'];
|
||||
}
|
||||
|
||||
if (isset($item['label'])) {
|
||||
$entry->label = $item['label'];
|
||||
}
|
||||
|
||||
if (isset($item['icon'])) {
|
||||
$entry->icon = $item['icon'];
|
||||
}
|
||||
|
||||
if (isset($item['url'])) {
|
||||
$entry->url = $item['url'];
|
||||
}
|
||||
|
||||
if (isset($item['sortOrder'])) {
|
||||
$entry->sortOrder = $item['sortOrder'];
|
||||
}
|
||||
|
||||
if (isset($item['isActive'])) {
|
||||
$entry->isActive = $item['isActive'];
|
||||
}
|
||||
|
||||
if (isset($item['htmlOptions'])) {
|
||||
$entry->isActive = $item['htmlOptions'];
|
||||
}
|
||||
|
||||
return $entry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the MenuEntry as array structure
|
||||
*
|
||||
* @deprecated since 1.4
|
||||
* @return array the menu entry array representation
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
if (!isset($this->htmlOptions['class'])) {
|
||||
$this->htmlOptions['class'] = '';
|
||||
}
|
||||
|
||||
return [
|
||||
'label' => $this->label,
|
||||
'id' => $this->id,
|
||||
'icon' => $this->icon,
|
||||
'url' => $this->url,
|
||||
'sortOrder' => $this->sortOrder,
|
||||
'isActive' => $this->isActive,
|
||||
'htmlOptions' => $this->htmlOptions
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
274
protected/humhub/modules/ui/menu/MenuLink.php
Normal file
274
protected/humhub/modules/ui/menu/MenuLink.php
Normal file
@ -0,0 +1,274 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @link https://www.humhub.org/
|
||||
* @copyright Copyright (c) 2018 HumHub GmbH & Co. KG
|
||||
* @license https://www.humhub.com/licences
|
||||
*/
|
||||
|
||||
namespace humhub\modules\ui\menu;
|
||||
|
||||
use humhub\modules\ui\icon\widgets\Icon;
|
||||
use humhub\modules\ui\menu\widgets\Menu;
|
||||
use humhub\libs\Html;
|
||||
use humhub\widgets\Link;
|
||||
use yii\helpers\Url;
|
||||
|
||||
/**
|
||||
* Class MenuLink
|
||||
*
|
||||
* Used to render menu link entries.
|
||||
*
|
||||
* @since 1.4
|
||||
* @see Menu
|
||||
*/
|
||||
class MenuLink extends MenuEntry
|
||||
{
|
||||
/**
|
||||
* @var string the label of the menu entry
|
||||
*/
|
||||
protected $label;
|
||||
|
||||
/**
|
||||
* @var string|array the url or route
|
||||
*/
|
||||
protected $url;
|
||||
|
||||
/**
|
||||
* @var Icon the icon
|
||||
*/
|
||||
protected $icon;
|
||||
|
||||
/**
|
||||
* @var bool use PJAX link if possible
|
||||
*/
|
||||
protected $pjaxEnabled = true;
|
||||
|
||||
/**
|
||||
* @var string optional badge (e.g. new item count) not supported by all templates
|
||||
*/
|
||||
protected $badgeText;
|
||||
|
||||
/**
|
||||
* @var Link
|
||||
*/
|
||||
protected $link;
|
||||
|
||||
/**
|
||||
* Renders the link tag for this menu entry
|
||||
*
|
||||
* @param array $extraHtmlOptions
|
||||
* @return string the Html link
|
||||
*/
|
||||
public function render($extraHtmlOptions = [])
|
||||
{
|
||||
if($this->link) {
|
||||
return $this->link.'';
|
||||
}
|
||||
|
||||
return Html::a(
|
||||
$this->getIcon() . ' ' . $this->getLabel(),
|
||||
$this->getUrl(),
|
||||
$this->getHtmlOptions($extraHtmlOptions)
|
||||
);
|
||||
}
|
||||
|
||||
public function getHtmlOptions($extraOptions = [])
|
||||
{
|
||||
$options = parent::getHtmlOptions($extraOptions);
|
||||
|
||||
if(!$this->pjaxEnabled) {
|
||||
Html::addPjaxPrevention($options);
|
||||
}
|
||||
|
||||
return array_merge($extraOptions, $options);
|
||||
}
|
||||
|
||||
public function compare(MenuEntry $entry)
|
||||
{
|
||||
return parent::compare($entry) || ($entry instanceof self && $this->getUrl() === $entry->getUrl());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $label string the label
|
||||
* @return static
|
||||
*/
|
||||
public function setLabel($label)
|
||||
{
|
||||
$this->label = $label;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Link
|
||||
*/
|
||||
public function getLink()
|
||||
{
|
||||
return $this->link;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $link Link the label
|
||||
* @return static
|
||||
*/
|
||||
public function setLink(Link $link)
|
||||
{
|
||||
$this->link = $link;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string the label
|
||||
*/
|
||||
public function getLabel()
|
||||
{
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Icon the icon
|
||||
*/
|
||||
public function getIcon()
|
||||
{
|
||||
return $this->icon;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $icon Icon|string the icon instance or icon name
|
||||
* * @return static
|
||||
*/
|
||||
public function setIcon($icon)
|
||||
{
|
||||
$this->icon = Icon::get($icon);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the URL
|
||||
*
|
||||
* @param $url array|string
|
||||
* @return static
|
||||
*/
|
||||
public function setUrl($url)
|
||||
{
|
||||
$this->url = $url;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the URL
|
||||
*
|
||||
* @param bool $asString return the URL as string
|
||||
* @return array|string
|
||||
*/
|
||||
public function getUrl($asString = true)
|
||||
{
|
||||
if ($asString) {
|
||||
return Url::to($this->url);
|
||||
}
|
||||
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isPjaxEnabled()
|
||||
{
|
||||
return $this->pjaxEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $pjaxEnabled
|
||||
* @return static
|
||||
*/
|
||||
public function setPjaxEnabled($pjaxEnabled)
|
||||
{
|
||||
$this->pjaxEnabled = $pjaxEnabled;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getBadgeText()
|
||||
{
|
||||
return $this->badgeText;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $badgeText
|
||||
* @return static
|
||||
*/
|
||||
public function setBadgeText($badgeText)
|
||||
{
|
||||
$this->badgeText = $badgeText;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates MenuEntry by old and deprecated array structure
|
||||
*
|
||||
* @deprecated since 1.4
|
||||
* @param $item
|
||||
* @return MenuLink
|
||||
*/
|
||||
public static function createByArray($item)
|
||||
{
|
||||
$entry = new static;
|
||||
|
||||
if (isset($item['id'])) {
|
||||
$entry->id = $item['id'];
|
||||
}
|
||||
|
||||
if (isset($item['label'])) {
|
||||
$entry->label = $item['label'];
|
||||
}
|
||||
|
||||
if (isset($item['icon'])) {
|
||||
$entry->icon = $item['icon'];
|
||||
}
|
||||
|
||||
if (isset($item['url'])) {
|
||||
$entry->url = $item['url'];
|
||||
}
|
||||
|
||||
if (isset($item['sortOrder'])) {
|
||||
$entry->sortOrder = $item['sortOrder'];
|
||||
}
|
||||
|
||||
if (isset($item['isActive'])) {
|
||||
$entry->isActive = $item['isActive'];
|
||||
}
|
||||
|
||||
if (isset($item['htmlOptions'])) {
|
||||
$entry->isActive = $item['htmlOptions'];
|
||||
}
|
||||
|
||||
return $entry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the MenuEntry as array structure
|
||||
*
|
||||
* @deprecated since 1.4
|
||||
* @return array the menu entry array representation
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
if (!isset($this->htmlOptions['class'])) {
|
||||
$this->htmlOptions['class'] = '';
|
||||
}
|
||||
|
||||
return [
|
||||
'label' => $this->label,
|
||||
'id' => $this->id,
|
||||
'icon' => $this->icon,
|
||||
'url' => $this->url,
|
||||
'sortOrder' => $this->sortOrder,
|
||||
'isActive' => $this->isActive,
|
||||
'htmlOptions' => $this->htmlOptions
|
||||
];
|
||||
}
|
||||
|
||||
}
|
@ -9,12 +9,12 @@
|
||||
namespace humhub\modules\ui\menu\widgets;
|
||||
|
||||
/**
|
||||
* Class DropDownMenu
|
||||
* Class DropdownMenu
|
||||
*
|
||||
* @since 1.4
|
||||
* @package humhub\modules\ui\menu\widgets
|
||||
*/
|
||||
abstract class DropDownMenu extends Menu
|
||||
abstract class DropdownMenu extends Menu
|
||||
{
|
||||
/**
|
||||
* @var string the label of the dropdown button
|
||||
@ -26,4 +26,15 @@ abstract class DropDownMenu extends Menu
|
||||
*/
|
||||
public $template = '@ui/menu/widgets/views/dropdown-menu.php';
|
||||
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getAttributes()
|
||||
{
|
||||
return [
|
||||
'class' => 'btn-group dropdown-navigation'
|
||||
];
|
||||
}
|
||||
|
||||
}
|
@ -9,8 +9,9 @@
|
||||
namespace humhub\modules\ui\menu\widgets;
|
||||
|
||||
use humhub\components\Event;
|
||||
use humhub\components\Widget;
|
||||
use humhub\modules\ui\menu\MenuEntry;
|
||||
use humhub\modules\ui\menu\MenuLink;
|
||||
use humhub\widgets\JsWidget;
|
||||
use yii\helpers\Url;
|
||||
use yii\web\View;
|
||||
|
||||
@ -20,18 +21,18 @@ use yii\web\View;
|
||||
* @since 1.4
|
||||
* @package humhub\modules\ui\widgets
|
||||
*/
|
||||
abstract class Menu extends Widget
|
||||
abstract class Menu extends JsWidget
|
||||
{
|
||||
/**
|
||||
* @inheritdocs
|
||||
*/
|
||||
public $jsWidget = 'ui.navigation.Navigation';
|
||||
|
||||
/**
|
||||
* @event MenuEvent an event raised before running the navigation widget.
|
||||
*/
|
||||
const EVENT_RUN = 'run';
|
||||
|
||||
/**
|
||||
* @var string dom element id
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* @var string template view file of the navigation
|
||||
*/
|
||||
@ -96,18 +97,38 @@ abstract class Menu extends Widget
|
||||
return [
|
||||
'menu' => $this,
|
||||
'entries' => $this->entries,
|
||||
|
||||
'options' => $this->getOptions(),
|
||||
// Deprecated
|
||||
'items' => $this->getItems(),
|
||||
'numItems' => count($this->getItems())
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return [
|
||||
'menu-id' => $this->id
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getAttributes()
|
||||
{
|
||||
return [
|
||||
'class' => 'panel panel-default left-navigation'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first entry with the given URL
|
||||
*
|
||||
* @param $url string|array the url or route
|
||||
* @return MenuEntry
|
||||
* @return MenuLink
|
||||
*/
|
||||
public function getEntryByUrl($url)
|
||||
{
|
||||
@ -116,6 +137,10 @@ abstract class Menu extends Widget
|
||||
}
|
||||
|
||||
foreach ($this->entries as $entry) {
|
||||
if(!$entry instanceof MenuLink) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($entry->getUrl() === $url) {
|
||||
return $entry;
|
||||
}
|
||||
@ -143,10 +168,10 @@ abstract class Menu extends Widget
|
||||
*
|
||||
* @param MenuEntry $entry
|
||||
*/
|
||||
public function setEntryActive($entry)
|
||||
public function setEntryActive(MenuEntry $entry)
|
||||
{
|
||||
foreach ($this->entries as $e) {
|
||||
$e->setIsActive(($entry->getUrl() === $e->getUrl()));
|
||||
foreach ($this->entries as $currentEntry) {
|
||||
$currentEntry->setIsActive(($currentEntry->compare($entry)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -157,12 +182,12 @@ abstract class Menu extends Widget
|
||||
*/
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @deprecated since 1.4
|
||||
* @param array $entryArray
|
||||
*/
|
||||
public function addItem($entryArray)
|
||||
{
|
||||
$entry = MenuEntry::createByArray($entryArray);
|
||||
$entry = MenuLink::createByArray($entryArray);
|
||||
$this->addEntry($entry);
|
||||
}
|
||||
|
||||
@ -176,7 +201,7 @@ abstract class Menu extends Widget
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @deprecated since 1.4
|
||||
* @return array the item group
|
||||
*/
|
||||
public function getItemGroups()
|
||||
@ -187,20 +212,52 @@ abstract class Menu extends Widget
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @deprecated since 1.4
|
||||
* @return array the menu items as array list
|
||||
*/
|
||||
public function getItems($group = '')
|
||||
{
|
||||
$items = [];
|
||||
foreach ($this->entries as $entry) {
|
||||
$items[] = $entry->toArray();
|
||||
if($entry instanceof MenuLink) {
|
||||
$items[] = $entry->toArray();
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Returns all entries filtered by $type. If no $type filter is given all entries
|
||||
* are returned.
|
||||
*
|
||||
* @param null|string $type
|
||||
* @return MenuEntry[]
|
||||
*/
|
||||
public function getEntries($type = null)
|
||||
{
|
||||
$result = [];
|
||||
foreach ($this->entries as $entry) {
|
||||
if(!$type || get_class($entry) === $type || is_subclass_of($entry, $type)) {
|
||||
$result[] = $entry;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this menu contains multiple entries of the given $type, or at all if no $type filter is given.
|
||||
*
|
||||
* @param null $type
|
||||
* @return bool
|
||||
*/
|
||||
public function hasMultipleEntries($type = null)
|
||||
{
|
||||
return count($this->getEntries($type)) > 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since 1.4
|
||||
*/
|
||||
public function setActive($url)
|
||||
{
|
||||
@ -211,7 +268,7 @@ abstract class Menu extends Widget
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @deprecated since 1.4
|
||||
*/
|
||||
public function setInactive($url)
|
||||
{
|
||||
@ -222,7 +279,7 @@ abstract class Menu extends Widget
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @deprecated since 1.4
|
||||
*/
|
||||
public static function markAsActive($url)
|
||||
{
|
||||
@ -232,7 +289,7 @@ abstract class Menu extends Widget
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @deprecated since 1.4
|
||||
*/
|
||||
public static function markAsInactive($url)
|
||||
{
|
||||
@ -242,19 +299,21 @@ abstract class Menu extends Widget
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @deprecated since 1.4
|
||||
* @return array the menu entry as array
|
||||
*/
|
||||
public function getActive()
|
||||
{
|
||||
$entry = $this->getActiveEntry();
|
||||
if ($entry) {
|
||||
return $entry->toArray();
|
||||
$activeEntry = $this->getActiveEntry();
|
||||
if ($activeEntry && $activeEntry instanceof MenuLink) {
|
||||
return $activeEntry->toArray();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @deprecated since 1.4
|
||||
* @param $url string the URL or route
|
||||
*/
|
||||
public function deleteItemByUrl($url)
|
||||
@ -266,7 +325,7 @@ abstract class Menu extends Widget
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @deprecated since 1.4
|
||||
*/
|
||||
public static function setViewState()
|
||||
{
|
||||
|
@ -14,7 +14,7 @@ namespace humhub\modules\ui\menu\widgets;
|
||||
* @sicne 1.4
|
||||
* @package humhub\modules\ui\menu\widgets
|
||||
*/
|
||||
abstract class SubTabMenu extends Menu
|
||||
abstract class SubTabMenu extends TabMenu
|
||||
{
|
||||
/**
|
||||
* @var string the title of the panel
|
||||
@ -26,4 +26,14 @@ abstract class SubTabMenu extends Menu
|
||||
*/
|
||||
public $template = '@ui/menu/widgets/views/sub-tab-menu.php';
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getAttributes()
|
||||
{
|
||||
return [
|
||||
'class' => 'nav nav-tabs tab-sub-menu'
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,6 +8,8 @@
|
||||
|
||||
namespace humhub\modules\ui\menu\widgets;
|
||||
|
||||
use humhub\modules\ui\menu\MenuLink;
|
||||
|
||||
/**
|
||||
* Class TabMenu
|
||||
*
|
||||
@ -21,4 +23,28 @@ abstract class TabMenu extends Menu
|
||||
*/
|
||||
public $template = '@ui/menu/widgets/views/tab-menu.php';
|
||||
|
||||
/**
|
||||
* @var bool whether or not to skip rendering if only one menu link is given
|
||||
*/
|
||||
public $renderSingleTab = false;
|
||||
|
||||
public function render($view, $params = [])
|
||||
{
|
||||
if(!$this->renderSingleTab && !$this->hasMultipleEntries(MenuLink::class)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return parent::render($view, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getAttributes()
|
||||
{
|
||||
return [
|
||||
'class' => 'tab-menu'
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,11 +1,14 @@
|
||||
<?php
|
||||
|
||||
use humhub\libs\Html;
|
||||
|
||||
/* @var $this \humhub\components\View */
|
||||
/* @var $menu \humhub\modules\ui\menu\widgets\DropDownMenu */
|
||||
/* @var $menu \humhub\modules\ui\menu\widgets\DropdownMenu */
|
||||
/* @var $entries \humhub\modules\ui\menu\MenuEntry[] */
|
||||
/* @var $options [] */
|
||||
?>
|
||||
|
||||
<div class="btn-group dropdown-navigation">
|
||||
<?= Html::beginTag('div', $options)?>
|
||||
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true"
|
||||
aria-expanded="true">
|
||||
|
||||
@ -16,8 +19,8 @@
|
||||
<ul class="dropdown-menu pull-right">
|
||||
<?php foreach ($entries as $entry) : ?>
|
||||
<li>
|
||||
<?= $entry->renderLinkTag() ?>
|
||||
<?= $entry->render() ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
<?= Html::endTag('div')?>
|
@ -1,20 +1,21 @@
|
||||
<?php
|
||||
|
||||
use humhub\libs\Html;
|
||||
|
||||
/* @var $this \humhub\components\View */
|
||||
/* @var $menu \humhub\modules\ui\menu\widgets\LeftNavigation */
|
||||
/* @var $entries \humhub\modules\ui\menu\MenuEntry[] */
|
||||
/* @var $options [] */
|
||||
?>
|
||||
|
||||
<div id="<?= $menu->id; ?>" data-menu-id="<?= $menu->id ?>" class="panel panel-default left-navigation">
|
||||
|
||||
<?= Html::beginTag('div', $options) ?>
|
||||
<?php if (!empty($menu->panelTitle)) : ?>
|
||||
<div class="panel-heading"><?= $menu->panelTitle; ?></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="list-group">
|
||||
<?php foreach ($entries as $entry): ?>
|
||||
<?= $entry->renderLinkTag(['class' => 'list-group-item']) ?>
|
||||
<?= $entry->render(['class' => 'list-group-item']) ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<?= Html::endTag('div') ?>
|
||||
|
@ -1,14 +1,17 @@
|
||||
<?php
|
||||
|
||||
use humhub\libs\Html;
|
||||
|
||||
/* @var $this \humhub\components\View */
|
||||
/* @var $menu \humhub\modules\ui\menu\widgets\SubTabMenu */
|
||||
/* @var $menu \humhub\modules\ui\menu\widgets\DropdownMenu */
|
||||
/* @var $entries \humhub\modules\ui\menu\MenuEntry[] */
|
||||
/* @var $options [] */
|
||||
?>
|
||||
|
||||
<ul id="tabs" class="nav nav-tabs tab-sub-menu">
|
||||
<?= Html::beginTag('ul', $options)?>
|
||||
<?php foreach ($entries as $entry): ?>
|
||||
<li>
|
||||
<?= $entry->renderLinkTag() ?>
|
||||
<li <?php if ($entry->getIsActive()): ?>class="active"<?php endif; ?>>
|
||||
<?= $entry->render() ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?= Html::endTag('ul')?>
|
||||
|
@ -1,16 +1,19 @@
|
||||
<?php
|
||||
|
||||
use humhub\libs\Html;
|
||||
|
||||
/* @var $this \humhub\components\View */
|
||||
/* @var $menu \humhub\modules\ui\menu\widgets\TabMenu */
|
||||
/* @var $menu \humhub\modules\ui\menu\widgets\DropdownMenu */
|
||||
/* @var $entries \humhub\modules\ui\menu\MenuEntry[] */
|
||||
/* @var $options [] */
|
||||
?>
|
||||
|
||||
<div class="tab-menu">
|
||||
<?= Html::beginTag('div', $options)?>
|
||||
<ul class="nav nav-tabs">
|
||||
<?php foreach ($entries as $entry): ?>
|
||||
<li <?php if ($entry->getIsActive()): ?>class="active"<?php endif; ?>>
|
||||
<?= $entry->renderLinkTag() ?>
|
||||
<?= $entry->render() ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
<?= Html::endTag('div')?>
|
||||
|
@ -8,9 +8,9 @@
|
||||
|
||||
namespace humhub\modules\user\widgets;
|
||||
|
||||
use humhub\modules\ui\menu\widgets\LeftNavigation;
|
||||
use Yii;
|
||||
use yii\helpers\Url;
|
||||
use humhub\modules\ui\menu\MenuLink;
|
||||
use humhub\modules\ui\menu\widgets\LeftNavigation;
|
||||
|
||||
/**
|
||||
* AccountMenuWidget as (usally left) navigation on users account options.
|
||||
@ -27,64 +27,58 @@ class AccountMenu extends LeftNavigation
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
|
||||
$controllerAction = Yii::$app->controller->action->id;
|
||||
$this->panelTitle = Yii::t('UserModule.widgets_AccountMenuWidget', '<strong>Account</strong> settings');
|
||||
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('UserModule.widgets_AccountMenuWidget', 'Profile'),
|
||||
'icon' => '<i class="fa fa-user"></i>',
|
||||
'url' => Url::toRoute('/user/account/edit'),
|
||||
'icon' => 'user',
|
||||
'url' => ['/user/account/edit'],
|
||||
'sortOrder' => 100,
|
||||
'isActive' => ($controllerAction == "edit" || $controllerAction == "change-email" || $controllerAction == "change-password" || $controllerAction == "delete"),
|
||||
]);
|
||||
'isActive' => MenuLink::isActiveState('user', 'account', ['edit', 'change-email', 'change-password', 'delete'])
|
||||
]));
|
||||
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('UserModule.account', 'E-Mail Summaries'),
|
||||
'icon' => '<i class="fa fa-envelope"></i>',
|
||||
'url' => Url::toRoute('/activity/user'),
|
||||
'icon' => 'envelope',
|
||||
'url' => ['/activity/user'],
|
||||
'sortOrder' => 105,
|
||||
'isActive' => (Yii::$app->controller->module->id == 'activity'),
|
||||
]);
|
||||
'isActive' => MenuLink::isActiveState('activity')
|
||||
]));
|
||||
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('UserModule.account', 'Notifications'),
|
||||
'icon' => '<i class="fa fa-bell"></i>',
|
||||
'url' => Url::toRoute('/notification/user'),
|
||||
'icon' => 'bell',
|
||||
'url' => ['/notification/user'],
|
||||
'sortOrder' => 106,
|
||||
'isActive' => (Yii::$app->controller->module->id == 'notification'),
|
||||
]);
|
||||
'isActive' => MenuLink::isActiveState('notification')
|
||||
]));
|
||||
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('UserModule.widgets_AccountMenuWidget', 'Settings'),
|
||||
'icon' => '<i class="fa fa-wrench"></i>',
|
||||
'url' => Url::toRoute('/user/account/edit-settings'),
|
||||
'icon' => 'wrench',
|
||||
'url' => ['/user/account/edit-settings'],
|
||||
'sortOrder' => 110,
|
||||
'isActive' => ($controllerAction == "edit-settings"),
|
||||
]);
|
||||
'isActive' => MenuLink::isActiveState('user', 'account', 'edit-settings')
|
||||
]));
|
||||
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('UserModule.widgets_AccountMenuWidget', 'Security'),
|
||||
'icon' => '<i class="fa fa-lock"></i>',
|
||||
'url' => Url::toRoute('/user/account/security'),
|
||||
'icon' => 'lock',
|
||||
'url' => ['/user/account/security'],
|
||||
'sortOrder' => 115,
|
||||
'isActive' => (Yii::$app->controller->action->id == "security"),
|
||||
]);
|
||||
'isActive' => MenuLink::isActiveState('user', 'account', 'security')
|
||||
]));
|
||||
|
||||
// Only show this page when really user specific modules available
|
||||
if (count(Yii::$app->user->getIdentity()->getAvailableModules()) != 0) {
|
||||
$this->addItem([
|
||||
'label' => Yii::t('UserModule.widgets_AccountMenuWidget', 'Modules'),
|
||||
'icon' => '<i class="fa fa-rocket"></i>',
|
||||
'url' => Url::toRoute('//user/account/edit-modules'),
|
||||
'sortOrder' => 120,
|
||||
'isActive' => (Yii::$app->controller->action->id == "edit-modules"),
|
||||
]);
|
||||
}
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('UserModule.widgets_AccountMenuWidget', 'Modules'),
|
||||
'icon' => 'rocket',
|
||||
'url' => ['/user/account/edit-modules'],
|
||||
'sortOrder' => 120,
|
||||
'isActive' => MenuLink::isActiveState('user', 'account', 'edit-modules'),
|
||||
'isVisible' => (count(Yii::$app->user->getIdentity()->getAvailableModules()) !== 0)
|
||||
]));
|
||||
|
||||
parent::init();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -8,9 +8,9 @@
|
||||
|
||||
namespace humhub\modules\user\widgets;
|
||||
|
||||
use humhub\modules\ui\menu\widgets\TabMenu;
|
||||
use Yii;
|
||||
use yii\helpers\Url;
|
||||
use humhub\modules\ui\menu\MenuLink;
|
||||
use humhub\modules\ui\menu\widgets\TabMenu;
|
||||
|
||||
/**
|
||||
* Account Settings Tab Menu
|
||||
@ -23,39 +23,36 @@ class AccountProfilMenu extends TabMenu
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('UserModule.base', 'General'),
|
||||
'url' => Url::toRoute(['/user/account/edit']),
|
||||
'url' => ['/user/account/edit'],
|
||||
'sortOrder' => 100,
|
||||
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'user' && Yii::$app->controller->id == 'account' && Yii::$app->controller->action->id == 'edit'),
|
||||
]);
|
||||
'isActive' => MenuLink::isActiveState('user', 'account', 'edit')
|
||||
]));
|
||||
|
||||
if (Yii::$app->user->canChangeEmail()) {
|
||||
$this->addItem([
|
||||
'label' => Yii::t('UserModule.base', 'Change Email'),
|
||||
'url' => Url::toRoute(['/user/account/change-email']),
|
||||
'sortOrder' => 200,
|
||||
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'user' && Yii::$app->controller->id == 'account' && (Yii::$app->controller->action->id == 'change-email' || Yii::$app->controller->action->id == 'change-email-validate')),
|
||||
]);
|
||||
}
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('UserModule.base', 'Change Email'),
|
||||
'url' => ['/user/account/change-email'],
|
||||
'sortOrder' => 200,
|
||||
'isActive' => MenuLink::isActiveState('user', 'account', ['change-email', 'change-email-validate']),
|
||||
'isVisible' => Yii::$app->user->canChangeEmail()
|
||||
]));
|
||||
|
||||
if (Yii::$app->user->canChangePassword()) {
|
||||
$this->addItem([
|
||||
'label' => Yii::t('UserModule.base', 'Change Password'),
|
||||
'url' => Url::toRoute(['/user/account/change-password']),
|
||||
'sortOrder' => 300,
|
||||
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'user' && Yii::$app->controller->id == 'account' && Yii::$app->controller->action->id == 'change-password'),
|
||||
]);
|
||||
}
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('UserModule.base', 'Change Password'),
|
||||
'url' => ['/user/account/change-password'],
|
||||
'sortOrder' => 300,
|
||||
'isActive' => MenuLink::isActiveState('user', 'account', 'change-password'),
|
||||
'isVisible' => Yii::$app->user->canChangePassword()
|
||||
]));
|
||||
|
||||
if (Yii::$app->user->canDeleteAccount()) {
|
||||
$this->addItem([
|
||||
'label' => Yii::t('UserModule.base', 'Delete Account'),
|
||||
'url' => Url::toRoute(['/user/account/delete']),
|
||||
'sortOrder' => 400,
|
||||
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'user' && Yii::$app->controller->id == 'account' && Yii::$app->controller->action->id == 'delete'),
|
||||
]);
|
||||
}
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('UserModule.base', 'Delete Account'),
|
||||
'url' => ['/user/account/delete'],
|
||||
'sortOrder' => 400,
|
||||
'isActive' => MenuLink::isActiveState('user', 'account', 'delete'),
|
||||
'isVisible' => Yii::$app->user->canDeleteAccount()
|
||||
]));
|
||||
|
||||
parent::init();
|
||||
}
|
||||
|
@ -8,9 +8,9 @@
|
||||
|
||||
namespace humhub\modules\user\widgets;
|
||||
|
||||
use humhub\modules\ui\menu\widgets\TabMenu;
|
||||
use Yii;
|
||||
use yii\helpers\Url;
|
||||
use humhub\modules\ui\menu\MenuLink;
|
||||
use humhub\modules\ui\menu\widgets\TabMenu;
|
||||
|
||||
/**
|
||||
* Account Settings Tab Menu
|
||||
@ -20,25 +20,26 @@ class AccountSettingsMenu extends TabMenu
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* @throws \yii\base\InvalidConfigException
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('UserModule.base', 'Basic Settings'),
|
||||
'url' => Url::toRoute(['/user/account/edit-settings']),
|
||||
'url' => ['/user/account/edit-settings'],
|
||||
'sortOrder' => 100,
|
||||
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'user' && Yii::$app->controller->id == 'account' && Yii::$app->controller->action->id == 'edit-settings'),
|
||||
]);
|
||||
'isActive' => MenuLink::isActiveState('user', 'account', 'edit-settings')
|
||||
]));
|
||||
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('UserModule.base', 'Connected Accounts'),
|
||||
'url' => ['/user/account/connected-accounts'],
|
||||
'sortOrder' => 300,
|
||||
'isActive' => MenuLink::isActiveState('user', 'account', 'connected-accounts'),
|
||||
'isVisible' => count($this->getSecondaryAuthProviders()) !== 0
|
||||
]));
|
||||
|
||||
if (count($this->getSecondaryAuthProviders()) != 0) {
|
||||
$this->addItem([
|
||||
'label' => Yii::t('UserModule.base', 'Connected Accounts'),
|
||||
'url' => Url::toRoute(['/user/account/connected-accounts']),
|
||||
'sortOrder' => 300,
|
||||
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'user' && Yii::$app->controller->id == 'account' && Yii::$app->controller->action->id == 'connected-accounts'),
|
||||
]);
|
||||
}
|
||||
|
||||
parent::init();
|
||||
}
|
||||
|
@ -8,9 +8,12 @@
|
||||
|
||||
namespace humhub\modules\user\widgets;
|
||||
|
||||
use humhub\modules\ui\menu\DropdownDivider;
|
||||
use humhub\modules\ui\menu\MenuLink;
|
||||
use humhub\modules\ui\menu\widgets\Menu;
|
||||
use Yii;
|
||||
use yii\helpers\Url;
|
||||
use humhub\modules\admin\widgets\AdminMenu;
|
||||
|
||||
/**
|
||||
* AccountTopMenu Widget
|
||||
@ -19,6 +22,7 @@ use yii\helpers\Url;
|
||||
*/
|
||||
class AccountTopMenu extends Menu
|
||||
{
|
||||
public $id = 'account-top-menu';
|
||||
|
||||
/**
|
||||
* @var boolean show user name
|
||||
@ -40,50 +44,54 @@ class AccountTopMenu extends Menu
|
||||
}
|
||||
|
||||
$user = Yii::$app->user->getIdentity();
|
||||
$this->addItem([
|
||||
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('base', 'My profile'),
|
||||
'icon' => '<i class="fa fa-user"></i>',
|
||||
'icon' => 'user',
|
||||
'url' => $user->createUrl('/user/profile/home'),
|
||||
'sortOrder' => 100,
|
||||
]);
|
||||
$this->addItem([
|
||||
'sortOrder' => 100]));
|
||||
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('base', 'Account settings'),
|
||||
'icon' => '<i class="fa fa-edit"></i>',
|
||||
'icon' => 'edit',
|
||||
'url' => Url::toRoute('/user/account/edit'),
|
||||
'sortOrder' => 200,
|
||||
]);
|
||||
]));
|
||||
|
||||
if (\humhub\modules\admin\widgets\AdminMenu::canAccess()) {
|
||||
$this->addItem([
|
||||
'label' => '---',
|
||||
'url' => '#',
|
||||
'sortOrder' => 300,
|
||||
]);
|
||||
if (AdminMenu::canAccess()) {
|
||||
$this->addEntry(new DropdownDivider(['sortOrder' => 300]));
|
||||
|
||||
$this->addItem([
|
||||
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('base', 'Administration'),
|
||||
'icon' => '<i class="fa fa-cogs"></i>',
|
||||
'icon' => 'cogs',
|
||||
'url' => Url::toRoute('/admin'),
|
||||
'sortOrder' => 400,
|
||||
]);
|
||||
]));
|
||||
}
|
||||
|
||||
$this->addItem([
|
||||
'label' => '---',
|
||||
'url' => '#',
|
||||
'sortOrder' => 600,
|
||||
]);
|
||||
$this->addEntry(new DropdownDivider(['sortOrder' => 600]));
|
||||
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('base', 'Logout'),
|
||||
'id' => 'account-logout',
|
||||
'icon' => '<i class="fa fa-sign-out"></i>',
|
||||
'pjax' => false,
|
||||
'icon' => 'sign-out',
|
||||
'pjaxEnabled' => false,
|
||||
'url' => Url::toRoute('/user/auth/logout'),
|
||||
'sortOrder' => 700,
|
||||
]);
|
||||
]));
|
||||
|
||||
parent::init();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function getAttributes()
|
||||
{
|
||||
return [
|
||||
'class' => 'nav'
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,10 +8,11 @@
|
||||
|
||||
namespace humhub\modules\user\widgets;
|
||||
|
||||
use Yii;
|
||||
use humhub\modules\ui\menu\MenuLink;
|
||||
use humhub\modules\ui\menu\widgets\LeftNavigation;
|
||||
use humhub\modules\user\models\User;
|
||||
use humhub\modules\user\permissions\ViewAboutPage;
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* ProfileMenuWidget shows the (usually left) navigation on user profiles.
|
||||
@ -42,23 +43,24 @@ class ProfileMenu extends LeftNavigation
|
||||
|
||||
$this->panelTitle = Yii::t('UserModule.widgets_ProfileMenuWidget', '<strong>Profile</strong> menu');
|
||||
|
||||
$this->addItem([
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('UserModule.widgets_ProfileMenuWidget', 'Stream'),
|
||||
'icon' => '<i class="fa fa-bars"></i>',
|
||||
'icon' => 'bars',
|
||||
'url' => $this->user->createUrl('//user/profile/home'),
|
||||
'sortOrder' => 200,
|
||||
'isActive' => (Yii::$app->controller->id == "profile" && (Yii::$app->controller->action->id == "index" || Yii::$app->controller->action->id == "home")),
|
||||
]);
|
||||
'isActive' => MenuLink::isActiveState('user', 'profile', ['index', 'home'])
|
||||
]));
|
||||
|
||||
|
||||
$this->addEntry(new MenuLink([
|
||||
'label' => Yii::t('UserModule.widgets_ProfileMenuWidget', 'About'),
|
||||
'icon' => 'info-circle>',
|
||||
'url' => $this->user->createUrl('/user/profile/about'),
|
||||
'sortOrder' => 300,
|
||||
'isActive' => MenuLink::isActiveState('user', 'profile', 'about'),
|
||||
'isVisible' => $this->user->permissionManager->can(ViewAboutPage::class)
|
||||
]));
|
||||
|
||||
if ($this->user->permissionManager->can(new ViewAboutPage())) {
|
||||
$this->addItem([
|
||||
'label' => Yii::t('UserModule.widgets_ProfileMenuWidget', 'About'),
|
||||
'icon' => '<i class="fa fa-info-circle"></i>',
|
||||
'url' => $this->user->createUrl('//user/profile/about'),
|
||||
'sortOrder' => 300,
|
||||
'isActive' => (Yii::$app->controller->id == "profile" && Yii::$app->controller->action->id == "about"),
|
||||
]);
|
||||
}
|
||||
parent::init();
|
||||
}
|
||||
|
||||
@ -68,12 +70,10 @@ class ProfileMenu extends LeftNavigation
|
||||
public function run()
|
||||
{
|
||||
if (Yii::$app->user->isGuest && $this->user->visibility != User::VISIBILITY_ALL) {
|
||||
return;
|
||||
return '';
|
||||
}
|
||||
|
||||
return parent::run();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -9,6 +9,12 @@
|
||||
use humhub\widgets\FooterMenu;
|
||||
use \yii\helpers\Html;
|
||||
use \yii\helpers\Url;
|
||||
use humhub\modules\user\widgets\Image;
|
||||
|
||||
/* @var $this \humhub\components\View */
|
||||
/* @var $menu \humhub\modules\ui\menu\widgets\DropdownMenu */
|
||||
/* @var $entries \humhub\modules\ui\menu\MenuEntry[] */
|
||||
/* @var $options [] */
|
||||
|
||||
/** @var \humhub\modules\user\models\User $userModel */
|
||||
$userModel = Yii::$app->user->getIdentity();
|
||||
@ -22,7 +28,7 @@ $userModel = Yii::$app->user->getIdentity();
|
||||
<?php endif; ?>
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<ul class="nav">
|
||||
<?= Html::beginTag('ul', $options) ?>
|
||||
<li class="dropdown account">
|
||||
<a href="#" id="account-dropdown-link" class="dropdown-toggle" data-toggle="dropdown" aria-label="<?= Yii::t('base', 'Profile dropdown') ?>">
|
||||
|
||||
@ -32,27 +38,25 @@ $userModel = Yii::$app->user->getIdentity();
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<img id="user-account-image" class="img-rounded"
|
||||
src="<?= $userModel->getProfileImage()->getUrl(); ?>"
|
||||
height="32" width="32" alt="<?= Yii::t('base', 'My profile image') ?>" data-src="holder.js/32x32"
|
||||
style="width: 32px; height: 32px;"/>
|
||||
<?= Image::widget([
|
||||
'user' => $userModel,
|
||||
'link' => false,
|
||||
'width' => 32,
|
||||
'htmlOptions' => [
|
||||
'id' => 'user-account-image',
|
||||
'alt' => Yii::t('base', 'My profile image')
|
||||
]])?>
|
||||
|
||||
<b class="caret"></b>
|
||||
</a>
|
||||
<ul class="dropdown-menu pull-right">
|
||||
<?php foreach ($this->context->getItems() as $item): ?>
|
||||
<?php if ($item['label'] == '---'): ?>
|
||||
<li class="divider"></li>
|
||||
<?php else: ?>
|
||||
<li>
|
||||
<a <?= isset($item['id']) ? 'id="' . $item['id'] . '"' : '' ?> href="<?= $item['url']; ?>" <?= isset($item['pjax']) && $item['pjax'] === false ? 'data-pjax-prevent' : '' ?>>
|
||||
<?= $item['icon'] . ' ' . $item['label']; ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
<?php foreach ($entries as $entry): ?>
|
||||
<li>
|
||||
<?= $entry->render() ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
<?= FooterMenu::widget(['location' => FooterMenu::LOCATION_ACCOUNT_MENU]); ?>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<?= Html::endTag('ul') ?>
|
||||
<?php endif; ?>
|
||||
|
@ -24,7 +24,6 @@ class FooterMenu extends Menu
|
||||
const LOCATION_FULL_PAGE = 'full';
|
||||
const LOCATION_EMAIL = 'mail';
|
||||
|
||||
|
||||
/**
|
||||
* @var string location of footer menu (e.g. login, mail, sidebar)
|
||||
*/
|
||||
|
@ -9,7 +9,7 @@ use yii\helpers\Html;
|
||||
|
||||
<?php foreach ($entries as $entry) : ?>
|
||||
<li class="visible-md visible-lg <?php if ($entry->getIsActive()): ?>active<?php endif; ?>">
|
||||
<?= Html::a($entry->getIcon() . "<br />" . $entry->getLabel(), $entry->getUrl(), $entry->getHtmlOptions()); ?>
|
||||
<?= Html::a($entry->getIcon() . '<br />' . $entry->getLabel(), $entry->getUrl(), $entry->getHtmlOptions()); ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
|
||||
@ -22,7 +22,7 @@ use yii\helpers\Html;
|
||||
<ul class="dropdown-menu">
|
||||
<?php foreach ($entries as $entry) : ?>
|
||||
<li class="<?php if ($entry->getIsActive()): ?>active<?php endif; ?>">
|
||||
<?= $entry->renderLinkTag(); ?>
|
||||
<?= $entry->render(); ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
|
@ -1,6 +1,9 @@
|
||||
humhub.module('ui.navigation', function (module, require, $) {
|
||||
|
||||
var event = require('event');
|
||||
var Widget = require('ui.widget').Widget;
|
||||
|
||||
var Navigation = Widget.extend();
|
||||
|
||||
var init = function () {
|
||||
module.initTopNav();
|
||||
@ -54,6 +57,7 @@ humhub.module('ui.navigation', function (module, require, $) {
|
||||
init: init,
|
||||
setActive: setActive,
|
||||
initTopNav: initTopNav,
|
||||
setActiveItem: setActiveItem
|
||||
setActiveItem: setActiveItem,
|
||||
Navigation: Navigation
|
||||
});
|
||||
});
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user