Skip to content
Snippets Groups Projects
Commit f5f7ccbb authored by Tim Steiner's avatar Tim Steiner
Browse files

Add PodcastProducer libraries to UNL Library

parent 5097fc1b
No related branches found
No related tags found
No related merge requests found
<?php
class Unl_Plist
{
static public function plistToArray($xml)
{
$dom = DOMDocument::loadXML($xml);
$xPath = new DOMXPath($dom);
$root = $xPath->query('plist/*')->item(0);
return self::_parseNode($root);
}
static protected function _parseNode($node)
{
switch ($node->nodeName) {
case 'integer':
return self::_parseInt($node);
break;
case 'string':
case 'key':
return self::_parseString($node);
break;
case 'date':
return self::_parseDate($node);
break;
case 'true':
case 'false':
return self::_parseBool($node);
break;
case 'dict':
return self::_parseDict($node);
break;
case 'array':
return self::_parseArray($node);
break;
default:
return null;
}
}
static protected function _parseInt($node)
{
return intval($node->textContent);
}
static protected function _parseString($node)
{
return $node->textContent;
}
static protected function _parseDate($node)
{
}
static protected function _parseBool($node)
{
return (bool) ($node->nodeName == 'true');
}
static protected function _parseDict($node)
{
$dict = array();
$childNodes = array();
foreach ($node->childNodes as $childNode) {
if ($childNode->nodeName == '#text') {
continue;
}
$childNodes[] = $childNode;
}
for ($i = 0; $childNodes[$i]; $i += 2) {
$key = self::_parseNode($childNodes[$i]);
$value = self::_parseNode($childNodes[$i+1]);
$dict[$key] = $value;
}
return $dict;
}
static protected function _parseArray($node)
{
$array = array();
foreach ($node->childNodes as $childNode) {
if ($childNode->nodeName == '#text') {
continue;
}
$array[] = self::_parseNode($childNode);
}
return $array;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment