本文整理汇总了PHP中wfWikiId函数的典型用法代码示例。如果您正苦于以下问题:PHP wfWikiId函数的具体用法?PHP wfWikiId怎么用?PHP wfWikiId使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wfWikiId函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute()
{
$conn = $this->getCirrusConnection();
foreach ($conn->getAllIndexTypes() as $index) {
$this->getResult()->addValue(array($index, 'page'), 'index', $conn->getIndex(wfWikiId(), $index)->getSettings()->get());
}
}
示例2: onAfterInsert
/**
* @param AbstractRevision $revision Revision object
* @param array $row Revision row
* @param array $metadata;
*/
public function onAfterInsert($revision, array $row, array $metadata)
{
global $wgRCFeeds;
// No action on imported revisions
if (isset($metadata['imported']) && $metadata['imported']) {
return;
}
$action = $revision->getChangeType();
$revisionId = $revision->getRevisionId()->getAlphadecimal();
$timestamp = $revision->getRevisionId()->getTimestamp();
/** @var Workflow $workflow */
$workflow = $metadata['workflow'];
$user = $revision->getUser();
if (!$this->isAllowed($revision, $action)) {
return;
}
$title = $this->getRcTitle($workflow, $revision->getChangeType());
$attribs = array('rc_namespace' => $title->getNamespace(), 'rc_title' => $title->getDBkey(), 'rc_user' => $row['rev_user_id'], 'rc_user_text' => $this->usernames->get(wfWikiId(), $row['rev_user_id'], $row['rev_user_ip']), 'rc_type' => RC_FLOW, 'rc_source' => self::SRC_FLOW, 'rc_minor' => 0, 'rc_bot' => 0, 'rc_patrolled' => $user->isAllowed('autopatrol') ? 1 : 0, 'rc_old_len' => $revision->getPreviousContentLength(), 'rc_new_len' => $revision->getContentLength(), 'rc_this_oldid' => 0, 'rc_last_oldid' => 0, 'rc_log_type' => null, 'rc_params' => serialize(array('flow-workflow-change' => array('action' => $action, 'revision_type' => get_class($revision), 'revision' => $revisionId, 'workflow' => $workflow->getId()->getAlphadecimal()))), 'rc_cur_id' => 0, 'rc_comment' => '', 'rc_timestamp' => $timestamp, 'rc_deleted' => 0);
$rc = $this->rcFactory->newFromRow((object) $attribs);
$rc->save(true);
// Insert into db
$feeds = $wgRCFeeds;
// Override the IRC formatter with our own formatter
foreach (array_keys($feeds) as $name) {
$feeds[$name]['original_formatter'] = $feeds[$name]['formatter'];
$feeds[$name]['formatter'] = $this->ircFormatter;
}
// pre-load the irc formatter which will be triggered via hook
$this->ircFormatter->associate($rc, array('revision' => $revision) + $metadata);
// run the feeds/irc/etc external notifications
$rc->notifyRCFeeds($feeds);
}
示例3: wfGlobalInterwikis
function wfGlobalInterwikis($prefix, &$iwData)
{
global $wgInterwikiCentralDB;
// docs/hooks.txt says: Return true without providing an interwiki to continue interwiki search.
if ($wgInterwikiCentralDB === null || $wgInterwikiCentralDB === wfWikiId()) {
// No global set or this is global, nothing to add
return true;
}
if (!Language::fetchLanguageName($prefix)) {
// Check if prefix exists locally and skip
foreach (Interwiki::getAllPrefixes(null) as $id => $localPrefixInfo) {
if ($prefix === $localPrefixInfo['iw_prefix']) {
return true;
}
}
$dbr = wfGetDB(DB_SLAVE, array(), $wgInterwikiCentralDB);
$res = $dbr->selectRow('interwiki', '*', array('iw_prefix' => $prefix), __METHOD__);
if (!$res) {
return true;
}
// Excplicitly make this an array since it's expected to be one
$iwData = (array) $res;
// At this point, we can safely return false because we know that we have something
return false;
}
return true;
}
示例4: setUp
protected function setUp()
{
global $wgFileBackends;
parent::setUp();
$uniqueId = time() . '-' . mt_rand();
$tmpPrefix = wfTempDir() . '/filebackend-unittest-' . $uniqueId;
if ($this->getCliArg('use-filebackend=')) {
if (self::$backendToUse) {
$this->singleBackend = self::$backendToUse;
} else {
$name = $this->getCliArg('use-filebackend=');
$useConfig = array();
foreach ($wgFileBackends as $conf) {
if ($conf['name'] == $name) {
$useConfig = $conf;
break;
}
}
$useConfig['name'] = 'localtesting';
// swap name
$useConfig['shardViaHashLevels'] = array('unittest-cont1' => array('levels' => 1, 'base' => 16, 'repeat' => 1));
$class = $useConfig['class'];
self::$backendToUse = new $class($useConfig);
$this->singleBackend = self::$backendToUse;
}
} else {
$this->singleBackend = new FSFileBackend(array('name' => 'localtesting', 'lockManager' => 'fsLockManager', 'wikiId' => wfWikiID() . $uniqueId, 'containerPaths' => array('unittest-cont1' => "{$tmpPrefix}-localtesting-cont1", 'unittest-cont2' => "{$tmpPrefix}-localtesting-cont2")));
}
$this->multiBackend = new FileBackendMultiWrite(array('name' => 'localtesting', 'lockManager' => 'fsLockManager', 'parallelize' => 'implicit', 'wikiId' => wfWikiId() . $uniqueId, 'backends' => array(array('name' => 'localmultitesting1', 'class' => 'FSFileBackend', 'lockManager' => 'nullLockManager', 'containerPaths' => array('unittest-cont1' => "{$tmpPrefix}-localtestingmulti1-cont1", 'unittest-cont2' => "{$tmpPrefix}-localtestingmulti1-cont2"), 'isMultiMaster' => false), array('name' => 'localmultitesting2', 'class' => 'FSFileBackend', 'lockManager' => 'nullLockManager', 'containerPaths' => array('unittest-cont1' => "{$tmpPrefix}-localtestingmulti2-cont1", 'unittest-cont2' => "{$tmpPrefix}-localtestingmulti2-cont2"), 'isMultiMaster' => true))));
$this->filesToPrune = array();
}
示例5: execute
public function execute()
{
$posFile = $this->getOption('p', 'searchUpdate.' . wfWikiId() . '.pos');
$end = $this->getOption('e', wfTimestampNow());
if ($this->hasOption('s')) {
$start = $this->getOption('s');
} elseif (is_readable('searchUpdate.pos')) {
# B/c to the old position file name which was hardcoded
# We can safely delete the file when we're done though.
$start = file_get_contents('searchUpdate.pos');
unlink('searchUpdate.pos');
} elseif (is_readable($posFile)) {
$start = file_get_contents($posFile);
} else {
$start = wfTimestamp(TS_MW, time() - 86400);
}
$lockTime = $this->getOption('l', 20);
$this->doUpdateSearchIndex($start, $end, $lockTime);
if (is_writable(dirname(realpath($posFile)))) {
$file = fopen($posFile, 'w');
if ($file !== false) {
fwrite($file, $end);
fclose($file);
} else {
$this->error("*** Couldn't write to the {$posFile}!\n");
}
} else {
$this->error("*** Couldn't write to the {$posFile}!\n");
}
}
示例6: getMocks
protected function getMocks()
{
$dbMock = $this->getMockBuilder('DatabaseMysql')->disableOriginalConstructor()->getMock();
$backendMock = $this->getMock('FSFileBackend', array(), array(array('name' => $this->backendName, 'wikiId' => wfWikiId())));
$wrapperMock = $this->getMock('FileBackendDBRepoWrapper', array('getDB'), array(array('backend' => $backendMock, 'repoName' => $this->repoName, 'dbHandleFactory' => null)));
$wrapperMock->expects($this->any())->method('getDB')->will($this->returnValue($dbMock));
return array($dbMock, $backendMock, $wrapperMock);
}
示例7: setUp
protected function setUp()
{
parent::setUp();
$this->filePath = __DIR__ . '/../../data/media';
$this->backend = new FSFileBackend(array('name' => 'localtesting', 'wikiId' => wfWikiId(), 'containerPaths' => array('data' => $this->filePath)));
$this->repo = new FSRepo(array('name' => 'temp', 'url' => 'http://localhost/thumbtest', 'backend' => $this->backend));
$this->handler = new PNGHandler();
}
示例8: setUp
protected function setUp()
{
parent::setUp();
$this->checkPHPExtension('exif');
$filePath = __DIR__ . '/../../data/media';
$this->backend = new FSFileBackend(array('name' => 'localtesting', 'wikiId' => wfWikiId(), 'containerPaths' => array('data' => $filePath)));
$this->repo = new FSRepo(array('name' => 'temp', 'url' => 'http://localhost/thumbtest', 'backend' => $this->backend));
$this->setMwGlobals('wgShowEXIF', true);
}
示例9: execute
public function execute()
{
$conn = $this->getCirrusConnection();
foreach ($conn->getAllIndexTypes() as $index) {
$mapping = $conn->getPageType(wfWikiId(), $index)->getMapping();
$this->getResult()->addValue(null, $index, $mapping);
$this->getResult()->addPreserveKeysList(array($index, 'page'), '_all');
}
}
示例10: setUp
protected function setUp()
{
parent::setUp();
$this->checkPHPExtension('exif');
$this->handler = new BitmapHandler();
$filePath = __DIR__ . '/../../data/media';
$tmpDir = $this->getNewTempDirectory();
$this->repo = new FSRepo(array('name' => 'temp', 'url' => 'http://localhost/thumbtest', 'backend' => new FSFileBackend(array('name' => 'localtesting', 'wikiId' => wfWikiId(), 'containerPaths' => array('temp-thumb' => $tmpDir, 'data' => $filePath)))));
$this->setMwGlobals(array('wgShowEXIF' => true, 'wgEnableAutoRotation' => true));
}
示例11: __construct
/**
* @param UserNameBatch $batch
* @param array $keys key - a list of keys from storage that contain user ids, value - the wiki for the user id lookup, default to $wiki if null
* @param string|null $wiki The wikiid to use when $wikiKey is null. If both are null wfWikiId() is used
*/
public function __construct(UserNameBatch $batch, array $keys, $wiki = null)
{
$this->batch = $batch;
$this->keys = $keys;
if ($wiki === null) {
$this->wiki = wfWikiId();
} else {
$this->wiki = $wiki;
}
}
示例12: makeTitle
/**
* Many loaded references typically point to the same Title, cache those instead
* of generating a bunch of duplicate title classes.
*/
public static function makeTitle($namespace, $title)
{
try {
return Workflow::getFromTitleCache(wfWikiId(), $namespace, $title);
} catch (InvalidInputException $e) {
// duplicate Title::makeTitleSafe which returns null on failure,
// but only for InvalidInputException
return null;
}
}
示例13: execute
public function execute()
{
global $wgGlobalUsageDatabase;
$dbr = wfGetDB(DB_SLAVE);
$dbw = wfGetDB(DB_MASTER, array(), $wgGlobalUsageDatabase);
$gu = new GlobalUsage(wfWikiId(), $dbw);
$lastPageId = intval($this->getOption('start-page', 0));
$lastIlTo = $this->getOption('start-image');
$limit = 500;
$maxlag = intval($this->getOption('maxlag', 5));
do {
$this->output("Querying links after (page_id, il_to) = ({$lastPageId}, {$lastIlTo})\n");
# Query all pages and any imagelinks associated with that
$quotedLastIlTo = $dbr->addQuotes($lastIlTo);
$res = $dbr->select(array('page', 'imagelinks', 'image'), array('page_id', 'page_namespace', 'page_title', 'il_to', 'img_name'), "(page_id = {$lastPageId} AND il_to > {$quotedLastIlTo})" . " OR page_id > {$lastPageId}", __METHOD__, array('ORDER BY' => $dbr->implicitOrderBy() ? 'page_id' : 'page_id, il_to', 'LIMIT' => $limit), array('imagelinks' => array('LEFT JOIN', 'page_id = il_from'), 'image' => array('LEFT JOIN', 'il_to = img_name')));
# Build up a tree per pages
$pages = array();
$lastRow = null;
foreach ($res as $row) {
if (!isset($pages[$row->page_id])) {
$pages[$row->page_id] = array();
}
# Add the imagelinks entry to the pages array if the image
# does not exist locally
if (!is_null($row->il_to) && is_null($row->img_name)) {
$pages[$row->page_id][$row->il_to] = $row;
}
$lastRow = $row;
}
# Insert the imagelinks data to the global table
foreach ($pages as $pageId => $rows) {
# Delete all original links if this page is not a continuation
# of last iteration.
if ($pageId != $lastPageId) {
$gu->deleteLinksFromPage($pageId);
}
if ($rows) {
$title = Title::newFromRow(reset($rows));
$images = array_keys($rows);
# Since we have a pretty accurate page_id, don't specify
# Title::GAID_FOR_UPDATE
$gu->insertLinks($title, $images, 0);
}
}
if ($lastRow) {
# We've processed some rows in this iteration, so save
# continuation variables
$lastPageId = $lastRow->page_id;
$lastIlTo = $lastRow->il_to;
# Be nice to the database
$dbw->commit();
wfWaitForSlaves($maxlag, $wgGlobalUsageDatabase);
}
} while (!is_null($lastRow));
}
示例14: processParam
protected function processParam($event, $param, $message, $user)
{
$extra = $event->getExtra();
if ($param === 'subject') {
if (isset($extra['topic-title']) && $extra['topic-title']) {
$this->processParamEscaped($message, trim($extra['topic-title']));
} else {
$message->params('');
}
} elseif ($param === 'commentText') {
if (isset($extra['content']) && $extra['content']) {
// @todo assumes content is html, make explicit
$message->params(Utils::htmlToPlaintext($extra['content'], 200));
} else {
$message->params('');
}
} elseif ($param === 'post-permalink') {
$anchor = $this->getPostLinkAnchor($event, $user);
if ($anchor) {
$message->params($anchor->getFullUrl());
} else {
$message->params('');
}
} elseif ($param === 'topic-permalink') {
// link to individual new-topic
if (isset($extra['topic-workflow'])) {
$title = Workflow::getFromTitleCache(wfWikiId(), NS_TOPIC, $extra['topic-workflow']->getAlphadecimal());
} else {
$title = $event->getTitle();
}
$anchor = $this->getUrlGenerator()->workflowLink($title, $extra['topic-workflow']);
$anchor->query['fromnotif'] = 1;
$message->params($anchor->getFullUrl());
} elseif ($param === 'new-topics-permalink') {
// link to board sorted by newest topics
$anchor = $this->getUrlGenerator()->boardLink($event->getTitle(), 'newest');
$anchor->query['fromnotif'] = 1;
$message->params($anchor->getFullUrl());
} elseif ($param == 'flow-title') {
$title = $event->getTitle();
if ($title) {
$formatted = $this->formatTitle($title);
} else {
$formatted = $this->getMessage('echo-no-title')->text();
}
$message->params($formatted);
} elseif ($param == 'old-subject') {
$this->processParamEscaped($message, trim($extra['old-subject']));
} elseif ($param == 'new-subject') {
$this->processParamEscaped($message, trim($extra['new-subject']));
} else {
parent::processParam($event, $param, $message, $user);
}
}
示例15: check
private function check()
{
for ($pageId = $this->fromId; $pageId <= $this->toId; $pageId++) {
$status = $this->checker->check($pageId);
if (!$status->isOK()) {
$this->error($status->getWikiText(), 1);
}
if (($pageId - $this->fromId) % 100 === 0) {
$this->output(sprintf("[%20s]%10d/%d\n", wfWikiId(), $pageId, $this->toId));
}
}
}