forked from alchemy-fr/Phlickr
-
Notifications
You must be signed in to change notification settings - Fork 1
/
AuthedPhotosetList.php
120 lines (112 loc) · 3.32 KB
/
AuthedPhotosetList.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
115
116
117
118
119
120
<?php
/**
* @version $Id$
* @author Andrew Morton <[email protected]>
* @license http://opensource.org/licenses/lgpl-license.php
* GNU Lesser General Public License, Version 2.1
* @package Phlickr
*/
/**
* Phlickr_Api includes the core classes.
*/
require_once dirname(__FILE__) . '/Api.php';
/**
* This class extends Phlickr_PhotosetList.
*/
require_once dirname(__FILE__) . '/PhotosetList.php';
/**
* One or more methods returns Phlickr_AuthedPhotoset objects.
*/
require_once dirname(__FILE__) . '/AuthedPhotoset.php';
/**
* Phlickr_PhotosetList is a modifiable list of an authenticated user's
* photosets.
*
* This class requires that the Phlickr_Api have valid authentication
* information.
*
* @package Phlickr
* @author Andrew Morton <[email protected]>
* @see Phlickr_PhotosetList
* @since 0.1.9
* @todo Add sample code.
*/
class Phlickr_AuthedPhotosetList extends Phlickr_PhotosetList {
/**
* Constructor.
*
* @param object Phlickr_Api $api This object must have valid
* authentication information or an exception will be thrown.
*/
function __construct(Phlickr_Api $api) {
parent::__construct($api, $api->getUserId());
}
/**
* Return an array of Phlickr_Photosets.
*
* @return array
*/
public function getPhotosets() {
if (!isset($this->_cachedXml->{$this->getResponseElement()})) {
$this->load();
}
$ret = array();
foreach ($this->_cachedXml->{$this->getResponseElement()} as $xml) {
$ret[] = new Phlickr_AuthedPhotoset($this->getApi(), $xml);
}
return $ret;
}
/**
* Create a new Photoset
*
* @param string $title Photoset's title.
* @param string $description Photoset's description.
* @param string $primaryPhotoId Id of the photo that will represent the Photoset.
* @return string Id of the new Photoset.
* @throws Phlickr_Exception
* @see delete()
*/
public function create($title, $description, $primaryPhotoId) {
$resp = $this->getApi()->executeMethod(
'flickr.photosets.create',
array('title' => $title,
'description' => $description,
'primary_photo_id' => $primaryPhotoId
)
);
// update the cashed xml after the changes
$this->refresh();
return (string) $resp->xml->photoset['id'];
}
/**
* Adjust the ordering of the Photosets.
*
* @param array $ids Array of Photo Ids in the order desired.
* @return void
* @throws Phlickr_Exception
*/
public function reorder($ids) {
$this->getApi()->executeMethod(
'flickr.photosets.orderSets',
array('photoset_ids' => implode(',', $ids))
);
// update the cashed xml after the changes
$this->refresh();
}
/**
* Delete a Photoset.
*
* @param string $id Id of Photoset to delete
* @return void
* @throws Phlickr_Exception
* @see create()
*/
public function delete($id) {
$this->getApi()->executeMethod(
'flickr.photosets.delete',
array('photoset_id' => $id)
);
// update the cashed xml after the changes
$this->refresh();
}
}