[Suggestion/request] photoalbum

Creating and modifying plugins.
SHRIKEE
Regular
Posts: 128
Joined: Tue Feb 21, 2006 2:49 am
Location: Netherlands
Contact:

Post by SHRIKEE »

its not uh weird. it looks unfamiliar... i guess you all use oop, ive never really used that. ill look into the code tonight and see what i can do.

is there a databse with functions hooks and stuff i can look into to see what does what and how?

thanks!
My kingdom For i am king of my heap of trash

Developing code on:
Workstation: Windows 2000 sp4, TSW webcoder 2005
Server: fedora core 4 amd64, apache 2.0.54, php 5.0.4, mysql 4.1.11.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

What you might want to look into is:

http://www.s9y.org/43.html
http://www.s9y.org/116.html (not so much up to date)

Most things can be learned by looking at the plugin API PHP code itself and its PHPdoc documentation:

http://svn.berlios.de/viewcvs/serendipi ... iew=markup

And, the most easy way of all is "learning by doing". Just have a look at existing plugins, you'll see how most things are done with that the best way.

Sadly I'm just a developer and not a good person at writing extensive documentation. But the Serendipity community is growing rapidly the last few months, and with the new 1.0 release we are drawing quite much attention. Which is why a group of active people (Judebert, Carl and David) are currently helping a lot at improving the Wiki and the Design and the Logo. I then expect many more people to join the project, and with them we might get a much better documentation soon.

Our code is quite clean, so I do hope that other developers can make sense out if it.

It would be great if you have a look at these things, and play around with it. I'll try to help as good as I can if you have questions. It would be great to have you onboard. :-)

Most important: Have fun! :-)

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
SHRIKEE
Regular
Posts: 128
Joined: Tue Feb 21, 2006 2:49 am
Location: Netherlands
Contact:

Post by SHRIKEE »

hmmk,

ive started to study the usergallery plugin again, this seems to get the closest to what i want.

when using functions, can they have the same name as other plugins or do i need unique function names?

regarding the property bag:

Code: Select all

$propbag->add('configuration', array('title','num_cols','andmore...'));
Are these unique values per plugin or can i use a 'title' or 'num_cols' field aswell?

as for the plugin name i think 'mediagallery' would be appropriate here :)
My kingdom For i am king of my heap of trash

Developing code on:
Workstation: Windows 2000 sp4, TSW webcoder 2005
Server: fedora core 4 amd64, apache 2.0.54, php 5.0.4, mysql 4.1.11.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

The methods inside the plugin can be called any way you like. Functions within classes only need to be unique within the class, so other plugins can define the same function names with different contents.

Only make sure you do not use any of the internal used methods for custom functionality (those are serendipity_plugin(), performConfig(), install(), uninstall(), introspect(), introspect_config_item(), validate(), generate_content(), get_config(), set_config(), cleanup(), serendipity_event(), register_dependencies(), getFieldReference(), event_hook()). Those special methods need to follow the structure of the original class, as you might have noticed within each plugin class.

The $propbag is an object of a class that stores any configuration or property data. There are some internal values that are used by serendipity, which you need to use. Examples of those are 'configuration', 'title', 'description', 'version', 'requirements'.

So if you want your plugin to be able to have config options, you need to add them to that 'configuration' property bag array. Plus you need to look into the introspect_config_item() method of the class, that tells how to treat each configuration value.

I basically suggest to not create a seperate plugin. Instead you should patch up the existing one to do what you want and then just submit me your patches, and I will commit your changes officially. With credits, of course! :-)

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
carl_galloway
Regular
Posts: 1331
Joined: Sun Dec 04, 2005 5:43 pm
Location: Andalucia, Spain
Contact:

Post by carl_galloway »

Gee this is exciting, guys, please make this work - I really want this code in my blog.

Garvin, Serendipity WILL be the killer app that I've been mentioning when changes like this get merged into the base.
SHRIKEE
Regular
Posts: 128
Joined: Tue Feb 21, 2006 2:49 am
Location: Netherlands
Contact:

Post by SHRIKEE »

hah, im working on it...

im using usergallery as a base but am not patching that file. well i am, but i created it as a seperate plugin called mediagallery.

