1
0

Add support for replacing an item's data file.

This commit is contained in:
Bharat Mediratta 2010-08-08 01:13:32 -07:00
parent 8562a1abc3
commit cf37aa5ceb
4 changed files with 17 additions and 6 deletions

View File

@ -129,10 +129,16 @@ class Gallery3 {
* @return object Gallery3 * @return object Gallery3
*/ */
public function save() { public function save() {
$response = Gallery3_Helper::request( $data = array();
"put", $this->url, $this->token, $data["entity"] = array_diff((array)$this->data->entity, $this->original_entity);
array("entity" => array_diff((array)$this->data->entity, $this->original_entity), if (isset($this->data->members)) {
"members" => $this->data->members)); $data["members"] = $this->data->members;
}
if ($this->file) {
$response = Gallery3_Helper::request("put", $this->url, $this->token, $data, $this->file);
} else {
$response = Gallery3_Helper::request("put", $this->url, $this->token, $data);
}
return $this->load(); return $this->load();
} }

View File

@ -39,13 +39,19 @@ for ($i = 0; $i < 2; $i++) {
->set("type", "photo") ->set("type", "photo")
->set("name", "Sample Photo.png") ->set("name", "Sample Photo.png")
->set("title", "Sample Photo") ->set("title", "Sample Photo")
->set_file("gallery.png") ->set_file("test1.png")
->create($album->url, $auth); ->create($album->url, $auth);
alert("Uploaded photo: <b>{$photo->url}</b>"); alert("Uploaded photo: <b>{$photo->url}</b>");
} }
$album->load(); $album->load();
alert("Album members: <b>" . join(", ", $album->data->members) . "</b>"); alert("Album members: <b>" . join(", ", $album->data->members) . "</b>");
alert("Replace the data file");
$photo->set_file("test2.png")
->save();
$comment = Gallery3::factory() $comment = Gallery3::factory()
->set("item", $album->data->members[0]) ->set("item", $album->data->members[0])
->set("type", "comment") ->set("type", "comment")
@ -93,7 +99,6 @@ $tag_relationship2->delete();
$tag->load(); $tag->load();
alert("1 remaining tag: <b>{$tag->data->relationships->items->members[0]}</b>"); alert("1 remaining tag: <b>{$tag->data->relationships->items->members[0]}</b>");
alert("Delete the album and tag"); alert("Delete the album and tag");
$album->delete(); $album->delete();
$tag->delete(); $tag->delete();

View File

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

BIN
client/test2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB