mirror of
https://github.com/php/web-pres2.git
synced 2026-03-23 23:12:07 +01:00
New presentation system - initial checkin
This commit is contained in:
133
README
Normal file
133
README
Normal file
@@ -0,0 +1,133 @@
|
||||
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
|
||||
31
TODO
Normal file
31
TODO
Normal file
@@ -0,0 +1,31 @@
|
||||
Things to work on
|
||||
|
||||
- Make the presentation listing page in index.php pretty. Perhaps
|
||||
add (+) buttons out in front of each one, and when clicked you
|
||||
would get a list of slides inside that presentation?
|
||||
|
||||
- Stupid IE does not support fixed positioned div elements
|
||||
Emulate it using Javascript.
|
||||
See: http://javascriptkit.com/javatutors/static3.shtml
|
||||
Or perhaps stick the navbar in a frame on IE. Note though that
|
||||
IE on the Mac does support fixed positioned div elements.
|
||||
|
||||
- This thing probably needs a name
|
||||
|
||||
- We need a way to print presentations nicely. This might be done through
|
||||
a conversion to Docbook-XML and then use all the existing tools to print
|
||||
from there. Or perhaps some other converter. Basically, I figure, it
|
||||
would just be another set of rendering methods in objects.php
|
||||
|
||||
- Calling all ming hackers - help us with some cool transitions for the navbar
|
||||
and also the various individual slide components if people choose to use
|
||||
the flash version.
|
||||
|
||||
- We also need to pretty up the navbar flash widget. All sorts of slick
|
||||
things could be done in this thing.
|
||||
|
||||
- A cooler help page would be nice.
|
||||
|
||||
- a pop-up list of slide titles would be good so at any time during a
|
||||
presentation you could get the list and navigate to any slide by
|
||||
clicking somewhere on the list.
|
||||
213
XML_Presentation.php
Normal file
213
XML_Presentation.php
Normal file
@@ -0,0 +1,213 @@
|
||||
<?php
|
||||
// {{{ header
|
||||
// vim: set tabstop=4 shiftwidth=4 fdm=marker:
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP Version 4 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1997-2002 The PHP Group |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | This source file is subject to version 2.02 of the PHP license, |
|
||||
// | that is bundled with this package in the file LICENSE, and is |
|
||||
// | available at through the world-wide-web at |
|
||||
// | http://www.php.net/license/2_02.txt. |
|
||||
// | If you did not receive a copy of the PHP license and are unable to |
|
||||
// | obtain it through the world-wide-web, please send a note to |
|
||||
// | license@php.net so we can mail you a copy immediately. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Authors: Rasmus Lerdorf <rasmus@php.net> |
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
// $Id$
|
||||
// }}}
|
||||
|
||||
require_once 'XML/Parser.php';
|
||||
require_once 'objects.php';
|
||||
|
||||
/**
|
||||
* Presentation parser class.
|
||||
*
|
||||
* This class is a parser for the .pres files
|
||||
*
|
||||
* @author Rasmus Lerdorf <rasmus@php.net>
|
||||
* @version $Revision$
|
||||
* @access public
|
||||
*/
|
||||
class XML_Presentation extends XML_Parser
|
||||
{
|
||||
|
||||
// {{{ properties
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
var $insideTag = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
var $activeTag = '';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
var $objects = array();
|
||||
|
||||
/**
|
||||
* @var int
|
||||
* Current Object Index
|
||||
*/
|
||||
var $coid = 0;
|
||||
|
||||
var $last_handler;
|
||||
|
||||
var $stack = array();
|
||||
|
||||
// }}}
|
||||
// {{{ Constructor
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @access public
|
||||
* @param mixed File pointer or name of the slide file.
|
||||
* @return void
|
||||
*/
|
||||
function XML_Presentation($handle = '')
|
||||
{
|
||||
$this->XML_Parser();
|
||||
|
||||
if (@is_resource($handle)) {
|
||||
$this->setInput($handle);
|
||||
} elseif ($handle != '') {
|
||||
$this->setInputFile($handle);
|
||||
} else {
|
||||
$this->raiseError('No filename passed.');
|
||||
}
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ startHandler()
|
||||
|
||||
/**
|
||||
* Start element handler for XML parser
|
||||
*
|
||||
* @access private
|
||||
* @param object XML parser object
|
||||
* @param string XML element
|
||||
* @param array Attributes of XML tag
|
||||
* @return void
|
||||
*/
|
||||
function startHandler($parser, $element, $attribs)
|
||||
{
|
||||
switch ($element) {
|
||||
/* These tags can have other tags inside */
|
||||
case 'PRESENTATION':
|
||||
$cl = '_'.strtolower($element);
|
||||
$this->objects[++$this->coid] = new $cl();
|
||||
$this->stack[] = $this->coid;
|
||||
$this->insideTag = $element;
|
||||
$this->_add_attribs($this->objects[$this->coid], $attribs);
|
||||
break;
|
||||
|
||||
/* Special case for array properties */
|
||||
case 'SLIDE':
|
||||
$this->objects[$this->coid]->slides[] = new _pres_slide();
|
||||
$idx = count($this->objects[$this->coid]->slides)-1;
|
||||
$this->_add_attribs($this->objects[$this->coid]->slides[$idx], $attribs);
|
||||
$this->activeTag = $element;
|
||||
break;
|
||||
|
||||
/* Everything else can't */
|
||||
default:
|
||||
$this->activeTag = $element;
|
||||
$this->_add_attribs($this->objects[$this->coid], $attribs, strtolower($element));
|
||||
break;
|
||||
}
|
||||
$this->last_handler = 'start';
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ endHandler()
|
||||
|
||||
/**
|
||||
* End element handler for XML parser
|
||||
*
|
||||
* @access private
|
||||
* @param object XML parser object
|
||||
* @param string
|
||||
* @return void
|
||||
*/
|
||||
function endHandler($parser, $element)
|
||||
{
|
||||
if ($element == $this->insideTag) {
|
||||
$this->insideTag = '';
|
||||
}
|
||||
|
||||
switch ($element) {
|
||||
case 'PRESENTATION':
|
||||
$this->coid = array_pop($this->stack);
|
||||
break;
|
||||
}
|
||||
$this->activeTag = '';
|
||||
$this->last_handler = 'end';
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ cdataHandler()
|
||||
|
||||
/**
|
||||
* Handler for character data
|
||||
*
|
||||
* @access private
|
||||
* @param object XML parser object
|
||||
* @param string CDATA
|
||||
* @return void
|
||||
*/
|
||||
function cdataHandler($parser, $cdata)
|
||||
{
|
||||
if(empty($this->activeTag)) return;
|
||||
|
||||
$el = strtolower($this->activeTag);
|
||||
if($el == 'slide') {
|
||||
$idx = count($this->objects[$this->coid]->slides) - 1;
|
||||
if($this->last_handler == 'cdata')
|
||||
$this->objects[$this->coid]->slides[$idx]->filename .= $cdata;
|
||||
else
|
||||
$this->objects[$this->coid]->slides[$idx]->filename = $cdata;
|
||||
} else {
|
||||
if($this->last_handler == 'cdata') {
|
||||
$this->objects[$this->coid]->$el .= $cdata;
|
||||
} else {
|
||||
$this->objects[$this->coid]->$el = $cdata;
|
||||
}
|
||||
}
|
||||
|
||||
$this->last_handler = 'cdata';
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ _add_attribs
|
||||
function _add_attribs(&$object, $attribs, $prefix='') {
|
||||
foreach($attribs as $attr=>$value) {
|
||||
$a = empty($prefix) ? strtolower($attr) : $prefix.ucfirst(strtolower($attr));
|
||||
$object->$a = $value;
|
||||
}
|
||||
}
|
||||
// }}}
|
||||
// {{{ getObjects()
|
||||
|
||||
/**
|
||||
* Get Presentation Objects
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
function getObjects()
|
||||
{
|
||||
return $this->objects;
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
}
|
||||
?>
|
||||
221
XML_Slide.php
Normal file
221
XML_Slide.php
Normal file
@@ -0,0 +1,221 @@
|
||||
<?php
|
||||
// {{{ header
|
||||
// vim: set expandtab tabstop=4 shiftwidth=4 fdm=marker:
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP Version 4 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1997-2002 The PHP Group |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | This source file is subject to version 2.02 of the PHP license, |
|
||||
// | that is bundled with this package in the file LICENSE, and is |
|
||||
// | available at through the world-wide-web at |
|
||||
// | http://www.php.net/license/2_02.txt. |
|
||||
// | If you did not receive a copy of the PHP license and are unable to |
|
||||
// | obtain it through the world-wide-web, please send a note to |
|
||||
// | license@php.net so we can mail you a copy immediately. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Authors: Rasmus Lerdorf <rasmus@php.net> |
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
// $Id$
|
||||
// }}}
|
||||
|
||||
require_once 'XML/Parser.php';
|
||||
require_once 'objects.php';
|
||||
|
||||
/**
|
||||
* Slide parser class.
|
||||
*
|
||||
* This class is a parser for a made up presentation slide format
|
||||
*
|
||||
* @author Rasmus Lerdorf <rasmus@php.net>
|
||||
* @version $Revision$
|
||||
* @access public
|
||||
*/
|
||||
class XML_Slide extends XML_Parser
|
||||
{
|
||||
|
||||
// {{{ properties
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
var $insideTag = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
var $activeTag = '';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
var $objects = array();
|
||||
|
||||
/**
|
||||
* @var int
|
||||
* Current Object Index
|
||||
*/
|
||||
var $coid = 0;
|
||||
|
||||
var $last_handler;
|
||||
|
||||
var $stack = array();
|
||||
|
||||
// }}}
|
||||
// {{{ Constructor
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @access public
|
||||
* @param mixed File pointer or name of the slide file.
|
||||
* @return void
|
||||
*/
|
||||
function XML_Slide($handle = '')
|
||||
{
|
||||
$this->XML_Parser();
|
||||
|
||||
if (@is_resource($handle)) {
|
||||
$this->setInput($handle);
|
||||
} elseif ($handle != '') {
|
||||
$this->setInputFile($handle);
|
||||
} else {
|
||||
$this->raiseError('No filename passed.');
|
||||
}
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ startHandler()
|
||||
|
||||
/**
|
||||
* Start element handler for XML parser
|
||||
*
|
||||
* @access private
|
||||
* @param object XML parser object
|
||||
* @param string XML element
|
||||
* @param array Attributes of XML tag
|
||||
* @return void
|
||||
*/
|
||||
function startHandler($parser, $element, $attribs)
|
||||
{
|
||||
switch ($element) {
|
||||
/* These tags can have other tags inside */
|
||||
case 'SLIDE':
|
||||
case 'BLURB':
|
||||
case 'IMAGE':
|
||||
case 'LIST':
|
||||
case 'EXAMPLE':
|
||||
$cl = '_'.strtolower($element);
|
||||
$this->objects[++$this->coid] = new $cl();
|
||||
$this->stack[] = $this->coid;
|
||||
$this->insideTag = $element;
|
||||
$this->_add_attribs($this->objects[$this->coid], $attribs);
|
||||
break;
|
||||
|
||||
/* Special case for array properties */
|
||||
case 'BULLET':
|
||||
$this->objects[$this->coid]->bullets[] = new _bullet();
|
||||
$idx = count($this->objects[$this->coid]->bullets) - 1;
|
||||
$this->_add_attribs($this->objects[$this->coid]->bullets[$idx], $attribs);
|
||||
$this->activeTag = $element;
|
||||
break;
|
||||
|
||||
/* Everything else can't */
|
||||
default:
|
||||
$this->activeTag = $element;
|
||||
$this->_add_attribs($this->objects[$this->coid], $attribs, strtolower($element));
|
||||
break;
|
||||
}
|
||||
$this->last_handler = 'start';
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ endHandler()
|
||||
|
||||
/**
|
||||
* End element handler for XML parser
|
||||
*
|
||||
* @access private
|
||||
* @param object XML parser object
|
||||
* @param string
|
||||
* @return void
|
||||
*/
|
||||
function endHandler($parser, $element)
|
||||
{
|
||||
if ($element == $this->insideTag) {
|
||||
$this->insideTag = '';
|
||||
}
|
||||
|
||||
switch ($element) {
|
||||
case 'SLIDE':
|
||||
case 'BLURB':
|
||||
case 'IMAGE':
|
||||
case 'LIST':
|
||||
case 'EXAMPLE':
|
||||
$this->coid = array_pop($this->stack);
|
||||
break;
|
||||
}
|
||||
$this->activeTag = '';
|
||||
$this->last_handler = 'end';
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ cdataHandler()
|
||||
|
||||
/**
|
||||
* Handler for character data
|
||||
*
|
||||
* @access private
|
||||
* @param object XML parser object
|
||||
* @param string CDATA
|
||||
* @return void
|
||||
*/
|
||||
function cdataHandler($parser, $cdata)
|
||||
{
|
||||
if(empty($this->activeTag)) return;
|
||||
|
||||
$el = strtolower($this->activeTag);
|
||||
if($el == 'bullet') {
|
||||
$idx = count($this->objects[$this->coid]->bullets) - 1;
|
||||
if($this->last_handler == 'cdata')
|
||||
$this->objects[$this->coid]->bullets[$idx]->text .= $cdata;
|
||||
else
|
||||
$this->objects[$this->coid]->bullets[$idx]->text = $cdata;
|
||||
} else {
|
||||
if($this->last_handler == 'cdata') {
|
||||
$this->objects[$this->coid]->$el .= $cdata;
|
||||
} else {
|
||||
$this->objects[$this->coid]->$el = $cdata;
|
||||
}
|
||||
}
|
||||
|
||||
$this->last_handler = 'cdata';
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ _add_attribs
|
||||
function _add_attribs(&$object, $attribs, $prefix='') {
|
||||
foreach($attribs as $attr=>$value) {
|
||||
$a = empty($prefix) ? strtolower($attr) : $prefix.ucfirst(strtolower($attr));
|
||||
$object->$a = $value;
|
||||
}
|
||||
}
|
||||
// }}}
|
||||
// {{{ getObjects()
|
||||
|
||||
/**
|
||||
* Get Slide Objects
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
function getObjects()
|
||||
{
|
||||
return $this->objects;
|
||||
}
|
||||
|
||||
// }}}
|
||||
|
||||
}
|
||||
?>
|
||||
6
config.php-dist
Normal file
6
config.php-dist
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
$presentationDir = 'presentations';
|
||||
$baseDir = '/pres2/';
|
||||
$showScript = 'show.php'; // In case you want to ForceType a shorter one
|
||||
$helpPage = 'help.php';
|
||||
?>
|
||||
116
flash.php
Normal file
116
flash.php
Normal file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
// Load class definitions
|
||||
require_once 'objects.php';
|
||||
require_once 'config.php';
|
||||
|
||||
session_start();
|
||||
|
||||
$m = new SWFMovie();
|
||||
|
||||
/*
|
||||
$fp = fopen("/tmp/debug.txt","w");
|
||||
fputs($fp,"coid=$coid\ntype=$type\ntext=".($objs[$coid]->title)."\n");
|
||||
fclose($fp);
|
||||
*/
|
||||
switch($type) {
|
||||
case 'title':
|
||||
// Entire movie will get key events - make shape that covers the whole thing
|
||||
$s = new SWFShape();
|
||||
$s->setRightFill($s->addFill(0, 0, 0));
|
||||
$s->drawLine($dx, 0);
|
||||
$s->drawLine(0, $dy);
|
||||
$s->drawLine(-$dx, 0);
|
||||
$s->drawLine(0, -$dy);
|
||||
|
||||
// Need a button to receive the key events - shape from above
|
||||
$b = new SWFButton();
|
||||
$b->addShape($s, SWFBUTTON_KEYPRESS);
|
||||
|
||||
// Space bar or Enter takes us to the next slide
|
||||
if($slideNum < $maxSlideNum) {
|
||||
$next = $slideNum+1;
|
||||
$b->addAction(new SWFAction("getURL('http://$HTTP_HOST$baseDir$showScript/$currentPres/$next','_self');"), swfbutton_keypress(' '));
|
||||
$b->addAction(new SWFAction("getURL('http://$HTTP_HOST$baseDir$showScript/$currentPres/$next','_self');"), swfbutton_keypress(chr(13)));
|
||||
}
|
||||
|
||||
// Backspace or DEL bar takes us to the previous slide
|
||||
if($slideNum > 0) {
|
||||
$prev = $slideNum - 1;
|
||||
$b->addAction(new SWFAction("getURL('http://$HTTP_HOST$baseDir$showScript/$currentPres/$prev','_self');"), swfbutton_keypress(chr(8)));
|
||||
$b->addAction(new SWFAction("getURL('http://$HTTP_HOST$baseDir$showScript/$currentPres/$prev','_self');"), swfbutton_keypress(chr(127)));
|
||||
}
|
||||
|
||||
// ESC reloads the current slide
|
||||
$b->addAction(new SWFAction("getURL('http://$HTTP_HOST$baseDir$showScript/$currentPres/$slideNum','_self');"), swfbutton_keypress(chr(27)));
|
||||
|
||||
// ? brings up the help page
|
||||
$b->addAction(new SWFAction("getURL('http://$HTTP_HOST$baseDir$helpPage','_blank');"), swfbutton_keypress('?'));
|
||||
|
||||
$f = new SWFFont($objs[$coid]->titleFont);
|
||||
$m->setBackground(0x66, 0x66, 0x99);
|
||||
$t = new SWFText();
|
||||
$t->setFont($f);
|
||||
|
||||
$rgb = rgb($objs[$coid]->titleColor);
|
||||
$t->setColor($rgb[0], $rgb[1], $rgb[2]);
|
||||
|
||||
$tHeight = $objs[$coid]->titleSize;
|
||||
$t->setHeight($tHeight);
|
||||
|
||||
$tText = $objs[$coid]->title;
|
||||
$t->addString($tText);
|
||||
|
||||
$m->setDimension($dx, $dy);
|
||||
|
||||
// Add the text to the movie and position it
|
||||
$i = $m->add($t);
|
||||
$i->moveTo((int)($dx/2)-$t->getWidth($tText)/2, $dy-round($t->getDescent())-($dy-$tHeight)/2);
|
||||
|
||||
// Don't forget to add the button
|
||||
$m->add($b);
|
||||
break;
|
||||
|
||||
case 'blurb':
|
||||
$m->setBackground(0xff, 0xff, 0xff);
|
||||
$m->setDimension($dx, $dy);
|
||||
$t = new SWFTextField();
|
||||
|
||||
if(!empty($objs[$coid]->title)) {
|
||||
$rgb = rgb($objs[$coid]->titleColor);
|
||||
$t->setColor($rgb[0], $rgb[1], $rgb[2]);
|
||||
$t = new SWFText();
|
||||
$f = new SWFFont($objs[$coid]->font);
|
||||
$t->setFont($f);
|
||||
$t->setHeight($objs[$coid]->titleSize);
|
||||
$t->addString($objs[$coid]->title);
|
||||
$i = $m->add($t);
|
||||
if($in==0) $i->moveTo(5, 0);
|
||||
}
|
||||
foreach($el['text'] as $in=>$val) {
|
||||
if(!empty($el['text'][$in]['data'])) {
|
||||
$t = new SWFTextField();
|
||||
$t->setColor($defaultColor[0], $defaultColor[1], $defaultColor[2]);
|
||||
$t->align(SWFTEXTFIELD_ALIGN_LEFT);
|
||||
$t->setFont($f);
|
||||
$t->setHeight((int)($_GET['h']/5));
|
||||
$t->addString($el['text'][$in]['data']);
|
||||
$i = $m->add($t);
|
||||
if($in==0) $i->moveTo(15, 5);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
header('Content-type: application/x-shockwave-flash');
|
||||
$m->output();
|
||||
|
||||
function rgb($rgb) {
|
||||
if(strlen($rgb)==6) {
|
||||
$r = hexdec(substr($rgb,0,2));
|
||||
$g = hexdec(substr($rgb,2,2));
|
||||
$b = hexdec(substr($rgb,4,2));
|
||||
} else $r = $g = $b = 0;
|
||||
return array($r,$g,$b);
|
||||
}
|
||||
?>
|
||||
BIN
fonts/AriaBlack.fdb
Normal file
BIN
fonts/AriaBlack.fdb
Normal file
Binary file not shown.
BIN
fonts/Arial.fdb
Normal file
BIN
fonts/Arial.fdb
Normal file
Binary file not shown.
BIN
fonts/BankGothic.fdb
Normal file
BIN
fonts/BankGothic.fdb
Normal file
Binary file not shown.
BIN
fonts/Bimini.fdb
Normal file
BIN
fonts/Bimini.fdb
Normal file
Binary file not shown.
BIN
fonts/Calligraph.fdb
Normal file
BIN
fonts/Calligraph.fdb
Normal file
Binary file not shown.
BIN
fonts/CenturGothic.fdb
Normal file
BIN
fonts/CenturGothic.fdb
Normal file
Binary file not shown.
BIN
fonts/CourierNew.fdb
Normal file
BIN
fonts/CourierNew.fdb
Normal file
Binary file not shown.
BIN
fonts/HachipochK.fdb
Normal file
BIN
fonts/HachipochK.fdb
Normal file
Binary file not shown.
BIN
fonts/Impact.fdb
Normal file
BIN
fonts/Impact.fdb
Normal file
Binary file not shown.
BIN
fonts/ManiacA.fdb
Normal file
BIN
fonts/ManiacA.fdb
Normal file
Binary file not shown.
BIN
fonts/ParkAvenue.fdb
Normal file
BIN
fonts/ParkAvenue.fdb
Normal file
Binary file not shown.
BIN
fonts/QUAKE.fdb
Normal file
BIN
fonts/QUAKE.fdb
Normal file
Binary file not shown.
BIN
fonts/RoughBrush.fdb
Normal file
BIN
fonts/RoughBrush.fdb
Normal file
Binary file not shown.
BIN
fonts/StaccatoBT.fdb
Normal file
BIN
fonts/StaccatoBT.fdb
Normal file
Binary file not shown.
BIN
fonts/Techno.fdb
Normal file
BIN
fonts/Techno.fdb
Normal file
Binary file not shown.
BIN
fonts/TimesNewRoman.fdb
Normal file
BIN
fonts/TimesNewRoman.fdb
Normal file
Binary file not shown.
BIN
fonts/TrebucheMS.fdb
Normal file
BIN
fonts/TrebucheMS.fdb
Normal file
Binary file not shown.
BIN
fonts/Verdana.fdb
Normal file
BIN
fonts/Verdana.fdb
Normal file
Binary file not shown.
BIN
fonts/Webdings.fdb
Normal file
BIN
fonts/Webdings.fdb
Normal file
Binary file not shown.
BIN
fonts/Wingdings.fdb
Normal file
BIN
fonts/Wingdings.fdb
Normal file
Binary file not shown.
21
help.php
Normal file
21
help.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Help Page</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Keystrokes</h1>
|
||||
<p>Note that your mouse cursor must be in the top navigation area of the
|
||||
screen for the keystrokes to work. This is to allow normal interactive
|
||||
slides to work correctly.</p>
|
||||
<table border=2>
|
||||
<tr><th align="center">Key</th><th>Action</th></tr>
|
||||
<tr><td align="center"><space></td><td>Next Slide</td></tr>
|
||||
<tr><td align="center"><Enter></td><td>Next Slide</td></tr>
|
||||
<tr><td align="center"><Backspace></td><td>Previous Slide</td></tr>
|
||||
<tr><td align="center"><DEL></td><td>Previous Slide</td></tr>
|
||||
<tr><td align="center"><ESC></td><td>Reload Current Slide</td></tr>
|
||||
<tr><td align="center">?</td><td>This Help File</td></tr>
|
||||
</table>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
57
index.php
Normal file
57
index.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
require_once 'config.php';
|
||||
|
||||
session_start();
|
||||
|
||||
require_once 'XML_Presentation.php';
|
||||
|
||||
$dir = opendir($presentationDir);
|
||||
while($file = readdir($dir)) {
|
||||
if($file[0]!='.' && substr($file,-4)=='.xml') {
|
||||
$i = substr($file,0,strpos($file,'.'));
|
||||
$ps[$i] = "$presentationDir/$file";
|
||||
}
|
||||
}
|
||||
closedir($dir);
|
||||
|
||||
foreach($ps as $i=>$filename) {
|
||||
$p =& new XML_Presentation($filename);
|
||||
$p->setErrorHandling(PEAR_ERROR_DIE,"%s\n");
|
||||
$p->parse();
|
||||
$pres = $p->getObjects();
|
||||
$slidecount[$i] = count($pres[1]->slides);
|
||||
$title[$i] = $pres[1]->title;
|
||||
if(isset($pres[1]->date)) {
|
||||
$tmp = strtotime($pres[1]->date);
|
||||
if($tmp==-1) $date[$i] = $pres[1]->date;
|
||||
else $date[$i] = date('M j, Y',$tmp);
|
||||
} else $date[$i] = ' ';
|
||||
if(isset($pres[1]->speaker)) {
|
||||
$speaker[$i] = $pres[1]->speaker;
|
||||
} else $speaker[$i] = ' ';
|
||||
if(isset($pres[1]->location)) {
|
||||
$location[$i] = $pres[1]->location;
|
||||
} else $location[$i] = ' ';
|
||||
}
|
||||
|
||||
asort($date); // Sort presentations by date
|
||||
reset($ps);
|
||||
echo <<<TOP
|
||||
<html>
|
||||
<head>
|
||||
<title>Presentations</title>
|
||||
<base href="http://$HTTP_HOST$baseDir">
|
||||
</head>
|
||||
<body>
|
||||
TOP;
|
||||
echo "<h1>Available Presentations</h1>\n";
|
||||
echo "<table><tr><th>ID</th><th>Title</th><th>Date</th><th>Location</th><th>Speaker</th><th>Slides</th></tr>\n";
|
||||
foreach($date as $i=>$date) {
|
||||
echo <<<ROW
|
||||
<tr><th align="left"><a href="$showScript/$i">$i</a></th><td>$title[$i]</td><td>$date</td><td>$location[$i]</td><td>$speaker[$i]</td><td align="right">$slidecount[$i]</td></tr>
|
||||
ROW;
|
||||
}
|
||||
echo "</table>\n";
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
207
objects.php
Normal file
207
objects.php
Normal file
@@ -0,0 +1,207 @@
|
||||
<?php
|
||||
// vim: set tabstop=4 shiftwidth=4 fdm=marker:
|
||||
|
||||
// {{{ Helper functions
|
||||
|
||||
// {{{ getFLashDimensions - Find the height and width of the given flash string
|
||||
function getFlashDimensions($font,$title,$size) {
|
||||
$f = new SWFFont($font);
|
||||
$t = new SWFText();
|
||||
$t->setFont($f);
|
||||
$t->setHeight($size);
|
||||
$dx = $t->getWidth($title) + 10;
|
||||
$dy = $size+10;
|
||||
return array($dx,$dy);
|
||||
}
|
||||
// }}}
|
||||
|
||||
// }}}
|
||||
|
||||
// {{{ Presentation List Classes
|
||||
class _presentation {
|
||||
function _presentation() {
|
||||
$this->title = 'No Title Text for this presentation yet';
|
||||
$this->navmode = 'flash';
|
||||
}
|
||||
}
|
||||
|
||||
class _pres_slide {
|
||||
function _pres_slide() {
|
||||
$this->filename = '';
|
||||
}
|
||||
}
|
||||
// }}}
|
||||
|
||||
// {{{ Slide Class
|
||||
class _slide {
|
||||
|
||||
function _slide() {
|
||||
$this->title = 'No Title Text for this slide yet';
|
||||
$this->titleSize = 18;
|
||||
$this->titleColor = 'ffffff';
|
||||
$this->titleAlign = 'center';
|
||||
$this->titleFont = 'fonts/Arial.fdb';
|
||||
$this->mode = 'flash';
|
||||
}
|
||||
|
||||
function display() {
|
||||
if(isset($this->titleMode)) $this->{$this->titleMode}();
|
||||
else $this->{$this->mode}();
|
||||
}
|
||||
|
||||
function html() {
|
||||
?>
|
||||
<h1 align=<?=$this->titleAlign?>><?=$this->title?></h1>
|
||||
<?php
|
||||
}
|
||||
|
||||
function flash() {
|
||||
global $coid, $winW, $winH;
|
||||
|
||||
list($dx,$dy) = getFlashDimensions($this->titleFont,$this->title,$this->titleSize);
|
||||
$dx = $winW; // full width
|
||||
?>
|
||||
<div align="<?=$this->titleAlign?>" class="sticky">
|
||||
<embed src="/pres2/flash.php/<?echo time()?>?type=title&dy=<?=$dy?>&dx=<?=$dx?>&coid=<?=$coid?>" quality=high loop=false
|
||||
pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"
|
||||
type="application/x-shockwave-flash" width="<?=$dx?>" height="<?=$dy?>">
|
||||
</embed>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
}
|
||||
// }}}
|
||||
|
||||
// {{{ Blurb Class
|
||||
class _blurb {
|
||||
|
||||
function _blurb() {
|
||||
$this->font = 'fonts/Arial.fdb';
|
||||
$this->align = 'left';
|
||||
$this->title = "No Blurb Title";
|
||||
$this->titleSize = 16;
|
||||
$this->titleColor = 'ff1122';
|
||||
$this->text = "No Blurb Text";
|
||||
$this->textSize = 14;
|
||||
$this->textColor = '000000';
|
||||
$this->mode = 'html';
|
||||
}
|
||||
|
||||
function display() {
|
||||
$this->{$this->mode}();
|
||||
}
|
||||
|
||||
function html() {
|
||||
?>
|
||||
<h1><?=$this->title?></h1>
|
||||
<blockquote><p><?=$this->text?></p></blockquote>
|
||||
<?php
|
||||
|
||||
}
|
||||
}
|
||||
// }}}
|
||||
|
||||
// {{{ Image Class
|
||||
class _image {
|
||||
function _image() {
|
||||
$this->filename = '';
|
||||
$this->mode = 'html';
|
||||
$this->align = 'left';
|
||||
}
|
||||
|
||||
function display() {
|
||||
$this->{$this->mode}();
|
||||
}
|
||||
|
||||
function html() {
|
||||
if(isset($this->title)) echo '<h1>'.$this->title."</h1>\n";
|
||||
$size = getimagesize($this->filename);
|
||||
?>
|
||||
<div align="<?=$this->align?>">
|
||||
<img src="<?=$this->filename?>" <?=$size[3]?>>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
}
|
||||
}
|
||||
// }}}
|
||||
|
||||
// {{{ Example Class
|
||||
class _example {
|
||||
function _example() {
|
||||
$this->filename = '';
|
||||
$this->type = 'php';
|
||||
$this->mode = 'html';
|
||||
$this->fontsize = '2em';
|
||||
$this->rfontsize = '1.8em';
|
||||
}
|
||||
|
||||
function display() {
|
||||
$this->{$this->mode}();
|
||||
}
|
||||
|
||||
function html() {
|
||||
if(isset($this->title)) echo '<h1>'.$this->title."</h1>\n";
|
||||
$sz = (float) $this->fontsize;
|
||||
if(!$sz) $sz = 0.1;
|
||||
$offset = (1/$sz).'em';
|
||||
echo '<div class="shadow"><div class="emcode" style="font-size: '.$sz."em; margin: -$offset 0 0 -$offset;\">\n";
|
||||
if(!empty($this->filename)) highlight_file($this->filename);
|
||||
else highlight_string($this->text);
|
||||
echo "</div></div>\n";
|
||||
if(!empty($this->result) && $this->result!='no') {
|
||||
echo "<h2>Output</h2>\n";
|
||||
$sz = (float) $this->rfontsize;
|
||||
if(!$sz) $sz = 0.1;
|
||||
$offset = (1/$sz).'em';
|
||||
echo '<div class="shadow"><div class="output" style="font-size: '.$sz."em; margin: -$offset 0 0 -$offset;\">\n";
|
||||
if(!empty($this->filename)) include $this->filename;
|
||||
else eval('?>'.$this->text);
|
||||
echo "</div></div>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
// }}}
|
||||
|
||||
// {{{ List Class
|
||||
class _list {
|
||||
function _list() {
|
||||
$this->mode = 'html';
|
||||
}
|
||||
|
||||
function display() {
|
||||
$this->{$this->mode}();
|
||||
}
|
||||
|
||||
function html() {
|
||||
if(isset($this->title))
|
||||
echo '<h1>'.$this->title."</h1>\n";
|
||||
echo '<ul>';
|
||||
while(list($k,$bul)=each($this->bullets)) $bul->display();
|
||||
echo '</ul>';
|
||||
}
|
||||
}
|
||||
// }}}
|
||||
|
||||
// {{{ Bullet Class
|
||||
class _bullet {
|
||||
|
||||
function _bullet() {
|
||||
$this->mode = 'html';
|
||||
$this->text = '';
|
||||
}
|
||||
|
||||
function display() {
|
||||
$this->{$this->mode}();
|
||||
}
|
||||
|
||||
function html() {
|
||||
if(!empty($this->fontsize)) $style = "style=\"font-size: ".$this->fontsize.';"';
|
||||
echo '<li $style>'.$this->text."</li>\n";
|
||||
}
|
||||
|
||||
}
|
||||
// }}}
|
||||
|
||||
?>
|
||||
145
show.php
Normal file
145
show.php
Normal file
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
require_once 'config.php';
|
||||
|
||||
if(!strlen($PATH_INFO)) {
|
||||
header('Location: http://'.$HTTP_HOST.$baseDir.'list.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
session_start();
|
||||
session_register('pres');
|
||||
session_register('objs');
|
||||
session_register('winH');
|
||||
session_register('winW');
|
||||
session_register('currentPres');
|
||||
session_register('slideNum');
|
||||
session_register('maxSlideNum');
|
||||
|
||||
$presFile = trim($PATH_INFO);
|
||||
$presFile = trim($presFile,'/');
|
||||
list($currentPres,$slideNum) = explode('/',$presFile);
|
||||
if(!$slideNum) $slideNum = 0;
|
||||
if($slideNum<0) $slideNum = 0;
|
||||
$presFile = str_replace('..','',$currentPres); // anti-hack
|
||||
$presFile = "$presentationDir/$presFile".'.xml';
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<base href="<?="http://$HTTP_HOST".$baseDir?>">
|
||||
<?/*
|
||||
A bit of fancy footwork to get the browser's inside dimensions in
|
||||
pixels. Should work on both NS4+ and IE4+. If it doesn't we default
|
||||
it to something sane. The dimensions are returned to the server via
|
||||
a Javascript cookie so as to not muck up our nice clean URL. The
|
||||
function is called if we don't have the dimensions already, or on a
|
||||
resize event to fetch the new window dimensions.
|
||||
*/?>
|
||||
<script language="JavaScript1.2">
|
||||
<!--
|
||||
function get_dims() {
|
||||
var winW = 1024;
|
||||
var winH = 650;
|
||||
|
||||
if (window.innerWidth) {
|
||||
winW = window.innerWidth;
|
||||
winH = window.innerHeight;
|
||||
} else if (document.all) {
|
||||
winW = document.body.clientWidth;
|
||||
winH = document.body.clientHeight;
|
||||
}
|
||||
document.cookie="dims="+winW+"_"+winH;
|
||||
top.location=top.location.href;
|
||||
}
|
||||
<?if(!isset($dims)) {?>
|
||||
get_dims();
|
||||
<? } ?>
|
||||
-->
|
||||
</script>
|
||||
<? if(isset($dims)) {
|
||||
list($winW, $winH) = explode('_',$dims);
|
||||
}
|
||||
/* The stylesheet will move out into its own file soon,
|
||||
it is just a bit easier working with an embedded one
|
||||
for now while it changes often. */
|
||||
?>
|
||||
<style title="Default" type="text/css">
|
||||
body {
|
||||
font-size: 12pt;
|
||||
margin-left:1.5em;
|
||||
margin-right:0em;
|
||||
margin-top:6em;
|
||||
margin-bottom:0em;
|
||||
}
|
||||
div.sticky {
|
||||
margin: 0;
|
||||
position: absolute;
|
||||
position: fixed;
|
||||
top: 0em;
|
||||
left: 0em;
|
||||
right: auto;
|
||||
bottom: auto;
|
||||
width: auto;
|
||||
}
|
||||
div.shadow {
|
||||
background: #777777;
|
||||
padding: 0.5em;
|
||||
margin: 0 1em 0 0;
|
||||
}
|
||||
div.emcode {
|
||||
background: #cccccc;
|
||||
border: thin solid #000000;
|
||||
padding: 0.5em;
|
||||
}
|
||||
div.output {
|
||||
font-family: monospace;
|
||||
background: #cccc55;
|
||||
border: thin solid #000000;
|
||||
padding: 0.5em;
|
||||
}
|
||||
h1 {
|
||||
font-size: 2em;
|
||||
}
|
||||
p,li {
|
||||
font-size: 2.6em;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<?php
|
||||
error_reporting(E_ALL);
|
||||
|
||||
require_once 'XML_Presentation.php';
|
||||
require_once 'XML_Slide.php';
|
||||
|
||||
$p =& new XML_Presentation($presFile);
|
||||
$p->setErrorHandling(PEAR_ERROR_DIE,"%s\n");
|
||||
$p->parse();
|
||||
$pres = $p->getObjects();
|
||||
|
||||
$maxSlideNum = count($pres[1]->slides)-1;
|
||||
|
||||
// Make sure we don't go beyond the last slide
|
||||
if($slideNum > $maxSlideNum) {
|
||||
$slideNum = $maxSlideNum;
|
||||
}
|
||||
$r =& new XML_Slide($pres[1]->slides[$slideNum]->filename);
|
||||
$r->setErrorHandling(PEAR_ERROR_DIE,"%s\n");
|
||||
$r->parse();
|
||||
|
||||
$objs = $r->getObjects();
|
||||
|
||||
?>
|
||||
<body onResize="get_dims();">
|
||||
<?php
|
||||
while(list($coid,$obj) = each($objs)) {
|
||||
$obj->display();
|
||||
}
|
||||
/*
|
||||
echo "<pre>";
|
||||
print_r($pres);
|
||||
print_r($objs);
|
||||
echo "</pre>";
|
||||
*/
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user