-
Notifications
You must be signed in to change notification settings - Fork 0
/
photo.php
114 lines (93 loc) · 2.7 KB
/
photo.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
class PWAG_Photo
{
protected $id;
protected $image;
protected $thumbnail;
protected $description;
protected $position;
protected $dimensions;
protected $access;
protected $exif;
protected $timestamp;
public function __construct($mixed)
{
if ($mixed instanceOf SimpleXMLElement)
{
$this->parseXml($mixed);
}
else
{
$this->id = $mixed;
require_once('feed.php');
$this->parseXml(PWAG_Feed::getInstance()->getPhoto($this->id));
}
}
public function getId()
{
return $this->id;
}
public function getDescription()
{
return $this->description;
}
public function getDimensions()
{
return $this->dimensions;
}
public function getExif()
{
return $this->exif;
}
public function getWidth()
{
return $this->dimensions['width'];
}
public function getHeight()
{
return $this->dimensions['height'];
}
public function getSize()
{
return $this->size;
}
public function isPublic()
{
return ( $this->access !== 'public' ? false : true);
}
public function getImage()
{
return $this->image;
}
public function getPosition()
{
return $this->position;
}
public function getThumbnail()
{
return $this->thumbnail;
}
public function getTimestamp()
{
return $this->timestamp / 1000;
}
protected function parseXml($xml)
{
$gphoto = $xml->children('http://schemas.google.com/photos/2007');
$media = $xml->children('http://search.yahoo.com/mrss/');
$this->id = (string) $gphoto->id;
$this->description = (string) $media->group->description;
$this->position = (int) $gphoto->position;
$this->size = (int) $gphoto->size;
$this->access = (string) $gphoto->access;
$this->timestamp = (string) $gphoto->timestamp;
$this->dimensions = array(
'width' => (int)$gphoto->width,
'height' => (int)$gphoto->height
);
$exifTags = $xml->children('http://schemas.google.com/photos/exif/2007');
$this->exif = PWAG_Feed::childrenToArray($exifTags->tags, 'http://schemas.google.com/photos/exif/2007');
$this->image = PWAG_Feed::attrToArray($media->group->content->attributes());
$this->thumbnail = PWAG_Feed::attrToArray($media->group->thumbnail->attributes());
}
}