Handler: SlideShow

Compatible with: R5.x


Copy the file slideshow.php into the /handlers/page/-directory.
Works fine, if an unchanged version of the default-theme is in the themes-directory.
The handler is called with pagename/slideshow.


Example: SlideShow




/handlers/page/slideshow.php


<?php
/*
Handler "slide_show"

*/

if (!defined('IN_WACKO'))
{
    exit;
}

// redirect to show method if page don't exists
if (!$this->page)
{
    
$this->redirect($this->href('show'));
}

if (
$this->has_access('read'))
{
    
// TODO: define more options for splitting the page body
    // split the page
    
$body_f    $this->format($this->page['body']);
    
$body    preg_split('/(<h2 .*>.*<\/h2>)/'$body_f, -1PREG_SPLIT_DELIM_CAPTURE);

    if (isset(
$_GET['debug']) && $_GET['debug'] == 1)
    {
        echo 
"<div style=\"display: none\">\n";
        
$this->debug_print_r($body);
        echo 
"</div>\n\n";
    }

    
// If the first slide starts with a level 1 heading
    
if (preg_match('/^<h2 .*>.*<\/h2>/'$body_f))
    {
        
$first_slide 0;
    }
    else
    {
        
$first_slide 1;
    }

    
$user $this->get_user(); // echo $this->get_user();

    // we test all the parameters of the handler 'slide_show',
    // if there is none, this is the "slide = 1" parameter is invoked by default

    /*
    switch ($_GET["method"])
    {
        case "export":
            export();
            break;
        case "show":
            show_slide();
            break;
        default:
            show_slide();
            break;
    }
    */

    //if ($_GET["export"]) { return; }

    
if (!$body)
    {
        return;
    }
    else
    {
        
// If you do not specify a parameter, it defaults to the first slide
        
if (!isset($_GET['slide']) or $_GET['slide'] == 1)
        {
            
$slide 1;
        }
        else
        {
            
$slide = isset($_GET['slide']) ? $_GET['slide'] : '';
        }

            
// HTTP header with right Charset settings
        
header('Content-Type: text/html; charset='.$this->get_charset());
?>
        <!DOCTYPE html>
        <html lang="<?php echo $this->page['page_lang'?>">
<?php    echo
        
"<head>\n",
        
"<title>"htmlspecialchars($this->config['site_name'], ENT_COMPAT ENT_HTML401HTML_ENTITIES_CHARSET), ":", (isset($this->page['title']) ? $this->page['title'] : $this->add_spaces($this->tag)), "</title>\n",
        
"<meta name=\"robots\" content=\"noindex, nofollow\" />\n",
        
'<meta name="language" content="'.$this->page['page_lang'].'" />',
        
'<link rel="stylesheet" href="'.$this->config['theme_url'].'css/default.css" />',
        
'<link rel="shortcut icon" href="'.$this->config['theme_url'].'icon/favicon.ico" type="image/x-icon" />';


        if (!
file_exists($this->config['theme_url'].'css/slideshow.css'))
        {
            echo 
"<style type=\"text/css\">\n",
            
".slide { font-size: 160%; margin: 5%; background-color: #fff; padding: 30px; border: 1px inset; line-height: 1.5; }\n",
            
".slide UL, LI { font-size: 100%; }\n",
            
".slide LI LI { font-size: 90% }\n",
            
".sl_nav p { text-decoration: none; text-align: right; font-size: 80%; line-height: 0.4; }\n",
            
".sl_nav A { text-decoration: none; }\n",
            
".sl_nav a:hover { color: #CF8888 }\n",
            
"div.sl_nav  { padding: 10px 20px 10px 0; }\n",
            
".page { background-color: #d1d1d1 }\n",
            
".sum { font-size: 8px; }\n",
            
"</style>\n";
        }
        else
        {
            echo 
'<link rel="stylesheet" href="'.$this->config['theme_url'].'css/slideshow.css" />';
        }

        echo
        
"</head>\n\n";

        
// displays the body of the page
        
echo
        
"<body >\n";
        
        
// display summary (incomplete!)
        /*
        if (isset($_GET['sum']) && $_GET['sum'] == 'on')
        {
            echo "<ul class=\"sum\">\n";

            if ($first_slide = 1)
            {
                echo "<li>", $this->format($body[0]), "</li>\n";
            }

            $i = 0;

            foreach ($body as $title_sum)
            {
                $i        = $i + 1;
                $type    = gettype($i / 2);
                
                // returns only the first 50 characters of the title
                #$title_sum = substr($title_sum, 0, 50);

                if ($type == "integer")
                {
                    echo "<li>",$this->format($title_sum, 'wacko'),"</li>\n";
                }
            }
            
            echo "</ul>\n\n";
        }
        */

        // display navigation menu
        
$navigation =    "<div class=\"sl_nav\">\n".
                        
"<p>";

        
// If this is not the first slide, we display links "<< previous" and "[start]"
        
if ($slide !== 1)
        {
            
$navigation .=    "<a href=\"".$this->href('slide_show''''slide='.($_GET['slide'] - 1))."\"> ".$this->_t('PrevAcr')."</a> ".
                            
"<a href=\"".$this->href('slide_show''''slide=1')."\">[Start]</a>\n";
        }

        
$navigation .= " ";

        if (isset(
$body[($slide) * - ($first_slide 2) + 2]) or $slide == 1)
        {
            
$navigation .=    "<a href=\"".$this->href('slide_show''''slide='.($slide 1))."\">".$this->_t('NextAcr')." </a>\n";
        }

        
$navigation .=    "</p>\n".
                        
"<p><a href=\"".$this->href('edit')."\">[edit] </a> ".
                            
"<a href=\"".$this->href()."\">[quit]</a></p>\n".
                        
"</div>\n\n";

        echo 
$navigation;

        echo 
"<div class=\"slide\">\n";

        
// showing content

        // if this is the first slide
        
if ($slide == and $first_slide == 1)
        {
            echo 
$body[0], "<br /><br />";
        }
        
// from the second slide
        
else
        {
            echo 
$body[($slide 2) - ($first_slide 2) - 1].$body[($slide 2) - ($first_slide 2)];
            echo 
"\n";
        }

        echo 
"</div>\n\n";

        echo 
$navigation;

        echo
        
"</body>\n",
        
"</html>";
    }
}
else
{
    
$message $this->_t('ReadAccessDenied');
    
$this->show_message($message'info');
}

// tweak
die (0);

?>

1. Documentation

uses heading H2 as page break


2. How to

example:

(1) Presentation
Slide 1

=== (2) Title ===
Slide 2

=== (3) Title ===
Slide 3

2.1. Localization (optional)


put this at the end of your language file


/lang/wacko.xyz.php

//hacks "YourPhrase" => "your translation here",

pls. notice that this entry will not survive an Wacko upgrade, so you have to redo this


[xyz] proposed translations
[de] ...
[fr]
[ru]

3. To Do

  • still a mess..
  • define more options for splitting the page body