/**
  * 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__);
 }
Ejemplo n.º 2
0
 function getPathPrefix()
 {
     $wikiDbName = $this->repo->getDBName();
     $wikiId = WikiFactory::DBtoID($wikiDbName);
     $wikiUploadPath = WikiFactory::getVarValueByName('wgUploadPath', $wikiId);
     return VignetteRequest::parsePathPrefix($wikiUploadPath);
 }
Ejemplo n.º 3
0
 public function getCityId()
 {
     if (empty($this->cityId) and !empty($this->dbName)) {
         $this->cityId = WikiFactory::DBtoID($this->dbName);
     }
     return $this->cityId;
 }
 /**
  * execute -- main entry point to api method
  *
  * use secret hash for checking if api is called by proper engine
  *
  * @access public
  *
  * @return api result
  */
 public function execute()
 {
     global $wgTheSchwartzSecretToken, $wgCityId, $wgServer, $wgExtensionMessagesFiles;
     $params = $this->extractRequestParams();
     $status = 0;
     if (isset($params["token"]) && $params["token"] === $wgTheSchwartzSecretToken) {
         /**
          * get creator from param
          */
         $founder = User::newFromId($params["user_id"]);
         $founder->load();
         /**
          * get city_founding_user from city_list
          */
         if (!$founder) {
             $wiki = WikiFactory::getWikiByID($wgCityId);
             $founder = User::newFromId($wiki->city_founding_user);
         }
         Wikia::log(__METHOD__, "user", $founder->getName());
         if ($founder && $founder->isEmailConfirmed()) {
             if ($founder->sendMail(wfMsg("autocreatewiki-reminder-subject"), wfMsg("autocreatewiki-reminder-body", array($founder->getName(), $wgServer)), null, null, "AutoCreateWikiReminder", wfMsg("autocreatewiki-reminder-body-HTML", array($founder->getName(), $wgServer)))) {
                 $status = 1;
             }
         }
     } else {
         $this->dieUsageMsg(array("sessionfailure"));
     }
     $result = array("status" => $status);
     $this->getResult()->setIndexedTagName($result, 'status');
     $this->getResult()->addValue(null, $this->getModuleName(), $result);
 }
Ejemplo n.º 5
0
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;
}
Ejemplo n.º 6
0
 public function execute($subpage)
 {
     global $wgOut, $wgRequest, $wgUser, $wgCacheEpoch, $wgCityId;
     wfProfileIn(__METHOD__);
     $this->setHeaders();
     $this->mTitle = SpecialPage::getTitleFor('cacheepoch');
     if ($this->isRestricted() && !$this->userCanExecute($wgUser)) {
         $this->displayRestrictionError();
         wfProfileOut(__METHOD__);
         return;
     }
     //no WikiFactory (internal wikis)
     if (empty($wgCityId)) {
         $wgOut->addHTML(wfMsg('cacheepoch-no-wf'));
         wfProfileOut(__METHOD__);
         return;
     }
     if ($wgRequest->wasPosted()) {
         $wgCacheEpoch = wfTimestampNow();
         $status = WikiFactory::setVarByName('wgCacheEpoch', $wgCityId, $wgCacheEpoch, wfMsg('cacheepoch-wf-reason'));
         if ($status) {
             $wgOut->addHTML('<h2>' . wfMsg('cacheepoch-updated', $wgCacheEpoch) . '</h2>');
         } else {
             $wgOut->addHTML('<h2>' . wfMsg('cacheepoch-not-updated') . '</h2>');
         }
     } else {
         $wgOut->addHTML('<h2>' . wfMsg('cacheepoch-header') . '</h2>');
     }
     $wgOut->addHTML(Xml::openElement('form', array('action' => $this->mTitle->getFullURL(), 'method' => 'post')));
     $wgOut->addHTML(wfMsg('cacheepoch-value', $wgCacheEpoch) . '<br>');
     $wgOut->addHTML(Xml::submitButton(wfMsg('cacheepoch-submit')));
     $wgOut->addHTML(Xml::closeElement('form'));
     wfProfileOut(__METHOD__);
 }
