/** * Before resetting the options, save the masthead info so we can restore it in onSpecialPreferencesAfterResetUserOptions * * @param $storage - storage in which we can save some options, it will be passed in onSpecialPreferencesAfterResetUserOptions hook call * @param User $user */ public static function onSpecialPreferencesBeforeResetUserOptions($preferences, &$user, &$storage) { // user identity box/masthead $userIdentityObject = new UserIdentityBox($user); $mastheadOptions = $userIdentityObject->getFullData(); $masthead = new Masthead($user); if (!empty($masthead->mUser->mOptionOverrides['avatar'])) { $mastheadOptions['avatar'] = $masthead->mUser->mOptionOverrides['avatar']; } $storage[self::MASTHEAD_OPTIONS_STORAGE_ARRAY_KEY_NAME] = $mastheadOptions; // customize toolbar/myToolbar $oasisToolbarService = new SharedToolbarService(); $toolbarNameInUserOptions = $oasisToolbarService->getToolbarOptionName(); $toolbarCurrentList = $user->getGlobalPreference($oasisToolbarService->getToolbarOptionName()); $storage[self::MY_TOOLBAR_OPTIONS_STORAGE_ARRAY_KEY_NAME] = array($toolbarNameInUserOptions => $toolbarCurrentList); return true; }
private function generateUserTools() { global $wgUser; $anonListItems = ['SpecialPage:Mostpopularcategories', 'SpecialPage:WikiActivity', 'SpecialPage:NewFiles']; $service = new SharedToolbarService(); $data = []; if ($wgUser->isAnon()) { foreach ($anonListItems as $listItem) { $data[] = $service->buildListItem($listItem); } } else { $data = $service->getVisibleList(); } if (!WikiaPageType::isWikiaHubMain()) { $renderedData[] = $this->sendRequest('ArticleNavigationContributeMenu', 'getContributeActionsForDropdown')->getVal('data'); } $dataInArr = $service->instanceToRenderData($service->listToInstance($data)); foreach ($dataInArr as $item) { $renderedData[] = $item; } if ($wgUser->isAllowed('admindashboard')) { $renderedData[] = ['tracker-name' => 'admin', 'caption' => 'Admin', 'href' => SpecialPage::getTitleFor('AdminDashboard')->getLocalURL(), 'type' => 'link']; } return $renderedData; }