本文整理汇总了PHP中WikiFactory::getWikiById方法的典型用法代码示例。如果您正苦于以下问题:PHP WikiFactory::getWikiById方法的具体用法?PHP WikiFactory::getWikiById怎么用?PHP WikiFactory::getWikiById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WikiFactory
的用法示例。
在下文中一共展示了WikiFactory::getWikiById方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
/**
* Called from maintenance script only. Send Digest emails for any founders with that preference enabled
*
* @param array $events Events is empty for this type
*/
public function process(array $events)
{
global $wgTitle;
wfProfileIn(__METHOD__);
$founderEmailObj = FounderEmails::getInstance();
$wgTitle = Title::newMainPage();
// Get list of founders with digest mode turned on
$cityList = $founderEmailObj->getFoundersWithPreference('founderemails-views-digest');
$wikiService = new WikiService();
// Gather daily page view stats for each wiki requesting views digest
foreach ($cityList as $cityID) {
$user_ids = $wikiService->getWikiAdminIds($cityID);
$foundingWiki = WikiFactory::getWikiById($cityID);
$page_url = GlobalTitle::newFromText('Createpage', NS_SPECIAL, $cityID)->getFullUrl(array('modal' => 'AddPage'));
$emailParams = array('$WIKINAME' => $foundingWiki->city_title, '$WIKIURL' => $foundingWiki->city_url, '$PAGEURL' => $page_url, '$UNIQUEVIEWS' => $founderEmailObj->getPageViews($cityID));
foreach ($user_ids as $user_id) {
$user = User::newFromId($user_id);
// skip if not enable
if (!$this->enabled($user, $cityID)) {
continue;
}
self::addParamsUser($cityID, $user->getName(), $emailParams);
$langCode = $user->getGlobalPreference('language');
$links = array('$WIKINAME' => $emailParams['$WIKIURL']);
$mailSubject = strtr(wfMsgExt('founderemails-email-views-digest-subject', array('content')), $emailParams);
$mailBody = strtr(wfMsgExt('founderemails-email-views-digest-body', array('content', 'parsemag'), $emailParams['$UNIQUEVIEWS']), $emailParams);
$mailBodyHTML = F::app()->renderView('FounderEmails', 'GeneralUpdate', array_merge($emailParams, array('language' => 'en', 'type' => 'views-digest')));
$mailBodyHTML = strtr($mailBodyHTML, FounderEmails::addLink($emailParams, $links));
$mailCategory = FounderEmailsEvent::CATEGORY_VIEWS_DIGEST . (!empty($langCode) && $langCode == 'en' ? 'EN' : 'INT');
$founderEmailObj->notifyFounder($user, $this, $mailSubject, $mailBody, $mailBodyHTML, $cityID, $mailCategory);
}
}
wfProfileOut(__METHOD__);
}
示例2: getWikiAdminIds
/**
* get list of wiki founder/admin/bureaucrat id
* Note: also called from maintenance script.
* @return array of $userIds
*/
public function getWikiAdminIds($wikiId = 0, $useMaster = false)
{
$this->wf->ProfileIn(__METHOD__);
$userIds = array();
if (empty($this->wg->FounderEmailsDebugUserId)) {
// get founder
$wikiId = empty($wikiId) ? $this->wg->CityId : $wikiId;
$wiki = WikiFactory::getWikiById($wikiId);
if (!empty($wiki) && $wiki->city_public == 1) {
$userIds[] = $wiki->city_founding_user;
// get admin and bureaucrat
if (empty($this->wg->EnableAnswers)) {
$memKey = $this->getMemKeyAdminIds($wikiId);
$adminIds = $this->wg->Memc->get($memKey);
if (!is_array($adminIds)) {
$dbname = $wiki->city_dbname;
$dbType = $useMaster ? DB_MASTER : DB_SLAVE;
$db = $this->wf->GetDB($dbType, array(), $dbname);
$result = $db->select('user_groups', 'distinct ug_user', array("ug_group in ('sysop','bureaucrat')"), __METHOD__);
$adminIds = array();
while ($row = $db->fetchObject($result)) {
$adminIds[] = $row->ug_user;
}
$db->freeResult($result);
$this->wg->Memc->set($memKey, $adminIds, 60 * 60 * 24);
}
$userIds = array_unique(array_merge($userIds, $adminIds));
}
}
} else {
$userIds[] = $this->wg->FounderEmailsDebugUserId;
}
$this->wf->ProfileOut(__METHOD__);
return $userIds;
}
示例3: WidgetFounderBadge
function WidgetFounderBadge($id, $params)
{
$output = "";
wfProfileIn(__METHOD__);
global $wgMemc;
$key = wfMemcKey("WidgetFounderBadge", "user");
$user = $wgMemc->get($key);
if (is_null($user)) {
global $wgCityId;
$user = WikiFactory::getWikiById($wgCityId)->city_founding_user;
$wgMemc->set($key, $user, 3600);
}
if (0 == $user) {
return wfMsgForContent("widget-founderbadge-notavailable");
}
$key = wfMemcKey("WidgetFounderBadge", "edits");
$edits = $wgMemc->get($key);
if (empty($edits)) {
$edits = AttributionCache::getInstance()->getUserEditPoints($user);
$wgMemc->set($key, $edits, 300);
}
$author = array("user_id" => $user, "user_name" => User::newFromId($user)->getName(), "edits" => $edits);
$output = Answer::getUserBadge($author);
wfProfileOut(__METHOD__);
return $output;
}
示例4: getWikiDataArray
/**
* Returns array with fields values from city_list for provided city_id that are required for ExactTarget updates
* @param int $iCityId
* @return array
*/
public function getWikiDataArray($iCityId)
{
/* Get wikidata from master */
$oWiki = \WikiFactory::getWikiById($iCityId, true);
$aWikiData = ['city_path' => $oWiki->city_path, 'city_dbname' => $oWiki->city_dbname, 'city_sitename' => $oWiki->city_sitename, 'city_url' => $oWiki->city_url, 'city_created' => $oWiki->city_created, 'city_founding_user' => $oWiki->city_founding_user, 'city_adult' => $oWiki->city_adult, 'city_public' => $oWiki->city_public, 'city_title' => $oWiki->city_title, 'city_founding_email' => $oWiki->city_founding_email, 'city_lang' => $oWiki->city_lang, 'city_special' => $oWiki->city_special, 'city_umbrella' => $oWiki->city_umbrella, 'city_ip' => $oWiki->city_ip, 'city_google_analytics' => $oWiki->city_google_analytics, 'city_google_search' => $oWiki->city_google_search, 'city_google_maps' => $oWiki->city_google_maps, 'city_indexed_rev' => $oWiki->city_indexed_rev, 'city_lastdump_timestamp' => $oWiki->city_lastdump_timestamp, 'city_factory_timestamp' => $oWiki->city_factory_timestamp, 'city_useshared' => $oWiki->city_useshared, 'ad_cat' => $oWiki->ad_cat, 'city_flags' => $oWiki->city_flags, 'city_cluster' => $oWiki->city_cluster, 'city_last_timestamp' => $oWiki->city_last_timestamp, 'city_founding_ip' => $oWiki->city_founding_ip, 'city_vertical' => $oWiki->city_vertical];
return $aWikiData;
}
示例5: getWikiFounder
/**
* get wiki founder
* @return User
*/
public function getWikiFounder($wikiId = 0)
{
global $wgCityId, $wgFounderEmailsDebugUserId;
$wikiId = !empty($wikiId) ? $wikiId : $wgCityId;
if (empty($wgFounderEmailsDebugUserId)) {
$wikiFounder = User::newFromId(WikiFactory::getWikiById($wikiId)->city_founding_user);
} else {
$wikiFounder = User::newFromId($wgFounderEmailsDebugUserId);
}
return $wikiFounder;
}
示例6: isFounder
/**
* Checks if user is the founder
*
* @return boolean
*
* @author Andrzej 'nAndy' Łukaszewski
*/
protected function isFounder()
{
wfProfileIn(__METHOD__);
$wiki = WikiFactory::getWikiById($this->app->wg->CityId);
if (intval($wiki->city_founding_user) === $this->user->GetId()) {
// mech: BugId 18248
$founder = $this->isUserInGroup(self::WIKIA_GROUP_SYSOP_NAME) || $this->isUserInGroup(self::WIKIA_GROUP_BUREAUCRAT_NAME);
wfProfileOut(__METHOD__);
return $founder;
}
wfProfileOut(__METHOD__);
return false;
}
示例7: formatRow
function formatRow($row)
{
$type = implode(", ", Phalanx::getTypeNames(isset($row->ps_blocker_hit) ? $row->ps_blocker_hit : $row->ps_blocker_type));
$username = $row->ps_blocked_user;
$timestamp = $this->app->wg->Lang->timeanddate($row->ps_timestamp);
$oWiki = WikiFactory::getWikiById($row->ps_wiki_id);
$url = isset($row->ps_referrer) ? $row->ps_referrer : "";
$url = empty($url) && isset($oWiki) ? $oWiki->city_url : $url;
$html = Html::openElement('li');
$html .= wfMsgExt('phalanx-stats-row', array('parseinline'), $type, $username, $url, $timestamp);
$html .= Html::closeElement('li');
return $html;
}
示例8: achievements
public static function achievements($cv_name, $city_id, $value)
{
wfProfileIn(__METHOD__);
if ($cv_name == 'wgEnableAchievementsExt' && $value == true) {
$wiki = WikiFactory::getWikiById($city_id);
// Force WikiFactory::getWikiById() to query DB_MASTER if needed.
if (!is_object($wiki)) {
$wiki = WikiFactory::getWikiById($city_id, true);
}
$user = User::newFromId($wiki->city_founding_user);
$user->load();
$achService = new AchAwardingService($city_id);
$achService->awardCustomNotInTrackBadge($user, BADGE_CREATOR);
}
wfProfileOut(__METHOD__);
return true;
}
示例9: process
public function process(array $events)
{
global $wgEnableAnswers, $wgCityId;
wfProfileIn(__METHOD__);
if ($this->isThresholdMet(count($events))) {
// get just one event when we have more... for now, just randomly
$eventData = $events[rand(0, count($events) - 1)];
$founderEmailObj = FounderEmails::getInstance();
$wikiService = F::build('WikiService');
$user_ids = $wikiService->getWikiAdminIds();
$foundingWiki = WikiFactory::getWikiById($wgCityId);
$emailParams = array('$EDITORNAME' => $eventData['data']['userName'], '$EDITORPAGEURL' => $eventData['data']['userPageUrl'], '$EDITORTALKPAGEURL' => $eventData['data']['userTalkPageUrl'], '$WIKINAME' => $foundingWiki->city_title, '$WIKIURL' => $foundingWiki->city_url);
$wikiType = !empty($wgEnableAnswers) ? '-answers' : '';
foreach ($user_ids as $user_id) {
$user = User::newFromId($user_id);
// skip if not enable
if (!$this->enabled($wgCityId, $user)) {
continue;
}
self::addParamsUser($wgCityId, $user->getName(), $emailParams);
$langCode = $user->getOption('language');
$mailSubject = strtr(wfMsgExt('founderemails' . $wikiType . '-email-user-registered-subject', array('content')), $emailParams);
$mailBody = strtr(wfMsgExt('founderemails' . $wikiType . '-email-user-registered-body', array('content')), $emailParams);
if (empty($wgEnableAnswers)) {
// FounderEmailv2.1
$links = array('$EDITORNAME' => $emailParams['$EDITORPAGEURL'], '$WIKINAME' => $emailParams['$WIKIURL']);
$mailBodyHTML = F::app()->renderView("FounderEmails", "GeneralUpdate", array_merge($emailParams, array('language' => 'en', 'type' => 'user-registered')));
$mailBodyHTML = strtr($mailBodyHTML, FounderEmails::addLink($emailParams, $links));
} else {
$mailBodyHTML = $this->getLocalizedMsg('founderemails' . $wikiType . '-email-user-registered-body-HTML', $emailParams);
}
$mailCategory = FounderEmailsEvent::CATEGORY_REGISTERED . (!empty($langCode) && $langCode == 'en' ? 'EN' : 'INT');
wfProfileOut(__METHOD__);
$founderEmailObj->notifyFounder($user, $this, $mailSubject, $mailBody, $mailBodyHTML, $wgCityId, $mailCategory);
}
return true;
}
wfProfileOut(__METHOD__);
return false;
}
示例10: getWikiAdminIds
/**
* get list of wiki founder/admin/bureaucrat id
* Note: also called from maintenance script.
*
* @param integer $wikiId - wiki Id (default: current wiki Id)
* @param bool $useMaster - flag that describes if we should use masted DB (default: false)
* @param bool $excludeBots - flag that describes if bots should be excluded from admins list (default: false)
* @param integer $limit - admins limit
* @param bool $includeFounder - flag that describes if founder user should be added to admins list (default: true)
*
* @return array of $userIds
*/
public function getWikiAdminIds($wikiId = 0, $useMaster = false, $excludeBots = false, $limit = null, $includeFounder = true)
{
wfProfileIn(__METHOD__);
$userIds = array();
if (empty($this->wg->FounderEmailsDebugUserId)) {
// get founder
$wikiId = empty($wikiId) ? $this->wg->CityId : $wikiId;
$wiki = WikiFactory::getWikiById($wikiId);
if (!empty($wiki) && $wiki->city_public == 1) {
if ($includeFounder) {
$userIds[] = $wiki->city_founding_user;
}
// get admin and bureaucrat
if (empty($this->wg->EnableAnswers)) {
$memKey = $this->getMemKeyAdminIds($wikiId, $excludeBots, $limit);
$adminIds = WikiaDataAccess::cache($memKey, 60 * 60 * 3, function () use($wiki, $useMaster, $excludeBots, $limit) {
$dbname = $wiki->city_dbname;
$dbType = $useMaster ? DB_MASTER : DB_SLAVE;
$db = wfGetDB($dbType, array(), $dbname);
$conditions = array("ug_group in ('sysop','bureaucrat')");
if ($excludeBots) {
$conditions[] = "ug_user not in (select distinct ug_user from user_groups where ug_group in (" . $db->makeList(self::$botGroups) . "))";
}
$result = $db->select('user_groups', 'distinct ug_user', $conditions, __METHOD__, !empty($limit) ? array('LIMIT' => $limit) : array());
$adminIds = array();
while ($row = $db->fetchObject($result)) {
$adminIds[] = $row->ug_user;
}
$db->freeResult($result);
return $adminIds;
});
$userIds = array_unique(array_merge($userIds, $adminIds));
}
}
} else {
$userIds[] = $this->wg->FounderEmailsDebugUserId;
}
wfProfileOut(__METHOD__);
return $userIds;
}
示例11: process
/**
* Called from maintenance script only. Send Digest emails for any founders with that preference enabled
* @param array $events
*/
public function process(array $events)
{
global $wgTitle;
wfProfileIn(__METHOD__);
$wgTitle = Title::newMainPage();
$founderEmailObj = FounderEmails::getInstance();
// Get list of founders with digest mode turned on (defined in FounderEmailsEvent
$cityList = $founderEmailObj->getFoundersWithPreference('founderemails-complete-digest');
$wikiService = F::build('WikiService');
foreach ($cityList as $cityID) {
$user_ids = $wikiService->getWikiAdminIds($cityID);
$foundingWiki = WikiFactory::getWikiById($cityID);
$page_url = GlobalTitle::newFromText('WikiActivity', NS_SPECIAL, $cityID)->getFullUrl();
$emailParams = array('$WIKINAME' => $foundingWiki->city_title, '$WIKIURL' => $foundingWiki->city_url, '$PAGEURL' => $page_url, '$UNIQUEVIEWS' => $founderEmailObj->getPageViews($cityID), '$USERJOINS' => $founderEmailObj->getNewUsers($cityID), '$USEREDITS' => $founderEmailObj->getDailyEdits($cityID));
foreach ($user_ids as $user_id) {
$user = User::newFromId($user_id);
// skip if not enable
if (!$this->enabled($cityID, $user)) {
continue;
}
self::addParamsUser($cityID, $user->getName(), $emailParams);
$langCode = $user->getOption('language');
// Only send digest emails for English users until translation is done
if ($langCode == 'en') {
$links = array('$WIKINAME' => $emailParams['$WIKIURL']);
$mailSubject = strtr(wfMsgExt('founderemails-email-complete-digest-subject', array('content')), $emailParams);
$mailBody = strtr(wfMsgExt('founderemails-email-complete-digest-body', array('content', 'parsemag'), $emailParams['$UNIQUEVIEWS'], $emailParams['$USEREDITS'], $emailParams['$USERJOINS']), $emailParams);
$mailBodyHTML = F::app()->renderView("FounderEmails", "GeneralUpdate", array_merge($emailParams, array('language' => 'en', 'type' => 'complete-digest')));
$mailBodyHTML = strtr($mailBodyHTML, FounderEmails::addLink($emailParams, $links));
$mailCategory = FounderEmailsEvent::CATEGORY_COMPLETE_DIGEST . (!empty($langCode) && $langCode == 'en' ? 'EN' : 'INT');
// Only send email if there is some kind of activity to report
if ($emailParams['$UNIQUEVIEWS'] > 0 || $emailParams['$USERJOINS'] > 0 || $emailParams['$USEREDITS'] > 0) {
$founderEmailObj->notifyFounder($user, $this, $mailSubject, $mailBody, $mailBodyHTML, $cityID, $mailCategory);
}
}
}
}
wfProfileOut(__METHOD__);
}
示例12: getWikiUsers
/**
* get users with avatar who sign up on the wiki (include founder)
* @param integer $wikiId
* @param integer $limit (number of users)
* @return array $wikiUsers
*/
protected function getWikiUsers($wikiId = null, $limit = 30)
{
$this->wf->ProfileIn(__METHOD__);
$wikiId = empty($wikiId) ? $this->wg->CityId : $wikiId;
$memKey = $this->wf->SharedMemcKey('userlogin', 'users_with_avatar', $wikiId);
$wikiUsers = $this->wg->Memc->get($memKey);
if (!is_array($wikiUsers)) {
$wikiUsers = array();
$db = $this->wf->GetDB(DB_SLAVE, array(), $this->wg->StatsDB);
$result = $db->select(array('user_login_history'), array('distinct user_id'), array('city_id' => $wikiId), __METHOD__, array('LIMIT' => $limit));
while ($row = $db->fetchObject($result)) {
$this->addUserToUserList($row->user_id, $wikiUsers);
}
$db->freeResult($result);
// add founder if not exist
$founder = WikiFactory::getWikiById($wikiId)->city_founding_user;
if (!array_key_exists($founder, $wikiUsers)) {
$this->addUserToUserList($founder, $wikiUsers);
}
$this->wg->Memc->set($memKey, $wikiUsers, 60 * 60 * 24);
}
$this->wf->ProfileOut(__METHOD__);
return $wikiUsers;
}
示例13: isset
die( "Usage: php maintenance.php [--help] [--dry-run] [--quiet]
--dry-run dry run
--quiet show summary result only
--help you are reading it right now\n\n" );
}
$dryRun = ( isset($options['dry-run']) );
$quiet = ( isset($options['quiet']) );
if ( empty($wgCityId) ) {
die( "Error: Invalid wiki id." );
}
echo "Wiki: ".$wgCityId;
$wiki = WikiFactory::getWikiById( $wgCityId );
if ( !empty($wiki) && $wiki->city_public == 1 ) {
$dbname = $wiki->city_dbname;
echo " ($dbname): \n";
$total = 0;
$add = 0;
$dup = 0;
$user = User::newFromName('WikiaBot');
$markers = array( RelatedVideosNamespaceData::WHITELIST_MARKER, RelatedVideosNamespaceData::BLACKLIST_MARKER );
echo "GlobalList: \n";
$globalList = RelatedVideosNamespaceData::newFromGeneralMessage();
示例14: getWikiInfo
/**
* get wiki info ( wikiname, description, url, status, images )
* @param integer $wikiId
* @param string $langCode
* @param WikiDataGetter $dataGetter
* @return array wikiInfo
*/
public function getWikiInfo($wikiId, $langCode, WikiDataGetter $dataGetter)
{
wfProfileIn(__METHOD__);
$wikiInfo = array('name' => '', 'headline' => '', 'description' => '', 'url' => '', 'official' => 0, 'promoted' => 0, 'blocked' => 0, 'images' => array());
if (!empty($wikiId)) {
$wiki = WikiFactory::getWikiById($wikiId);
if (!empty($wiki)) {
$wikiInfo['url'] = $wiki->city_url . '?redirect=no';
}
$wikiData = $dataGetter->getWikiData($wikiId, $langCode);
if (!empty($wikiData)) {
$wikiInfo['name'] = $wikiData['name'];
$wikiInfo['headline'] = $wikiData['headline'];
$wikiInfo['description'] = $wikiData['description'];
// wiki status
$wikiInfo['official'] = intval(CityVisualization::isOfficialWiki($wikiData['flags']));
$wikiInfo['promoted'] = intval(CityVisualization::isPromotedWiki($wikiData['flags']));
$wikiInfo['blocked'] = intval(CityVisualization::isBlockedWiki($wikiData['flags']));
$wikiInfo['images'] = array();
if (!empty($wikiData['main_image'])) {
$wikiInfo['images'][] = $wikiData['main_image'];
}
$wikiData['images'] = !empty($wikiData['images']) ? (array) $wikiData['images'] : array();
// wiki images
if (!empty($wikiData['images'])) {
$wikiInfo['images'] = array_merge($wikiInfo['images'], $wikiData['images']);
}
}
}
wfProfileOut(__METHOD__);
return $wikiInfo;
}
示例15: blockWikia
private function blockWikia($wikiId)
{
$oWiki = WikiFactory::getWikiById($wikiId);
if (!is_object($oWiki)) {
return false;
}
// process block data for display
$data = array('wiki_id' => $oWiki->city_id, 'sitename' => WikiFactory::getVarValueByName("wgSitename", $oWiki->city_id), 'url' => WikiFactory::getVarValueByName("wgServer", $oWiki->city_id), 'last_timestamp' => $this->wg->Lang->timeanddate($oWiki->city_last_timestamp));
// we have a valid id, change title to use it
$this->wg->Out->setPageTitle(wfMsg('phalanx-stats-title') . ': ' . $data['url']);
$headers = array(wfMsg('phalanx-stats-table-wiki-id'), wfMsg('phalanx-stats-table-wiki-name'), wfMsg('phalanx-stats-table-wiki-url'), wfMsg('phalanx-stats-table-wiki-last-edited'));
$tableAttribs = array('border' => 1, 'class' => 'wikitable', 'style' => "font-family:monospace;");
$table = Xml::buildTable(array($data), $tableAttribs, $headers);
$this->setVal('table', $table);
$pager = new PhalanxStatsWikiaPager($wikiId);
$this->setVal('statsPager', $pager->getNavigationBar() . $pager->getBody() . $pager->getNavigationBar());
}