I just added "getcomment" to work in the Zenphoto lightroom plugin it can now syn all comments of images
but for some reason I can get "setComment" to work .. what am I missing?
function addImageComments($args) {
global $_zp_current_image;
$v = var_export($args, true);
debuglog ('addImageComments');
debuglog ($v);
if (is_object($login_state = authorize($args))) return $login_state;
$args = decode64($args);
$image = getImageForImageID($args['Id']);
if ($image->filename)
$image->setCommentsAllowed;
$image->setComments($args['commentText']);
else
return new IXR_Error(-1, 'Image not found on server '.$obj['filename']);
return true;
}
$image must be an image object, otherwise the method cannot work. If this is the current image that would be in $_zp_current_image already. Otherwise you need to setup one.
I don't remembergetImageForImageID($args['Id']); but does that return an image object?
Also you need to use the save() method after you setup a new object so you really save the values set (meaing if this is not an existing image in this case but a new one).
Also having a issue with getting ratings
it dies as soon as I do "$image->getRating()"
So I did some hard coding to check my API logic and its fine,
function getImageRatings($args) {
global $_zp_current_image;
$v = var_export($args, true);
debuglog ('getImageRatings');
debuglog ($v);
if (is_object($login_state = authorize($args))) return $login_state;
$args = decode64($args);
$image = getImageForImageID($args['Id']);
/if ($image->filename)
$image->getRating();
//debuglog ('RatingNumber: '.$image->getRating();
else
return new IXR_Error(-1, 'Image not found on server '.$obj['filename']);/
return 7;//$image->getRating();
}
function getImageForImageID($id) {
$row = query_single_row('SELECT '.prefix("images").'.id, '.prefix("images").'.filename, '.prefix("albums").'.folder FROM
'.prefix("images").' LEFT JOIN '.prefix("albums").' ON '.prefix("images").'.albumId = '.prefix("albums").'.id
WHERE
'.prefix("images").'.id='.$id, true);
$album = new Album(new Gallery(),$row['folder']);
return new _Image($album, $row['filename']);
}
As soon as I add "$image->save();" it breaks the code...
I think I have to make a dum theme and test my code in a actual Zenphoto environment to rule up any issues before I make new functions to connect to Zenphoto through the API.
Let me know if you have any insight.. thanks ... kinda stuck.
getImageForImageIDshould use newImage() instead of directly the constructor. I don't remember why we separated it (sbillard will know) but that makes sure an image obj is created.
So you can't use the global directly? YOu also should not have to setup the gallery object as that is already in $_zp_gallery most everywhere.
Ok so I using one of the default themes to double check my code before I pull my hair out debugging what I can see ..
When I executed this code
""
This is the error it produced.
Fatal error: Call to undefined method _Image::getRating() in /home1/glamwor2/public_html/clients.philbertphotography.com/themes/copy_of_default/image.php on line 56
So you mean
function getImageobject($id) {
$row = query_single_row('SELECT '.prefix("images").'.id, '.prefix("images").'.filename, '.prefix("albums").'.folder FROM
'.prefix("images").' LEFT JOIN '.prefix("albums").' ON '.prefix("images").'.albumId = '.prefix("albums").'.id
WHERE
'.prefix("images").'.id='.$id, true);
$galleryobject = new Gallery();
$album = new Album($galleryobject,$row['folder']);
$image = new newImage($album, $row['filename']);
return $image;
}
When I try it I get an error... let me rework the logic on that end later and see.
Some suggestions:
First there is always a global $_zp_gallery which contains the gallery object. You can use that. But actually, even that is not needed. The $galleryobject parameter is ignored now and you can simply pass NULL. (1.4.5 will introduce a new_album() function analogous to the new_image() function.)
There is no guarantee that your will succeed, so you should be testing the result before using it.
Otherwise, let us know the error and we can better tell what is failing.
This code $_zp_current_image->setComment('HELLO DOLLY');
Created this error...
Fatal error: Call to undefined method _Image:etComment() in /home1/glamwor2/public_html/clients.philbertphotography.com/themes/copy_of_default/image.php on line 60
Well I am soo glad I was not going crazy after 10 hours of debugin
I guess I have to make my own function to make this happen since the internal stuff is broken
new newImage($album, $row['filename']);is in any case wrong..;-) (one "new" is enough).
@sbillard: Aren't the functions newImage() and newAlbum() without underscore actually unless I missed a change?
You need to make sure that you use the methods on the right object. If you don't it never will work.
OK let me go over the docs again .. I think I made a mistake some where thanks so far ..
So what is the "setcomment" for?
http://www.zenphoto.org/documentation/classes/Comment.html#methodsetComment
That is a method of the comment class, not the image class. That is why the URL you posted is to ...classes/Comment.html....
Theme objects have an addComment() method. Is that what you are looking for?
@acrylian: You are right, I should always look first before posting a function name.