Zenphoto image discovery

Hello

I have question regarding zenphoto image discovery function
What I mean by discovery is when zenphoto discovers new images from a album folder and makes a mysql entry for them.

As zenphoto doesn't offer anonymous image upload i'am making my own script that basically just uploads the info into the zenphoto albums folder and then it would modify the appropriate title, desc, etc info in the photos mysql row.

But for that to happen i would like zenphoto to create the mysql row not my script to ensure maximum compatibility.

So the question being is there a special function or a page that i could include in my script that would make zenphoto create the mysql row for the new image?

would appriciate any help
Thank You

Comments

  • You would have to cause your script to "view" the image. The "function" you want is `newImage(, )`
  • Hello again!

    Thank You for the help. But i'am afraid my php skills are too weak to use that info in any useful way.

    I would appriciate it creatly if anyone could give a piece of code that would need to be ran for the "zenphoto view image effect to work".

    It would save me from requiering the zenphoto front page in a hidden div or doing something stupid like that :)
  • Ok after a good deal of trial and error i found this to work for me
    $newImage= newImage(new Album($_POST['album'], $_POST['album']), $image_name );

    where the §_POST['album] contains the folder name that the image got copied and $image_name the filename of the new image.

    Anyone confirm that this is not the complete wrong way?
  • acrylian Administrator, Developer
    If you would have done it correctly this would create a new image object. Note that `new Album()` requires the gallery object and the album name: http://www.zenphoto.org/documentation/classes/Album.html (see constructor album). You setup a new gallery object by `$gallery = new Gallery()`.

    Why do you need that actually? The images you have uploaded will be discovered automatically if someone views the album either on the backend or the frontend. If you use exif data Zenphoto will use that to generate the title, description.
    Please take a look at the diagram here: http://www.zenphoto.org/2009/03/troubleshooting-zenphoto/#22

    Edit: You should never use $_POST data directly, at least use our `sanitize()` function for security reasons.
  • The reason i want to force the discovery is that i want guests to upload images and add Title, Location, Desc etc.

    If i create the MYSQL entry myself then Zenphoto won't add EXIF info. So it would be ideal for me if Zenphoto discovers the photo then makes MYSQL entry that my script can modify upon.

    I'm very green with php so it takes some time to get my head around it.

    Thanks for the help
  • Ok me again GROAN

    My test code in Zenphoto works GREAT ... but when I use the exact same thing in my API it returns the "admin" or username.... I am stumped at this point any pointers?
    =========================================
    $id = "3370";
    $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 = 'Joseph Philbert';
    $commentText = 'HELLO Fing World';

    //if ($image->filename)
    $postcomment = $imageobject->addComment($username, 'jj@jj.com', '', $commentText, '','' , '', '', '', '');
    echo 'postcomment '. $postcomment;
  • Can you explain a bit more about the environment you are running in? The most probably cause for the above is that the comment form plugin is not active.

    I guess I am also confused about your query. What exactly is it attempting to do? Looks like you are trying to get the image object from its ID? If so, maybe `getItemByID()` would be simpler.
  • crap I see what happens O posted the problem in the wrong topic while I was doing research GROAN "too much code on the brain"

    Anyway I am getting the image object from the ID then using that the create an object ...then it helps me make all the other magic :)

    Gonna start testing getItemByID() ...fun fun
  • BTW the comment form plugin is on that how I was able to test it in a live environment before I pasted the code in the API and nothing .. :)
  • `getItemByID()` just cut my coding in half LOL
  • You still should describe the environment. Presumably it is different from when you tested in the live environment vs the API. The symptom you described would happen if the comment form filter to process comments was not active. But unless you describe the API environment there is no way to guess why that would be the case.

    Just for the record:

    The comment form plugin registers the filter if it is running on a front-end page load. The front-end environment needs to be setup for the processing to work.
  • Ohhhhhhhhhhhhh......... The API runs from Adobe LightRoom the API code runs from "zp-install/plugins/zp-lightroom/xmlrpc.php" folder.

    So now I get why that does not work ... I may have to make a custom mysql or php to post comments ...hmmm sucks ..
  • So you are loading the plugin script directly rather than having Zenphoto load it? Then you need to be sure that the appropriate Zenphoto environment is also loaded. In this case the problem is that the comment form plugin "believes" that comments are only posted from the "front-end" scripts--that is ones descending from the root index.php script.

    There is no reason why your script cannot run that way. If it is a THEME_PLUGIN or a CLASS_PLUGIN it will get loaded along with the front end.

    It would be a really bad idea to make your own Mysql calls to post the comment--those are internal things and subject to change without notice. Really all you need is to insure that the comment form plugin registers its comment handling filter.
  • Yea I was going to write Mysql calls but I also thought that was a bad idea..

    The plugin is not a "TRUE" plugin it just resides in the folder and loads the needed php files so it can communicate to Zenphoto

    It loads:

    "//
    // make sure that the WEBPATH is set to parent directory for correct URL values
    //
    $dir = str_replace('\\', '/', realpath(dirname(__FILE__)));
    define('SERVERPATH', strstr($dir, '/plugins/zp-lightroom', true));

    require_once(SERVERPATH . '/zp-core/functions.php');
    include_once(SERVERPATH . '/zp-core/template-functions.php');
    require_once(SERVERPATH . '/zp-core/lib-auth.php');
    include_once(SERVERPATH . '/plugins/zp-lightroom/IXR_Library.inc.php');"

    Now I am wondering if theres any point making it partly a TRUE plug-in even partially just to get it to work hmmmm
  • When you have time take a look I brain storming as to what is the best way to make this work the way you suggested. I may be a large rewrite but in the long run will be better integrated I think.

    https://github.com/philbertphotos/Zenphoto-Lightroom-Publisher/blob/3.02/zp-lightroom/xmlrpc.php
  • I think your best approach is to also load the comment form functions.php script and directly call the `comment_form_addCcomment()` function.

    The down side of this is that if there ever is a competing comment form plugin that does not use this function.php script your plugin will probably fail. But I doubt that will ever be the case. Mostly people just customize the form itself.
  • Another suggestion:

    `
    define('OFFSET_PATH', 3);
    require_once(dirname(dirname(dirname($_SERVER['SCRIPT_FILENAME'])))."/zp-core/admin-globals.php");
    `
    Will get you setup with the global defines for ZENFOLDER, etc. and loading functions.php will establish the SERVERPATH define for you. (You could actually substitute `template-functions.php` for `admin-globals.php` above and get all the ZP stuff loaded.
  • Ok time to try some stuff..
    Thanks...
Sign In or Register to comment.