Ejemplo n.º 7
0
 public function __construct($id = null)
 {
     parent::__construct();
     if (is_null($id)) {
         $id = $this->wg->CityId;
     }
     $this->id = $id;
     if ($this->wg->CityId == $id) {
         $this->db = wfGetDB(DB_SLAVE);
         $this->dbname = $this->wg->DBname;
     } else {
         // find db name
         $dbname = WikiFactory::IDtoDB($this->id);
         if (empty($dbname)) {
             throw new Exception("Could not find wiki with ID {$this->id}");
         }
         // open db connection (and check if db really exists)
         $db = wfGetDB(DB_SLAVE, array(), $dbname);
         if (!is_object($db)) {
             throw new Exception("Could not connect to wiki database {$dbname}");
         }
         $this->db = $db;
         $this->dbname = $dbname;
     }
 }
Ejemplo n.º 8
0
 /**
  * Get storage instance to access uploaded files for a given wiki
  *
  * @param $cityId number|string city ID or wiki name
  * @param $dataCenter string|null name of data center (res, iowa ... )
  * @return SwiftStorage storage instance
  */
 public static function newFromWiki($cityId, $dataCenter = null)
 {
     $wgUploadPath = \WikiFactory::getVarValueByName('wgUploadPath', $cityId);
     $path = trim(parse_url($wgUploadPath, PHP_URL_PATH), '/');
     list($containerName, $prefix) = explode('/', $path, 2);
     return new self($containerName, '/' . $prefix, $dataCenter);
 }
 function execute($par)
 {
     global $wgOut, $wgCityId, $wgSuppressWikiHeader, $wgSuppressPageHeader, $wgShowMyToolsOnly, $wgExtensionsPath, $wgBlankImgUrl, $wgJsMimeType, $wgTitle, $wgUser, $wgRequest;
     wfProfileIn(__METHOD__);
     // redirect to www.wikia.com
     if ($wgCityId == 177) {
         $destServer = WikiFactory::getVarValueByName('wgServer', $this->destCityId);
         $destArticlePath = WikiFactory::getVarValueByName('wgArticlePath', $this->destCityId);
         $wgOut->redirect($destServer . str_replace('$1', 'Special:LandingPage', $destArticlePath));
         return;
     }
     $this->setHeaders();
     $wgOut->addStyle(AssetsManager::getInstance()->getSassCommonURL('extensions/wikia/LandingPage/css/LandingPage.scss'));
     // hide wiki and page header
     $wgSuppressWikiHeader = true;
     $wgSuppressPageHeader = true;
     // only shown "My Tools" on floating toolbar
     $wgShowMyToolsOnly = true;
     // parse language links (RT #71622)
     $languageLinks = array();
     $parsedMsg = wfStringToArray(wfMsg('landingpage-language-links'), '*', 10);
     foreach ($parsedMsg as $item) {
         if ($item != '') {
             list($text, $lang) = explode('|', $item);
             $languageLinks[] = array('text' => $text, 'href' => $wgTitle->getLocalUrl("uselang={$lang}"));
         }
     }
     // fetching the landingpage sites
     $landingPageLinks = CorporatePageHelper::parseMsgImg('landingpage-sites', false, false);
     // render HTML
     $template = new EasyTemplate(dirname(__FILE__) . '/templates');
     $template->set_vars(array('imagesPath' => $wgExtensionsPath . '/wikia/LandingPage/images/', 'languageLinks' => $languageLinks, 'wgBlankImgUrl' => $wgBlankImgUrl, 'wgTitle' => $wgTitle, 'landingPageLinks' => $landingPageLinks, 'landingPageSearch' => F::app()->getView("SearchController", "Index", array("placeholder" => "Search Wikia", "fulltext" => "0", "wgBlankImgUrl" => $wgBlankImgUrl, "wgTitle" => $wgTitle))));
     $wgOut->addHTML($template->render('main'));
     wfProfileOut(__METHOD__);
 }
