Subversion Repositories googlemaps

[/] [trunk/] [extension/] [gmaplocation/] [datatypes/] [ezgmaplocation/] [ezgmaplocation.php] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1 joekepley
<?php
2
//
3
// Definition of eZGmapLocation class
4
//
5
// SOFTWARE NAME: Blend Gmap Location Class
6 4 Cyberwolf
// SOFTWARE RELEASE: 0.5
7
// COPYRIGHT NOTICE: Copyright (C) 2006-2009 Blend Interactive
8 1 joekepley
// SOFTWARE LICENSE: GNU General Public License v2.0
9
// NOTICE: >
10
//   This program is free software; you can redistribute it and/or
11
//   modify it under the terms of version 2.0  of the GNU General
12
//   Public License as published by the Free Software Foundation.
13 4 Cyberwolf
//
14 1 joekepley
//   This program is distributed in the hope that it will be useful,
15
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
16
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
//   GNU General Public License for more details.
18 4 Cyberwolf
//
19 1 joekepley
//   You should have received a copy of version 2.0 of the GNU General
20
//   Public License along with this program; if not, write to the Free
21
//   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22
//   MA 02110-1301, USA.
23
//
24
//
25
 
26
/*! \file ezgmaplocation.php
27
*/
28
 
29
/*!
30
  \class eZGmapLocation ezgmaplocation.php
31
  \ingroup eZDatatype
32 4 Cyberwolf
  \brief The class eZGmapLocation provides a datatype for storing
33 1 joekepley
  \latitude & longitude values.
34
 
35
*/
36
 
37
class eZGmapLocation
38
{
39
    /*!
40
     Constructor
41
    */
42 4 Cyberwolf
    function __construct( $latitude, $longitude )
43 1 joekepley
    {
44
        $this->Latitude = $latitude;
45
        $this->Longitude = $longitude;
46
    }
47
 
48
    /*!
49
     \return list of supported attributes
50
    */
51
    function attributes()
52
    {
53
        return array( 'latitude',
54
                      'longitude' );
55
    }
56
 
57
    function hasAttribute( $name )
58
    {
59
        return in_array( $name, $this->attributes() );
60
    }
61
 
62 4 Cyberwolf
    function attribute( $name )
63 1 joekepley
    {
64
        switch ( $name )
65
        {
66
            case "latitude" :
67
            {
68
                return $this->Latitude;
69
            }break;
70
            case "longitude" :
71
            {
72
                return $this->Longitude;
73
            }break;
74
            default:
75
            {
76 4 Cyberwolf
                eZDebug::writeError( "Attribute '$name' does not exist", __METHOD__ );
77 1 joekepley
                $retValue = null;
78
                return $retValue;
79
            }break;
80
        }
81
    }
82
 
83
 
84
    function decodeXML( $xmlString )
85
    {
86 4 Cyberwolf
        $dom = new DOMDocument( '1.0', 'utf-8' );
87 1 joekepley
 
88
        if ( $xmlString != "" )
89
        {
90 4 Cyberwolf
            $success = $dom->loadXML( $xmlString );
91
            if ( !$success )
92
            {
93
                eZDebug::writeError( 'Failed loading XML', __METHOD__ );
94
                return false;
95
            }
96 1 joekepley
 
97 4 Cyberwolf
            $locationElement = $dom->documentElement;
98 1 joekepley
 
99 4 Cyberwolf
            $this->Latitude = $locationElement->getAttribute( 'latitude' );
100
            $this->Longitude = $locationElement->getAttribute( 'longitude' );
101 1 joekepley
        }
102
        else
103
        {
104
            $this->Latitude = 0;
105
            $this->Longitude = 0;
106
        }
107
    }
108
 
109
 
110 4 Cyberwolf
    function xmlString()
111 1 joekepley
    {
112 4 Cyberwolf
        $doc = new DOMDocument( '1.0', 'utf-8' );
113 1 joekepley
 
114 4 Cyberwolf
        $root = $doc->createElement( 'ezgmaplocation' );
115
        $root->setAttribute( 'latitude', $this->Latitude );
116
        $root->setAttribute( 'longitude', $this->Longitude );
117
        $doc->appendChild( $root );
118 1 joekepley
 
119 4 Cyberwolf
        return $doc->saveXML();
120 1 joekepley
    }
121
 
122
    function setLatitude( $value )
123
    {
124
        $this->Latitude = $value;
125
    }
126
 
127
    function setLongitude( $value )
128
    {
129
        $this->Longitude = $value;
130
    }
131
 
132
 
133 4 Cyberwolf
    private $Latitude;
134
    private $Longitude;
135 1 joekepley
}
136
 
137
?>