本文整理汇总了PHP中WikiFactory::getVarByName方法的典型用法代码示例。如果您正苦于以下问题:PHP WikiFactory::getVarByName方法的具体用法?PHP WikiFactory::getVarByName怎么用?PHP WikiFactory::getVarByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WikiFactory
的用法示例。
在下文中一共展示了WikiFactory::getVarByName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: maintenance
public function maintenance($server)
{
global $wgCityId, $IP;
$cmd = sprintf("SERVER_ID={$wgCityId} php {$IP}/maintenance/update.php --server={$server} --quick --nopurge");
$output = wfShellExec($cmd, $exitStatus);
$this->info('run update.php', ['exitStatus' => $exitStatus, 'output' => $output]);
$cmd = sprintf("SERVER_ID={$wgCityId} php {$IP}/maintenance/initStats.php --server={$server}");
$output = wfShellExec($cmd, $exitStatus);
$this->info('run initStats.php', ['exitStatus' => $exitStatus, 'output' => $output]);
$cmd = sprintf("SERVER_ID={$wgCityId} php {$IP}/maintenance/refreshLinks.php --server={$server} --new-only");
$output = wfShellExec($cmd, $exitStatus);
$this->info('run refreshLinks.php', ['exitStatus' => $exitStatus, 'output' => $output]);
$this->info("Remove edit lock");
$variable = \WikiFactory::getVarByName('wgReadOnly', $wgCityId);
if (isset($variable->cv_variable_id)) {
\WikiFactory::removeVarById($variable->cv_variable_id, $wgCityId);
\WikiFactory::clearCache($wgCityId);
}
$dbname = \WikiFactory::IDtoDB($wgCityId);
$founder = $this->founder->getId();
$cmd = sprintf("perl /usr/wikia/backend/bin/scribe/events_local_users.pl --usedb={$dbname} --user={$founder} ");
$output = wfShellExec($cmd, $exitStatus);
$this->info('run events_local_users.pl', ['exitStatus' => $exitStatus, 'output' => $output]);
$wgMemc = wfGetMainCache();
$wgMemc->delete(\WikiFactory::getVarsKey($wgCityId));
return true;
}
示例2: getWikisList
public function getWikisList($limit = null, $batch = 1)
{
wfProfileIn(__METHOD__);
$cacheKey = $this->generateCacheKey(__METHOD__);
$games = $this->loadFromCache($cacheKey);
if (empty($games)) {
$games = array();
$wikiFactoryRecommendVar = WikiFactory::getVarByName(self::WF_WIKI_RECOMMEND_VAR, null);
if (!empty($wikiFactoryRecommendVar)) {
$recommendedIds = WikiFactory::getCityIDsFromVarValue($wikiFactoryRecommendVar->cv_variable_id, true, '=');
foreach ($recommendedIds as $wikiId) {
$wikiName = WikiFactory::getVarValueByName('wgSitename', $wikiId);
$wikiGames = WikiFactory::getVarValueByName('wgWikiTopics', $wikiId);
$wikiDomain = str_replace('http://', '', WikiFactory::getVarValueByName('wgServer', $wikiId));
$wikiThemeSettings = WikiFactory::getVarValueByName('wgOasisThemeSettings', $wikiId);
$wordmarkUrl = $wikiThemeSettings['wordmark-image-url'];
$wordmarkType = $wikiThemeSettings['wordmark-type'];
//$wikiLogo = WikiFactory::getVarValueByName( "wgLogo", $wikiId );
$games[] = array('name' => !empty($wikiThemeSettings['wordmark-text']) ? $wikiThemeSettings['wordmark-text'] : $wikiName, 'games' => !empty($wikiGames) ? $wikiGames : '', 'color' => !empty($wikiThemeSettings['wordmark-color']) ? $wikiThemeSettings['wordmark-color'] : '#0049C6', 'backgroundColor' => !empty($wikiThemeSettings['color-page']) ? $wikiThemeSettings['color-page'] : '#FFFFFF', 'domain' => $wikiDomain, 'wordmarkUrl' => $wordmarkType == 'graphic' && !empty($wordmarkUrl) ? $wordmarkUrl : '');
}
} else {
wfProfileOut(__METHOD__);
throw new WikiaException('WikiFactory variable \'' . self::WF_WIKI_RECOMMEND_VAR . '\' not found');
}
$this->storeInCache($cacheKey, $games);
}
$ret = wfPaginateArray($games, $limit, $batch);
wfProfileOut(__METHOD__);
return $ret;
}
示例3: initializeBlacklist
/**
* Look for videos that are blacklisted in the wgVideosModuleBlackList variable on community central
*/
protected function initializeBlacklist()
{
$communityBlacklist = \WikiFactory::getVarByName("wgVideosModuleBlackList", \WikiFactory::COMMUNITY_CENTRAL);
if (is_object($communityBlacklist) && !empty($communityBlacklist->cv_value)) {
$this->blacklist = unserialize($communityBlacklist->cv_value);
}
}
示例4: axWFactoryGetVariable
/**
* axWFactoryGetVariable
*
* Method for getting variable form via AJAX request.
*
* @author Krzysztof Krzyżaniak <eloy@wikia.com>
* @access public
*
* @return HTML code with variable data
*/
function axWFactoryGetVariable()
{
global $wgRequest, $wgUser, $wgOut, $wgPreWikiFactoryValues;
if (!$wgUser->isAllowed('wikifactory')) {
$wgOut->readOnlyPage();
#--- FIXME: later change to something reasonable
return;
}
$cv_id = $wgRequest->getVal("varid");
$city_id = $wgRequest->getVal("wiki");
$variable = WikiFactory::getVarById($cv_id, $city_id);
// BugId:3054
if (empty($variable)) {
return json_encode(array('error' => true, 'message' => 'No such variable.'));
}
$related = array();
$r_pages = array();
if (preg_match("/Related variables:(.*)\$/", $variable->cv_description, $matches)) {
$names = preg_split("/[\\s,;.()]+/", $matches[1], null, PREG_SPLIT_NO_EMPTY);
foreach ($names as $name) {
$rel_var = WikiFactory::getVarByName($name, $city_id);
if (!empty($rel_var)) {
$related[] = $rel_var;
} else {
if (preg_match("/^MediaWiki:.*\$/", $name, $matches2)) {
$r_pages[] = array("url" => GlobalTitle::newFromText($name, 0, $city_id)->getFullURL());
}
}
}
}
$oTmpl = new EasyTemplate(dirname(__FILE__) . "/templates/");
$oTmpl->set_vars(array("cityid" => $city_id, "variable" => $variable, "groups" => WikiFactory::getGroups(), "accesslevels" => WikiFactory::$levels, "related" => $related, "related_pages" => $r_pages, "preWFValues" => $wgPreWikiFactoryValues, 'wikiFactoryUrl' => Title::makeTitle(NS_SPECIAL, 'WikiFactory')->getFullUrl()));
return json_encode(array("div-body" => $oTmpl->render("variable"), "div-name" => "wk-variable-form"));
}
示例5: getWikisList
public function getWikisList()
{
$this->wf->profileIn(__METHOD__);
$cacheKey = $this->getGlobalCacheKey(self::MEMCACHE_GLOBAL_KEY_TOKEN);
$ret = $this->loadFromCache($cacheKey);
if (empty($ret)) {
$ret = array();
$wikiFactoryRecommendVar = WikiFactory::getVarByName(self::WF_SWITCH_NAME, null);
if (!empty($wikiFactoryRecommendVar)) {
$gamesIds = WikiFactory::getCityIDsFromVarValue($wikiFactoryRecommendVar->cv_variable_id, true, '=');
foreach ($gamesIds as $wikiId) {
$game = $this->getSettings($wikiId);
if (!empty($game)) {
$wikiName = WikiFactory::getVarValueByName('wgSitename', $wikiId);
$wikiThemeSettings = WikiFactory::getVarValueByName('wgOasisThemeSettings', $wikiId);
$game->name = !empty($wikiThemeSettings['wordmark-text']) ? $wikiThemeSettings['wordmark-text'] : $wikiName;
$game->id = WikiFactory::IDtoDB($wikiId);
$game->domain = str_replace('http://', '', WikiFactory::getVarValueByName('wgServer', $wikiId));
$ret[$game->id] = $game;
}
}
} else {
$this->wf->profileOut(__METHOD__);
throw new WikiaException('WikiFactory variable \'' . self::WF_SWITCH_NAME . '\' not found');
}
$this->storeInCache($cacheKey, $ret);
}
$this->app->wf->profileOut(__METHOD__);
return $ret;
}
示例6: getWfWikiTopics
protected function getWfWikiTopics($wikiId)
{
$topics = unserialize(WikiFactory::getVarByName(self::WF_VARIABLE_NAME, $wikiId)->cv_value);
if (!is_array($topics) || $topics == false || empty($topics)) {
$topics = array();
}
return $topics;
}
示例7: isVESet
function isVESet($id)
{
$out = WikiFactory::getVarByName('wgEnableVisualEditorExt', $id);
if (!is_object($out) || empty($out->cv_value)) {
return false;
} else {
return true;
}
}
示例8: getBrokenThemeSettings
function getBrokenThemeSettings($id)
{
$themeSettings = WikiFactory::getVarByName('wgOasisThemeSettings', $id);
if (!is_object($themeSettings) || empty($themeSettings->cv_value)) {
return null;
}
$themeSettingsArray = unserialize($themeSettings->cv_value);
$backgroundImage = $themeSettingsArray['background-image'];
return getType($backgroundImage) !== 'string' || $backgroundImage === 'false' ? $themeSettingsArray : null;
}
示例9: loadData
public static function loadData($forceRefresh = false, $forceLanguage = null)
{
global $wgMemc, $wgStatsDB, $wgContLang, $wgExternalSharedDB, $wgStatsDBEnabled;
wfProfileIn(__METHOD__);
self::$mLanguage = !empty($forceLanguage) ? $forceLanguage : $wgContLang->getCode();
$cacheKey = self::CACHE_KEY_TOKEN . ':' . strtoupper(self::$mLanguage);
self::$mData = $wgMemc->get($cacheKey);
if (empty(self::$mData) || $forceRefresh) {
self::$mData = array();
$wikisIDs = array();
// get all the active wikis selected by the sales team
$wikiFactoryRecommended = WikiFactory::getVarByName(self::WF_VAR_NAME, null);
self::$mData['recommended'] = array();
if (!empty($wikiFactoryRecommended) && !empty($wikiFactoryRecommended->cv_variable_id)) {
$dbr = WikiFactory::db(DB_SLAVE);
$res = $dbr->select(array('city_list', 'city_variables'), 'city_id', array('city_id = cv_city_id', 'city_public' => 1, 'city_lang' => self::$mLanguage, 'cv_variable_id' => $wikiFactoryRecommended->cv_variable_id, 'cv_value' => serialize(true)));
while ($row = $dbr->fetchObject($res)) {
self::$mData['recommended'][] = $row->city_id;
}
$dbr->freeResult($res);
}
$counter = 0;
self::$mData['hubs'] = array();
if (!empty($wgStatsDBEnabled)) {
$langs = array(self::$mLanguage);
$wikis = DataMartService::getTopWikisByPageviews(DataMartService::PERIOD_ID_MONTHLY, 200, $langs, null, 1);
$minPageViews = isset(self::$pageviewsLimits[self::$mLanguage]) ? self::$pageviewsLimits[self::$mLanguage] : self::$pageviewsLimits['default'];
foreach ($wikis as $wikiID => $pvCount) {
if ($pvCount >= $minPageViews) {
$hub = WikiFactoryHub::getInstance();
$cat_id = $hub->getCategoryId($wikiID);
if (!$cat_id) {
continue;
}
if (!isset(self::$mData['hubs'][$cat_id])) {
self::$mData['hubs'][$cat_id] = array();
}
self::$mData['hubs'][$cat_id][] = $wikiID;
$counter++;
}
}
}
// removing entries from hubs that have a match in recommended
if (!empty(self::$mData['recommended']) && !empty(self::$mData['hubs'])) {
$counter = 0;
foreach (self::$mData['hubs'] as $hubID => &$item) {
$item = array_diff($item, self::$mData['recommended']);
$counter += count($item);
}
}
self::$mData['total'] = $counter;
$wgMemc->set($cacheKey, self::$mData, 3600 * self::CACHE_EXPIRY);
}
wfProfileOut(__METHOD__);
}
示例10: enableSpecialVideosExt
/**
* enable Special Video Ext
* @param integer $wikiId
*/
function enableSpecialVideosExt( $wikiId ) {
echo "Enable Special Videos Ext:\n";
$feature = 'wgEnableSpecialVideosExt';
$wgValue = WikiFactory::getVarByName( $feature, $wikiId );
if ( empty($wgValue) ) {
echo "\tError invalid params. \n";
} else {
WikiFactory::setVarByName( $feature, $wikiId, true, "enable Special Videos Ext for wikis that enable Related Videos" );
WikiFactory::clearCache( $wikiId );
echo "\tUpdate $feature from ".var_export( unserialize($wgValue->cv_value), true )." to true. \n";
}
}
示例11: getWamPageUrl
public function getWamPageUrl()
{
try {
$wikiId = (new WikiaCorporateModel())->getCorporateWikiIdByLang($this->langCode);
} catch (Exception $e) {
$wikiId = WikiService::WIKIAGLOBAL_CITY_ID;
}
$wamPageConfig = WikiFactory::getVarByName('wgWAMPageConfig', $wikiId)->cv_value;
$pageName = !empty($wamPageConfig['pageName']) ? $wamPageConfig['pageName'] : 'WAM';
$url = GlobalTitle::newFromText($pageName, NS_MAIN, $wikiId)->getFullURL();
return $url;
}
示例12: execute
/**
* execute
*
* entry point for TaskExecutor
*
* @access public
* @author eloy@wikia
*
* @param mixed $params default null - task data from wikia_tasks table
*
* @return boolean - status of operation
*/
public function execute($params = null)
{
global $IP, $wgWikiaLocalSettingsPath, $wgWikiaAdminSettingsPath, $wgExtensionMessagesFiles;
$this->mTaskID = $params->task_id;
$this->mParams = unserialize($params->task_arguments);
$city_id = $this->mParams["city_id"];
$command = $this->mParams["command"];
$type = $this->mParams["type"];
$server = $this->mParams["server"];
$this->addLog("wgServer for this site is: {$server}");
if ($city_id && $command) {
$this->mWikiId = $city_id;
/**
* execute maintenance script
*/
$cmd = sprintf("SERVER_ID={$city_id} php {$IP}/{$command} --server={$server} --conf {$wgWikiaLocalSettingsPath} --aconf {$wgWikiaAdminSettingsPath}");
$this->addLog("Running {$cmd}");
$retval = wfShellExec($cmd, $status);
$this->addLog($retval);
if ($type == "ACWLocal" || $type == "CWLocal") {
$cmd = sprintf("SERVER_ID={$city_id} php {$IP}/maintenance/update.php --server={$server} --quick --nopurge --conf {$wgWikiaLocalSettingsPath} --aconf {$wgWikiaAdminSettingsPath}");
$this->addLog("Running {$cmd}");
$retval = wfShellExec($cmd, $status);
$this->addLog($retval);
$cmd = sprintf("SERVER_ID={$city_id} php {$IP}/maintenance/initStats.php --server={$server} --conf {$wgWikiaLocalSettingsPath} --aconf {$wgWikiaAdminSettingsPath}");
$this->addLog("Running {$cmd}");
$retval = wfShellExec($cmd, $status);
$this->addLog($retval);
$cmd = sprintf("SERVER_ID={$city_id} php {$IP}/maintenance/refreshLinks.php --server={$server} --new-only --conf {$wgWikiaLocalSettingsPath} --aconf {$wgWikiaAdminSettingsPath}");
$this->addLog("Running {$cmd}");
$retval = wfShellExec($cmd, $status);
$this->addLog($retval);
$this->addLog("Remove edit lock");
$oVariable = WikiFactory::getVarByName('wgReadOnly', $city_id);
if (isset($oVariable->cv_variable_id)) {
WikiFactory::removeVarById($oVariable->cv_variable_id, $city_id);
WikiFactory::clearCache($city_id);
}
}
$dbname = WikiFactory::IDtoDB($city_id);
$cmd = sprintf("perl /usr/wikia/backend/bin/scribe/events_local_users.pl --usedb={$dbname} ");
$this->addLog("Running {$cmd}");
$retval = wfShellExec($cmd, $status);
$this->addLog($retval);
/**
* once again clear cache at the very end
*/
$wgMemc = wfGetMainCache();
$wgMemc->delete(WikiFactory::getVarsKey($city_id));
}
return true;
}
示例13: customSpecialStatistics
/**
* @access public
* @static
*/
public static function customSpecialStatistics(&$specialpage, &$text)
{
global $wgOut, $wgDBname, $wgLang, $wgRequest, $wgTitle, $wgUser, $wgCityId, $wgHTTPProxy;
$tmpl = new EasyTemplate(dirname(__FILE__) . "/templates/");
/**
* get last dump request timestamp
*/
$wiki = WikiFactory::getWikiByID($wgCityId);
if (strtotime(wfTimestampNow()) - strtotime($wiki->city_lastdump_timestamp) > 7 * 24 * 60 * 60) {
$tmpl->set("available", true);
} else {
$tmpl->set("available", false);
}
$tmpl->set("title", $wgTitle);
$tmpl->set("isAnon", $wgUser->isAnon());
$dumpInfo = self::getLatestDumpInfo($wgCityId);
$sTimestamp = $dumpInfo ? $dumpInfo['timestamp'] : false;
$sDumpExtension = self::getExtensionFromCompression($dumpInfo ? $dumpInfo['compression'] : false);
$tmpl->set('nolink', false);
if (empty($sTimestamp)) {
$sTimestamp = wfMessage('dump-database-last-unknown')->escaped();
$tmpl->set('nolink', true);
}
$tmpl->set("curr", array("url" => 'http://s3.amazonaws.com/wikia_xml_dumps/' . self::getPath("{$wgDBname}_pages_current.xml{$sDumpExtension}"), "timestamp" => $sTimestamp));
$tmpl->set("full", array("url" => 'http://s3.amazonaws.com/wikia_xml_dumps/' . self::getPath("{$wgDBname}_pages_full.xml{$sDumpExtension}"), "timestamp" => $sTimestamp));
// The Community Central's value of the wgDumpRequestBlacklist variable contains an array of users who are not allowed to request dumps with this special page.
$aDumpRequestBlacklist = (array) unserialize(WikiFactory::getVarByName('wgDumpRequestBlacklist', WikiFactory::COMMUNITY_CENTRAL)->cv_value);
$bIsAllowed = $wgUser->isAllowed('dumpsondemand') && !in_array($wgUser->getName(), $aDumpRequestBlacklist);
$tmpl->set('bIsAllowed', $bIsAllowed);
$text .= $tmpl->render("dod");
if ($wgRequest->wasPosted() && $bIsAllowed) {
self::queueDump($wgCityId);
wfDebug(__METHOD__, ": request for database dump was posted\n");
$text = Wikia::successbox(wfMsg("dump-database-request-requested")) . $text;
}
return true;
}
示例14: toggleFeature
/**
* @desc enable/disable feature
* @requestParam string enabled [true/false]
* @requestParam string feature (extension variable)
* @responseParam string result [OK/error]
* @responseParam string error (error message)
*/
public function toggleFeature()
{
$enabled = $this->getVal('enabled', null);
$feature = $this->getVal('feature', null);
// check user permission
if (!$this->wg->User->isAllowed('wikifeatures')) {
$this->setVal('result', 'error');
$this->setVal('error', $this->wf->Msg('wikifeatures-error-permission'));
return;
}
// check if feature given is actually something we allow setting
if (!in_array($feature, $this->wg->WikiFeatures['normal']) && !in_array($feature, $this->wg->WikiFeatures['labs'])) {
$this->setVal('result', 'error');
$this->setVal('error', $this->wf->Msg('wikifeatures-error-invalid-parameter'));
return;
}
// validate feature: valid value ($enabled and $feature), check if Feature exists ($wg_value)
$wg_value = WikiFactory::getVarByName($feature, $this->wg->CityId);
if ($enabled != 'true' && $enabled != 'false' || empty($feature) || empty($wg_value)) {
$this->setVal('result', 'error');
$this->setVal('error', $this->wf->Msg('wikifeatures-error-invalid-parameter'));
return;
}
$enabled = $enabled == 'true';
$logMsg = "set extension option: {$feature} = " . var_export($enabled, TRUE);
$log = WF::build('LogPage', array('wikifeatures'));
$log->addEntry('wikifeatures', SpecialPage::getTitleFor('WikiFeatures'), $logMsg, array());
WikiFactory::setVarByName($feature, $this->wg->CityId, $enabled, "WikiFeatures");
if ($feature == 'wgShowTopListsInCreatePage') {
WikiFactory::setVarByName('wgEnableTopListsExt', $this->wg->CityId, $enabled, "WikiFeatures");
}
// clear cache for active wikis
WikiFactory::clearCache($this->wg->CityId);
$this->wg->Memc->delete(WikiFeaturesHelper::getInstance()->getMemcKeyNumActiveWikis($feature));
$this->setVal('result', 'ok');
}
示例15: getWhitelistedWikisFromWF
protected function getWhitelistedWikisFromWF()
{
$this->wf->ProfileIn(__METHOD__);
$key = wfMemcKey(__CLASS__, __METHOD__);
$data = $this->wg->memc->get($key, null);
if (!empty($data)) {
$this->wf->ProfileOut(__METHOD__);
return $data;
}
$oVariable = WikiFactory::getVarByName('wgImageReviewWhitelisted', 177);
$fromWf = WikiFactory::getListOfWikisWithVar($oVariable->cv_variable_id, 'bool', '=', true);
$this->wg->memc->set($key, $fromWf, 60 * 10);
$this->wf->ProfileOut(__METHOD__);
return $fromWf;
}