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"; }
function formatResult($skin, $result) { global $wgUser, $wgContLang; $fromObj = Title::makeTitle($result->namespace, $result->title); if (isset($result->rd_title)) { $toObj = Title::makeTitle($result->rd_namespace, $result->rd_title); } else { $blinks = $fromObj->getBrokenLinksFrom(); # TODO: check for redirect, not for links if ($blinks) { $toObj = $blinks[0]; } else { $toObj = false; } } // $toObj may very easily be false if the $result list is cached if (!is_object($toObj)) { return '<s>' . $skin->makeLinkObj($fromObj) . '</s>'; } $from = $skin->makeKnownLinkObj($fromObj, '', 'redirect=no'); $edit = $skin->makeKnownLinkObj($fromObj, wfMsgHtml('brokenredirects-edit'), 'action=edit'); $to = $skin->makeBrokenLinkObj($toObj); $arr = $wgContLang->getArrow(); $out = "{$from} {$edit}"; if ($wgUser->isAllowed('delete')) { $delete = $skin->makeKnownLinkObj($fromObj, wfMsgHtml('brokenredirects-delete'), 'action=delete'); $out .= " {$delete}"; } $out .= " {$arr} {$to}"; return $out; }
/** * Hook function for RecentChange_save * Saves user data into the cu_changes table */ public static function updateCheckUserData(RecentChange $rc) { global $wgRequest; // Extract params extract($rc->mAttribs); // Get IP $ip = wfGetIP(); // Get XFF header $xff = $wgRequest->getHeader('X-Forwarded-For'); list($xff_ip, $isSquidOnly) = IP::getClientIPfromXFF($xff); // Get agent $agent = $wgRequest->getHeader('User-Agent'); // Store the log action text for log events // $rc_comment should just be the log_comment // BC: check if log_type and log_action exists // If not, then $rc_comment is the actiontext and comment if (isset($rc_log_type) && $rc_type == RC_LOG) { $target = Title::makeTitle($rc_namespace, $rc_title); $context = RequestContext::newExtraneousContext($target); $formatter = LogFormatter::newFromRow($rc->mAttribs); $formatter->setContext($context); $actionText = $formatter->getPlainActionText(); } else { $actionText = ''; } $dbw = wfGetDB(DB_MASTER); $cuc_id = $dbw->nextSequenceValue('cu_changes_cu_id_seq'); $rcRow = array('cuc_id' => $cuc_id, 'cuc_namespace' => $rc_namespace, 'cuc_title' => $rc_title, 'cuc_minor' => $rc_minor, 'cuc_user' => $rc_user, 'cuc_user_text' => $rc_user_text, 'cuc_actiontext' => $actionText, 'cuc_comment' => $rc_comment, 'cuc_this_oldid' => $rc_this_oldid, 'cuc_last_oldid' => $rc_last_oldid, 'cuc_type' => $rc_type, 'cuc_timestamp' => $rc_timestamp, 'cuc_ip' => IP::sanitizeIP($ip), 'cuc_ip_hex' => $ip ? IP::toHex($ip) : null, 'cuc_xff' => !$isSquidOnly ? $xff : '', 'cuc_xff_hex' => $xff_ip && !$isSquidOnly ? IP::toHex($xff_ip) : null, 'cuc_agent' => $agent); # On PG, MW unsets cur_id due to schema incompatibilites. So it may not be set! if (isset($rc_cur_id)) { $rcRow['cuc_page_id'] = $rc_cur_id; } $dbw->insert('cu_changes', $rcRow, __METHOD__); return true; }
public function execute($params = false) { $sEditLinkText = wfMessage('bs-widget-edit')->text(); $oTitle = Title::makeTitle(NS_USER, RequestContext::getMain()->getUser()->getName() . '/Widgetbar'); $sEditLink = Linker::link($oTitle, Html::rawElement('span', array(), $sEditLinkText), array('id' => 'bs-widgetbar-edit', 'class' => 'icon-pencil clearfix'), array('action' => 'edit', 'preload' => '')); $aOut = array(); $aOut[] = '<div id="bs-widget-container" >'; $aOut[] = ' <div class="icon-plus" id="bs-widget-tab" title="' . wfMessage('bs-widget-container-tooltip')->text() . '" tabindex="100">[+/-]</div>'; $aOut[] = ' <div id="bs-flyout">'; $aOut[] = ' <h4 id="bs-flyout-heading">' . wfMessage('bs-widget-flyout-heading')->text() . '</h4>'; $aOut[] = ' <div id="bs-flyout-content">'; $aOut[] = ' <div id="bs-flyout-content-widgets">'; $aOut[] = ' <h4 id="bs-flyout-content-widgets-header">' . wfMessage("bs-widget-flyout-heading")->plain() . $sEditLink . '</h4>'; foreach ($this->_mWidgets as $oWidgetView) { if ($oWidgetView instanceof ViewWidget) { $aOut[] = $oWidgetView->execute(); } else { wfDebug(__METHOD__ . ': Invalid widget.'); } } $aOut[] = ' </div>'; $aOut[] = ' </div>'; $aOut[] = ' </div>'; $aOut[] = '</div>'; return implode("\n", $aOut); }
public function initialize() { $dbr = wfGetDB(DB_MASTER); $res = $dbr->select('categorylinks', array('cl_to', 'COUNT(*) AS count'), array(), __METHOD__, array('GROUP BY' => 'cl_to', 'ORDER BY' => 'count DESC', 'LIMIT' => $this->limit)); wfSuppressWarnings(); // prevent PHP from bitching about strtotime() foreach ($res as $row) { $tag_name = Title::makeTitle(NS_CATEGORY, $row->cl_to); $tag_text = $tag_name->getText(); if (strtotime($tag_text) == '') { // don't want dates to show up if ($row->count > $this->tags_highest_count) { $this->tags_highest_count = $row->count; } $this->tags[$tag_text] = array('count' => $row->count); } } wfRestoreWarnings(); // sort tag array by key (tag name) if ($this->tags_highest_count == 0) { return; } ksort($this->tags); /* and what if we have _1_ category? like on a new wiki with nteen articles, mhm? */ if ($this->tags_highest_count == 1) { $coef = $this->tags_max_pts - $this->tags_min_pts; } else { $coef = ($this->tags_max_pts - $this->tags_min_pts) / (($this->tags_highest_count - 1) * 2); } foreach ($this->tags as $tag => $att) { $this->tags[$tag]['size'] = $this->tags_min_pts + ($this->tags[$tag]['count'] - 1) * $coef; } }
function formatResult($skin, $result) { global $wgContLang; $fname = 'DoubleRedirectsPage::formatResult'; $titleA = Title::makeTitle($result->namespace, $result->title); if ($result && !isset($result->nsb)) { $dbr =& wfGetDB(DB_SLAVE); $sql = $this->getSQLText($dbr, $result->namespace, $result->title); $res = $dbr->query($sql, $fname); if ($res) { $result = $dbr->fetchObject($res); $dbr->freeResult($res); } } if (!$result) { return ''; } $titleB = Title::makeTitle($result->nsb, $result->tb); $titleC = Title::makeTitle($result->nsc, $result->tc); $linkA = $skin->makeKnownLinkObj($titleA, '', 'redirect=no'); $edit = $skin->makeBrokenLinkObj($titleA, "(" . wfMsg("qbedit") . ")", 'redirect=no'); $linkB = $skin->makeKnownLinkObj($titleB, '', 'redirect=no'); $linkC = $skin->makeKnownLinkObj($titleC); $arr = $wgContLang->isRTL() ? '←' : '→'; return "{$linkA} {$edit} {$arr} {$linkB} {$arr} {$linkC}"; }
public function execute() { global $wgUser; $this->output("Checking existence of old default messages..."); $dbr = $this->getDB(DB_REPLICA); $res = $dbr->select(['page', 'revision'], ['page_namespace', 'page_title'], ['page_namespace' => NS_MEDIAWIKI, 'page_latest=rev_id', 'rev_user_text' => 'MediaWiki default']); if ($dbr->numRows($res) == 0) { # No more messages left $this->output("done.\n"); return; } # Deletions will be made by $user temporarly added to the bot group # in order to hide it in RecentChanges. $user = User::newFromName('MediaWiki default'); if (!$user) { $this->error("Invalid username", true); } $user->addGroup('bot'); $wgUser = $user; # Handle deletion $this->output("\n...deleting old default messages (this may take a long time!)...", 'msg'); $dbw = $this->getDB(DB_MASTER); foreach ($res as $row) { wfWaitForSlaves(); $dbw->ping(); $title = Title::makeTitle($row->page_namespace, $row->page_title); $page = WikiPage::factory($title); $error = ''; // Passed by ref // FIXME: Deletion failures should be reported, not silently ignored. $page->doDeleteArticle('No longer required', false, 0, true, $error, $user); } $this->output("done!\n", 'msg'); }
/** * @param Skin $skin * @param object $result Result row * @return string */ function formatResult($skin, $result) { global $wgContLang; $nt = Title::makeTitle($result->namespace, $result->title); $text = htmlspecialchars($wgContLang->convert($nt->getText())); if (!$this->isCached()) { // We can assume the freshest data $plink = Linker::link($nt, $text, array(), array(), array('broken')); $nlinks = $this->msg('nmembers')->numParams($result->value)->escaped(); } else { $plink = Linker::link($nt, $text); $currentValue = isset($this->currentCategoryCounts[$result->title]) ? $this->currentCategoryCounts[$result->title] : 0; $cachedValue = intval($result->value); // T76910 // If the category has been created or emptied since the list was refreshed, strike it if ($nt->isKnown() || $currentValue === 0) { $plink = "<del>{$plink}</del>"; } // Show the current number of category entries if it changed if ($currentValue !== $cachedValue) { $nlinks = $this->msg('nmemberschanged')->numParams($cachedValue, $currentValue)->escaped(); } else { $nlinks = $this->msg('nmembers')->numParams($cachedValue)->escaped(); } } return $this->getLanguage()->specialList($plink, $nlinks); }
public function execute($subpage) { global $wgRequest, $wgUser, $wgOut; if ($wgUser->isAnon()) { $this->displayRestrictionError(); return; } if ($wgUser->isBlocked()) { throw new UserBlockedError($this->getUser()->mBlock); } /** * initial output */ $this->mTitle = Title::makeTitle(NS_SPECIAL, 'CloakCheck'); $wgOut->setPageTitle(wfMsg('cloakcheck')); $wgOut->setRobotpolicy('noindex,nofollow'); $wgOut->setArticleRelated(false); #staff can see other people, users cant if (!$wgUser->isAllowed('cloakcheck')) { #user is user, show just button $this->isChecker = false; $this->mTarget = $wgUser->getName(); } else { #user is staff (or otherwise flagged), allow to use full form/subpage $this->isChecker = true; $this->mTarget = $wgRequest->getText('username', $subpage); } /** * show form */ $this->doForm(); if ($wgRequest->wasPosted()) { $this->process(); } }
/** * @param Skin $skin * @param object $result Result row * @return string */ function formatResult($skin, $result) { $title = Title::makeTitle(NS_TEMPLATE, $result->title); $pageLink = Linker::linkKnown($title, null, array(), array('redirect' => 'no')); $wlhLink = Linker::linkKnown(SpecialPage::getTitleFor('Whatlinkshere', $title->getPrefixedText()), $this->msg('unusedtemplateswlh')->escaped()); return $this->getLanguage()->specialList($pageLink, $wlhLink); }
function doCategoryQuery() { $dbr = wfGetDB(DB_SLAVE, 'category'); if ($this->from != '') { $pageCondition = 'clms_sortkey >= ' . $dbr->addQuotes($this->from); $this->flip = false; } elseif ($this->until != '') { $pageCondition = 'clms_sortkey < ' . $dbr->addQuotes($this->until); $this->flip = true; } else { $pageCondition = '1 = 1'; $this->flip = false; } $res = $dbr->select(array('page', 'categorylinks_multisort', 'category'), array('page_title', 'page_namespace', 'page_len', 'page_is_redirect', 'clms_sortkey', 'cat_id', 'cat_title', 'cat_subcats', 'cat_pages', 'cat_files'), array($pageCondition, 'clms_to' => $this->title->getDBkey(), 'clms_sortkey_name' => $this->sortkeyName), __METHOD__, array('ORDER BY' => $this->flip ? 'clms_sortkey DESC' : 'clms_sortkey', 'USE INDEX' => array('categorylinks_multisort' => 'clms_sortkey'), 'LIMIT' => $this->limit + 1), array('categorylinks_multisort' => array('INNER JOIN', 'clms_from = page_id'), 'category' => array('LEFT JOIN', 'cat_title = page_title AND page_namespace = ' . NS_CATEGORY))); $count = 0; $this->nextPage = null; while ($x = $dbr->fetchObject($res)) { if (++$count > $this->limit) { // We've reached the one extra which shows that there are // additional pages to be had. Stop here... $this->nextPage = $x->clms_sortkey; break; } $title = Title::makeTitle($x->page_namespace, $x->page_title); if ($title->getNamespace() == NS_CATEGORY) { $cat = Category::newFromRow($x, $title); $this->addSubcategoryObject($cat, $x->clms_sortkey, $x->page_len); } elseif ($this->showGallery && $title->getNamespace() == NS_FILE) { $this->addImage($title, $x->clms_sortkey, $x->page_len, $x->page_is_redirect); } else { $this->addPage($title, $x->clms_sortkey, $x->page_len, $x->page_is_redirect); } } }
/** * Show the special page * * @param $params Mixed: parameter(s) passed to the page or null */ public function execute($params) { $out = $this->getOutput(); $user = $this->getUser(); // Set the page title, robot policies, etc. $this->setHeaders(); /** * Redirect anonymous users to the login page * It will automatically return them to the ViewRelationshipRequests page */ if (!$user->isLoggedIn()) { $out->setPageTitle($this->msg('ur-error-page-title')->plain()); $login = SpecialPage::getTitleFor('Userlogin'); $out->redirect($login->getFullURL('returnto=Special:ViewRelationshipRequests')); return false; } // Add CSS & JS $out->addModuleStyles('ext.socialprofile.userrelationship.css'); $out->addModules('ext.socialprofile.userrelationship.js'); $rel = new UserRelationship($user->getName()); $friend_request_count = $rel->getOpenRequestCount($user->getID(), 1); $foe_request_count = $rel->getOpenRequestCount($user->getID(), 2); if ($this->getRequest()->wasPosted() && $_SESSION['alreadysubmitted'] == false) { $_SESSION['alreadysubmitted'] = true; $rel->addRelationshipRequest($this->user_name_to, $this->relationship_type, $_POST['message']); $output = '<br /><span class="title">' . $this->msg('ur-already-submitted')->plain() . '</span><br /><br />'; $out->addHTML($output); } else { $_SESSION['alreadysubmitted'] = false; $output = ''; $out->setPageTitle($this->msg('ur-requests-title')->plain()); $requests = $rel->getRequestList(0); if ($requests) { foreach ($requests as $request) { $user_from = Title::makeTitle(NS_USER, $request['user_name_from']); $avatar = new wAvatar($request['user_id_from'], 'l'); $avatar_img = $avatar->getAvatarURL(); if ($request['type'] == 'Foe') { $msg = $this->msg('ur-requests-message-foe', htmlspecialchars($user_from->getFullURL()), $request['user_name_from'])->text(); } else { $msg = $this->msg('ur-requests-message-friend', htmlspecialchars($user_from->getFullURL()), $request['user_name_from'])->text(); } $message = $out->parse(trim($request['message']), false); $output .= "<div class=\"relationship-action black-text\" id=\"request_action_{$request['id']}\">\n\t\t\t\t\t \t{$avatar_img}" . $msg; if ($request['message']) { $output .= '<div class="relationship-message">' . $message . '</div>'; } $output .= '<div class="cleared"></div> <div class="relationship-buttons"> <input type="button" class="site-button" value="' . $this->msg('ur-accept')->plain() . '" data-response="1" /> <input type="button" class="site-button" value="' . $this->msg('ur-reject')->plain() . '" data-response="-1" /> </div> </div>'; } } else { $output = $this->msg('ur-no-requests-message')->parse(); } $out->addHTML($output); } }
function renderKeypage($input, $argv, $parser) { # $argv is an array containing any arguments passed to the # extension like <example argument="foo" bar>.. # Put this on the sandbox page: (works in MediaWiki 1.5.5) # <example argument="foo" argument2="bar">Testing text **example** in between the new tags</example> $kwline = trim(html_entity_decode($input, ENT_QUOTES, "UTF-8")); $tok = strtok($kwline, ",;"); $kws = array(); while ($tok !== false) { $kws[] = strtolower(trim($tok)); $tok = strtok(",;"); } $kws = array_unique($kws); // var_dump($kws); $output = "<span class=\"small\">"; $komma = ""; if (count($kws)) { foreach ($kws as $kw) { if (strlen($kw) > 80) { $kw = substr($kw, 0, 80); } $kwu = $kw; $kwu[0] = strtoupper($kwu[0]); $output .= sprintf("%s<a href=\"%s\">%s</a>", $komma, Title::makeTitle(NS_SPECIAL, sprintf("Keyword/%s", $kw))->getLocalURL(), $kwu); $komma = ", "; } } $output .= "</span>\n"; return $output; }
function getArticleRequestBottom() { global $wgTitle, $wgStylePath, $wgScript, $wgScriptPath; global $wgLang, $wgTitle, $wgRequest; $s = ""; $li = $wgLang->specialPage("Userlogin"); $lo = $wgLang->specialPage("Userlogout"); $rt = $wgTitle->getPrefixedURL(); if (0 == strcasecmp(urlencode($lo), $rt)) { $q = ""; } else { $q = "?returnto={$rt}"; } $action = $wgRequest->getVal("action"); if ($wgTitle->getNamespace() == NS_ARTICLE_REQUEST && $action == "" && $wgTitle->getArticleID() > 0) { $s .= "</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t"; $t = Title::makeTitle(NS_MAIN, $wgTitle->getText()); if ($t->getArticleID() > 0) { $s .= "<td style=\"padding-left: 50px\" colspan=\"2\"><br/><br/>" . wfMsg('answeredtopic', $t->getText(), $t->getFullURL()) . "</a>."; } else { $s .= "<td style=\"padding-left: 250px\" colspan=\"2\">\n\t\t\t\t\t\t\t<br/><br/>" . wfMsg('canyouhelp') . "<br/><br/>\n\t\t\t\t\t\t\t<img src=\"{$wgStylePath}/common/images/arrow.jpg\" align=\"middle\"> <a href=\"{$wgScript}?title=" . $wgTitle->getDBKey() . "&action=edit&requested=" . $wgTitle->getDBKey() . "\">" . wfMsg('write-howto') . " " . $wgTitle->getText() . "</a><br/>\n\t\t\t\t<br/><!--<font size=-3>" . wfMsg('requested-topic-removed') . "</font><br/><br/>-->\n\t\t\t\t\t\t\t<img src=\"{$wgStylePath}/common/images/arrow.jpg\" align=\"middle\"> <a href=\"{$wgScriptPath}/" . $wgLang->getNsText(NS_SPECIAL) . ":EmailLink?target=" . $wgTitle->getPrefixedURL() . "&returnto={$rt}\">" . wfMsg('sendthisrequest') . "</a>\n\t\t\t\t\t\t\t<br/><font size=-3> " . wfMsg('knowanexprt') . "</font><br/><br/>\n\t\t\t\t\t\t\t<img src=\"{$wgStylePath}/common/images/arrow.jpg\" align=\"middle\"> <a href=\"/Special:Createpage\">" . wfMsg('writerelated') . "</a> <br/>\n\t\t\t\t\t\t\t<font size=-3> " . wfMsg('topicremains') . "</font><br/><br/>\n\t\t\t\t\t<img src=\"{$wgStylePath}/common/images/arrow.jpg\" align=\"middle\"> <a href=\"{$wgScriptPath}/" . wfMsg('about-wikihow-url') . "\">" . wfMsg('learnmoreaboutwikihow') . "</a> <br/>"; } $s .= "</td>\n\t\t\t\t</tr>\n\t\t\t\t</table></div>"; } return $s; }
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 setupMwRdf() { global $wgParser, $wgMessageCache, $wgRequest, $wgOut, $wgHooks; $wgMessageCache->addMessages(array('rdf' => 'Rdf', 'rdf-inpage' => "Embedded In-page Turtle", 'rdf-dcmes' => "Dublin Core Metadata Element Set", 'rdf-cc' => "Creative Commons", 'rdf-image' => "Embedded images", 'rdf-linksfrom' => "Links from the page", 'rdf-links' => "All links", 'rdf-linksto' => "Links to the page", 'rdf-history' => "Historical versions", 'rdf-interwiki' => "Interwiki links", 'rdf-categories' => "Categories", 'rdf-target' => "Target page", 'rdf-modelnames' => "Model(s)", 'rdf-format' => "Output format", 'rdf-output-rdfxml' => "RDFXML", 'rdf-output-turtle' => "Turtle", 'rdf-output-ntriples' => "NTriples", 'rdf-instructions' => "Select the target page and RDF models you're interested in.")); $wgParser->setHook('rdf', 'renderMwRdf'); SpecialPage::addPage(new SpecialPage('Rdf', '', true, 'wfRdfSpecialPage', 'extensions/Rdf/Rdf.php')); SpecialPage::addPage(new SpecialPage('RdfQuery', '', true, 'wfSpecialRdfQuery', 'extensions/Rdf/Rdf.php')); # next we set some hooks for saving and clearing RDF data. Each # hook is called on the same ModelingAgent object as it preserves # the list of pages we link to in its state $wgHooks['ArticleSave'][] = array('wfRdfOnArticleSave'); $wgHooks['ArticleSaveComplete'][] = array('wfRdfOnArticleSaveComplete'); $wgHooks['TitleMoveComplete'][] = array('wfRdfOnTitleMoveComplete'); $wgHooks['ArticleDeleteComplete'][] = array('wfRdfOnArticleDeleteComplete'); # Add an RDF metadata link if requested $action = $wgRequest->getText('action', 'view'); # Note: $wgTitle not yet set; have to get it from the request $title = $wgRequest->getText('title'); if (!isset($title) || strlen($title) == 0) { return true; } $nt = Title::newFromText($title); if (!isset($nt) || $nt->getNamespace() == NS_SPECIAL) { return true; } # finally *if* this is a page view we need to add the link if (!$action == 'view') { return true; } $rdft = Title::makeTitle(NS_SPECIAL, "Rdf"); $target = $nt->getPrefixedDBkey(); $linkdata = array('title' => 'RDF Metadata', 'type' => 'application/rdf+xml', 'href' => $rdft->getLocalURL("target={$target}")); $wgOut->addMetadataLink($linkdata); return true; }
/** * Handle the onDataChanged hook of SMW >1.6, which gets called * every time the value of a propery changes somewhere. * * @since 0.1 * * @param SMWStore $store * @param SMWChangeSet $changes * * @return true */ public static function onDataUpdate( SMWStore $store, SMWSemanticData $newData ) { $subject = $newData->getSubject(); $oldData = $store->getSemanticData( $subject ); $title = Title::makeTitle( $subject->getNamespace(), $subject->getDBkey() ); $groups = SWLGroups::getMatchingWatchGroups( $title ); $edit = false; foreach ( $groups as /* SWLGroup */ $group ) { $changeSet = SWLChangeSet::newFromSemanticData( $oldData, $newData, $group->getProperties() ); if ( $changeSet->hasUserDefinedProperties() ) { if ( $edit === false ) { $edit = new SWLEdit( $title->getArticleID(), $GLOBALS['wgUser']->getName(), wfTimestampNow() ); $edit->writeToDB(); } $changeSet->setEdit( $edit ); $setId = $changeSet->writeToStore( $groups, $edit->getId() ); if ( $setId != 0 ) { $group->notifyWatchingUsers( $changeSet ); } } } return true; }
function execute() { $start = $this->getOption('start', 0); $this->output("Rebuilding titlekey table...\n"); $dbr = $this->getDB(DB_SLAVE); $maxId = $dbr->selectField('page', 'MAX(page_id)', '', __METHOD__); $lastId = 0; for (; $start <= $maxId; $start += $this->mBatchSize) { if ($start != 0) { $this->output("... {$start}...\n"); } $result = $dbr->select('page', array('page_id', 'page_namespace', 'page_title'), array('page_id > ' . intval($start)), __METHOD__, array('ORDER BY' => 'page_id', 'LIMIT' => $this->mBatchSize)); $titles = array(); foreach ($result as $row) { $titles[$row->page_id] = Title::makeTitle($row->page_namespace, $row->page_title); $lastId = $row->page_id; } $result->free(); TitleKey::setBatchKeys($titles); wfWaitForSlaves(20); } if ($lastId) { $this->output("... {$lastId} ok.\n"); } else { $this->output("... no pages.\n"); } }
/** * Displays the main form for removing a gift * @return HTML output */ function displayForm() { global $wgUser, $wgOut, $wgUploadPath; $rel = new UserGifts($wgUser->getName()); $gift = $rel->getUserGift($this->gift_id); $user = Title::makeTitle(NS_USER, $gift['user_name_from']); $gift_image = '<img src="' . $wgUploadPath . '/awards/' . Gifts::getGiftImage($gift['gift_id'], 'l') . '" border="0" alt="gift" />'; $output = $wgOut->setPageTitle(wfMsg('g-remove-title', $gift['name'])); $output .= '<div class="back-links"> <a href="' . $wgUser->getUserPage()->escapeFullURL() . '">' . wfMsg('g-back-link', $gift['user_name_to']) . '</a> </div> <form action="" method="post" enctype="multipart/form-data" name="form1"> <div class="g-remove-message">' . wfMsg('g-remove-message', $gift['name']) . '</div> <div class="g-container">' . $gift_image . '<div class="g-name">' . $gift['name'] . '</div> <div class="g-from">' . wfMsg('g-from', $user->escapeFullURL(), $gift['user_name_from']) . '</div>'; if ($gift['message']) { $output .= '<div class="g-user-message">' . $gift['message'] . '</div>'; } $output .= '</div> <div class="cleared"></div> <div class="g-buttons"> <input type="hidden" name="user" value="' . addslashes($gift['user_name_from']) . '"> <input type="button" class="site-button" value="' . wfMsg('g-remove') . '" size="20" onclick="document.form1.submit()" /> <input type="button" class="site-button" value="' . wfMsg('g-cancel') . '" size="20" onclick="history.go(-1)" /> </div> </form>'; return $output; }
/** * @param $skin Skin * @param $result * @return String */ function formatResult($skin, $result) { $fromObj = Title::makeTitle($result->namespace, $result->title); if (isset($result->rd_title)) { $toObj = Title::makeTitle($result->rd_namespace, $result->rd_title); } else { $blinks = $fromObj->getBrokenLinksFrom(); # TODO: check for redirect, not for links if ($blinks) { $toObj = $blinks[0]; } else { $toObj = false; } } // $toObj may very easily be false if the $result list is cached if (!is_object($toObj)) { return '<del>' . Linker::link($fromObj) . '</del>'; } $from = Linker::linkKnown($fromObj, null, array(), array('redirect' => 'no')); $links = array(); $links[] = Linker::linkKnown($fromObj, $this->msg('brokenredirects-edit')->escaped(), array(), array('action' => 'edit')); $to = Linker::link($toObj, null, array(), array(), array('broken')); $arr = $this->getLanguage()->getArrow(); $out = $from . $this->msg('word-separator')->escaped(); if ($this->getUser()->isAllowed('delete')) { $links[] = Linker::linkKnown($fromObj, $this->msg('brokenredirects-delete')->escaped(), array(), array('action' => 'delete')); } $out .= $this->msg('parentheses')->rawParams($this->getLanguage()->pipeList($links))->escaped(); $out .= " {$arr} {$to}"; return $out; }
/** * Create a LocalFile from a title * Do not call this except from inside a repo class. * * @param $row * @param $repo * * @return LocalFile */ static function newFromRow($row, $repo) { $title = Title::makeTitle(NS_FILE, $row->img_name); $file = new self($title, $repo); $file->loadFromRow($row); return $file; }
static function newFromRow($row, $repo) { $title = Title::makeTitle(NS_FILE, $row->oi_name); $file = new self($title, $repo, null, $row->oi_archive_name); $file->loadFromRow($row, 'oi_'); return $file; }
/** * Fetch a dummy title to set on Messages * @return Title */ protected function getDummyTitle() { if (self::$dummyTitle === null) { self::$dummyTitle = Title::makeTitle(NS_SPECIAL, 'Badtitle/' . __METHOD__); } return self::$dummyTitle; }
public function execute($subpage) { global $wgUser, $wgOut, $wgRequest; if ($wgUser->isBlocked()) { throw new UserBlockedError($this->getUser()->mBlock); } if (wfReadOnly()) { $wgOut->readOnlyPage(); return; } if (!$wgUser->isAllowed('tagsreport')) { $this->displayRestrictionError(); return; } /** * initial output */ $this->mTitle = Title::makeTitle(NS_SPECIAL, 'TagsReport'); $wgOut->setPageTitle(wfMsg('tagsreporttitle')); $wgOut->setRobotpolicy('noindex,nofollow'); $wgOut->setArticleRelated(false); $this->mTag = $wgRequest->getVal('target'); /** * show form */ $this->showForm(); $this->showArticleList(); }
function formatResult($skin, $result) { $title = Title::makeTitle(NS_TEMPLATE, $result->title); $pageLink = $skin->linkKnown($title, null, array(), array('redirect' => 'no')); $wlhLink = $skin->linkKnown(SpecialPage::getTitleFor('Whatlinkshere'), wfMsgHtml('unusedtemplateswlh'), array(), array('target' => $title->getPrefixedText())); return wfSpecialList($pageLink, $wlhLink); }
/** * Return a clause with the list of disambiguation templates. * This function was copied verbatim from specials/SpecialDisambiguations.php */ function disambiguation_templates( $dbr ) { $dMsgText = wfMsgForContent('disambiguationspage'); $linkBatch = new LinkBatch; # If the text can be treated as a title, use it verbatim. # Otherwise, pull the titles from the links table $dp = Title::newFromText($dMsgText); if( $dp ) { if($dp->getNamespace() != NS_TEMPLATE) { # FIXME we assume the disambiguation message is a template but # the page can potentially be from another namespace :/ wfDebug("Mediawiki:disambiguationspage message does not refer to a template!\n"); } $linkBatch->addObj( $dp ); } else { # Get all the templates linked from the Mediawiki:Disambiguationspage $disPageObj = Title::makeTitleSafe( NS_MEDIAWIKI, 'disambiguationspage' ); $res = $dbr->select( array('pagelinks', 'page'), 'pl_title', array('page_id = pl_from', 'pl_namespace' => NS_TEMPLATE, 'page_namespace' => $disPageObj->getNamespace(), 'page_title' => $disPageObj->getDBkey()), __METHOD__ ); foreach ( $res as $row ) { $linkBatch->addObj( Title::makeTitle( NS_TEMPLATE, $row->pl_title )); } } return $linkBatch->constructSet( 'tl', $dbr ); }
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"; }
/** * Do the query and add the results to a given LinkCache object * Return an array mapping PDBK to ID */ function executeInto(&$cache) { $fname = 'LinkBatch::executeInto'; wfProfileIn($fname); // Do query $res = $this->doQuery(); if (!$res) { wfProfileOut($fname); return array(); } // For each returned entry, add it to the list of good links, and remove it from $remaining $ids = array(); $remaining = $this->data; while ($row = $res->fetchObject()) { $title = Title::makeTitle($row->page_namespace, $row->page_title); $cache->addGoodLinkObj($row->page_id, $title); $ids[$title->getPrefixedDBkey()] = $row->page_id; unset($remaining[$row->page_namespace][$row->page_title]); } $res->free(); // The remaining links in $data are bad links, register them as such foreach ($remaining as $ns => $dbkeys) { foreach ($dbkeys as $dbkey => $nothing) { $title = Title::makeTitle($ns, $dbkey); $cache->addBadLinkObj($title); $ids[$title->getPrefixedDBkey()] = 0; } } wfProfileOut($fname); return $ids; }
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 execute() { require_once 'includes/PageHistory.php'; global $wgOut, $wgTitle; if ($_GET["pid"] != "") { $dbr =& wfGetDB(DB_SLAVE); $sql = "SELECT page_namespace,page_title FROM {$dbr->tableName('page')} WHERE page_id = " . $_GET["pid"]; $res = $dbr->query($sql); while ($row = $dbr->fetchObject($res)) { $title = Title::makeTitle($row->page_namespace, $row->page_title); $title2 = $title->getText(); } } if ($title2 != "") { $wgTitle = Title::newFromURL($title2); $wgArticle = new Article($wgTitle); $wgOut->setSquidMaxage($wgSquidMaxage); $h = new PageHistory($wgArticle); $h->History(); } // This line removes the navigation and everything else from the // page, if you don't set it, you get what looks like a regular wiki // page, with the body you defined above. $wgOut->setArticleBodyOnly(true); }