Allow get() calls to take a "name" parameter to search the collection.
This commit is contained in:
parent
cbcbe30dba
commit
7ba6ba821a
@ -64,8 +64,18 @@ class Gallery3 {
|
|||||||
* @param string the path relative to the current resource
|
* @param string the path relative to the current resource
|
||||||
* @return object Gallery3
|
* @return object Gallery3
|
||||||
*/
|
*/
|
||||||
public function get($relative_path) {
|
public function get($relative_path, $params=array()) {
|
||||||
return self::factory("$this->url/$relative_path", $this->token, $this)->load();
|
$query = "";
|
||||||
|
if ($params) {
|
||||||
|
foreach ($params as $key => $value) {
|
||||||
|
$query[] = rawurlencode($key) . "=" . rawurlencode($value);
|
||||||
|
}
|
||||||
|
if ($query) {
|
||||||
|
$query = "?" . join("&", $query);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::factory("$this->url/$relative_path$query", $this->token, $this)->load();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -143,10 +153,6 @@ class Gallery3 {
|
|||||||
* @return object Gallery3
|
* @return object Gallery3
|
||||||
*/
|
*/
|
||||||
public function delete() {
|
public function delete() {
|
||||||
if (empty($this->url)) {
|
|
||||||
throw new Gallery3_Exception("Missing remote resource");
|
|
||||||
}
|
|
||||||
|
|
||||||
Gallery3_Helper::request("delete", $this->url, $this->token);
|
Gallery3_Helper::request("delete", $this->url, $this->token);
|
||||||
$this->reset();
|
$this->reset();
|
||||||
}
|
}
|
||||||
@ -157,15 +163,10 @@ class Gallery3 {
|
|||||||
* @return object Gallery3
|
* @return object Gallery3
|
||||||
*/
|
*/
|
||||||
public function remove($url) {
|
public function remove($url) {
|
||||||
if (empty($url)) {
|
|
||||||
throw new Gallery3_Exception("Missing remote resource");
|
|
||||||
}
|
|
||||||
|
|
||||||
Gallery3_Helper::request("delete", $this->url, $this->token, array("url" => $url));
|
Gallery3_Helper::request("delete", $this->url, $this->token, array("url" => $url));
|
||||||
$this->load();
|
$this->load();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reload the resource from a given url. This is useful after the remote resource has been
|
* Reload the resource from a given url. This is useful after the remote resource has been
|
||||||
* modified.
|
* modified.
|
||||||
|
Reference in New Issue
Block a user