public static function newFromArray($notices)
 {
     $obj = new self();
     foreach ($notices as $text) {
         $obj->add(WF::build('EditPageNotice', array($text)));
     }
     return $obj;
 }
 protected function renderImage($filename, $orientation = self::RIGHT)
 {
     $parser = WF::build('Parser');
     $parser->setOutputType(OT_HTML);
     $parserOptions = WF::build('ParserOptions');
     $fakeTitle = WF::build('FakeTitle', array(''));
     return $parser->parse($this->getWikiText($filename, $orientation), $fakeTitle, $parserOptions, false)->getText();
 }
 function __construct()
 {
     parent::__construct('SpellCheckerInfo');
     $this->app = WF::build('App');
     $this->out = $this->app->getGlobal('wgOut');
     $this->request = $this->app->getGlobal('wgRequest');
     $this->title = $this->app->getGlobal('wgTitle');
 }
 public function getGameCacheValue()
 {
     $app = WF::build('App');
     $factory = WF::build('ScavengerHuntGames');
     $gameId = $this->getVal('gameId', '');
     $readWrite = $this->getVal('readwrite', 0);
     $key = wfSharedMemcKey('ScavengerHuntGameIndex', $gameId, $readWrite ? 1 : 0, ScavengerHuntGames::CACHE_VERSION);
     $this->setVal('key', $key);
     $this->setVal('response', unserialize($factory->getCache()->get($key)));
 }
 public function __construct($url)
 {
     $this->feed = $this->getFromCache($url);
     if (empty($this->feed)) {
         $rssContent = Http::get($url);
         $this->feed = new SimplePie();
         $this->feed->set_raw_data($rssContent);
         $this->feed->set_cache_duration(0);
         $this->feed->init();
         $this->saveToCache($url, $this->feed);
     }
     $this->blacklistedSeries = WF::build('App')->getGlobal('wgCrunchyrollBlacklistedSeries');
 }
 public function testEditNotices()
 {
     $title = WF::build('Title', array('NewArticle'), 'newFromText');
     $editPage = $this->editPageFactory($title);
     $testNotice1Body = '<div>1st notice</div>';
     $testNotice1Key = 'TESTKEY1';
     $testNotice2Body = '<div>2nd notice</div>';
     $testNotice2Key = 'TESTKEY2';
     $editPage->addEditNotice($testNotice1Body, $testNotice1Key);
     $editPage->addEditNotice($testNotice2Body, $testNotice2Key);
     $this->assertEquals(array(md5($testNotice1Key) => '1st notice', md5($testNotice2Key) => '2nd notice'), $editPage->getNotices());
     $this->assertEquals($testNotice1Body . $testNotice2Body, $editPage->getNoticesHtml());
 }
Example #7
0
 function execute()
 {
     global $wgOut, $wgAVStag;
     $dataMaper = new Amazon_DataMapper();
     $fromAmazon = $dataMaper->findItemsByTag($wgAVStag);
     foreach ($fromAmazon as $key => $value) {
         $data[$key]['image'] = $value->ImageSets->ImageSet->LargeImage;
         $data[$key]['season'] = $value->ItemAttributes->SeasonSequence;
         $data[$key]['episode'] = $value->ItemAttributes->EpisodeSequence;
         $data[$key]['title'] = $value->ItemAttributes->Title;
         $data[$key]['video-widget'] = $dataMaper->findWidgetByAsin($key);
         $data[$key]['video-widget-code'] = htmlspecialchars('<avs_video align="right"  asin="' . $key . '" />');
         $data[$key]['image-widget-code'] = htmlspecialchars('<avs_image_link align="right" asin="' . $key . '" />');
     }
     $oTmpl = WF::build('EasyTemplate', array(dirname(__FILE__) . "/templates/"));
     $oTmpl->set_vars(array("data" => $data));
     $wgOut->addHTML($oTmpl->render("list"));
 }
