/** * Show the list of regex blocks - current and expired, along with some controls (unblock, statistics, etc.) */ private function showRegexList() { global $wgOut, $wgLang, $wgUser, $wgContLang; wfProfileIn(__METHOD__); $action = $this->mTitle->escapeLocalURL($this->makeListUrlParams()); $action_unblock = $this->mTitle->escapeLocalURL("action=delete&" . $this->makeListUrlParams()); $regexData = new RegexBlockData(); $this->numResults = $regexData->fetchNbrResults(); $filter = 'filter=' . urlencode($this->mFilter) . '&rfilter=' . urlencode($this->mRegexFilter); $pager = wfViewPrevNext($this->mOffset, $this->mLimit, $wgContLang->specialpage('RegexBlock'), $filter, $this->numResults - $this->mOffset <= $this->mLimit); /* allow display by specific blockers only */ $blockers = $regexData->fetchBlockers(); $blocker_list = array(); if (!empty($blockers)) { $blocker_list = $regexData->getBlockersData($this->mFilter, $this->mRegexFilter, $this->mLimit, $this->mOffset); } /* make link to statistics */ $mSkin = $wgUser->getSkin(); $wgOut->addHTML('<br /> <b>' . wfMsg('regexblock-currently-blocked') . '</b> <p>' . $pager . '</p> <form name="regexlist" method="get" action="' . htmlspecialchars($action) . '"> ' . wfMsg('regexblock-view-blocked') . ' <select name="filter"> <option value="">' . wfMsg('regexblock-view-all') . '</option>'); if (is_array($blockers)) { foreach ($blockers as $id => $blocker) { $sel = htmlspecialchars($this->mFilter == $blocker) ? ' selected="selected"' : ''; $wgOut->addHTML('<option value="' . htmlspecialchars($blocker) . '"' . $sel . '>' . htmlspecialchars($blocker) . '</option>'); } } $wgOut->addHTML('</select> ' . wfMsg('regexblock-regex-filter') . wfMsg('word-separator') . ' <input type="text" name="rfilter" id="regex_filter" value="' . $this->mRegexFilter . '" /> <input type="submit" value="' . wfMsg('regexblock-view-go') . '" /> </form> <br /><br />'); if (!empty($blockers)) { $wgOut->addHTML('<ul>'); $loop = 0; $comma = ' <b>·</b> '; // the spaces here are intentional foreach ($blocker_list as $id => $row) { $loop++; $color_expire = "%s"; if ('infinite' == $row['expiry']) { $row['expiry'] = wfMsg('regexblock-view-block-infinite'); } else { if (wfTimestampNow() > $row['expiry']) { $color_expire = "<span style=\"color:#DC143C\">%s</span>"; } $row['expiry'] = sprintf($color_expire, $wgLang->timeanddate(wfTimestamp(TS_MW, $row['expiry']), true)); } $exact_match = $row['exact_match'] ? wfMsg('regexblock-view-match') : wfMsg('regexblock-view-regex'); $create_block = $row['create_block'] ? wfMsg('regexblock-view-account') : ''; $reason = '<i>' . $row['reason'] . '</i>'; $stats_link = $mSkin->makeKnownLinkObj($this->mTitle, wfMsg('regexblock-view-stats'), 'action=stats&blckid=' . urlencode($row['blckid'])); $wgOut->addHTML('<li style="border-bottom:1px dashed #778899; padding-bottom:2px;font-size:11px"> <b><font style="color:#3B7F07; font-size:12px">' . $row['blckby_name'] . '</font>' . $comma . $exact_match . $create_block . '</b>' . $comma . ' (' . wfMsg('regexblock-view-block-by') . ' <b>' . $row['blocker'] . '</b>, ' . $reason . ') ' . wfMsg('regexblock-view-time', $row['datim'], $row['date'], $row['time']) . $comma . ' (<a href="' . $action_unblock . '&ip=' . $row['ublock_ip'] . '&blocker=' . $row['ublock_blocker'] . '">' . wfMsg('regexblock-view-block-unblock') . '</a>) ' . $comma . $row['expiry'] . $comma . ' (' . $stats_link . ') </li>'); } $wgOut->addHTML('</ul><br /><br /><p>' . $pager . '</p>'); } else { $wgOut->addWikiMsg('regexblock-view-empty'); } wfProfileOut(__METHOD__); }
private function showRegexList() { global $wgOut, $wgRequest, $wgMemc, $wgLang, $wgUser; global $wgContLang; wfProfileIn(__METHOD__); $titleObj = Title::makeTitle(NS_SPECIAL, 'RegexBlock'); $action = htmlspecialchars($titleObj->getLocalURL()) . "?" . $this->makeListUrlParams(); $action_unblock = htmlspecialchars($titleObj->getLocalURL("action=delete")) . "&" . $this->makeListUrlParams(); $regexData = new RegexBlockData(); $this->numResults = $regexData->fetchNbrResults(); $filter = 'filter=' . urlencode($this->mFilter) . '&rfilter=' . urlencode($this->mRegexFilter); $pager = $wgLang->viewPrevNext(SpecialPage::getTitleFor('RegexBlock'), $this->mOffset, $this->mLimit, wfCgiToArray($filter), $this->numResults - $this->mOffset <= $this->mLimit); /* allow display by specific blockers only */ $blockers = $regexData->fetchBlockers(); $blocker_list = array(); if (!empty($blockers)) { $blocker_list = $regexData->getBlockersData($this->mFilter, $this->mRegexFilter, $this->mLimit, $this->mOffset); } /* make link to statistics */ $mSkin = RequestContext::getMain()->getSkin(); $oTmpl = new EasyTemplate(dirname(__FILE__) . "/templates/"); $oTmpl->set_vars(array("pager" => $pager, "titleObj" => $titleObj, "urls" => $this->makeListUrlParams(true), "action" => $action, "action_unblock" => $action_unblock, "sel_blocker" => $this->mFilter, "regex_filter" => $this->mRegexFilter, "blockers" => $blockers, "blocker_list" => $blocker_list, "lang" => $wgLang, "skin" => $mSkin)); $wgOut->addHTML($oTmpl->render("page-output")); wfProfileOut(__METHOD__); }