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'));
 }
 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.º 3
0
 /**
  * Get list of wikis marked by wiki founders as directed at children
  * @return array citiesList
  */
 public function getCitiesForReviewList($limit = 20, $page = 0)
 {
     wfProfileIn(__METHOD__);
     if ($page < 0) {
         $page = 0;
     }
     $offset = $page * $limit;
     $aCities = array();
     if ($this->byFounderVarId) {
         $aCities = WikiFactory::getListOfWikisWithVar($this->byFounderVarId, 'bool', '=', true, '', $offset, $limit);
     }
     wfProfileOut(__METHOD__);
     return $aCities;
 }
Ejemplo n.º 4
0
 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;
         }
     }
 }
Ejemplo n.º 5
0
 protected function getIdsBlacklistedWikis()
 {
     $blacklistIds = WikiaDataAccess::cache(wfSharedMemcKey('wam_blacklist', self::MEMCACHE_VER), self::CACHE_DURATION, function () {
         $contentWarningWikis = $excludedWikis = [];
         // Exlude wikias with ContentWarning extension enabled
         $blacklistExtVarId = WikiFactory::getVarIdByName(self::WAM_BLACKLIST_EXT_VAR_NAME);
         if ($blacklistExtVarId) {
             $contentWarningWikis = array_keys(WikiFactory::getListOfWikisWithVar($blacklistExtVarId, 'bool', '=', true));
         }
         // Exclude wikias with an exclusion flag set to true
         $blacklistFlagVarId = WikiFactory::getVarIdByName(self::WAM_EXCLUDE_FLAG_NAME);
         if ($blacklistFlagVarId) {
             $excludedWikis = array_keys(WikiFactory::getListOfWikisWithVar($blacklistFlagVarId, 'bool', '=', true));
         }
         return array_merge($contentWarningWikis, $excludedWikis);
     });
     return $blacklistIds;
 }
 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;
 }
Ejemplo n.º 7
0
 * @author: Inez
 *
 * Get familiar with "How_to_run_maintenance_script" article on internal to figure out how to run it.
 */
ini_set("include_path", dirname(__FILE__) . "/../");
require_once "commandLine.inc";
function enableVEUI($id)
{
    WikiFactory::setVarByName('wgEnableVisualEditorUI', $id, true);
    WikiFactory::clearCache($id);
}
function isVEenabled($id)
{
    $out = WikiFactory::getVarByName('wgEnableVisualEditorExt', $id);
    return $out ? unserialize($out->cv_value) : false;
}
$varid = WikiFactory::getVarIdByName('wgEnableVisualEditorExt', true);
$list = WikiFactory::getListOfWikisWithVar($varid, 'bool', '=', true);
foreach ($list as $id => $val) {
    echo "Wiki id: {$id}\n";
    $isVEenabled = isVEenabled($id);
    if ($isVEenabled) {
        // IMPORTANT! Uncomment line below if you really want it to work.
        //enableVEUI( $id );
        echo "Enabled VEUI\n";
    } else {
        echo "Not enabled VEUI because VE not enabled\n";
    }
    echo "########################################\n";
}
WikiFactory::clearInterwikiCache();
Ejemplo n.º 8
0
 /**
  * @desc Gets id of wgEnableWikiaHomePageExt variable and then loads and returns list of corporate sites
  * @return array
  */
 protected function getCorporateSitesList()
 {
     return WikiaDataAccess::cache(wfSharedMemcKey('corporate_pages_list', self::CITY_VISUALIZATION_CORPORATE_PAGE_LIST_MEMC_VERSION), WikiaResponse::CACHE_STANDARD, function () {
         // loads list of corporate sites (sites which have $wgEnableWikiaHomePageExt WF variable set to true)
         $wikiFactoryVarId = WikiFactory::getVarIdByName(self::WIKIA_HOME_PAGE_WF_VAR_NAME);
         if (is_int($wikiFactoryVarId)) {
             return WikiFactory::getListOfWikisWithVar($wikiFactoryVarId, 'bool', '=', true);
         } else {
             return [];
         }
     });
 }
 public function getWikisIncludedInCorporateFooterDropdown()
 {
     $wikiFactoryList = [];
     $varId = WikiFactory::getVarIdByName(self::IS_WIKI_INCLUDED_IN_CORPORATE_FOOTER_DROPDOWN_VAR_NAME);
     if (is_int($varId)) {
         $wikiFactoryList = WikiaDataAccess::cache(wfMemcKey('wikis_included_in_corporate_footer_dropdown', self::WIKIA_HOME_PAGE_HELPER_MEMC_VERSION), 24 * 60 * 60, function () use($varId) {
             $list = WikiFactory::getListOfWikisWithVar($varId, 'bool', '=', true);
             return $this->cleanWikisDataArray($list);
         }, WikiaDataAccess::REFRESH_CACHE);
     }
     return $wikiFactoryList;
 }
