/**
  * Initializes the DBDataTransclusionSource from the given parameter array.
  * @param $spec associative array of options. See class-level documentation for details.
  */
 function __construct($spec)
 {
     if (!isset($spec['fieldNames']) && isset($spec['fieldInfo'])) {
         $spec['fieldNames'] = array_keys($spec['fieldInfo']);
     }
     DataTransclusionSource::__construct($spec);
     $this->query = $spec['query'];
     $this->querySuffix = @$spec['querySuffix'];
 }
 /**
  * Initializes the CachingDataTransclusionSource
  *
  * @param $spec an associative array of options. See class-level
  *		documentation of DataTransclusionSource for details.
  *
  * @param $data an array containing a list of records. Records from
  *		this list can be accessed via fetchRecord() using the key fields specified
  *		by $spec['keyFields']. If $data is not given, $spec['data'] must contain the data array.
  */
 function __construct($spec, $data = null)
 {
     DataTransclusionSource::__construct($spec);
     if ($data === null) {
         $data = $spec['data'];
     }
     $this->lookup = array();
     foreach ($data as $rec) {
         $this->putRecord($rec);
     }
 }
 public static function naiveResolvePath($data, $path, $split = true)
 {
     if (is_object($data)) {
         if ($dom instanceof DOMNode) {
             throw new MWException("naiveResolvePath does not like DOMNode objects");
         }
         $data = wfObjectToArray($data);
     }
     if (!is_array($data) || $path === '.') {
         return $data;
     }
     if ($split && is_string($path)) {
         $path = DataTransclusionSource::splitList($path, '/');
     }
     if (is_string($path) || is_int($path)) {
         return @$data[$path];
     }
     if (!$path) {
         return $data;
     }
     $p = array_shift($path);
     if (is_string($p) && preg_match('/^(@)?(\\d+)$/', $p, $m)) {
         //numberic index
         $i = (int) $m[2];
         if ($m[1]) {
             //meta-index
             $k = array_keys($data);
             $p = $k[$i];
         }
     }
     if (!isset($data[$p])) {
         return false;
     }
     $next = $data[$p];
     if ($next && $path) {
         return FlattenRecord::naiveResolvePath($next, $path);
     } else {
         return $next;
     }
     //TODO: named components. separator??
 }
 public function decodeData($raw, $format = null)
 {
     if ($format === null) {
         $format = $this->dataFormat;
     }
     if ($format == 'json' || $format == 'js') {
         return DataTransclusionSource::decodeJson($raw);
     } elseif ($format == 'wddx') {
         return DataTransclusionSource::decodeWddx($raw);
     } elseif ($format == 'xml') {
         return DataTransclusionSource::parseXml($raw);
     } elseif ($format == 'php' || $format == 'pser') {
         return DataTransclusionSource::decodeSerialized($raw);
     }
     return false;
 }