/**
  * Return report for a given set of results
  *
  * @param array $results results
  * @return string report
  */
 public function render($results, $tool)
 {
     $tmpl = new EasyTemplate(dirname(__FILE__) . '/templates');
     $totalTime = 0;
     foreach ($results as &$fileEntry) {
         $fileEntry['blameUrl'] = $this->getBlameUrl($fileEntry['fileChecked']);
         $totalTime += $fileEntry['time'];
     }
     $stats = array('generationDate' => date('r'), 'totalTime' => $totalTime, 'errorsCount' => 0, 'importantErrorsCount' => 0);
     if ($tool !== '') {
         $stats['tool'] = $tool;
     }
     // count errors reported in all files
     foreach ($results as $entry) {
         $stats['errorsCount'] += $entry['errorsCount'];
         $stats['importantErrorsCount'] += $entry['importantErrorsCount'];
     }
     $tmpl->set('results', $results);
     $tmpl->set('stats', $stats);
     return $tmpl->render('reportHtml');
 }
Exemplo n.º 2
0
 /**
  * Chat tag parser implementation
  */
 public static function parseTag($input, $args, $parser)
 {
     wfProfileIn(__METHOD__);
     $template = new EasyTemplate(dirname(__FILE__) . "/templates/");
     $template->set('linkToSpecialChat', SpecialPage::getTitleFor("Chat")->escapeLocalUrl());
     if (F::app()->checkSkin('oasis')) {
         $html = $template->render('entryPointTag');
     } else {
         $html = $template->render('entryPointTagMonobook');
     }
     wfProfileOut(__METHOD__);
     return $html;
 }
