Subversion Repositories googlemaps

[/] [trunk/] [extension/] [gmaplocation/] [datatypes/] [ezgmaplocation/] [ezgmaplocation.php] - Diff between revs 1 and 4

Show entire file | Ignore whitespace | Details | Blame | View Log

Rev 1 Rev 4
Line 1... Line 1...
<?php
<?php
//
//
// Definition of eZGmapLocation class
// Definition of eZGmapLocation class
//
//
// SOFTWARE NAME: Blend Gmap Location Class
// SOFTWARE NAME: Blend Gmap Location Class
// SOFTWARE RELEASE: 0.3
// SOFTWARE RELEASE: 0.5
// COPYRIGHT NOTICE: Copyright (C) 2006 Blend Interactive
// COPYRIGHT NOTICE: Copyright (C) 2006-2009 Blend Interactive
// SOFTWARE LICENSE: GNU General Public License v2.0
// SOFTWARE LICENSE: GNU General Public License v2.0
// NOTICE: >
// NOTICE: >
//   This program is free software; you can redistribute it and/or
//   This program is free software; you can redistribute it and/or
//   modify it under the terms of version 2.0  of the GNU General
//   modify it under the terms of version 2.0  of the GNU General
//   Public License as published by the Free Software Foundation.
//   Public License as published by the Free Software Foundation.
//
//
//   This program is distributed in the hope that it will be useful,
//   This program is distributed in the hope that it will be useful,
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//   GNU General Public License for more details.
//   GNU General Public License for more details.
//
//
//   You should have received a copy of version 2.0 of the GNU General
//   You should have received a copy of version 2.0 of the GNU General
//   Public License along with this program; if not, write to the Free
//   Public License along with this program; if not, write to the Free
//   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
//   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
//   MA 02110-1301, USA.
//   MA 02110-1301, USA.
//
//
Line 37... Line 37...
class eZGmapLocation
class eZGmapLocation
{
{
    /*!
    /*!
     Constructor
     Constructor
    */
    */
    function eZGmapLocation( $latitude, $longitude )
    function __construct( $latitude, $longitude )
    {
    {
        $this->Latitude = $latitude;
        $this->Latitude = $latitude;
        $this->Longitude = $longitude;
        $this->Longitude = $longitude;
    }
    }
 
 
Line 57... Line 57...
    function hasAttribute( $name )
    function hasAttribute( $name )
    {
    {
        return in_array( $name, $this->attributes() );
        return in_array( $name, $this->attributes() );
    }
    }
 
 
    function &attribute( $name )
    function attribute( $name )
    {
    {
        switch ( $name )
        switch ( $name )
        {
        {
            case "latitude" :
            case "latitude" :
            {
            {
Line 71... Line 71...
            {
            {
                return $this->Longitude;
                return $this->Longitude;
            }break;
            }break;
            default:
            default:
            {
            {
                eZDebug::writeError( "Attribute '$name' does not exist", 'eZGmapLocation::attribute' );
                eZDebug::writeError( "Attribute '$name' does not exist", __METHOD__ );
                $retValue = null;
                $retValue = null;
                return $retValue;
                return $retValue;
            }break;
            }break;
        }
        }
    }
    }
 
 
 
 
    function decodeXML( $xmlString )
    function decodeXML( $xmlString )
    {
    {
        include_once( 'lib/ezxml/classes/ezxml.php' );
        $dom = new DOMDocument( '1.0', 'utf-8' );
 
 
        $xml = new eZXML();
 
 
 
 
 
        $dom =& $xml->domTree( $xmlString );
 
 
 
        if ( $xmlString != "" )
        if ( $xmlString != "" )
        {
        {
            $locationElement =& $dom->root( );
            $success = $dom->loadXML( $xmlString );
 
            if ( !$success )
 
            {
 
                eZDebug::writeError( 'Failed loading XML', __METHOD__ );
 
                return false;
 
            }
 
 
            $latitude = $locationElement->attributeValue( 'latitude' );
            $locationElement = $dom->documentElement;
            $longitude = $locationElement->attributeValue( 'longitude' );
 
 
 
            $this->Latitude = $latitude;
 
            $this->Longitude = $longitude;
 
 
 
 
            $this->Latitude = $locationElement->getAttribute( 'latitude' );
 
            $this->Longitude = $locationElement->getAttribute( 'longitude' );
        }
        }
        else
        else
        {
        {
            $this->Latitude = 0;
            $this->Latitude = 0;
            $this->Longitude = 0;
            $this->Longitude = 0;
        }
        }
    }
    }
 
 
 
 
    function &xmlString( )
    function xmlString()
    {
    {
        include_once( 'lib/ezxml/classes/ezdomdocument.php' );
        $doc = new DOMDocument( '1.0', 'utf-8' );
 
 
        $doc = new eZDOMDocument( "Location" );
 
 
 
        $root = $doc->createElementNode( "ezgmaplocation" );
 
        $root->appendAttribute( $doc->createAttributeNode( "latitude", $this->Latitude ) );
 
        $root->appendAttribute( $doc->createAttributeNode( "longitude", $this->Longitude ) );
 
        $doc->setRoot( $root );
 
 
 
        $xml = $doc->toString();
        $root = $doc->createElement( 'ezgmaplocation' );
 
        $root->setAttribute( 'latitude', $this->Latitude );
 
        $root->setAttribute( 'longitude', $this->Longitude );
 
        $doc->appendChild( $root );
 
 
        return $xml;
        return $doc->saveXML();
    }
    }
 
 
    function setLatitude( $value )
    function setLatitude( $value )
    {
    {
        $this->Latitude = $value;
        $this->Latitude = $value;
Line 134... Line 128...
    {
    {
        $this->Longitude = $value;
        $this->Longitude = $value;
    }
    }
 
 
 
 
    var $Latitude;
    private $Latitude;
    var $Longitude;
    private $Longitude;
}
}
 
 
?>
?>