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;
 }
 public function __construct($id = 0)
 {
     $this->startPopupSprite = $this->finishPopupSprite = $this->progressBarBackgroundSprite = $this->progressBarExitSprite = $this->progressBarHintLabel = ScavengerHuntGameArticle::getSpriteTemplate();
     $this->app = F::app();
     $this->id = $id;
 }
foreach ($sprites as $sprite) {
    ?>
<div class="scavengerhunt-editor-tips-sprite">
	<?php 
    echo wfMsg('scavengerhunt-editor-tip-' . $sprite);
    ?>
</div>
<div class="scavenger-half-dimension-box-wrapper">
	<label>
		<?php 
    echo wfMsg('scavengerhunt-label-' . $sprite);
    ?>
	</label><br />
	<?php 
    $switch = 1;
    $source = !empty($article) && isset($article[$sprite]) ? $article[$sprite] : ScavengerHuntGameArticle::getSpriteTemplate();
    foreach ($source as $key => $dimension) {
        if ($switch % 2) {
            ?>
			<div class="scavenger-half-dimension-box"><label><?php 
            echo wfMsg('scavengerhunt-label-sprite-' . $key);
            ?>
		<?php 
        }
        ?>
			<input class="scavenger-image-offset <?php 
        echo in_array($sprite . $key . $sufix, $highlight) ? ' sh-error' : '';
        ?>
" type="text" name="<?php 
        echo $sprite . $key . $sufix;
        ?>