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