コード例 #1
0
ファイル: Result.php プロジェクト: necrogami/pheal
    /**
     * initializes the PhealResult
     * @param SimpleXMLElement $xml
     */
    public function __construct($xml)
    {
        // switch to UTC
        $oldtz	= date_default_timezone_get();
        date_default_timezone_set('UTC');
        
        $this->request_time = (string) $xml->currentTime;
        $this->cached_until = (string) $xml->cachedUntil;
        $this->request_time_unixtime = (int) strtotime($xml->currentTime);
        $this->cached_until_unixtime = (int) strtotime($xml->cachedUntil);
        
        // switch back to normal time
        date_default_timezone_set($oldtz);

	// error detection
        if($xml->error)
            throw new Pheal_API_Exception($xml->error["code"], (String) $xml->error);
        $this->_element = Pheal_Element::parse_element($xml->result);
    }
コード例 #2
0
ファイル: Element.php プロジェクト: necrogami/pheal
    /**
     * parse SimpleXMLElement
     * @param SimpleXMLElement $element
     * @return mixed
     */
    public static function parse_element($element)
    {
        if($element->getName() =="rowset")
        {
            $re = new Pheal_Row_Set($element);
        }
        // corp/MemberSecurity workaround
        elseif($element->getName() == "result" && $element->member)
        {
            $container = new Pheal_Container();
            $container->add_element('members',new Pheal_Row_Set($element,'members','member'));
            $re = new Pheal_Element('result',$container);
        }
        else
        {
            $key = $element->getName();
            $echilds = $element->children();
            if(count($echilds) > 0)
            {
                $container = new Pheal_Container();
                foreach($echilds as $celement)
                {
                    $cel = Pheal_Element::parse_element($celement);
                    if(count($celement->attributes()) > 0)
                        $container->add_element($cel->_name, $cel);
                    else
                        $container->add_element($cel->_name, $cel->_value);
                }
                $value = $container;
            } else $value = (String) $element;

            $re = new Pheal_Element($key, $value);
            if(count($element->attributes()) > 0)
            {
                foreach($element->attributes() as $attelem)
                {
                    $re->add_attrib($attelem->getName(), (String) $attelem);
                }
            }

        }
        return $re;
    }