- XHTML fixes (that was need to make Firefox work with my new CSS correctly).

- Fixed some call-time-pass-by-reference warnings.
- Allow a new tag "div" , on which effect=slide works as well.
- Changed how body tags are added, so that we can pick a CSS class for the
  body tag dependent on the template.
- Changed some of the ways on how slide XML is opened, related to incomplete
  PHP 6 implementations of functions.

#- Rasmus, I tested those changes with a few of your talks as well, they look
#  fine here, but you might want to double check.
This commit is contained in:
Derick Rethans
2007-05-03 11:28:39 +00:00
parent a36a054643
commit 26b4e55785
7 changed files with 63 additions and 34 deletions

View File

@@ -106,7 +106,7 @@ class XML_Presentation extends XML_Parser
* @param array Attributes of XML tag
* @return void
*/
function startHandler($parser, $element, $attribs)
function startHandler($parser, $element, &$attribs)
{
switch ($element) {
/* These tags can have other tags inside */

View File

@@ -77,7 +77,6 @@ class XML_Slide extends XML_Parser
function XML_Slide($handle = '')
{
$this->XML_Parser();
if (@is_resource($handle)) {
$this->setInput($handle);
} elseif ($handle != '') {
@@ -99,7 +98,7 @@ class XML_Slide extends XML_Parser
* @param array Attributes of XML tag
* @return void
*/
function startHandler($parser, $element, $attribs)
function startHandler($parser, $element, &$attribs)
{
switch ($element) {
/* These tags can have other tags inside */
@@ -121,6 +120,15 @@ class XML_Slide extends XML_Parser
$this->activeTag = 'text';
break;
case 'DIV':
$cl = '_'.strtolower($element);
$this->objects[++$this->coid] = new $cl();
$this->stack[] = $this->coid;
$this->insideTag = $element;
$this->_add_attribs($this->objects[$this->coid], $attribs);
$this->activeTag = 'text';
break;
/* Divider for indicating where to switch areas for layouts */
case 'DIVIDE':
$cl = '_'.strtolower($element);
@@ -181,7 +189,7 @@ class XML_Slide extends XML_Parser
switch ($element) {
case 'SLIDE':
$this->objects[++$this->coid] = new _footer();
$this->objects[] = new _footer();
/* fall-through */
case 'BLURB':
case 'IMAGE':
@@ -190,7 +198,10 @@ class XML_Slide extends XML_Parser
case 'LINK':
case 'PHP':
case 'DIVIDE':
case 'TABLE':
$this->coid = array_pop($this->stack);
break;
case 'DIV':
$this->objects[++$this->coid] = new _div_end();
$this->coid = array_pop($this->stack);
break;
case 'BULLET':

View File

@@ -57,7 +57,7 @@ class html extends display {
echo <<<HEADER
<html>
<head>
<base href="http://$_SERVER[HTTP_HOST]$this->baseDir">
<base href="http://$_SERVER[HTTP_HOST]$this->baseDir"/>
<title>{$presentation->title}</title>
HEADER;
switch($presentation->template) {
@@ -71,6 +71,7 @@ HEADER;
$body_style = "margin-top: " . ($browser_is_IE ? "0px" : "8em") . ";";
break;
}
$this->body_style = $body_style;
include 'getwidth.php';
include $presentation->stylesheet;
/* the following includes scripts necessary for various animations */
@@ -79,17 +80,22 @@ HEADER;
if($this->slideNum) echo '<link rel="prev" href="'.$this->presentationDir.'/'.$presentation->slides[$this->prevSlideNum]->filename."\" />\n";
if($this->nextSlideNum) echo '<link rel="next" href="'.$this->presentationDir.'/'.$presentation->slides[$this->nextSlideNum]->filename."\" />\n";
echo '</head>';
echo "<body onResize=\"get_dims();\" style=\"".$body_style."\">\n";
while(list($this->coid,$obj) = each($this->objs)) {
$obj->display();
}
echo <<<FOOTER
</body>
</html>
FOOTER;
}
function _slide(&$slide) {
$body_style = $this->body_style;
$class = '';
if ($this->pres->template != 'php')
{
$class = " class='{$slide->template}'";
}
echo "<body onResize=\"get_dims();\" style=\"".$body_style."\"$class>\n";
$currentPres = $_SESSION['currentPres'];
$navsize = $slide->navsize;
@@ -117,7 +123,7 @@ FOOTER;
break;
case 'php2':
echo "<div id=\"stickyBar\" class=\"sticky\" align=\"$slide->titleAlign\" style=\"width: 100%\"><div class=\"navbar\">";
echo "<div id=\"stickyBar\" class=\"sticky\" align=\"$slide->titleAlign\" style=\"align: {$slide->titleAlign}; width: 100%\"><div class=\"navbar\">";
echo "<table style=\"float: left;\" width=\"60%\" border=\"0\" cellpadding=0 cellspacing=0><tr>\n";
if(!empty($slide->logo1)) $logo1 = $slide->logo1;
else $logo1 = $this->pres->logo1;
@@ -229,7 +235,8 @@ ENDD;
echo "<div style=\"float: left; margin: -0.2em 2em 0 0; font-size: $navsize;\"><a href=\"http://$_SERVER[HTTP_HOST]$this->baseDir$this->showScript/$currentPres/$prev\" style=\"text-decoration: none; color: $slide->navcolor;\">".markup_text($this->prevTitle)."</a></div>";
echo "<div style=\"float: right; margin: -0.2em 2em 0 0; color: $slide->navcolor; font-size: $navsize;\"><a href=\"http://$_SERVER[HTTP_HOST]$this->baseDir$this->showScript/$currentPres/$next\" style=\"text-decoration: none; color: $slide->navcolor;\">".markup_text($this->nextTitle)."</a></div>";
}
echo '</div></div><div class="mainarea">';
echo "</div></div>\n";
echo "<div class=\"mainarea\">\n";
break;
case 'php':
@@ -340,7 +347,9 @@ ENDD;
function _image(&$image) {
$effect = '';
$class = '';
$alt = ' alt=""';
if($image->effect) $effect = "effect=\"$#image->effect\"";
if(isset($image->alt)) $alt = " alt='{$image->title}'";
if(isset($image->title)) echo "<h1 align=\"{$image->talign}\">".markup_text($image->title)."</h1>\n";
if ($image->width) {
$size = "width=\"{$image->width}\" height=\"{$image->height}\"";
@@ -359,7 +368,7 @@ ENDD;
}
?>
<div <?php echo $effect?> align="<?php echo $image->align?>" style="margin-left: <?php echo $image->marginleft?>; margin-right: <?php echo $image->marginright?>;">
<img align="<?php echo $image->align?>" src="<?php echo $this->slideDir.$image->filename?>" <?php echo $size?><?php echo $class?>>
<img align="<?php echo $image->align?>" src="<?php echo $this->slideDir.$image->filename?>" <?php echo $size?><?php echo $class?><?php echo $alt?>/>
</div>
<?php
if(isset($image->clear)) echo "<br clear=\"".$image->clear."\"/>\n";
@@ -670,16 +679,16 @@ type=\"application/x-shockwave-flash\" width=$example->iwidth height=$example->i
if (isset($bullet->class)) {
$class = $bullet->class;
} else {
$class = "pres_bullet'";
$class = "pres_bullet";
}
$attrs = '';
if (isset($bullet->effect) && !empty($bullet->effect)) {
$attrs = " style='' effect='{$bullet->effect}'";
}
if ($symbol != '&bull;')
echo "\n<div $attrs><li class='$class' style='list-style-type: none;'><tt>{$symbol}</tt> $markedText</li></div>";
echo "\n<li class='$class' style='list-style-type: none;'><div $attrs><tt>{$symbol}</tt> $markedText</div></li>";
else
echo "\n<div $attrs><li class='$class'>$markedText</li></div>";
echo "\n<li class='$class'><div $attrs>$markedText</div></li>";
} else {
echo "\n<div $eff_str style=\"position: relative;\"><li style=\"$style\">".'<tt>'.$symbol.'</tt> '.$markedText."</li></div>\n";
}
@@ -751,7 +760,7 @@ type=\"application/x-shockwave-flash\" width=$example->iwidth height=$example->i
else $leader='';
if (empty($link->target)) $link->target = '_self';
if(!empty($link->text)) {
if ($this->pres->template == 'css') {
if ($this->pres->template == 'css') {
$class = '';
if (empty($link->class)) $link->class = 'link';
echo "<div class='{$link->class}'>".markup_text($leader)."<a href='{$link->href}' target='{$link->target}'>".markup_text($link->text)."</a></div>\n";
@@ -815,6 +824,9 @@ EOB;
<?php
}
break;
case 'css':
echo "</div>\n";
/* (this seemed too intrusive)
case 'php2':
if($this->nextTitle) {
@@ -827,6 +839,7 @@ EOB;
break;
*/
}
echo "</body>\n";
}
}
@@ -1298,10 +1311,11 @@ class pdf extends display {
pdf_set_info($this->pdf, "Subject", isset($presentation->topic)?$presentation->topic:"");
while(list($this->slideNum,$slide) = each($presentation->slides)) {
// testing hack
$slideDir = dirname($this->presentationDir.'/'.$presentation->slides[$this->slideNum]->filename).'/';
$fn = $this->presentationDir.'/'.$presentation->slides[$this->slideNum]->filename;
$r =& new XML_Slide($fn);
// testing hack
$slideDir = dirname($this->presentationDir.'/'.$presentation->slides[$this->slideNum]->filename).'/';
$fn = $this->presentationDir.'/'.$presentation->slides[$this->slideNum]->filename;
$fh = fopen($fn, "rb");
$r =& new XML_Slide($fh);
$r->setErrorHandling(PEAR_ERROR_DIE,"%s ($fn)\n");
$r->parse();

View File

@@ -1,4 +1,4 @@
<?/*
<?php /*
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
@@ -6,7 +6,7 @@
function is called if we don't have the dimensions already, or on a
resize event to fetch the new window dimensions.
*/?>
<script language="JavaScript" defer="defer">
<script type="text/javascript" language="JavaScript" defer="defer">
<!--
function get_dims() {
var winW = 1024;

View File

@@ -32,8 +32,8 @@
$i = 0;
foreach($ps as $pres_id=>$filename) {
$p = &new XML_Presentation($filename);
$fh = fopen($filename, "rb");
$p = &new XML_Presentation($fh);
$p->setErrorHandling(PEAR_ERROR_DIE,"%s\n");
$p->parse();
$pres = $p->getObjects();
@@ -75,7 +75,7 @@
unset($pres);
// default options for the file..
$p = &new XML_Presentation("index.xml");
$p = &new XML_Presentation(fopen("index.xml", "rb"));
$p->setErrorHandling(PEAR_ERROR_DIE,"%s\n");
$p->parse();
$pres = $p->getObjects();
@@ -87,7 +87,7 @@
<base href="<?php echo "http://".$_SERVER['HTTP_HOST'].$baseDir?>">
<title>PHP Presents</title>
<?php include("css.php"); ?>
<script language="JavaScript1.2">
<script language="JavaScript1.2" type="text/javascript">
<!--
function change_mode() {
document.cookie="display_mode="+document.modes_form.modes.options[document.modes_form.modes.selectedIndex].value+"|"+document.modes_form.speaker.checked;

View File

@@ -1,6 +1,6 @@
<script type="text/javascript" language="javascript" src="1k.js"></script>
<script type="text/javascript" language="javascript" src="slide.js"></script>
<script language="JavaScript1.2">
<script type="text/javascript" language="JavaScript1.2">
<!--
if(!document.all) {
window.captureEvents(Event.KEYUP);

View File

@@ -1,5 +1,5 @@
<?php
error_reporting(E_ALL);
/// error_reporting(E_ALL);
require_once 'config.php';
$c = compact('presentationDir', 'baseDir', 'showScript', 'helpPage', 'baseFontSize',
@@ -22,7 +22,8 @@
session_start();
// Figure out which presentation file to read and slide to show
$presFile = trim(trim($_SERVER['PATH_INFO']),'/');
$presFile = trim($_SERVER['PATH_INFO']);
$presFile = trim($presFile ,'/');
if (substr($presFile,-4) == ".pdf") {
$navmode = 'pdfus';
$presFile = substr($presFile, 0, -4);
@@ -36,7 +37,7 @@
Adding support for URLs such as
http://shiflett.org/talks/oscon2004/php-security
*/
$urlArray = explode('/', $presFile);
$urlArray = explode('/', (string) $presFile);
$slideNumIndex = sizeof($urlArray) - 1;
if ($urlArray[$slideNumIndex] == strval(intval($urlArray[$slideNumIndex]))) {
$slideNum = $urlArray[$slideNumIndex];
@@ -53,11 +54,12 @@
*/
if(!isset($_SESSION['titlesLoaded'])) $_SESSION['titlesLoaded'] = 0;
$presFile = str_replace('..','',$_SESSION['currentPres']); // anti-hack
$presFile = str_replace('..','',(string)$_SESSION['currentPres']); // anti-hack
$presFile = "$presentationDir/$presFile".'.xml';
// Load in the presentation
$p =& new XML_Presentation($presFile);
$fh = fopen($presFile, "rb");
$p =& new XML_Presentation($fh);
$p->setErrorHandling(PEAR_ERROR_DIE,"%s\n");
$p->parse();
$pres = $p->getObjects();
@@ -117,7 +119,8 @@
// Load the slide
$mode->slideDir = dirname($presentationDir.'/'.$pres->slides[$mode->slideNum]->filename).'/';
$r =& new XML_Slide($presentationDir.'/'.$pres->slides[$mode->slideNum]->filename);
$fh = fopen($presentationDir.'/'.$pres->slides[$mode->slideNum]->filename, "rb");
$r =& new XML_Slide($fh);
$r->setErrorHandling(PEAR_ERROR_DIE,"%s\n");
$r->parse();
// Display slide
@@ -128,9 +131,10 @@
function get_all_titles($pres) {
global $presentationDir;
reset($pres);
while(list($slideNum,$slide) = each($pres->slides)) {
$r =& new XML_Slide($presentationDir.'/'.$pres->slides[$slideNum]->filename);
// $r =& new XML_Slide($presentationDir.'/'.$pres->slides[$slideNum]->filename);
$fh = fopen($presentationDir.'/'.$pres->slides[$slideNum]->filename, "rb");
$r =& new XML_Slide($fh);
$r->parse();
$objs = $r->getObjects();