/**
  * Render the #get_web_data parser function
  */
 static function doGetWebData(&$parser)
 {
     global $wgTitle, $edgCurPageName, $edgValues;
     // If we're handling multiple pages, reset $edgValues
     // when we move from one page to another.
     $cur_page_name = $wgTitle->getText();
     if (!isset($edgCurPageName) || $edgCurPageName != $cur_page_name) {
         $edgValues = array();
         $edgCurPageName = $cur_page_name;
     }
     $params = func_get_args();
     array_shift($params);
     // we already know the $parser ...
     $args = EDUtils::parseParams($params);
     // parse params into name-value pairs
     if (array_key_exists('url', $args)) {
         $url = $args['url'];
     } else {
         return;
     }
     $url = str_replace(' ', '%20', $url);
     // do some minor URL-encoding
     // if the URL isn't allowed (based on a whitelist), exit
     if (!EDUtils::isURLAllowed($url)) {
         return;
     }
     if (array_key_exists('format', $args)) {
         $format = strtolower($args['format']);
     } else {
         $format = '';
     }
     $external_values = EDUtils::getDataFromURL($url, $format);
     if (count($external_values) == 0) {
         return;
     }
     if (array_key_exists('data', $args)) {
         // parse the 'data' arg into mappings
         $mappings = EDUtils::paramToArray($args['data'], false, true);
     } else {
         return;
     }
     if (array_key_exists('filters', $args)) {
         // parse the 'filters' arg
         $filters = EDUtils::paramToArray($args['filters'], true, false);
     } else {
         $filters = array();
     }
     self::setGlobalValuesArray($external_values, $filters, $mappings);
 }
 /**
  * Render the #get_web_data parser function.
  */
 static function doGetWebData(&$parser)
 {
     global $edgCurPageName, $edgValues, $edgCacheExpireTime;
     // If we're handling multiple pages, reset $edgValues
     // when we move from one page to another.
     $cur_page_name = $parser->getTitle()->getText();
     if (!isset($edgCurPageName) || $edgCurPageName != $cur_page_name) {
         $edgValues = array();
         $edgCurPageName = $cur_page_name;
     }
     $params = func_get_args();
     array_shift($params);
     // we already know the $parser ...
     $args = EDUtils::parseParams($params);
     // parse params into name-value pairs
     if (array_key_exists('url', $args)) {
         $url = $args['url'];
     } else {
         return EDUtils::formatErrorMessage(wfMessage('externaldata-no-param-specified', 'url')->parse());
     }
     $url = str_replace(' ', '%20', $url);
     // do some minor URL-encoding
     // if the URL isn't allowed (based on a whitelist), exit
     if (!EDUtils::isURLAllowed($url)) {
         return EDUtils::formatErrorMessage("URL is not allowed");
     }
     if (array_key_exists('format', $args)) {
         $format = strtolower($args['format']);
     } else {
         $format = '';
     }
     if ($format == 'xml') {
         if (array_key_exists('use xpath', $args)) {
             // Somewhat of a hack - store the fact that
             // we're using XPath within the format, even
             // though the format is still XML.
             $format = 'xml with xpath';
         }
     } elseif ($format == 'csv' || $format == 'csv with header') {
         if (array_key_exists('delimiter', $args)) {
             $delimiter = $args['delimiter'];
             // Hopefully this solution isn't "too clever".
             $format = array($format, $args['delimiter']);
         }
     }
     if (array_key_exists('data', $args)) {
         // parse the 'data' arg into mappings
         if ($format == 'xml with xpath') {
             $mappings = EDUtils::paramToArray($args['data'], false, false);
         } else {
             $mappings = EDUtils::paramToArray($args['data'], false, true);
         }
     } else {
         return EDUtils::formatErrorMessage(wfMessage('externaldata-no-param-specified', 'data')->parse());
     }
     if (array_key_exists('cache seconds', $args)) {
         // set cache expire time
         $cacheExpireTime = $args['cache seconds'];
     } else {
         $cacheExpireTime = $edgCacheExpireTime;
     }
     $postData = array_key_exists('post data', $args) ? $args['post data'] : '';
     $external_values = EDUtils::getDataFromURL($url, $format, $mappings, $postData, $cacheExpireTime);
     if (is_string($external_values)) {
         // It's an error message - display it on the screen.
         return EDUtils::formatErrorMessage($external_values);
     }
     if (count($external_values) == 0) {
         return;
     }
     if (array_key_exists('filters', $args)) {
         // parse the 'filters' arg
         $filters = EDUtils::paramToArray($args['filters'], true, false);
     } else {
         $filters = array();
     }
     self::setGlobalValuesArray($external_values, $filters, $mappings);
 }