public function getHTML() { wfProfileIn(__METHOD__); if ($this->isVisible()) { $ownerName = $this->ownerUser->getName(); $tmplData = array(); $tmplData['ownerBadges'] = $this->getBadgesAnnotated(); $tmplData['challengesBadges'] = $this->getChallengesAnnotated(); $tmplData['title_no'] = wfMsg('achievements-profile-title-no', $ownerName); $tmplData['title'] = wfMsgExt('achievements-profile-title', array('parsemag'), $ownerName, $this->owner->getBadgesCount()); $tmplData['title_challenges'] = wfMsg('achievements-profile-title-challenges', $ownerName); $tmplData['leaderboard_url'] = Skin::makeSpecialUrl("Leaderboard"); if ($this->owner->getBadgesCount() > 0) { $rankingService = new AchRankingService(); $tmplData['user_rank'] = $rankingService->getUserRankingPosition($this->ownerUser); } if ($this->viewerUser->isAllowed('editinterface')) { $tmplData['customize_url'] = Skin::makeSpecialUrl("AchievementsCustomize"); } $template = new EasyTemplate(dirname(__FILE__) . '/../templates'); $template->set_vars($tmplData); $out = $template->render('ProfileBox'); } else { $out = ''; } wfProfileOut(__METHOD__); return $out; }
/** * Main method. * * @since 0.1 * * @param string $subPage */ public function execute($subPage) { parent::execute($subPage); $out = $this->getOutput(); if (trim($subPage) === '') { $this->getOutput()->redirect(SpecialPage::getTitleFor('Institutions')->getLocalURL()); } else { $out->setPageTitle(wfMsgExt('ep-institution-title', 'parsemag', $this->subPage)); $org = EPOrg::selectRow(null, array('name' => $this->subPage)); if ($org === false) { $this->displayNavigation(); if ($this->getUser()->isAllowed('ep-org')) { $out->addWikiMsg('ep-institution-create', $this->subPage); EPOrg::displayAddNewControl($this->getContext(), array('name' => $this->subPage)); } else { $out->addWikiMsg('ep-institution-none', $this->subPage); } } else { $links = array(); if ($this->getUser()->isAllowed('ep-org')) { $links[wfMsg('ep-institution-nav-edit')] = SpecialPage::getTitleFor('EditInstitution', $this->subPage); } $this->displayNavigation($links); $this->displaySummary($org); $out->addHTML(Html::element('h2', array(), wfMsg('ep-institution-courses'))); EPCourse::displayPager($this->getContext(), array('org_id' => $org->getId())); if ($this->getUser()->isAllowed('ep-course')) { $out->addHTML(Html::element('h2', array(), wfMsg('ep-institution-add-course'))); EPCourse::displayAddNewControl($this->getContext(), array('org' => $org->getId())); } } } }
function doTagRow($tag, $hitcount) { static $sk = null, $doneTags = array(); if (!$sk) { $sk = $this->getSkin(); } if (in_array($tag, $doneTags)) { return ''; } global $wgLang; $newRow = ''; $newRow .= Xml::tags('td', null, Xml::element('tt', null, $tag)); $disp = ChangeTags::tagDescription($tag); $disp .= ' (' . $sk->link(Title::makeTitle(NS_MEDIAWIKI, "Tag-{$tag}"), wfMsgHtml('tags-edit')) . ')'; $newRow .= Xml::tags('td', null, $disp); $msg = wfMessage("tag-{$tag}-description"); $desc = !$msg->exists() ? '' : $msg->parse(); $desc .= ' (' . $sk->link(Title::makeTitle(NS_MEDIAWIKI, "Tag-{$tag}-description"), wfMsgHtml('tags-edit')) . ')'; $newRow .= Xml::tags('td', null, $desc); $hitcount = wfMsgExt('tags-hitcount', array('parsemag'), $wgLang->formatNum($hitcount)); $hitcount = $sk->link(SpecialPage::getTitleFor('Recentchanges'), $hitcount, array(), array('tagfilter' => $tag)); $newRow .= Xml::tags('td', null, $hitcount); $doneTags[] = $tag; return Xml::tags('tr', null, $newRow) . "\n"; }
protected function getTypeProperties($typeLabel) { global $wgRequest, $smwgTypePagingLimit; if ($smwgTypePagingLimit <= 0) { return ''; } // not too useful, but we comply to this request $from = $wgRequest->getVal('from'); $until = $wgRequest->getVal('until'); $typeValue = SMWDataValueFactory::newTypeIDValue('__typ', $typeLabel); $store = smwfGetStore(); $options = SMWPageLister::getRequestOptions($smwgTypePagingLimit, $from, $until); $diWikiPages = $store->getPropertySubjects(new SMWDIProperty('_TYPE'), $typeValue->getDataItem(), $options); if (!$options->ascending) { $diWikiPages = array_reverse($diWikiPages); } $result = ''; if (count($diWikiPages) > 0) { $pageLister = new SMWPageLister($diWikiPages, null, $smwgTypePagingLimit, $from, $until); $title = $this->getTitleFor('Types', $typeLabel); $title->setFragment('#SMWResults'); // Make navigation point to the result list. $navigation = $pageLister->getNavigationLinks($title); $resultNumber = min($smwgTypePagingLimit, count($diWikiPages)); $typeName = $typeValue->getLongWikiText(); $result .= "<a name=\"SMWResults\"></a><div id=\"mw-pages\">\n" . '<h2>' . wfMsg('smw_type_header', $typeName) . "</h2>\n<p>" . wfMsgExt('smw_typearticlecount', array('parsemag'), $resultNumber) . "</p>\n" . $navigation . $pageLister->formatList() . $navigation . "\n</div>"; } return $result; }
/** * Make a "what links here" link for a given title * * @param Title $title Title to make the link for * @param Skin $skin Skin to use * @param object $result Result row * @return string */ private function makeWlhLink($title, $skin, $result) { global $wgLang; $wlh = SpecialPage::getTitleFor('Whatlinkshere'); $label = wfMsgExt('nlinks', array('parsemag', 'escape'), $wgLang->formatNum($result->value)); return $skin->link($wlh, $label, array(), array('target' => $title->getPrefixedText())); }
/** * Retrieve the specil words from the database. */ public function execute() { // Get the requests parameters. $params = $this->extractRequestParams(); if (!(isset($params['userid']) xor isset($params['groupids']))) { $this->dieUsage(wfMsgExt('swl-err-userid-xor-groupids'), 'userid-xor-groupids'); } $isUserFilter = isset($params['userid']); $filter = $isUserFilter ? $params['userid'] : $params['groupids']; $this->setupChangeSetQuery($filter, $isUserFilter, $params['limit'], $params['continue']); $sets = $this->select(__METHOD__); $count = 0; $resultSets = array(); foreach ($sets as $set) { if (++$count > $params['limit']) { // We've reached the one extra which shows that // there are additional pages to be had. Stop here... $this->setContinueEnumParameter('continue', $set->edit_time . '-' . $set->spe_set_id); break; } $resultSets[] = SWLChangeSet::newFromDBResult($set); } if ($params['merge']) { $this->mergeSets($resultSets); } foreach ($resultSets as &$set) { $set = $set->toArray(); foreach ($set['changes'] as $propName => $changes) { $this->getResult()->setIndexedTagName($set['changes'][$propName], 'change'); } } $this->getResult()->setIndexedTagName($resultSets, 'set'); $this->getResult()->addValue(null, 'sets', $resultSets); }
function getLongDesc($image) { global $wgLang; $original = parent::getLongDesc($image); wfSuppressWarnings(); $metadata = unserialize($image->getMetadata()); wfRestoreWarnings(); if (!$metadata || $metadata['frameCount'] <= 0) { return $original; } $info = array(); $info[] = $original; if ($metadata['loopCount'] == 0) { $info[] = wfMsgExt('file-info-png-looped', 'parseinline'); } elseif ($metadata['loopCount'] > 1) { $info[] = wfMsgExt('file-info-png-repeat', 'parseinline', $metadata['loopCount']); } if ($metadata['frameCount'] > 0) { $info[] = wfMsgExt('file-info-png-frames', 'parseinline', $metadata['frameCount']); } if ($metadata['duration']) { $info[] = $wgLang->formatTimePeriod($metadata['duration']); } return $wgLang->commaList($info); }
/** * Adds awards for all registered users, updates statistics and purges * caches. * Special:PopulateAwards calls this function */ public function update_system_gifts() { global $wgOut, $wgMemc; $dbw = wfGetDB(DB_MASTER); $stats = new UserStatsTrack(1, ''); $this->categories = array_flip($this->categories); $res = $dbw->select('system_gift', array('gift_id', 'gift_category', 'gift_threshold', 'gift_name'), array(), __METHOD__, array('ORDER BY' => 'gift_category, gift_threshold ASC')); $x = 0; foreach ($res as $row) { if ($row->gift_category) { $res2 = $dbw->select('user_stats', array('stats_user_id', 'stats_user_name'), array($stats->stats_fields[$this->categories[$row->gift_category]] . " >= {$row->gift_threshold}", 'stats_user_id <> 0'), __METHOD__); foreach ($res2 as $row2) { if ($this->doesUserHaveGift($row2->stats_user_id, $row->gift_id) == false) { $dbw->insert('user_system_gift', array('sg_gift_id' => $row->gift_id, 'sg_user_id' => $row2->stats_user_id, 'sg_user_name' => $row2->stats_user_name, 'sg_status' => 0, 'sg_date' => date('Y-m-d H:i:s', time() - 60 * 60 * 24 * 3)), __METHOD__); $sg_key = wfMemcKey('user', 'profile', 'system_gifts', "{$row2->stats_user_id}"); $wgMemc->delete($sg_key); // Update counters (bug #27981) UserSystemGifts::incGiftGivenCount($row->gift_id); $wgOut->addHTML(wfMsg('ga-user-got-awards', $row2->stats_user_name, $row->gift_name) . '<br />'); $x++; } } } } $wgOut->addHTML(wfMsgExt('ga-awards-given-out', 'parsemag', $x)); }
public function onGetNotificationMessage($nc, &$msg, $isMain, $data, $authors, $userCount, $myName) { if (empty($data->article_title_ns) || MWNamespace::getSubject($data->article_title_ns) != NS_WIKIA_FORUM_BOARD) { return true; } if (!$isMain) { if ($data->parent_username == $myName) { $replyTo = "your"; } else { $replyTo = "someone"; } //$params[] = $data->msg_author_displayname; $params['$1'] = $nc->getDisplayname($data->msg_author_displayname); $params['$2'] = ""; if ($userCount == 2) { $params['$2'] = $nc->getDisplayname($authors[1]['displayname']); } $params['$3'] = $data->article_title_text; $msgid = "forum-notification-user{$userCount}-reply-to-{$replyTo}"; } else { $msgid = 'forum-notification-newmsg-on-followed-wall'; $params['$1'] = $nc->getDisplayname($data->msg_author_displayname); $params['$2'] = $data->wall_displayname; } $msg = wfMsgExt($msgid, array('parsemag'), $params); return true; }
/** * Entry point */ public function execute($par) { global $wgOut, $wgRequest, $wgUser, $wgTitle, $haclgHaloScriptPath, $haclgSuperGroups; haclCheckScriptPath(); $q = $wgRequest->getValues(); if ($wgUser->isLoggedIn()) { $wgOut->setPageTitle(wfMsg('hacl_special_page')); $groups = $wgUser->getGroups(); $this->isAdmin = true && array_intersect($groups, $haclgSuperGroups); if (!isset($q['action']) || !isset(self::$actions[$q['action']]) || $q['action'] == 'rightgraph' && !$this->isAdmin) { $q['action'] = 'acllist'; } $f = 'html_' . $q['action']; $wgOut->addLink(array('rel' => 'stylesheet', 'type' => 'text/css', 'media' => 'screen, projection', 'href' => $haclgHaloScriptPath . '/skins/haloacl.css')); if ($f == 'html_acllist') { $wgOut->addHTML('<p style="margin-top: -8px">' . wfMsgExt('hacl_acllist_hello', 'parseinline') . '</p>'); } $this->_actions($q); $this->{$f}($q); } else { $q = $_GET; unset($q['title']); $wgOut->redirect(Title::newFromText('Special:UserLogin')->getFullUrl(array('returnto' => 'Special:IntraACL', 'returntoquery' => http_build_query($q)))); } }
public function execute() { global $wgUser; if (!$wgUser->isLoggedIn()) { $this->dieUsage('You must be logged-in to have a watchlist', 'notloggedin'); } $params = $this->extractRequestParams(); $title = Title::newFromText($params['title']); if (!$title || $title->getNamespace() < 0) { $this->dieUsageMsg(array('invalidtitle', $params['title'])); } $article = new Article($title, 0); $res = array('title' => $title->getPrefixedText()); if ($params['unwatch']) { $res['unwatched'] = ''; $res['message'] = wfMsgExt('removedwatchtext', array('parse'), $title->getPrefixedText()); $success = WatchAction::doUnwatch($title, $wgUser); } else { $res['watched'] = ''; $res['message'] = wfMsgExt('addedwatchtext', array('parse'), $title->getPrefixedText()); $success = UnwatchAction::doWatch($title, $wgUser); } if (!$success) { $this->dieUsageMsg('hookaborted'); } $this->getResult()->addValue(null, $this->getModuleName(), $res); }
static function createPropertyText($property_type, $default_form, $allowed_values_str) { global $smwgContLang; $prop_labels = $smwgContLang->getPropertyLabels(); $type_tag = "[[{$prop_labels['_TYPE']}::{$property_type}]]"; $text = wfMsgForContent('sf_property_isproperty', $type_tag); if ($default_form !== '') { global $sfgContLang; $sf_prop_labels = $sfgContLang->getPropertyLabels(); $default_form_tag = "[[{$sf_prop_labels[SF_SP_HAS_DEFAULT_FORM]}::{$default_form}]]"; $text .= ' ' . wfMsgForContent('sf_property_linkstoform', $default_form_tag); } if ($allowed_values_str !== '') { // replace the comma substitution character that has no chance of // being included in the values list - namely, the ASCII beep global $sfgListSeparator; $allowed_values_str = str_replace("\\{$sfgListSeparator}", "\\a", $allowed_values_str); $allowed_values_array = explode($sfgListSeparator, $allowed_values_str); $text .= "\n\n" . wfMsgExt('sf_property_allowedvals', array('parsemag', 'content'), count($allowed_values_array)); foreach ($allowed_values_array as $i => $value) { // replace beep back with comma, trim $value = str_replace("\\a", $sfgListSeparator, trim($value)); $prop_labels = $smwgContLang->getPropertyLabels(); $text .= "\n* [[" . $prop_labels['_PVAL'] . "::{$value}]]"; } } return $text; }
public function execute() { global $wgUser; if (!$wgUser->isAllowed('surveysubmit') || $wgUser->isBlocked()) { $this->dieUsageMsg(array('badaccess-groups')); } $params = $this->extractRequestParams(); if (!(isset($params['id']) xor isset($params['name']))) { $this->dieUsage(wfMsg('survey-err-id-xor-name'), 'id-xor-name'); } if (isset($params['name'])) { $survey = Survey::newFromName($params['name'], null, false); if ($survey === false) { $this->dieUsage(wfMsgExt('survey-err-survey-name-unknown', 'parsemag', $params['name']), 'survey-name-unknown'); } } else { $survey = Survey::newFromId($params['id'], null, false); if ($survey === false) { $this->dieUsage(wfMsgExt('survey-err-survey-id-unknown', 'parsemag', $params['id']), 'survey-id-unknown'); } } $submission = new SurveySubmission(array('survey_id' => $survey->getId(), 'page_id' => 0, 'user_name' => $GLOBALS['wgUser']->getName(), 'time' => wfTimestampNow())); foreach (FormatJson::decode($params['answers']) as $answer) { $submission->addAnswer(SurveyAnswer::newFromArray((array) $answer)); } $submission->writeToDB(); }
public function execute() { $params = $this->extractRequestParams(); if (!(isset($params['username']) xor isset($params['userid']))) { $this->dieUsage(wfMsgExt('ep-addinstructor-invalid-user-args'), 'username-xor-userid'); } if (isset($params['username'])) { $user = User::newFromName($params['username']); $userId = $user->getId(); } else { $userId = $params['userid']; } if ($userId < 1) { $this->dieUsage(wfMsgExt('ep-addinstructor-invalid-user'), 'invalid-user'); } if (!$this->userIsAllowed($userId)) { $this->dieUsageMsg(array('badaccess-groups')); } $course = EPCourse::selectRow(array('id', 'name', 'instructors'), array('id' => $params['courseid'])); if ($course === false) { $this->dieUsage(wfMsgExt('ep-addinstructor-invalid-course'), 'invalid-course'); } $success = false; switch ($params['subaction']) { case 'add': $success = $course->addInstructors(array($userId), $params['reason']); break; case 'remove': $success = $course->removeInstructors(array($userId), $params['reason']); break; } $this->getResult()->addValue(null, 'success', $success); }
function showForm() { global $wgOut, $wgUser, $wgLang, $wgRequest; $self = SpecialPage::getTitleFor('Resetpass'); $form = '<div id="userloginForm">' . wfOpenElement('form', array('method' => 'post', 'action' => $self->getLocalUrl())) . '<h2>' . wfMsgHtml('resetpass_header') . '</h2>' . '<div id="userloginprompt">' . wfMsgExt('resetpass_text', array('parse')) . '</div>' . '<table>' . wfHidden('token', $wgUser->editToken()) . wfHidden('wpName', $this->mName) . wfHidden('wpPassword', $this->mTemporaryPassword) . wfHidden('returnto', $wgRequest->getVal('returnto')) . $this->pretty(array(array('wpName', 'username', 'text', $this->mName), array('wpNewPassword', 'newpassword', 'password', ''), array('wpRetype', 'yourpasswordagain', 'password', ''))) . '<tr>' . '<td></td>' . '<td>' . Xml::checkLabel(wfMsg('remembermypassword'), 'wpRemember', 'wpRemember', $wgRequest->getCheck('wpRemember')) . '</td>' . '</tr>' . '<tr>' . '<td></td>' . '<td>' . wfSubmitButton(wfMsgHtml('resetpass_submit')) . '</td>' . '</tr>' . '</table>' . wfCloseElement('form') . '</div>'; $wgOut->addHtml($form); }
/** * Build the HTML for the page * @return true */ private function buildPage() { global $wgScriptPath; $htmlOut = ''; // Output beginning of the page $htmlOut .= <<<HTML <!DOCTYPE html> <html lang="en" dir="ltr" class="client-nojs"> HTML; $htmlOut .= $this->getHtmlHead(); $htmlOut .= <<<HTML <body> <div id="everything"> <div id="instructions"> HTML; $htmlOut .= wfMsgExt('congresslookup-text', 'parse'); $htmlOut .= '</div><div id="contacts">'; if ($this->getZip() === false) { $htmlOut .= $this->getZipForm(true); } elseif (!is_null($this->getZip())) { $htmlOut .= $this->getCongressTables(); } else { $htmlOut .= $this->getZipForm(); } // Output end of the page $htmlOut .= "\n</div>\n</div>\n</body>\n</html>\n"; echo $htmlOut; return true; }
public function getSummary() { if ($this->summary === false) { if ($this->messageId) { $id = $this->messageId; if (is_array($id)) { $id = array_shift($id); } if (substr($id, 0, 3) == 'mw-') { $id = substr($id, 3); } if (isset(self::$messagesMap[$id])) { $id = self::$messagesMap[$id]; } $messageId = $id . '-notice'; $message = wfMsg($messageId); if (!wfEmptyMsg($messageId, $message)) { $this->summary = wfMsgExt($messageId, array('parseinline')); } } if ($this->summary === false) { $this->summary = $this->getHtmlSnippet(); } } return (string) $this->summary; }
/** * Show a message, depending on settings and the relevancy of the results. * * @param $out Object: OutputPage instance * @return Boolean: true */ function wfEditSimilarViewMesg(&$out) { global $wgUser, $wgEditSimilarAlwaysShowThanks; if (!empty($_SESSION['ES_saved']) && $wgUser->getOption('edit-similar', 1) == 1 && $out->isArticle()) { if (EditSimilar::checkCounter()) { $message_text = ''; $title = $out->getTitle(); $articleTitle = $title->getText(); // here we'll populate the similar articles and links $instance = new EditSimilar($title->getArticleId(), 'category'); $similarities = $instance->getSimilarArticles(); if (!empty($similarities)) { global $wgLang; if ($instance->mSimilarArticles) { $messageText = wfMsgExt('editsimilar-thanks', array('parsemag'), $wgLang->listToText($similarities), count($similarities)); } else { // the articles we found were rather just articles needing attention $messageText = wfMsgExt('editsimilar-thanks-notsimilar', array('parsemag'), $wgLang->listToText($similarities), count($similarities)); } } else { if ($wgUser->isLoggedIn() && !empty($wgEditSimilarAlwaysShowThanks)) { $messageText = wfMsg('editsimilar-thankyou', $wgUser->getName()); } } if ($messageText != '') { EditSimilar::showMessage($messageText, $articleTitle); } } // display that only once $_SESSION['ES_saved'] = ''; } return true; }
/** * Main execution function * @param $par Parameters passed to the page */ function execute($par) { global $wgOut, $wgUser; wfLoadExtensionMessages('Gadgets'); $skin = $wgUser->getSkin(); $this->setHeaders(); $wgOut->setPagetitle(wfMsg("gadgets-title")); $wgOut->addWikiText(wfMsg("gadgets-pagetext")); $gadgets = wfLoadGadgetsStructured(); if (!$gadgets) { return; } $listOpen = false; $msgOpt = array('parseinline', 'parsemag'); foreach ($gadgets as $section => $entries) { if ($section !== false && $section !== '') { $t = Title::makeTitleSafe(NS_MEDIAWIKI, "Gadget-section-{$section}"); $lnk = $t ? $skin->makeLinkObj($t, wfMsgHTML("edit")) : htmlspecialchars($section); $ttext = wfMsgExt("gadget-section-{$section}", $msgOpt); if ($listOpen) { $wgOut->addHTML('</ul>'); $listOpen = false; } $wgOut->addHTML("\n<h2>{$ttext} [{$lnk}]</h2>\n"); } foreach ($entries as $gname => $code) { $t = Title::makeTitleSafe(NS_MEDIAWIKI, "Gadget-{$gname}"); if (!$t) { continue; } $lnk = $skin->makeLinkObj($t, wfMsgHTML("edit")); $ttext = wfMsgExt("gadget-{$gname}", $msgOpt); if (!$listOpen) { $listOpen = true; $wgOut->addHTML('<ul>'); } $wgOut->addHTML("<li>"); $wgOut->addHTML("{$ttext} [{$lnk}]<br/>"); $wgOut->addHTML(wfMsgHTML("gadgets-uses") . ": "); $first = true; foreach ($code as $codePage) { $t = Title::makeTitleSafe(NS_MEDIAWIKI, "Gadget-{$codePage}"); if (!$t) { continue; } if ($first) { $first = false; } else { $wgOut->addHTML(", "); } $lnk = $skin->makeLinkObj($t, htmlspecialchars($t->getText())); $wgOut->addHTML($lnk); } $wgOut->addHtml("</li>"); } } if ($listOpen) { $wgOut->addHTML('</ul>'); } }
/** * GetPreferences hook handler. * @param $user User * @param $preferences Array: Preference descriptions */ public static function getPreferences($user, &$preferences) { $gadgets = Gadget::loadStructuredList(); if (!$gadgets) { return true; } $options = array(); $default = array(); foreach ($gadgets as $section => $thisSection) { $available = array(); foreach ($thisSection as $gadget) { if ($gadget->isAllowed($user)) { $gname = $gadget->getName(); # bug 30182: dir="auto" because it's often not translated $desc = '<span dir="auto">' . $gadget->getDescription() . '</span>'; $available[$desc] = $gname; if ($gadget->isEnabled($user)) { $default[] = $gname; } } } if ($section !== '') { $section = wfMsgExt("gadget-section-{$section}", 'parseinline'); if (count($available)) { $options[$section] = $available; } } else { $options = array_merge($options, $available); } } $preferences['gadgets-intro'] = array('type' => 'info', 'label' => ' ', 'default' => Xml::tags('tr', array(), Xml::tags('td', array('colspan' => 2), wfMsgExt('gadgets-prefstext', 'parse'))), 'section' => 'gadgets', 'raw' => 1, 'rawrow' => 1); $preferences['gadgets'] = array('type' => 'multiselect', 'options' => $options, 'section' => 'gadgets', 'label' => ' ', 'prefix' => 'gadget-', 'default' => $default); return true; }
public function execute($subpage) { global $wgOut, $wgUser; if (!$this->userCanExecute($wgUser)) { $this->displayRestrictionError(); return; } $this->setHeaders(); // Base styles used for all code review UI actions. $wgOut->addModules('ext.codereview'); $wgOut->addModules('ext.codereview.tooltips'); $wgOut->addModuleStyles('ext.codereview.styles'); $view = $this->getViewFrom($subpage); if ($view) { $view->execute(); } else { $wgOut->addWikiMsg('nosuchactiontext'); $wgOut->returnToMain(null, $this->getTitle()); return; } // Add subtitle for easy navigation if ($view instanceof CodeView) { $repo = $view->getRepo(); if ($repo) { $wgOut->setSubtitle(wfMsgExt('codereview-subtitle', 'parse', CodeRepoListView::getNavItem($repo))); } } }
public function execute($par) { $this->checkPermissions(); $this->checkReadOnly(); list($this->target, $this->type) = SpecialBlock::getTargetAndType($par, $this->getRequest()); $this->block = Block::newFromTarget($this->target); $this->setHeaders(); $this->outputHeader(); $out = $this->getOutput(); $out->setPageTitle($this->msg('unblockip')); $out->addModules('mediawiki.special'); $form = new HTMLForm($this->getFields(), $this->getContext()); $form->setWrapperLegend(wfMsg('unblockip')); $form->setSubmitCallback(array(__CLASS__, 'processUIUnblock')); $form->setSubmitText(wfMsg('ipusubmit')); $form->addPreText(wfMsgExt('unblockiptext', 'parse')); if ($form->show()) { switch ($this->type) { case Block::TYPE_USER: case Block::TYPE_IP: $out->addWikiMsg('unblocked', $this->target); break; case Block::TYPE_RANGE: $out->addWikiMsg('unblocked-range', $this->target); break; case Block::TYPE_ID: case Block::TYPE_AUTO: $out->addWikiMsg('unblocked-id', $this->target); break; } } }
/** * Show a global usage section on the image page * * @param object $imagePage The ImagePage * @param string $html HTML to add to the image page as global usage section * @return bool */ public static function onImagePageAfterImageLinks($imagePage, &$html) { if (!self::hasResults($imagePage)) { return true; } $title = $imagePage->getFile()->getTitle(); $targetName = $title->getText(); $query = self::getImagePageQuery($title); $guHtml = ''; foreach ($query->getSingleImageResult() as $wiki => $result) { $wikiName = WikiMap::getWikiName($wiki); $escWikiName = Sanitizer::escapeClass($wikiName); /* Wikia change begin */ wfRunHooks('GlobalUsageImagePageWikiLink', array(&$wikiName)); /* Wikia change end */ $guHtml .= "<li class='mw-gu-onwiki-{$escWikiName}'>" . wfMsgExt('globalusage-on-wiki', 'parseinline', $targetName, $wikiName) . "\n<ul>"; foreach ($result as $item) { $guHtml .= "\t<li>" . SpecialGlobalUsage::formatItem($item) . "</li>\n"; } $guHtml .= "</ul></li>\n"; } if ($guHtml) { $html .= '<h2 id="globalusage">' . wfMsgHtml('globalusage') . "</h2>\n" . '<div id="mw-imagepage-section-globalusage">' . wfMsgExt('globalusage-of-file', 'parse') . "<ul>\n" . $guHtml . "</ul>\n"; if ($query->hasMore()) { $html .= wfMsgExt('globalusage-more', 'parse', $targetName); } $html .= '</div>'; } return true; }
/** * Show the special page * * @param $params Mixed: parameter(s) passed to the page or null */ public function execute($params) { global $wgOut, $wgUser; // Check permissions if (!in_array('staff', $wgUser->getEffectiveGroups())) { throw new ErrorPageError('error', 'badaccess'); } // Show a message if the database is in read-only mode if (wfReadOnly()) { $wgOut->readOnlyPage(); return; } // If user is blocked, they don't need to access this page if ($wgUser->isBlocked()) { $wgOut->blockedPage(); return; } $dbw = wfGetDB(DB_MASTER); $res = $dbw->select('page', array('page_title'), array('page_namespace' => NS_USER), __METHOD__); $count = 0; // To avoid an annoying PHP notice foreach ($res as $row) { $user_name_title = Title::newFromDBkey($row->page_title); $user_name = $user_name_title->getText(); $user_id = User::idFromName($user_name); if ($user_id > 0) { $s = $dbw->selectRow('user_profile', array('up_user_id'), array('up_user_id' => $user_id), __METHOD__); if ($s === false) { $dbw->insert('user_profile', array('up_user_id' => $user_id, 'up_type' => 0), __METHOD__); $count++; } } } $wgOut->addHTML(wfMsgExt('populate-user-profile-done', 'parsemag', $count)); }
static function formatLogEntry($type, $action, $title, $sk, $parameters) { switch ($action) { case 'merge': if ($parameters[0]) { $msg = 'lqt-log-action-merge-across'; } else { $msg = 'lqt-log-action-merge-down'; } break; default: $msg = 'lqt-log-action-' . $action; break; } $options = array('parseinline'); $forIRC = $sk === null; if ($forIRC) { global $wgContLang; $options['language'] = $wgContLang->getCode(); } $replacements = array_merge(array($title->getPrefixedText()), $parameters); $html = wfMsgExt($msg, $options, $replacements); if ($forIRC) { $html = StringUtils::delimiterReplace('<', '>', '', $html); } return $html; }
/** * @param $value * @param $alldata * @return bool|String */ function validate( $value, $alldata ) { $p = parent::validate( $value, $alldata ); if ( $p !== true ) { return $p; } if ( !isset( $this->mParams['valid-values'] ) ) { return true; } if ( $value === 'default' ) { return true; } $codes = $this->tidy( $value ); $valid = array_flip( $this->mParams['valid-values'] ); foreach ( $codes as $code ) { if ( !isset( $valid[$code] ) ) { return wfMsgExt( 'translate-pref-editassistlang-bad', 'parse', $code ); } } return true; }
/** * Returns the HTML which is added to $wgOut after the article text. * * @return string */ protected function getHtml() { wfProfileIn(__METHOD__ . ' (SMW)'); if ($this->limit > 0) { // limit==0: configuration setting to disable this completely $store = smwfGetStore(); $description = new SMWConceptDescription($this->getDataItem()); $query = SMWPageLister::getQuery($description, $this->limit, $this->from, $this->until); $queryResult = $store->getQueryResult($query); $diWikiPages = $queryResult->getResults(); if ($this->until !== '') { $diWikiPages = array_reverse($diWikiPages); } $errors = $queryResult->getErrors(); } else { $diWikiPages = array(); $errors = array(); } $pageLister = new SMWPageLister($diWikiPages, null, $this->limit, $this->from, $this->until); $this->mTitle->setFragment('#SMWResults'); // Make navigation point to the result list. $navigation = $pageLister->getNavigationLinks($this->mTitle); $titleText = htmlspecialchars($this->mTitle->getText()); $resultNumber = min($this->limit, count($diWikiPages)); $result = "<a name=\"SMWResults\"></a><div id=\"mw-pages\">\n" . '<h2>' . wfMsg('smw_concept_header', $titleText) . "</h2>\n" . wfMsgExt('smw_conceptarticlecount', array('parsemag'), $resultNumber) . smwfEncodeMessages($errors) . "\n" . $navigation . $pageLister->formatList() . $navigation . "</div>\n"; wfProfileOut(__METHOD__ . ' (SMW)'); return $result; }
function trySubmit() { global $wgOut, $wgUser; $errors = array(); $ip = $this->mUnblockIP; if (!IP::isIPAddress($ip) && strlen($ip)) { $errors[] = array('globalblocking-unblock-ipinvalid', $ip); $ip = ''; } if (0 == ($id = GlobalBlocking::getGlobalBlockId($ip))) { $errors[] = array('globalblocking-notblocked', $ip); } if (count($errors) > 0) { return $errors; } $dbw = GlobalBlocking::getGlobalBlockingMaster(); $dbw->delete('globalblocks', array('gb_id' => $id), __METHOD__); $page = new LogPage('gblblock'); $page->addEntry('gunblock', Title::makeTitleSafe(NS_USER, $ip), $this->mReason); $successmsg = wfMsgExt('globalblocking-unblock-unblocked', array('parse'), $ip, $id); $wgOut->addHTML($successmsg); $link = $wgUser->getSkin()->makeKnownLinkObj(SpecialPage::getTitleFor('GlobalBlockList'), wfMsg('globalblocking-return')); $wgOut->addHTML($link); $wgOut->setSubtitle(wfMsg('globalblocking-unblock-successsub')); return array(); }
function doTagRow($tag, $hitcount) { static $sk = null, $doneTags = array(); if (!$sk) { global $wgUser; $sk = $wgUser->getSkin(); } if (in_array($tag, $doneTags)) { return ''; } $newRow = ''; $newRow .= Xml::tags('td', null, Xml::element('tt', null, $tag)); $disp = ChangeTags::tagDescription($tag); $disp .= ' (' . $sk->link(Title::makeTitle(NS_MEDIAWIKI, "Tag-{$tag}"), wfMsg('tags-edit')) . ')'; $newRow .= Xml::tags('td', null, $disp); $desc = wfMsgExt("tag-{$tag}-description", 'parseinline'); $desc = wfEmptyMsg("tag-{$tag}-description", $desc) ? '' : $desc; $desc .= ' (' . $sk->link(Title::makeTitle(NS_MEDIAWIKI, "Tag-{$tag}-description"), wfMsg('tags-edit')) . ')'; $newRow .= Xml::tags('td', null, $desc); $hitcount = wfMsg('tags-hitcount', $hitcount); $hitcount = $sk->link(SpecialPage::getTitleFor('RecentChanges'), $hitcount, array(), array('tagfilter' => $tag)); $newRow .= Xml::tags('td', null, $hitcount); $doneTags[] = $tag; return Xml::tags('tr', null, $newRow) . "\n"; }
public function addWikiaVars(&$obj, BaseTemplate &$tpl) { global $wgUser; wfProfileIn(__METHOD__); // ads $this->setupAds($tpl); // setup footer links $tpl->set('footerlinks', wfMsgExt('Shared-Monobook-footer-wikia-links', 'parse')); # rt33045 $tpl->set('contact', '<a href="' . $wgUser->getSkin()->makeUrl('Special:Contact') . '" title="Contact Wikia">Contact Wikia</a>'); # BAC-1036, CE-278 /* Replace Wikia logo path This functionality is for finding proper path of Wiki.png instead of const one from wgLogo wikia logo should be stored under File:Wiki.png on current wikia. If wfFindFile doesn't find it on current wikia it tires to fallback to starter.wikia.com where the default one is stored */ $logoPage = Title::newFromText('Wiki.png', NS_FILE); $logoFile = wfFindFile($logoPage); if ($logoFile) { $tpl->set('logopath', $logoFile->getUrl()); } else { $tpl->set('logopath', wfReplaceImageServer($tpl->data['logopath'])); } wfProfileOut(__METHOD__); return true; }