Ejemplo n.º 10
0
 private function getUploadDir()
 {
     if (!isset($this->uploadDir)) {
         $this->uploadDir = WikiFactory::getVarValueByName('wgUploadPath', $this->mTitle->mCityId);
     }
     return $this->uploadDir;
 }
Ejemplo n.º 11
0
function countNotExternal()
{
    $dbr = wfGetDB(DB_SLAVE, "dpl");
    /**
     * get active databases from city_list
     */
    $databases = array();
    $res = $dbr->select(WikiFactory::table("city_list"), array("city_dbname", "city_id"), array("city_public" => 1), __FUNCTION__);
    while ($row = $dbr->fetchObject($res)) {
        $databases[$row->city_id] = $row->city_dbname;
    }
    $dbr->freeResult($res);
    foreach ($databases as $city_id => $database) {
        $sql = "\n\t\t\tSELECT count(*) as count\n\t\t\tFROM revision r1 FORCE INDEX (PRIMARY), text t2\n\t\t\tWHERE old_id = rev_text_id\n\t\t\tAND old_flags NOT LIKE '%external%'\n\t\t";
        $dbr->selectDB($database);
        $dbr->begin();
        $res = $dbr->query($sql, __FUNCTION__);
        $row = $dbr->fetchObject($res);
        if (!empty($row->count)) {
            printf("Not External rows in %5d %30s = %8d\n", $city_id, $database, $row->count);
        }
        $dbr->freeResult($res);
        $dbr->commit();
    }
}
Ejemplo n.º 12
0
 /**
  * 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);
     }
 }
Ejemplo n.º 13
0
 /**
  * @param $wikiId
  * @param $query
  * @return float
  */
 public function performQueryTest($wikiId, $query)
 {
     $wgLinkSuggestLimit = 6;
     $dbName = WikiFactory::IDtoDB($wikiId);
     $db = wfGetDB(DB_SLAVE, [], $dbName);
     $namespaces = WikiFactory::getVarValueByName("wgContentNamespaces", $wikiId);
     $namespaces = $namespaces ? $namespaces : [0];
     $query = addslashes($query);
     $queryLower = strtolower($query);
     if (count($namespaces) > 0) {
         $commaJoinedNamespaces = count($namespaces) > 1 ? array_shift($namespaces) . ', ' . implode(', ', $namespaces) : $namespaces[0];
     }
     $pageNamespaceClause = isset($commaJoinedNamespaces) ? 'page_namespace IN (' . $commaJoinedNamespaces . ') AND ' : '';
     $pageTitlePrefilter = "";
     if (strlen($queryLower) >= 2) {
         $pageTitlePrefilter = "(\n\t\t\t\t\t\t\t( page_title " . $db->buildLike(strtoupper($queryLower[0]) . strtolower($queryLower[1]), $db->anyString()) . " ) OR\n\t\t\t\t\t\t\t( page_title " . $db->buildLike(strtoupper($queryLower[0]) . strtoupper($queryLower[1]), $db->anyString()) . " ) ) AND ";
     } else {
         if (strlen($queryLower) >= 1) {
             $pageTitlePrefilter = "( page_title " . $db->buildLike(strtoupper($queryLower[0]), $db->anyString()) . " ) AND ";
         }
     }
     $sql = "SELECT page_len, page_id, page_title, rd_title, page_namespace, page_is_redirect\n\t\t\t\t\t\tFROM page\n\t\t\t\t\t\tLEFT JOIN redirect ON page_is_redirect = 1 AND page_id = rd_from\n\t\t\t\t\t\tLEFT JOIN querycache ON qc_title = page_title AND qc_type = 'BrokenRedirects'\n\t\t\t\t\t\tWHERE  {$pageTitlePrefilter} {$pageNamespaceClause} (LOWER(page_title) LIKE '{$queryLower}%')\n\t\t\t\t\t\t\tAND qc_type IS NULL\n\t\t\t\t\t\tORDER BY page_id\n\t\t\t\t\t\tLIMIT " . $wgLinkSuggestLimit * 3;
     // we fetch 3 times more results to leave out redirects to the same page
     $start = microtime(true);
     $res = $db->query($sql, __METHOD__);
     while ($res->fetchRow()) {
     }
     return microtime(true) - $start;
 }
