full zenphoto functionality integration in a website

Hej folks.

I have a idea and I was searching around for a long time for a really good gallery. First of all I found a very good german lightweight picture gallery, but really lightweight. Only one php-file, no sub galleries, no db, no comments and no polling.
That would be ok, if you want it small, light and easy.

But I want more, I want comments and polling and - the important thing - I want a full php class structure so that I (more or less) can easy integrate the gallery into my website.
That´s my theme now!

I have a website programmed with the lightweight php framework codeigniter (http://codeigniter.com/).
I have my own templates, my ohnw MVC hierarchy (CI provide this) and I have a full DB connection where my content comes from.

The most gallerys - ZP so, too - has a full closed system, with templates and database connection.
My Question is now:
how can I fully integrate zenphoto in my website?
This means to me:

maybe I call http://mydomain.de/index.php/pictures/xyz

and this loads my website, my design and my selfprogrammed dynamic menu, but in my content-area I load ZP.

So how can I get instances from ZP and load into my website what I need (without reprogramming it): - galleries (and gallery navigation - paging)
- full pictures with
- comments and polling ...
- automatically ZP testing if the gallery is public or not ...

Provides ZP functions, modules and classes to get an instance of maybe a gallery or a picture back (as return statement or as an full object) instead of just publishing on the website (echo the whole content)??

Would be great if someone can give me some answers / ideas. Maybe someone has done this already and can help me??
If ZP provides the functions (or some) I need, I will write a wrapper (a library or plugin) for CI so that you can have a single ZP instance installed fully indepent from your CI core (website).
This is important to make a new version just simple available over a normal upgrade mechanism without hacking around in self modified and crapped-up code. ;)

That´s all ... I´m agog of your answers.

Greetz
/Ulf

[edit]
I testing around the whole day to get a single picture from ZP to integrate it in my website. There are so many posts and questions ... and it´s easier as I thought.
I just wrote a function in my controller (CodeIgniter provided a full ModelViewController pattern) which access the DB and executes the SQL from the zenshow plugin to get the relevant information.
And then I can call: http://yourdomain.de/zen/myalbum/image/666/picture.jpg
where 666 is the size of the picture and I get a full sized picture. Very good!

If the rest is just that easy to integrate it is what I´ve dreamed from. ;)

