As promised at Linuxtag, I have rewritten the presentation system.
Presentations and slides are now defined in XML files and the architecture
of the thing is much cleaner and nicer.  It should be much easier to adapt
this thing to more people.

I'd appreciate a bit of help with it.  The basic framework is in place but
there are many areas where someone with more artistic sense than myself
could really make a difference.  You can see the current status of it
here: http://pres.lerdorf.com
(put your mouse cursor somewhere in the navbar and hit space to go to the
 next slide, backspace to go back)

It really only works with Mozilla 1.0 with the flash5 plugin installed.
Please don't email me and complain that it looks like crap on IE.  I
really don't care what it looks like on IE at this point.

Code can be fetched from cvs.php.net in "pres2".  If you are interested in
helping out and don't already have enough karma to commit to it, let me
know and I will set you up.

The README file for it so far follows:

Ever wondered what would happen if someone was crazy enough to combine
XML, PHP, HTML, CSS, JavaScript, Flash and ActionScript in one
application? Well, here it is. The new and improved PHP presentation
system.

Brief walkthrough of how this all hangs together:

config.php            - User configurable paths and filenames
flash.php             - Flash widget rendering embedded from objects.php
fonts/                - Font files
help.php              - Help file
index.php             - Prints list of available presentations
objects.php           - Top-level widget rendering
presentations/        - Directory of presentation files
show.php              - Main slide display code
slides/               - Directory of slide files
XML_Presentation.php  - XML parser for the presentation files
XML_Slide.php         - XML parser for the slide files

When a user first enters the site index.php presents a list of
presentations by walking through the presentations/ directory and parsing
each *.xml file using the XML_Presentation XML parser. The filename of the
presentation file without the extension becomes the id by which the
presentation is known. This string is passed to show.php via PATH_INFO
(eg. show.php/intro)

Now we are in show.php. Here we first parse $PATH_INFO to figure out which
presentation file to read. Open the presentation file and grab the list of
slides. First slide is #0 internally. Will probably show it to the user as
starting at #1. The presentation file itself looks like this:


<presentation>
 <title>PHP - Scripting the Web</title>
 <event>OSCON</event>
 <location>San Diego</location>
 <date>July 22, 2002</date>
 <speaker>Rasmus</speaker>
 <navmode>flash</navmode>

 <slide>slides/slide1.xml</slide>
 <slide>slides/slide2.xml</slide>

</presentation>

That is, you start it with a <presentation> tag, and have at least a title
tag inside.  The others are optional.  Then a series of <slide> tags where
you put the relative filename of each slide.

This particular presentation XML file ends up getting parsed into an
array of objects that looks like this:

Array
(
    [1] => _presentation Object
        (
            [title] => PHP - Scripting the Web
            [navmode] => flash
            [event] => OSCON
            [location] => San Diego
            [date] => July 22, 2002
            [speaker] => Rasmus
            [slides] => Array
                (
                    [0] => _pres_slide Object
                        (
                            [filename] => slides/slide1.xml
                        )

                    [1] => _pres_slide Object
                        (
                            [filename] => slides/slide2.xml
                        )

                )

        )

)

Technically you could put more than 1 presentation in the same file, but
this isn't completely supported at this point. This presentation object
gets stored in $pres which is a session variable. We will see why in a
little bit. So to get at the title of the presentation you would use:

  $pres[1]->title

And to get the filename of the first slides you would use:

  $pres[1]->slides[0]->filename

The slide XML files start with a <slide> tag and needs a <title> tag as
well. Then it can have any combination of the following tags:

<blurb>   Paragraph of text which can contain <title> and <text>
<list>    Bullet list which can contain <title> and <bullet>
<image>   Image which can contain <title> and <filename>
<example> Example block which can contain <title>, <text> or <filename>

See the example slides in the slides/ directory for more info.

The default navbar is written in flash5 and is rendered from objects.php
with an embed tag which embeds flash.php. Since the flash.php is fetched
in a separate request, it gets the current slide data via the session
data. It also makes use of $slideNum and $maxSlideNum to navigate through
the slides. A unique quality of this navbar is that when the mouse cursor
is over it, it takes full control of the keyboard allowing the space bar
to be used to advance to the next slide and the backspace key to go back
one. Once you move the mouse cursor out of the navbar area all keystrokes
go to the browser. We need this so we can do interactive slides where we
don't want the space and backspace keys to change the slide.

Architecturally any widget, including the navbar can have multiple
rendering methods. For someone without a flash plugin for their browser,
they will be able to choose (or we might even be able to detect this) a
non-flash navbar of some kind. Likewise for each component of the slide.
So far I have focused on HTML rendering of the various pieces, but
eventually I'd like to see plain text, flash, SVG, jpg, png, etc...
rendering methods for each component.

If you look in objects.php you will see that each widget type has a $mode
property and that the display() method for each one looks something like
this:

    function display() {
        $this->{$this->mode}();
    }

And then you can have html(), flash(), text(), svg(), jpg() methods for
each one.

Have a look at the TODO file for a list of things to start working on. If
we all pitch in a bit we should all end up with cool-looking presentations
through this very flexible system.

-Rasmus


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to