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

67 lines
1.5 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");
}
print "Connect to $SITE_URL <br/>";
$gallery3 = Gallery3::connect($SITE_URL, $USER, $PASSWORD);
$root = $gallery3->get("gallery");
$tags = $gallery3->get("tags");
print "Create a tag <br/>";
2010-01-05 21:42:45 +00:00
$tag = $tags->add()
->set_value("name", "My Tag")
->save();
print "Create a new album <br/>";
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();
print "Upload a photo <br/>";
2010-01-05 21:42:45 +00:00
$photo = $album->add()
->set_value("type", "photo")
->set_value("name", "Sample Photo")
->set_value("title", "Sample Photo")
->set_file("/tmp/foo.jpg")
->save();
2010-01-05 21:42:45 +00:00
print "Added: " . $album->members[0] . " <br/>";
print "Tag the album <br/>";
$tag->add()
->set_value("url", $album->url)
->save();
print "Tag the photo <br/>";
2010-01-05 21:42:45 +00:00
$tag->add()
->set_value("url", $photo->url)
->save();
2010-01-05 21:42:45 +00:00
print "Tagged items: " . join($tag->members, " ") . "<br/>";
2010-01-05 21:42:45 +00:00
print "Un-tag the photo <br/>";
$tag->remove($photo->url);
print "Tagged items: " . join($tag->members, " ") . "<br/>";
print "Find and modify the album <br/>";
$album = $root->get("Sample-Album")
->set_value("title", "This is my title")
->save();
2010-01-05 21:42:45 +00:00
print "New title: $album->title <br/>";
// Now delete the album
print "Delete the album <br/>";
$album->delete();
2010-01-05 21:42:45 +00:00
// Delete the tag
$tag->delete();
print "Done! <br/>";
?>