Extension talk:SuperGallery

From Organic Design wiki

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)

Serialisation is really not the answer here, it's inefficient and unreadable compared to simply encoding only the values you need in standard wikitext form. And in reality PHP's inherent serialisation functions wouldn't usually be used for other applications either as more universally usable formats such as XML or JSON would be used to ensure language independence of the serialised data. --nad 20:38, 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)


Generating user page

Use Case

  • User wants to go to a special page and be able to enter the relevant file location and style data into a form and have a supergallery page generated for him
  • When the submit button is pressed he wants to be taken to an article with the name he has specified with all the data in it, all he has to do is press Save Page --Jack 10:28, 11 December 2008 (NZDT)
  • Ideally he wants to be able to edit the new page later, to change styles, picture backgrounds and links --Jack 10:50, 11 December 2008 (NZDT)


The tag now generated looks like this:

<supergallery 
			gtitle = "foo76"
			width = "120"
			height = "200"
			column = "3"
			border = "1"
			tablemargin = "2"
			bordercolor = "#cccccc"
			backgroundcolor	= "#ffffff"
			cellpadding = "10" url1 = "http://localhost/wiki4/images/d/de/Boat.jpg" image1 = "Boat.jpg" bkpre1 = "http://localhost/wiki4/images/thumb/d/de/Boat.jpg/" caption1 = "Pictures of Auckland" url2 = "http://localhost/wiki4/images/d/de/Boat.jpg" image2 = "Boat.jpg" bkpre2 = "http://localhost/wiki4/images/thumb/d/de/Boat.jpg/" caption2 = "Pictures of Auckland" url3 = "http://localhost/wiki4/images/d/de/Boat.jpg" image3 = "Boat.jpg" bkpre3 = "http://localhost/wiki4/images/thumb/d/de/Boat.jpg/" caption3 = "Pictures of Auckland" url4 = "http://localhost/wiki4/images/d/de/Boat.jpg" image4 = "Boat.jpg" bkpre4 = "http://localhost/wiki4/images/thumb/d/de/Boat.jpg/" caption4 = "Pictures of Auckland" url5 = "http://localhost/wiki4/images/d/de/Boat.jpg" image5 = "Boat.jpg" bkpre5 = "http://localhost/wiki4/images/thumb/d/de/Boat.jpg/" caption5 = "Pictures of Auckland" url6 = "http://localhost/wiki4/images/d/de/Boat.jpg" image6 = "Boat.jpg" bkpre6 = "http://localhost/wiki4/images/thumb/d/de/Boat.jpg/" caption6 = "Pictures of Auckland" url7 = "http://localhost/wiki4/images/d/de/Boat.jpg" image7 = "Boat.jpg" bkpre7 = "http://localhost/wiki4/images/thumb/d/de/Boat.jpg/" caption7 = "Pictures of Auckland">

--Jack 20:26, 15 December 2008 (NZDT)