Ejemplo n.º 14
0
 /**
  * Mark given wiki as queued for removal
  *
  * @param $wikiId integer city ID
  * @return bool
  */
 private function markWikiAsClosed($wikiId)
 {
     WikiFactory::setFlags($wikiId, WikiFactory::FLAG_FREE_WIKI_URL | WikiFactory::FLAG_DELETE_DB_IMAGES);
     $res = WikiFactory::setPublicStatus(WikiFactory::CLOSE_ACTION, $wikiId, self::REASON);
     WikiFactory::clearCache($wikiId);
     return $res !== false;
 }
 /**
  * Get variables values
  *
  * @return object key / value list variables
  */
 private function getVariablesValues()
 {
     global $wgInstantGlobalsOverride;
     if (!empty($wgInstantGlobalsOverride) && is_array($wgInstantGlobalsOverride)) {
         $override = $wgInstantGlobalsOverride;
     } else {
         $override = [];
     }
     $ret = [];
     $variables = [];
     wfRunHooks('InstantGlobalsGetVariables', [&$variables]);
     foreach ($variables as $name) {
         // Use the value on community but override with the $wgInstantGlobalsOverride
         if (array_key_exists($name, $override)) {
             $value = $override[$name];
         } else {
             $value = WikiFactory::getVarValueByName($name, Wikia::COMMUNITY_WIKI_ID);
         }
         // don't emit "falsy" values
         if (!empty($value)) {
             $ret[$name] = $value;
         }
     }
     return (object) $ret;
 }
Ejemplo n.º 16
0
 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;
 }
Ejemplo n.º 17
0
 public function execute()
 {
     $this->test = $this->hasOption('test') ? true : false;
     $this->verbose = $this->hasOption('verbose') ? true : false;
     $this->clear = $this->hasOption('clear') ? true : false;
     $this->refresh = $this->hasOption('refresh') ? true : false;
     if ($this->test) {
         echo "== TEST MODE ==\n";
     }
     $this->debug("(debugging output enabled)\n");
     $startTime = time();
     // Clear existing suggestions if we are forcing a rebuild
     if ($this->clear) {
         $this->clearSuggestions();
     }
     $this->processVideoList();
     $delta = $this->formatDuration(time() - $startTime);
     $stats = $this->usageStats();
     $wgDBName = WikiFactory::IDtoDB($_ENV['SERVER_ID']);
     echo "[{$wgDBName}] Finished in {$delta}.\n";
     echo "[{$wgDBName}] Usage Stats: Total videos before swapping videos=" . ($stats['totalVids'] + $stats['swapTypes'][2] + $stats['swapTypes'][3]) . ", ";
     echo "Total videos=" . $stats['totalVids'] . " (Videos with suggestions=" . $stats['vidsWithSuggestions'] . "), ";
     echo "Total suggestions=" . $stats['numSuggestions'] . ", Avg per video=" . sprintf("%.1f", $stats['avgSuggestions']) . ", ";
     echo "Total kept videos=" . $stats['swapTypes'][1] . ", Total swapped videos=" . ($stats['swapTypes'][2] + $stats['swapTypes'][3]) . " (Exact title=" . $stats['swapTypes'][3] . ")\n";
 }
