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;
}
Comments
ex: $comment = $_zp_current_comment new zp_current_comment()
I don't remember`getImageForImageID($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).
I think something is missing
As for the save() ...DUH!!! my bad let me check
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']);
}
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.
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.
When I executed this code
"<?php echo ('RatingNumber: '.$_zp_current_image->getRating());?>"
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
You should probably tell us what errors you are getting. But your descriptions all point to `$image` NOT being an object.
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.
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.
Created this error...
Fatal error: Call to undefined method _Image::setComment() 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 :P
I guess I have to make my own function to make this happen since the internal stuff is broken
@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.
So what is the "setcomment" for?
http://www.zenphoto.org/documentation/classes/Comment.html#methodsetComment
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.
reference:
http://www.zenphoto.org/documentation/classes/ThemeObject.html#methodaddComment
The album constructor totally ignores the gallery parameter since there is one and only one gallery object.
==================================
I tested this completely on Zenphoto and it works GREAT .as soon as I added it to the API for the plugin it returns user. any ideas as to why?
==================================
$id = "someid";
$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);
$albumobject = new Album(new Gallery(),$row['folder']);
$imageobject = newImage($albumobject, $row['filename']);
$username = 'Joh Doe';
$commentText = 'HELLO Blaster World';
$postcomment = $imageobject->addComment($username, 'fake-email.com', '', $commentText, '','' , '', '', '', '');
echo 'postcomment '. $postcomment;