Example #8
0
 public function getFakeRow()
 {
     $article = WF::build('ScavengerHuntGames')->newGameArticle();
     $article->setArticleName(self::MOCK_TEXT);
     $article->setWikiId(self::LANDING_WIKI_ID);
     foreach (array('spriteNotFound', 'spriteInProgressBar', 'spriteInProgressBarHover', 'spriteInProgressBarNotFound') as $spriteName) {
         $methodName = 'set' . ucfirst($spriteName);
         $article->{$methodName}($this->getFakeSprite());
     }
     $article->setSpriteNotFound(self::MOCK_URL);
     $article->setClueText(self::MOCK_TEXT);
     $article->setCongrats(self::MOCK_TEXT);
     $row = new stdClass();
     $row->game_id = self::MOCK_GAME_ID;
     $row->wiki_id = self::LANDING_WIKI_ID;
     $row->game_name = self::MOCK_TEXT;
     $row->game_is_enabled = 0;
     $row->game_data = serialize(array('clueColor' => '#fff', 'clueFont' => 'bold', 'clueSize' => '14', 'facebookImg' => '', 'facebookDescription' => '', 'name' => self::MOCK_TEXT, 'hash' => self::MOCK_TEXT, 'landingTitle' => self::MOCK_TEXT, 'landingArticleName' => self::MOCK_TEXT, 'landingArticleWikiId' => self::LANDING_WIKI_ID, 'landingButtonText' => self::MOCK_TEXT, 'landingButtonX' => self::MOCK_INT, 'landingButtonY' => self::MOCK_INT, 'startingClueTitle' => self::MOCK_TEXT, 'startingClueText' => self::MOCK_TEXT, 'startingClueButtonText' => self::MOCK_TEXT, 'startingClueButtonTarget' => self::MOCK_URL, 'entryFormTitle' => self::MOCK_TEXT, 'entryFormText' => self::MOCK_TEXT, 'entryFormButtonText' => self::MOCK_TEXT, 'entryFormQuestion' => self::MOCK_TEXT, 'goodbyeTitle' => self::MOCK_TEXT, 'goodbyeText' => self::MOCK_TEXT, 'goodbyeImage' => self::MOCK_TEXT, 'spriteImg' => self::MOCK_URL, 'entryFormEmail' => self::MOCK_TEXT, 'entryFormUsername' => self::MOCK_TEXT, 'articles' => array($article), 'progressBarBackgroundSprite' => $this->getFakeSprite(), 'progressBarExitSprite' => $this->getFakeSprite(), 'progressBarHintLabel' => $this->getFakeSprite(), 'startPopupSprite' => $this->getFakeSprite(), 'finishPopupSprite' => $this->getFakeSprite(), 'landingButtonX' => 1, 'landingButtonY' => 1));
     return $row;
 }
 /**
  * @dataProvider conditions
  */
 public function testGameNotLoaded($isUserAnon, $cookieValue)
 {
     // starting conditions
     $scavengerHunt = WF::build('ScavengerHunt');
     $scavengerHunt->setGame(null);
     $mockedUser = $this->getMock('User', array('isAnon', 'getName'));
     $mockedUser->expects($this->any())->method('isAnon')->will($this->returnValue(self::MOCK_USER_NAME));
     $mockedUser->expects($this->any())->method('getName')->will($this->returnValue(self::MOCK_USER_NAME));
     $this->mockClass('User', $mockedUser);
     $_COOKIE[$scavengerHunt->getHuntIdKey()] = $cookieValue;
     // mocks
     $oFakeGame = $this->getFakeGame();
     // test
     $oFinalGame = $scavengerHunt->getActiveGame();
     if (empty($cookieValue)) {
         $this->assertEmpty($oFinalGame);
     } else {
         $this->assertNotEmpty($oFinalGame);
         $oFakeGameID = $oFinalGame->getId();
         $this->assertEquals($oFakeGameID, $oFinalGame->getId());
     }
 }
 /**
  * @desc enable/disable feature
  * @requestParam string enabled [true/false]
  * @requestParam string feature	(extension variable)
  * @responseParam string result [OK/error]
  * @responseParam string error (error message)
  */
 public function toggleFeature()
 {
     $enabled = $this->getVal('enabled', null);
     $feature = $this->getVal('feature', null);
     // check user permission
     if (!$this->wg->User->isAllowed('wikifeatures')) {
         $this->setVal('result', 'error');
         $this->setVal('error', $this->wf->Msg('wikifeatures-error-permission'));
         return;
     }
     // check if feature given is actually something we allow setting
     if (!in_array($feature, $this->wg->WikiFeatures['normal']) && !in_array($feature, $this->wg->WikiFeatures['labs'])) {
         $this->setVal('result', 'error');
         $this->setVal('error', $this->wf->Msg('wikifeatures-error-invalid-parameter'));
         return;
     }
     // validate feature: valid value ($enabled and $feature), check if Feature exists ($wg_value)
     $wg_value = WikiFactory::getVarByName($feature, $this->wg->CityId);
     if ($enabled != 'true' && $enabled != 'false' || empty($feature) || empty($wg_value)) {
         $this->setVal('result', 'error');
         $this->setVal('error', $this->wf->Msg('wikifeatures-error-invalid-parameter'));
         return;
     }
     $enabled = $enabled == 'true';
     $logMsg = "set extension option: {$feature} = " . var_export($enabled, TRUE);
     $log = WF::build('LogPage', array('wikifeatures'));
     $log->addEntry('wikifeatures', SpecialPage::getTitleFor('WikiFeatures'), $logMsg, array());
     WikiFactory::setVarByName($feature, $this->wg->CityId, $enabled, "WikiFeatures");
     if ($feature == 'wgShowTopListsInCreatePage') {
         WikiFactory::setVarByName('wgEnableTopListsExt', $this->wg->CityId, $enabled, "WikiFeatures");
     }
     // clear cache for active wikis
     WikiFactory::clearCache($this->wg->CityId);
     $this->wg->Memc->delete(WikiFeaturesHelper::getInstance()->getMemcKeyNumActiveWikis($feature));
     $this->setVal('result', 'ok');
 }
 public function getGoodbyeHtml(ScavengerHuntGame $game)
 {
     // build entry form html
     $template = WF::build('EasyTemplate', array(dirname(__FILE__) . '/templates/'));
     /* @var $template EasyTemplate */
     $template->set_vars(array('title' => $game->getGoodbyeTitle(), 'text' => $this->parseCached($game->getGoodbyeText()), 'shareUrl' => $game->getLandingTitle(), 'imageSrc' => $game->getSpriteImg(), 'imgSprite' => $game->getFinishPopupSprite()));
     return $template->render('modal-clue');
 }
 public function getFogbugzService()
 {
     if ($this->fogbugzService == null) {
         $this->fogbugzService = WF::build('FogbugzService', array($this->wg->fogbugzAPIConfig['apiUrl'], $this->wg->fogbugzAPIConfig['username'], $this->wg->fogbugzAPIConfig['password'], $this->app->getGlobal('wgHTTPProxy')));
     }
     return $this->fogbugzService;
 }
