public function getWikisInVisualisationAsCSV()
 {
     wfProfileIn(__METHOD__);
     global $wgOut;
     if (!$this->checkAccess()) {
         wfProfileOut(__METHOD__);
         $this->response->setHeader('Cache-Control', 'no-cache');
         throw new PermissionsException('managewikiahome');
     }
     // get data
     $visualizationLang = $this->request->getVal('lang', $this->wg->contLang->getCode());
     $list = $this->helper->getWikisForStaffTool($this->prepareFilterOptions($visualizationLang, []));
     $collections = $this->getWikiaCollectionsModel()->getList($visualizationLang);
     $verticals = $this->helper->getWikiVerticals();
     // output data in csv format
     $out = fopen('php://memory', 'w');
     // header
     $outHeader = ['ID', 'Vertical', 'Title', 'Is blocked?', 'Is promoted?', 'Is official?'];
     foreach ($collections as $collection) {
         $outHeader[] = 'In collection: ' . $collection['name'] . '?';
     }
     fputcsv($out, $outHeader);
     foreach ($list as $wiki) {
         $outLine = [$wiki->city_id, $verticals[$wiki->city_vertical], $wiki->city_title, CityVisualization::isBlockedWiki($wiki->city_flags) ? 1 : 0, CityVisualization::isPromotedWiki($wiki->city_flags) ? 1 : 0, CityVisualization::isOfficialWiki($wiki->city_flags) ? 1 : 0];
         foreach ($collections as $collection) {
             $outLine[] = in_array($collection['id'], $wiki->collections) ? 1 : 0;
         }
         fputcsv($out, $outLine);
     }
     fseek($out, 0);
     $csv = stream_get_contents($out);
     fclose($out);
     // turn off usual rendering
     $wgOut->disable();
     // set up headers
     $this->response->setFormat(WikiaResponse::FORMAT_RAW);
     $this->response->setHeader('Cache-Control', 'private');
     $this->response->setHeader('Content-Description', 'File Transfer');
     $this->response->setHeader('Content-Disposition', 'attachment; filename=ManageWikiaHomeWikisList-' . $visualizationLang . '.csv');
     $this->response->setHeader('Content-Transfer-Encoding', 'binary');
     $this->response->setContentType('application/octet-stream');
     $this->response->setBody($csv);
     wfProfileOut(__METHOD__);
 }