The one problem im walking into now is how to get the directories properly listed :(

ive got the config screen working aswell as the install thingy

ive edited the serendipity_event_staticpages.php to recognize my file and add it to the staticpages list... So now on to the layout of the gallery itself...

the images shouldnt be to hard as i can adapt the layout of usergallery. but the dir listing gives me a headache :(

maybe some one knows something about it?
My kingdom For i am king of my heap of trash

Developing code on:
Workstation: Windows 2000 sp4, TSW webcoder 2005
Server: fedora core 4 amd64, apache 2.0.54, php 5.0.4, mysql 4.1.11.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi Shrikee!

You might want to look at the serendipity_traverseDir() function in include/functions_images.inc.php. Our code often uses this to show directory structures...like in include/admin/images.inc.php we use it to display the list of directories for creating new ones, or editing directories. Or the dropdown inside the mediagallery with the path structure also uses that function.

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
mgroeninger
Regular
Posts: 546
Joined: Mon Dec 20, 2004 11:57 pm
Contact:

Post by mgroeninger »

I'd like to clearify something... The usergallery plugin has two modes of output. One mode (the default) uses the standard media output built into Serendipity core. The other mode uses a skinnable thumbnail page to display a single directory of images. The skinnable output allows for text to be added to the top of the page, which would allow someone to build a directory structure without too much difficulty. Of course, further changes are possible using Smarty. The plugin will even check to see if a theme supports the plugin when it displays.

I tried to leave the plugin as flexible as possible, rather than try to get it to address a very specific need (i.e. mine). The only thing I believe it is missing is pagiation of folders.

Regardless, the thought I had (last time I fiddled with the plugin) was that rather than developing the usergallery plugin further it should get moved into the staticpage plugin as a page type (like article), where a new gallery page could be added which references a different directory. I don't have a whole lot of time right now to look into how to do that, but I feel it is probably the best way to go forward.
SHRIKEE
Regular
Posts: 128
Joined: Tue Feb 21, 2006 2:49 am
Location: Netherlands
Contact:

Post by SHRIKEE »

I almost got it working!

Finetuning some functions now and testing the thing!
My kingdom For i am king of my heap of trash

Developing code on:
Workstation: Windows 2000 sp4, TSW webcoder 2005
Server: fedora core 4 amd64, apache 2.0.54, php 5.0.4, mysql 4.1.11.
SHRIKEE
Regular
Posts: 128
Joined: Tue Feb 21, 2006 2:49 am
Location: Netherlands
Contact:

Post by SHRIKEE »

Uff why is the documentation this poor :(

what does serendipity_db_query() do?

I want to count the files for a folder.

Code: Select all

$count_query = "SELECT count(id) FROM {$serendipity['dbPrefix']}images WHERE path = '".serendipity_db_escape_string($limit_directory)."'";
$count_result = serendipity_db_query($total_query, true, 'num');
$limit_directory being the current folder which matches the path in the path field

does not work!
My kingdom For i am king of my heap of trash

Developing code on:
Workstation: Windows 2000 sp4, TSW webcoder 2005
Server: fedora core 4 amd64, apache 2.0.54, php 5.0.4, mysql 4.1.11.
SHRIKEE
Regular
Posts: 128
Joined: Tue Feb 21, 2006 2:49 am
Location: Netherlands
Contact:

Post by SHRIKEE »

heres a first beta (whitout filecount)

http://www.sothq.net/pages/album.html

Current features:
- virtually unlimited galleries with virtually unlimited subcategories *
- Admin panel where a starting folder must be set. All folders and files in this folder are indexed. **
- Page hooks for permalinks (defaults at /pages/album.html)
- Option to set 2 3 or 4 columns
- Images are opened in a thumbnail
- images are fully managed through the media manager

* This option needs some tuning as i couldnt figure out how to pass the folders properly. Due to this the script cannot read folders in subcategories :(
** Currently links to other folders (categories) show as offsite links. I couldnt figure out how to change this

now its bedtime :p
My kingdom For i am king of my heap of trash

Developing code on:
Workstation: Windows 2000 sp4, TSW webcoder 2005
Server: fedora core 4 amd64, apache 2.0.54, php 5.0.4, mysql 4.1.11.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

That sounds good! If you're willing to share the plugin, or the patch - that would be great. If you're familiar with CVS I can give you a CVS account to be able to maintain your plugin in our repository?

As for your SQL question, you should try this code:

Code: Select all

$count_query = "SELECT count(id) AS counter FROM {$serendipity['dbPrefix']}images WHERE path = '".serendipity_db_escape_string($limit_directory)."'";
$count_result = serendipity_db_query($total_query, true, 'assoc'); 
echo $count_result['counter'];
Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
SHRIKEE
Regular
Posts: 128
Joined: Tue Feb 21, 2006 2:49 am
Location: Netherlands
Contact:

Post by SHRIKEE »

Im not familiar with cvs ;) but ill figure it out i think.
Ill send the code when i got a first fully working version which is ready to distribute :) Currently it works but is not optimised yet.

Ill try your query now.
My kingdom For i am king of my heap of trash

Developing code on:
Workstation: Windows 2000 sp4, TSW webcoder 2005
Server: fedora core 4 amd64, apache 2.0.54, php 5.0.4, mysql 4.1.11.
SHRIKEE
Regular
Posts: 128
Joined: Tue Feb 21, 2006 2:49 am
Location: Netherlands
Contact:

Post by SHRIKEE »

The query returns 0 at all times :( im not sure how to use this function...

Today ive been working on templates though. The images are shown on a thumbnailed page. When clicked it shows it on a new page. If the image is larger as 480x360 its on the fly resized to that size to fit most themes.

This image can be clicked and a popup hops in to show the fullsized image. The popup is generated dynamically and can be closed by clicking the image or use the X in the upperright corner.

Can anyone tell me how to remove the little arrow that shows on offsite links? thanks!
My kingdom For i am king of my heap of trash

Developing code on:
Workstation: Windows 2000 sp4, TSW webcoder 2005
Server: fedora core 4 amd64, apache 2.0.54, php 5.0.4, mysql 4.1.11.
carl_galloway
Regular
Posts: 1331
Joined: Sun Dec 04, 2005 5:43 pm
Location: Andalucia, Spain
Contact:

Post by carl_galloway »

Shrikee, if you use bleeding edge software you get all the extras that we play with as well :D

The arrows can be removed by deleting the following from the theme stylesheet;

Code: Select all

/* style for links within entries */
.serendipity_entry_body a, .serendipity_entry_extended a {
	padding-right: 11px;
	background: transparent url({TEMPLATE_PATH}img/link_blue.gif) no-repeat top right; }

/* style for links when hovered over within entries */
.serendipity_entry_body a:hover, .serendipity_entry_extended a:hover {
	background: transparent url({TEMPLATE_PATH}img/link_ltblue.gif) no-repeat top right; }
Post Reply