Example #13
0
 protected function getKey($prefix, $cityId = false)
 {
     if (empty($cityId)) {
         $cityId = WF::build('App')->getGlobal('wgCityId');
     }
     return wfSharedMemcKey('WikiaMetrics2', $prefix, $cityId);
 }
Example #14
0
 /**
  * Count total users
  * @return Integer
  */
 public function users()
 {
     /**
      * wikia change
      * cache number of users for 12hours
      * it's not important to have exact numbers there
      */
     $cache = WF::build("App")->getGlobal("wgMemc");
     $this->mUsers = $cache->get(wfSharedMemcKey("registered-users-number"));
     if (empty($this->mUsers)) {
         $this->mUsers = $this->dbshared->selectField('`user`', 'COUNT(*)', '', __METHOD__);
         $cache->set(wfSharedMemcKey("registered-users-number"), $this->mUsers, 60 * 60 * 12);
     }
     return $this->mUsers;
 }
Example #15
0
 /**
  * This is the ajax-endpoint that the node server will connect to in order to get the currently logged-in user's info.
  * The node server will pass the same cookies that the client has set, and this will allow this ajax request to be
  * part of the same sesssion that the user already has going.  By doing this, the user's existing wikia login session
  * can be used, so they don't need to re-login for us to know that they are legitimately authorized to use the chat or not.
  *
  * The returned info is just a custom subset of what the node server needs and does not contain an exhaustive list of rights.
  *
  * The 'isLoggedIn' field and 'canChat' field of the result should be checked by the calling code before allowing
  * the user to chat.  This is the last line of security against any users attemptin to circumvent our protections.  Otherwise,
  * a banned user could copy the entire client code (HTML/JS/etc.) from an unblocked user, then run that code while logged in as
  * under a banned account, and they would still be given access.
  *
  * The returned 'isChatMod' field is boolean based on whether the user is a chat moderator on the current wiki.
  *
  * If the user is not allowed to chat, an error message is returned (which can be shown to the user).
  */
 public static function getUserInfo()
 {
     global $wgMemc, $wgServer, $wgArticlePath, $wgRequest, $wgCityId, $wgContLang, $wgIP;
     wfProfileIn(__METHOD__);
     $data = $wgMemc->get($wgRequest->getVal('key'), false);
     if (empty($data)) {
         return array('errorMsg' => wfMsg('chat-room-is-not-on-this-wiki'));
     }
     $user = User::newFromId($data['user_id']);
     if (empty($user) || !$user->isLoggedIn() || $user->getName() != $wgRequest->getVal('name', '')) {
         wfProfileOut(__METHOD__);
         return array('errorMsg' => wfMsg('chat-room-is-not-on-this-wiki'));
     }
     $isCanGiveChatMode = false;
     $userChangeableGroups = $user->changeableGroups();
     if (in_array('chatmoderator', $userChangeableGroups['add'])) {
         $isCanGiveChatMode = true;
     }
     // First, check if they can chat on this wiki.
     $retVal = array('canChat' => Chat::canChat($user), 'isLoggedIn' => $user->isLoggedIn(), 'isChatMod' => $user->isAllowed('chatmoderator'), 'isCanGiveChatMode' => $isCanGiveChatMode, 'isStaff' => $user->isAllowed('chatstaff'), 'username' => $user->getName(), 'avatarSrc' => AvatarService::getAvatarUrl($user->getName(), self::CHAT_AVATAR_DIMENSION), 'editCount' => "", 'since' => '', 'activeBasket' => ChatHelper::getServerBasket(), 'wgCityId' => $wgCityId, 'wgServer' => $wgServer, 'wgArticlePath' => $wgArticlePath);
     // Figure out the error message to return (i18n is done on this side).
     if ($retVal['isLoggedIn'] === false) {
         $retVal['errorMsg'] = wfMsg('chat-no-login');
     } else {
         if ($retVal['canChat'] === false) {
             $retVal['errorMsg'] = wfMsg('chat-you-are-banned-text');
         }
     }
     // If the user is approved to chat, make sure the roomId provided is for this wiki.
     // Users may be banned on the wiki of the room, but not on this wiki for example, so this prevents cross-wiki chat hacks.
     if ($retVal['canChat']) {
         $roomId = $wgRequest->getVal('roomId');
         $cityIdOfRoom = NodeApiClient::getCityIdForRoom($roomId);
         if ($wgCityId !== $cityIdOfRoom) {
             $retVal['canChat'] = false;
             // don't let the user chat in the room they requested.
             $retVal['errorMsg'] = wfMsg('chat-room-is-not-on-this-wiki');
         }
     }
     // If the user can chat, dig up some other stats which are a little more expensive to compute.
     if ($retVal['canChat']) {
         $userStatsService = new UserStatsService($user->getId());
         $stats = $userStatsService->getStats();
         // NOTE: This is attached to the user so it will be in the wiki's content language instead of wgLang (which it normally will).
         $stats['edits'] = $wgContLang->formatNum($stats['edits']);
         if (empty($stats['date'])) {
             // If the user has not edited on this wiki, don't show anything
             $retVal['since'] = "";
         } else {
             // this results goes to chat server, which obiously has no user lang
             // so we just return a short month name key - it has to be translated on client side
             $date = getdate(wfTimestamp(TS_UNIX, $stats['date']));
             $retVal['since'] = $date;
         }
         $retVal['editCount'] = $stats['edits'];
     }
     if ($retVal['isLoggedIn'] && $retVal['canChat']) {
         // record the IP of the connecting user.
         // use memcache so we order only one (user, ip) pair each day
         $ip = $wgRequest->getVal('address');
         $memcKey = self::getUserIPMemcKey($data['user_id'], $ip, date("Y-m-d"));
         $entry = $wgMemc->get($memcKey, false);
         if (empty($entry)) {
             $wgMemc->set($memcKey, true, 86400);
             $log = WF::build('LogPage', array('chatconnect', false, false));
             $log->addEntry('chatconnect', SpecialPage::getTitleFor('Chat'), '', array($ip), $user);
             $dbw = wfGetDB(DB_MASTER);
             $cuc_id = $dbw->nextSequenceValue('cu_changes_cu_id_seq');
             $rcRow = array('cuc_id' => $cuc_id, 'cuc_namespace' => NS_SPECIAL, 'cuc_title' => 'Chat', 'cuc_minor' => 0, 'cuc_user' => $user->getID(), 'cuc_user_text' => $user->getName(), 'cuc_actiontext' => wfMsgForContent('chat-checkuser-join-action'), 'cuc_comment' => '', 'cuc_this_oldid' => 0, 'cuc_last_oldid' => 0, 'cuc_type' => CUC_TYPE_CHAT, 'cuc_timestamp' => $dbw->timestamp(), 'cuc_ip' => IP::sanitizeIP($ip), 'cuc_ip_hex' => $ip ? IP::toHex($ip) : null, 'cuc_xff' => '', 'cuc_xff_hex' => null, 'cuc_agent' => null);
             $dbw->insert('cu_changes', $rcRow, __METHOD__);
             $dbw->commit();
         }
     }
     wfProfileOut(__METHOD__);
     return $retVal;
 }
 protected function analyzeHtml($html, &$more = null)
 {
     $pos = 0;
     $tags = array();
     preg_match_all("/<(\\/?)(div|table)[^>]*>/isU", $html, $tags, PREG_SET_ORDER | PREG_OFFSET_CAPTURE);
     $depth = 0;
     $chunks = array();
     foreach ($tags as $tag) {
         $tagcontent = $tag[0][0];
         $tagstartpos = $tag[0][1];
         $tagendpos = $tagstartpos + strlen($tagcontent);
         $tagopening = empty($tag[1][0]);
         if ($tagopening) {
             if ($depth == 0) {
                 $remnant = trim(substr($html, $pos, $tagstartpos - $pos));
                 if (!empty($remnant)) {
                     $chunks[] = array($pos, $tagstartpos - $pos, $remnant, false);
                 }
                 $pos = $tagstartpos;
                 $sectiontagstartpos = $tagstartpos;
                 $sectiontagcontent = $tagcontent;
             }
             $depth++;
         } else {
             $depth--;
             if ($depth == 0) {
                 $id = false;
                 if (preg_match("/(?:id|class)=[\"']?([^\"'> ]+)[\"'>\t ]/isU", $sectiontagcontent, $matches)) {
                     $id = $matches[1];
                 }
                 $content = trim(substr($html, $sectiontagstartpos, $tagendpos - $sectiontagstartpos));
                 $chunks[] = array($sectiontagstartpos, $tagendpos - $sectiontagstartpos, $content, $id);
                 $pos = $tagendpos;
             }
             if ($depth < 0) {
                 $depth = 0;
             }
         }
     }
     $remnant = trim(substr($html, $pos));
     if (!empty($remnant)) {
         $chunks[] = array($pos, strlen($html) - $pos, $remnant, false);
     }
     $notices = array();
     foreach ($chunks as $chunk) {
         if ($chunk[3]) {
             $notice = WF::build('EditPageNotice', array($chunk[2], $chunk[3]));
             if ($notice->getSummary() != '') {
                 $this->notices->add($notice);
                 $notices[] = $notice;
             }
         }
     }
     if (count($notices) < count($chunks)) {
         $more = true;
     }
     return $notices;
 }
 /**
  * @return array|bool|Mixed
  */
 public function getJSParamsForCurrent()
 {
     $cityId = $this->app->wg->cityId;
     $articleName = $this->app->wg->title->getPartialURL();
     if (!$this->isPagePartOfAnyHunt($cityId, $articleName)) {
         return false;
     }
     $key = wfSharedMemcKey('ScavengerHuntIndexer', $cityId, md5($articleName));
     $value = $this->getCache()->get($key);
     if (empty($value)) {
         self::log('performance', __METHOD__);
         $enabledGames = $this->getEnabledGames();
         $value = array();
         foreach ($enabledGames as $game) {
             $template = WF::build('EasyTemplate', array(dirname(__FILE__) . '/../templates/'));
             /* @var $template EasyTemplate */
             $template->set_vars(array('game' => $game));
             if ($game->getLandingArticleName() == $articleName) {
                 $value['wgScavengerHuntStart'][] = (int) $game->getId();
                 $value['wgScavengerHuntStartMsg'][] = $game->getLandingButtonText();
                 $value['wgScavengerHuntStartPosition'][] = array('X' => $game->getLandingButtonX(), 'Y' => $game->getLandingButtonY());
                 $value['wgScavengerHuntStartClueTitle'][] = $game->getStartingClueTitle();
                 $value['wgScavengerHuntSpriteImg'][] = $game->getSpriteImg();
                 $value['wgScavengerHuntSprite'][] = ScavengerHunt::formatSpriteForJS(array('sprite' => $game->getStartPopupSprite()), 'sprite');
                 $value['wgScavengerHuntStartClueHtml'][] = $template->render('modal-starting');
             }
         }
         $value['wgCookieDomain'] = $this->app->wg->cookieDomain;
         $this->getCache()->set($key, $value, self::CACHE_TTL);
     } else {
         self::log('performance(cache)', __METHOD__);
     }
     return $value;
 }