Comments

  • uk81 Member
    @sbillard
    More or less it is what I'm searching for, but it does not work for me, yet.
    I have not find out why, but at the moment I only get a big database error back (but the DB is ok and running).

    I don´t know, but I think the problem is CodeIgniter. It is a full php framework with MVC pattern.
    I used the code from your link link inside my codeigniter-controller. CI autmatically loads some contents and initialize global helpers, libraries and so on.
    Maybe this is a problem and both things does not work together very good.

    Or have you another idea for a DB problem when using ZP as a plugin?
    The error message is that ZP couldn´t get a DB connection (from the place I use it) and tells me that maybe the connection parameters not correct. But that´s not true, ZP as standalone (call it directly over the browser) works properly fine!
  • uk81 Member
    I think about now and here is a list what I think I'll need for a full integration. Maybe one or some classes provide this functionality:
    - getting all galeries (overview, like startpage of ZP, maybe a list with picture URLs and titles ...!?)
    - getting all subgalleries/thumbnails of a gallery (like above -> one layer down of the hierarchy)
    - getting polling and comments for a picture
    - getting some service information for images/galleries like tags, description ...
    - all pictures from the cache, not like the http://mydomain.de/zp/mygallery/image/300/picture.jpg (will create on the fly a 300px picture)
    - for all thinks a testing (like ZP always do) if the gallery/picture is public, can show, has a pw ...

    The paging I can do for myself, CI provides very good and easy to use helper for this. So I can write some functions for reading out the gallerys, show a overview and set my own links to show them.
    So the links operates inside my own website and only the pictures show up from ZP.

    Why I do not program it for myself?
    - Why invent the wheel new, when it already exists?
    I can also program functions with direct DB access for:
    - getting galleries with thumbnails
    - getting subgalleries / thumbnails from pictures
    - getting picture, tags, description, polling and comments

    But! so I have to make sure, that:
    - only public pictures/galleries will show
    - that I get the pictures from the cache (so that the webserver don´t have to recalculate the pictures every time new someone access the website)
    - ask for pw if there is one
    - show if comments are allowed
    - test all input fields from comments
    - insert polling and test if user has already select a poll ...
    and so on

    But ZP provides this function in its core and when it provides it via a interface (like a API) ... I don´t have to program it all my way. :)
  • acrylian Administrator, Developer
    I don't know codeigniter (but I know which "lightweight german gallery" you mean..:-)) We have a fairly large documentation including all the main classes on our site's user guide page. Maybe you already find there what you need.
  • uk81 Member
    I hope so.
    Thanks acrylian. Maybe I can write something like a core-class which provides what I need.
    It is still a object with the options above.

    But a general question (without took a look at the class documentations yet):
    is there a way to get things/objects/galleries/pictures (I name it: elements) from ZP in a easy way with the guarantee that it take care of privileges (like "gallery is public" ...)?

    So that I can let give me for example a list of gallery names or gallery informations without taking care for myself, if all privileges are fullfilled?
    If not I have to program a class on my own, which executes a sql query and take care for its own if maybe something is public, visible, ...
    But then I can reprogram a whole part of ZPs core. ;) I want not to do so ... (if I don´t have to) ;)
  • acrylian Administrator, Developer
    The classes actually take care of these things like public etc. Zenphoto uses a set of global variables with class objects like $_zp_gallery (the gallery object), $_zp_current_album (the currently selected album object) and $_zp_current_image (well...:-))
    Of course you can initialize these classes yoursefl like with all other classes: new Gallery, new Album etc. The class methods are documentated.
    As for sql queries within zp-core the functions-db.php provides functions for that and the image processor can be accessed via i.php (both are not in the documentation, but are documentated in the files itself).

    To save a lot of work you also might consider just making a lookalike theme for zenphoto and run it separatly...:-)
  • uk81:

    Maybe your framework has some confilct with zenphoto globals. The connection parameters are loaded from the zp-config.php file and end up in the array `$_zp_conf_vars`. I suppose you could dump that array after the plugin code and see if it has the right things.
  • zigmoo Member
    Hey Guys,

    CodeIgniter, as a high-security measure, actively removes all global variables it finds, except the contents of $_COOKIE and $_POST. I found this VERY annoying when I was first getting used to CI, especially that it erases $_SESSION and creates its own!

    The reason that uk81's post (2008-05-24 23:44:28) describes a database error is that zf stores its database connection values (and a whole lot besides!) in globals, and even though uk81 wrote his CI wrapper code correctly, CI is trying to execute the zf code with no database configs variables. Furthermore, many other functions in zf depend on globals, not just the initial database connection.

    It seems to me that the only solution is to modify the way zf passes information to and from its functions, so that globals are not used. I think that initializing a special class in the config and then passing that in to functions that need its data might work.

    Sbillard and acrylian, would you guys be interested if some of us wanted to try and help out by modifying zf so that it would no longer rely on globals?

    Thanks,

    moo
  • Certainly, but understand it is a BIG task.
  • acrylian Administrator, Developer
    Yes, but sounds like a Zenphoto 2.0 project (at least) to me, since that will surely require a nearly complete rewrite of the code.
  • trisweb Administrator
    It is my understanding that the global variables they refer to are not all globally *scoped* variables, but simply the globals referenced by register_globals (which would create global variables out of GPC data, eg: $_POST['test'] -> $test). These are highly insecure and should never be used.

    However, using global variables in general is not inherently insecure at all, and there should be no problem with it. It's controversial and debatable, but I look at it this way - Encapsulating the data (that needs global access) inside a class or object is simply adding overhead to the basic requirement, and where would you store that class or object to be most easily accessible globally? In a global variable, of course, so it's sort of hypocritical.

    I see a few (not tons, zenphoto only has a few, honestly) globally-scoped variables with good naming convention and usefulness as the logical solution for data that needs global scope. Don't see any reason to change this, but I'm willing to hear better arguments.
Sign In or Register to comment.