Ejemplo n.º 18
0
 /**
  * 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;
 }
 function execute()
 {
     global $wgOut, $wgUser, $wgRequest, $wgTitle;
     $gVar = $wgRequest->getText('var');
     $gVal = $wgRequest->getVal('val', 'true');
     $gLikeVal = $wgRequest->getVal('likeValue', 'true');
     $gTypeVal = $wgRequest->getVal('searchType', 'bool');
     $wgOut->SetPageTitle(wfMsg('whereisextension'));
     $wgOut->setRobotpolicy('noindex,nofollow');
     if (!$wgUser->isAllowed('WhereIsExtension')) {
         $this->displayRestrictionError();
         return;
     }
     $this->values = array(0 => array('true', true, '='), 1 => array('false', false, '='), 2 => array('not empty', '', '!='));
     $tagName = $wgRequest->getVal('wikiSelectTagName', null);
     $tagWikis = $wgRequest->getArray('wikiSelected');
     $tagResultInfo = '';
     if ($wgRequest->wasPosted() && !empty($tagName) && count($tagWikis)) {
         $tagResultInfo = $this->tagSelectedWikis($tagName, $tagWikis);
     }
     $formData['vars'] = $this->getListOfVars($gVar == '');
     $formData['vals'] = $this->values;
     $formData['selectedVal'] = $gVal;
     $formData['likeValue'] = $gLikeVal;
     $formData['searchType'] = $gTypeVal;
     $formData['selectedGroup'] = $gVar == '' ? 27 : '';
     //default group: extensions (or all groups when looking for variable, rt#16953)
     $formData['groups'] = WikiFactory::getGroups();
     $formData['actionURL'] = $wgTitle->getFullURL();
     // by default, we don't need a paginator
     $sPaginator = '';
     if (!empty($gVar)) {
         $formData['selectedVar'] = $gVar;
         // assume an empty result
         $formData['count'] = 0;
         $formData['wikis'] = array();
         if (isset($this->values[$gVal][1]) && isset($this->values[$gVal][2])) {
             // check how many wikis meet the conditions
             $formData['count'] = WikiFactory::getCountOfWikisWithVar($gVar, $gTypeVal, $this->values[$gVal][2], $this->values[$gVal][1], $gLikeVal);
             // if there are any, get the list and create a Paginator
             if (0 < $formData['count']) {
                 // determine the offset (from the requested page)
                 $iPage = $wgRequest->getVal('page', 1);
                 $iOffset = ($iPage - 1) * self::ITEMS_PER_PAGE;
                 // the list
                 $formData['wikis'] = WikiFactory::getListOfWikisWithVar($gVar, $gTypeVal, $this->values[$gVal][2], $this->values[$gVal][1], $gLikeVal, $iOffset, self::ITEMS_PER_PAGE);
                 // the Paginator, if we need more than one page
                 if (self::ITEMS_PER_PAGE < $formData['count']) {
                     $oPaginator = Paginator::newFromArray(array_fill(0, $formData['count'], ''), self::ITEMS_PER_PAGE, 5);
                     $oPaginator->setActivePage($iPage - 1);
                     $sPager = $oPaginator->getBarHTML(sprintf('%s?var=%s&val=%s&likeValue=%s&searchType=%s&page=%%s', $wgTitle->getFullURL(), $gVar, $gVal, $gLikeVal, $gTypeVal));
                 }
             }
         }
     }
     $oTmpl = new EasyTemplate(dirname(__FILE__) . '/templates/');
     $oTmpl->set_vars(array('formData' => $formData, 'tagResultInfo' => $tagResultInfo, 'sPager' => $sPager));
     $wgOut->addHTML($oTmpl->render('list'));
 }
 public static function getRtpCountries()
 {
     static $countries;
     if ($countries) {
         return $countries;
     }
     return $countries = WikiFactory::getVarValueByName(self::RTP_COUNTRIES, WikiFactory::COMMUNITY_CENTRAL);
 }
Ejemplo n.º 21
0
 public function getWikiDomain()
 {
     global $wgDBname;
     if (empty($this->wikiDomain)) {
         $this->setWikiDomain(WikiFactory::DBtoDomain($wgDBname));
     }
     return $this->wikiDomain;
 }
 /**
  * Return number of communities
  * and number of communities with curated content wg variable set to not falsy value.
  *
  * @responseParam integer totalCommunities
  * @responseParam integer communitiesWithCuratedContent
  */
 public function getCuratedContentStats()
 {
     $data = $this->sendSelfRequest('getWikiaStats')->getData();
     $this->getResponse()->setFormat(WikiaResponse::FORMAT_JSON);
     $communitiesWithCuratedContent = WikiFactory::getCountOfWikisWithVar(CuratedContentController::CURATED_CONTENT_WG_VAR_ID_PROD, "full", "LIKE", null, "true");
     $this->setVal('item', intval($communitiesWithCuratedContent));
     $this->setVal('min', ['value' => 0]);
     $this->setVal('max', ['value' => $data['communities']]);
 }
 protected function getWikisWithVar()
 {
     $wikiList = [];
     $list = WikiFactory::getListOfWikisWithVar(self::LICENSE_WIKI_FACTORY_VAR_ID, "full", '', '');
     foreach ($list as $wikiId => $val) {
         $wikiList[$wikiId] = array("id" => $wikiId, "url" => $val['u'], "host" => rtrim(ltrim($val['u'], "http://"), "/"), "db" => $val['d']);
     }
     return $wikiList;
 }