Ejemplo n.º 10
0
	$dryRun = ( isset($options['dry-run']) );
	$quiet = ( isset($options['quiet']) );
	$copyRVtoGlobalList = ( isset($options['copyRVtoGlobalList']) );

	if ( empty($wgCityId) ) {
		die( "Error: Invalid wiki id." );
	}

	echo "Base wiki: ".$wgCityId."\n";

	// get var id
	$var = WikiFactory::getVarByName( 'wgRelatedVideosPartialRelease', $wgCityId );
	echo "wgRelatedVideosPartialRelease ID: ".$var->cv_id."\n";

	// get list of wikis with wgRelatedVideosPartialRelease = false
	$wikis = WikiFactory::getListOfWikisWithVar( $var->cv_id, 'bool', '=' , false, true );
	$total = count( $wikis );
	echo "Total wikis (wgRelatedVideosPartialRelease = false): ".$total."\n";

	$counter = 0;
	$failed = 0;

	foreach( $wikis as $wikiId => $detail ) {
		$counter++;
		echo "[$counter of $total] Wiki $wikiId ";
		$wiki = WikiFactory::getWikiById( $wikiId );
		if ( !empty($wiki) && $wiki->city_public == 1 ) {
			$dbname = $wiki->city_dbname;

			echo "($dbname): \n";
 /**
  * Get list of hubs from Database
  *
  * @param $lang
  * @return array
  */
 private function getHubsWikis($lang)
 {
     $varId = WikiFactory::getVarIdByName(self::HUBS_V3_VARIABLE_NAME);
     $wikis = WikiFactory::getListOfWikisWithVar($varId, 'bool', '=', true);
     if (!empty($lang)) {
         foreach ($wikis as $wikiId => $wiki) {
             if ($wiki['l'] != $lang) {
                 unset($wikis[$wikiId]);
             }
         }
     }
     $out = [];
     foreach ($wikis as $wikiId => $wiki) {
         $out[$wikiId] = ['id' => $wikiId, 'name' => $wiki['t'], 'url' => $wiki['u'], 'language' => $wiki['l']];
     }
     return $out;
 }
 public function getCuratedContentQuality()
 {
     $curatedContentQualityPerWiki = [];
     $curatedContentQualityTotal = ['totalNumberOfMissingImages' => 0, 'totalNumberOfTooLongTitles' => 0, 'totalNumberOfItems' => 0];
     $wikiID = $this->request->getInt('wikiID', null);
     $totalImages = $this->request->getBool('totalImages', false);
     $totalTitles = $this->request->getBool('totalTitles', false);
     $this->cacheResponseFor(1, self::DAYS);
     $this->getResponse()->setFormat(WikiaResponse::FORMAT_JSON);
     if (empty($wikiID)) {
         $wikiWithCC = WikiFactory::getListOfWikisWithVar(self::CURATED_CONTENT_WG_VAR_ID_PROD, "full", "LIKE", null, "true");
         foreach ($wikiWithCC as $wikiID => $wikiData) {
             $quality = $this->getCuratedContentQualityForWiki($wikiID);
             $curatedContentQualityTotal['totalNumberOfMissingImages'] += $quality['missingImagesCount'];
             $curatedContentQualityTotal['totalNumberOfTooLongTitles'] += $quality['tooLongTitlesCount'];
             $curatedContentQualityTotal['totalNumberOfItems'] += $quality['totalNumberOfItems'];
             $curatedContentQualityPerWiki[$wikiData['u']] = $quality;
         }
         if ($totalImages) {
             $this->response->setVal('item', $curatedContentQualityTotal['totalNumberOfMissingImages']);
             $this->response->setVal('min', ['value' => 0]);
             $this->response->setVal('max', ['value' => $curatedContentQualityTotal['totalNumberOfItems']]);
         } else {
             if ($totalTitles) {
                 $this->response->setVal('item', $curatedContentQualityTotal['totalNumberOfTooLongTitles']);
                 $this->response->setVal('min', ['value' => 0]);
                 $this->response->setVal('max', ['value' => $curatedContentQualityTotal['totalNumberOfItems']]);
             } else {
                 $this->response->setVal('curatedContentQualityTotal', $curatedContentQualityTotal);
                 $this->response->setVal('curatedContentQualityPerWiki', $curatedContentQualityPerWiki);
             }
         }
     } else {
         $quality = $this->getCuratedContentQualityForWiki($wikiID);
         $this->response->setVal('wikiQuality', $quality);
     }
 }