<?php

// セッションスタート
session_start();
// クラス呼び出し
require 'warning_function_class.php';
$on_or_off = new WF();
// ログイン状態のチェック
if (!isset($_SESSION["USERID"])) {
    header("Location: admin_screen_login.php");
    exit;
}
// ON/OFFの設定によりクラス内の変数の値を変更
if (isset($_POST["on_off"])) {
    if ($_POST["on_off"] == 1) {
        $on_or_off->on();
        $on_off = $on_or_off->wfr;
        $_SESSION["on_off"] = $on_off;
    } else {
        $on_or_off->off();
        $on_off = $on_or_off->wfr;
        $_SESSION["on_off"] = $on_off;
    }
} else {
    if (isset($_SESSION["on_off"])) {
        $on_off = $_SESSION["on_off"];
    }
}
/*保留
if ($_SERVER["REQUEST_METHOD"] == "POST") {
	$on_off = $_SESSION["ONOFF"];                           
Example #19
0
 function testDuplicateCreate()
 {
     $this->markTestSkipped('Randomly failing due to master/slave lag');
     // FIXME
     /**  @var $poll WikiaPollAjax */
     $poll = WF::build('WikiaPollAjax');
     $wgRequest = $this->getMock('WebRequest', array('getVal', 'getArray'));
     $wgRequest->expects($this->at(0))->method('getVal')->with($this->equalTo('question'))->will($this->returnValue("Unit Testing"));
     $wgRequest->expects($this->any())->method('getArray')->with($this->equalTo('answer'))->will($this->returnValue(array("One", "Two", "Three")));
     $wgRequest->expects($this->any())->method('getIP')->will($this->returnValue('127.0.0.1'));
     $this->mockGlobalVariable('wgRequest', $wgRequest);
     $this->mockApp();
     // Create the same poll twice
     $result = $poll->create();
     $this->assertType("array", $result, "Create duplicate result is array");
     $this->assertEquals(false, $result["success"], "Create duplicate Poll success flag is false");
     $this->assertType("string", $result["error"], "Create duplicate Poll results in an error");
     // clean up
     $title = Title::newFromText("Unit Testing", NS_WIKIA_POLL);
     $article = new Article($title, NS_WIKIA_POLL);
     /* @var $article WikiPage */
     if ($article->exists()) {
         $article->doDelete("Unit Testing", true);
     }
 }
 public function execute($subpage)
 {
     wfProfileIn(__METHOD__);
     $this->games = WF::build('ScavengerHuntGames');
     $this->setHeaders();
     $this->mTitle = SpecialPage::getTitleFor('scavengerhunt');
     if ($this->isRestricted() && !$this->userCanExecute($this->user)) {
         $this->displayRestrictionError();
         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'))) {
         NotificationsController::addConfirmation(wfMsg('scavengerhunt-edit-token-mismatch'), NotificationsController::CONFIRMATION_ERROR);
         $this->out->redirect($this->mTitle->getFullUrl());
         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 = WF::build('EasyTemplate', array(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 = WF::build('ScavengerHuntGamesPager', array($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();
                 NotificationsController::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());
                 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();
                         NotificationsController::addConfirmation($enabled ? wfMsg('scavengerhunt-game-has-been-enabled') : wfMsg('scavengerhunt-game-has-been-disabled'));
                         $this->out->redirect($this->mTitle->getFullUrl() . "/edit/{$id}");
                         return;
                     } else {
                         $game->setEnabled(false);
                     }
                 } else {
                     if ($this->request->getVal('delete')) {
                         $game->delete();
                         NotificationsController::addConfirmation(wfMsg('scavengerhunt-game-has-been-deleted'));
                         $this->out->redirect($this->mTitle->getFullUrl());
                         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()) {
                         NotificationsController::addConfirmation($action == 'add' ? wfMsg('scavengerhunt-game-has-been-created') : wfMsg('scavengerhunt-game-has-been-saved'));
                         $this->out->redirect($this->mTitle->getFullUrl());
                         return;
                     } else {
                         NotificationsController::addConfirmation(wfMsg('scavengerhunt-game-has-not-been-saved'), NotificationsController::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__);
 }
 function isWidePage()
 {
     global $wgTitle;
     // Custom edit pages are mostly using special pages
     // and the default Oasis logic is not to show any rail modules
     // there so we need to tweak it
     if ($wgTitle->getNamespace() == NS_SPECIAL) {
         return false;
     }
     // Some nasty trick to make BodyModule think we are not
     // on edit page so it will make proper list of modules
     $action = $this->request->setVal('action', null);
     $diff = $this->request->setVal('diff', null);
     $railModuleList = WF::build('BodyController')->getRailModuleList();
     $this->request->setVal('action', $action);
     $this->request->setVal('diff', $diff);
     return empty($railModuleList);
 }
 /**
  * Get HTML of notices shown above the editor and use show it as custom dismissable notice
  */
 protected function showHeader()
 {
     $this->app->wf->ProfileIn(__METHOD__);
     $oldHtml = $this->out->getHTML();
     $this->out->clearHTML();
     $bridge = WF::build('EditPageOutputBridge', array($this, $this->mCoreEditNotices));
     /* @var $bridge EditPageOutputBridge */
     parent::showHeader();
     // handle notices related to edit undo
     if ($this->editFormPageTop != '') {
         $bridge->getMockObject()->addHTML($this->editFormPageTop);
         $this->editFormPageTop = '';
     }
     $bridge->close();
     // restore state of output
     $this->out->clearHTML();
     $this->out->addHTML($oldHtml);
     $this->app->wf->ProfileOut(__METHOD__);
 }
Example #23
0
 protected function getGapiResults()
 {
     global $wgWikiaGAAccount, $wgWikiaGALogin, $wgWikiaGAPassword, $wgHTTPProxy;
     $retries = self::SD_GAPI_RETRIES;
     $results = array();
     $dimensions = $this->frequency->getGapiDateDimensionsTable();
     $sortBy = $this->frequency->getGapiSortingDate();
     if (!empty($this->extraDimension)) {
         $dimensions[] = $this->extraDimension;
         $sortBy[] = $this->extraDimension;
     }
     $ga = WF::build('gapi', array($wgWikiaGALogin, $wgWikiaGAPassword, null, 'curl', $wgHTTPProxy));
     while ($retries > 0 && empty($results)) {
         try {
             $ga->requestReportData($this->getAccount(), $dimensions, $this->GAPImetrics, $sortBy, $this->getGAFilters(), $this->startDate, $this->endDate, 1, 10000);
             $results = $ga->getResults();
             break;
         } catch (Exception $e) {
             $retries--;
             sleep(1);
             Wikia::log(__METHOD__, 'jku', $e->getMessage());
         }
     }
     return $results;
 }
Example #24
0
 /**
  * Main WF Instance
  *
  * Ensures only one instance of WF is loaded or can be loaded.
  *
  * @since 6.0.0
  * @static
  * @see WF()
  * @return Main WF instance
  */
 public static function instance()
 {
     if (is_null(self::$_instance)) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Example #25
0
/**
 * Returns the main instance of WF to prevent the need to use globals.
 *
 * @since  1.0.0
 * @return object WF
 */
function WF()
{
    return WF::instance();
}
Example #26
0
 /**
  * Create new object tracer
  *
  * @param object $object Object to be traced
  * @param array $methods List of method names to be traced
  */
 public function __construct($object, $methods)
 {
     parent::__construct($object);
     $this->methods = $methods;
     $this->tracer = WF::build('ObjectCallTrace');
 }