public function getGameCacheValue()
 {
     $factory = new 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)));
 }
 /** HELPER METHODS **/
 public function newGameArticle()
 {
     return $this->games->newGameArticle();
 }
 public static function onOpenGraphMetaBeforeCustomFields($articleId, &$titleImage, &$titleDescription)
 {
     $games = new ScavengerHuntGames();
     /* @var $games ScavengerHuntGames */
     $elements = $games->getOpenGraphMetaElements();
     if (!empty($elements) && isset($elements['facebookImg']) && isset($elements['facebookDescription'])) {
         if (!empty($elements['facebookImg'])) {
             $titleImage = $elements['facebookImg'];
         }
         if (!empty($elements['facebookDescription'])) {
             $titleDescription = $elements['facebookDescription'];
         }
     }
     return true;
 }
 protected function updatePostedGame($game = null)
 {
     wfProfileIn(__METHOD__);
     if (empty($game)) {
         $gameId = (int) $this->request->getVal('gameId');
         $game = $this->games->findById($gameId, true);
         if (empty($game)) {
             throw new WikiaException("Could not retrieve specified game");
         }
     }
     if ($game->getId() == 0) {
         $game->setWikiId($this->app->getGlobal('wgCityId'));
     }
     // prepare data for normal params
     $nonArrayParams = $game->getDataNonArrayProperties();
     $paramValues = array();
     foreach ($nonArrayParams as $param) {
         $mValue = $this->request->getVal($param);
         $paramValues[$param] = $mValue;
     }
     // prepare data for sprites
     $arrayParams = $game->getDataArrayProperties();
     $spriteSchema = array('X', 'Y', 'X1', 'Y1', 'X2', 'Y2');
     foreach ($arrayParams as $param) {
         $mValue = array();
         foreach ($spriteSchema as $dimension) {
             $mValue[$dimension] = (int) $this->request->getVal($param . $dimension);
         }
         $paramValues[$param] = $mValue;
     }
     $game->setAll($paramValues);
     //create list of articles
     $articleMarkers = $this->request->getArray('articleMarker');
     $articleTitles = $this->request->getArray('articleTitle');
     $clueTexts = $this->request->getArray('clueText');
     $aCongrats = $this->request->getArray('congrats');
     $spritesInArticles = array('spriteInProgressBarNotFound', 'spriteNotFound', 'spriteInProgressBar', 'spriteInProgressBarHover');
     foreach ($spriteSchema as $dimension) {
         foreach ($spritesInArticles as $spriteName) {
             $tmpName = $spriteName . $dimension;
             ${$tmpName} = $this->request->getArray($tmpName);
         }
     }
     $articles = array();
     if (!empty($articleMarkers) && is_array($articleMarkers)) {
         foreach (array_keys($articleMarkers) as $i) {
             $article = $game->newGameArticle();
             // prepare data for acticle sprites
             $spriteNotFound = ScavengerHuntGameArticle::getSpriteTemplate();
             $spriteInProgressBar = ScavengerHuntGameArticle::getSpriteTemplate();
             $spriteInProgressBarHover = ScavengerHuntGameArticle::getSpriteTemplate();
             $aResults = array();
             foreach ($spriteSchema as $dimension) {
                 foreach ($spritesInArticles as $spriteName) {
                     $tmpName = $spriteName . $dimension;
                     $aParam = ${$tmpName};
                     if (!isset($aResults[$spriteName])) {
                         $aResults[$spriteName] = array();
                     }
                     $aResults[$spriteName][$dimension] = isset($aParam[$i]) ? (int) $aParam[$i] : 0;
                 }
             }
             $article->setAll(array('title' => isset($articleTitles[$i]) ? $articleTitles[$i] : '', 'clueText' => isset($clueTexts[$i]) ? $clueTexts[$i] : '', 'congrats' => isset($aCongrats[$i]) ? $aCongrats[$i] : '', 'spriteInProgressBarHover' => $aResults['spriteInProgressBarHover'], 'spriteInProgressBarNotFound' => $aResults['spriteInProgressBarNotFound'], 'spriteInProgressBar' => $aResults['spriteInProgressBar'], 'spriteNotFound' => $aResults['spriteNotFound']));
             $articles[] = $article;
         }
     }
     $game->setArticles($articles);
     wfProfileOut(__METHOD__);
     return $game;
 }