New module: Show updates to your gallery
HorsePunchKid
Joined: 2005-05-04
Posts: 89 |
Posted: Thu, 2005-10-06 19:32 | |||
(Continued from this thread, since it no longer has anything to do with RSS.) You can find here or attached to this post a very simple module that shows the last n items added to your gallery. This is a very hasty release, so consider it pre-alpha code. You can see it in action here. To use the module, all you should need to do is download it, unzip it, read the README, place it in your modules directory, install and activate it in the Site Admin console of your gallery, and configure the number of items to display and how to display them. Once you've done this, you should be able to view your updates at a URL like: If you have any problems or suggestions, please let me know, preferrably via this thread. Latest version: 0.2.4, 2005-10-09
|
||||
Posts: 10
This is exactly what I've been looking for. Except I get:
Fatal error: Call to a member function on a non-object in /home/XXXXX/public_html/gallery/modules/updates/ShowUpdates.inc on line 64
Posts: 89
Hi, joefish; I don't have an update to release yet, but can you replace the file updates/ShowUpdates.inc with this version? The only change is that there's a bit of code to print out the error properly.
I'm pretty sure the query a few lines before line 64 is failing for some reason, but I didn't properly output the error, so it's hard to say for sure. If you could swap in that version and post the full error here, I might be able to help debug it.
--
http://severinghaus.org/gallery/
Posts: 10
Here's the output:
Error Detail -
Error (ERROR_STORAGE_FAILURE)
* in modules/core/classes/GalleryStorage/DatabaseStorage.class at line 1166 (gallerystatus::error)
* in modules/core/classes/GalleryStorage.class at line 245 (mysqldatabasestorage::search)
* in modules/core/classes/Gallery.class at line 223 (gallerystorage::search)
* in modules/updates/ShowUpdates.inc at line 62 (gallery::search)
* in modules/core/classes/GalleryTheme.class at line 688 (showupdatesview::loadtemplate)
* in modules/core/classes/GalleryView.class at line 285 (matrixtheme::loadtemplate)
* in main.php at line 287 (showupdatesview::doloadtemplate)
* in main.php at line 87
* in main.php at line 80
System Information
Gallery version 2.0
PHP version 4.4.0 apache
Webserver Apache/1.3.33 (Unix) mod_auth_passthrough/1.8 mod_log_bytes/1.2 mod_bwlimited/1.4 PHP/4.4.0 FrontPage/5.0.2.2635 mod_ssl/2.8.22 OpenSSL/0.9.7a
Database mysqlt 4.1.13-standard
Toolkits ImageMagick, NetPBM
Operating system Linux eagle.rootserve.com 2.4.21-32.0.1.ELsmp #1 SMP Wed May 25 14:26:33 EDT 2005 i686
Browser Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4
Posts: 89
Well, for some reason the query is failing. I can help debug this further, but it may be a bit of a pain. The main thing that would help is to know exactly what query it's trying to execute, since Gallery2 has a relatively complex system for executing queries.
To find out exactly what query is being executed, you'll need to modify:
gallery/modules/core/classes/GalleryStorage/DatabaseStorage.class
In this file, on line 1135, you'll see the call where G2 translates the query from what you specify into what you need in order to run it against MySQL. Right after this line, add:
var_dump($query);
This will cause G2 to dump out the SQL for every query it executes.
This query should look something like:
If it doesn't (unlikely), that's a problem I'm not sure I'll be able to help with. If that is what you get, I think the best thing to do will be to try to run that query manually against your MySQL database and see what MySQL has to say about it.
--
http://severinghaus.org/gallery/
Posts: 53
The error joefish is reporting is the same error I got when I installed the module but had not "saved" the default admin screen. It seems the module insists that the default value be saved rather than assume the default value if none is saved.
Before spending a huge amount of time trying to debug the error joefish should just open the module's Admin screen and save the default value. After this (assuming it's the same problem) everything should magically work.
Posts: 32509
HorsePunchKid, cool
after fixing the basic bugs, fee free to add it to the modules list on codex.gallery2.org -> user contributions
@url rewrites:
you should just register a short url with the url rewrite module, no need to do manual htaccess editing...
Posts: 32
Nice work HorsePunchKid!
I have only modified the files to display dates in Frech format and to set the correct style for the page to fit with my theme!
I have replaced the old version of ShowUpdates.inc by the new one and I have no error.
Thanks a lot, this feature is important for me, and now I have it
Posts: 10
I'm not quite sure what you mean?
Posts: 10
Nevermind - I found what you meant. One needs to go to the "updates" area from the admin screen, and push 'save', to specify the amount of items that should be shown in the update display.
The module now works as intended.
Thankyou for your help
Posts: 100
Thanks so much. This is perfect and a great addition to my gallery pages.
Posts: 89
Sorry about that, but it is covered very explicitly in the README. ;-) I was worried that the query was mangled in some other way, since my entire knowledge of the query translator is based on one query I saw somewhere. Glad it works the way I figured.
I will certainly fix the problem, though. I'm just not quite sure what the standard method for handling default values is. Should I just save the default parameters into the database (setPluginParameter) when the module is first installed? If so, when does one do that? Should I override GalleryModule::autoConfigure? I'll see what I can do.
Sorry the update has been a little slow in coming. I'll get something up in the next few hours!
Posts: 89
A new version, 0.2, is ready. You can download it here or get it from the attachment to this post. I have fixed (hopefully) the problem with needing to configure it before using it.
I also added a couple of configuration options, fixed the date display to use your gallery-wide setting, added a hook for the URL rewrite module, and added a "custom CSS" field in the Site Admin page so that you don't have to fiddle with templates to make style adjustments. Please read the README, even if you've already read it from a previous version; it is short and simple.
Edit: Uploaded version with the module version number corrected.
--
http://severinghaus.org/gallery/
Posts: 10
Thanks, works well.
Posts: 10
Ok, I say I want to incude the latest 5 photos in another (non-gallery) page of my website. I don't want all the header stuff and gallery layout to be there. I tried editing the ShowUpdates.inc file, and commented out the line that says $template->head('modules/updates/templates/Header.tpl');, but obviously this only gets rid of the stuff done with the header.tpl from the updates module. How can I get rid of all gallery layout stuff when I call this page? It seems to get prepended before this module does anything...
Posts: 10
WHat is the consensis on the 0.2 version? I would like to try this but only if it works. Please let me know. Thansk.
Posts: 89
For what it's worth, zduchene, I did completely uninstall and reinstall the module a couple of times while testing it, and it seemed to work fine. I don't think you'll have any trouble, but if you do, I will do my best to help. Worst case, it's easy enough to uninstall. ;-)
--
http://severinghaus.org/gallery/
Posts: 10
I uninstalled 0.1, then installed 0.2, and it worked fine.
Posts: 565
Steven----
Is this what is causing v0.2 to install in Modules as v0.1? I'm sure I d/l'd v0.2 uninstalled/overwritten in modules and stuff but it still keeps signing on as v0.2;~/
----best wishes, Robert
Posts: 89
D'oh! Good catch, icpix. I will fix that immediately and upload a new version. Hopefully I can replace the attachment from that previous post.
The version attached to this post should have that fixed, and I think I was able to fix the version attached to the previous post. Sorry about that.
--
http://severinghaus.org/gallery/
Posts: 565
Whoa Steven I've a small RFE... would you include the ability to remove the filename/title... you've only left that one out of your listing! Afterall the image itself is linked for clicking.
----best wishes, Robert
Posts: 89
I have not tested it too thoroughly yet, but you can find version 0.2.1 with an item title toggle option here. You must visit the Site Admin page and save your settings if you upgrade. Or at least I'm pretty sure you need to. This upgrade requires an extra parameter (showTitles) in the database, and unless you uninstall the module first, it won't have a default value lying around to use. (I'll figure out how to use G2's upgrading API sooner or later.)
--
http://severinghaus.org/gallery/
Posts: 565
Standby I'll give a whirl.
Posts: 565
Steven----
That's a winner;~) I uninstalled first, cleaned the maintenance module and then reloaded. Updates v0.2.1 popped up straightaway. There was a strange 'well, where is it?' interval. I don't think I allowed enough time for Updates (the module) to update (so to speak). I sent you my site earlier by PM, you can see the effect and why I asked.
----best wishes, Robert
Posts: 77
In the zip archive the only file is a binary thing...is this what its supposed to be or are there problems on my end?
Posts: 10
I think that may be a problem on your end NBrady (?)
HorsePunchKid: Could you make it so that a theme can be chosen specifically for the latest updates screen? That way, I could easily solve my problem mentioned above (have a basic output without the rest of the gallery stuff).
Posts: 16504
NBrady try Firefox instead of IE to d/l the zip file. I assume your problem is that the zip file was corrupt or something when you d/l'd it?
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here
Posts: 89
NBrady, you're about the fourth or fifth person I've heard having trouble downloading attachments from the Gallery forums. If you're using Internet Explorer, try another browser to download it; that seems to be helping in a lot of cases. Alternatively, you could try this link.
joefish: I'm not sure how to do what you're suggesting. If I understand you correctly, you want to display the updates on a page completely outside the Gallery2 system? What sort of output would you want? Just the list of divs with the updates-item class? Alternatively, I could probably output XML, maybe an RSS feed or something.
--
http://severinghaus.org/gallery/
Posts: 10
Yes, that's right. Either the list of divs or RSS would work for me.
Posts: 89
Check out this "page", joefish. If you view the source, you can see it's just dumping out all the divs. If that looks like what you need, I can package it up. It's not a great solution, since it's got a lot of redundant code just copied over from the "ShowUpdates" view, but it works. If you need to tweak the output, look at RawUpdates.tpl.
Edit: I went ahead and packaged it up here. Check out the README to see how to use it.
--
http://severinghaus.org/gallery/
Posts: 10
Thankyou very much! That's excellent!
One suggestion: If I turn off 'show item titles' and 'show date created', I still get the extra divs in the output. For example, the output looks like this:
<div class="updates-item">
<div class="updates-thumb">
<a href="http://gallery.somewhere.net/v/student-life/sl2004/reunion/IMG_1530.jpg.html">
<img src="http://gallery.somewhere.net/d/1343-2/IMG_1530.jpg" alt="IMG_1530.jpg"/>
</a>
</div>
<div class="updates-caption">
</div>
</div>
(Extra spaces cut out obvisouly).
Posts: 5
Exactly what i was looking for! Thankies!
Posts: 32509
HorsePunchKid
it may be a good idea to keep the 1st post of this topic up to date, since it's the first thing users see and read when they find this topic.
i'd edit the first post and replace the 0.1 version file with the current version.
and i'd remove obsolete instructions (.htaccess) etc.
just a suggestion
Posts: 6
HorsePunchKid
Really like the module only I find one major issue with it which affects the way i want to use it in particular.
It does not obey permissions.
For example, most of my albums are for Registered Users only, but if i open the Updates page it will read across ALL albums and show all pictures even if im not logged in at all.
Is there any way of fixing that?
Posts: 89
joefish: I may add an option to remove the captions div entirely. I think you're not the only one would could make use of that option. In the meantime, you can use a CSS directive like div.updates-caption { display: none; } to remove it.
valiant: Very good idea indeed. :-) I have updated the first post.
kos: I hadn't even thought of that, since I don't use the permissions system at all. No promises, but I'll see what I can do about that in the next release.
--
http://severinghaus.org/gallery/
Posts: 32509
@permissions:
you may look at the source code (SQL) of the core api functions to see how to properly respect the permissions
see modules/core/classes/GalleryCoreApi.class -> modules/core/classes/helpers/*.class
Posts: 89
Version 0.2.3 of the updates module, available here or attached below, should fix the permissions problems and also allows you to disable captions entirely.
Thanks for the tip, valiant. I found the helper classes for permissions and used the "medium" one to retrieve permissions for each item for the current user. It is probably too simplistic at the moment, as it is just checking if you have any permissions at all. So for example, if you don't give someone view permissions on an item but do give them some other kind of permission, it will still show up in the updates. This seemed sufficiently unlikely that it was worth ignoring for this release, but it shouldn't be hard to correct.
Edit: This is now fixed; such a minor change that I'm just reuploading it as 0.2.3.
--
http://severinghaus.org/gallery/
Posts: 32509
as you show only the thumbnail and not resizes or the full size image, a check for "view item" is correct. nothing else is needed.
for an efficient use, i recommend GalleryCoreApi::fetchPermissionsForItems -> gets the permissions for all "new" items at once.
Posts: 89
I noticed that particular method and am already using it. :-) The hardest part about this fix was realizing and dealing with PHP's little quirk with arrays, where you unset an item and the array doesn't get reindexed. The fetch function didn't like the fact that indices were "missing" from the array.
--
http://severinghaus.org/gallery/
Posts: 89
A minor update here or attached below. I have added the option to show links to the parent album for each item. I also added labels to a couple of fields. If you don't want them to show up, you can add something like this to your custom CSS:
div.updates-item label { display: none; }
Since I added a configuration option, you'll need to visit your Site Admin page for the updates module and save your settings to get the new option into the database. Sorry, I still haven't tried to figure out how to use the upgrade API.
--
http://severinghaus.org/gallery/
Posts: 32509
@upgrading:
basically, just add a function upgrade to your module.inc and if there's nothing to do, just return a success.
if you need to change something, e.g. add a plugin parameter, add a switch($oldersion) case statement to add a pluginparameter and finally return true.
just to be clear; in the upgrade function, you don't need to change the module version etc. that is done by the G2 framework.
Posts: 89
Sounds easy enough. I'll give it a shot in the next version. Thanks again for your help!
--
http://severinghaus.org/gallery/
Posts: 6
HorsePunchKid
Thanks for the update.
Unfortunately it doesnt seem to be working perfectly for me. You can see it on: http://www.maven.sc/seycrew/gallery2/main.php?g2_view=updates.ShowUpdates
I have 2 user groups. Registered Users and Everybody. I have several root albums, 1 of which is public and the others are locked to regsitered users only.
When opening updates as member of registered users it is showing photos across all albums fine, as expected.
When opening as a guest it is still 'retrieving' images across ALL albums but its just not displaying the thumbnails for the images that guest has no permissions for.
Is it possible to make it not retrieve those images at all?
Posts: 6
Just noticed something strange.
Ordered by date I have the following images:
[reg_image1][reg_image2][guest_image1][guest_image2]...[guest_imageN][reg_image3][reg_image4]
where reg_image is image only registered users can view and guest_image is image everybody can view.
when i open the updates page, reg_image1 and reg_image2 are not shown AT ALL. but reg_image3 and reg_image4 are shown as caption links in firefox or broken images in Internet explorer.
Hope that helps you debug.
Posts: 87
Hi
I belive that we need to use the album temple so that this module inhericts the desgin
and make a link addable to the template in the theme control
Paul
PS this is a needed and usefull module
Posts: 53
Making use of the album tempalte (and being able to create a meta "album" that could be listed from the top of G2) would be sweeeet.
Posts: 87
Hi
new version seems to work without any probem But the default CSS didn't work for meI was getting a broken <HR> under the top row of images
fix it with the css block
/*set the total height so the float left work on all line*/
div.updates-item
{
width:160px;
float: left;
padding: 10px;
text-align: center;
display:block;
}
/*set the caption box and add scoll bars as needed to handle lage text blocks*/
div.updates-caption{
width:160px;
height:80px;
overflow:auto;
overflow-y:auto;
overflow-x:visible;
}
div.updates-link{
width:157px;
}
div.updates-thumb{
height:160px;
}
I hope this helps
Posts: 87
Maybe looking at how the album/image links work could be the way to go!
that we we could plase the update anywhere in the album tree!
Posts: 6
Also is there any chance for Video support?
Posts: 130
I'm very interested ina module like this but I'm hpoing to get the output like this
http://gallery.cpfc.org/create_static.php
This is the last created albums - it's a hack for 1.5 but it works well
Posts: 87
HI
If you want a quick/dirty hack just add a style block and hide all the elements you don't want (display:none;)etc.
With a quick bit of work you could get a text list