Exemplo n.º 1
0
 public static function parse($xmlpath)
 {
     libxml_use_internal_errors(true);
     $xml = simplexml_load_file($xmlpath, 'SimpleXMLElement', LIBXML_NOCDATA);
     foreach (libxml_get_errors() as $error) {
         ErrorHelper::logError('XML Error on line ' . $error->line . ' column ' . $error->column . ': ' . $error->message);
     }
     if (!$xml) {
         return null;
     }
     $data = XMLHelper::xml2array($xml);
     XMLHelper::collapse($data, 'socials', 'social');
     XMLHelper::collapse($data, 'histories', 'history');
     XMLHelper::collapse($data, 'trailers', 'trailer');
     XMLHelper::collapse($data, 'awards', 'award');
     XMLHelper::collapse($data, 'quotes', 'quote');
     XMLHelper::collapse($data, 'additionals', 'additional');
     XMLHelper::collapse($data, 'credits', 'credit');
     XMLHelper::collapse($data, 'contacts', 'contact');
     XMLHelper::collapse($data, 'platforms', 'platform');
     XMLHelper::collapse($data, 'features', 'feature');
     XMLHelper::collapse($data, 'prices', 'price');
     // transforms the pricing data to be indexed by the optional platform-tag
     if (isset($data['prices'])) {
         $priceByPlatform = array();
         foreach ($data['prices'] as $price) {
             if (!isset($price['platform'])) {
                 $price['platform'] = '';
             }
             $priceByPlatform[$price['platform']][] = $price;
         }
         $data['prices'] = $priceByPlatform;
     }
     return $data;
 }
Exemplo n.º 2
0
 public static function getData($game)
 {
     $data = LoadHelper::loadCached('https://promoterapp.com/dopresskit/' . $game->promoter['product'], PROMOTER_CACHE_DURATION);
     if ($data == null) {
         return;
     }
     $promoterxml = simplexml_load_string($data);
     $promoter = XMLHelper::xml2array($promoterxml);
     XMLHelper::collapse($promoter, 'reviews', 'review');
     if (!isset($promoter['reviews'])) {
         return;
     }
     if (PROMOTER_OVERWRITE || !isset($game->quotes)) {
         $game->quotes = array();
     }
     foreach ($promoter['reviews'] as $review) {
         $game->quotes[] = array('link' => $review['url'], 'description' => $review['quote'], 'name' => $review['reviewerName'], 'website' => $review['publicationName']);
     }
 }