Ejemplo n.º 24
0
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;
}
 public function __construct($cityId)
 {
     global $wgForeignFileRepos;
     parent::__construct();
     $this->cityId = $cityId;
     $this->skinName = RequestContext::getMain()->getSkin()->getSkinName();
     $hubWiki = WikiFactory::getWikiByID($cityId);
     $hubDbName = $hubWiki->city_dbname;
     $wgForeignFileRepos[] = ['class' => 'WikiaForeignDBViaLBRepo', 'name' => $hubDbName, 'transformVia404' => true, 'wiki' => $hubDbName, 'backend' => "wikia{$hubDbName}-backend"];
 }
Ejemplo n.º 26
0
 function execute($params = null)
 {
     global $IP, $wgWikiaLocalSettingsPath;
     /*  go with each supplied wiki and delete the supplied article
     			load all configs for particular wikis before doing so
     			(from wikifactory, not by _obsolete_ maintenance scripts
     			and from LocalSettings as worked on fps)
     		 */
     $this->mTaskID = $params->task_id;
     $oUser = User::newFromId($params->task_user_id);
     if ($oUser instanceof User) {
         $oUser->load();
         $this->mUser = $oUser->getName();
     } else {
         $this->log("Invalid user - id: " . $params->task_user_id);
         return true;
     }
     $data = unserialize($params->task_arguments);
     foreach ($data['page_list'] as $imageData) {
         $retval = "";
         list($wikiId, $imageId) = $imageData;
         $dbname = WikiFactory::getWikiByID($wikiId);
         if (!$dbname) {
             continue;
         }
         $title = GlobalTitle::newFromId($imageId, $wikiId);
         if (!is_object($title)) {
             $this->log('Apparently the article does not exist anymore');
             continue;
         }
         $city_url = WikiFactory::getVarValueByName("wgServer", $wikiId);
         if (empty($city_url)) {
             continue;
         }
         $city_path = WikiFactory::getVarValueByName("wgScript", $wikiId);
         $city_lang = WikiFactory::getVarValueByName("wgLanguageCode", $wikiId);
         $reason = wfMsgExt('imagereview-reason', array('language' => $city_lang));
         $sCommand = "perl /usr/wikia/backend/bin/run_maintenance --id={$wikiId} --script=wikia/deleteOn.php ";
         $sCommand .= "-- ";
         $sCommand .= "-u " . escapeshellarg($this->mUser) . " ";
         $sCommand .= "-t " . escapeshellarg($title->getPrefixedText()) . " ";
         if ($reason) {
             $sCommand .= "-r " . escapeshellarg($reason) . " ";
         }
         $actual_title = wfShellExec($sCommand, $retval);
         if ($retval) {
             $this->addLog('Article deleting error! (' . $city_url . '). Error code returned: ' . $retval . ' Error was: ' . $actual_title);
         } else {
             $this->addLog('Removed: <a href="' . $city_url . $city_path . '?title=' . wfEscapeWikiText($actual_title) . '">' . $city_url . $city_path . '?title=' . $actual_title . '</a>');
         }
         $this->flagUser($imageId, $wikiId);
         $this->flagWiki($wikiId);
     }
     return true;
 }
Ejemplo n.º 27
0
 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__);
 }
