当前位置: 首页>>代码示例>>PHP>>正文


PHP WikiFactory::setVarById方法代码示例

本文整理汇总了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__);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:21,代码来源:WDACReviewHelper.class.php

示例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;
         }
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:22,代码来源:identifyTopWamWikis.php

示例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;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:35,代码来源:CreateWiki.php

示例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";
}
开发者ID:yusufchang,项目名称:app,代码行数:31,代码来源:csv2wf.php


注:本文中的WikiFactory::setVarById方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。