protected function validateGame(ScavengerHuntGame $game)
 {
     wfProfileIn(__METHOD__);
     $errors = $highlight = array();
     $data = $game->getAll();
     if (empty($data['name'])) {
         $errors[] = wfMsg('scavengerhunt-form-error-name');
         $highlight[] = 'name';
     }
     if (!$game->isEnabled()) {
         return array('errors' => $errors, 'highlight' => $highlight);
     }
     // sprite image has to be a proper URL
     $this->ifNotProperURL($data, array('spriteImg'), wfMsg('scavengerhunt-form-error-no-sprite-image'), $errors, $highlight);
     // landing title has to be a proper URL
     $this->ifNotProperURL($data, array('landingTitle'), wfMsg('scavengerhunt-form-error-no-landing-title'), $errors, $highlight);
     // no landing button
     $this->ifAnyEmpty($data, array('landingButtonText'), wfMsg('scavengerhunt-form-error-landing-button-text'), $errors, $highlight);
     // no landing button position
     $this->ifAnyEmpty($data, array('landingButtonX', 'landingButtonY'), wfMsg('scavengerhunt-form-error-landing-button-position'), $errors, $highlight);
     // no starting clue
     $this->ifAnyEmpty($data, array('startingClueTitle', 'startingClueText', 'startingClueButtonText'), wfMsg('scavengerhunt-form-error-starting-clue'), $errors, $highlight);
     // sprite image has to be a proper URL
     $this->ifNotProperURL($data, array('startingClueButtonTarget'), wfMsg('scavengerhunt-form-error-invalid-url'), $errors, $highlight);
     // error form incompleat
     $this->ifAnyEmpty($data, array('entryFormTitle', 'entryFormText', 'entryFormButtonText'), wfMsg('scavengerhunt-form-error-entry-form'), $errors, $highlight);
     // error facebook data incompleat
     $this->ifAnyEmpty($data, array('facebookImg', 'facebookDescription'), wfMsg('scavengerhunt-form-error-facebook-empty'), $errors, $highlight);
     // no goodbye form incompleat
     $this->ifAnyEmpty($data, array('goodbyeTitle', 'goodbyeText'), wfMsg('scavengerhunt-form-error-goodbye'), $errors, $highlight);
     if (empty($data['clueColor']) || !preg_match('/^#?([a-f]|[A-F]|[0-9]){3}(([a-f]|[A-F]|[0-9]){3})?$/', $data['clueColor'])) {
         $errors[] = wfMsg('scavengerhunt-form-error-clueColor');
         $highlight[] = 'clueColor';
     }
     foreach ($game->getDataArrayProperties() as $property) {
         if (in_array($property, $this->optionalSprites)) {
             continue;
         }
         if ((int) $data[$property]['X1'] >= (int) $data[$property]['X2'] || (int) $data[$property]['Y1'] >= (int) $data[$property]['Y2']) {
             $errors[] = wfMsg('scavengerhunt-form-error-' . $property . '-sprite-empty');
             if ((int) $data[$property]['X1'] >= (int) $data[$property]['X2']) {
                 $highlight[] = $property . 'X1';
                 $highlight[] = $property . 'X2';
             }
             if ((int) $data[$property]['Y1'] >= (int) $data[$property]['Y2']) {
                 $highlight[] = $property . 'Y1';
                 $highlight[] = $property . 'Y2';
             }
         }
     }
     $spritesInArticles = array('spriteInProgressBarNotFound', 'spriteNotFound', 'spriteInProgressBar', 'spriteInProgressBarHover');
     if (count($data['articles']) == 0) {
         $errors[] = wfMsg('scavengerhunt-form-error-no-articles');
     }
     $articleTitlesList = array();
     foreach ($data['articles'] as $n => $article) {
         $article = $article->getAll();
         //check if article title is not a duplicate.
         if (in_array($article['title'], $articleTitlesList)) {
             $errors[] = wfMsg('scavengerhunt-form-error-duplicated-article-title');
             $highlight[] = "articleTitle[{$n}]";
         } else {
             $articleTitlesList[] = $article['title'];
         }
         // articleTitle has to be a proper URL
         if (!preg_match('/^(?:' . wfUrlProtocols() . ')/', $article['title'])) {
             $errors[] = wfMsg('scavengerhunt-form-error-no-article-title');
             $highlight[] = "articleTitle[{$n}]";
         }
         foreach ($spritesInArticles as $property) {
             if ((int) $article[$property]['X1'] >= (int) $article[$property]['X2'] || (int) $article[$property]['Y1'] >= (int) $article[$property]['Y2']) {
                 $errors[] = wfMsg('scavengerhunt-form-error-article-' . $property . '-sprite-empty', $article['title']);
                 if ((int) $article[$property]['X1'] >= (int) $article[$property]['X2']) {
                     $highlight[] = $property . "X1[{$n}]";
                     $highlight[] = $property . "X2[{$n}]";
                 }
                 if ((int) $article[$property]['Y1'] >= (int) $article[$property]['Y2']) {
                     $highlight[] = $property . "Y1[{$n}]";
                     $highlight[] = $property . "Y2[{$n}]";
                 }
             }
         }
         if (empty($article['clueText'])) {
             $errors[] = wfMsg('scavengerhunt-form-error-article-clue');
             $highlight[] = "clueText[{$n}]";
         }
         if (empty($article['congrats'])) {
             $errors[] = wfMsg('scavengerhunt-form-error-article-clue');
             $highlight[] = "congrats[{$n}]";
         }
     }
     wfProfileOut(__METHOD__);
     return array('errors' => $errors, 'highlight' => $highlight);
 }