Ejemplo n.º 28
0
function wfAdEngineSetupJSVars(array &$vars)
{
    wfProfileIn(__METHOD__);
    global $wgRequest, $wgNoExternals, $wgEnableAdsInContent, $wgEnableOpenXSPC, $wgAdDriverCookieLifetime, $wgHighValueCountries, $wgDartCustomKeyValues, $wgUser, $wgEnableWikiAnswers, $wgAdDriverUseCookie, $wgAdDriverUseExpiryStorage, $wgEnableAdMeldAPIClient, $wgEnableAdMeldAPIClientPixels, $wgLoadAdDriverOnLiftiumInit;
    $wgNoExternals = $wgRequest->getBool('noexternals', $wgNoExternals);
    if (!empty($wgNoExternals)) {
        $vars["wgNoExternals"] = $wgNoExternals;
    }
    if (!empty($wgEnableAdsInContent)) {
        $vars["wgEnableAdsInContent"] = $wgEnableAdsInContent;
    }
    if (!empty($wgEnableAdMeldAPIClient)) {
        $vars["wgEnableAdMeldAPIClient"] = $wgEnableAdMeldAPIClient;
    }
    if (!empty($wgEnableAdMeldAPIClientPixels)) {
        $vars["wgEnableAdMeldAPIClientPixels"] = $wgEnableAdMeldAPIClientPixels;
    }
    // OpenX SPC (init in AdProviderOpenX.js)
    if (!empty($wgEnableOpenXSPC)) {
        $vars["wgEnableOpenXSPC"] = $wgEnableOpenXSPC;
    }
    // AdDriver
    $vars['wgAdDriverCookieLifetime'] = $wgAdDriverCookieLifetime;
    $highValueCountries = WikiFactory::getVarValueByName('wgHighValueCountries', 177);
    // community central
    if (empty($highValueCountries)) {
        $highValueCountries = $wgHighValueCountries;
    }
    $vars['wgHighValueCountries'] = $highValueCountries;
    if (!empty($wgAdDriverUseExpiryStorage)) {
        $vars["wgAdDriverUseExpiryStorage"] = $wgAdDriverUseExpiryStorage;
    }
    if (!empty($wgAdDriverUseCookie)) {
        $vars["wgAdDriverUseCookie"] = $wgAdDriverUseCookie;
    }
    if (!empty($wgLoadAdDriverOnLiftiumInit)) {
        $vars['wgLoadAdDriverOnLiftiumInit'] = $wgLoadAdDriverOnLiftiumInit;
    }
    if ($wgUser->getOption('showAds')) {
        $vars['wgUserShowAds'] = true;
    }
    // Answers sites
    if (!empty($wgEnableWikiAnswers)) {
        $vars['wgEnableWikiAnswers'] = $wgEnableWikiAnswers;
    }
    /*
    // Krux
    if (!empty($wgEnableKruxTargeting) && empty($wgNoExternals)) {
    	$vars['wgEnableKruxTargeting'] = $wgEnableKruxTargeting;
    	$vars['wgKruxCategoryId'] = WikiFactoryHub::getInstance()->getKruxId($cat['id']);
    }
    */
    wfProfileOut(__METHOD__);
    return true;
}
 public function getFiltered()
 {
     $filtered = $this->filter->getFiltered();
     foreach ($filtered as $key => $wikiData) {
         $wikiId = (int) $wikiData['id'];
         if (WikiFactory::getVarValueByName('wgIsPrivateWiki', $wikiId)) {
             unset($filtered[$key]);
         }
     }
     return $filtered;
 }
Ejemplo n.º 30
0
 /**
  * Get domain for a wiki using given database name
  *
  * @param string database name
  * @return string HTTP domain
  */
 private static function getHostByDbName($dbname)
 {
     global $wgDevelEnvironment, $wgDevelEnvironmentName;
     if (!empty($wgDevelEnvironment)) {
         $hostName = "http://{$dbname}.{$wgDevelEnvironmentName}.wikia-dev.com";
     } else {
         $cityId = WikiFactory::DBtoID($dbname);
         $hostName = WikiFactory::getVarValueByName('wgServer', $cityId);
     }
     return rtrim($hostName, '/');
 }