/** * Get the link to users talk page * @return string */ protected function getTalkLink() { // replace secondary icon $attrs = array('class' => MobileUI::iconClass('talk', 'before', MobileUI::buttonClass()), 'href' => $this->targetUser->getTalkPage()->getLocalUrl()); // FIXME: What if this is the user's own profile? Should we change the message? return Html::element('a', $attrs, $this->msg('mobile-frontend-profile-usertalk', $this->targetUser->getName())); }
/** * Returns an array with details for a talk button. * @param Title $talkTitle Title object of the talk page * @param array $talkButton Array with data of desktop talk button * @return array */ protected function getTalkButton($talkTitle, $talkButton) { $button = parent::getTalkButton($talkTitle, $talkButton); // use a button with icon in beta $button['attributes']['class'] = MobileUI::iconClass('talk', 'before', 'talk icon-32px'); return $button; }
/** * Adds HTML to render a header at the top of the feed * @param Title|string $title The page to link to or a string to show */ protected function renderHeaderBar($title) { if ($title instanceof Title) { $headerTitle = $this->getHeaderBarLink($title); } else { // manually style it as a userlink $headerTitle = Html::element('span', array('class' => MobileUI::iconClass('user', 'before', 'mw-mf-user icon-16px')), $title); } $this->getOutput()->addHtml(Html::openElement('div', array('class' => 'content-header')) . Html::openElement('h2', array()) . $headerTitle . Html::closeElement('h2') . Html::closeElement('div')); }
/** * @inheritdoc * Renders a search link and branding. */ protected function makeChromeHeaderContent($data) { $templateParser = new TemplateParser(__DIR__ . '/../../templates'); $args = array('siteName' => SkinMinerva::getSitename(), 'showSearchForm' => $this->isSpecialMobileMenuPage, 'showTitle' => !$this->isSpecialMobileMenuPage); if ($this->isSpecialMobileMenuPage) { $args += array('mobileMenuClass' => 'js-only back ' . MobileUI::iconClass('back'), 'mobileMenuLink' => '#back', 'mobileMenuTitle' => wfMessage('mobile-frontend-main-menu-back')->parse(), 'searchForm' => $this->makeSearchForm($data)); } else { $args += array('mobileMenuClass' => MobileUI::iconClass('search'), 'mobileMenuLink' => SpecialPage::getTitleFor('MobileMenu')->getLocalUrl(), 'mobileMenuTitle' => wfMessage('mobile-frontend-main-menu')->parse(), 'searchInputClass' => 'hidden'); } echo $templateParser->processTemplate('header', $args); }
/** * Renders an item in the feed * @param MWTimestamp $ts The time the edit occurred * @param string $diffLink url to the diff for the edit * @param string $username The username of the user that made the edit (absent if anonymous) * @param string $comment The edit summary * @param Title|null $title The title of the page that was edited * @param bool $isAnon Is the edit anonymous? * @param int|null $bytes Net number of bytes changed or null if not applicable * @param bool $isMinor Is the edit minor? * @return string HTML code * * @todo FIXME: use an array as an argument? */ protected function renderFeedItemHtml($ts, $diffLink = '', $username = '', $comment = '', $title = null, $isAnon = false, $bytes = 0, $isMinor = false) { $output = $this->getOutput(); $user = $this->getUser(); $lang = $this->getLanguage(); if ($isAnon) { $usernameClass = MobileUI::iconClass('anonymous', 'before', 'icon-16px mw-mf-user mw-mf-anon'); } else { $usernameClass = MobileUI::iconClass('user', 'before', 'icon-16px mw-mf-user'); } $html = Html::openElement('li', array('class' => 'page-summary')); if ($diffLink) { $html .= Html::openElement('a', array('href' => $diffLink, 'class' => 'title')); } else { $html .= Html::openElement('div', array('class' => 'title')); } if ($title) { $html .= Html::element('h3', array(), $title->getPrefixedText()); } if ($username && $this->showUsername) { $html .= Html::element('p', array('class' => $usernameClass), $username); } $html .= Html::element('p', array('class' => 'edit-summary component truncated-text multi-line two-line'), $comment); if ($isMinor) { $html .= ChangesList::flag('minor'); } $html .= Html::openElement('div', array('class' => 'list-thumb')) . Html::element('p', array('class' => 'timestamp'), $lang->userTime($ts, $user)); if ($bytes) { $formattedBytes = $lang->formatNum($bytes); if ($bytes > 0) { $formattedBytes = '+' . $formattedBytes; $bytesClass = 'mw-mf-bytesadded'; } else { $bytesClass = 'mw-mf-bytesremoved'; } $html .= Html::element('p', array('class' => $bytesClass, 'dir' => 'ltr'), $formattedBytes); } $html .= Html::closeElement('div'); if ($diffLink) { $html .= Html::closeElement('a'); } else { $html .= Html::closeElement('div'); } $html .= Html::closeElement('li'); $output->addHtml($html); }
/** * Prepare configured and available page actions * @param BaseTemplate $tpl */ protected function preparePageActions(BaseTemplate $tpl) { $title = $this->getTitle(); // Reuse template data variable from SkinTemplate to construct page menu $menu = array(); $actions = $tpl->data['content_navigation']['actions']; // empty placeholder for edit and photos which both require js if ($this->isAllowedPageAction('edit')) { $menu['edit'] = array('id' => 'ca-edit', 'text' => '', 'itemtitle' => $this->msg('mobile-frontend-pageaction-edit-tooltip'), 'class' => MobileUI::iconClass('edit', 'element', 'hidden')); } if ($this->isAllowedPageAction('watch')) { $watchTemplate = array('id' => 'ca-watch', 'class' => MobileUI::iconClass('watch', 'element', 'icon-32px watch-this-article hidden')); // standardise watch article into one menu item if (isset($actions['watch'])) { $menu['watch'] = array_merge($actions['watch'], $watchTemplate); } elseif (isset($actions['unwatch'])) { $menu['watch'] = array_merge($actions['unwatch'], $watchTemplate); $menu['watch']['class'] .= ' watched'; } else { // placeholder for not logged in $menu['watch'] = $watchTemplate; // FIXME: makeLink (used by makeListItem) when no text is present defaults to use the key $menu['watch']['text'] = ''; $menu['watch']['href'] = $this->getLoginUrl(array('returnto' => $title)); } } $tpl->set('page_actions', $menu); }
/** * Gets HTML to place in the header bar * @param Title $title The page to link to * @return string HTML representing the link in the header bar */ protected function getHeaderBarLink($title) { return Html::element('a', array('class' => MobileUI::iconClass('user', 'before', 'mw-mf-user'), 'href' => SpecialPage::getTitleFor('UserProfile', $title->getText())->getLocalUrl()), $title->getText()); }
/** * Returns an array of links for page secondary actions * @param BaseTemplate $tpl * @return Array */ protected function getSecondaryActions(BaseTemplate $tpl) { $buttons = parent::getSecondaryActions($tpl); $title = $this->getTitle(); $namespaces = $tpl->data['content_navigation']['namespaces']; if ($this->isTalkAllowed()) { // FIXME [core]: This seems unnecessary.. $subjectId = $title->getNamespaceKey(''); $talkId = $subjectId === 'main' ? 'talk' : "{$subjectId}_talk"; $talkButton = isset($namespaces[$talkId]) && !$title->isTalkPage() ? $namespaces[$talkId]['text'] : ''; $talkTitle = $title->getTalkPage(); $buttons['talk'] = array('attributes' => array('href' => $talkTitle->getLinkURL(), 'class' => MobileUI::iconClass('talk', 'before', 'talk'), 'data-title' => $talkTitle->getFullText()), 'label' => $talkButton); } return $buttons; }
/** * Render the footer including userinfos (Name, Role, Editcount) */ function showFooter() { $output = $this->getOutput(); $output->addHtml(Html::openElement('div', array('id' => 'mw-mf-userinfo', 'class' => 'position-fixed')) . Html::openElement('div', array('class' => 'post-content'))); $userId = $this->rev->getUser(); if ($userId) { $user = User::newFromId($userId); $edits = $user->getEditCount(); $attrs = array('class' => MobileUI::iconClass('user', 'before', 'mw-mf-user icon-16px'), 'data-revision-id' => $this->revId, 'data-user-name' => $user->getName(), 'data-user-gender' => $user->getOption('gender')); $output->addHtml(Html::openElement('div', $attrs) . Linker::link($user->getUserPage(), htmlspecialchars($user->getName()), array('class' => 'mw-mf-user-link')) . '</div>' . '<div class="mw-mf-roles meta">' . $this->listGroups($user) . '</div>' . '<div class="mw-mf-edit-count meta">' . $this->msg('mobile-frontend-diffview-editcount', $this->getLanguage()->formatNum($edits))->parse() . '</div>'); } else { $ipAddr = $this->rev->getUserText(); $userPage = SpecialPage::getTitleFor('Contributions', $ipAddr); $output->addHtml(Html::element('div', array('class' => MobileUI::iconClass('anonymous', 'before', 'mw-mf-user icon-16px mw-mf-anon')), $this->msg('mobile-frontend-diffview-anonymous')) . '<div>' . Linker::link($userPage, htmlspecialchars($ipAddr)) . '</div>'); } if ($this->mDiffEngine instanceof InlineDifferenceEngine) { $output->addHtml($this->mDiffEngine->getPatrolledLink()); } $output->addHtml(Html::closeElement('div') . Html::closeElement('div')); }
/** * Prepare configured and available page actions * @param BaseTemplate $tpl */ protected function preparePageActions(BaseTemplate $tpl) { $title = $this->getTitle(); $noJsEdit = MobileContext::singleton()->getMFConfig()->get('MFAllowNonJavaScriptEditing'); // Reuse template data variable from SkinTemplate to construct page menu $menu = array(); $actions = $tpl->data['content_navigation']['actions']; if ($this->isUserPage) { if (!$this->getTitle()->exists()) { $tpl->set('page_actions', $menu); return; } } // empty placeholder for edit and photos which both require js if ($this->isAllowedPageAction('edit')) { $additionalClass = $noJsEdit ? ' nojs-edit' : ''; $menu['edit'] = array('id' => 'ca-edit', 'text' => '', 'itemtitle' => $this->msg('mobile-frontend-pageaction-edit-tooltip'), 'class' => MobileUI::iconClass('edit-enabled', 'element' . $additionalClass), 'links' => array('edit' => array('href' => $this->getTitle()->getLocalUrl(array('action' => 'edit', 'section' => 0))))); } if ($this->isAllowedPageAction('watch')) { $watchTemplate = array('id' => 'ca-watch', 'class' => MobileUI::iconClass('watch', 'element', 'icon-32px watch-this-article hidden')); // standardise watch article into one menu item if (isset($actions['watch'])) { $menu['watch'] = array_merge($actions['watch'], $watchTemplate); } elseif (isset($actions['unwatch'])) { $menu['watch'] = array_merge($actions['unwatch'], $watchTemplate); $menu['watch']['class'] .= ' watched'; } else { // placeholder for not logged in $menu['watch'] = $watchTemplate; // FIXME: makeLink (used by makeListItem) when no text is present defaults to use the key $menu['watch']['text'] = ''; $menu['watch']['href'] = $this->getLoginUrl(array('returnto' => $title)); } } $tpl->set('page_actions', $menu); }
/** * @inheritdoc */ protected function getSearchForm($data) { return Html::openElement('form', array('action' => $data['wgScript'], 'class' => 'search-box')) . Html::openElement('div', array('class' => MobileUI::iconClass('search-invert', 'element', 'fulltext-search no-js-only'))) . $this->makeSearchButton('fulltext') . Html::closeElement('div') . Html::openElement('span') . $this->makeSearchInput($this->getSearchAttributes()) . Html::closeElement('span') . Html::closeElement('form'); }