Exemplo n.º 3
0
 /**
  * @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;
 }
Exemplo n.º 4
0
 /**
  * @access public
  * @static
  */
 public static function customSpecialStatistics(&$specialpage, &$text)
 {
     global $wgOut, $wgDBname, $wgLang, $wgRequest, $wgTitle, $wgUser, $wgCityId, $wgHTTPProxy;
     /**
      * read json file with dumps information
      */
     $tmpl = new EasyTemplate(dirname(__FILE__) . "/templates/");
     $index = array();
     $proxy = array();
     if (isset($wgHTTPProxy) && $wgHTTPProxy) {
         $proxy["proxy"] = $wgHTTPProxy;
     } else {
         $proxy["noProxy"] = true;
     }
     $url = self::getUrl($wgDBname, "index.json");
     $json = Http::get($url, 5, $proxy);
     if ($json) {
         wfDebug(__METHOD__ . ": getting informations about last dump from {$url} succeded\n");
         $index = (array) json_decode($json);
     } else {
         wfDebug(__METHOD__ . ": getting informations about last dump from {$url} failed\n");
     }
     /**
      * 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());
     $tmpl->set("curr", array("url" => self::getUrl($wgDBname, "pages_current.xml.gz"), "timestamp" => !empty($index["pages_current.xml.gz"]->mwtimestamp) ? $wgLang->timeanddate($index["pages_current.xml.gz"]->mwtimestamp) : "unknown"));
     $tmpl->set("full", array("url" => self::getUrl($wgDBname, "pages_full.xml.gz"), "timestamp" => !empty($index["pages_full.xml.gz"]->mwtimestamp) ? $wgLang->timeanddate($index["pages_full.xml.gz"]->mwtimestamp) : "unknown"));
     $tmpl->set("index", $index);
     $text .= $tmpl->render("dod");
     if ($wgRequest->wasPosted() && !$wgUser->isAnon()) {
         self::sendMail();
         wfDebug(__METHOD__, ": request for database dump was posted\n");
         $text = Wikia::successbox(wfMsg("dump-database-request-requested")) . $text;
     }
     return true;
 }
Exemplo n.º 5
0
 private function doStats($days = null, $lang = null)
 {
     global $wgOut;
     $where = null;
     if (!empty($days)) {
         $ymd = gmdate('Y-m-d', strtotime("{$days} days ago"));
         $where = array("city_created > '{$ymd}'");
     }
     if (!empty($lang)) {
         $where['city_lang'] = $lang;
     }
     $dbr = WikiFactory::db(DB_SLAVE);
     $res = $dbr->select(array("city_list"), array("date(city_created) as date", "city_public", "count(*) as count"), $where, __METHOD__, array("GROUP BY" => "date(city_created), city_public", "ORDER BY" => "date(city_created) desc"));
     $stats = array();
     while ($row = $dbr->fetchObject($res)) {
         if (!isset($stats[$row->date])) {
             $stats[$row->date] = (object) null;
         }
         $stats[$row->date]->total += $row->count;
         switch ($row->city_public) {
             case 1:
                 $stats[$row->date]->active += $row->count;
                 break;
             case 0:
                 $stats[$row->date]->disabled += $row->count;
                 break;
             case 2:
                 $stats[$row->date]->redirected += $row->count;
                 break;
         }
     }
     $dbr->freeResult($res);
     $wgOut->setPageTitle(strtoupper($lang) . ' Wikis created daily');
     $Tmpl = new EasyTemplate(dirname(__FILE__) . "/templates/");
     $Tmpl->set("stats", $stats);
     $Tmpl->set("days", $days);
     return $Tmpl->render("shortstats");
 }
    function execute($par)
    {
        wfProfileIn(__METHOD__);
        global $wgOut, $wgUser, $wgBlankImgUrl;
        $this->setHeaders();
        // not available for skins different than Oasis
        if (!F::app()->checkSkin('oasis')) {
            $wgOut->addWikiMsg('myhome-switch-to-monaco');
            wfProfileOut(__METHOD__);
            return;
        }
        // choose default view (RT #68074)
        if ($wgUser->isLoggedIn()) {
            $this->defaultView = MyHome::getDefaultView();
            if ($par == '') {
                $par = $this->defaultView;
            }
        } else {
            $this->defaultView = false;
        }
        // watchlist feed
        if ($par == 'watchlist') {
            $this->classWatchlist = "selected";
            // not available for anons
            if ($wgUser->isAnon()) {
                if (get_class(RequestContext::getMain()->getSkin()) == 'SkinOasis') {
                    $wgOut->wrapWikiMsg('<div class="latest-activity-watchlist-login" >$1</div>', array('oasis-activity-watchlist-login', wfGetReturntoParam()));
                } else {
                    $wgOut->wrapWikiMsg('<div id="myhome-log-in">$1</div>', array('myhome-log-in', wfGetReturntoParam()));
                }
                //oasis-activity-watchlist-login
                // RT #23970
                $wgOut->addInlineScript(<<<JS
\$(function() {
\t\$('#myhome-log-in').find('a').click(function(ev) {
\t\topenLogin(ev);
\t});
});
JS
);
                wfProfileOut(__METHOD__);
                return;
            } else {
                $this->feedSelected = 'watchlist';
                $feedProxy = new WatchlistFeedAPIProxy();
                $feedRenderer = new WatchlistFeedRenderer();
            }
        } else {
            //for example: wiki-domain.com/wiki/Special:WikiActivity
            $this->feedSelected = 'activity';
            $feedProxy = new ActivityFeedAPIProxy();
            $feedRenderer = new ActivityFeedRenderer();
        }
        $feedProvider = new DataFeedProvider($feedProxy);
        global $wgJsMimeType, $wgExtensionsPath;
        $wgOut->addScript("<script type=\"{$wgJsMimeType}\" src=\"{$wgExtensionsPath}/wikia/MyHome/WikiActivity.js\"></script>\n");
        $wgOut->addExtensionStyle(AssetsManager::getInstance()->getSassCommonURL('extensions/wikia/MyHome/oasis.scss'));
        wfRunHooks('SpecialWikiActivityExecute', array($wgOut, $wgUser));
        $data = $feedProvider->get(50);
        // this breaks when set to 60...
        // FIXME: do it in AchievementsII extension
        global $wgEnableAchievementsInActivityFeed, $wgEnableAchievementsExt;
        if (!empty($wgEnableAchievementsInActivityFeed) && !empty($wgEnableAchievementsExt)) {
            $wgOut->addExtensionStyle("{$wgExtensionsPath}/wikia/AchievementsII/css/achievements_sidebar.css");
        }
        // use message from MyHome as special page title
        $wgOut->setPageTitle(wfMsg('oasis-activity-header'));
        $template = new EasyTemplate(dirname(__FILE__) . '/templates');
        $template->set('data', $data['results']);
        $showMore = isset($data['query-continue']);
        if ($showMore) {
            $template->set('query_continue', $data['query-continue']);
        }
        if (empty($data['results'])) {
            $template->set('emptyMessage', wfMsgExt("myhome-activity-feed-empty", array('parse')));
        }
        $template->set_vars(array('showMore' => $showMore, 'type' => $this->feedSelected, 'wgBlankImgUrl' => $wgBlankImgUrl));
        $wgOut->addHTML($template->render('activityfeed.oasis'));
        // page header: replace subtitle with navigation
        global $wgHooks;
        $wgHooks['PageHeaderIndexAfterExecute'][] = array(&$this, 'addNavigation');
        wfProfileOut(__METHOD__);
    }
Exemplo n.º 7
0
 /**
  * Generates a template with the login form and registration form already filled into
  * it and other settings populated as well.  This template can then be executed with
  * different EasyTemplates to give different results such as one view for ajax dialogs
  * and one view for standalone pages (such as Special:Signup).
  */
 public static function getTemplateForCombinedForms($static = false, $lastmsg = "", &$ajaxLoginForm = "")
 {
     global $wgRequest;
     // Setup the data for the templates, similar to GetComboAjaxLogin.
     if (session_id() == '') {
         wfSetupSession();
     }
     // TODO: Invstigate why this was here.
     //if ($wgRequest->getCheck( 'wpCreateaccount' )) {
     //	return "error";
     //}
     $tmpl = new EasyTemplate(dirname(__FILE__) . '/templates/');
     $response = new AjaxResponse();
     $type = $wgRequest->getVal('type', '');
     if (!wfReadOnly()) {
         if (empty($ajaxLoginForm)) {
             $ajaxLoginForm = new AjaxLoginForm($wgRequest);
         }
         $ajaxLoginForm->execute($type);
         if (!empty($ajaxLoginForm->ajaxTemplate)) {
             $lastmsg = $ajaxLoginForm->ajaxTemplate->data['message'];
             $tmpl->set('message', $ajaxLoginForm->ajaxTemplate->data['message']);
             $tmpl->set('messagetype', $ajaxLoginForm->ajaxTemplate->data['messagetype']);
         }
         $tmpl->set("registerAjax", $ajaxLoginForm->ajaxRender());
     }
     $isReadOnly = wfReadOnly() ? 1 : 0;
     $tmpl->set("isReadOnly", $isReadOnly);
     if (!LoginForm::getLoginToken()) {
         LoginForm::setLoginToken();
     }
     $tmpl->set("loginToken", LoginForm::getLoginToken());
     if (!LoginForm::getCreateaccountToken()) {
         LoginForm::setCreateaccountToken();
     }
     $tmpl->set("createToken", LoginForm::getCreateaccountToken());
     // Use the existing settings to generate the login portion of the form, which will then
     // be fed back into the bigger template in this case (it is not always fed into ComboAjaxLogin template).
     $returnto = $wgRequest->getVal('returnto', '');
     if (!($returnto == '')) {
         $returnto = "&returnto=" . wfUrlencode($returnto);
     }
     $returntoquery = $wgRequest->getVal('returntoquery', '');
     if (!($returntoquery == '')) {
         $returntoquery = "&returntoquery=" . wfUrlencode($returntoquery);
     }
     $loginaction = Skin::makeSpecialUrl('Signup', "type=login&action=submitlogin" . $returnto . $returntoquery);
     $signupaction = Skin::makeSpecialUrl('Signup', "type=signup" . $returnto . $returntoquery);
     $tmpl->set("loginaction", $loginaction);
     $tmpl->set("signupaction", $signupaction);
     $tmpl->set("loginerror", $lastmsg);
     $tmpl->set("actiontype", $type);
     $tmpl->set("showRegister", false);
     $tmpl->set("showLogin", false);
     if ($static) {
         if (strtolower($type) == "login") {
             $tmpl->set("showLogin", true);
         } else {
             if (!$isReadOnly) {
                 $tmpl->set("showRegister", true);
             }
         }
     }
     $tmpl->set("ajaxLoginComponent", $tmpl->render('AjaxLoginComponent'));
     return $tmpl;
 }
Exemplo n.º 8
0
 public function execute($subpage)
 {
     wfProfileIn(__METHOD__);
     $this->games = new ScavengerHuntGames();
     $this->setHeaders();
     $this->mTitle = SpecialPage::getTitleFor('scavengerhunt');
     if ($this->isRestricted() && !$this->userCanExecute($this->user)) {
         $this->displayRestrictionError();
         wfProfileOut(__METHOD__);
         return;
     }
     @(list($action, $id) = explode('/', $subpage));
     $action = !empty($action) ? $action : 'list';
     $id = (int) $id;
     $game = $this->games->findById($id);
     if (empty($game)) {
         $game = $this->games->newGame();
     }
     // check edit tokens
     if ($this->request->wasPosted() && !$this->user->matchEditToken($this->request->getVal('wpEditToken'))) {
         BannerNotificationsController::addConfirmation(wfMsg('scavengerhunt-edit-token-mismatch'), BannerNotificationsController::CONFIRMATION_ERROR);
         $this->out->redirect($this->mTitle->getFullUrl());
         wfProfileOut(__METHOD__);
         return;
     }
     $this->out->addStyle(AssetsManager::getInstance()->getSassCommonURL('extensions/wikia/ScavengerHunt/css/scavenger-special.scss'));
     $this->out->addStyle(AssetsManager::getInstance()->getSassCommonURL('extensions/wikia/ScavengerHunt/css/scavenger-game.scss'));
     $this->out->addScriptFile($this->app->getGlobal('wgExtensionsPath') . '/wikia/ScavengerHunt/js/scavenger-special.js');
     $template = new EasyTemplate(dirname(__FILE__) . '/templates/');
     $errors = array();
     switch ($action) {
         case 'list':
             $button = '<a class="wikia-button scavengerhunt-add-button" href="' . $this->mTitle->getFullUrl() . '/add">' . Xml::element('img', array('class' => 'sprite new', 'src' => $this->app->getGlobal('wgBlankImgUrl'))) . wfMsg('scavengerhunt-button-add') . '</a>';
             $this->out->mPagetitle .= $button;
             $this->out->mPageLinkTitle = true;
             // Games list
             $pager = new ScavengerHuntGamesPager($this->games, $this->mTitle->getFullUrl(), $template);
             $this->out->addHTML($pager->getBody() . $pager->getNavigationBar());
             break;
         case 'toggle':
             $enable = !$game->isEnabled();
             $game->setEnabled($enable);
             $errors = $this->validateGame($game);
             if (empty($errors['errors'])) {
                 $game->save();
                 BannerNotificationsController::addConfirmation($enable ? wfMsg('scavengerhunt-game-has-been-enabled') : wfMsg('scavengerhunt-game-has-been-disabled'));
                 //success! go to the list
                 $this->out->redirect($this->mTitle->getFullUrl());
                 wfProfileOut(__METHOD__);
                 return;
             } else {
                 //failure - display errors
                 $game->setEnabled(false);
             }
             // no "break" on purpose - wasPosted() will return false but we'll display proper template
         // no "break" on purpose - wasPosted() will return false but we'll display proper template
         case 'edit':
             if ($this->request->wasPosted()) {
                 if ($this->request->getVal('enable')) {
                     $enabled = !$this->request->getVal('prevEnabled');
                     $game->setEnabled($enabled);
                     $errors = $this->validateGame($game);
                     if (empty($errors['errors'])) {
                         $game->save();
                         BannerNotificationsController::addConfirmation($enabled ? wfMsg('scavengerhunt-game-has-been-enabled') : wfMsg('scavengerhunt-game-has-been-disabled'));
                         $this->out->redirect($this->mTitle->getFullUrl() . "/edit/{$id}");
                         wfProfileOut(__METHOD__);
                         return;
                     } else {
                         $game->setEnabled(false);
                     }
                 } else {
                     if ($this->request->getVal('delete')) {
                         $game->delete();
                         BannerNotificationsController::addConfirmation(wfMsg('scavengerhunt-game-has-been-deleted'));
                         $this->out->redirect($this->mTitle->getFullUrl());
                         wfProfileOut(__METHOD__);
                         return;
                     }
                 }
             }
             // no "break" on purpose
         // no "break" on purpose
         case 'add':
             if ($this->request->wasPosted()) {
                 if ($this->request->getVal('save')) {
                     $game = $this->updatePostedGame($game);
                     // move the validation process to the moment of enabling the game
                     $errors = $this->validateGame($game);
                     // save changes
                     if (empty($errors['errors']) && $game->save()) {
                         BannerNotificationsController::addConfirmation($action == 'add' ? wfMsg('scavengerhunt-game-has-been-created') : wfMsg('scavengerhunt-game-has-been-saved'));
                         $this->out->redirect($this->mTitle->getFullUrl());
                         wfProfileOut(__METHOD__);
                         return;
                     } else {
                         BannerNotificationsController::addConfirmation(wfMsg('scavengerhunt-game-has-not-been-saved'), BannerNotificationsController::CONFIRMATION_NOTIFY);
                     }
                 }
             }
             $template->set('errors', isset($errors['errors']) ? $errors['errors'] : array());
             $template->set('highlight', isset($errors['highlight']) ? $errors['highlight'] : array());
             $template->set('editToken', $this->user->getEditToken());
             $template->set_vars($this->getTemplateVarsFromGame($game));
             $this->out->addHTML($template->render('form'));
             break;
     }
     wfProfileOut(__METHOD__);
 }
Exemplo n.º 9
0
 public static function afterAjaxLoginHTML(&$html)
 {
     $tmpl = new EasyTemplate(dirname(__FILE__) . '/templates/');
     if (!LoginForm::getLoginToken()) {
         LoginForm::setLoginToken();
     }
     $tmpl->set("loginToken", LoginForm::getLoginToken());
     $tmpl->set("fbButtton", FBConnect::getFBButton("sendToConnectOnLoginForSpecificForm();", "fbPrefsConnect"));
     $html = $tmpl->execute('ajaxLoginMerge');
     return true;
 }