/** * Returns an array of modules related to the current context of the page. * @return array */ public function getContextSpecificModules() { $modules = array(); $user = $this->getUser(); $req = $this->getRequest(); $action = $req->getVal('article_action'); $campaign = $req->getVal('campaign'); $title = $this->getTitle(); if ($this->isAllowedPageAction('upload') && !$title->isMainPage() && $this->mobileContext->userCanUpload()) { $modules[] = 'mobile.leadPhotoUploader'; } if ($user->isLoggedIn()) { // enable the user module $modules[] = 'mobile.usermodule'; if ($this->useEcho()) { $modules[] = 'mobile.notifications'; } if ($this->isCurrentPageEditable()) { if ($action === 'signup-edit' || $campaign === 'leftNavSignup') { $modules[] = 'mobile.newusers'; } } $mfExperiments = $this->getMFConfig()->get('MFExperiments'); if (count($mfExperiments) > 0) { $modules[] = 'mobile.experiments'; } } if ($this->mobileContext->userCanUpload()) { $modules[] = 'mobile.upload.ui'; } return $modules; }
/** * Prepares and returns urls and links personal to the given user * @return array */ protected function getPersonalTools() { $returnToTitle = $this->getTitle()->getPrefixedText(); $donateTitle = SpecialPage::getTitleFor('Uploads'); $watchTitle = SpecialPage::getTitleFor('Watchlist'); $items = array(); // Watchlist link $watchlistQuery = array(); $user = $this->getUser(); // MobileS if ($user && $this->mobileContext) { $view = $user->getOption(SpecialMobileWatchlist::VIEW_OPTION_NAME, false); $filter = $user->getOption(SpecialMobileWatchlist::FILTER_OPTION_NAME, false); if ($view) { $watchlistQuery['watchlistview'] = $view; } if ($filter && $view === 'feed') { $watchlistQuery['filter'] = $filter; } } $items[] = array('name' => 'watchlist', 'components' => array(array('text' => wfMessage('mobile-frontend-main-menu-watchlist')->escaped(), 'href' => $this->getPersonalUrl($watchTitle, 'mobile-frontend-watchlist-purpose', $watchlistQuery), 'class' => MinervaUI::iconClass('watchlist', 'before'), 'data-event-name' => 'watchlist')), 'class' => 'jsonly'); // Links specifically for mobile mode if ($this->isMobileMode) { // Uploads link if ($this->mobileContext->userCanUpload()) { $items[] = array('name' => 'uploads', 'components' => array(array('text' => wfMessage('mobile-frontend-main-menu-upload')->escaped(), 'href' => $this->getPersonalUrl($donateTitle, 'mobile-frontend-donate-image-anon'), 'class' => MinervaUI::iconClass('uploads', 'before', 'menu-item-upload'), 'data-event-name' => 'uploads')), 'class' => 'jsonly'); } // Settings link $items[] = array('name' => 'settings', 'components' => array(array('text' => wfMessage('mobile-frontend-main-menu-settings')->escaped(), 'href' => SpecialPage::getTitleFor('MobileOptions')->getLocalUrl(array('returnto' => $returnToTitle)), 'class' => MinervaUI::iconClass('mobileoptions', 'before'), 'data-event-name' => 'settings'))); // Links specifically for desktop mode } else { // Preferences link $items[] = array('name' => 'preferences', 'components' => array(array('text' => wfMessage('preferences')->escaped(), 'href' => $this->getPersonalUrl(SpecialPage::getTitleFor('Preferences'), 'prefsnologintext2'), 'class' => MinervaUI::iconClass('settings', 'before'), 'data-event-name' => 'preferences'))); } // Login/Logout links $items[] = $this->getLogInOutLink(); // Allow other extensions to add or override tools Hooks::run('MobilePersonalTools', array(&$items)); return $items; }
/** * Prepares and returns urls and links personal to the given user * @return array */ protected function getPersonalTools() { $returnToTitle = $this->getTitle()->getPrefixedText(); $donateTitle = SpecialPage::getTitleFor('Uploads'); $watchTitle = SpecialPage::getTitleFor('Watchlist'); $menu = new MenuBuilder(); // Watchlist link $watchlistQuery = array(); $user = $this->getUser(); if ($user) { $view = $user->getOption(SpecialMobileWatchlist::VIEW_OPTION_NAME, false); $filter = $user->getOption(SpecialMobileWatchlist::FILTER_OPTION_NAME, false); if ($view) { $watchlistQuery['watchlistview'] = $view; } if ($filter && $view === 'feed') { $watchlistQuery['filter'] = $filter; } } $menu->insert('watchlist', $isJSOnly = true)->addComponent(wfMessage('mobile-frontend-main-menu-watchlist')->escaped(), $this->getPersonalUrl($watchTitle, 'mobile-frontend-watchlist-purpose', $watchlistQuery), MobileUI::iconClass('watchlist', 'before'), array('data-event-name' => 'watchlist')); // Links specifically for mobile mode if ($this->isMobileMode) { // Uploads link if ($this->mobileContext->userCanUpload()) { $menu->insert('uploads', $isJSOnly = true)->addComponent(wfMessage('mobile-frontend-main-menu-upload')->escaped(), $this->getPersonalUrl($donateTitle, 'mobile-frontend-donate-image-anon'), MobileUI::iconClass('uploads', 'before', 'menu-item-upload'), array('data-event-name' => 'uploads')); } // Settings link $menu->insert('settings')->addComponent(wfMessage('mobile-frontend-main-menu-settings')->escaped(), SpecialPage::getTitleFor('MobileOptions')->getLocalUrl(array('returnto' => $returnToTitle)), MobileUI::iconClass('mobileoptions', 'before'), array('data-event-name' => 'settings')); // Links specifically for desktop mode } else { // Preferences link $menu->insert('preferences')->addComponent(wfMessage('preferences')->escaped(), $this->getPersonalUrl(SpecialPage::getTitleFor('Preferences'), 'prefsnologintext2'), MobileUI::iconClass('settings', 'before'), array('data-event-name' => 'preferences')); } // Login/Logout links $this->insertLogInOutLink($menu); // Allow other extensions to add or override tools Hooks::run('MobileMenu', array('personal', &$menu)); return $menu->getEntries(); }