本文整理汇总了PHP中WikiFactory::setVarById方法的典型用法代码示例。如果您正苦于以下问题:PHP WikiFactory::setVarById方法的具体用法?PHP WikiFactory::setVarById怎么用?PHP WikiFactory::setVarById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WikiFactory
的用法示例。
在下文中一共展示了WikiFactory::setVarById方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateWDACFlags
/**
* Update variables in WikiFactory
* @param array $cities List of wikis to update flags
* containg wikis IDs and values: True - is WDAC, False - is not WDAC
* Struncture of param
* $city = array( $cityId => $isDirectedAtCh )
*/
public function updateWDACFlags($cities)
{
wfProfileIn(__METHOD__);
foreach ($cities as $cityId => $isDirectedAtCh) {
if ($isDirectedAtCh == WDACReviewSpecialController::FLAG_APPROVE) {
WikiFactory::setVarById($this->byStaffVarId, $cityId, true, self::UPDATE_REASON);
WikiFactory::removeVarById($this->byFounderVarId, $cityId, self::UPDATE_REASON);
} elseif ($isDirectedAtCh == WDACReviewSpecialController::FLAG_DISAPPROVE) {
WikiFactory::setVarById($this->byStaffVarId, $cityId, false, self::UPDATE_REASON);
WikiFactory::removeVarById($this->byFounderVarId, $cityId, self::UPDATE_REASON);
}
}
wfProfileOut(__METHOD__);
}
示例2: execute
public function execute()
{
$wikiFactory = new WikiFactory();
$varId = $wikiFactory->getVarIdByName(self::VAR_TO_SET);
if ($varId === false) {
throw new ErrorException('No such variable: ' . self::VAR_TO_SET);
}
$newTopWikiIds = $this->getTopWamWikiIds(self::TOP_NUMBER_OF_WIKIS);
$oldTopWikiIds = array_keys($wikiFactory->getListOfWikisWithVar($varId, 'bool', '=', true));
foreach ($newTopWikiIds as $wikiId) {
if (array_search($wikiId, $oldTopWikiIds) === false) {
$wikiFactory->setVarById($varId, $wikiId, true, __METHOD__);
echo '+' . $wikiId . PHP_EOL;
}
}
foreach ($oldTopWikiIds as $wikiId) {
if (array_search($wikiId, $newTopWikiIds) === false) {
$wikiFactory->removeVarById($varId, $wikiId, __METHOD__);
echo '-' . $wikiId . PHP_EOL;
}
}
}
示例3: addCustomSettings
/**
* addCustomSettings
*
* @author tor@wikia-inc.com
* @param string $match
* @param array $settings
* @param string $type
*/
public function addCustomSettings($match, $settings, $type = 'unknown')
{
global $wgUser;
wfProfileIn(__METHOD__);
if ((!empty($match) || $type == 'universal') && isset($settings[$match]) && is_array($settings[$match])) {
wfDebugLog("createwiki", __METHOD__ . ": Found '{$match}' in {$type} settings array \n", true);
/**
* switching user for correct logging
*/
$oldUser = $wgUser;
$wgUser = User::newFromName('CreateWiki script');
foreach ($settings[$match] as $key => $value) {
$success = WikiFactory::setVarById($key, $this->mNewWiki->city_id, $value);
if ($success) {
wfDebugLog("createwiki", __METHOD__ . ": Successfully added setting for {$this->mNewWiki->city_id}: {$key} = {$value}\n", true);
} else {
wfDebugLog("createwiki", __METHOD__ . ": Failed to add setting for {$this->mNewWiki->city_id}: {$key} = {$value}\n", true);
}
}
$wgUser = $oldUser;
wfDebugLog("createwiki", __METHOD__ . ": Finished adding {$type} settings\n", true);
} else {
wfDebugLog("createwiki", __METHOD__ . ": '{$match}' not found in {$type} settings array. Skipping this step.\n", true);
}
wfProfileOut(__METHOD__);
return 1;
}
示例4: while
<?php
/**
* Import WF variables into CSV. The CSV must take the following format:
* wiki_id,variable_id,variable_value
* NOTE: variable value _must_ be serialized.
* @package MediaWiki
* @addtopackage maintenance
*/
require_once "../../../../maintenance/commandLine.inc";
$rowCounter = 0;
if (($handle = fopen($argv[0], 'r')) !== false) {
while (($row = fgetcsv($handle)) !== false) {
try {
$wikiId = $row[0];
$variableId = $row[1];
$variableValue = $row[2];
if (($valArray = unserialize($variableValue)) !== false) {
WikiFactory::setVarById($variableId, $wikiId, $valArray);
}
if ($rowCounter++ % 1000 == 0) {
echo "{$rowCounter}\n";
}
} catch (Exception $e) {
echo "Problem with {$wikiId}: {$e}\n";
}
}
fclose($handle);
} else {
echo "{$argv[0]} could not be opened";
}