Difference between revisions of "Extension talk:SuperGallery"
(New section: Serialization) |
(→Simple example of Serialization) |
||
Line 31: | Line 31: | ||
http://www.devshed.com/c/a/PHP/The-Basics-of-Serializing-Objects-in-PHP/ | http://www.devshed.com/c/a/PHP/The-Basics-of-Serializing-Objects-in-PHP/ | ||
--[[User:Jack|Jack]] 10:27, 10 December 2008 (NZDT) | --[[User:Jack|Jack]] 10:27, 10 December 2008 (NZDT) | ||
+ | |||
+ | Nice simple example:<pre><?php | ||
+ | class dog { | ||
+ | |||
+ | var $name; | ||
+ | var $age; | ||
+ | var $owner; | ||
+ | |||
+ | function dog($in_name="unnamed",$in_age="0",$in_owner="unknown") { | ||
+ | $this->name = $in_name; | ||
+ | $this->age = $in_age; | ||
+ | $this->owner = $in_owner; | ||
+ | } | ||
+ | |||
+ | function getage() { | ||
+ | return ($this->age * 365); | ||
+ | } | ||
+ | |||
+ | function getowner() { | ||
+ | return ($this->owner); | ||
+ | } | ||
+ | |||
+ | function getname() { | ||
+ | return ($this->name); | ||
+ | } | ||
+ | } | ||
+ | ?> | ||
+ | |||
+ | <body bgcolor=white> | ||
+ | <h1>Beware the dog</h1> | ||
+ | <?php | ||
+ | $ourfirstdog = new dog("Rover",12,"Lisa and Graham"); | ||
+ | $dogdisc = serialize($ourfirstdog); | ||
+ | |||
+ | $pet = unserialize($dogdisc); | ||
+ | $old = $pet->getage(); | ||
+ | $name = $pet->getname(); | ||
+ | print "Our first dog is called $name and is $old days old<br>"; | ||
+ | print $dogdisc; | ||
+ | ?></pre> --[[User:Jack|Jack]] 17:05, 10 December 2008 (NZDT) |
Revision as of 04:05, 10 December 2008
Specification
The user clicks on the link, intending to make a gallery page that itself links to galleries. A form pops up. It has eight (or so) sets of inputs boxes containing:
- url of thumbnail
- size of thumbnail
- link to sub-gallery
- caption about sub-gallery
- border
- padding
The form also has:
- title of supergallery
The extension needs to know if this is a user's private supergallery, so it can append /username to its url. The extension itself uses gallery tags and css backgrounds to create the page for the user. It auto-places each sub-gallery "cell" depending on how many the user specifies by filling in sub-gallery details on the form.
No Ajax is needed, as the submit button creates the page.
I have a working example of this as a page, see http://jack.co.nz/Galleries
-- Jack 15:23, 29 November 2008 (NZDT)
Coding Issues
Heading offline, will do this now as much as possible, got the latest updates to the template, compiles OK locally, back online 3 days time maybe -- Jack 15:22, 29 November 2008 (NZDT)
Serialization
The output of this extension needs to be serialized so it can be the contents of a tag function in a new page. Also, a new input is needed in the form for the name of the new page. Here is a good article about serializing objects: http://www.devshed.com/c/a/PHP/The-Basics-of-Serializing-Objects-in-PHP/ --Jack 10:27, 10 December 2008 (NZDT)
Nice simple example:
<?php class dog { var $name; var $age; var $owner; function dog($in_name="unnamed",$in_age="0",$in_owner="unknown") { $this->name = $in_name; $this->age = $in_age; $this->owner = $in_owner; } function getage() { return ($this->age * 365); } function getowner() { return ($this->owner); } function getname() { return ($this->name); } } ?> <body bgcolor=white> <h1>Beware the dog</h1> <?php $ourfirstdog = new dog("Rover",12,"Lisa and Graham"); $dogdisc = serialize($ourfirstdog); $pet = unserialize($dogdisc); $old = $pet->getage(); $name = $pet->getname(); print "Our first dog is called $name and is $old days old<br>"; print $dogdisc; ?>
--Jack 17:05, 10 December 2008 (NZDT)