Example #1
0
 /**
  * Construct a new Gallery3 instance associated with a remote resource
  * @param   string remote url
  * @param   string authentication token
  * @return  object Gallery3
  */
 public function factory($url = null, $token = null)
 {
     $obj = new Gallery3();
     $obj->token = $token;
     $obj->url = $url;
     if ($url && $token) {
         $obj->load();
     }
     return $obj;
 }
Example #2
0
alert("Album members: <b>" . join(", ", $album->data->members) . "</b>");
$comment = Gallery3::factory()->set("item", $album->data->members[0])->set("type", "comment")->set("text", "This is a random comment-- whee!")->create($comments->url, $auth);
alert("Comment: <b>{$comment->url}</b>");
alert("Reorder the album");
$album->set_members(array($album->data->members[1], $album->data->members[0]))->set("sort_column", "weight")->save();
alert("New order: <b>" . join(", ", $album->data->members) . "</b>");
alert("Search for the photo");
$photos = Gallery3::factory($root->url, $auth)->set("name", "Sample")->load();
alert("Found: {$photos->data->members[0]}");
alert("Grab a random photo");
$photos = Gallery3::factory("{$root->url}?random=true", $auth)->load();
alert("Found: {$photos->data->members[0]}");
alert("Tag the album (using the album's relationships: {$album->data->relationships->tags->url})");
$tag_relationship1 = Gallery3::factory()->set("tag", $tag->url)->set("item", $root->url)->create($album->data->relationships->tags->url, $auth);
alert("Tag: {$tag_relationship1->url}");
alert("Tag the photo (using the tag's relationships: {$tag->data->relationships->items->url})");
$tag_relationship2 = Gallery3::factory()->set("tag", $tag->url)->set("item", $photo->url)->create($tag->data->relationships->items->url, $auth);
alert("Tag: {$tag_relationship2->url}");
alert("Un-tag the photo");
$tag_relationship2->delete();
$tag->load();
alert("1 remaining tag: <b>{$tag->data->relationships->items->members[0]}</b>");
alert("Delete the album and tag");
$album->delete();
$tag->delete();
alert("Done!");
function alert($msg)
{
    print "{$msg} <br/>\n";
    flush();
}
Example #3
0
$photos = Gallery3::factory($root->url, $auth)
  ->set("random", "true")
  ->load();
alert("Found: {$photos->data->members[0]}");


alert("Tag the album (using the album's relationships: {$album->data->relationships->tags->url})");
$tag_relationship1 = Gallery3::factory()
  ->set("tag", $tag->url)
  ->set("item", $root->url)
  ->create($album->data->relationships->tags->url, $auth);
alert("Tag: {$tag_relationship1->url}");


alert("Tag the photo (using the tag's relationships: {$tag->data->relationships->items->url})");
$tag_relationship2 = Gallery3::factory()
  ->set("tag", $tag->url)
  ->set("item", $photo->url)
  ->create($tag->data->relationships->items->url, $auth);
alert("Tag: {$tag_relationship2->url}");

alert("Un-tag the photo");
$tag_relationship2->delete();
$tag->load();
alert("1 remaining tag: <b>{$tag->data->relationships->items->members[0]}</b>");


alert("Delete the album and tag");
$album->delete();
$tag->delete();