function formatRow($row) { $type = implode(", ", Phalanx::getTypeNames(isset($row->ps_blocker_hit) ? $row->ps_blocker_hit : $row->ps_blocker_type)); $username = $row->ps_blocked_user; $timestamp = $this->app->wg->Lang->timeanddate($row->ps_timestamp); $oWiki = WikiFactory::getWikiById($row->ps_wiki_id); $url = isset($row->ps_referrer) ? $row->ps_referrer : ""; $url = empty($url) && isset($oWiki) ? $oWiki->city_url : $url; $html = Html::openElement('li'); $html .= wfMsgExt('phalanx-stats-row', array('parseinline'), $type, $username, $url, $timestamp); $html .= Html::closeElement('li'); return $html; }
private function blockStats($blockId) { $this->wg->Out->setPageTitle(sprintf("%s #%s", wfMsg('phalanx-stats-title'), $blockId)); $data = Phalanx::newFromId($blockId); if (!isset($data["id"])) { $this->wg->Out->addWikiMsg('phalanx-stats-block-notfound', $blockId); return; } $data['author_id'] = User::newFromId($data['author_id'])->getName(); $data['timestamp'] = $this->wg->Lang->timeanddate($data['timestamp']); if ($data['expire'] == null) { $data['expire'] = 'infinite'; } else { $data['expire'] = $this->wg->Lang->timeanddate($data['expire']); } $data['regex'] = $data['regex'] ? 'Yes' : 'No'; $data['case'] = $data['case'] ? 'Yes' : 'No'; $data['exact'] = $data['exact'] ? 'Yes' : 'No'; $data['lang'] = empty($data['lang']) ? 'All' : $data['lang']; if ($data['type'] & Phalanx::TYPE_EMAIL && !$this->wg->User->isAllowed('phalanxemailblock')) { /* hide email from non-privildged users */ $data['text'] = wfMsg('phalanx-email-filter-hidden'); } $data['type'] = implode(', ', Phalanx::getTypeNames($data['type'])); /* stats table */ $headers = array(wfMsg('phalanx-stats-table-id'), wfMsg('phalanx-stats-table-user'), wfMsg('phalanx-stats-table-type'), wfMsg('phalanx-stats-table-create'), wfMsg('phalanx-stats-table-expire'), wfMsg('phalanx-stats-table-exact'), wfMsg('phalanx-stats-table-regex'), wfMsg('phalanx-stats-table-case'), wfMsg('phalanx-stats-table-language')); $tableAttribs = array('class' => 'wikitable', 'width' => '100%'); /* pull these out of the array, so they dont get used in the top rows */ $row = $data->toArray(); unset($row['text']); unset($row['reason']); unset($row['comment']); unset($row['ip_hex']); // parse block comment if ($data['comment'] != '') { $comment = ParserPool::parse($data['comment'], $this->wg->Title, new ParserOptions())->getText(); } else { $comment = ''; } $table = Xml::buildTable(array($row), $tableAttribs, $headers); $table = str_replace("</table>", "", $table); $table .= "<tr><th>" . wfMsg('phalanx-stats-table-text') . "</th><td colspan='8'>" . htmlspecialchars($data['text']) . "</td></tr>"; $table .= "<tr><th>" . wfMsg('phalanx-stats-table-reason') . "</th><td colspan='8'>{$data['reason']}</td></tr>"; $table .= "<tr><th>" . wfMsg('phalanx-stats-table-comment') . "</th><td colspan='8'>{$comment}</td></tr>"; $table .= "</table>"; $this->setVal('table', $table); $this->setVal('editUrl', $this->phalanxTitle->getLocalUrl(array('id' => $data['id']))); /* match statistics */ $pager = new PhalanxStatsPager($blockId); $this->setVal('statsPager', $pager->getNavigationBar() . $pager->getBody() . $pager->getNavigationBar()); }
function formatRow($row) { $type = implode(", ", Phalanx::getTypeNames(isset($row->ps_blocker_hit) ? $row->ps_blocker_hit : $row->ps_blocker_type)); $username = $row->ps_blocked_user; $timestamp = $this->app->wg->Lang->timeanddate($row->ps_timestamp); $url = $row->ps_referrer; $blockId = (int) $row->ps_blocker_id; # block $phalanxUrl = $this->mSkin->makeLinkObj($this->mTitle, $blockId, 'id=' . $blockId); # stats $statsUrl = $this->mSkin->makeLinkObj($this->mTitleStats, wfMsg('phalanx-link-stats'), 'blockId=' . $blockId); $html = Html::openElement('li'); $html .= wfMsgExt('phalanx-stats-row-per-wiki', array('parseinline', 'replaceafter'), $type, $username, $phalanxUrl, $timestamp, $statsUrl, $url); $html .= Html::closeElement('li'); return $html; }
function formatRow($row) { // hide e-mail filters if ($row->p_type & Phalanx::TYPE_EMAIL && !$this->app->wg->User->isAllowed('phalanxemailblock')) { return ''; } if (isset($row->p_author_id)) { $author = User::newFromId($row->p_author_id); $authorName = $author->getName(); } else { $authorName = ''; } $statsUrl = sprintf("%s/%s", $this->phalanxStatsPage->getLocalUrl(), $row->p_id); $html = Html::openElement('li', array('id' => 'phalanx-block-' . $row->p_id)); $html .= Html::element('b', array('class' => 'blockContent'), $row->p_text); $html .= sprintf(" (%s%s%s) ", !empty($row->p_regex) ? 'regex' : 'plain', !empty($row->p_case) ? ',case' : '', !empty($row->p_exact) ? ',exact' : ''); /* control links */ $html .= sprintf(" • %s • %s", Html::element('a', array('class' => 'modify', 'href' => $this->phalanxPage->getLocalUrl(array('id' => $row->p_id))), wfMsg('phalanx-link-modify')), Html::element('a', array('class' => 'stats', 'href' => $statsUrl), wfMsg('phalanx-link-stats'))); /* remove block button - handled via AJAX */ $html .= Html::element('button', array('class' => 'unblock', 'data-id' => $row->p_id), wfMsg('phalanx-link-unblock')); $html .= Html::element('br'); /* types */ $html .= wfMsg('phalanx-display-row-blocks', implode(', ', Phalanx::getTypeNames($row->p_type))); /* created */ if (isset($row->p_timestamp)) { $html .= sprintf(" • %s ", wfMsgExt('phalanx-display-row-created', array('parseinline'), $authorName, $this->app->wg->Lang->timeanddate($row->p_timestamp))); } /* valid till */ if (property_exists($row, 'p_expire')) { if (is_null($row->p_expire)) { $html .= sprintf(" • %s ", wfMsg('phalanx-display-row-expire-infinity')); } else { if (is_numeric($row->p_expire)) { $html .= sprintf(" • %s ", wfMsg('phalanx-display-row-expire', $this->app->wg->Lang->timeanddate($row->p_expire))); } } } $html .= Html::closeElement("li"); return $html; }
/** * Returns current block data * * @return array */ private function blockDataForForm() { $data = array(); $id = $this->wg->Request->getInt('id'); if ($id > 0) { // block edit $data = Phalanx::newFromId($id); if ($data['type'] & Phalanx::TYPE_EMAIL && !$this->app->wg->User->isAllowed('phalanxemailblock')) { // VSTF members should not be able to view email blocks $data = []; } else { $data['type'] = Phalanx::getTypeNames($data['type']); $data['checkId'] = $id; $data['checkBlocker'] = ''; return $data; } } // block creation $pager = new PhalanxPager(); $data['checkBlocker'] = $this->wg->Request->getText('wpPhalanxCheckBlocker', ''); $data['checkId'] = $this->wg->Request->getIntOrNull('id'); $data['type'] = $pager->getSearchFilter(); $data['text'] = $this->wg->Request->getText('target', ''); // prefill the filter content using target URL parameter $data['lang'] = ''; $data['expire'] = ''; $data['reason'] = ''; $data['comment'] = ''; return $data; }
private function log($action) { $title = Title::newFromText('PhalanxStats/' . $this->data['id'], NS_SPECIAL); $types = implode(',', Phalanx::getTypeNames($this->data['type'])); if ($this->data['type'] & Phalanx::TYPE_EMAIL) { $logType = 'phalanxemail'; } else { $logType = 'phalanx'; } $log = new LogPage($logType); $log->addEntry($action, $title, wfMsgExt('phalanx-rule-log-details', array('parsemag', 'content'), $this->data['text'], $types, $this->data['reason'])); }
public static function logUniversal($action, $data) { $title = Title::newFromText('PhalanxStats/' . $data['id'], NS_SPECIAL); $types = implode(',', Phalanx::getTypeNames($data['type'])); if ($data['type'] & Phalanx::TYPE_EMAIL) { $logType = 'phalanxemail'; } else { $logType = 'phalanx'; } $log = new LogPage($logType); $log->addEntry($action, $title, wfMsgExt('phalanx-rule-log-details', array('parsemag', 'content'), $data['text'], $types, $data['reason'])); // Workaround lack of automatic COMMIT in Ajax requests $db = wfGetDB(DB_MASTER); $db->commit(); }
function formatRow($row) { global $wgLang; $type = implode(Phalanx::getTypeNames($row->ps_blocker_type)); $username = $row->ps_blocked_user; $timestamp = $wgLang->timeanddate($row->ps_timestamp); $blockId = (int) $row->ps_blocker_id; # block $phalanxUrl = $this->mSkin->makeLinkObj($this->mTitle, $blockId, 'id=' . $blockId); # stats $statsUrl = $this->mSkin->makeLinkObj($this->mTitleStats, wfMsg('phalanx-link-stats'), 'blockId=' . $blockId); $html = '<li>'; $html .= wfMsgExt('phalanx-stats-row-per-wiki', array('parseinline', 'replaceafter'), $type, $username, $phalanxUrl, $timestamp, $statsUrl); $html .= '</li>'; return $html; }
function formatRow($row) { global $wgLang, $wgUser; // hide e-mail filters if ($row->p_type & Phalanx::TYPE_EMAIL && !$wgUser->isAllowed('phalanxemailblock')) { return ''; } $author = User::newFromId($row->p_author_id); $authorName = $author->getName(); $authorUrl = $author->getUserPage()->getFullUrl(); $phalanxUrl = Title::newFromText('Phalanx', NS_SPECIAL)->getFullUrl(array('id' => $row->p_id)); $statsUrl = Title::newFromText('PhalanxStats', NS_SPECIAL)->getFullUrl() . '/' . $row->p_id; $html = '<li id="phalanx-block-' . $row->p_id . '">'; $html .= '<b>' . htmlspecialchars($row->p_text) . '</b> ('; $html .= $row->p_regex ? 'regex' : 'plain'; if ($row->p_case) { $html .= ',case'; } if ($row->p_exact) { $html .= ',exact'; } $html .= ') '; // control links $html .= " • <a class='unblock' href='{$phalanxUrl}'>" . wfMsg('phalanx-link-unblock') . '</a>'; $html .= " • <a class='modify' href='{$phalanxUrl}'>" . wfMsg('phalanx-link-modify') . '</a>'; $html .= " • <a class='stats' href='{$statsUrl}'>" . wfMsg('phalanx-link-stats') . '</a>'; // types $html .= '<br /> ' . wfMsg('phalanx-display-row-blocks', implode(', ', Phalanx::getTypeNames($row->p_type))); $html .= ' • ' . wfMsgExt('phalanx-display-row-created', array('parseinline'), $authorName, $wgLang->timeanddate($row->p_timestamp)); $html .= '</li>'; return $html; }