diff -r 877f952ae2bd -r 6b6c2214f778 web/lib/Zend/Gdata/Analytics/DataEntry.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/lib/Zend/Gdata/Analytics/DataEntry.php Thu Mar 21 19:52:38 2013 +0100 @@ -0,0 +1,116 @@ +registerAllNamespaces(Zend_Gdata_Analytics::$namespaces); + parent::__construct($element); + } + + /** + * @param DOMElement $child + * @return void + */ + protected function takeChildFromDOM($child) + { + $absoluteNodeName = $child->namespaceURI . ':' . $child->localName; + switch ($absoluteNodeName) { + case $this->lookupNamespace('analytics') . ':' . 'dimension'; + $dimension = new Zend_Gdata_Analytics_Extension_Dimension(); + $dimension->transferFromDOM($child); + $this->_dimensions[] = $dimension; + break; + case $this->lookupNamespace('analytics') . ':' . 'metric'; + $metric = new Zend_Gdata_Analytics_Extension_Metric(); + $metric->transferFromDOM($child); + $this->_metrics[] = $metric; + break; + default: + parent::takeChildFromDOM($child); + break; + } + } + + /** + * @param string $name + * @return mixed + */ + public function getDimension($name) + { + foreach ($this->_dimensions as $dimension) { + if ($dimension->getName() == $name) { + return $dimension; + } + } + return null; + } + + /** + * @param string $name + * @return mixed + */ + public function getMetric($name) + { + foreach ($this->_metrics as $metric) { + if ($metric->getName() == $name) { + return $metric; + } + } + return null; + } + + /** + * @param string $name + * @return mixed + */ + public function getValue($name) + { + if (null !== ($metric = $this->getMetric($name))) { + return $metric; + } + return $this->getDimension($name); + } +}