function doTagRow($tag, $hitcount) { $user = $this->getUser(); $newRow = ''; $newRow .= Xml::tags('td', null, Xml::element('code', null, $tag)); $disp = ChangeTags::tagDescription($tag); if ($user->isAllowed('editinterface')) { $disp .= ' '; $editLink = Linker::link(Title::makeTitle(NS_MEDIAWIKI, "Tag-{$tag}"), $this->msg('tags-edit')->escaped()); $disp .= $this->msg('parentheses')->rawParams($editLink)->escaped(); } $newRow .= Xml::tags('td', null, $disp); $msg = $this->msg("tag-{$tag}-description"); $desc = !$msg->exists() ? '' : $msg->parse(); if ($user->isAllowed('editinterface')) { $desc .= ' '; $editDescLink = Linker::link(Title::makeTitle(NS_MEDIAWIKI, "Tag-{$tag}-description"), $this->msg('tags-edit')->escaped()); $desc .= $this->msg('parentheses')->rawParams($editDescLink)->escaped(); } $newRow .= Xml::tags('td', null, $desc); $active = isset($this->definedTags[$tag]) ? 'tags-active-yes' : 'tags-active-no'; $active = $this->msg($active)->escaped(); $newRow .= Xml::tags('td', null, $active); $hitcountLabel = $this->msg('tags-hitcount')->numParams($hitcount)->escaped(); $hitcountLink = Linker::link(SpecialPage::getTitleFor('Recentchanges'), $hitcountLabel, array(), array('tagfilter' => $tag)); // add raw $hitcount for sorting, because tags-hitcount contains numbers and letters $newRow .= Xml::tags('td', array('data-sort-value' => $hitcount), $hitcountLink); return Xml::tags('tr', null, $newRow) . "\n"; }
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"; }
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"; }
function doTagRow($tag, $hitcount) { static $doneTags = array(); if (in_array($tag, $doneTags)) { return ''; } $newRow = ''; $newRow .= Xml::tags('td', null, Xml::element('code', null, $tag)); $disp = ChangeTags::tagDescription($tag); $disp .= ' '; $editLink = Linker::link(Title::makeTitle(NS_MEDIAWIKI, "Tag-{$tag}"), $this->msg('tags-edit')->escaped()); $disp .= $this->msg('parentheses')->rawParams($editLink)->escaped(); $newRow .= Xml::tags('td', null, $disp); $msg = $this->msg("tag-{$tag}-description"); $desc = !$msg->exists() ? '' : $msg->parse(); $desc .= ' '; $editDescLink = Linker::link(Title::makeTitle(NS_MEDIAWIKI, "Tag-{$tag}-description"), $this->msg('tags-edit')->escaped()); $desc .= $this->msg('parentheses')->rawParams($editDescLink)->escaped(); $newRow .= Xml::tags('td', null, $desc); $hitcount = $this->msg('tags-hitcount')->numParams($hitcount)->escaped(); $hitcount = Linker::link(SpecialPage::getTitleFor('Recentchanges'), $hitcount, array(), array('tagfilter' => $tag)); $newRow .= Xml::tags('td', null, $hitcount); $doneTags[] = $tag; return Xml::tags('tr', null, $newRow) . "\n"; }
private function doTag($tagName, $hitcount) { static $count = 0; static $doneTags = array(); if (in_array($tagName, $doneTags)) { return true; } if (++$count > $this->limit) { $this->setContinueEnumParameter('continue', $tagName); return false; } $tag = array(); $tag['name'] = $tagName; if ($this->fld_displayname) { $tag['displayname'] = ChangeTags::tagDescription($tagName); } if ($this->fld_description) { $msg = wfMessage("tag-{$tagName}-description"); $tag['description'] = $msg->exists() ? $msg->text() : ''; } if ($this->fld_hitcount) { $tag['hitcount'] = $hitcount; } $doneTags[] = $tagName; $fit = $this->result->addValue(array('query', $this->getModuleName()), null, $tag); if (!$fit) { $this->setContinueEnumParameter('continue', $tagName); return false; } return true; }
/** * Insert the tags of the given change */ private function formatReviewSummaryRow($rc, $page) { global $wgRequest; $s = ''; if (!$rc) { return $s; } $attr = $rc->mAttribs; $tagRows = $attr['collabwatchlist_tags']; $classes = array(); $displayTags = array(); foreach ($tagRows as $tagRow) { $tag = $tagRow['ct_tag']; $collabwatchlistTag = Xml::tags('span', array('class' => 'mw-collabwatchlist-tag-marker ' . Sanitizer::escapeClass("mw-collabwatchlist-tag-marker-{$tag}"), 'title' => $tagRow['rrt_comment']), ChangeTags::tagDescription($tag)); $classes[] = Sanitizer::escapeClass("mw-collabwatchlist-tag-{$tag}"); /** Insert links to user page, user talk page and eventually a blocking link */ $userLink = $this->skin->userLink($tagRow['user_id'], $tagRow['user_name']); $delTagTarget = CollabWatchlistEditor::getUnsetTagUrl($wgRequest->getFullRequestURL(), $attr['rc_title'], $tagRow['cw_id'], $tag, $attr['rc_id']); $delTagLink = Xml::element('a', array('href' => $delTagTarget, 'class' => 'mw-collabwatchlist-unsettag-' . $tag), wfMsg('collabwatchlist-unset-tag')); $displayTags[] = $collabwatchlistTag . ' ' . $delTagLink . ' ' . $userLink; } $markers = '(' . implode(', ', $displayTags) . ')'; $markers = Xml::tags('span', array('class' => 'mw-collabwatchlist-tag-markers'), $markers); return array($markers, $classes); }
function doTagRow($tag, $hitcount, $showManageActions, $showDeleteActions, $showEditLinks) { $newRow = ''; $newRow .= Xml::tags('td', null, Xml::element('code', null, $tag)); $disp = ChangeTags::tagDescription($tag); if ($showEditLinks) { $disp .= ' '; $editLink = Linker::link($this->msg("tag-{$tag}")->inContentLanguage()->getTitle(), $this->msg('tags-edit')->escaped()); $disp .= $this->msg('parentheses')->rawParams($editLink)->escaped(); } $newRow .= Xml::tags('td', null, $disp); $msg = $this->msg("tag-{$tag}-description"); $desc = !$msg->exists() ? '' : $msg->parse(); if ($showEditLinks) { $desc .= ' '; $editDescLink = Linker::link($this->msg("tag-{$tag}-description")->inContentLanguage()->getTitle(), $this->msg('tags-edit')->escaped()); $desc .= $this->msg('parentheses')->rawParams($editDescLink)->escaped(); } $newRow .= Xml::tags('td', null, $desc); $sourceMsgs = []; $isExtension = isset($this->extensionDefinedTags[$tag]); $isExplicit = isset($this->explicitlyDefinedTags[$tag]); if ($isExtension) { $sourceMsgs[] = $this->msg('tags-source-extension')->escaped(); } if ($isExplicit) { $sourceMsgs[] = $this->msg('tags-source-manual')->escaped(); } if (!$sourceMsgs) { $sourceMsgs[] = $this->msg('tags-source-none')->escaped(); } $newRow .= Xml::tags('td', null, implode(Xml::element('br'), $sourceMsgs)); $isActive = $isExplicit || isset($this->extensionActivatedTags[$tag]); $activeMsg = $isActive ? 'tags-active-yes' : 'tags-active-no'; $newRow .= Xml::tags('td', null, $this->msg($activeMsg)->escaped()); $hitcountLabel = $this->msg('tags-hitcount')->numParams($hitcount)->escaped(); if ($this->getConfig()->get('UseTagFilter')) { $hitcountLabel = Linker::link(SpecialPage::getTitleFor('Recentchanges'), $hitcountLabel, [], ['tagfilter' => $tag]); } // add raw $hitcount for sorting, because tags-hitcount contains numbers and letters $newRow .= Xml::tags('td', ['data-sort-value' => $hitcount], $hitcountLabel); // actions $actionLinks = []; // delete if ($showDeleteActions && ChangeTags::canDeleteTag($tag)->isOK()) { $actionLinks[] = Linker::linkKnown($this->getPageTitle('delete'), $this->msg('tags-delete')->escaped(), [], ['tag' => $tag]); } if ($showManageActions) { // we've already checked that the user had the requisite userright // activate if (ChangeTags::canActivateTag($tag)->isOK()) { $actionLinks[] = Linker::linkKnown($this->getPageTitle('activate'), $this->msg('tags-activate')->escaped(), [], ['tag' => $tag]); } // deactivate if (ChangeTags::canDeactivateTag($tag)->isOK()) { $actionLinks[] = Linker::linkKnown($this->getPageTitle('deactivate'), $this->msg('tags-deactivate')->escaped(), [], ['tag' => $tag]); } } if ($actionLinks) { $newRow .= Xml::tags('td', null, $this->getLanguage()->pipeList($actionLinks)); } return Xml::tags('tr', null, $newRow) . "\n"; }
public function execute() { $params = $this->extractRequestParams(); $prop = array_flip($params['prop']); $fld_displayname = isset($prop['displayname']); $fld_description = isset($prop['description']); $fld_hitcount = isset($prop['hitcount']); $fld_defined = isset($prop['defined']); $fld_source = isset($prop['source']); $fld_active = isset($prop['active']); $limit = $params['limit']; $result = $this->getResult(); $extensionDefinedTags = array_fill_keys(ChangeTags::listExtensionDefinedTags(), 0); $explicitlyDefinedTags = array_fill_keys(ChangeTags::listExplicitlyDefinedTags(), 0); $extensionActivatedTags = array_fill_keys(ChangeTags::listExtensionActivatedTags(), 0); $definedTags = array_merge($extensionDefinedTags, $explicitlyDefinedTags); # Fetch defined tags that aren't past the continuation if ($params['continue'] !== null) { $cont = $params['continue']; $tags = array_filter(array_keys($definedTags), function ($v) use($cont) { return $v >= $cont; }); $tags = array_fill_keys($tags, 0); } else { $tags = $definedTags; } # Merge in all used tags $this->addTables('change_tag'); $this->addFields('ct_tag'); $this->addFields(array('hitcount' => $fld_hitcount ? 'COUNT(*)' : '0')); $this->addOption('LIMIT', $limit + 1); $this->addOption('GROUP BY', 'ct_tag'); $this->addWhereRange('ct_tag', 'newer', $params['continue'], null); $res = $this->select(__METHOD__); foreach ($res as $row) { $tags[$row->ct_tag] = (int) $row->hitcount; } # Now make sure the array is sorted for proper continuation ksort($tags); $count = 0; foreach ($tags as $tagName => $hitcount) { if (++$count > $limit) { $this->setContinueEnumParameter('continue', $tagName); break; } $tag = array(); $tag['name'] = $tagName; if ($fld_displayname) { $tag['displayname'] = ChangeTags::tagDescription($tagName); } if ($fld_description) { $msg = $this->msg("tag-{$tagName}-description"); $tag['description'] = $msg->exists() ? $msg->text() : ''; } if ($fld_hitcount) { $tag['hitcount'] = $hitcount; } $isExtension = isset($extensionDefinedTags[$tagName]); $isExplicit = isset($explicitlyDefinedTags[$tagName]); if ($fld_defined) { $tag['defined'] = $isExtension || $isExplicit; } if ($fld_source) { $tag['source'] = array(); if ($isExtension) { $tag['source'][] = 'extension'; } if ($isExplicit) { $tag['source'][] = 'manual'; } } if ($fld_active) { $tag['active'] = $isExplicit || isset($extensionActivatedTags[$tagName]); } $fit = $result->addValue(array('query', $this->getModuleName()), null, $tag); if (!$fit) { $this->setContinueEnumParameter('continue', $tagName); break; } } $result->addIndexedTagName(array('query', $this->getModuleName()), 'tag'); }
function doTagRow($tag, $hitcount, $showActions) { $user = $this->getUser(); $newRow = ''; $newRow .= Xml::tags('td', null, Xml::element('code', null, $tag)); $disp = ChangeTags::tagDescription($tag); if ($user->isAllowed('editinterface')) { $disp .= ' '; $editLink = Linker::link(Title::makeTitle(NS_MEDIAWIKI, "Tag-{$tag}"), $this->msg('tags-edit')->escaped()); $disp .= $this->msg('parentheses')->rawParams($editLink)->escaped(); } $newRow .= Xml::tags('td', null, $disp); $msg = $this->msg("tag-{$tag}-description"); $desc = !$msg->exists() ? '' : $msg->parse(); if ($user->isAllowed('editinterface')) { $desc .= ' '; $editDescLink = Linker::link(Title::makeTitle(NS_MEDIAWIKI, "Tag-{$tag}-description"), $this->msg('tags-edit')->escaped()); $desc .= $this->msg('parentheses')->rawParams($editDescLink)->escaped(); } $newRow .= Xml::tags('td', null, $desc); $sourceMsgs = array(); $isExtension = isset($this->extensionDefinedTags[$tag]); $isExplicit = isset($this->explicitlyDefinedTags[$tag]); if ($isExtension) { $sourceMsgs[] = $this->msg('tags-source-extension')->escaped(); } if ($isExplicit) { $sourceMsgs[] = $this->msg('tags-source-manual')->escaped(); } if (!$sourceMsgs) { $sourceMsgs[] = $this->msg('tags-source-none')->escaped(); } $newRow .= Xml::tags('td', null, implode(Xml::element('br'), $sourceMsgs)); $isActive = $isExplicit || isset($this->extensionActivatedTags[$tag]); $activeMsg = $isActive ? 'tags-active-yes' : 'tags-active-no'; $newRow .= Xml::tags('td', null, $this->msg($activeMsg)->escaped()); $hitcountLabel = $this->msg('tags-hitcount')->numParams($hitcount)->escaped(); $hitcountLink = Linker::link(SpecialPage::getTitleFor('Recentchanges'), $hitcountLabel, array(), array('tagfilter' => $tag)); // add raw $hitcount for sorting, because tags-hitcount contains numbers and letters $newRow .= Xml::tags('td', array('data-sort-value' => $hitcount), $hitcountLink); // actions $actionLinks = array(); if ($showActions) { // delete if (ChangeTags::canDeleteTag($tag, $user)->isOK()) { $actionLinks[] = Linker::linkKnown($this->getPageTitle('delete'), $this->msg('tags-delete')->escaped(), array(), array('tag' => $tag)); } // activate if (ChangeTags::canActivateTag($tag, $user)->isOK()) { $actionLinks[] = Linker::linkKnown($this->getPageTitle('activate'), $this->msg('tags-activate')->escaped(), array(), array('tag' => $tag)); } // deactivate if (ChangeTags::canDeactivateTag($tag, $user)->isOK()) { $actionLinks[] = Linker::linkKnown($this->getPageTitle('deactivate'), $this->msg('tags-deactivate')->escaped(), array(), array('tag' => $tag)); } $newRow .= Xml::tags('td', null, $this->getLanguage()->pipeList($actionLinks)); } return Xml::tags('tr', null, $newRow) . "\n"; }