1
0
This repository has been archived on 2021-04-26. You can view files and clone it, but cannot push or open issues or pull requests.
gallery3-contrib/client/example.php

80 lines
1.7 KiB
PHP
Raw Normal View History

<?
include("Gallery3.php");
$SITE_URL = "http://example.com/gallery3";
$USER = "admin";
$PASSWORD = "admin";
if (file_exists("local_config.php")) {
include("local_config.php");
}
alert("Connect to $SITE_URL");
$gallery3 = Gallery3::connect($SITE_URL, $USER, $PASSWORD);
$root = $gallery3->get("gallery");
$tags = $gallery3->get("tags");
alert("Create a tag");
2010-01-05 21:42:45 +00:00
$tag = $tags->add()
->set_value("name", "My Tag")
->save();
alert("Create a new album");
2010-01-05 21:42:45 +00:00
$album = $root->add()
->set_value("type", "album")
->set_value("name", "Sample Album")
->set_value("title", "This is my Sample Album")
->save();
alert("Upload a photo");
2010-01-05 21:42:45 +00:00
$photo = $album->add()
->set_value("type", "photo")
->set_value("name", "Sample Photo.jpg")
->set_value("title", "Sample Photo")
->set_file("/tmp/foo.jpg")
->save();
alert("Added: " . $album->members[0] . "");
2010-01-05 21:42:45 +00:00
alert("Search for the photo");
$photos = $root->get("", array("name" => "Sample"));
alert("Found: {$photos->members[0]}");
2010-01-08 23:30:54 +00:00
alert("Grab a random photo");
$photos = $root->get("", array("random" => "true"));
alert("Found: {$photos->members[0]}");
alert("Tag the album");
2010-01-05 21:42:45 +00:00
$tag->add()
->set_value("url", $album->url)
->save();
alert("Tag the photo");
2010-01-05 21:42:45 +00:00
$tag->add()
->set_value("url", $photo->url)
->save();
alert("Tagged items: " . join($tag->members, " "));
alert("Un-tag the photo");
2010-01-05 21:42:45 +00:00
$tag->remove($photo->url);
alert("Tagged items: " . join($tag->members, " "));
2010-01-05 21:42:45 +00:00
alert("Find and modify the album");
$album = $root->get("Sample-Album")
->set_value("title", "This is my title")
->save();
alert("New title: $album->title");
// Now delete the album
alert("Delete the album");
$album->delete();
2010-01-05 21:42:45 +00:00
// Delete the tag
$tag->delete();
alert("Done!");
function alert($msg) {
print "$msg <br/>";
flush();
}
?>